diff --git a/dist/entry.js b/dist/entry.js index fe20753bd7..9110b1da2c 100644 --- a/dist/entry.js +++ b/dist/entry.js @@ -856,8 +856,8 @@ Blockly.Blocks.arduino_toggle_led = {init:function() { this.setNextStatement(!0); }}; Entry.block.arduino_toggle_led = function(b, a) { - var c = a.getNumberValue("VALUE"), d = a.getField("OPERATOR"); - Entry.hw.setDigitalPortValue(c, "on" == d ? 255 : 0); + var c = a.getNumberValue("VALUE"), d = "on" == a.getField("OPERATOR") ? 255 : 0; + Entry.hw.setDigitalPortValue(c, d); return a.callReturn(); }; Blockly.Blocks.arduino_toggle_pwm = {init:function() { @@ -1057,8 +1057,8 @@ Blockly.Blocks.dplay_select_led = {init:function() { Entry.block.dplay_select_led = function(b, a) { var c = a.getField("PORT"), d = 7; "7" == c ? d = 7 : "8" == c ? d = 8 : "9" == c ? d = 9 : "10" == c && (d = 10); - c = a.getField("OPERATOR"); - Entry.hw.setDigitalPortValue(d, "on" == c ? 255 : 0); + c = "on" == a.getField("OPERATOR") ? 255 : 0; + Entry.hw.setDigitalPortValue(d, c); return a.callReturn(); }; Blockly.Blocks.dplay_get_switch_status = {init:function() { @@ -2068,10 +2068,10 @@ Entry.block.wait_second = function(b, a) { } a.isStart = !0; a.timeFlag = 1; - var c = a.getNumberValue("SECOND", a); + var c = a.getNumberValue("SECOND", a), c = 60 / (Entry.FPS || 60) * c * 1E3; setTimeout(function() { a.timeFlag = 0; - }, 60 / (Entry.FPS || 60) * c * 1E3); + }, c); return a; }; Blockly.Blocks.repeat_basic = {init:function() { @@ -7807,12 +7807,7 @@ p.generateView = function(b, a) { this.view = c; Entry.isForLecture && c.addClass("lecture"); this.parentView_.appendChild(c); - if (!Entry.isForLecture) { - var d = Entry.createElement("div", "entryBlockHelperHeaderWorkspace"); - d.innerHTML = Lang.Helper.Block_info; - c.appendChild(d); - } - d = Entry.createElement("div", "entryBlockHelperContentWorkspace"); + var d = Entry.createElement("div", "entryBlockHelperContentWorkspace"); d.addClass("entryBlockHelperIntro"); Entry.isForLecture && d.addClass("lecture"); c.appendChild(d); @@ -15298,7 +15293,7 @@ Entry.BlockMenu = function(b, a, c, d) { b.getCategoryCodes = function(a) { a = this._convertSelector(a); var b = this._categoryCodes[a]; - b || (b = []); + b || (this._generateCategoryElement(a), b = []); b instanceof Entry.Code || (b = this._categoryCodes[a] = new Entry.Code(b)); return b; }; @@ -15427,18 +15422,21 @@ Entry.BlockMenu = function(b, a, c, d) { }; b._generateCategoryView = function(a) { if (a) { - for (var b = this, d = 0;d < a.length;d++) { - var e = a[d].category; - (function(a, d) { - a.text(Lang.Blocks[d.toUpperCase()]); - b._categoryElems[d] = a; - a.bindOnClick(function(a) { - b.selectMenu(d); - }); - })(Entry.Dom("li", {id:"entryCategory" + e, class:"entryCategoryElementWorkspace", parent:this._categoryCol}), e); + for (var b = 0;b < a.length;b++) { + this._generateCategoryElement(a[b].category); } } }; + b._generateCategoryElement = function(a) { + var b = this; + (function(a, e) { + a.text(Lang.Blocks[e.toUpperCase()]); + b._categoryElems[e] = a; + a.bindOnClick(function(a) { + b.selectMenu(e); + }); + })(Entry.Dom("li", {id:"entryCategory" + a, class:"entryCategoryElementWorkspace", parent:this._categoryCol}), a); + }; b.updateOffset = function() { this._offset = this.svgDom.offset(); }; diff --git a/dist/entry.min.js b/dist/entry.min.js index 597adc0aed..d6431e0056 100644 --- a/dist/entry.min.js +++ b/dist/entry.min.js @@ -86,7 +86,7 @@ Blockly.Blocks.arduino_get_pwm_port_number={init:function(){this.setColour("#009 Blockly.Blocks.arduino_get_number_sensor_value={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.ARDUINO_num_sensor_value_1);this.appendValueInput("VALUE").setCheck(["Number","String",null]);this.appendDummyInput().appendField(Lang.Blocks.ARDUINO_num_sensor_value_2).appendField(" ");this.setInputsInline(!0);this.setOutput(!0,"Number")}};Entry.block.arduino_get_number_sensor_value=function(b,a){var c=a.getValue("VALUE",a);return Entry.hw.getAnalogPortValue(c[1])}; Blockly.Blocks.arduino_get_digital_value={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.ARDUINO_get_digital_value_1);this.appendValueInput("VALUE").setCheck("Number");this.appendDummyInput().appendField(Lang.Blocks.ARDUINO_num_sensor_value_2).appendField(" ");this.setInputsInline(!0);this.setOutput(!0,"Boolean")}};Entry.block.arduino_get_digital_value=function(b,a){var c=a.getNumberValue("VALUE",a);return Entry.hw.getDigitalPortValue(c)}; Blockly.Blocks.arduino_toggle_led={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.ARDUINO_num_pin_1);this.appendValueInput("VALUE").setCheck(["Number","String",null]);this.appendDummyInput().appendField(Lang.Blocks.ARDUINO_num_pin_2);this.appendDummyInput().appendField(new Blockly.FieldDropdown([[Lang.Blocks.ARDUINO_on,"on"],[Lang.Blocks.ARDUINO_off,"off"]]),"OPERATOR").appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*")); -this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.arduino_toggle_led=function(b,a){var c=a.getNumberValue("VALUE"),d=a.getField("OPERATOR");Entry.hw.setDigitalPortValue(c,"on"==d?255:0);return a.callReturn()}; +this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.arduino_toggle_led=function(b,a){var c=a.getNumberValue("VALUE"),d="on"==a.getField("OPERATOR")?255:0;Entry.hw.setDigitalPortValue(c,d);return a.callReturn()}; Blockly.Blocks.arduino_toggle_pwm={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.ARDUINO_toggle_pwm_1);this.appendValueInput("PORT").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.ARDUINO_toggle_pwm_2);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.ARDUINO_toggle_pwm_3);this.appendDummyInput().appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png", "*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.arduino_toggle_pwm=function(b,a){var c=a.getNumberValue("PORT"),d=a.getNumberValue("VALUE"),d=Math.round(d),d=Math.max(d,0),d=Math.min(d,255);Entry.hw.setDigitalPortValue(c,d);return a.callReturn()}; Blockly.Blocks.arduino_convert_scale={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.ARDUINO_convert_scale_1);this.appendValueInput("VALUE1").setCheck(["Number","String",null]);this.appendDummyInput().appendField(Lang.Blocks.ARDUINO_convert_scale_2);this.appendValueInput("VALUE2").setCheck(["Number","String",null]);this.appendDummyInput().appendField(Lang.Blocks.ARDUINO_convert_scale_3);this.appendValueInput("VALUE3").setCheck(["Number","String",null]);this.appendDummyInput().appendField(Lang.Blocks.ARDUINO_convert_scale_4); @@ -114,7 +114,7 @@ Entry.block.CODEino_get_accelerometer_direction=function(b,a){var c=a.getField(" Blockly.Blocks.CODEino_get_accelerometer_value={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.CODEino_string_8).appendField(new Blockly.FieldDropdown([[Lang.Blocks.CODEino_accelerometer_X,"3"],[Lang.Blocks.CODEino_accelerometer_Y,"4"],[Lang.Blocks.CODEino_accelerometer_Z,"5"]]),"PORT").appendField(Lang.Blocks.CODEino_string_9);this.setOutput(!0,"Number");this.setInputsInline(!0)}}; Entry.block.CODEino_get_accelerometer_value=function(b,a){var c=265,d=402,e=-90,f=90,g=Entry.hw.getAnalogPortValue(a.getField("PORT",a));if(c>d)var h=c,c=d,d=h;e>f&&(h=e,e=f,f=h);g=(f-e)/(d-c)*(g-c);g+=e;g=Math.min(f,g);g=Math.max(e,g);return Math.round(g)}; Blockly.Blocks.dplay_select_led={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.ARDUINO_num_pin_1);this.appendDummyInput().appendField(new Blockly.FieldDropdown([["7","7"],["8","8"],["9","9"],["10","10"]]),"PORT");this.appendDummyInput().appendField(Lang.Blocks.dplay_num_pin_1);this.appendDummyInput().appendField(new Blockly.FieldDropdown([[Lang.Blocks.ARDUINO_on,"on"],[Lang.Blocks.ARDUINO_off,"off"]]),"OPERATOR").appendField(new Blockly.FieldIcon(Entry.mediaFilePath+ -"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.dplay_select_led=function(b,a){var c=a.getField("PORT"),d=7;"7"==c?d=7:"8"==c?d=8:"9"==c?d=9:"10"==c&&(d=10);c=a.getField("OPERATOR");Entry.hw.setDigitalPortValue(d,"on"==c?255:0);return a.callReturn()}; +"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.dplay_select_led=function(b,a){var c=a.getField("PORT"),d=7;"7"==c?d=7:"8"==c?d=8:"9"==c?d=9:"10"==c&&(d=10);c="on"==a.getField("OPERATOR")?255:0;Entry.hw.setDigitalPortValue(d,c);return a.callReturn()}; Blockly.Blocks.dplay_get_switch_status={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("\ub514\uc9c0\ud138 ");this.appendDummyInput().appendField(new Blockly.FieldDropdown([["2","2"],["4","4"]]),"PORT");this.appendDummyInput().appendField(Lang.Blocks.dplay_num_pin_2).appendField(new Blockly.FieldDropdown([[Lang.Blocks.dplay_string_5,"ON"],[Lang.Blocks.dplay_string_6,"OFF"]]),"STATUS").appendField(" ");this.setInputsInline(!0);this.setOutput(!0,"Boolean")}}; Entry.block.dplay_get_switch_status=function(b,a){var c=a.getField("PORT"),d=2;"2"==c?d=2:"4"==c&&(d=4);return"OFF"==a.getField("STATUS")?1==Entry.hw.getDigitalPortValue(d)?1:0:0==Entry.hw.getDigitalPortValue(d)?1:0}; Blockly.Blocks.dplay_get_light_status={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.dplay_light).appendField(new Blockly.FieldDropdown([[Lang.Blocks.dplay_string_3,"BRIGHT"],[Lang.Blocks.dplay_string_4,"DARK"]]),"STATUS").appendField(" ");this.setInputsInline(!0);this.setOutput(!0,"Boolean")}}; @@ -231,7 +231,7 @@ Entry.block.quotient_and_mod=function(b,a){var c=a.getNumberValue("LEFTHAND",a), Blockly.Blocks.choose_project_timer_action={init:function(){this.setColour(calcBlockColor);this.appendDummyInput().appendField(Lang.Blocks.CALC_choose_project_timer_action_1,calcFontColor).appendField(new Blockly.FieldDropdown([[Lang.Blocks.CALC_choose_project_timer_action_sub_1,"START"],[Lang.Blocks.CALC_choose_project_timer_action_sub_2,"STOP"],[Lang.Blocks.CALC_choose_project_timer_action_sub_3,"RESET"]],null,!0,calcArrowColor),"ACTION").appendField(Lang.Blocks.CALC_choose_project_timer_action_2, calcFontColor).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/calc_01.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)},whenAdd:function(){Entry.engine&&Entry.engine.showProjectTimer()},whenRemove:function(b){Entry.engine&&Entry.engine.hideProjectTimer(b)}}; Entry.block.choose_project_timer_action=function(b,a){var c=a.getField("ACTION"),d=Entry.engine,e=d.projectTimer;"START"==c?e.isInit?e.isInit&&e.isPaused&&(e.pauseStart&&(e.pausedTime+=(new Date).getTime()-e.pauseStart),delete e.pauseStart,e.isPaused=!1):d.startProjectTimer():"STOP"==c?e.isInit&&!e.isPaused&&(e.isPaused=!0,e.pauseStart=(new Date).getTime()):"RESET"==c&&e.isInit&&(e.setValue(0),e.start=(new Date).getTime(),e.pausedTime=0,delete e.pauseStart);return a.callReturn()};Blockly.Blocks.wait_second={init:function(){this.setColour("#498deb");this.appendDummyInput().appendField(Lang.Blocks.FLOW_wait_second_1);this.appendValueInput("SECOND").setCheck(["Number","String",null]);this.appendDummyInput().appendField(Lang.Blocks.FLOW_wait_second_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/flow_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.wait_second=function(b,a){if(a.isStart){if(1==a.timeFlag)return a;delete a.timeFlag;delete a.isStart;Entry.engine.isContinue=!1;return a.callReturn()}a.isStart=!0;a.timeFlag=1;var c=a.getNumberValue("SECOND",a);setTimeout(function(){a.timeFlag=0},60/(Entry.FPS||60)*c*1E3);return a}; +Entry.block.wait_second=function(b,a){if(a.isStart){if(1==a.timeFlag)return a;delete a.timeFlag;delete a.isStart;Entry.engine.isContinue=!1;return a.callReturn()}a.isStart=!0;a.timeFlag=1;var c=a.getNumberValue("SECOND",a),c=60/(Entry.FPS||60)*c*1E3;setTimeout(function(){a.timeFlag=0},c);return a}; Blockly.Blocks.repeat_basic={init:function(){this.setColour("#498deb");this.appendDummyInput().appendField(Lang.Blocks.FLOW_repeat_basic_1);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.FLOW_repeat_basic_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/flow_03.png","*"));this.appendStatementInput("DO");this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; Entry.block.repeat_basic=function(b,a){var c;if(!a.isLooped){a.isLooped=!0;c=a.getNumberValue("VALUE",a);if(0>c)throw Error(Lang.Blocks.FLOW_repeat_basic_errorMsg);a.iterCount=Math.floor(c)}if(0==a.iterCount||0>a.iterCount)return delete a.isLooped,delete a.iterCount,a.callReturn();a.iterCount--;return a.getStatement("DO",a)}; Blockly.Blocks.repeat_inf={init:function(){this.setColour("#498deb");this.appendDummyInput().appendField(Lang.Blocks.FLOW_repeat_inf).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/flow_03.png","*"));this.appendStatementInput("DO");this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.repeat_inf=function(b,a){a.isLooped=!0;return a.getStatement("DO")}; @@ -801,9 +801,9 @@ this.parent.objectType&&(b.colour=this.getColour(),b.text=this.getText(),b.textA Entry.EntityObject.prototype.removeBrush=function(){Entry.stage.selectedObjectContainer.removeChild(this.shape);this.shape=this.brush=null}; Entry.EntityObject.prototype.updateBG=function(){if(this.bgObject){this.bgObject.graphics.clear();var b=this.getWidth(),a=this.getHeight();this.bgObject.graphics.setStrokeStyle(1).beginStroke().beginFill(this.getBGColour()).drawRect(-b/2,-a/2,b,a);if(this.getLineBreak())this.bgObject.x=0;else switch(this.getTextAlign()){case Entry.TEXT_ALIGN_LEFT:this.bgObject.x=b/2;break;case Entry.TEXT_ALIGN_CENTER:this.bgObject.x=0;break;case Entry.TEXT_ALIGN_RIGHT:this.bgObject.x=-b/2}}}; Entry.EntityObject.prototype.alignTextBox=function(){if("textBox"==this.type){var b=this.textObject;if(this.lineBreak){var a=b.getMeasuredLineHeight();b.y=a/2-this.getHeight()/2;switch(this.textAlign){case Entry.TEXT_ALIGN_CENTER:b.x=0;break;case Entry.TEXT_ALIGN_LEFT:b.x=-this.getWidth()/2;break;case Entry.TEXT_ALIGN_RIGHT:b.x=this.getWidth()/2}b.maxHeight=this.getHeight()}else b.x=0,b.y=0}};Entry.EntityObject.prototype.syncDialogVisible=function(){this.dialog&&(this.dialog.object.visible=this.visible)};Entry.Helper=function(){this.visible=!1};p=Entry.Helper.prototype; -p.generateView=function(b,a){if(!this.parentView_){this.parentView_=b;this.blockHelpData=EntryStatic.blockInfo;var c=Entry.createElement("div","entryBlockHelperWorkspace");this.view=c;Entry.isForLecture&&c.addClass("lecture");this.parentView_.appendChild(c);if(!Entry.isForLecture){var d=Entry.createElement("div","entryBlockHelperHeaderWorkspace");d.innerHTML=Lang.Helper.Block_info;c.appendChild(d)}d=Entry.createElement("div","entryBlockHelperContentWorkspace");d.addClass("entryBlockHelperIntro"); -Entry.isForLecture&&d.addClass("lecture");c.appendChild(d);this.blockHelperContent_=d;this.blockHelperView_=c;c=Entry.createElement("div","entryBlockHelperBlockWorkspace");this.blockHelperContent_.appendChild(c);d=Entry.createElement("div","entryBlockHelperDescriptionWorkspace");this.blockHelperContent_.appendChild(d);d.innerHTML=Lang.Helper.Block_click_msg;this.blockHelperDescription_=d;this._renderView=new Entry.RenderView($(c),"LEFT");this.code=new Entry.Code([]);this._renderView.changeCode(this.code); -this.first=!0}};p.bindWorkspace=function(b){b&&(this._blockViewObserver&&this._blockViewObserver.destroy(),this.workspace=b,this._blockViewObserver=b.observe(this,"_updateSelectedBlock",["selectedBlockView"]))};p._updateSelectedBlock=function(){var b=this.workspace.selectedBlockView;if(b&&this.visible&&b!=this._blockView){var a=b.block.type;this._blockView=b;this.renderBlock(a)}}; +p.generateView=function(b,a){if(!this.parentView_){this.parentView_=b;this.blockHelpData=EntryStatic.blockInfo;var c=Entry.createElement("div","entryBlockHelperWorkspace");this.view=c;Entry.isForLecture&&c.addClass("lecture");this.parentView_.appendChild(c);var d=Entry.createElement("div","entryBlockHelperContentWorkspace");d.addClass("entryBlockHelperIntro");Entry.isForLecture&&d.addClass("lecture");c.appendChild(d);this.blockHelperContent_=d;this.blockHelperView_=c;c=Entry.createElement("div","entryBlockHelperBlockWorkspace"); +this.blockHelperContent_.appendChild(c);d=Entry.createElement("div","entryBlockHelperDescriptionWorkspace");this.blockHelperContent_.appendChild(d);d.innerHTML=Lang.Helper.Block_click_msg;this.blockHelperDescription_=d;this._renderView=new Entry.RenderView($(c),"LEFT");this.code=new Entry.Code([]);this._renderView.changeCode(this.code);this.first=!0}}; +p.bindWorkspace=function(b){b&&(this._blockViewObserver&&this._blockViewObserver.destroy(),this.workspace=b,this._blockViewObserver=b.observe(this,"_updateSelectedBlock",["selectedBlockView"]))};p._updateSelectedBlock=function(){var b=this.workspace.selectedBlockView;if(b&&this.visible&&b!=this._blockView){var a=b.block.type;this._blockView=b;this.renderBlock(a)}}; p.renderBlock=function(b){var a=Lang.Helper[b];if(b&&this.visible&&a&&!Entry.block[b].isPrimitive){this.first&&(this.blockHelperContent_.removeClass("entryBlockHelperIntro"),this.first=!1);this.code.clear();var c=Entry.block[b].def,c=c||{type:b};this.code.createThread([c]);this.code.board.align();this.code.board.resize();var c=this.code.getThreads()[0].getFirstBlock().view,d=c.svgGroup.getBBox();b=d.width;d=d.height;c=c.getSkeleton().box(c).offsetX;isNaN(c)&&(c=0);this.blockHelperDescription_.innerHTML= a;this._renderView.align();$(this.blockHelperDescription_).css({top:d+30});this._renderView.svgDom.css({"margin-left":-(b/2)-20-c})}};p.getView=function(){return this.view};p.resize=function(){};Entry.Activity=function(b,a){this.name=b;this.timestamp=new Date;var c=[];if(void 0!==a)for(var d=0,e=a.length;de)var h=d,d=e,e=h;f>g&&(h=f,f=g,g=h);c-=d;c*=(g-f)/(e-d);c+=f;c=Math.min(g,c);c=Math.max(f, c);return Math.round(c)}},sensorBoard_get_named_sensor_value:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],params:[{type:"Dropdown",options:[["\uc18c\ub9ac","0"],["\ube5b \uac10\uc9c0","1"],["\uc2ac\ub77c\uc774\ub354","2"],["\uc628\ub3c4","3"]],value:"0",fontSize:11}],events:{},def:{params:[null],type:"sensorBoard_get_named_sensor_value"},paramsKeyMap:{PORT:0},"class":"sensorBoard",isNotFor:["sensorBoard"],func:function(b,a){return Entry.hw.getAnalogPortValue(a.getField("PORT", @@ -1517,7 +1517,7 @@ null,null],type:"quotient_and_mod"},paramsKeyMap:{LEFTHAND:1,RIGHTHAND:3,OPERATO "START"],[Lang.Blocks.CALC_choose_project_timer_action_sub_2,"STOP"],[Lang.Blocks.CALC_choose_project_timer_action_sub_3,"RESET"]],value:"START",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_CALC},{type:"Text",text:Lang.Blocks.CALC_choose_project_timer_action_2,color:"#3D3D3D"},{type:"Indicator",img:"block_icon/calc_01.png",size:12}],events:{viewAdd:[function(){Entry.engine&&Entry.engine.showProjectTimer()}],dataDestroy:[function(b){Entry.engine&&Entry.engine.hideProjectTimer(b)}]},def:{params:[null, "START",null,null],type:"choose_project_timer_action"},paramsKeyMap:{ACTION:1},"class":"calc_timer",isNotFor:[],func:function(b,a){var c=a.getField("ACTION"),d=Entry.engine,e=d.projectTimer;"START"==c?e.isInit?e.isInit&&e.isPaused&&(e.pauseStart&&(e.pausedTime+=(new Date).getTime()-e.pauseStart),delete e.pauseStart,e.isPaused=!1):d.startProjectTimer():"STOP"==c?e.isInit&&!e.isPaused&&(e.isPaused=!0,e.pauseStart=(new Date).getTime()):"RESET"==c&&e.isInit&&(e.setValue(0),e.start=(new Date).getTime(), e.pausedTime=0,delete e.pauseStart);return a.callReturn()}},wait_second:{color:"#498deb",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/flow_03.png",size:12}],events:{},def:{params:[{type:"number",params:["2"]},null],type:"wait_second"},paramsKeyMap:{SECOND:0},"class":"delay",isNotFor:[],func:function(b,a){if(a.isStart){if(1==a.timeFlag)return a;delete a.timeFlag;delete a.isStart;Entry.engine.isContinue=!1;return a.callReturn()}a.isStart=!0; -a.timeFlag=1;var c=a.getNumberValue("SECOND",a);setTimeout(function(){a.timeFlag=0},60/(Entry.FPS||60)*c*1E3);return a}},repeat_basic:{color:"#498deb",skeleton:"basic_loop",statements:[{accept:"basic"}],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/flow_03.png",size:12}],events:{},def:{params:[{type:"number",params:["10"]},null],type:"repeat_basic"},paramsKeyMap:{VALUE:0},statementsKeyMap:{DO:0},"class":"repeat",isNotFor:[],func:function(b,a){var c;if(!a.isLooped){a.isLooped= +a.timeFlag=1;var c=a.getNumberValue("SECOND",a),c=60/(Entry.FPS||60)*c*1E3;setTimeout(function(){a.timeFlag=0},c);return a}},repeat_basic:{color:"#498deb",skeleton:"basic_loop",statements:[{accept:"basic"}],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/flow_03.png",size:12}],events:{},def:{params:[{type:"number",params:["10"]},null],type:"repeat_basic"},paramsKeyMap:{VALUE:0},statementsKeyMap:{DO:0},"class":"repeat",isNotFor:[],func:function(b,a){var c;if(!a.isLooped){a.isLooped= !0;c=a.getNumberValue("VALUE",a);if(0>c)throw Error(Lang.Blocks.FLOW_repeat_basic_errorMsg);a.iterCount=Math.floor(c)}if(0==a.iterCount||0>a.iterCount)return delete a.isLooped,delete a.iterCount,a.callReturn();a.iterCount--;return a.getStatement("DO",a)}},repeat_inf:{color:"#498deb",skeleton:"basic_loop",statements:[{accept:"basic"}],params:[{type:"Indicator",img:"block_icon/flow_03.png",size:12}],events:{},def:{params:[null],type:"repeat_inf"},statementsKeyMap:{DO:0},"class":"repeat",isNotFor:[], func:function(b,a){a.isLooped=!0;return a.getStatement("DO")}},stop_repeat:{color:"#498deb",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/flow_03.png",size:12}],events:{},def:{params:[null],type:"stop_repeat"},"class":"repeat",isNotFor:[],func:function(b,a){return this.executor.breakLoop()}},wait_until_true:{color:"#498deb",skeleton:"basic",statements:[],params:[{type:"Block",accept:"boolean"},{type:"Indicator",img:"block_icon/flow_03.png",size:12}],events:{},def:{params:[{type:"True"}, null],type:"wait_until_true"},paramsKeyMap:{BOOL:0},"class":"wait",isNotFor:[],func:function(b,a){return a.getBooleanValue("BOOL",a)?a.callReturn():a}},_if:{color:"#498deb",skeleton:"basic_loop",statements:[{accept:"basic"}],params:[{type:"Block",accept:"boolean"},{type:"Indicator",img:"block_icon/flow_03.png",size:12}],events:{},def:{params:[{type:"True"},null],type:"_if"},paramsKeyMap:{BOOL:0},statementsKeyMap:{STACK:0},"class":"condition",isNotFor:[],func:function(b,a){return a.isCondition?(delete a.isCondition, @@ -1841,7 +1841,7 @@ arrowColor:EntryStatic.ARROW_COLOR_HW}],events:{},def:{params:[null,null],type:" params:[{type:"Dropdown",options:[["2","2"],["4","4"]],value:"2",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW},{type:"Dropdown",options:[["\uc67c\ucabd","LEFT"],["\uc624\ub978\ucabd","LIGHT"]],value:"LEFT",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW}],events:{},def:{params:[null,null],type:"dplay_get_tilt"},paramsKeyMap:{PORT:0,STATUS:1},"class":"dplay_get",isNotFor:["dplay"],func:function(b,a){var c=a.getField("PORT"),d=2;"2"==c?d=2:"4"==c&&(d=4);return"LIGHT"==a.getField("STATUS")?1== Entry.hw.getDigitalPortValue(d)?1:0:0==Entry.hw.getDigitalPortValue(d)?1:0}},dplay_toggle_led:{parent:"arduino_toggle_led",isNotFor:["dplay"],def:{params:[{type:"arduino_get_port_number"},null,null],type:"dplay_toggle_led"},"class":"dplay_set"},dplay_toggle_pwm:{parent:"arduino_toggle_pwm",isNotFor:["dplay"],def:{params:[{type:"arduino_get_pwm_port_number"},{type:"arduino_text",params:["255"]},null],type:"dplay_toggle_pwm"},"class":"dplay_set"},dplay_select_led:{color:"#00979D",fontColor:"#FFF",skeleton:"basic", statements:[],template:"\ub514\uc9c0\ud138 %1 LED \uc0c1\ud0dc\ub97c %2 %3",params:[{type:"Dropdown",options:[["7","7"],["8","8"],["9","9"],["10","10"],["12","12"],["13","13"]],value:"7",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW},{type:"Dropdown",options:[["\ucf1c\uae30","ON"],["\ub044\uae30","OFF"]],value:"ON",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,null,null],type:"dplay_select_led"},paramsKeyMap:{PORT:0, -OPERATOR:1},"class":"dplay_set",isNotFor:["dplay"],func:function(b,a){var c=a.getField("PORT"),d=7;"7"==c?d=7:"8"==c?d=8:"9"==c?d=9:"10"==c?d=10:"12"==c?d=12:"13"==c&&(d=13);c=a.getField("OPERATOR");Entry.hw.setDigitalPortValue(d,"ON"==c?255:0);return a.callReturn()}},dplay_DCmotor:{color:"#00979D",fontColor:"#FFF",skeleton:"basic",statements:[],template:"%1 DC\ubaa8\ud130 \uc0c1\ud0dc\ub97c %2 %3",params:[{type:"Dropdown",options:[["\uc67c\ucabd","1"],["\uc624\ub978\ucabd","2"],["\uc591\ucabd", +OPERATOR:1},"class":"dplay_set",isNotFor:["dplay"],func:function(b,a){var c=a.getField("PORT"),d=7;"7"==c?d=7:"8"==c?d=8:"9"==c?d=9:"10"==c?d=10:"12"==c?d=12:"13"==c&&(d=13);c="ON"==a.getField("OPERATOR")?255:0;Entry.hw.setDigitalPortValue(d,c);return a.callReturn()}},dplay_DCmotor:{color:"#00979D",fontColor:"#FFF",skeleton:"basic",statements:[],template:"%1 DC\ubaa8\ud130 \uc0c1\ud0dc\ub97c %2 %3",params:[{type:"Dropdown",options:[["\uc67c\ucabd","1"],["\uc624\ub978\ucabd","2"],["\uc591\ucabd", "3"]],value:"1",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW},{type:"Dropdown",options:[["\uc815\ubc29\ud5a5","FRONT"],["\uc5ed\ubc29\ud5a5","REAR"],["\uc815\uc9c0","OFF"]],value:"FRONT",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,null,null],type:"dplay_DCmotor"},paramsKeyMap:{PORT:0,OPERATOR:1},"class":"dplay_set",isNotFor:["dplay"],func:function(b,a){var c=a.getField("PORT"),d=0,e=0,f=0,g=0;"1"== c?(d=3,e=5):"2"==c?(d=6,e=11):"3"==c&&(d=3,e=5,f=11,g=6);var c=Entry.dplay.vel_value,h=a.getField("OPERATOR"),k=0,l=0;"FRONT"==h?(k=c,l=0):"REAR"==h?(k=0,l=c):"OFF"==h&&(l=k=0);Entry.hw.setDigitalPortValue(d,l);Entry.hw.setDigitalPortValue(e,k);Entry.hw.setDigitalPortValue(f,l);Entry.hw.setDigitalPortValue(g,k);return a.callReturn()}},dplay_DCmotor_speed:{color:"#00979D",fontColor:"#FFF",skeleton:"basic",statements:[],template:"%1 DC\ubaa8\ud130 \uc18d\ub3c4\ub97c %2(\uc73c)\ub85c \uc815\ud558\uae30 %3", params:[{type:"Dropdown",options:[["\uc67c\ucabd","1"],["\uc624\ub978\ucabd","2"],["\uc591\ucabd","3"]],value:"1",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,{type:"text",params:["100"]},null],type:"dplay_DCmotor_speed"},paramsKeyMap:{PORT:0,VALUE:1},"class":"dplay_set",isNotFor:["dplay"],func:function(b,a){var c=a.getField("PORT"),d=0,e=0,f=0,g=0;"1"==c?(d=3,e=5):"2"==c? @@ -1875,14 +1875,15 @@ b.getMode())&&Entry.GlobalSvg.addControl(a);else if(g.code&&(b=e.block,d=b.getTh this._boardBlockView;if(a){this.workspace.getBoard();this._boardBlockView=null;var b=Entry.GlobalSvg.left,d=Entry.GlobalSvg.width/2,a=a.getBoard().offset().left;return bthis._bannedClass.indexOf(a)&&this._bannedClass.push(a);this.align(b)};b.unbanClass=function(a,b){var d=this._bannedClass.indexOf(a);-1b&&(a.preventDefault(), -this.selectMenu(b-49))};b.setPatternRectFill=function(a){this.patternRect.attr({fill:a})};b._clearCategory=function(){this._selectedCategoryView=null;this._categories=[];var a=this._categoryElems,b;for(b in a)a[b].remove();this._categoryElems={};a=this._categoryCodes;for(b in a){var d=a[b];d.constructor==Entry.Code&&d.clear()}this._categoryCodes=null};b.setCategoryData=function(a){this._clearCategory();this._categoryData=a;this._generateCategoryView(a);this._generateCategoryCodes(a)};b._generateCategoryView= -function(a){if(a)for(var b=this,d=0;dthis._bannedClass.indexOf(a)&&this._bannedClass.push(a);this.align(b)};b.unbanClass=function(a,b){var d=this._bannedClass.indexOf(a);-1b&&(a.preventDefault(),this.selectMenu(b-49))};b.setPatternRectFill=function(a){this.patternRect.attr({fill:a})};b._clearCategory=function(){this._selectedCategoryView=null;this._categories=[];var a=this._categoryElems,b;for(b in a)a[b].remove();this._categoryElems={};a=this._categoryCodes;for(b in a){var d=a[b];d.constructor==Entry.Code&&d.clear()}this._categoryCodes=null};b.setCategoryData=function(a){this._clearCategory(); +this._categoryData=a;this._generateCategoryView(a);this._generateCategoryCodes(a)};b._generateCategoryView=function(a){if(a)for(var b=0;b=b?this.setVisible(!1):this.setVisible(!0)};b._reset=function(){this.vY=0;this.vScrollbar.attr({y:this.vY});this.resizeScrollBar()};b.onMouseDown=function(a){function b(a){a.stopPropagation&&a.stopPropagation();a.preventDefault&&a.preventDefault();a=a.originalEvent&&a.originalEvent.touches?a.originalEvent.touches[0]:a;var c=e.dragInstance; diff --git a/src/helper.js b/src/helper.js index f8f53c4805..35a143ff4f 100644 --- a/src/helper.js +++ b/src/helper.js @@ -24,12 +24,12 @@ p.generateView = function(parentView, option) { if (Entry.isForLecture) blockHelperView.addClass('lecture'); helper.parentView_.appendChild(blockHelperView); - if (!Entry.isForLecture) { - var blockHelperHeader = Entry.createElement('div', - 'entryBlockHelperHeaderWorkspace'); - blockHelperHeader.innerHTML = Lang.Helper.Block_info; - blockHelperView.appendChild(blockHelperHeader); - } + // if (!Entry.isForLecture) { + // var blockHelperHeader = Entry.createElement('div', + // 'entryBlockHelperHeaderWorkspace'); + // blockHelperHeader.innerHTML = Lang.Helper.Block_info; + // blockHelperView.appendChild(blockHelperHeader); + // } var blockHelperContent = Entry.createElement('div', 'entryBlockHelperContentWorkspace'); blockHelperContent.addClass('entryBlockHelperIntro'); diff --git a/src/workspace/block_menu.js b/src/workspace/block_menu.js index 8bba1db223..e31d80c570 100644 --- a/src/workspace/block_menu.js +++ b/src/workspace/block_menu.js @@ -380,8 +380,10 @@ Entry.BlockMenu = function(dom, align, categoryData, scroll) { p.getCategoryCodes = function(selector) { var name = this._convertSelector(selector); var code = this._categoryCodes[name]; - if (!code) + if (!code) { + this._generateCategoryElement(name); code = []; + } if (!(code instanceof Entry.Code)) code = this._categoryCodes[name] = new Entry.Code(code); return code; @@ -588,26 +590,30 @@ Entry.BlockMenu = function(dom, align, categoryData, scroll) { p._generateCategoryView = function(data) { if (!data) return; - var that = this; for (var i=0; i