diff --git a/dist/entry.js b/dist/entry.js index b49cdd1bfd..93907525f9 100644 --- a/dist/entry.js +++ b/dist/entry.js @@ -112,6 +112,17 @@ var Entry = {block:{}, TEXT_ALIGN_CENTER:0, TEXT_ALIGN_LEFT:1, TEXT_ALIGN_RIGHT: c = c.tagName.toUpperCase(); !a.isEditing || "INPUT" === c && b || a.editObjectValues(!1); } +}, generateFunctionSchema:function(b) { + b = "func_" + b; + if (!Entry.block[b]) { + var a = function() { + }; + a.prototype = Entry.block.function_general; + a = new a; + a.changeEvent = new Entry.Event; + a.template = Lang.template.function_general; + Entry.block[b] = a; + } }}; window.Entry = Entry; Entry.Albert = {PORT_MAP:{leftWheel:0, rightWheel:0, buzzer:0, leftEye:0, rightEye:0, note:0, bodyLed:0, frontLed:0, padWidth:0, padHeight:0}, setZero:function() { @@ -12238,17 +12249,11 @@ Entry.Func = function(b) { this.blockMenuBlock = this.block = null; this.hashMap = {}; this.paramMap = {}; - var a = function() { - }; - a.prototype = Entry.block.function_general; - a = new a; - a.changeEvent = new Entry.Event; - a.template = Lang.template.function_general; - Entry.block["func_" + this.id] = a; + Entry.generateFunctionSchema(this.id); if (b) { b = this.content._blockMap; - for (var c in b) { - Entry.Func.registerParamBlock(b[c].type); + for (var a in b) { + Entry.Func.registerParamBlock(b[a].type); } Entry.Func.generateWsBlock(this); } @@ -13886,7 +13891,7 @@ Entry.VariableContainer.prototype.setVariables = function(b) { }; Entry.VariableContainer.prototype.setFunctions = function(b) { b && b.forEach(function(a) { - Entry.block["func_" + a.id] = !0; + Entry.generateFunctionSchema(a.id); }); for (var a in b) { var c = new Entry.Func(b[a]); diff --git a/dist/entry.min.js b/dist/entry.min.js index 6d0782f671..47f09a61ba 100644 --- a/dist/entry.min.js +++ b/dist/entry.min.js @@ -7,7 +7,8 @@ canvasWidth:480})},resizeElement:function(b){if("workspace"==Entry.type){var a=t a+"px";400<=a?Entry.engine.view_.removeClass("collapsed"):Entry.engine.view_.addClass("collapsed");Entry.playground.view_.style.left=a+.5+"px";Entry.propertyPanel.resize(a);var d=Entry.engine.view_.getElementsByClassName("entryAddButtonWorkspace_w")[0];d&&(Entry.objectAddable?(d.style.top=c+24+"px",d.style.width=.7*a+"px"):d.style.display="none");if(d=Entry.engine.view_.getElementsByClassName("entryRunButtonWorkspace_w")[0])Entry.objectAddable?(d.style.top=c+24+"px",d.style.left=.7*a+"px",d.style.width= .3*a+"px"):(d.style.left="2px",d.style.top=c+24+"px",d.style.width=a-4+"px");if(d=Entry.engine.view_.getElementsByClassName("entryStopButtonWorkspace_w")[0])Entry.objectAddable?(d.style.top=c+24+"px",d.style.left=.7*a+"px",d.style.width=.3*a+"px"):(d.style.left="2px",d.style.top=c+24+"px",d.style.width=a+"px");(a=b.menuWidth)?244>a?a=244:400svg").css({width:a-64+"px"});Entry.playground.mainWorkspace.blockMenu.setWidth(); $(".entryWorkspaceBoard").css({left:a+"px"});Entry.playground.resizeHandle_.style.left=a+"px";Entry.playground.variableViewWrapper_.style.width=a+"px";this.interfaceState=b}Entry.windowResized.notify()},getUpTime:function(){return(new Date).getTime()-this.startTime},addActivity:function(b){Entry.stateManager&&Entry.stateManager.addActivity(b)},startActivityLogging:function(){Entry.reporter&&Entry.reporter.start(Entry.projectId,window.user?window.user._id:null,Entry.startTime)},getActivityLog:function(){var b= -{};Entry.stateManager&&(b.activityLog=Entry.stateManager.activityLog_);return b},DRAG_MODE_NONE:0,DRAG_MODE_MOUSEDOWN:1,DRAG_MODE_DRAG:2,cancelObjectEdit:function(b){var a=Entry.playground.object;if(a){var c=b.target;b=0!==$(a.view_).find(c).length;c=c.tagName.toUpperCase();!a.isEditing||"INPUT"===c&&b||a.editObjectValues(!1)}}};window.Entry=Entry;Entry.Albert={PORT_MAP:{leftWheel:0,rightWheel:0,buzzer:0,leftEye:0,rightEye:0,note:0,bodyLed:0,frontLed:0,padWidth:0,padHeight:0},setZero:function(){var b=Entry.Albert.PORT_MAP,a=Entry.hw.sendQueue,c;for(c in b)a[c]=b[c];Entry.hw.update();b=Entry.Albert;b.tempo=60;b.removeAllTimeouts()},monitorTemplate:{imgPath:"hw/albert.png",width:387,height:503,listPorts:{oid:{name:"OID",type:"input",pos:{x:0,y:0}},buzzer:{name:Lang.Hw.buzzer,type:"output",pos:{x:0,y:0}},note:{name:Lang.Hw.note,type:"output", +{};Entry.stateManager&&(b.activityLog=Entry.stateManager.activityLog_);return b},DRAG_MODE_NONE:0,DRAG_MODE_MOUSEDOWN:1,DRAG_MODE_DRAG:2,cancelObjectEdit:function(b){var a=Entry.playground.object;if(a){var c=b.target;b=0!==$(a.view_).find(c).length;c=c.tagName.toUpperCase();!a.isEditing||"INPUT"===c&&b||a.editObjectValues(!1)}},generateFunctionSchema:function(b){b="func_"+b;if(!Entry.block[b]){var a=function(){};a.prototype=Entry.block.function_general;a=new a;a.changeEvent=new Entry.Event;a.template= +Lang.template.function_general;Entry.block[b]=a}}};window.Entry=Entry;Entry.Albert={PORT_MAP:{leftWheel:0,rightWheel:0,buzzer:0,leftEye:0,rightEye:0,note:0,bodyLed:0,frontLed:0,padWidth:0,padHeight:0},setZero:function(){var b=Entry.Albert.PORT_MAP,a=Entry.hw.sendQueue,c;for(c in b)a[c]=b[c];Entry.hw.update();b=Entry.Albert;b.tempo=60;b.removeAllTimeouts()},monitorTemplate:{imgPath:"hw/albert.png",width:387,height:503,listPorts:{oid:{name:"OID",type:"input",pos:{x:0,y:0}},buzzer:{name:Lang.Hw.buzzer,type:"output",pos:{x:0,y:0}},note:{name:Lang.Hw.note,type:"output", pos:{x:0,y:0}}},ports:{leftProximity:{name:Lang.Blocks.ALBERT_sensor_leftProximity,type:"input",pos:{x:178,y:401}},rightProximity:{name:Lang.Blocks.ALBERT_sensor_rightProximity,type:"input",pos:{x:66,y:359}},battery:{name:Lang.Blocks.ALBERT_sensor_battery,type:"input",pos:{x:88,y:368}},light:{name:Lang.Blocks.ALBERT_sensor_light,type:"input",pos:{x:127,y:391}},leftWheel:{name:Lang.Hw.leftWheel,type:"output",pos:{x:299,y:406}},rightWheel:{name:Lang.Hw.rightWheel,type:"output",pos:{x:22,y:325}},leftEye:{name:Lang.Hw.leftEye, type:"output",pos:{x:260,y:26}},rightEye:{name:Lang.Hw.rightEye,type:"output",pos:{x:164,y:13}},bodyLed:{name:Lang.Hw.body+" "+Lang.Hw.led,type:"output",pos:{x:367,y:308}},frontLed:{name:Lang.Hw.front+" "+Lang.Hw.led,pos:{x:117,y:410}}},mode:"both"},tempo:60,timeouts:[],removeTimeout:function(b){clearTimeout(b);var a=this.timeouts;b=a.indexOf(b);0<=b&&a.splice(b,1)},removeAllTimeouts:function(){var b=this.timeouts,a;for(a in b)clearTimeout(b[a]);this.timeouts=[]},name:"albert"}; Blockly.Blocks.albert_hand_found={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.ALBERT_hand_found);this.setOutput(!0,"Boolean");this.setInputsInline(!0)}};Entry.block.albert_hand_found=function(b,a){var c=Entry.hw.portData;return 40"+b.block+"").childNodes[0]};Entry.Func.prototype.destroy=function(){this.blockMenuBlock.destroy()}; -Entry.Func.edit=function(b){this.cancelEdit();this.targetFunc=b;this.initEditView(b.content);this.bindFuncChangeEvent();this.updateMenu()};Entry.Func.initEditView=function(b){this.menuCode||this.setupMenuCode();var a=Entry.playground.mainWorkspace;a.setMode(Entry.Workspace.MODE_OVERLAYBOARD);a.changeOverlayBoardCode(b);this._workspaceStateEvent=a.changeEvent.attach(this,this.endEdit)}; -Entry.Func.endEdit=function(b){this.unbindFuncChangeEvent();this._workspaceStateEvent.destroy();delete this._workspaceStateEvent;switch(b){case "save":this.save();case "cancelEdit":this.cancelEdit()}};Entry.Func.save=function(){this.targetFunc.generateBlock(!0);Entry.variableContainer.saveFunction(this.targetFunc)}; +{},b;for(b in this.data)a[b]=this.data[b];return a}})(Entry.Model);Entry.Func=function(b){this.id=b?b.id:Entry.generateHash();this.content=b?new Entry.Code(b.content):new Entry.Code([[{type:"function_create",copyable:!1,deletable:!1,x:40,y:40}]]);this.blockMenuBlock=this.block=null;this.hashMap={};this.paramMap={};Entry.generateFunctionSchema(this.id);if(b){b=this.content._blockMap;for(var a in b)Entry.Func.registerParamBlock(b[a].type);Entry.Func.generateWsBlock(this)}Entry.Func.registerFunction(this);Entry.Func.updateMenu()};Entry.Func.threads={}; +Entry.Func.registerFunction=function(b){if(Entry.playground){var a=Entry.playground.mainWorkspace;a&&(this._targetFuncBlock=a.getBlockMenu().getCategoryCodes("func").createThread([{type:"func_"+b.id}]),b.blockMenuBlock=this._targetFuncBlock)}};Entry.Func.executeFunction=function(b){var a=this.threads[b];if(a=Entry.Engine.computeThread(a.entity,a))return this.threads[b]=a,!0;delete this.threads[b];return!1};Entry.Func.clearThreads=function(){this.threads={}}; +Entry.Func.prototype.init=function(b){this.id=b.id;this.content=Blockly.Xml.textToDom(b.content);this.block=Blockly.Xml.textToDom(""+b.block+"").childNodes[0]};Entry.Func.prototype.destroy=function(){this.blockMenuBlock.destroy()};Entry.Func.edit=function(b){this.cancelEdit();this.targetFunc=b;this.initEditView(b.content);this.bindFuncChangeEvent();this.updateMenu()}; +Entry.Func.initEditView=function(b){this.menuCode||this.setupMenuCode();var a=Entry.playground.mainWorkspace;a.setMode(Entry.Workspace.MODE_OVERLAYBOARD);a.changeOverlayBoardCode(b);this._workspaceStateEvent=a.changeEvent.attach(this,this.endEdit)};Entry.Func.endEdit=function(b){this.unbindFuncChangeEvent();this._workspaceStateEvent.destroy();delete this._workspaceStateEvent;switch(b){case "save":this.save();case "cancelEdit":this.cancelEdit()}}; +Entry.Func.save=function(){this.targetFunc.generateBlock(!0);Entry.variableContainer.saveFunction(this.targetFunc)}; Entry.Func.syncFuncName=function(b){var a=0,c=[],c=b.split(" "),d="";b=[];b=Blockly.mainWorkspace.getAllBlocks();for(var e=0;eb.x_&&a.xe?!0:!1}; Entry.VariableContainer.prototype.getListById=function(b){var a=this.lists_,c=[];if(0