From a8936916a36fae960b908d05d81151b1ab3d0bee Mon Sep 17 00:00:00 2001 From: jykim Date: Wed, 13 Jul 2016 14:32:08 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B0=81=EB=8F=84=20=EB=B8=94=EB=A1=9D=20?= =?UTF-8?q?=EA=B4=80=EB=A0=A8=20=EC=9D=B4=EC=8A=88=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit boolgom/Entry#3383 --- dist/entry.js | 23629 ++++++++++++++++----------------- dist/entry.min.js | 3710 +++--- src/workspace/field/angle.js | 2 +- 3 files changed, 13632 insertions(+), 13709 deletions(-) diff --git a/dist/entry.js b/dist/entry.js index e392c8d977..df605ce2a0 100644 --- a/dist/entry.js +++ b/dist/entry.js @@ -1,14 +1,14 @@ -var Entry = {block:{}, TEXT_ALIGN_CENTER:0, TEXT_ALIGN_LEFT:1, TEXT_ALIGN_RIGHT:2, TEXT_ALIGNS:["center", "left", "right"], clipboard:null, loadProject:function(a) { - a || (a = Entry.getStartProject(Entry.mediaFilePath)); +var Entry = {block:{}, TEXT_ALIGN_CENTER:0, TEXT_ALIGN_LEFT:1, TEXT_ALIGN_RIGHT:2, TEXT_ALIGNS:["center", "left", "right"], clipboard:null, loadProject:function(b) { + b || (b = Entry.getStartProject(Entry.mediaFilePath)); "workspace" == this.type && Entry.stateManager.startIgnore(); - Entry.projectId = a._id; - Entry.variableContainer.setVariables(a.variables); - Entry.variableContainer.setMessages(a.messages); - Entry.scene.addScenes(a.scenes); + Entry.projectId = b._id; + Entry.variableContainer.setVariables(b.variables); + Entry.variableContainer.setMessages(b.messages); + Entry.scene.addScenes(b.scenes); Entry.stage.initObjectContainers(); - Entry.variableContainer.setFunctions(a.functions); - Entry.container.setObjects(a.objects); - Entry.FPS = a.speed ? a.speed : 60; + Entry.variableContainer.setFunctions(b.functions); + Entry.container.setObjects(b.objects); + Entry.FPS = b.speed ? b.speed : 60; createjs.Ticker.setFPS(Entry.FPS); "workspace" == this.type && setTimeout(function() { Entry.stateManager.endIgnore(); @@ -16,37 +16,35 @@ var Entry = {block:{}, TEXT_ALIGN_CENTER:0, TEXT_ALIGN_LEFT:1, TEXT_ALIGN_RIGHT: Entry.engine.projectTimer || Entry.variableContainer.generateTimer(); 0 === Object.keys(Entry.container.inputValue).length && Entry.variableContainer.generateAnswer(); Entry.start(); - return a; -}, exportProject:function(a) { - a || (a = {}); + return b; +}, exportProject:function(b) { + b || (b = {}); Entry.engine.isState("stop") || Entry.engine.toggleStop(); Entry.Func && Entry.Func.workspace && Entry.Func.workspace.visible && Entry.Func.cancelEdit(); - a.objects = Entry.container.toJSON(); - a.scenes = Entry.scene.toJSON(); - a.variables = Entry.variableContainer.getVariableJSON(); - a.messages = Entry.variableContainer.getMessageJSON(); - a.functions = Entry.variableContainer.getFunctionJSON(); - a.scenes = Entry.scene.toJSON(); - a.speed = Entry.FPS; - return a; -}, setBlockByText:function(a, b) { - a = []; - b = jQuery.parseXML(b).getElementsByTagName("category"); - for (var c = 0;c < b.length;c++) { - for (var d = b[c], e = {category:d.getAttribute("id"), blocks:[]}, d = d.childNodes, f = 0;f < d.length;f++) { - var g = d[f]; - !g.tagName || "BLOCK" != g.tagName.toUpperCase() && "BTN" != g.tagName.toUpperCase() || e.blocks.push(g.getAttribute("type")); - } - a.push(e); - } - Entry.playground.setBlockMenu(a); -}, setBlock:function(a, b) { - Entry.playground.setMenuBlock(a, b); + b.objects = Entry.container.toJSON(); + b.scenes = Entry.scene.toJSON(); + b.variables = Entry.variableContainer.getVariableJSON(); + b.messages = Entry.variableContainer.getMessageJSON(); + b.functions = Entry.variableContainer.getFunctionJSON(); + b.scenes = Entry.scene.toJSON(); + b.speed = Entry.FPS; + return b; +}, setBlockByText:function(b, a) { + for (var c = [], d = jQuery.parseXML(a).getElementsByTagName("category"), e = 0;e < d.length;e++) { + for (var f = d[e], g = {category:f.getAttribute("id"), blocks:[]}, f = f.childNodes, h = 0;h < f.length;h++) { + var k = f[h]; + !k.tagName || "BLOCK" != k.tagName.toUpperCase() && "BTN" != k.tagName.toUpperCase() || g.blocks.push(k.getAttribute("type")); + } + c.push(g); + } + Entry.playground.setBlockMenu(c); +}, setBlock:function(b, a) { + Entry.playground.setMenuBlock(b, a); }, enableArduino:function() { -}, initSound:function(a) { - a.path = a.fileurl ? a.fileurl : Entry.defaultPath + "/uploads/" + a.filename.substring(0, 2) + "/" + a.filename.substring(2, 4) + "/" + a.filename + a.ext; - Entry.soundQueue.loadFile({id:a.id, src:a.path, type:createjs.LoadQueue.SOUND}); -}, beforeUnload:function(a) { +}, initSound:function(b) { + b.path = b.fileurl ? b.fileurl : Entry.defaultPath + "/uploads/" + b.filename.substring(0, 2) + "/" + b.filename.substring(2, 4) + "/" + b.filename + b.ext; + Entry.soundQueue.loadFile({id:b.id, src:b.path, type:createjs.LoadQueue.SOUND}); +}, beforeUnload:function(b) { Entry.hw.closeConnection(); Entry.variableContainer.updateCloudVariables(); if ("workspace" == Entry.type && (localStorage && Entry.interfaceState && localStorage.setItem("workspace-interface", JSON.stringify(Entry.interfaceState)), !Entry.stateManager.isSaved())) { @@ -55,88 +53,88 @@ var Entry = {block:{}, TEXT_ALIGN_CENTER:0, TEXT_ALIGN_LEFT:1, TEXT_ALIGN_RIGHT: }, loadInterfaceState:function() { if ("workspace" == Entry.type) { if (localStorage && localStorage.getItem("workspace-interface")) { - var a = localStorage.getItem("workspace-interface"); - this.resizeElement(JSON.parse(a)); + var b = localStorage.getItem("workspace-interface"); + this.resizeElement(JSON.parse(b)); } else { this.resizeElement({menuWidth:280, canvasWidth:480}); } } -}, resizeElement:function(a) { +}, resizeElement:function(b) { if ("workspace" == Entry.type) { - var b = this.interfaceState; - !a.canvasWidth && b.canvasWidth && (a.canvasWidth = b.canvasWidth); - !a.menuWidth && this.interfaceState.menuWidth && (a.menuWidth = b.menuWidth); + var a = this.interfaceState; + !b.canvasWidth && a.canvasWidth && (b.canvasWidth = a.canvasWidth); + !b.menuWidth && this.interfaceState.menuWidth && (b.menuWidth = a.menuWidth); Entry.engine.speedPanelOn && Entry.engine.toggleSpeedPanel(); - (b = a.canvasWidth) ? 325 > b ? b = 325 : 720 < b && (b = 720) : b = 400; - a.canvasWidth = b; - var c = 9 * b / 16; - Entry.engine.view_.style.width = b + "px"; + (a = b.canvasWidth) ? 325 > a ? a = 325 : 720 < a && (a = 720) : a = 400; + b.canvasWidth = a; + var c = 9 * a / 16; + Entry.engine.view_.style.width = a + "px"; Entry.engine.view_.style.height = c + "px"; Entry.engine.view_.style.top = "40px"; Entry.stage.canvas.canvas.style.height = c + "px"; - Entry.stage.canvas.canvas.style.width = b + "px"; - 400 <= b ? Entry.engine.view_.removeClass("collapsed") : Entry.engine.view_.addClass("collapsed"); - Entry.playground.view_.style.left = b + .5 + "px"; - Entry.propertyPanel.resize(b); + Entry.stage.canvas.canvas.style.width = 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 * b + "px") : d.style.display = "none"); + 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 * b + "px", d.style.width = .3 * b + "px") : (d.style.left = "2px", d.style.top = c + 24 + "px", d.style.width = b - 4 + "px"); + 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 * b + "px", d.style.width = .3 * b + "px") : (d.style.left = "2px", d.style.top = c + 24 + "px", d.style.width = b + "px"); + 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"); } - (b = a.menuWidth) ? 244 > b ? b = 244 : 400 < b && (b = 400) : b = 264; - a.menuWidth = b; - $(".blockMenuContainer").css({width:b - 64 + "px"}); - $(".blockMenuContainer>svg").css({width:b - 64 + "px"}); + (a = b.menuWidth) ? 244 > a ? a = 244 : 400 < a && (a = 400) : a = 264; + b.menuWidth = a; + $(".blockMenuContainer").css({width:a - 64 + "px"}); + $(".blockMenuContainer>svg").css({width:a - 64 + "px"}); Entry.playground.mainWorkspace.blockMenu.setWidth(); - $(".entryWorkspaceBoard").css({left:b + "px"}); - Entry.playground.resizeHandle_.style.left = b + "px"; - Entry.playground.variableViewWrapper_.style.width = b + "px"; - this.interfaceState = a; + $(".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(a) { - Entry.stateManager && Entry.stateManager.addActivity(a); +}, 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 a = {}; - Entry.stateManager && (a.activityLog = Entry.stateManager.activityLog_); - return a; -}, DRAG_MODE_NONE:0, DRAG_MODE_MOUSEDOWN:1, DRAG_MODE_DRAG:2, cancelObjectEdit:function(a) { - var b = Entry.playground.object; - if (b) { - var c = a.target; - a = 0 !== $(b.view_).find(c).length; + 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(); - !b.isEditing || "INPUT" === c && a || b.editObjectValues(!1); + !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 a = Entry.Albert.PORT_MAP, b = Entry.hw.sendQueue, c; - for (c in a) { - b[c] = a[c]; + var b = Entry.Albert.PORT_MAP, a = Entry.hw.sendQueue, c; + for (c in b) { + a[c] = b[c]; } Entry.hw.update(); - a = Entry.Albert; - a.tempo = 60; - a.removeAllTimeouts(); + 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(a) { - clearTimeout(a); - var b = this.timeouts; - a = b.indexOf(a); - 0 <= a && b.splice(a, 1); +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 a = this.timeouts, b; - for (b in a) { - clearTimeout(a[b]); + var b = this.timeouts, a; + for (a in b) { + clearTimeout(b[a]); } this.timeouts = []; }, name:"albert"}; @@ -146,9 +144,9 @@ Blockly.Blocks.albert_hand_found = {init:function() { this.setOutput(!0, "Boolean"); this.setInputsInline(!0); }}; -Entry.block.albert_hand_found = function(a, b) { - a = Entry.hw.portData; - return 40 < a.leftProximity || 40 < a.rightProximity; +Entry.block.albert_hand_found = function(b, a) { + var c = Entry.hw.portData; + return 40 < c.leftProximity || 40 < c.rightProximity; }; Blockly.Blocks.albert_value = {init:function() { this.setColour("#00979D"); @@ -157,10 +155,9 @@ Blockly.Blocks.albert_value = {init:function() { this.setInputsInline(!0); this.setOutput(!0, "Number"); }}; -Entry.block.albert_value = function(a, b) { - a = Entry.hw.portData; - b = b.getField("DEVICE"); - return a[b]; +Entry.block.albert_value = function(b, a) { + var c = Entry.hw.portData, d = a.getField("DEVICE"); + return c[d]; }; Blockly.Blocks.albert_move_forward_for_secs = {init:function() { this.setColour("#00979D"); @@ -171,30 +168,29 @@ Blockly.Blocks.albert_move_forward_for_secs = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.albert_move_forward_for_secs = function(a, b) { - a = Entry.hw.sendQueue; - if (b.isStart) { - if (1 == b.timeFlag) { - return b; +Entry.block.albert_move_forward_for_secs = function(b, a) { + var c = Entry.hw.sendQueue; + if (a.isStart) { + if (1 == a.timeFlag) { + return a; } - delete b.isStart; - delete b.timeFlag; + delete a.isStart; + delete a.timeFlag; Entry.engine.isContinue = !1; - a.leftWheel = 0; - a.rightWheel = 0; - return b.callReturn(); + c.leftWheel = 0; + c.rightWheel = 0; + return a.callReturn(); } - b.isStart = !0; - b.timeFlag = 1; - a.leftWheel = 30; - a.rightWheel = 30; - a = 1E3 * b.getNumberValue("VALUE"); - var c = setTimeout(function() { - b.timeFlag = 0; - Entry.Albert.removeTimeout(c); - }, a); - Entry.Albert.timeouts.push(c); - return b; + a.isStart = !0; + a.timeFlag = 1; + c.leftWheel = 30; + c.rightWheel = 30; + var c = 1E3 * a.getNumberValue("VALUE"), d = setTimeout(function() { + a.timeFlag = 0; + Entry.Albert.removeTimeout(d); + }, c); + Entry.Albert.timeouts.push(d); + return a; }; Blockly.Blocks.albert_move_backward_for_secs = {init:function() { this.setColour("#00979D"); @@ -205,30 +201,29 @@ Blockly.Blocks.albert_move_backward_for_secs = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.albert_move_backward_for_secs = function(a, b) { - a = Entry.hw.sendQueue; - if (b.isStart) { - if (1 == b.timeFlag) { - return b; +Entry.block.albert_move_backward_for_secs = function(b, a) { + var c = Entry.hw.sendQueue; + if (a.isStart) { + if (1 == a.timeFlag) { + return a; } - delete b.isStart; - delete b.timeFlag; + delete a.isStart; + delete a.timeFlag; Entry.engine.isContinue = !1; - a.leftWheel = 0; - a.rightWheel = 0; - return b.callReturn(); + c.leftWheel = 0; + c.rightWheel = 0; + return a.callReturn(); } - b.isStart = !0; - b.timeFlag = 1; - a.leftWheel = -30; - a.rightWheel = -30; - a = 1E3 * b.getNumberValue("VALUE"); - var c = setTimeout(function() { - b.timeFlag = 0; - Entry.Albert.removeTimeout(c); - }, a); - Entry.Albert.timeouts.push(c); - return b; + a.isStart = !0; + a.timeFlag = 1; + c.leftWheel = -30; + c.rightWheel = -30; + var c = 1E3 * a.getNumberValue("VALUE"), d = setTimeout(function() { + a.timeFlag = 0; + Entry.Albert.removeTimeout(d); + }, c); + Entry.Albert.timeouts.push(d); + return a; }; Blockly.Blocks.albert_turn_for_secs = {init:function() { this.setColour("#00979D"); @@ -239,29 +234,28 @@ Blockly.Blocks.albert_turn_for_secs = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.albert_turn_for_secs = function(a, b) { - a = Entry.hw.sendQueue; - if (b.isStart) { - if (1 == b.timeFlag) { - return b; +Entry.block.albert_turn_for_secs = function(b, a) { + var c = Entry.hw.sendQueue; + if (a.isStart) { + if (1 == a.timeFlag) { + return a; } - delete b.isStart; - delete b.timeFlag; + delete a.isStart; + delete a.timeFlag; Entry.engine.isContinue = !1; - a.leftWheel = 0; - a.rightWheel = 0; - return b.callReturn(); + c.leftWheel = 0; + c.rightWheel = 0; + return a.callReturn(); } - b.isStart = !0; - b.timeFlag = 1; - "LEFT" == b.getField("DIRECTION", b) ? (a.leftWheel = -30, a.rightWheel = 30) : (a.leftWheel = 30, a.rightWheel = -30); - a = 1E3 * b.getNumberValue("VALUE"); - var c = setTimeout(function() { - b.timeFlag = 0; - Entry.Albert.removeTimeout(c); - }, a); - Entry.Albert.timeouts.push(c); - return b; + a.isStart = !0; + a.timeFlag = 1; + "LEFT" == a.getField("DIRECTION", a) ? (c.leftWheel = -30, c.rightWheel = 30) : (c.leftWheel = 30, c.rightWheel = -30); + var c = 1E3 * a.getNumberValue("VALUE"), d = setTimeout(function() { + a.timeFlag = 0; + Entry.Albert.removeTimeout(d); + }, c); + Entry.Albert.timeouts.push(d); + return a; }; Blockly.Blocks.albert_change_both_wheels_by = {init:function() { this.setColour("#00979D"); @@ -274,12 +268,11 @@ Blockly.Blocks.albert_change_both_wheels_by = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.albert_change_both_wheels_by = function(a, b) { - a = Entry.hw.sendQueue; - var c = b.getNumberValue("LEFT"), d = b.getNumberValue("RIGHT"); - a.leftWheel = void 0 != a.leftWheel ? a.leftWheel + c : c; - a.rightWheel = void 0 != a.rightWheel ? a.rightWheel + d : d; - return b.callReturn(); +Entry.block.albert_change_both_wheels_by = function(b, a) { + var c = Entry.hw.sendQueue, d = a.getNumberValue("LEFT"), e = a.getNumberValue("RIGHT"); + c.leftWheel = void 0 != c.leftWheel ? c.leftWheel + d : d; + c.rightWheel = void 0 != c.rightWheel ? c.rightWheel + e : e; + return a.callReturn(); }; Blockly.Blocks.albert_set_both_wheels_to = {init:function() { this.setColour("#00979D"); @@ -292,11 +285,11 @@ Blockly.Blocks.albert_set_both_wheels_to = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.albert_set_both_wheels_to = function(a, b) { - a = Entry.hw.sendQueue; - a.leftWheel = b.getNumberValue("LEFT"); - a.rightWheel = b.getNumberValue("RIGHT"); - return b.callReturn(); +Entry.block.albert_set_both_wheels_to = function(b, a) { + var c = Entry.hw.sendQueue; + c.leftWheel = a.getNumberValue("LEFT"); + c.rightWheel = a.getNumberValue("RIGHT"); + return a.callReturn(); }; Blockly.Blocks.albert_change_wheel_by = {init:function() { this.setColour("#00979D"); @@ -307,11 +300,10 @@ Blockly.Blocks.albert_change_wheel_by = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.albert_change_wheel_by = function(a, b) { - a = Entry.hw.sendQueue; - var c = b.getField("DIRECTION"), d = b.getNumberValue("VALUE"); - "LEFT" == c ? a.leftWheel = void 0 != a.leftWheel ? a.leftWheel + d : d : ("RIGHT" != c && (a.leftWheel = void 0 != a.leftWheel ? a.leftWheel + d : d), a.rightWheel = void 0 != a.rightWheel ? a.rightWheel + d : d); - return b.callReturn(); +Entry.block.albert_change_wheel_by = function(b, a) { + var c = Entry.hw.sendQueue, d = a.getField("DIRECTION"), e = a.getNumberValue("VALUE"); + "LEFT" == d ? c.leftWheel = void 0 != c.leftWheel ? c.leftWheel + e : e : ("RIGHT" != d && (c.leftWheel = void 0 != c.leftWheel ? c.leftWheel + e : e), c.rightWheel = void 0 != c.rightWheel ? c.rightWheel + e : e); + return a.callReturn(); }; Blockly.Blocks.albert_set_wheel_to = {init:function() { this.setColour("#00979D"); @@ -322,11 +314,10 @@ Blockly.Blocks.albert_set_wheel_to = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.albert_set_wheel_to = function(a, b) { - a = Entry.hw.sendQueue; - var c = b.getField("DIRECTION"), d = b.getNumberValue("VALUE"); - "LEFT" == c ? a.leftWheel = d : ("RIGHT" != c && (a.leftWheel = d), a.rightWheel = d); - return b.callReturn(); +Entry.block.albert_set_wheel_to = function(b, a) { + var c = Entry.hw.sendQueue, d = a.getField("DIRECTION"), e = a.getNumberValue("VALUE"); + "LEFT" == d ? c.leftWheel = e : ("RIGHT" != d && (c.leftWheel = e), c.rightWheel = e); + return a.callReturn(); }; Blockly.Blocks.albert_stop = {init:function() { this.setColour("#00979D"); @@ -335,11 +326,11 @@ Blockly.Blocks.albert_stop = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.albert_stop = function(a, b) { - a = Entry.hw.sendQueue; - a.leftWheel = 0; - a.rightWheel = 0; - return b.callReturn(); +Entry.block.albert_stop = function(b, a) { + var c = Entry.hw.sendQueue; + c.leftWheel = 0; + c.rightWheel = 0; + return a.callReturn(); }; Blockly.Blocks.albert_set_pad_size_to = {init:function() { this.setColour("#00979D"); @@ -352,11 +343,11 @@ Blockly.Blocks.albert_set_pad_size_to = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.albert_set_pad_size_to = function(a, b) { - a = Entry.hw.sendQueue; - a.padWidth = b.getNumberValue("WIDTH"); - a.padHeight = b.getNumberValue("HEIGHT"); - return b.callReturn(); +Entry.block.albert_set_pad_size_to = function(b, a) { + var c = Entry.hw.sendQueue; + c.padWidth = a.getNumberValue("WIDTH"); + c.padHeight = a.getNumberValue("HEIGHT"); + return a.callReturn(); }; Blockly.Blocks.albert_set_eye_to = {init:function() { this.setColour("#00979D"); @@ -366,11 +357,10 @@ Blockly.Blocks.albert_set_eye_to = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.albert_set_eye_to = function(a, b) { - a = Entry.hw.sendQueue; - var c = b.getField("DIRECTION", b), d = Number(b.getField("COLOR", b)); - "LEFT" == c ? a.leftEye = d : ("RIGHT" != c && (a.leftEye = d), a.rightEye = d); - return b.callReturn(); +Entry.block.albert_set_eye_to = function(b, a) { + var c = Entry.hw.sendQueue, d = a.getField("DIRECTION", a), e = +a.getField("COLOR", a); + "LEFT" == d ? c.leftEye = e : ("RIGHT" != d && (c.leftEye = e), c.rightEye = e); + return a.callReturn(); }; Blockly.Blocks.albert_clear_eye = {init:function() { this.setColour("#00979D"); @@ -379,11 +369,10 @@ Blockly.Blocks.albert_clear_eye = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.albert_clear_eye = function(a, b) { - a = Entry.hw.sendQueue; - var c = b.getField("DIRECTION", b); - "LEFT" == c ? a.leftEye = 0 : ("RIGHT" != c && (a.leftEye = 0), a.rightEye = 0); - return b.callReturn(); +Entry.block.albert_clear_eye = function(b, a) { + var c = Entry.hw.sendQueue, d = a.getField("DIRECTION", a); + "LEFT" == d ? c.leftEye = 0 : ("RIGHT" != d && (c.leftEye = 0), c.rightEye = 0); + return a.callReturn(); }; Blockly.Blocks.albert_body_led = {init:function() { this.setColour("#00979D"); @@ -392,10 +381,10 @@ Blockly.Blocks.albert_body_led = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.albert_body_led = function(a, b) { - a = Entry.hw.sendQueue; - "ON" == b.getField("STATE", b) ? a.bodyLed = 1 : a.bodyLed = 0; - return b.callReturn(); +Entry.block.albert_body_led = function(b, a) { + var c = Entry.hw.sendQueue; + "ON" == a.getField("STATE", a) ? c.bodyLed = 1 : c.bodyLed = 0; + return a.callReturn(); }; Blockly.Blocks.albert_front_led = {init:function() { this.setColour("#00979D"); @@ -404,10 +393,10 @@ Blockly.Blocks.albert_front_led = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.albert_front_led = function(a, b) { - a = Entry.hw.sendQueue; - "ON" == b.getField("STATE", b) ? a.frontLed = 1 : a.frontLed = 0; - return b.callReturn(); +Entry.block.albert_front_led = function(b, a) { + var c = Entry.hw.sendQueue; + "ON" == a.getField("STATE", a) ? c.frontLed = 1 : c.frontLed = 0; + return a.callReturn(); }; Blockly.Blocks.albert_beep = {init:function() { this.setColour("#00979D"); @@ -416,28 +405,28 @@ Blockly.Blocks.albert_beep = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.albert_beep = function(a, b) { - a = Entry.hw.sendQueue; - if (b.isStart) { - if (1 == b.timeFlag) { - return b; +Entry.block.albert_beep = function(b, a) { + var c = Entry.hw.sendQueue; + if (a.isStart) { + if (1 == a.timeFlag) { + return a; } - delete b.isStart; - delete b.timeFlag; + delete a.isStart; + delete a.timeFlag; Entry.engine.isContinue = !1; - a.buzzer = 0; - return b.callReturn(); + c.buzzer = 0; + return a.callReturn(); } - b.isStart = !0; - b.timeFlag = 1; - a.buzzer = 440; - a.note = 0; - var c = setTimeout(function() { - b.timeFlag = 0; - Entry.Albert.removeTimeout(c); + a.isStart = !0; + a.timeFlag = 1; + c.buzzer = 440; + c.note = 0; + var d = setTimeout(function() { + a.timeFlag = 0; + Entry.Albert.removeTimeout(d); }, 200); - Entry.Albert.timeouts.push(c); - return b; + Entry.Albert.timeouts.push(d); + return a; }; Blockly.Blocks.albert_change_buzzer_by = {init:function() { this.setColour("#00979D"); @@ -448,12 +437,11 @@ Blockly.Blocks.albert_change_buzzer_by = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.albert_change_buzzer_by = function(a, b) { - a = Entry.hw.sendQueue; - var c = b.getNumberValue("VALUE"); - a.buzzer = void 0 != a.buzzer ? a.buzzer + c : c; - a.note = 0; - return b.callReturn(); +Entry.block.albert_change_buzzer_by = function(b, a) { + var c = Entry.hw.sendQueue, d = a.getNumberValue("VALUE"); + c.buzzer = void 0 != c.buzzer ? c.buzzer + d : d; + c.note = 0; + return a.callReturn(); }; Blockly.Blocks.albert_set_buzzer_to = {init:function() { this.setColour("#00979D"); @@ -464,11 +452,11 @@ Blockly.Blocks.albert_set_buzzer_to = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.albert_set_buzzer_to = function(a, b) { - a = Entry.hw.sendQueue; - a.buzzer = b.getNumberValue("VALUE"); - a.note = 0; - return b.callReturn(); +Entry.block.albert_set_buzzer_to = function(b, a) { + var c = Entry.hw.sendQueue; + c.buzzer = a.getNumberValue("VALUE"); + c.note = 0; + return a.callReturn(); }; Blockly.Blocks.albert_clear_buzzer = {init:function() { this.setColour("#00979D"); @@ -477,11 +465,11 @@ Blockly.Blocks.albert_clear_buzzer = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.albert_clear_buzzer = function(a, b) { - a = Entry.hw.sendQueue; - a.buzzer = 0; - a.note = 0; - return b.callReturn(); +Entry.block.albert_clear_buzzer = function(b, a) { + var c = Entry.hw.sendQueue; + c.buzzer = 0; + c.note = 0; + return a.callReturn(); }; Blockly.Blocks.albert_play_note_for = {init:function() { this.setColour("#00979D"); @@ -493,37 +481,36 @@ Blockly.Blocks.albert_play_note_for = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.albert_play_note_for = function(a, b) { +Entry.block.albert_play_note_for = function(b, a) { var c = Entry.hw.sendQueue; - if (b.isStart) { - if (1 == b.timeFlag) { - return b; + if (a.isStart) { + if (1 == a.timeFlag) { + return a; } - delete b.isStart; - delete b.timeFlag; + delete a.isStart; + delete a.timeFlag; Entry.engine.isContinue = !1; c.note = 0; - return b.callReturn(); + return a.callReturn(); } - a = b.getNumberField("NOTE", b); - var d = b.getNumberField("OCTAVE", b), e = 6E4 * b.getNumberValue("VALUE", b) / Entry.Albert.tempo; - b.isStart = !0; - b.timeFlag = 1; + var d = a.getNumberField("NOTE", a), e = a.getNumberField("OCTAVE", a), f = a.getNumberValue("VALUE", a), g = Entry.Albert.tempo, f = 6E4 * f / g; + a.isStart = !0; + a.timeFlag = 1; c.buzzer = 0; - c.note = a + 12 * (d - 1); - if (100 < e) { - var f = setTimeout(function() { + c.note = d + 12 * (e - 1); + if (100 < f) { + var h = setTimeout(function() { c.note = 0; - Entry.Albert.removeTimeout(f); - }, e - 100); - Entry.Albert.timeouts.push(f); + Entry.Albert.removeTimeout(h); + }, f - 100); + Entry.Albert.timeouts.push(h); } - var g = setTimeout(function() { - b.timeFlag = 0; - Entry.Albert.removeTimeout(g); - }, e); - Entry.Albert.timeouts.push(g); - return b; + var k = setTimeout(function() { + a.timeFlag = 0; + Entry.Albert.removeTimeout(k); + }, f); + Entry.Albert.timeouts.push(k); + return a; }; Blockly.Blocks.albert_rest_for = {init:function() { this.setColour("#00979D"); @@ -534,28 +521,28 @@ Blockly.Blocks.albert_rest_for = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.albert_rest_for = function(a, b) { - a = Entry.hw.sendQueue; - if (b.isStart) { - if (1 == b.timeFlag) { - return b; +Entry.block.albert_rest_for = function(b, a) { + var c = Entry.hw.sendQueue; + if (a.isStart) { + if (1 == a.timeFlag) { + return a; } - delete b.isStart; - delete b.timeFlag; + delete a.isStart; + delete a.timeFlag; Entry.engine.isContinue = !1; - return b.callReturn(); + return a.callReturn(); } - b.isStart = !0; - b.timeFlag = 1; - var c = b.getNumberValue("VALUE"), c = 6E4 * c / Entry.Albert.tempo; - a.buzzer = 0; - a.note = 0; - var d = setTimeout(function() { - b.timeFlag = 0; - Entry.Albert.removeTimeout(d); - }, c); - Entry.Albert.timeouts.push(d); - return b; + a.isStart = !0; + a.timeFlag = 1; + var d = a.getNumberValue("VALUE"), d = 6E4 * d / Entry.Albert.tempo; + c.buzzer = 0; + c.note = 0; + var e = setTimeout(function() { + a.timeFlag = 0; + Entry.Albert.removeTimeout(e); + }, d); + Entry.Albert.timeouts.push(e); + return a; }; Blockly.Blocks.albert_change_tempo_by = {init:function() { this.setColour("#00979D"); @@ -566,10 +553,10 @@ Blockly.Blocks.albert_change_tempo_by = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.albert_change_tempo_by = function(a, b) { - Entry.Albert.tempo += b.getNumberValue("VALUE"); +Entry.block.albert_change_tempo_by = function(b, a) { + Entry.Albert.tempo += a.getNumberValue("VALUE"); 1 > Entry.Albert.tempo && (Entry.Albert.tempo = 1); - return b.callReturn(); + return a.callReturn(); }; Blockly.Blocks.albert_set_tempo_to = {init:function() { this.setColour("#00979D"); @@ -580,10 +567,10 @@ Blockly.Blocks.albert_set_tempo_to = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.albert_set_tempo_to = function(a, b) { - Entry.Albert.tempo = b.getNumberValue("VALUE"); +Entry.block.albert_set_tempo_to = function(b, a) { + Entry.Albert.tempo = a.getNumberValue("VALUE"); 1 > Entry.Albert.tempo && (Entry.Albert.tempo = 1); - return b.callReturn(); + return a.callReturn(); }; Blockly.Blocks.albert_move_forward = {init:function() { this.setColour("#00979D"); @@ -592,27 +579,27 @@ Blockly.Blocks.albert_move_forward = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.albert_move_forward = function(a, b) { - a = Entry.hw.sendQueue; - if (b.isStart) { - if (1 == b.timeFlag) { - return b; +Entry.block.albert_move_forward = function(b, a) { + var c = Entry.hw.sendQueue; + if (a.isStart) { + if (1 == a.timeFlag) { + return a; } - delete b.timeFlag; - delete b.isStart; + delete a.timeFlag; + delete a.isStart; Entry.engine.isContinue = !1; - a.leftWheel = 0; - a.rightWheel = 0; - return b.callReturn(); + c.leftWheel = 0; + c.rightWheel = 0; + return a.callReturn(); } - b.isStart = !0; - b.timeFlag = 1; - a.leftWheel = 30; - a.rightWheel = 30; + a.isStart = !0; + a.timeFlag = 1; + c.leftWheel = 30; + c.rightWheel = 30; setTimeout(function() { - b.timeFlag = 0; + a.timeFlag = 0; }, 1E3); - return b; + return a; }; Blockly.Blocks.albert_move_backward = {init:function() { this.setColour("#00979D"); @@ -621,25 +608,25 @@ Blockly.Blocks.albert_move_backward = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.albert_move_backward = function(a, b) { - a = Entry.hw.sendQueue; - if (b.isStart) { - if (1 == b.timeFlag) { - return a.leftWheel = -30, a.rightWheel = -30, b; +Entry.block.albert_move_backward = function(b, a) { + var c = Entry.hw.sendQueue; + if (a.isStart) { + if (1 == a.timeFlag) { + return c.leftWheel = -30, c.rightWheel = -30, a; } - delete b.timeFlag; - delete b.isStart; + delete a.timeFlag; + delete a.isStart; Entry.engine.isContinue = !1; - a.leftWheel = 0; - a.rightWheel = 0; - return b.callReturn(); + c.leftWheel = 0; + c.rightWheel = 0; + return a.callReturn(); } - b.isStart = !0; - b.timeFlag = 1; + a.isStart = !0; + a.timeFlag = 1; setTimeout(function() { - b.timeFlag = 0; + a.timeFlag = 0; }, 1E3); - return b; + return a; }; Blockly.Blocks.albert_turn_around = {init:function() { this.setColour("#00979D"); @@ -648,30 +635,30 @@ Blockly.Blocks.albert_turn_around = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.albert_turn_around = function(a, b) { - a = Entry.hw.sendQueue; - if (b.isStart) { - if (1 == b.timeFlag) { - return a.leftWheel = b.leftValue, a.rightWheel = b.rightValue, b; +Entry.block.albert_turn_around = function(b, a) { + var c = Entry.hw.sendQueue; + if (a.isStart) { + if (1 == a.timeFlag) { + return c.leftWheel = a.leftValue, c.rightWheel = a.rightValue, a; } - delete b.timeFlag; - delete b.isStart; - delete b.leftValue; - delete b.rightValue; + delete a.timeFlag; + delete a.isStart; + delete a.leftValue; + delete a.rightValue; Entry.engine.isContinue = !1; - a.leftWheel = 0; - a.rightWheel = 0; - return b.callReturn(); + c.leftWheel = 0; + c.rightWheel = 0; + return a.callReturn(); } - a = "LEFT" == b.getField("DIRECTION", b); - b.leftValue = a ? -30 : 30; - b.rightValue = a ? 30 : -30; - b.isStart = !0; - b.timeFlag = 1; + c = "LEFT" == a.getField("DIRECTION", a); + a.leftValue = c ? -30 : 30; + a.rightValue = c ? 30 : -30; + a.isStart = !0; + a.timeFlag = 1; setTimeout(function() { - b.timeFlag = 0; + a.timeFlag = 0; }, 1E3); - return b; + return a; }; Blockly.Blocks.albert_set_led_to = {init:function() { this.setColour("#00979D"); @@ -681,11 +668,10 @@ Blockly.Blocks.albert_set_led_to = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.albert_set_led_to = function(a, b) { - a = Entry.hw.sendQueue; - var c = b.getField("DIRECTION", b), d = Number(b.getField("COLOR", b)); - "FRONT" == c ? (a.leftEye = d, a.rightEye = d) : "LEFT" == c ? a.leftEye = d : a.rightEye = d; - return b.callReturn(); +Entry.block.albert_set_led_to = function(b, a) { + var c = Entry.hw.sendQueue, d = a.getField("DIRECTION", a), e = +a.getField("COLOR", a); + "FRONT" == d ? (c.leftEye = e, c.rightEye = e) : "LEFT" == d ? c.leftEye = e : c.rightEye = e; + return a.callReturn(); }; Blockly.Blocks.albert_clear_led = {init:function() { this.setColour("#00979D"); @@ -694,11 +680,10 @@ Blockly.Blocks.albert_clear_led = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.albert_clear_led = function(a, b) { - a = Entry.hw.sendQueue; - var c = b.getField("DIRECTION", b); - "FRONT" == c ? (a.leftEye = 0, a.rightEye = 0) : "LEFT" == c ? a.leftEye = 0 : a.rightEye = 0; - return b.callReturn(); +Entry.block.albert_clear_led = function(b, a) { + var c = Entry.hw.sendQueue, d = a.getField("DIRECTION", a); + "FRONT" == d ? (c.leftEye = 0, c.rightEye = 0) : "LEFT" == d ? c.leftEye = 0 : c.rightEye = 0; + return a.callReturn(); }; Blockly.Blocks.albert_change_wheels_by = {init:function() { this.setColour("#00979D"); @@ -709,11 +694,10 @@ Blockly.Blocks.albert_change_wheels_by = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.albert_change_wheels_by = function(a, b) { - a = Entry.hw.sendQueue; - var c = Entry.hw.portData, d = b.getField("DIRECTION"), e = b.getNumberValue("VALUE"); - "LEFT" == d ? a.leftWheel = void 0 != a.leftWheel ? a.leftWheel + e : c.leftWheel + e : ("RIGHT" != d && (a.leftWheel = void 0 != a.leftWheel ? a.leftWheel + e : c.leftWheel + e), a.rightWheel = void 0 != a.rightWheel ? a.rightWheel + e : c.rightWheel + e); - return b.callReturn(); +Entry.block.albert_change_wheels_by = function(b, a) { + var c = Entry.hw.sendQueue, d = Entry.hw.portData, e = a.getField("DIRECTION"), f = a.getNumberValue("VALUE"); + "LEFT" == e ? c.leftWheel = void 0 != c.leftWheel ? c.leftWheel + f : d.leftWheel + f : ("RIGHT" != e && (c.leftWheel = void 0 != c.leftWheel ? c.leftWheel + f : d.leftWheel + f), c.rightWheel = void 0 != c.rightWheel ? c.rightWheel + f : d.rightWheel + f); + return a.callReturn(); }; Blockly.Blocks.albert_set_wheels_to = {init:function() { this.setColour("#00979D"); @@ -724,16 +708,15 @@ Blockly.Blocks.albert_set_wheels_to = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.albert_set_wheels_to = function(a, b) { - a = Entry.hw.sendQueue; - var c = b.getField("DIRECTION"), d = b.getNumberValue("VALUE"); - "LEFT" == c ? a.leftWheel = d : ("RIGHT" != c && (a.leftWheel = d), a.rightWheel = d); - return b.callReturn(); +Entry.block.albert_set_wheels_to = function(b, a) { + var c = Entry.hw.sendQueue, d = a.getField("DIRECTION"), e = a.getNumberValue("VALUE"); + "LEFT" == d ? c.leftWheel = e : ("RIGHT" != d && (c.leftWheel = e), c.rightWheel = e); + return a.callReturn(); }; Entry.Arduino = {name:"arduino", setZero:function() { Entry.hw.sendQueue.readablePorts = []; - for (var a = 0;20 > a;a++) { - Entry.hw.sendQueue[a] = 0, Entry.hw.sendQueue.readablePorts.push(a); + for (var b = 0;20 > b;b++) { + Entry.hw.sendQueue[b] = 0, Entry.hw.sendQueue.readablePorts.push(b); } Entry.hw.update(); }, monitorTemplate:{imgPath:"hw/arduino.png", width:605, height:434, listPorts:{2:{name:Lang.Hw.port_en + " 2 " + Lang.Hw.port_ko, type:"input", pos:{x:0, y:0}}, 3:{name:Lang.Hw.port_en + " 3 " + Lang.Hw.port_ko, type:"input", pos:{x:0, y:0}}, 4:{name:Lang.Hw.port_en + " 4 " + Lang.Hw.port_ko, type:"input", pos:{x:0, y:0}}, 5:{name:Lang.Hw.port_en + " 5 " + Lang.Hw.port_ko, type:"input", pos:{x:0, y:0}}, 6:{name:Lang.Hw.port_en + " 6 " + Lang.Hw.port_ko, type:"input", pos:{x:0, y:0}}, 7:{name:Lang.Hw.port_en + @@ -742,15 +725,15 @@ Lang.Hw.port_ko, type:"input", pos:{x:0, y:0}}, a0:{name:Lang.Hw.port_en + " A0 Lang.Hw.port_ko, type:"input", pos:{x:0, y:0}}}, mode:"both"}}; Entry.SensorBoard = {name:"sensorBoard", setZero:Entry.Arduino.setZero}; Entry.ardublock = {name:"ardublock", setZero:Entry.Arduino.setZero}; -Entry.dplay = {name:"dplay", vel_value:255, Left_value:255, Right_value:255, setZero:Entry.Arduino.setZero, timeouts:[], removeTimeout:function(a) { - clearTimeout(a); - var b = this.timeouts; - a = b.indexOf(a); - 0 <= a && b.splice(a, 1); +Entry.dplay = {name:"dplay", vel_value:255, Left_value:255, Right_value:255, setZero:Entry.Arduino.setZero, timeouts:[], removeTimeout:function(b) { + clearTimeout(b); + var a = this.timeouts; + b = a.indexOf(b); + 0 <= b && a.splice(b, 1); }, removeAllTimeouts:function() { - var a = this.timeouts, b; - for (b in a) { - clearTimeout(a[b]); + var b = this.timeouts, a; + for (a in b) { + clearTimeout(b[a]); } this.timeouts = []; }}; @@ -763,8 +746,8 @@ Blockly.Blocks.arduino_text = {init:function() { this.setOutput(!0, "String"); this.setInputsInline(!0); }}; -Entry.block.arduino_text = function(a, b) { - return b.getStringField("NAME"); +Entry.block.arduino_text = function(b, a) { + return a.getStringField("NAME"); }; Blockly.Blocks.arduino_send = {init:function() { this.setColour("#00979D"); @@ -775,13 +758,12 @@ Blockly.Blocks.arduino_send = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.arduino_send = function(a, b) { - a = b.getValue("VALUE", b); - var c = new XMLHttpRequest; - c.open("POST", "http://localhost:23518/arduino/", !1); - c.send(String(a)); - Entry.assert(200 == c.status, "arduino is not connected"); - return b.callReturn(); +Entry.block.arduino_send = function(b, a) { + var c = a.getValue("VALUE", a), d = new XMLHttpRequest; + d.open("POST", "http://localhost:23518/arduino/", !1); + d.send(String(c)); + Entry.assert(200 == d.status, "arduino is not connected"); + return a.callReturn(); }; Blockly.Blocks.arduino_get_string = {init:function() { this.setColour("#00979D"); @@ -791,13 +773,12 @@ Blockly.Blocks.arduino_get_string = {init:function() { this.setOutput(!0, "String"); this.setInputsInline(!0); }}; -Entry.block.arduino_get_number = function(a, b) { - a = b.getValue("VALUE", b); - b = new XMLHttpRequest; - b.open("POST", "http://localhost:23518/arduino/", !1); - b.send(String(a)); - Entry.assert(200 == b.status, "arduino is not connected"); - return Number(b.responseText); +Entry.block.arduino_get_number = function(b, a) { + var c = a.getValue("VALUE", a), d = new XMLHttpRequest; + d.open("POST", "http://localhost:23518/arduino/", !1); + d.send(String(c)); + Entry.assert(200 == d.status, "arduino is not connected"); + return +d.responseText; }; Blockly.Blocks.arduino_get_number = {init:function() { this.setColour("#00979D"); @@ -807,13 +788,12 @@ Blockly.Blocks.arduino_get_number = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.arduino_get_string = function(a, b) { - a = b.getValue("VALUE", b); - b = new XMLHttpRequest; - b.open("POST", "http://localhost:23518/arduino/", !1); - b.send(String(a)); - Entry.assert(200 == b.status, "arduino is not connected"); - return b.responseText; +Entry.block.arduino_get_string = function(b, a) { + var c = a.getValue("VALUE", a), d = new XMLHttpRequest; + d.open("POST", "http://localhost:23518/arduino/", !1); + d.send(String(c)); + Entry.assert(200 == d.status, "arduino is not connected"); + return d.responseText; }; Blockly.Blocks.arduino_get_sensor_number = {init:function() { this.setColour("#00979D"); @@ -822,8 +802,8 @@ Blockly.Blocks.arduino_get_sensor_number = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.arduino_get_sensor_number = function(a, b) { - return b.getStringField("PORT"); +Entry.block.arduino_get_sensor_number = function(b, a) { + return a.getStringField("PORT"); }; Blockly.Blocks.arduino_get_port_number = {init:function() { this.setColour("#00979D"); @@ -832,8 +812,8 @@ Blockly.Blocks.arduino_get_port_number = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.arduino_get_port_number = function(a, b) { - return b.getStringField("PORT"); +Entry.block.arduino_get_port_number = function(b, a) { + return a.getStringField("PORT"); }; Blockly.Blocks.arduino_get_pwm_port_number = {init:function() { this.setColour("#00979D"); @@ -842,8 +822,8 @@ Blockly.Blocks.arduino_get_pwm_port_number = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.arduino_get_pwm_port_number = function(a, b) { - return b.getStringField("PORT"); +Entry.block.arduino_get_pwm_port_number = function(b, a) { + return a.getStringField("PORT"); }; Blockly.Blocks.arduino_get_number_sensor_value = {init:function() { this.setColour("#00979D"); @@ -853,9 +833,9 @@ Blockly.Blocks.arduino_get_number_sensor_value = {init:function() { this.setInputsInline(!0); this.setOutput(!0, "Number"); }}; -Entry.block.arduino_get_number_sensor_value = function(a, b) { - a = b.getValue("VALUE", b); - return Entry.hw.getAnalogPortValue(a[1]); +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"); @@ -865,9 +845,9 @@ Blockly.Blocks.arduino_get_digital_value = {init:function() { this.setInputsInline(!0); this.setOutput(!0, "Boolean"); }}; -Entry.block.arduino_get_digital_value = function(a, b) { - a = b.getNumberValue("VALUE", b); - return Entry.hw.getDigitalPortValue(a); +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"); @@ -879,11 +859,10 @@ Blockly.Blocks.arduino_toggle_led = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.arduino_toggle_led = function(a, b) { - a = b.getNumberValue("VALUE"); - var c = b.getField("OPERATOR"); - Entry.hw.setDigitalPortValue(a, "on" == c ? 255 : 0); - return b.callReturn(); +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"); @@ -897,11 +876,10 @@ Blockly.Blocks.arduino_toggle_pwm = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.arduino_toggle_pwm = function(a, b) { - a = b.getNumberValue("PORT"); - var c = b.getNumberValue("VALUE"), c = Math.round(c), c = Math.max(c, 0), c = Math.min(c, 255); - Entry.hw.setDigitalPortValue(a, c); - return b.callReturn(); +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"); @@ -920,18 +898,17 @@ Blockly.Blocks.arduino_convert_scale = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.arduino_convert_scale = function(a, b) { - var c = b.getNumberValue("VALUE1", b), d = b.getNumberValue("VALUE2", b), e = b.getNumberValue("VALUE3", b); - a = b.getNumberValue("VALUE4", b); - b = b.getNumberValue("VALUE5", b); +Entry.block.arduino_convert_scale = function(b, a) { + var c = a.getNumberValue("VALUE1", a), d = a.getNumberValue("VALUE2", a), e = a.getNumberValue("VALUE3", a), f = a.getNumberValue("VALUE4", a), g = a.getNumberValue("VALUE5", a); if (d > e) { - var f = d, d = e, e = f - } - a > b && (f = a, a = b, b = f); - c = (b - a) / (e - d) * (c - d); - c += a; - c = Math.min(b, c); - c = Math.max(a, c); + 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); }; Blockly.Blocks.sensorBoard_get_named_sensor_value = {init:function() { @@ -940,8 +917,8 @@ Blockly.Blocks.sensorBoard_get_named_sensor_value = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.sensorBoard_get_named_sensor_value = function(a, b) { - return Entry.hw.getAnalogPortValue(b.getField("PORT", b)); +Entry.block.sensorBoard_get_named_sensor_value = function(b, a) { + return Entry.hw.getAnalogPortValue(a.getField("PORT", a)); }; Blockly.Blocks.sensorBoard_is_button_pressed = {init:function() { this.setColour("#00979D"); @@ -950,8 +927,8 @@ Blockly.Blocks.sensorBoard_is_button_pressed = {init:function() { this.setInputsInline(!0); this.setOutput(!0, "Boolean"); }}; -Entry.block.sensorBoard_is_button_pressed = function(a, b) { - return Entry.hw.getDigitalPortValue(b.getNumberField("PORT", b)); +Entry.block.sensorBoard_is_button_pressed = function(b, a) { + return Entry.hw.getDigitalPortValue(a.getNumberField("PORT", a)); }; Blockly.Blocks.sensorBoard_led = {init:function() { this.setColour("#00979D"); @@ -960,9 +937,9 @@ Blockly.Blocks.sensorBoard_led = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.sensorBoard_led = function(a, b) { - Entry.hw.setDigitalPortValue(b.getField("PORT"), b.getNumberField("OPERATOR")); - return b.callReturn(); +Entry.block.sensorBoard_led = function(b, a) { + Entry.hw.setDigitalPortValue(a.getField("PORT"), a.getNumberField("OPERATOR")); + return a.callReturn(); }; Entry.block.arduino_download_connector = {skeleton:"basic_button", color:"#eee", template:"%1", params:[{type:"Text", text:"\uc5f0\uacb0 \ud504\ub85c\uadf8\ub7a8 \ub2e4\uc6b4\ub85c\ub4dc", color:"#333", align:"center"}], func:function() { }, events:{mousedown:[function() { @@ -987,8 +964,8 @@ Blockly.Blocks.CODEino_get_sensor_number = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.CODEino_get_sensor_number = function(a, b) { - return b.getStringField("PORT"); +Entry.block.CODEino_get_sensor_number = function(b, a) { + return a.getStringField("PORT"); }; Blockly.Blocks.CODEino_get_named_sensor_value = {init:function() { this.setColour("#00979D"); @@ -996,8 +973,8 @@ Blockly.Blocks.CODEino_get_named_sensor_value = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.CODEino_get_named_sensor_value = function(a, b) { - return Entry.hw.getAnalogPortValue(b.getField("PORT", b)); +Entry.block.CODEino_get_named_sensor_value = function(b, a) { + return Entry.hw.getAnalogPortValue(a.getField("PORT", a)); }; Blockly.Blocks.CODEino_get_sound_status = {init:function() { this.setColour("#00979D"); @@ -1005,8 +982,8 @@ Blockly.Blocks.CODEino_get_sound_status = {init:function() { this.setInputsInline(!0); this.setOutput(!0, "Boolean"); }}; -Entry.block.CODEino_get_sound_status = function(a, b) { - return "GREAT" == b.getField("STATUS", b) ? 600 < Entry.hw.getAnalogPortValue(0) ? 1 : 0 : 600 > Entry.hw.getAnalogPortValue(0) ? 1 : 0; +Entry.block.CODEino_get_sound_status = function(b, a) { + return "GREAT" == a.getField("STATUS", a) ? 600 < Entry.hw.getAnalogPortValue(0) ? 1 : 0 : 600 > Entry.hw.getAnalogPortValue(0) ? 1 : 0; }; Blockly.Blocks.CODEino_get_light_status = {init:function() { this.setColour("#00979D"); @@ -1014,8 +991,8 @@ Blockly.Blocks.CODEino_get_light_status = {init:function() { this.setInputsInline(!0); this.setOutput(!0, "Boolean"); }}; -Entry.block.CODEino_get_light_status = function(a, b) { - return "DARK" == b.getField("STATUS", b) ? 800 < Entry.hw.getAnalogPortValue(1) ? 1 : 0 : 800 > Entry.hw.getAnalogPortValue(1) ? 1 : 0; +Entry.block.CODEino_get_light_status = function(b, a) { + return "DARK" == a.getField("STATUS", a) ? 800 < Entry.hw.getAnalogPortValue(1) ? 1 : 0 : 800 > Entry.hw.getAnalogPortValue(1) ? 1 : 0; }; Blockly.Blocks.CODEino_is_button_pressed = {init:function() { this.setColour("#00979D"); @@ -1023,9 +1000,9 @@ Blockly.Blocks.CODEino_is_button_pressed = {init:function() { this.setInputsInline(!0); this.setOutput(!0, "Boolean"); }}; -Entry.block.CODEino_is_button_pressed = function(a, b) { - a = b.getNumberField("PORT", b); - return 14 < a ? !Entry.hw.getAnalogPortValue(a - 14) : !Entry.hw.getDigitalPortValue(a); +Entry.block.CODEino_is_button_pressed = function(b, a) { + var c = a.getNumberField("PORT", a); + return 14 < c ? !Entry.hw.getAnalogPortValue(c - 14) : !Entry.hw.getDigitalPortValue(c); }; Blockly.Blocks.CODEino_get_accelerometer_direction = {init:function() { this.setColour("#00979D"); @@ -1034,22 +1011,23 @@ Blockly.Blocks.CODEino_get_accelerometer_direction = {init:function() { this.setInputsInline(!0); this.setOutput(!0, "Boolean"); }}; -Entry.block.CODEino_get_accelerometer_direction = function(a, b) { - a = b.getField("DIRECTION", b); - b = 0; - "LEFT" == a || "RIGHT" == a ? b = 3 : "FRONT" == a || "REAR" == a ? b = 4 : "REVERSE" == a && (b = 5); - b = Entry.hw.getAnalogPortValue(b) - 265; - b = Math.min(90, 180 / 137 * b + -90); - b = Math.max(-90, b); - b = Math.round(b); - if ("LEFT" == a || "REAR" == a) { - return -30 > b ? 1 : 0; +Entry.block.CODEino_get_accelerometer_direction = function(b, a) { + var c = a.getField("DIRECTION", a), d = 0; + "LEFT" == c || "RIGHT" == c ? d = 3 : "FRONT" == c || "REAR" == c ? d = 4 : "REVERSE" == c && (d = 5); + d = Entry.hw.getAnalogPortValue(d); + d = 180 / 137 * (d - 265); + d += -90; + d = Math.min(90, d); + d = Math.max(-90, d); + d = Math.round(d); + if ("LEFT" == c || "REAR" == c) { + return -30 > d ? 1 : 0; } - if ("RIGHT" == a || "FRONT" == a) { - return 30 < b ? 1 : 0; + if ("RIGHT" == c || "FRONT" == c) { + return 30 < d ? 1 : 0; } - if ("REVERSE" == a) { - return -50 > b ? 1 : 0; + if ("REVERSE" == c) { + return -50 > d ? 1 : 0; } }; Blockly.Blocks.CODEino_get_accelerometer_value = {init:function() { @@ -1058,19 +1036,17 @@ Blockly.Blocks.CODEino_get_accelerometer_value = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.CODEino_get_accelerometer_value = function(a, b) { - var c = Entry.hw.getAnalogPortValue(b.getField("PORT", b)), d = 265, e = 402; - a = -90; - b = 90; - if (d > e) { - var f = d, d = e, e = f +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 } - a > b && (f = a, a = b, b = f); - c = (b - a) / (e - d) * (c - d); - c += a; - c = Math.min(b, c); - c = Math.max(a, c); - return Math.round(c); + 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"); @@ -1082,13 +1058,12 @@ Blockly.Blocks.dplay_select_led = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.dplay_select_led = function(a, b) { - var c = b.getField("PORT"); - a = 7; - "7" == c ? a = 7 : "8" == c ? a = 8 : "9" == c ? a = 9 : "10" == c && (a = 10); - c = b.getField("OPERATOR"); - Entry.hw.setDigitalPortValue(a, "on" == c ? 255 : 0); - return b.callReturn(); +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"); @@ -1098,11 +1073,10 @@ Blockly.Blocks.dplay_get_switch_status = {init:function() { this.setInputsInline(!0); this.setOutput(!0, "Boolean"); }}; -Entry.block.dplay_get_switch_status = function(a, b) { - a = b.getField("PORT"); - var c = 2; - "2" == a ? c = 2 : "4" == a && (c = 4); - return "OFF" == b.getField("STATUS") ? 1 == Entry.hw.getDigitalPortValue(c) ? 1 : 0 : 0 == Entry.hw.getDigitalPortValue(c) ? 1 : 0; +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"); @@ -1110,8 +1084,8 @@ Blockly.Blocks.dplay_get_light_status = {init:function() { this.setInputsInline(!0); this.setOutput(!0, "Boolean"); }}; -Entry.block.dplay_get_light_status = function(a, b) { - return "DARK" == b.getField("STATUS", b) ? 800 < Entry.hw.getAnalogPortValue(1) ? 1 : 0 : 800 > Entry.hw.getAnalogPortValue(1) ? 1 : 0; +Entry.block.dplay_get_light_status = function(b, a) { + return "DARK" == a.getField("STATUS", a) ? 800 < Entry.hw.getAnalogPortValue(1) ? 1 : 0 : 800 > Entry.hw.getAnalogPortValue(1) ? 1 : 0; }; Blockly.Blocks.dplay_get_value = {init:function() { this.setColour("#00979D"); @@ -1123,9 +1097,9 @@ Blockly.Blocks.dplay_get_value = {init:function() { this.setInputsInline(!0); this.setOutput(!0, "Number"); }}; -Entry.block.dplay_get_value = function(a, b) { - a = b.getValue("VALUE", b); - return Entry.hw.getAnalogPortValue(a[1]); +Entry.block.dplay_get_value = function(b, a) { + var c = a.getValue("VALUE", a); + return Entry.hw.getAnalogPortValue(c[1]); }; Blockly.Blocks.dplay_get_tilt = {init:function() { this.setColour("#00979D"); @@ -1133,8 +1107,8 @@ Blockly.Blocks.dplay_get_tilt = {init:function() { this.setInputsInline(!0); this.setOutput(!0, "Boolean"); }}; -Entry.block.dplay_get_tilt = function(a, b) { - return "LIGHT" == b.getField("STATUS", b) ? 1 == Entry.hw.getDigitalPortValue(12) ? 1 : 0 : 0 == Entry.hw.getDigitalPortValue(12) ? 1 : 0; +Entry.block.dplay_get_tilt = function(b, a) { + return "LIGHT" == a.getField("STATUS", a) ? 1 == Entry.hw.getDigitalPortValue(12) ? 1 : 0 : 0 == Entry.hw.getDigitalPortValue(12) ? 1 : 0; }; Blockly.Blocks.dplay_DCmotor = {init:function() { this.setColour("#00979D"); @@ -1145,15 +1119,14 @@ Blockly.Blocks.dplay_DCmotor = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.dplay_DCmotor = function(a, b) { - a = b.getField("PORT"); - var c = 0; - "3" == a ? c = 5 : "6" == a && (c = 11); - var d = b.getField("OPERATOR"), e = 0, f = 0; - "FRONT" == d ? (e = 255, f = 0) : "REAR" == d ? (e = 0, f = 255) : "OFF" == d && (f = e = 0); - Entry.hw.setDigitalPortValue(a, e); +Entry.block.dplay_DCmotor = function(b, a) { + var c = a.getField("PORT"), d = 0; + "3" == c ? d = 5 : "6" == c && (d = 11); + var e = a.getField("OPERATOR"), f = 0, g = 0; + "FRONT" == e ? (f = 255, g = 0) : "REAR" == e ? (f = 0, g = 255) : "OFF" == e && (g = f = 0); Entry.hw.setDigitalPortValue(c, f); - return b.callReturn(); + Entry.hw.setDigitalPortValue(d, g); + return a.callReturn(); }; Blockly.Blocks.dplay_buzzer = {init:function() { this.setColour("#00979D"); @@ -1167,16 +1140,15 @@ Blockly.Blocks.dplay_buzzer = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.dplay_buzzer = function(a, b) { - var c = b.getField("PORT"); - a = 2; - "1" == c ? a = 2 : "2" == c ? a = 4 : "3" == c && (a = 7); - c = b.getNumberValue("VALUE"); +Entry.block.dplay_buzzer = function(b, a) { + var c = a.getField("PORT"), d = 2; + "1" == c ? d = 2 : "2" == c ? d = 4 : "3" == c && (d = 7); + c = a.getNumberValue("VALUE"); c = Math.round(c); c = Math.max(c, 0); c = Math.min(c, 100); - Entry.hw.setDigitalPortValue(a, c); - return b.callReturn(); + Entry.hw.setDigitalPortValue(d, c); + return a.callReturn(); }; Blockly.Blocks.dplay_servo = {init:function() { this.setColour("#00979D"); @@ -1188,42 +1160,39 @@ Blockly.Blocks.dplay_servo = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.dplay_servo = function(a, b) { - a = b.getNumberValue("VALUE"); - a = Math.round(a); - a = Math.max(a, 0); - a = Math.min(a, 180); - Entry.hw.setDigitalPortValue(9, a); - return b.callReturn(); +Entry.block.dplay_servo = function(b, a) { + var c = a.getNumberValue("VALUE"), c = Math.round(c), c = Math.max(c, 0), c = Math.min(c, 180); + Entry.hw.setDigitalPortValue(9, c); + return a.callReturn(); }; Entry.Bitbrick = {SENSOR_MAP:{1:"light", 2:"IR", 3:"touch", 4:"potentiometer", 5:"MIC", 21:"UserSensor", 11:"UserInput", 20:"LED", 19:"SERVO", 18:"DC"}, PORT_MAP:{buzzer:2, 5:4, 6:6, 7:8, 8:10, LEDR:12, LEDG:14, LEDB:16}, sensorList:function() { - for (var a = [], b = Entry.hw.portData, c = 1;5 > c;c++) { - var d = b[c]; - d && (d.value || 0 === d.value) && a.push([c + " - " + Lang.Blocks["BITBRICK_" + d.type], c.toString()]); + for (var b = [], a = Entry.hw.portData, c = 1;5 > c;c++) { + var d = a[c]; + d && (d.value || 0 === d.value) && b.push([c + " - " + Lang.Blocks["BITBRICK_" + d.type], c.toString()]); } - return 0 == a.length ? [[Lang.Blocks.no_target, "null"]] : a; + return 0 == b.length ? [[Lang.Blocks.no_target, "null"]] : b; }, touchList:function() { - for (var a = [], b = Entry.hw.portData, c = 1;5 > c;c++) { - var d = b[c]; - d && "touch" === d.type && a.push([c.toString(), c.toString()]); + for (var b = [], a = Entry.hw.portData, c = 1;5 > c;c++) { + var d = a[c]; + d && "touch" === d.type && b.push([c.toString(), c.toString()]); } - return 0 == a.length ? [[Lang.Blocks.no_target, "null"]] : a; + return 0 == b.length ? [[Lang.Blocks.no_target, "null"]] : b; }, servoList:function() { - for (var a = [], b = Entry.hw.portData, c = 5;9 > c;c++) { - var d = b[c]; - d && "SERVO" === d.type && a.push(["ABCD"[c - 5], c.toString()]); + for (var b = [], a = Entry.hw.portData, c = 5;9 > c;c++) { + var d = a[c]; + d && "SERVO" === d.type && b.push(["ABCD"[c - 5], c.toString()]); } - return 0 == a.length ? [[Lang.Blocks.no_target, "null"]] : a; + return 0 == b.length ? [[Lang.Blocks.no_target, "null"]] : b; }, dcList:function() { - for (var a = [], b = Entry.hw.portData, c = 5;9 > c;c++) { - var d = b[c]; - d && "DC" === d.type && a.push(["ABCD"[c - 5], c.toString()]); + for (var b = [], a = Entry.hw.portData, c = 5;9 > c;c++) { + var d = a[c]; + d && "DC" === d.type && b.push(["ABCD"[c - 5], c.toString()]); } - return 0 == a.length ? [[Lang.Blocks.no_target, "null"]] : a; + return 0 == b.length ? [[Lang.Blocks.no_target, "null"]] : b; }, setZero:function() { - var a = Entry.hw.sendQueue, b; - for (b in Entry.Bitbrick.PORT_MAP) { - a[b] = 0; + var b = Entry.hw.sendQueue, a; + for (a in Entry.Bitbrick.PORT_MAP) { + b[a] = 0; } Entry.hw.update(); }, name:"bitbrick", servoMaxValue:181, servoMinValue:1, dcMaxValue:100, dcMinValue:-100, monitorTemplate:{keys:["value"], imgPath:"hw/bitbrick.png", width:400, height:400, listPorts:{1:{name:Lang.Hw.port_en + " 1 " + Lang.Hw.port_ko, type:"input", pos:{x:0, y:0}}, 2:{name:Lang.Hw.port_en + " 2 " + Lang.Hw.port_ko, type:"input", pos:{x:0, y:0}}, 3:{name:Lang.Hw.port_en + " 3 " + Lang.Hw.port_ko, type:"input", pos:{x:0, y:0}}, 4:{name:Lang.Hw.port_en + " 4 " + Lang.Hw.port_ko, type:"input", pos:{x:0, @@ -1234,9 +1203,9 @@ Blockly.Blocks.bitbrick_sensor_value = {init:function() { this.setOutput(!0, "String"); this.setInputsInline(!0); }}; -Entry.block.bitbrick_sensor_value = function(a, b) { - a = b.getStringField("PORT"); - return Entry.hw.portData[a].value; +Entry.block.bitbrick_sensor_value = function(b, a) { + var c = a.getStringField("PORT"); + return Entry.hw.portData[c].value; }; Blockly.Blocks.bitbrick_is_touch_pressed = {init:function() { this.setColour("#00979D"); @@ -1244,8 +1213,8 @@ Blockly.Blocks.bitbrick_is_touch_pressed = {init:function() { this.setOutput(!0, "Boolean"); this.setInputsInline(!0); }}; -Entry.block.bitbrick_is_touch_pressed = function(a, b) { - return 0 === Entry.hw.portData[b.getStringField("PORT")].value; +Entry.block.bitbrick_is_touch_pressed = function(b, a) { + return 0 === Entry.hw.portData[a.getStringField("PORT")].value; }; Blockly.Blocks.bitbrick_turn_off_color_led = {init:function() { this.setColour("#00979D"); @@ -1254,11 +1223,11 @@ Blockly.Blocks.bitbrick_turn_off_color_led = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.bitbrick_turn_off_color_led = function(a, b) { +Entry.block.bitbrick_turn_off_color_led = function(b, a) { Entry.hw.sendQueue.LEDR = 0; Entry.hw.sendQueue.LEDG = 0; Entry.hw.sendQueue.LEDB = 0; - return b.callReturn(); + return a.callReturn(); }; Blockly.Blocks.bitbrick_turn_on_color_led_by_rgb = {init:function() { this.setColour("#00979D"); @@ -1273,13 +1242,12 @@ Blockly.Blocks.bitbrick_turn_on_color_led_by_rgb = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.bitbrick_turn_on_color_led_by_rgb = function(a, b) { - a = b.getNumberValue("rValue"); - var c = b.getNumberValue("gValue"), d = b.getNumberValue("bValue"), e = Entry.adjustValueWithMaxMin, f = Entry.hw.sendQueue; - f.LEDR = e(a, 0, 255); - f.LEDG = e(c, 0, 255); - f.LEDB = e(d, 0, 255); - return b.callReturn(); +Entry.block.bitbrick_turn_on_color_led_by_rgb = function(b, a) { + var c = a.getNumberValue("rValue"), d = a.getNumberValue("gValue"), e = a.getNumberValue("bValue"), f = Entry.adjustValueWithMaxMin, g = Entry.hw.sendQueue; + g.LEDR = f(c, 0, 255); + g.LEDG = f(d, 0, 255); + g.LEDB = f(e, 0, 255); + return a.callReturn(); }; Blockly.Blocks.bitbrick_turn_on_color_led_by_picker = {init:function() { this.setColour("#00979D"); @@ -1288,12 +1256,12 @@ Blockly.Blocks.bitbrick_turn_on_color_led_by_picker = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.bitbrick_turn_on_color_led_by_picker = function(a, b) { - a = b.getStringField("VALUE"); - Entry.hw.sendQueue.LEDR = parseInt(a.substr(1, 2), 16); - Entry.hw.sendQueue.LEDG = parseInt(a.substr(3, 2), 16); - Entry.hw.sendQueue.LEDB = parseInt(a.substr(5, 2), 16); - return b.callReturn(); +Entry.block.bitbrick_turn_on_color_led_by_picker = function(b, a) { + var c = a.getStringField("VALUE"); + Entry.hw.sendQueue.LEDR = parseInt(c.substr(1, 2), 16); + Entry.hw.sendQueue.LEDG = parseInt(c.substr(3, 2), 16); + Entry.hw.sendQueue.LEDB = parseInt(c.substr(5, 2), 16); + return a.callReturn(); }; Blockly.Blocks.bitbrick_turn_on_color_led_by_value = {init:function() { this.setColour("#00979D"); @@ -1304,15 +1272,13 @@ Blockly.Blocks.bitbrick_turn_on_color_led_by_value = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.bitbrick_turn_on_color_led_by_value = function(a, b) { - a = b.getNumberValue("VALUE"); - var c, d, e; - a %= 200; - 67 > a ? (c = 200 - 3 * a, d = 3 * a, e = 0) : 134 > a ? (a -= 67, c = 0, d = 200 - 3 * a, e = 3 * a) : 201 > a && (a -= 134, c = 3 * a, d = 0, e = 200 - 3 * a); - Entry.hw.sendQueue.LEDR = c; - Entry.hw.sendQueue.LEDG = d; - Entry.hw.sendQueue.LEDB = e; - return b.callReturn(); +Entry.block.bitbrick_turn_on_color_led_by_value = function(b, a) { + var c = a.getNumberValue("VALUE"), d, e, f, c = c % 200; + 67 > c ? (d = 200 - 3 * c, e = 3 * c, f = 0) : 134 > c ? (c -= 67, d = 0, e = 200 - 3 * c, f = 3 * c) : 201 > c && (c -= 134, d = 3 * c, e = 0, f = 200 - 3 * c); + Entry.hw.sendQueue.LEDR = d; + Entry.hw.sendQueue.LEDG = e; + Entry.hw.sendQueue.LEDB = f; + return a.callReturn(); }; Blockly.Blocks.bitbrick_buzzer = {init:function() { this.setColour("#00979D"); @@ -1323,14 +1289,14 @@ Blockly.Blocks.bitbrick_buzzer = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.bitbrick_buzzer = function(a, b) { - if (b.isStart) { - return Entry.hw.sendQueue.buzzer = 0, delete b.isStart, b.callReturn(); +Entry.block.bitbrick_buzzer = function(b, a) { + if (a.isStart) { + return Entry.hw.sendQueue.buzzer = 0, delete a.isStart, a.callReturn(); } - a = b.getNumberValue("VALUE"); - Entry.hw.sendQueue.buzzer = a; - b.isStart = !0; - return b; + var c = a.getNumberValue("VALUE"); + Entry.hw.sendQueue.buzzer = c; + a.isStart = !0; + return a; }; Blockly.Blocks.bitbrick_turn_off_all_motors = {init:function() { this.setColour("#00979D"); @@ -1339,16 +1305,15 @@ Blockly.Blocks.bitbrick_turn_off_all_motors = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.bitbrick_turn_off_all_motors = function(a, b) { - var c = Entry.hw.sendQueue; - a = Entry.Bitbrick; - a.servoList().map(function(b) { - c[b[1]] = 0; +Entry.block.bitbrick_turn_off_all_motors = function(b, a) { + var c = Entry.hw.sendQueue, d = Entry.Bitbrick; + d.servoList().map(function(a) { + c[a[1]] = 0; }); - a.dcList().map(function(b) { - c[b[1]] = 128; + d.dcList().map(function(a) { + c[a[1]] = 128; }); - return b.callReturn(); + return a.callReturn(); }; Blockly.Blocks.bitbrick_dc_speed = {init:function() { this.setColour("#00979D"); @@ -1359,12 +1324,10 @@ Blockly.Blocks.bitbrick_dc_speed = {init:function() { this.setNextStatement(!0); this.setInputsInline(!0); }}; -Entry.block.bitbrick_dc_speed = function(a, b) { - a = b.getNumberValue("VALUE"); - a = Math.min(a, Entry.Bitbrick.dcMaxValue); - a = Math.max(a, Entry.Bitbrick.dcMinValue); - Entry.hw.sendQueue[b.getStringField("PORT")] = a + 128; - return b.callReturn(); +Entry.block.bitbrick_dc_speed = function(b, a) { + var c = a.getNumberValue("VALUE"), c = Math.min(c, Entry.Bitbrick.dcMaxValue), c = Math.max(c, Entry.Bitbrick.dcMinValue); + Entry.hw.sendQueue[a.getStringField("PORT")] = c + 128; + return a.callReturn(); }; Blockly.Blocks.bitbrick_dc_direction_speed = {init:function() { this.setColour("#00979D"); @@ -1375,11 +1338,10 @@ Blockly.Blocks.bitbrick_dc_direction_speed = {init:function() { this.setNextStatement(!0); this.setInputsInline(!0); }}; -Entry.block.bitbrick_dc_direction_speed = function(a, b) { - a = "CW" === b.getStringField("DIRECTION"); - var c = b.getNumberValue("VALUE"), c = Math.min(c, Entry.Bitbrick.dcMaxValue), c = Math.max(c, 0); - Entry.hw.sendQueue[b.getStringField("PORT")] = a ? c + 128 : 128 - c; - return b.callReturn(); +Entry.block.bitbrick_dc_direction_speed = function(b, a) { + var c = "CW" === a.getStringField("DIRECTION"), d = a.getNumberValue("VALUE"), d = Math.min(d, Entry.Bitbrick.dcMaxValue), d = Math.max(d, 0); + Entry.hw.sendQueue[a.getStringField("PORT")] = c ? d + 128 : 128 - d; + return a.callReturn(); }; Blockly.Blocks.bitbrick_servomotor_angle = {init:function() { this.setColour("#00979D"); @@ -1390,12 +1352,10 @@ Blockly.Blocks.bitbrick_servomotor_angle = {init:function() { this.setNextStatement(!0); this.setInputsInline(!0); }}; -Entry.block.bitbrick_servomotor_angle = function(a, b) { - a = b.getNumberValue("VALUE") + 1; - a = Math.min(a, Entry.Bitbrick.servoMaxValue); - a = Math.max(a, Entry.Bitbrick.servoMinValue); - Entry.hw.sendQueue[b.getStringField("PORT")] = a; - return b.callReturn(); +Entry.block.bitbrick_servomotor_angle = function(b, a) { + var c = a.getNumberValue("VALUE") + 1, c = Math.min(c, Entry.Bitbrick.servoMaxValue), c = Math.max(c, Entry.Bitbrick.servoMinValue); + Entry.hw.sendQueue[a.getStringField("PORT")] = c; + return a.callReturn(); }; Blockly.Blocks.bitbrick_convert_scale = {init:function() { this.setColour("#00979D"); @@ -1412,21 +1372,17 @@ Blockly.Blocks.bitbrick_convert_scale = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.bitbrick_convert_scale = function(a, b) { - a = b.getNumberField("PORT"); - var c = Entry.hw.portData[a].value, d = b.getNumberValue("VALUE2", b), e = b.getNumberValue("VALUE3", b); - a = b.getNumberValue("VALUE4", b); - b = b.getNumberValue("VALUE5", b); - if (a > b) { - var f = a; - a = b; - b = f; - } - c = (b - a) / (e - d) * (c - d); - c += a; - c = Math.min(b, c); - c = Math.max(a, c); - return Math.round(c); +Entry.block.bitbrick_convert_scale = function(b, a) { + var c = a.getNumberField("PORT"), d = Entry.hw.portData[c].value, c = a.getNumberValue("VALUE2", a), e = a.getNumberValue("VALUE3", a), f = a.getNumberValue("VALUE4", a), g = a.getNumberValue("VALUE5", a); + if (f > g) { + var h = f, f = g, g = h + } + d -= c; + d *= (g - f) / (e - c); + d += f; + d = Math.min(g, d); + d = Math.max(f, d); + return Math.round(d); }; var categoryColor = "#FF9E20"; Blockly.Blocks.start_drawing = {init:function() { @@ -1436,11 +1392,11 @@ Blockly.Blocks.start_drawing = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.start_drawing = function(a, b) { - a.brush ? a.brush.stop = !1 : Entry.setBasicBrush(a); +Entry.block.start_drawing = function(b, a) { + b.brush ? b.brush.stop = !1 : Entry.setBasicBrush(b); Entry.stage.sortZorder(); - a.brush.moveTo(a.getX(), -1 * a.getY()); - return b.callReturn(); + b.brush.moveTo(b.getX(), -1 * b.getY()); + return a.callReturn(); }; Blockly.Blocks.stop_drawing = {init:function() { this.setColour(categoryColor); @@ -1449,9 +1405,9 @@ Blockly.Blocks.stop_drawing = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.stop_drawing = function(a, b) { - a.brush && a.shape && (a.brush.stop = !0); - return b.callReturn(); +Entry.block.stop_drawing = function(b, a) { + b.brush && b.shape && (b.brush.stop = !0); + return a.callReturn(); }; Blockly.Blocks.set_color = {init:function() { this.setColour(categoryColor); @@ -1462,11 +1418,11 @@ Blockly.Blocks.set_color = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.set_color = function(a, b) { - var c = b.getField("VALUE", b); - a.brush || (Entry.setBasicBrush(a), a.brush.stop = !0); - a.brush && (c = Entry.hex2rgb(c), a.brush.rgb = c, a.brush.endStroke(), a.brush.beginStroke("rgba(" + c.r + "," + c.g + "," + c.b + "," + a.brush.opacity / 100 + ")"), a.brush.moveTo(a.getX(), -1 * a.getY())); - return b.callReturn(); +Entry.block.set_color = function(b, a) { + var c = a.getField("VALUE", a); + b.brush || (Entry.setBasicBrush(b), b.brush.stop = !0); + b.brush && (c = Entry.hex2rgb(c), b.brush.rgb = c, b.brush.endStroke(), b.brush.beginStroke("rgba(" + c.r + "," + c.g + "," + c.b + "," + b.brush.opacity / 100 + ")"), b.brush.moveTo(b.getX(), -1 * b.getY())); + return a.callReturn(); }; Blockly.Blocks.set_random_color = {init:function() { this.setColour(categoryColor); @@ -1475,16 +1431,16 @@ Blockly.Blocks.set_random_color = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.set_random_color = function(a, b) { - a.brush || (Entry.setBasicBrush(a), a.brush.stop = !0); - if (a.brush) { +Entry.block.set_random_color = function(b, a) { + b.brush || (Entry.setBasicBrush(b), b.brush.stop = !0); + if (b.brush) { var c = Entry.generateRgb(); - a.brush.rgb = c; - a.brush.endStroke(); - a.brush.beginStroke("rgba(" + c.r + "," + c.g + "," + c.b + "," + a.brush.opacity / 100 + ")"); - a.brush.moveTo(a.getX(), -1 * a.getY()); + b.brush.rgb = c; + b.brush.endStroke(); + b.brush.beginStroke("rgba(" + c.r + "," + c.g + "," + c.b + "," + b.brush.opacity / 100 + ")"); + b.brush.moveTo(b.getX(), -1 * b.getY()); } - return b.callReturn(); + return a.callReturn(); }; Blockly.Blocks.change_thickness = {init:function() { this.setColour(categoryColor); @@ -1495,11 +1451,11 @@ Blockly.Blocks.change_thickness = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.change_thickness = function(a, b) { - var c = b.getNumberValue("VALUE", b); - a.brush || (Entry.setBasicBrush(a), a.brush.stop = !0); - a.brush && (a.brush.thickness += c, 1 > a.brush.thickness && (a.brush.thickness = 1), a.brush.setStrokeStyle(a.brush.thickness), a.brush.moveTo(a.getX(), -1 * a.getY())); - return b.callReturn(); +Entry.block.change_thickness = function(b, a) { + var c = a.getNumberValue("VALUE", a); + b.brush || (Entry.setBasicBrush(b), b.brush.stop = !0); + b.brush && (b.brush.thickness += c, 1 > b.brush.thickness && (b.brush.thickness = 1), b.brush.setStrokeStyle(b.brush.thickness), b.brush.moveTo(b.getX(), -1 * b.getY())); + return a.callReturn(); }; Blockly.Blocks.set_thickness = {init:function() { this.setColour(categoryColor); @@ -1510,11 +1466,11 @@ Blockly.Blocks.set_thickness = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.set_thickness = function(a, b) { - var c = b.getNumberValue("VALUE", b); - a.brush || (Entry.setBasicBrush(a), a.brush.stop = !0); - a.brush && (a.brush.thickness = c, a.brush.setStrokeStyle(a.brush.thickness), a.brush.moveTo(a.getX(), -1 * a.getY())); - return b.callReturn(); +Entry.block.set_thickness = function(b, a) { + var c = a.getNumberValue("VALUE", a); + b.brush || (Entry.setBasicBrush(b), b.brush.stop = !0); + b.brush && (b.brush.thickness = c, b.brush.setStrokeStyle(b.brush.thickness), b.brush.moveTo(b.getX(), -1 * b.getY())); + return a.callReturn(); }; Blockly.Blocks.change_opacity = {init:function() { this.setColour(categoryColor); @@ -1525,12 +1481,12 @@ Blockly.Blocks.change_opacity = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.change_opacity = function(a, b) { - var c = b.getNumberValue("VALUE", b); - a.brush || (Entry.setBasicBrush(a), a.brush.stop = !0); - c = Entry.adjustValueWithMaxMin(a.brush.opacity + c, 0, 100); - a.brush && (a.brush.opacity = c, a.brush.endStroke(), c = a.brush.rgb, a.brush.beginStroke("rgba(" + c.r + "," + c.g + "," + c.b + "," + a.brush.opacity / 100 + ")"), a.brush.moveTo(a.getX(), -1 * a.getY())); - return b.callReturn(); +Entry.block.change_opacity = function(b, a) { + var c = a.getNumberValue("VALUE", a); + b.brush || (Entry.setBasicBrush(b), b.brush.stop = !0); + c = Entry.adjustValueWithMaxMin(b.brush.opacity + c, 0, 100); + b.brush && (b.brush.opacity = c, b.brush.endStroke(), c = b.brush.rgb, b.brush.beginStroke("rgba(" + c.r + "," + c.g + "," + c.b + "," + b.brush.opacity / 100 + ")"), b.brush.moveTo(b.getX(), -1 * b.getY())); + return a.callReturn(); }; Blockly.Blocks.set_opacity = {init:function() { this.setColour(categoryColor); @@ -1541,11 +1497,11 @@ Blockly.Blocks.set_opacity = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.set_opacity = function(a, b) { - var c = b.getNumberValue("VALUE", b); - a.brush || (Entry.setBasicBrush(a), a.brush.stop = !0); - a.brush && (a.brush.opacity = Entry.adjustValueWithMaxMin(c, 0, 100), a.brush.endStroke(), c = a.brush.rgb, a.brush.beginStroke("rgba(" + c.r + "," + c.g + "," + c.b + "," + a.brush.opacity / 100 + ")"), a.brush.moveTo(a.getX(), -1 * a.getY())); - return b.callReturn(); +Entry.block.set_opacity = function(b, a) { + var c = a.getNumberValue("VALUE", a); + b.brush || (Entry.setBasicBrush(b), b.brush.stop = !0); + b.brush && (b.brush.opacity = Entry.adjustValueWithMaxMin(c, 0, 100), b.brush.endStroke(), c = b.brush.rgb, b.brush.beginStroke("rgba(" + c.r + "," + c.g + "," + c.b + "," + b.brush.opacity / 100 + ")"), b.brush.moveTo(b.getX(), -1 * b.getY())); + return a.callReturn(); }; Blockly.Blocks.brush_erase_all = {init:function() { this.setColour(categoryColor); @@ -1554,19 +1510,19 @@ Blockly.Blocks.brush_erase_all = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.brush_erase_all = function(a, b) { - var c = a.brush; +Entry.block.brush_erase_all = function(b, a) { + var c = b.brush; if (c) { var d = c._stroke.style, e = c._strokeStyle.width; c.clear().setStrokeStyle(e).beginStroke(d); - c.moveTo(a.getX(), -1 * a.getY()); + c.moveTo(b.getX(), -1 * b.getY()); } - a = a.parent.getStampEntities(); - a.map(function(b) { - b.removeClone(); + c = b.parent.getStampEntities(); + c.map(function(a) { + a.removeClone(); }); - a = null; - return b.callReturn(); + c = null; + return a.callReturn(); }; Blockly.Blocks.brush_stamp = {init:function() { this.setColour(categoryColor); @@ -1575,9 +1531,9 @@ Blockly.Blocks.brush_stamp = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.brush_stamp = function(a, b) { - a.parent.addStampEntity(a); - return b.callReturn(); +Entry.block.brush_stamp = function(b, a) { + b.parent.addStampEntity(b); + return a.callReturn(); }; Blockly.Blocks.change_brush_transparency = {init:function() { this.setColour(categoryColor); @@ -1588,12 +1544,12 @@ Blockly.Blocks.change_brush_transparency = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.change_brush_transparency = function(a, b) { - var c = b.getNumberValue("VALUE", b); - a.brush || (Entry.setBasicBrush(a), a.brush.stop = !0); - c = Entry.adjustValueWithMaxMin(a.brush.opacity - c, 0, 100); - a.brush && (a.brush.opacity = c, a.brush.endStroke(), c = a.brush.rgb, a.brush.beginStroke("rgba(" + c.r + "," + c.g + "," + c.b + "," + a.brush.opacity / 100 + ")"), a.brush.moveTo(a.getX(), -1 * a.getY())); - return b.callReturn(); +Entry.block.change_brush_transparency = function(b, a) { + var c = a.getNumberValue("VALUE", a); + b.brush || (Entry.setBasicBrush(b), b.brush.stop = !0); + c = Entry.adjustValueWithMaxMin(b.brush.opacity - c, 0, 100); + b.brush && (b.brush.opacity = c, b.brush.endStroke(), c = b.brush.rgb, b.brush.beginStroke("rgba(" + c.r + "," + c.g + "," + c.b + "," + b.brush.opacity / 100 + ")"), b.brush.moveTo(b.getX(), -1 * b.getY())); + return a.callReturn(); }; Blockly.Blocks.set_brush_tranparency = {init:function() { this.setColour(categoryColor); @@ -1604,11 +1560,11 @@ Blockly.Blocks.set_brush_tranparency = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.set_brush_tranparency = function(a, b) { - var c = b.getNumberValue("VALUE", b); - a.brush || (Entry.setBasicBrush(a), a.brush.stop = !0); - a.brush && (a.brush.opacity = Entry.adjustValueWithMaxMin(c, 0, 100), a.brush.endStroke(), c = a.brush.rgb, a.brush.beginStroke("rgba(" + c.r + "," + c.g + "," + c.b + "," + (1 - a.brush.opacity / 100) + ")"), a.brush.moveTo(a.getX(), -1 * a.getY())); - return b.callReturn(); +Entry.block.set_brush_tranparency = function(b, a) { + var c = a.getNumberValue("VALUE", a); + b.brush || (Entry.setBasicBrush(b), b.brush.stop = !0); + b.brush && (b.brush.opacity = Entry.adjustValueWithMaxMin(c, 0, 100), b.brush.endStroke(), c = b.brush.rgb, b.brush.beginStroke("rgba(" + c.r + "," + c.g + "," + c.b + "," + (1 - b.brush.opacity / 100) + ")"), b.brush.moveTo(b.getX(), -1 * b.getY())); + return a.callReturn(); }; var calcArrowColor = "#e8b349", calcBlockColor = "#FFD974", calcFontColor = "#3D3D3D"; Blockly.Blocks.number = {init:function() { @@ -1617,8 +1573,8 @@ Blockly.Blocks.number = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.number = function(a, b) { - return b.getField("NUM", b); +Entry.block.number = function(b, a) { + return a.getField("NUM", a); }; Blockly.Blocks.angle = {init:function() { this.setColour(calcBlockColor); @@ -1626,8 +1582,8 @@ Blockly.Blocks.angle = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.angle = function(a, b) { - return b.getNumberField("ANGLE"); +Entry.block.angle = function(b, a) { + return a.getNumberField("ANGLE"); }; Blockly.Blocks.get_x_coordinate = {init:function() { this.setColour(calcBlockColor); @@ -1635,8 +1591,8 @@ Blockly.Blocks.get_x_coordinate = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.get_x_coordinate = function(a, b) { - return a.getX(); +Entry.block.get_x_coordinate = function(b, a) { + return b.getX(); }; Blockly.Blocks.get_y_coordinate = {init:function() { this.setColour(calcBlockColor); @@ -1644,8 +1600,8 @@ Blockly.Blocks.get_y_coordinate = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.get_y_coordinate = function(a, b) { - return a.getY(); +Entry.block.get_y_coordinate = function(b, a) { + return b.getY(); }; Blockly.Blocks.get_angle = {init:function() { this.setColour(calcBlockColor); @@ -1653,8 +1609,8 @@ Blockly.Blocks.get_angle = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.get_angle = function(a, b) { - return parseFloat(a.getRotation().toFixed(1)); +Entry.block.get_angle = function(b, a) { + return parseFloat(b.getRotation().toFixed(1)); }; Blockly.Blocks.get_rotation_direction = {init:function() { this.setColour(calcBlockColor); @@ -1663,8 +1619,8 @@ Blockly.Blocks.get_rotation_direction = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.get_rotation_direction = function(a, b) { - return "DIRECTION" == b.getField("OPERATOR", b).toUpperCase() ? parseFloat(a.getDirection().toFixed(1)) : parseFloat(a.getRotation().toFixed(1)); +Entry.block.get_rotation_direction = function(b, a) { + return "DIRECTION" == a.getField("OPERATOR", a).toUpperCase() ? parseFloat(b.getDirection().toFixed(1)) : parseFloat(b.getRotation().toFixed(1)); }; Blockly.Blocks.distance_something = {init:function() { this.setColour(calcBlockColor); @@ -1672,13 +1628,13 @@ Blockly.Blocks.distance_something = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.distance_something = function(a, b) { - b = b.getField("VALUE", b); - if ("mouse" == b) { - return b = Entry.stage.mouseCoordinate, Math.sqrt(Math.pow(a.getX() - b.x, 2) + Math.pow(a.getY() - b.y, 2)); +Entry.block.distance_something = function(b, a) { + var c = a.getField("VALUE", a); + if ("mouse" == c) { + return c = Entry.stage.mouseCoordinate, Math.sqrt(Math.pow(b.getX() - c.x, 2) + Math.pow(b.getY() - c.y, 2)); } - b = Entry.container.getEntity(b); - return Math.sqrt(Math.pow(a.getX() - b.getX(), 2) + Math.pow(a.getY() - b.getY(), 2)); + c = Entry.container.getEntity(c); + return Math.sqrt(Math.pow(b.getX() - c.getX(), 2) + Math.pow(b.getY() - c.getY(), 2)); }; Blockly.Blocks.coordinate_mouse = {init:function() { this.setColour(calcBlockColor); @@ -1686,8 +1642,8 @@ Blockly.Blocks.coordinate_mouse = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.coordinate_mouse = function(a, b) { - return "x" === b.getField("VALUE", b) ? Number(Entry.stage.mouseCoordinate.x) : Number(Entry.stage.mouseCoordinate.y); +Entry.block.coordinate_mouse = function(b, a) { + return "x" === a.getField("VALUE", a) ? +Entry.stage.mouseCoordinate.x : +Entry.stage.mouseCoordinate.y; }; Blockly.Blocks.coordinate_object = {init:function() { this.setColour(calcBlockColor); @@ -1696,24 +1652,24 @@ Blockly.Blocks.coordinate_object = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.coordinate_object = function(a, b) { - var c = b.getField("VALUE", b); - a = "self" == c ? a : Entry.container.getEntity(c); - switch(b.getField("COORDINATE", b)) { +Entry.block.coordinate_object = function(b, a) { + var c = a.getField("VALUE", a), c = "self" == c ? b : Entry.container.getEntity(c); + switch(a.getField("COORDINATE", a)) { case "x": - return a.getX(); + return c.getX(); case "y": - return a.getY(); + return c.getY(); case "rotation": - return a.getRotation(); + return c.getRotation(); case "direction": - return a.getDirection(); + return c.getDirection(); case "picture_index": - return b = a.parent, b = b.pictures, b.indexOf(a.picture) + 1; + var d = c.parent, d = d.pictures; + return d.indexOf(c.picture) + 1; case "size": - return Number(a.getSize().toFixed(1)); + return +c.getSize().toFixed(1); case "picture_name": - return b = a.parent, b = b.pictures, b[b.indexOf(a.picture)].name; + return d = c.parent, d = d.pictures, d[d.indexOf(c.picture)].name; } }; Blockly.Blocks.calc_basic = {init:function() { @@ -1724,11 +1680,9 @@ Blockly.Blocks.calc_basic = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.calc_basic = function(a, b) { - a = b.getField("OPERATOR", b); - var c = b.getNumberValue("LEFTHAND", b); - b = b.getNumberValue("RIGHTHAND", b); - return "PLUS" == a ? c + b : "MINUS" == a ? c - b : "MULTI" == a ? c * b : c / b; +Entry.block.calc_basic = function(b, a) { + var c = a.getField("OPERATOR", a), d = a.getNumberValue("LEFTHAND", a), e = a.getNumberValue("RIGHTHAND", a); + return "PLUS" == c ? d + e : "MINUS" == c ? d - e : "MULTI" == c ? d * e : d / e; }; Blockly.Blocks.calc_plus = {init:function() { this.setColour(calcBlockColor); @@ -1738,10 +1692,9 @@ Blockly.Blocks.calc_plus = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.calc_plus = function(a, b) { - a = b.getNumberValue("LEFTHAND", b); - b = b.getNumberValue("RIGHTHAND", b); - return a + b; +Entry.block.calc_plus = function(b, a) { + var c = a.getNumberValue("LEFTHAND", a), d = a.getNumberValue("RIGHTHAND", a); + return c + d; }; Blockly.Blocks.calc_minus = {init:function() { this.setColour(calcBlockColor); @@ -1751,10 +1704,9 @@ Blockly.Blocks.calc_minus = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.calc_minus = function(a, b) { - a = b.getNumberValue("LEFTHAND", b); - b = b.getNumberValue("RIGHTHAND", b); - return a - b; +Entry.block.calc_minus = function(b, a) { + var c = a.getNumberValue("LEFTHAND", a), d = a.getNumberValue("RIGHTHAND", a); + return c - d; }; Blockly.Blocks.calc_times = {init:function() { this.setColour(calcBlockColor); @@ -1764,10 +1716,9 @@ Blockly.Blocks.calc_times = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.calc_times = function(a, b) { - a = b.getNumberValue("LEFTHAND", b); - b = b.getNumberValue("RIGHTHAND", b); - return a * b; +Entry.block.calc_times = function(b, a) { + var c = a.getNumberValue("LEFTHAND", a), d = a.getNumberValue("RIGHTHAND", a); + return c * d; }; Blockly.Blocks.calc_divide = {init:function() { this.setColour(calcBlockColor); @@ -1777,10 +1728,9 @@ Blockly.Blocks.calc_divide = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.calc_divide = function(a, b) { - a = b.getNumberValue("LEFTHAND", b); - b = b.getNumberValue("RIGHTHAND", b); - return a / b; +Entry.block.calc_divide = function(b, a) { + var c = a.getNumberValue("LEFTHAND", a), d = a.getNumberValue("RIGHTHAND", a); + return c / d; }; Blockly.Blocks.calc_mod = {init:function() { this.setColour(calcBlockColor); @@ -1792,10 +1742,9 @@ Blockly.Blocks.calc_mod = {init:function() { this.appendDummyInput("VALUE").appendField(Lang.Blocks.CALC_calc_mod_3, calcFontColor); this.setInputsInline(!0); }}; -Entry.block.calc_mod = function(a, b) { - a = b.getNumberValue("LEFTHAND", b); - b = b.getNumberValue("RIGHTHAND", b); - return a % b; +Entry.block.calc_mod = function(b, a) { + var c = a.getNumberValue("LEFTHAND", a), d = a.getNumberValue("RIGHTHAND", a); + return c % d; }; Blockly.Blocks.calc_share = {init:function() { this.setColour(calcBlockColor); @@ -1807,10 +1756,9 @@ Blockly.Blocks.calc_share = {init:function() { this.appendDummyInput("VALUE").appendField(Lang.Blocks.CALC_calc_share_3, calcFontColor); this.setInputsInline(!0); }}; -Entry.block.calc_share = function(a, b) { - a = b.getNumberValue("LEFTHAND", b); - b = b.getNumberValue("RIGHTHAND", b); - return Math.floor(a / b); +Entry.block.calc_share = function(b, a) { + var c = a.getNumberValue("LEFTHAND", a), d = a.getNumberValue("RIGHTHAND", a); + return Math.floor(c / d); }; Blockly.Blocks.calc_operation = {init:function() { this.setColour(calcBlockColor); @@ -1823,45 +1771,45 @@ Blockly.Blocks.calc_operation = {init:function() { this.appendDummyInput().appendField(" "); this.setInputsInline(!0); }}; -Entry.block.calc_operation = function(a, b) { - a = b.getNumberValue("LEFTHAND", b); - b = b.getField("VALUE", b); - if (-1 < ["asin_radian", "acos_radian"].indexOf(b) && (1 < a || -1 > a)) { +Entry.block.calc_operation = function(b, a) { + var c = a.getNumberValue("LEFTHAND", a), d = a.getField("VALUE", a); + if (-1 < ["asin_radian", "acos_radian"].indexOf(d) && (1 < c || -1 > c)) { throw Error("x range exceeded"); } - b.indexOf("_") && (b = b.split("_")[0]); - -1 < ["sin", "cos", "tan"].indexOf(b) && (a = Entry.toRadian(a)); - switch(b) { + d.indexOf("_") && (d = d.split("_")[0]); + -1 < ["sin", "cos", "tan"].indexOf(d) && (c = Entry.toRadian(c)); + var e = 0; + switch(d) { case "square": - b = a * a; + e = c * c; break; case "factorial": - b = Entry.factorial(a); + e = Entry.factorial(c); break; case "root": - b = Math.sqrt(a); + e = Math.sqrt(c); break; case "log": - b = Math.log(a) / Math.LN10; + e = Math.log(c) / Math.LN10; break; case "ln": - b = Math.log(a); + e = Math.log(c); break; case "asin": ; case "acos": ; case "atan": - b = Entry.toDegrees(Math[b](a)); + e = Entry.toDegrees(Math[d](c)); break; case "unnatural": - b = a - Math.floor(a); - 0 > a && (b = 1 - b); + e = c - Math.floor(c); + 0 > c && (e = 1 - e); break; default: - b = Math[b](a); + e = Math[d](c); } - return Math.round(1E3 * b) / 1E3; + return Math.round(1E3 * e) / 1E3; }; Blockly.Blocks.calc_rand = {init:function() { this.setColour(calcBlockColor); @@ -1873,12 +1821,9 @@ Blockly.Blocks.calc_rand = {init:function() { this.appendDummyInput("VALUE").appendField(Lang.Blocks.CALC_calc_rand_3, calcFontColor); this.setInputsInline(!0); }}; -Entry.block.calc_rand = function(a, b) { - a = b.getStringValue("LEFTHAND", b); - b = b.getStringValue("RIGHTHAND", b); - var c = Math.min(a, b), d = Math.max(a, b); - a = Entry.isFloat(a); - return Entry.isFloat(b) || a ? (Math.random() * (d - c) + c).toFixed(2) : Math.floor(Math.random() * (d - c + 1) + c); +Entry.block.calc_rand = function(b, a) { + var c = a.getStringValue("LEFTHAND", a), d = a.getStringValue("RIGHTHAND", a), e = Math.min(c, d), f = Math.max(c, d), c = Entry.isFloat(c); + return Entry.isFloat(d) || c ? (Math.random() * (f - e) + e).toFixed(2) : Math.floor(Math.random() * (f - e + 1) + e); }; Blockly.Blocks.get_date = {init:function() { this.setColour(calcBlockColor); @@ -1887,10 +1832,9 @@ Blockly.Blocks.get_date = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.get_date = function(a, b) { - a = b.getField("VALUE", b); - b = new Date; - return "YEAR" == a ? b.getFullYear() : "MONTH" == a ? b.getMonth() + 1 : "DAY" == a ? b.getDate() : "HOUR" == a ? b.getHours() : "MINUTE" == a ? b.getMinutes() : b.getSeconds(); +Entry.block.get_date = function(b, a) { + var c = a.getField("VALUE", a), d = new Date; + return "YEAR" == c ? d.getFullYear() : "MONTH" == c ? d.getMonth() + 1 : "DAY" == c ? d.getDate() : "HOUR" == c ? d.getHours() : "MINUTE" == c ? d.getMinutes() : d.getSeconds(); }; Blockly.Blocks.get_sound_duration = {init:function() { this.setColour(calcBlockColor); @@ -1900,12 +1844,10 @@ Blockly.Blocks.get_sound_duration = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.get_sound_duration = function(a, b) { - b = b.getField("VALUE", b); - a = a.parent.sounds; - for (var c = 0;c < a.length;c++) { - if (a[c].id == b) { - return a[c].duration; +Entry.block.get_sound_duration = function(b, a) { + for (var c = a.getField("VALUE", a), d = b.parent.sounds, e = 0;e < d.length;e++) { + if (d[e].id == c) { + return d[e].duration; } } }; @@ -1917,12 +1859,12 @@ Blockly.Blocks.reset_project_timer = {init:function() { this.setNextStatement(!0); }, whenAdd:function() { Entry.engine && Entry.engine.showProjectTimer(); -}, whenRemove:function(a) { - Entry.engine && Entry.engine.hideProjectTimer(a); +}, whenRemove:function(b) { + Entry.engine && Entry.engine.hideProjectTimer(b); }}; -Entry.block.reset_project_timer = function(a, b) { +Entry.block.reset_project_timer = function(b, a) { Entry.engine.updateProjectTimer(0); - return b.callReturn(); + return a.callReturn(); }; Blockly.Blocks.set_visible_project_timer = {init:function() { this.setColour(calcBlockColor); @@ -1934,14 +1876,13 @@ Blockly.Blocks.set_visible_project_timer = {init:function() { this.setNextStatement(!0); }, whenAdd:function() { Entry.engine && Entry.engine.showProjectTimer(); -}, whenRemove:function(a) { - Entry.engine && Entry.engine.hideProjectTimer(a); +}, whenRemove:function(b) { + Entry.engine && Entry.engine.hideProjectTimer(b); }}; -Entry.block.set_visible_project_timer = function(a, b) { - a = b.getField("ACTION", b); - var c = Entry.engine.projectTimer; - "SHOW" == a ? c.setVisible(!0) : c.setVisible(!1); - return b.callReturn(); +Entry.block.set_visible_project_timer = function(b, a) { + var c = a.getField("ACTION", a), d = Entry.engine.projectTimer; + "SHOW" == c ? d.setVisible(!0) : d.setVisible(!1); + return a.callReturn(); }; Blockly.Blocks.timer_variable = {init:function() { this.setColour(calcBlockColor); @@ -1949,7 +1890,7 @@ Blockly.Blocks.timer_variable = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.timer_variable = function(a, b) { +Entry.block.timer_variable = function(b, a) { return Entry.container.inputValue.getValue(); }; Blockly.Blocks.get_project_timer_value = {init:function() { @@ -1959,10 +1900,10 @@ Blockly.Blocks.get_project_timer_value = {init:function() { this.setInputsInline(!0); }, whenAdd:function() { Entry.engine && Entry.engine.showProjectTimer(); -}, whenRemove:function(a) { - Entry.engine && Entry.engine.hideProjectTimer(a); +}, whenRemove:function(b) { + Entry.engine && Entry.engine.hideProjectTimer(b); }}; -Entry.block.get_project_timer_value = function(a, b) { +Entry.block.get_project_timer_value = function(b, a) { return Entry.engine.projectTimer.getValue(); }; Blockly.Blocks.char_at = {init:function() { @@ -1975,13 +1916,12 @@ Blockly.Blocks.char_at = {init:function() { this.appendDummyInput("VALUE").appendField(Lang.Blocks.CALC_char_at_3, calcFontColor); this.setInputsInline(!0); }}; -Entry.block.char_at = function(a, b) { - a = b.getStringValue("LEFTHAND", b); - b = b.getNumberValue("RIGHTHAND", b) - 1; - if (0 > b || b > a.length - 1) { +Entry.block.char_at = function(b, a) { + var c = a.getStringValue("LEFTHAND", a), d = a.getNumberValue("RIGHTHAND", a) - 1; + if (0 > d || d > c.length - 1) { throw Error(); } - return a[b]; + return c[d]; }; Blockly.Blocks.length_of_string = {init:function() { this.setColour(calcBlockColor); @@ -1991,8 +1931,8 @@ Blockly.Blocks.length_of_string = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.length_of_string = function(a, b) { - return b.getStringValue("STRING", b).length; +Entry.block.length_of_string = function(b, a) { + return a.getStringValue("STRING", a).length; }; Blockly.Blocks.substring = {init:function() { this.setColour(calcBlockColor); @@ -2006,15 +1946,12 @@ Blockly.Blocks.substring = {init:function() { this.setOutput(!0, "String"); this.setInputsInline(!0); }}; -Entry.block.substring = function(a, b) { - a = b.getStringValue("STRING", b); - var c = b.getNumberValue("START", b) - 1; - b = b.getNumberValue("END", b) - 1; - var d = a.length - 1; - if (0 > c || 0 > b || c > d || b > d) { +Entry.block.substring = function(b, a) { + var c = a.getStringValue("STRING", a), d = a.getNumberValue("START", a) - 1, e = a.getNumberValue("END", a) - 1, f = c.length - 1; + if (0 > d || 0 > e || d > f || e > f) { throw Error(); } - return a.substring(Math.min(c, b), Math.max(c, b) + 1); + return c.substring(Math.min(d, e), Math.max(d, e) + 1); }; Blockly.Blocks.replace_string = {init:function() { this.setColour(calcBlockColor); @@ -2028,8 +1965,8 @@ Blockly.Blocks.replace_string = {init:function() { this.setOutput(!0, "String"); this.setInputsInline(!0); }}; -Entry.block.replace_string = function(a, b) { - return b.getStringValue("STRING", b).replace(new RegExp(b.getStringValue("OLD_WORD", b), "gm"), b.getStringValue("NEW_WORD", b)); +Entry.block.replace_string = function(b, a) { + return a.getStringValue("STRING", a).replace(new RegExp(a.getStringValue("OLD_WORD", a), "gm"), a.getStringValue("NEW_WORD", a)); }; Blockly.Blocks.change_string_case = {init:function() { this.setColour(calcBlockColor); @@ -2041,8 +1978,8 @@ Blockly.Blocks.change_string_case = {init:function() { this.setOutput(!0, "String"); this.setInputsInline(!0); }}; -Entry.block.change_string_case = function(a, b) { - return b.getStringValue("STRING", b)[b.getField("CASE", b)](); +Entry.block.change_string_case = function(b, a) { + return a.getStringValue("STRING", a)[a.getField("CASE", a)](); }; Blockly.Blocks.index_of_string = {init:function() { this.setColour(calcBlockColor); @@ -2054,11 +1991,9 @@ Blockly.Blocks.index_of_string = {init:function() { this.appendDummyInput("VALUE").appendField(Lang.Blocks.CALC_index_of_string_3, calcFontColor); this.setInputsInline(!0); }}; -Entry.block.index_of_string = function(a, b) { - a = b.getStringValue("LEFTHAND", b); - b = b.getStringValue("RIGHTHAND", b); - b = a.indexOf(b); - return -1 < b ? b + 1 : 0; +Entry.block.index_of_string = function(b, a) { + var c = a.getStringValue("LEFTHAND", a), d = a.getStringValue("RIGHTHAND", a), c = c.indexOf(d); + return -1 < c ? c + 1 : 0; }; Blockly.Blocks.combine_something = {init:function() { this.setColour(calcBlockColor); @@ -2070,10 +2005,9 @@ Blockly.Blocks.combine_something = {init:function() { this.setInputsInline(!0); this.setOutput(!0, "String"); }}; -Entry.block.combine_something = function(a, b) { - a = b.getStringValue("VALUE1", b); - b = b.getStringValue("VALUE2", b); - return a + b; +Entry.block.combine_something = function(b, a) { + var c = a.getStringValue("VALUE1", a), d = a.getStringValue("VALUE2", a); + return c + d; }; Blockly.Blocks.get_sound_volume = {init:function() { this.setColour(calcBlockColor); @@ -2081,7 +2015,7 @@ Blockly.Blocks.get_sound_volume = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.get_sound_volume = function(a, b) { +Entry.block.get_sound_volume = function(b, a) { return 100 * createjs.Sound.getVolume(); }; Blockly.Blocks.quotient_and_mod = {init:function() { @@ -2093,13 +2027,12 @@ Blockly.Blocks.quotient_and_mod = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.quotient_and_mod = function(a, b) { - a = b.getNumberValue("LEFTHAND", b); - var c = b.getNumberValue("RIGHTHAND", b); - if (isNaN(a) || isNaN(c)) { +Entry.block.quotient_and_mod = function(b, a) { + var c = a.getNumberValue("LEFTHAND", a), d = a.getNumberValue("RIGHTHAND", a); + if (isNaN(c) || isNaN(d)) { throw Error(); } - return "QUOTIENT" == b.getField("OPERATOR", b) ? Math.floor(a / c) : a % c; + return "QUOTIENT" == a.getField("OPERATOR", a) ? Math.floor(c / d) : c % d; }; Blockly.Blocks.choose_project_timer_action = {init:function() { this.setColour(calcBlockColor); @@ -2110,14 +2043,13 @@ Blockly.Blocks.choose_project_timer_action = {init:function() { this.setNextStatement(!0); }, whenAdd:function() { Entry.engine && Entry.engine.showProjectTimer(); -}, whenRemove:function(a) { - Entry.engine && Entry.engine.hideProjectTimer(a); +}, whenRemove:function(b) { + Entry.engine && Entry.engine.hideProjectTimer(b); }}; -Entry.block.choose_project_timer_action = function(a, b) { - a = b.getField("ACTION"); - var c = Entry.engine, d = c.projectTimer; - "START" == a ? d.isInit ? d.isInit && d.isPaused && (d.pauseStart && (d.pausedTime += (new Date).getTime() - d.pauseStart), delete d.pauseStart, d.isPaused = !1) : c.startProjectTimer() : "STOP" == a ? d.isInit && !d.isPaused && (d.isPaused = !0, d.pauseStart = (new Date).getTime()) : "RESET" == a && d.isInit && (d.setValue(0), d.start = (new Date).getTime(), d.pausedTime = 0, delete d.pauseStart); - return b.callReturn(); +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"); @@ -2128,23 +2060,23 @@ Blockly.Blocks.wait_second = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.wait_second = function(a, b) { - if (b.isStart) { - if (1 == b.timeFlag) { - return b; +Entry.block.wait_second = function(b, a) { + if (a.isStart) { + if (1 == a.timeFlag) { + return a; } - delete b.timeFlag; - delete b.isStart; + delete a.timeFlag; + delete a.isStart; Entry.engine.isContinue = !1; - return b.callReturn(); + return a.callReturn(); } - b.isStart = !0; - b.timeFlag = 1; - a = b.getNumberValue("SECOND", b); + a.isStart = !0; + a.timeFlag = 1; + var c = a.getNumberValue("SECOND", a), c = 60 / (Entry.FPS || 60) * c * 1E3; setTimeout(function() { - b.timeFlag = 0; - }, 60 / (Entry.FPS || 60) * a * 1E3); - return b; + a.timeFlag = 0; + }, c); + return a; }; Blockly.Blocks.repeat_basic = {init:function() { this.setColour("#498deb"); @@ -2156,20 +2088,21 @@ Blockly.Blocks.repeat_basic = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.repeat_basic = function(a, b) { - if (!b.isLooped) { - b.isLooped = !0; - a = b.getNumberValue("VALUE", b); - if (0 > a) { +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); } - b.iterCount = Math.floor(a); + a.iterCount = Math.floor(c); } - if (0 == b.iterCount || 0 > b.iterCount) { - return delete b.isLooped, delete b.iterCount, b.callReturn(); + if (0 == a.iterCount || 0 > a.iterCount) { + return delete a.isLooped, delete a.iterCount, a.callReturn(); } - b.iterCount--; - return b.getStatement("DO", b); + a.iterCount--; + return a.getStatement("DO", a); }; Blockly.Blocks.repeat_inf = {init:function() { this.setColour("#498deb"); @@ -2179,9 +2112,9 @@ Blockly.Blocks.repeat_inf = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.repeat_inf = function(a, b) { - b.isLooped = !0; - return b.getStatement("DO"); +Entry.block.repeat_inf = function(b, a) { + a.isLooped = !0; + return a.getStatement("DO"); }; Blockly.Blocks.stop_repeat = {init:function() { this.setColour("#498deb"); @@ -2190,7 +2123,7 @@ Blockly.Blocks.stop_repeat = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.stop_repeat = function(a, b) { +Entry.block.stop_repeat = function(b, a) { return this.executor.break(); }; Blockly.Blocks.wait_until_true = {init:function() { @@ -2202,8 +2135,8 @@ Blockly.Blocks.wait_until_true = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.wait_until_true = function(a, b) { - return b.getBooleanValue("BOOL", b) ? b.callReturn() : b; +Entry.block.wait_until_true = function(b, a) { + return a.getBooleanValue("BOOL", a) ? a.callReturn() : a; }; Blockly.Blocks._if = {init:function() { this.setColour("#498deb"); @@ -2215,8 +2148,8 @@ Blockly.Blocks._if = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block._if = function(a, b) { - return b.isLooped ? (delete b.isLooped, b.callReturn()) : b.getBooleanValue("BOOL", b) ? (b.isLooped = !0, b.getStatement("STACK", b)) : b.callReturn(); +Entry.block._if = function(b, a) { + return a.isLooped ? (delete a.isLooped, a.callReturn()) : a.getBooleanValue("BOOL", a) ? (a.isLooped = !0, a.getStatement("STACK", a)) : a.callReturn(); }; Blockly.Blocks.if_else = {init:function() { this.setColour("#498deb"); @@ -2230,13 +2163,13 @@ Blockly.Blocks.if_else = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.if_else = function(a, b) { - if (b.isLooped) { - return delete b.isLooped, b.callReturn(); +Entry.block.if_else = function(b, a) { + if (a.isLooped) { + return delete a.isLooped, a.callReturn(); } - a = b.getBooleanValue("BOOL", b); - b.isLooped = !0; - return a ? b.getStatement("STACK_IF", b) : b.getStatement("STACK_ELSE", b); + var c = a.getBooleanValue("BOOL", a); + a.isLooped = !0; + return c ? a.getStatement("STACK_IF", a) : a.getStatement("STACK_ELSE", a); }; Blockly.Blocks.create_clone = {init:function() { this.setColour("#498deb"); @@ -2247,11 +2180,10 @@ Blockly.Blocks.create_clone = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.create_clone = function(a, b) { - var c = b.getField("VALUE", b); - b = b.callReturn(); - "self" == c ? a.parent.addCloneEntity(a.parent, a, null) : Entry.container.getObject(c).addCloneEntity(a.parent, null, null); - return b; +Entry.block.create_clone = function(b, a) { + var c = a.getField("VALUE", a), d = a.callReturn(); + "self" == c ? b.parent.addCloneEntity(b.parent, b, null) : Entry.container.getObject(c).addCloneEntity(b.parent, null, null); + return d; }; Blockly.Blocks.delete_clone = {init:function() { this.setColour("#498deb"); @@ -2259,11 +2191,11 @@ Blockly.Blocks.delete_clone = {init:function() { this.setInputsInline(!0); this.setPreviousStatement(!0); }}; -Entry.block.delete_clone = function(a, b) { - if (!a.isClone) { - return b.callReturn(); +Entry.block.delete_clone = function(b, a) { + if (!b.isClone) { + return a.callReturn(); } - a.removeClone(); + b.removeClone(); }; Blockly.Blocks.when_clone_start = {init:function() { this.setColour("#498deb"); @@ -2271,8 +2203,8 @@ Blockly.Blocks.when_clone_start = {init:function() { this.setInputsInline(!0); this.setNextStatement(!0); }}; -Entry.block.when_clone_start = function(a, b) { - return b.callReturn(); +Entry.block.when_clone_start = function(b, a) { + return a.callReturn(); }; Blockly.Blocks.stop_run = {init:function() { this.setColour("#498deb"); @@ -2281,7 +2213,7 @@ Blockly.Blocks.stop_run = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.stop_run = function(a, b) { +Entry.block.stop_run = function(b, a) { return Entry.engine.toggleStop(); }; Blockly.Blocks.repeat_while_true = {init:function() { @@ -2293,10 +2225,10 @@ Blockly.Blocks.repeat_while_true = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.repeat_while_true = function(a, b) { - a = b.getBooleanValue("BOOL", b); - "until" == b.getField("OPTION", b) && (a = !a); - return (b.isLooped = a) ? b.getStatement("DO", b) : b.callReturn(); +Entry.block.repeat_while_true = function(b, a) { + var c = a.getBooleanValue("BOOL", a); + "until" == a.getField("OPTION", a) && (c = !c); + return (a.isLooped = c) ? a.getStatement("DO", a) : a.callReturn(); }; Blockly.Blocks.stop_object = {init:function() { this.setColour("#498deb"); @@ -2307,18 +2239,17 @@ Blockly.Blocks.stop_object = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.stop_object = function(a, b) { - b = b.getField("TARGET", b); - var c = Entry.container; - switch(b) { +Entry.block.stop_object = function(b, a) { + var c = a.getField("TARGET", a), d = Entry.container; + switch(c) { case "all": - return c.clearRunningState(), this.die(); + return d.clearRunningState(), this.die(); case "thisOnly": - return a.parent.script.clearExecutorsByEntity(a), this.die(); + return b.parent.script.clearExecutorsByEntity(b), this.die(); case "thisThread": return this.die(); case "otherThread": - a.parent.script.clearExecutors(), a.parent.script.addExecutor(this.executor); + b.parent.script.clearExecutors(), b.parent.script.addExecutor(this.executor); } }; Blockly.Blocks.restart_project = {init:function() { @@ -2327,7 +2258,7 @@ Blockly.Blocks.restart_project = {init:function() { this.setInputsInline(!0); this.setPreviousStatement(!0); }}; -Entry.block.restart_project = function(a, b) { +Entry.block.restart_project = function(b, a) { Entry.engine.toggleStop(); Entry.engine.toggleRun(); }; @@ -2338,13 +2269,13 @@ Blockly.Blocks.remove_all_clones = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.remove_all_clones = function(a, b) { - a = a.parent.getClonedEntities(); - a.map(function(b) { - b.removeClone(); +Entry.block.remove_all_clones = function(b, a) { + var c = b.parent.getClonedEntities(); + c.map(function(a) { + a.removeClone(); }); - a = null; - return b.callReturn(); + c = null; + return a.callReturn(); }; Entry.block.functionAddButton = {skeleton:"basic_button", color:"#eee", isNotFor:["functionInit"], template:"%1", params:[{type:"Text", text:"\ud568\uc218 \ucd94\uac00", color:"#333", align:"center"}], events:{mousedown:[function() { Entry.variableContainer.createFunction(); @@ -2378,18 +2309,18 @@ Blockly.Blocks.function_param_string = {init:function() { this.setColour("#FFD974"); this.setOutput(!0, ["String", "Number"]); this.setInputsInline(!0); -}, domToMutation:function(a) { - a.getElementsByTagName("field"); - this.hashId = a.getAttribute("hashid"); - (a = Entry.Func.targetFunc.stringHash[this.hashId]) || (a = ""); - this.appendDummyInput().appendField(new Blockly.FieldTextInput(Lang.Blocks.FUNCTION_character_variable + a), ""); +}, domToMutation:function(b) { + b.getElementsByTagName("field"); + this.hashId = b.getAttribute("hashid"); + (b = Entry.Func.targetFunc.stringHash[this.hashId]) || (b = ""); + this.appendDummyInput().appendField(new Blockly.FieldTextInput(Lang.Blocks.FUNCTION_character_variable + b), ""); }, mutationToDom:function() { - var a = document.createElement("mutation"); - a.setAttribute("hashid", this.hashId); - return a; + var b = document.createElement("mutation"); + b.setAttribute("hashid", this.hashId); + return b; }}; -Entry.block.function_param_string = function(a, b, c) { - return b.register[b.hashId].run(); +Entry.block.function_param_string = function(b, a, c) { + return a.register[a.hashId].run(); }; Entry.block.function_param_string = {skeleton:"basic_string_field", color:"#ffd974", template:"\ubb38\uc790/\uc22b\uc790\uac12", func:function() { return this.executor.register.params[this.executor.register.paramMap[this.block.type]]; @@ -2399,18 +2330,18 @@ Blockly.Blocks.function_param_boolean = {init:function() { this.setColour("#AEB8FF"); this.setOutput(!0, "Boolean"); this.setInputsInline(!0); -}, domToMutation:function(a) { - a.getElementsByTagName("field"); - this.hashId = a.getAttribute("hashid"); - (a = Entry.Func.targetFunc.booleanHash[this.hashId]) || (a = ""); - this.appendDummyInput().appendField(new Blockly.FieldTextInput(Lang.Blocks.FUNCTION_logical_variable + a), ""); +}, domToMutation:function(b) { + b.getElementsByTagName("field"); + this.hashId = b.getAttribute("hashid"); + (b = Entry.Func.targetFunc.booleanHash[this.hashId]) || (b = ""); + this.appendDummyInput().appendField(new Blockly.FieldTextInput(Lang.Blocks.FUNCTION_logical_variable + b), ""); }, mutationToDom:function() { - var a = document.createElement("mutation"); - a.setAttribute("hashid", this.hashId); - return a; + var b = document.createElement("mutation"); + b.setAttribute("hashid", this.hashId); + return b; }}; -Entry.block.function_param_boolean = function(a, b, c) { - return b.register[b.hashId].run(); +Entry.block.function_param_boolean = function(b, a, c) { + return a.register[a.hashId].run(); }; Entry.block.function_param_boolean = {skeleton:"basic_boolean_field", color:"#aeb8ff", template:"\ud310\ub2e8\uac12", func:function() { return this.executor.register.params[this.executor.register.paramMap[this.block.type]]; @@ -2423,8 +2354,8 @@ Blockly.Blocks.function_create = {init:function() { this.setInputsInline(!0); this.setNextStatement(!0); }}; -Entry.block.function_create = function(a, b) { - return b.callReturn(); +Entry.block.function_create = function(b, a) { + return a.callReturn(); }; Entry.block.function_create = {skeleton:"basic", color:"#cc7337", event:"funcDef", template:"\ud568\uc218 \uc815\uc758\ud558\uae30 %1 %2", params:[{type:"Block", accept:"paramMagnet", value:{type:"function_field_label"}}, {type:"Indicator", img:"/lib/entryjs/images/block_icon/function_03.png", size:12}], func:function() { }}; @@ -2433,12 +2364,12 @@ Blockly.Blocks.function_general = {init:function() { this.setInputsInline(!0); this.setNextStatement(!0); this.setPreviousStatement(!0); -}, domToMutation:function(a) { - var b = a.getElementsByTagName("field"); +}, domToMutation:function(b) { + var a = b.getElementsByTagName("field"); this.appendDummyInput().appendField(""); - b.length || this.appendDummyInput().appendField(Lang.Blocks.FUNCTION_function); - for (var c = 0;c < b.length;c++) { - var d = b[c], e = d.getAttribute("hashid"); + a.length || this.appendDummyInput().appendField(Lang.Blocks.FUNCTION_function); + for (var c = 0;c < a.length;c++) { + var d = a[c], e = d.getAttribute("hashid"); switch(d.getAttribute("type").toLowerCase()) { case "label": this.appendDummyInput().appendField(d.getAttribute("content")); @@ -2450,11 +2381,11 @@ Blockly.Blocks.function_general = {init:function() { this.appendValueInput(e).setCheck(["Boolean"]); } } - this.hashId = a.getAttribute("hashid"); + this.hashId = b.getAttribute("hashid"); this.appendDummyInput().appendField(new Blockly.FieldIcon(Entry.mediaFilePath + "block_icon/function_03.png", "*")); }, mutationToDom:function() { - for (var a = document.createElement("mutation"), b = 1;b < this.inputList.length;b++) { - var c = this.inputList[b]; + for (var b = document.createElement("mutation"), a = 1;a < this.inputList.length;a++) { + var c = this.inputList[a]; if (c.fieldRow[0] && c.fieldRow[0] instanceof Blockly.FieldLabel) { var c = c.fieldRow[0], d = document.createElement("field"); d.setAttribute("type", "label"); @@ -2462,34 +2393,34 @@ Blockly.Blocks.function_general = {init:function() { } else { c.connection && "String" == c.connection.check_[0] ? (d = document.createElement("field"), d.setAttribute("type", "string"), d.setAttribute("hashid", c.name)) : c.connection && "Boolean" == c.connection.check_[0] && (d = document.createElement("field"), d.setAttribute("type", "boolean"), d.setAttribute("hashid", c.name)); } - a.appendChild(d); + b.appendChild(d); } - a.setAttribute("hashid", this.hashId); - return a; + b.setAttribute("hashid", this.hashId); + return b; }}; -Entry.block.function_general = function(a, b) { - if (!b.thread) { - var c = Entry.variableContainer.getFunction(b.hashId); - b.thread = new Entry.Script(a); - b.thread.register = b.values; +Entry.block.function_general = function(b, a) { + if (!a.thread) { + var c = Entry.variableContainer.getFunction(a.hashId); + a.thread = new Entry.Script(b); + a.thread.register = a.values; for (var d = 0;d < c.content.childNodes.length;d++) { - "function_create" == c.content.childNodes[d].getAttribute("type") && b.thread.init(c.content.childNodes[d]); + "function_create" == c.content.childNodes[d].getAttribute("type") && a.thread.init(c.content.childNodes[d]); } } - if (a = Entry.Engine.computeThread(a, b.thread)) { - return b.thread = a, b; + if (c = Entry.Engine.computeThread(b, a.thread)) { + return a.thread = c, a; } - delete b.thread; - return b.callReturn(); + delete a.thread; + return a.callReturn(); }; -Entry.block.function_general = {skeleton:"basic", color:"#cc7337", template:"\ud568\uc218", params:[], func:function(a) { +Entry.block.function_general = {skeleton:"basic", color:"#cc7337", template:"\ud568\uc218", params:[], func:function(b) { if (!this.initiated) { this.initiated = !0; - var b = Entry.variableContainer.getFunction(this.block.type.substr(5, 9)); - this.funcCode = b.content; - this.funcExecutor = this.funcCode.raiseEvent("funcDef", a)[0]; + var a = Entry.variableContainer.getFunction(this.block.type.substr(5, 9)); + this.funcCode = a.content; + this.funcExecutor = this.funcCode.raiseEvent("funcDef", b)[0]; this.funcExecutor.register.params = this.getParams(); - this.funcExecutor.register.paramMap = b.paramMap; + this.funcExecutor.register.paramMap = a.paramMap; } this.funcExecutor.execute(); if (!this.funcExecutor.isEnd()) { @@ -2497,31 +2428,31 @@ Entry.block.function_general = {skeleton:"basic", color:"#cc7337", template:"\ud } }}; Entry.Hamster = {PORT_MAP:{leftWheel:0, rightWheel:0, buzzer:0, outputA:0, outputB:0, leftLed:0, rightLed:0, note:0, lineTracerMode:0, lineTracerModeId:0, lineTracerSpeed:5, ioModeA:0, ioModeB:0}, setZero:function() { - var a = Entry.Hamster.PORT_MAP, b = Entry.hw.sendQueue, c; - for (c in a) { - b[c] = a[c]; + var b = Entry.Hamster.PORT_MAP, a = Entry.hw.sendQueue, c; + for (c in b) { + a[c] = b[c]; } Entry.hw.update(); - a = Entry.Hamster; - a.lineTracerModeId = 0; - a.lineTracerStateId = -1; - a.tempo = 60; - a.removeAllTimeouts(); -}, lineTracerModeId:0, lineTracerStateId:-1, tempo:60, timeouts:[], removeTimeout:function(a) { - clearTimeout(a); - var b = this.timeouts; - a = b.indexOf(a); - 0 <= a && b.splice(a, 1); + b = Entry.Hamster; + b.lineTracerModeId = 0; + b.lineTracerStateId = -1; + b.tempo = 60; + b.removeAllTimeouts(); +}, lineTracerModeId:0, lineTracerStateId:-1, 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 a = this.timeouts, b; - for (b in a) { - clearTimeout(a[b]); + var b = this.timeouts, a; + for (a in b) { + clearTimeout(b[a]); } this.timeouts = []; -}, setLineTracerMode:function(a, b) { +}, setLineTracerMode:function(b, a) { this.lineTracerModeId = this.lineTracerModeId + 1 & 255; - a.lineTracerMode = b; - a.lineTracerModeId = this.lineTracerModeId; + b.lineTracerMode = a; + b.lineTracerModeId = this.lineTracerModeId; }, name:"hamster", monitorTemplate:{imgPath:"hw/hamster.png", width:256, height:256, listPorts:{temperature:{name:Lang.Blocks.HAMSTER_sensor_temperature, type:"input", pos:{x:0, y:0}}, accelerationX:{name:Lang.Blocks.HAMSTER_sensor_accelerationX, type:"input", pos:{x:0, y:0}}, accelerationY:{name:Lang.Blocks.HAMSTER_sensor_accelerationY, type:"input", pos:{x:0, y:0}}, accelerationZ:{name:Lang.Blocks.HAMSTER_sensor_accelerationZ, type:"input", pos:{x:0, y:0}}, buzzer:{name:Lang.Hw.buzzer, type:"output", pos:{x:0, y:0}}, note:{name:Lang.Hw.buzzer + "2", type:"output", pos:{x:0, y:0}}, outputA:{name:Lang.Hw.output + "A", type:"output", pos:{x:0, y:0}}, outputB:{name:Lang.Hw.output + "B", type:"output", pos:{x:0, y:0}}}, ports:{leftProximity:{name:Lang.Blocks.HAMSTER_sensor_leftProximity, type:"input", pos:{x:122, y:156}}, rightProximity:{name:Lang.Blocks.HAMSTER_sensor_rightProximity, type:"input", pos:{x:10, y:108}}, leftFloor:{name:Lang.Blocks.HAMSTER_sensor_leftFloor, type:"input", pos:{x:100, y:234}}, rightFloor:{name:Lang.Blocks.HAMSTER_sensor_rightFloor, type:"input", pos:{x:13, y:180}}, lightsensor:{name:Lang.Blocks.HAMSTER_sensor_light, type:"input", pos:{x:56, y:189}}, leftWheel:{name:Lang.Hw.leftWheel, type:"output", pos:{x:209, y:115}}, rightWheel:{name:Lang.Hw.rightWheel, type:"output", pos:{x:98, y:30}}, leftLed:{name:Lang.Hw.left + " " + Lang.Hw.led, type:"output", pos:{x:87, y:210}}, rightLed:{name:Lang.Hw.right + " " + Lang.Hw.led, type:"output", pos:{x:24, y:168}}}, mode:"both"}}; @@ -2531,9 +2462,9 @@ Blockly.Blocks.hamster_hand_found = {init:function() { this.setOutput(!0, "Boolean"); this.setInputsInline(!0); }}; -Entry.block.hamster_hand_found = function(a, b) { - a = Entry.hw.portData; - return 50 < a.leftProximity || 50 < a.rightProximity; +Entry.block.hamster_hand_found = function(b, a) { + var c = Entry.hw.portData; + return 50 < c.leftProximity || 50 < c.rightProximity; }; Blockly.Blocks.hamster_value = {init:function() { this.setColour("#00979D"); @@ -2542,10 +2473,9 @@ Blockly.Blocks.hamster_value = {init:function() { this.setInputsInline(!0); this.setOutput(!0, "Number"); }}; -Entry.block.hamster_value = function(a, b) { - a = Entry.hw.portData; - b = b.getField("DEVICE"); - return a[b]; +Entry.block.hamster_value = function(b, a) { + var c = Entry.hw.portData, d = a.getField("DEVICE"); + return c[d]; }; Blockly.Blocks.hamster_move_forward_once = {init:function() { this.setColour("#00979D"); @@ -2554,53 +2484,52 @@ Blockly.Blocks.hamster_move_forward_once = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.hamster_move_forward_once = function(a, b) { - a = Entry.hw.sendQueue; - var c = Entry.hw.portData; - if (b.isStart) { - if (b.isMoving) { - switch(b.boardState) { +Entry.block.hamster_move_forward_once = function(b, a) { + var c = Entry.hw.sendQueue, d = Entry.hw.portData; + if (a.isStart) { + if (a.isMoving) { + switch(a.boardState) { case 1: - 2 > b.count ? (50 > c.leftFloor && 50 > c.rightFloor ? b.count++ : b.count = 0, c = c.leftFloor - c.rightFloor, a.leftWheel = 45 + .25 * c, a.rightWheel = 45 - .25 * c) : (b.count = 0, b.boardState = 2); + 2 > a.count ? (50 > d.leftFloor && 50 > d.rightFloor ? a.count++ : a.count = 0, d = d.leftFloor - d.rightFloor, c.leftWheel = 45 + .25 * d, c.rightWheel = 45 - .25 * d) : (a.count = 0, a.boardState = 2); break; case 2: - c = c.leftFloor - c.rightFloor; - a.leftWheel = 45 + .25 * c; - a.rightWheel = 45 - .25 * c; - b.boardState = 3; - var d = setTimeout(function() { - b.boardState = 4; - Entry.Hamster.removeTimeout(d); + d = d.leftFloor - d.rightFloor; + c.leftWheel = 45 + .25 * d; + c.rightWheel = 45 - .25 * d; + a.boardState = 3; + var e = setTimeout(function() { + a.boardState = 4; + Entry.Hamster.removeTimeout(e); }, 250); - Entry.Hamster.timeouts.push(d); + Entry.Hamster.timeouts.push(e); break; case 3: - c = c.leftFloor - c.rightFloor; - a.leftWheel = 45 + .25 * c; - a.rightWheel = 45 - .25 * c; + d = d.leftFloor - d.rightFloor; + c.leftWheel = 45 + .25 * d; + c.rightWheel = 45 - .25 * d; break; case 4: - a.leftWheel = 0, a.rightWheel = 0, b.boardState = 0, b.isMoving = !1; + c.leftWheel = 0, c.rightWheel = 0, a.boardState = 0, a.isMoving = !1; } - return b; + return a; } - delete b.isStart; - delete b.isMoving; - delete b.count; - delete b.boardState; + delete a.isStart; + delete a.isMoving; + delete a.count; + delete a.boardState; Entry.engine.isContinue = !1; - a.leftWheel = 0; - a.rightWheel = 0; - return b.callReturn(); + c.leftWheel = 0; + c.rightWheel = 0; + return a.callReturn(); } - b.isStart = !0; - b.isMoving = !0; - b.count = 0; - b.boardState = 1; - a.leftWheel = 45; - a.rightWheel = 45; - Entry.Hamster.setLineTracerMode(a, 0); - return b; + a.isStart = !0; + a.isMoving = !0; + a.count = 0; + a.boardState = 1; + c.leftWheel = 45; + c.rightWheel = 45; + Entry.Hamster.setLineTracerMode(c, 0); + return a; }; Blockly.Blocks.hamster_turn_once = {init:function() { this.setColour("#00979D"); @@ -2609,65 +2538,64 @@ Blockly.Blocks.hamster_turn_once = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.hamster_turn_once = function(a, b) { - a = Entry.hw.sendQueue; - var c = Entry.hw.portData; - if (b.isStart) { - if (b.isMoving) { - if (b.isLeft) { - switch(b.boardState) { +Entry.block.hamster_turn_once = function(b, a) { + var c = Entry.hw.sendQueue, d = Entry.hw.portData; + if (a.isStart) { + if (a.isMoving) { + if (a.isLeft) { + switch(a.boardState) { case 1: - 2 > b.count ? 50 < c.leftFloor && b.count++ : (b.count = 0, b.boardState = 2); + 2 > a.count ? 50 < d.leftFloor && a.count++ : (a.count = 0, a.boardState = 2); break; case 2: - 20 > c.leftFloor && (b.boardState = 3); + 20 > d.leftFloor && (a.boardState = 3); break; case 3: - 2 > b.count ? 20 > c.leftFloor && b.count++ : (b.count = 0, b.boardState = 4); + 2 > a.count ? 20 > d.leftFloor && a.count++ : (a.count = 0, a.boardState = 4); break; case 4: - 50 < c.leftFloor && (b.boardState = 5); + 50 < d.leftFloor && (a.boardState = 5); break; case 5: - c = c.leftFloor - c.rightFloor, -15 < c ? (a.leftWheel = 0, a.rightWheel = 0, b.boardState = 0, b.isMoving = !1) : (a.leftWheel = .5 * c, a.rightWheel = .5 * -c); + d = d.leftFloor - d.rightFloor, -15 < d ? (c.leftWheel = 0, c.rightWheel = 0, a.boardState = 0, a.isMoving = !1) : (c.leftWheel = .5 * d, c.rightWheel = .5 * -d); } } else { - switch(b.boardState) { + switch(a.boardState) { case 1: - 2 > b.count ? 50 < c.rightFloor && b.count++ : (b.count = 0, b.boardState = 2); + 2 > a.count ? 50 < d.rightFloor && a.count++ : (a.count = 0, a.boardState = 2); break; case 2: - 20 > c.rightFloor && (b.boardState = 3); + 20 > d.rightFloor && (a.boardState = 3); break; case 3: - 2 > b.count ? 20 > c.rightFloor && b.count++ : (b.count = 0, b.boardState = 4); + 2 > a.count ? 20 > d.rightFloor && a.count++ : (a.count = 0, a.boardState = 4); break; case 4: - 50 < c.rightFloor && (b.boardState = 5); + 50 < d.rightFloor && (a.boardState = 5); break; case 5: - c = c.rightFloor - c.leftFloor, -15 < c ? (a.leftWheel = 0, a.rightWheel = 0, b.boardState = 0, b.isMoving = !1) : (a.leftWheel = .5 * -c, a.rightWheel = .5 * c); + d = d.rightFloor - d.leftFloor, -15 < d ? (c.leftWheel = 0, c.rightWheel = 0, a.boardState = 0, a.isMoving = !1) : (c.leftWheel = .5 * -d, c.rightWheel = .5 * d); } } - return b; + return a; } - delete b.isStart; - delete b.isMoving; - delete b.count; - delete b.boardState; - delete b.isLeft; + delete a.isStart; + delete a.isMoving; + delete a.count; + delete a.boardState; + delete a.isLeft; Entry.engine.isContinue = !1; - a.leftWheel = 0; - a.rightWheel = 0; - return b.callReturn(); + c.leftWheel = 0; + c.rightWheel = 0; + return a.callReturn(); } - b.isStart = !0; - b.isMoving = !0; - b.count = 0; - b.boardState = 1; - "LEFT" == b.getField("DIRECTION", b) ? (b.isLeft = !0, a.leftWheel = -45, a.rightWheel = 45) : (b.isLeft = !1, a.leftWheel = 45, a.rightWheel = -45); - Entry.Hamster.setLineTracerMode(a, 0); - return b; + a.isStart = !0; + a.isMoving = !0; + a.count = 0; + a.boardState = 1; + "LEFT" == a.getField("DIRECTION", a) ? (a.isLeft = !0, c.leftWheel = -45, c.rightWheel = 45) : (a.isLeft = !1, c.leftWheel = 45, c.rightWheel = -45); + Entry.Hamster.setLineTracerMode(c, 0); + return a; }; Blockly.Blocks.hamster_move_forward_for_secs = {init:function() { this.setColour("#00979D"); @@ -2678,31 +2606,30 @@ Blockly.Blocks.hamster_move_forward_for_secs = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.hamster_move_forward_for_secs = function(a, b) { - a = Entry.hw.sendQueue; - if (b.isStart) { - if (1 == b.timeFlag) { - return b; +Entry.block.hamster_move_forward_for_secs = function(b, a) { + var c = Entry.hw.sendQueue; + if (a.isStart) { + if (1 == a.timeFlag) { + return a; } - delete b.isStart; - delete b.timeFlag; + delete a.isStart; + delete a.timeFlag; Entry.engine.isContinue = !1; - a.leftWheel = 0; - a.rightWheel = 0; - return b.callReturn(); + c.leftWheel = 0; + c.rightWheel = 0; + return a.callReturn(); } - b.isStart = !0; - b.timeFlag = 1; - a.leftWheel = 30; - a.rightWheel = 30; - Entry.Hamster.setLineTracerMode(a, 0); - a = 1E3 * b.getNumberValue("VALUE"); - var c = setTimeout(function() { - b.timeFlag = 0; - Entry.Hamster.removeTimeout(c); - }, a); - Entry.Hamster.timeouts.push(c); - return b; + a.isStart = !0; + a.timeFlag = 1; + c.leftWheel = 30; + c.rightWheel = 30; + Entry.Hamster.setLineTracerMode(c, 0); + var c = 1E3 * a.getNumberValue("VALUE"), d = setTimeout(function() { + a.timeFlag = 0; + Entry.Hamster.removeTimeout(d); + }, c); + Entry.Hamster.timeouts.push(d); + return a; }; Blockly.Blocks.hamster_move_backward_for_secs = {init:function() { this.setColour("#00979D"); @@ -2713,31 +2640,30 @@ Blockly.Blocks.hamster_move_backward_for_secs = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.hamster_move_backward_for_secs = function(a, b) { - a = Entry.hw.sendQueue; - if (b.isStart) { - if (1 == b.timeFlag) { - return b; +Entry.block.hamster_move_backward_for_secs = function(b, a) { + var c = Entry.hw.sendQueue; + if (a.isStart) { + if (1 == a.timeFlag) { + return a; } - delete b.isStart; - delete b.timeFlag; + delete a.isStart; + delete a.timeFlag; Entry.engine.isContinue = !1; - a.leftWheel = 0; - a.rightWheel = 0; - return b.callReturn(); + c.leftWheel = 0; + c.rightWheel = 0; + return a.callReturn(); } - b.isStart = !0; - b.timeFlag = 1; - a.leftWheel = -30; - a.rightWheel = -30; - Entry.Hamster.setLineTracerMode(a, 0); - a = 1E3 * b.getNumberValue("VALUE"); - var c = setTimeout(function() { - b.timeFlag = 0; - Entry.Hamster.removeTimeout(c); - }, a); - Entry.Hamster.timeouts.push(c); - return b; + a.isStart = !0; + a.timeFlag = 1; + c.leftWheel = -30; + c.rightWheel = -30; + Entry.Hamster.setLineTracerMode(c, 0); + var c = 1E3 * a.getNumberValue("VALUE"), d = setTimeout(function() { + a.timeFlag = 0; + Entry.Hamster.removeTimeout(d); + }, c); + Entry.Hamster.timeouts.push(d); + return a; }; Blockly.Blocks.hamster_turn_for_secs = {init:function() { this.setColour("#00979D"); @@ -2748,30 +2674,29 @@ Blockly.Blocks.hamster_turn_for_secs = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.hamster_turn_for_secs = function(a, b) { - a = Entry.hw.sendQueue; - if (b.isStart) { - if (1 == b.timeFlag) { - return b; +Entry.block.hamster_turn_for_secs = function(b, a) { + var c = Entry.hw.sendQueue; + if (a.isStart) { + if (1 == a.timeFlag) { + return a; } - delete b.isStart; - delete b.timeFlag; + delete a.isStart; + delete a.timeFlag; Entry.engine.isContinue = !1; - a.leftWheel = 0; - a.rightWheel = 0; - return b.callReturn(); + c.leftWheel = 0; + c.rightWheel = 0; + return a.callReturn(); } - b.isStart = !0; - b.timeFlag = 1; - "LEFT" == b.getField("DIRECTION", b) ? (a.leftWheel = -30, a.rightWheel = 30) : (a.leftWheel = 30, a.rightWheel = -30); - Entry.Hamster.setLineTracerMode(a, 0); - a = 1E3 * b.getNumberValue("VALUE"); - var c = setTimeout(function() { - b.timeFlag = 0; - Entry.Hamster.removeTimeout(c); - }, a); - Entry.Hamster.timeouts.push(c); - return b; + a.isStart = !0; + a.timeFlag = 1; + "LEFT" == a.getField("DIRECTION", a) ? (c.leftWheel = -30, c.rightWheel = 30) : (c.leftWheel = 30, c.rightWheel = -30); + Entry.Hamster.setLineTracerMode(c, 0); + var c = 1E3 * a.getNumberValue("VALUE"), d = setTimeout(function() { + a.timeFlag = 0; + Entry.Hamster.removeTimeout(d); + }, c); + Entry.Hamster.timeouts.push(d); + return a; }; Blockly.Blocks.hamster_change_both_wheels_by = {init:function() { this.setColour("#00979D"); @@ -2784,13 +2709,12 @@ Blockly.Blocks.hamster_change_both_wheels_by = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.hamster_change_both_wheels_by = function(a, b) { - a = Entry.hw.sendQueue; - var c = b.getNumberValue("LEFT"), d = b.getNumberValue("RIGHT"); - a.leftWheel = void 0 != a.leftWheel ? a.leftWheel + c : c; - a.rightWheel = void 0 != a.rightWheel ? a.rightWheel + d : d; - Entry.Hamster.setLineTracerMode(a, 0); - return b.callReturn(); +Entry.block.hamster_change_both_wheels_by = function(b, a) { + var c = Entry.hw.sendQueue, d = a.getNumberValue("LEFT"), e = a.getNumberValue("RIGHT"); + c.leftWheel = void 0 != c.leftWheel ? c.leftWheel + d : d; + c.rightWheel = void 0 != c.rightWheel ? c.rightWheel + e : e; + Entry.Hamster.setLineTracerMode(c, 0); + return a.callReturn(); }; Blockly.Blocks.hamster_set_both_wheels_to = {init:function() { this.setColour("#00979D"); @@ -2803,12 +2727,12 @@ Blockly.Blocks.hamster_set_both_wheels_to = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.hamster_set_both_wheels_to = function(a, b) { - a = Entry.hw.sendQueue; - a.leftWheel = b.getNumberValue("LEFT"); - a.rightWheel = b.getNumberValue("RIGHT"); - Entry.Hamster.setLineTracerMode(a, 0); - return b.callReturn(); +Entry.block.hamster_set_both_wheels_to = function(b, a) { + var c = Entry.hw.sendQueue; + c.leftWheel = a.getNumberValue("LEFT"); + c.rightWheel = a.getNumberValue("RIGHT"); + Entry.Hamster.setLineTracerMode(c, 0); + return a.callReturn(); }; Blockly.Blocks.hamster_change_wheel_by = {init:function() { this.setColour("#00979D"); @@ -2819,12 +2743,11 @@ Blockly.Blocks.hamster_change_wheel_by = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.hamster_change_wheel_by = function(a, b) { - a = Entry.hw.sendQueue; - var c = b.getField("DIRECTION"), d = b.getNumberValue("VALUE"); - "LEFT" == c ? a.leftWheel = void 0 != a.leftWheel ? a.leftWheel + d : d : ("RIGHT" != c && (a.leftWheel = void 0 != a.leftWheel ? a.leftWheel + d : d), a.rightWheel = void 0 != a.rightWheel ? a.rightWheel + d : d); - Entry.Hamster.setLineTracerMode(a, 0); - return b.callReturn(); +Entry.block.hamster_change_wheel_by = function(b, a) { + var c = Entry.hw.sendQueue, d = a.getField("DIRECTION"), e = a.getNumberValue("VALUE"); + "LEFT" == d ? c.leftWheel = void 0 != c.leftWheel ? c.leftWheel + e : e : ("RIGHT" != d && (c.leftWheel = void 0 != c.leftWheel ? c.leftWheel + e : e), c.rightWheel = void 0 != c.rightWheel ? c.rightWheel + e : e); + Entry.Hamster.setLineTracerMode(c, 0); + return a.callReturn(); }; Blockly.Blocks.hamster_set_wheel_to = {init:function() { this.setColour("#00979D"); @@ -2835,12 +2758,11 @@ Blockly.Blocks.hamster_set_wheel_to = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.hamster_set_wheel_to = function(a, b) { - a = Entry.hw.sendQueue; - var c = b.getField("DIRECTION"), d = b.getNumberValue("VALUE"); - "LEFT" == c ? a.leftWheel = d : ("RIGHT" != c && (a.leftWheel = d), a.rightWheel = d); - Entry.Hamster.setLineTracerMode(a, 0); - return b.callReturn(); +Entry.block.hamster_set_wheel_to = function(b, a) { + var c = Entry.hw.sendQueue, d = a.getField("DIRECTION"), e = a.getNumberValue("VALUE"); + "LEFT" == d ? c.leftWheel = e : ("RIGHT" != d && (c.leftWheel = e), c.rightWheel = e); + Entry.Hamster.setLineTracerMode(c, 0); + return a.callReturn(); }; Blockly.Blocks.hamster_follow_line_using = {init:function() { this.setColour("#00979D"); @@ -2850,15 +2772,14 @@ Blockly.Blocks.hamster_follow_line_using = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.hamster_follow_line_using = function(a, b) { - a = Entry.hw.sendQueue; - var c = b.getField("COLOR"), d = b.getField("DIRECTION"), e = 1; - "RIGHT" == d ? e = 2 : "BOTH" == d && (e = 3); - "WHITE" == c && (e += 7); - a.leftWheel = 0; - a.rightWheel = 0; - Entry.Hamster.setLineTracerMode(a, e); - return b.callReturn(); +Entry.block.hamster_follow_line_using = function(b, a) { + var c = Entry.hw.sendQueue, d = a.getField("COLOR"), e = a.getField("DIRECTION"), f = 1; + "RIGHT" == e ? f = 2 : "BOTH" == e && (f = 3); + "WHITE" == d && (f += 7); + c.leftWheel = 0; + c.rightWheel = 0; + Entry.Hamster.setLineTracerMode(c, f); + return a.callReturn(); }; Blockly.Blocks.hamster_follow_line_until = {init:function() { this.setColour("#00979D"); @@ -2868,19 +2789,18 @@ Blockly.Blocks.hamster_follow_line_until = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.hamster_follow_line_until = function(a, b) { - a = Entry.hw.sendQueue; - var c = Entry.hw.portData, d = b.getField("COLOR"), e = b.getField("DIRECTION"), f = 4; - "RIGHT" == e ? f = 5 : "FRONT" == e ? f = 6 : "REAR" == e && (f = 7); - "WHITE" == d && (f += 7); - if (b.isStart) { - if (d = Entry.Hamster, c.lineTracerStateId != d.lineTracerStateId && (d.lineTracerStateId = c.lineTracerStateId, 64 == c.lineTracerState)) { - return delete b.isStart, Entry.engine.isContinue = !1, d.setLineTracerMode(a, 0), b.callReturn(); +Entry.block.hamster_follow_line_until = function(b, a) { + var c = Entry.hw.sendQueue, d = Entry.hw.portData, e = a.getField("COLOR"), f = a.getField("DIRECTION"), g = 4; + "RIGHT" == f ? g = 5 : "FRONT" == f ? g = 6 : "REAR" == f && (g = 7); + "WHITE" == e && (g += 7); + if (a.isStart) { + if (e = Entry.Hamster, d.lineTracerStateId != e.lineTracerStateId && (e.lineTracerStateId = d.lineTracerStateId, 64 == d.lineTracerState)) { + return delete a.isStart, Entry.engine.isContinue = !1, e.setLineTracerMode(c, 0), a.callReturn(); } } else { - b.isStart = !0, a.leftWheel = 0, a.rightWheel = 0, Entry.Hamster.setLineTracerMode(a, f); + a.isStart = !0, c.leftWheel = 0, c.rightWheel = 0, Entry.Hamster.setLineTracerMode(c, g); } - return b; + return a; }; Blockly.Blocks.hamster_set_following_speed_to = {init:function() { this.setColour("#00979D"); @@ -2889,9 +2809,9 @@ Blockly.Blocks.hamster_set_following_speed_to = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.hamster_set_following_speed_to = function(a, b) { - Entry.hw.sendQueue.lineTracerSpeed = Number(b.getField("SPEED", b)); - return b.callReturn(); +Entry.block.hamster_set_following_speed_to = function(b, a) { + Entry.hw.sendQueue.lineTracerSpeed = +a.getField("SPEED", a); + return a.callReturn(); }; Blockly.Blocks.hamster_stop = {init:function() { this.setColour("#00979D"); @@ -2900,12 +2820,12 @@ Blockly.Blocks.hamster_stop = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.hamster_stop = function(a, b) { - a = Entry.hw.sendQueue; - a.leftWheel = 0; - a.rightWheel = 0; - Entry.Hamster.setLineTracerMode(a, 0); - return b.callReturn(); +Entry.block.hamster_stop = function(b, a) { + var c = Entry.hw.sendQueue; + c.leftWheel = 0; + c.rightWheel = 0; + Entry.Hamster.setLineTracerMode(c, 0); + return a.callReturn(); }; Blockly.Blocks.hamster_set_led_to = {init:function() { this.setColour("#00979D"); @@ -2915,11 +2835,10 @@ Blockly.Blocks.hamster_set_led_to = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.hamster_set_led_to = function(a, b) { - a = Entry.hw.sendQueue; - var c = b.getField("DIRECTION", b), d = Number(b.getField("COLOR", b)); - "LEFT" == c ? a.leftLed = d : ("RIGHT" != c && (a.leftLed = d), a.rightLed = d); - return b.callReturn(); +Entry.block.hamster_set_led_to = function(b, a) { + var c = Entry.hw.sendQueue, d = a.getField("DIRECTION", a), e = +a.getField("COLOR", a); + "LEFT" == d ? c.leftLed = e : ("RIGHT" != d && (c.leftLed = e), c.rightLed = e); + return a.callReturn(); }; Blockly.Blocks.hamster_clear_led = {init:function() { this.setColour("#00979D"); @@ -2928,11 +2847,10 @@ Blockly.Blocks.hamster_clear_led = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.hamster_clear_led = function(a, b) { - a = Entry.hw.sendQueue; - var c = b.getField("DIRECTION", b); - "LEFT" == c ? a.leftLed = 0 : ("RIGHT" != c && (a.leftLed = 0), a.rightLed = 0); - return b.callReturn(); +Entry.block.hamster_clear_led = function(b, a) { + var c = Entry.hw.sendQueue, d = a.getField("DIRECTION", a); + "LEFT" == d ? c.leftLed = 0 : ("RIGHT" != d && (c.leftLed = 0), c.rightLed = 0); + return a.callReturn(); }; Blockly.Blocks.hamster_beep = {init:function() { this.setColour("#00979D"); @@ -2941,28 +2859,28 @@ Blockly.Blocks.hamster_beep = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.hamster_beep = function(a, b) { - a = Entry.hw.sendQueue; - if (b.isStart) { - if (1 == b.timeFlag) { - return b; +Entry.block.hamster_beep = function(b, a) { + var c = Entry.hw.sendQueue; + if (a.isStart) { + if (1 == a.timeFlag) { + return a; } - delete b.isStart; - delete b.timeFlag; + delete a.isStart; + delete a.timeFlag; Entry.engine.isContinue = !1; - a.buzzer = 0; - return b.callReturn(); + c.buzzer = 0; + return a.callReturn(); } - b.isStart = !0; - b.timeFlag = 1; - a.buzzer = 440; - a.note = 0; - var c = setTimeout(function() { - b.timeFlag = 0; - Entry.Hamster.removeTimeout(c); + a.isStart = !0; + a.timeFlag = 1; + c.buzzer = 440; + c.note = 0; + var d = setTimeout(function() { + a.timeFlag = 0; + Entry.Hamster.removeTimeout(d); }, 200); - Entry.Hamster.timeouts.push(c); - return b; + Entry.Hamster.timeouts.push(d); + return a; }; Blockly.Blocks.hamster_change_buzzer_by = {init:function() { this.setColour("#00979D"); @@ -2973,12 +2891,11 @@ Blockly.Blocks.hamster_change_buzzer_by = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.hamster_change_buzzer_by = function(a, b) { - a = Entry.hw.sendQueue; - var c = b.getNumberValue("VALUE"); - a.buzzer = void 0 != a.buzzer ? a.buzzer + c : c; - a.note = 0; - return b.callReturn(); +Entry.block.hamster_change_buzzer_by = function(b, a) { + var c = Entry.hw.sendQueue, d = a.getNumberValue("VALUE"); + c.buzzer = void 0 != c.buzzer ? c.buzzer + d : d; + c.note = 0; + return a.callReturn(); }; Blockly.Blocks.hamster_set_buzzer_to = {init:function() { this.setColour("#00979D"); @@ -2989,11 +2906,11 @@ Blockly.Blocks.hamster_set_buzzer_to = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.hamster_set_buzzer_to = function(a, b) { - a = Entry.hw.sendQueue; - a.buzzer = b.getNumberValue("VALUE"); - a.note = 0; - return b.callReturn(); +Entry.block.hamster_set_buzzer_to = function(b, a) { + var c = Entry.hw.sendQueue; + c.buzzer = a.getNumberValue("VALUE"); + c.note = 0; + return a.callReturn(); }; Blockly.Blocks.hamster_clear_buzzer = {init:function() { this.setColour("#00979D"); @@ -3002,11 +2919,11 @@ Blockly.Blocks.hamster_clear_buzzer = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.hamster_clear_buzzer = function(a, b) { - a = Entry.hw.sendQueue; - a.buzzer = 0; - a.note = 0; - return b.callReturn(); +Entry.block.hamster_clear_buzzer = function(b, a) { + var c = Entry.hw.sendQueue; + c.buzzer = 0; + c.note = 0; + return a.callReturn(); }; Blockly.Blocks.hamster_play_note_for = {init:function() { this.setColour("#00979D"); @@ -3018,37 +2935,36 @@ Blockly.Blocks.hamster_play_note_for = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.hamster_play_note_for = function(a, b) { +Entry.block.hamster_play_note_for = function(b, a) { var c = Entry.hw.sendQueue; - if (b.isStart) { - if (1 == b.timeFlag) { - return b; + if (a.isStart) { + if (1 == a.timeFlag) { + return a; } - delete b.isStart; - delete b.timeFlag; + delete a.isStart; + delete a.timeFlag; Entry.engine.isContinue = !1; c.note = 0; - return b.callReturn(); + return a.callReturn(); } - a = b.getNumberField("NOTE", b); - var d = b.getNumberField("OCTAVE", b), e = 6E4 * b.getNumberValue("VALUE", b) / Entry.Hamster.tempo; - b.isStart = !0; - b.timeFlag = 1; + var d = a.getNumberField("NOTE", a), e = a.getNumberField("OCTAVE", a), f = a.getNumberValue("VALUE", a), g = Entry.Hamster.tempo, f = 6E4 * f / g; + a.isStart = !0; + a.timeFlag = 1; c.buzzer = 0; - c.note = a + 12 * (d - 1); - if (100 < e) { - var f = setTimeout(function() { + c.note = d + 12 * (e - 1); + if (100 < f) { + var h = setTimeout(function() { c.note = 0; - Entry.Hamster.removeTimeout(f); - }, e - 100); - Entry.Hamster.timeouts.push(f); + Entry.Hamster.removeTimeout(h); + }, f - 100); + Entry.Hamster.timeouts.push(h); } - var g = setTimeout(function() { - b.timeFlag = 0; - Entry.Hamster.removeTimeout(g); - }, e); - Entry.Hamster.timeouts.push(g); - return b; + var k = setTimeout(function() { + a.timeFlag = 0; + Entry.Hamster.removeTimeout(k); + }, f); + Entry.Hamster.timeouts.push(k); + return a; }; Blockly.Blocks.hamster_rest_for = {init:function() { this.setColour("#00979D"); @@ -3059,28 +2975,28 @@ Blockly.Blocks.hamster_rest_for = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.hamster_rest_for = function(a, b) { - a = Entry.hw.sendQueue; - if (b.isStart) { - if (1 == b.timeFlag) { - return b; +Entry.block.hamster_rest_for = function(b, a) { + var c = Entry.hw.sendQueue; + if (a.isStart) { + if (1 == a.timeFlag) { + return a; } - delete b.isStart; - delete b.timeFlag; + delete a.isStart; + delete a.timeFlag; Entry.engine.isContinue = !1; - return b.callReturn(); + return a.callReturn(); } - b.isStart = !0; - b.timeFlag = 1; - var c = b.getNumberValue("VALUE"), c = 6E4 * c / Entry.Hamster.tempo; - a.buzzer = 0; - a.note = 0; - var d = setTimeout(function() { - b.timeFlag = 0; - Entry.Hamster.removeTimeout(d); - }, c); - Entry.Hamster.timeouts.push(d); - return b; + a.isStart = !0; + a.timeFlag = 1; + var d = a.getNumberValue("VALUE"), d = 6E4 * d / Entry.Hamster.tempo; + c.buzzer = 0; + c.note = 0; + var e = setTimeout(function() { + a.timeFlag = 0; + Entry.Hamster.removeTimeout(e); + }, d); + Entry.Hamster.timeouts.push(e); + return a; }; Blockly.Blocks.hamster_change_tempo_by = {init:function() { this.setColour("#00979D"); @@ -3091,10 +3007,10 @@ Blockly.Blocks.hamster_change_tempo_by = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.hamster_change_tempo_by = function(a, b) { - Entry.Hamster.tempo += b.getNumberValue("VALUE"); +Entry.block.hamster_change_tempo_by = function(b, a) { + Entry.Hamster.tempo += a.getNumberValue("VALUE"); 1 > Entry.Hamster.tempo && (Entry.Hamster.tempo = 1); - return b.callReturn(); + return a.callReturn(); }; Blockly.Blocks.hamster_set_tempo_to = {init:function() { this.setColour("#00979D"); @@ -3105,10 +3021,10 @@ Blockly.Blocks.hamster_set_tempo_to = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.hamster_set_tempo_to = function(a, b) { - Entry.Hamster.tempo = b.getNumberValue("VALUE"); +Entry.block.hamster_set_tempo_to = function(b, a) { + Entry.Hamster.tempo = a.getNumberValue("VALUE"); 1 > Entry.Hamster.tempo && (Entry.Hamster.tempo = 1); - return b.callReturn(); + return a.callReturn(); }; Blockly.Blocks.hamster_set_port_to = {init:function() { this.setColour("#00979D"); @@ -3118,11 +3034,10 @@ Blockly.Blocks.hamster_set_port_to = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.hamster_set_port_to = function(a, b) { - a = Entry.hw.sendQueue; - var c = b.getField("PORT", b), d = Number(b.getField("MODE", b)); - "A" == c ? a.ioModeA = d : ("B" != c && (a.ioModeA = d), a.ioModeB = d); - return b.callReturn(); +Entry.block.hamster_set_port_to = function(b, a) { + var c = Entry.hw.sendQueue, d = a.getField("PORT", a), e = +a.getField("MODE", a); + "A" == d ? c.ioModeA = e : ("B" != d && (c.ioModeA = e), c.ioModeB = e); + return a.callReturn(); }; Blockly.Blocks.hamster_change_output_by = {init:function() { this.setColour("#00979D"); @@ -3133,11 +3048,10 @@ Blockly.Blocks.hamster_change_output_by = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.hamster_change_output_by = function(a, b) { - a = Entry.hw.sendQueue; - var c = b.getField("PORT"), d = b.getNumberValue("VALUE"); - "A" == c ? a.outputA = void 0 != a.outputA ? a.outputA + d : d : ("B" != c && (a.outputA = void 0 != a.outputA ? a.outputA + d : d), a.outputB = void 0 != a.outputB ? a.outputB + d : d); - return b.callReturn(); +Entry.block.hamster_change_output_by = function(b, a) { + var c = Entry.hw.sendQueue, d = a.getField("PORT"), e = a.getNumberValue("VALUE"); + "A" == d ? c.outputA = void 0 != c.outputA ? c.outputA + e : e : ("B" != d && (c.outputA = void 0 != c.outputA ? c.outputA + e : e), c.outputB = void 0 != c.outputB ? c.outputB + e : e); + return a.callReturn(); }; Blockly.Blocks.hamster_set_output_to = {init:function() { this.setColour("#00979D"); @@ -3148,11 +3062,10 @@ Blockly.Blocks.hamster_set_output_to = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.hamster_set_output_to = function(a, b) { - a = Entry.hw.sendQueue; - var c = b.getField("PORT"), d = b.getNumberValue("VALUE"); - "A" == c ? a.outputA = d : ("B" != c && (a.outputA = d), a.outputB = d); - return b.callReturn(); +Entry.block.hamster_set_output_to = function(b, a) { + var c = Entry.hw.sendQueue, d = a.getField("PORT"), e = a.getNumberValue("VALUE"); + "A" == d ? c.outputA = e : ("B" != d && (c.outputA = e), c.outputB = e); + return a.callReturn(); }; Blockly.Blocks.is_clicked = {init:function() { this.setColour("#AEB8FF"); @@ -3160,7 +3073,7 @@ Blockly.Blocks.is_clicked = {init:function() { this.setOutput(!0, "Boolean"); this.setInputsInline(!0); }}; -Entry.block.is_clicked = function(a, b) { +Entry.block.is_clicked = function(b, a) { return Entry.stage.isClick; }; Blockly.Blocks.is_press_some_key = {init:function() { @@ -3170,9 +3083,9 @@ Blockly.Blocks.is_press_some_key = {init:function() { this.setOutput(!0, "Boolean"); this.setInputsInline(!0); }}; -Entry.block.is_press_some_key = function(a, b) { - a = Number(b.getField("VALUE", b)); - return 0 <= Entry.pressedKeys.indexOf(a); +Entry.block.is_press_some_key = function(b, a) { + var c = +a.getField("VALUE", a); + return 0 <= Entry.pressedKeys.indexOf(c); }; Blockly.Blocks.reach_something = {init:function() { this.setColour("#AEB8FF"); @@ -3182,68 +3095,64 @@ Blockly.Blocks.reach_something = {init:function() { this.setOutput(!0, "Boolean"); this.setInputsInline(!0); }}; -Entry.block.reach_something = function(a, b) { - if (!a.getVisible()) { +Entry.block.reach_something = function(b, a) { + if (!b.getVisible()) { return !1; } - var c = b.getField("VALUE", b); - b = a.object; - var d = /wall/.test(c), e = ndgmr.checkPixelCollision; - if (d) { - switch(a = Entry.stage.wall, c) { + var c = a.getField("VALUE", a), d = b.object, e = /wall/.test(c), f = ndgmr.checkPixelCollision; + if (e) { + switch(e = Entry.stage.wall, c) { case "wall": - if (e(b, a.up, .2, !0) || e(b, a.down, .2, !0) || e(b, a.left, .2, !0) || e(b, a.right, .2, !0)) { + if (f(d, e.up, .2, !0) || f(d, e.down, .2, !0) || f(d, e.left, .2, !0) || f(d, e.right, .2, !0)) { return !0; } break; case "wall_up": - if (e(b, a.up, .2, !0)) { + if (f(d, e.up, .2, !0)) { return !0; } break; case "wall_down": - if (e(b, a.down, .2, !0)) { + if (f(d, e.down, .2, !0)) { return !0; } break; case "wall_right": - if (e(b, a.right, .2, !0)) { + if (f(d, e.right, .2, !0)) { return !0; } break; case "wall_left": - if (e(b, a.left, .2, !0)) { + if (f(d, e.left, .2, !0)) { return !0; } ; } } else { if ("mouse" == c) { - return e = Entry.stage.canvas, e = b.globalToLocal(e.mouseX, e.mouseY), b.hitTest(e.x, e.y); + return f = Entry.stage.canvas, f = d.globalToLocal(f.mouseX, f.mouseY), d.hitTest(f.x, f.y); } c = Entry.container.getEntity(c); - if ("textBox" == c.type || "textBox" == a.type) { - e = c.object.getTransformedBounds(); - b = b.getTransformedBounds(); - if (Entry.checkCollisionRect(b, e)) { + if ("textBox" == c.type || "textBox" == b.type) { + f = c.object.getTransformedBounds(); + d = d.getTransformedBounds(); + if (Entry.checkCollisionRect(d, f)) { return !0; } - a = c.parent.clonedEntities; - c = 0; - for (d = a.length;c < d;c++) { - var f = a[c]; - if (!f.isStamp && f.getVisible() && Entry.checkCollisionRect(b, f.object.getTransformedBounds())) { + for (var c = c.parent.clonedEntities, e = 0, g = c.length;e < g;e++) { + var h = c[e]; + if (!h.isStamp && h.getVisible() && Entry.checkCollisionRect(d, h.object.getTransformedBounds())) { return !0; } } } else { - if (c.getVisible() && e(b, c.object, .2, !0)) { + if (c.getVisible() && f(d, c.object, .2, !0)) { return !0; } - a = c.parent.clonedEntities; - c = 0; - for (d = a.length;c < d;c++) { - if (f = a[c], !f.isStamp && f.getVisible() && e(b, f.object, .2, !0)) { + c = c.parent.clonedEntities; + e = 0; + for (g = c.length;e < g;e++) { + if (h = c[e], !h.isStamp && h.getVisible() && f(d, h.object, .2, !0)) { return !0; } } @@ -3259,11 +3168,9 @@ Blockly.Blocks.boolean_comparison = {init:function() { this.setOutput(!0, "Boolean"); this.setInputsInline(!0); }}; -Entry.block.boolean_comparison = function(a, b) { - a = b.getField("OPERATOR", b); - var c = b.getNumberValue("LEFTHAND", b); - b = b.getNumberValue("RIGHTHAND", b); - return "EQUAL" == a ? c == b : "BIGGER" == a ? c > b : c < b; +Entry.block.boolean_comparison = function(b, a) { + var c = a.getField("OPERATOR", a), d = a.getNumberValue("LEFTHAND", a), e = a.getNumberValue("RIGHTHAND", a); + return "EQUAL" == c ? d == e : "BIGGER" == c ? d > e : d < e; }; Blockly.Blocks.boolean_equal = {init:function() { this.setColour("#AEB8FF"); @@ -3273,10 +3180,9 @@ Blockly.Blocks.boolean_equal = {init:function() { this.setOutput(!0, "Boolean"); this.setInputsInline(!0); }}; -Entry.block.boolean_equal = function(a, b) { - a = b.getStringValue("LEFTHAND", b); - b = b.getStringValue("RIGHTHAND", b); - return a == b; +Entry.block.boolean_equal = function(b, a) { + var c = a.getStringValue("LEFTHAND", a), d = a.getStringValue("RIGHTHAND", a); + return c == d; }; Blockly.Blocks.boolean_bigger = {init:function() { this.setColour("#AEB8FF"); @@ -3286,10 +3192,9 @@ Blockly.Blocks.boolean_bigger = {init:function() { this.setOutput(!0, "Boolean"); this.setInputsInline(!0); }}; -Entry.block.boolean_bigger = function(a, b) { - a = b.getNumberValue("LEFTHAND", b); - b = b.getNumberValue("RIGHTHAND", b); - return a > b; +Entry.block.boolean_bigger = function(b, a) { + var c = a.getNumberValue("LEFTHAND", a), d = a.getNumberValue("RIGHTHAND", a); + return c > d; }; Blockly.Blocks.boolean_smaller = {init:function() { this.setColour("#AEB8FF"); @@ -3299,10 +3204,9 @@ Blockly.Blocks.boolean_smaller = {init:function() { this.setOutput(!0, "Boolean"); this.setInputsInline(!0); }}; -Entry.block.boolean_smaller = function(a, b) { - a = b.getNumberValue("LEFTHAND", b); - b = b.getNumberValue("RIGHTHAND", b); - return a < b; +Entry.block.boolean_smaller = function(b, a) { + var c = a.getNumberValue("LEFTHAND", a), d = a.getNumberValue("RIGHTHAND", a); + return c < d; }; Blockly.Blocks.boolean_and_or = {init:function() { this.setColour("#AEB8FF"); @@ -3312,11 +3216,9 @@ Blockly.Blocks.boolean_and_or = {init:function() { this.setOutput(!0, "Boolean"); this.setInputsInline(!0); }}; -Entry.block.boolean_and_or = function(a, b) { - a = b.getField("OPERATOR", b); - var c = b.getBooleanValue("LEFTHAND", b); - b = b.getBooleanValue("RIGHTHAND", b); - return "AND" == a ? c && b : c || b; +Entry.block.boolean_and_or = function(b, a) { + var c = a.getField("OPERATOR", a), d = a.getBooleanValue("LEFTHAND", a), e = a.getBooleanValue("RIGHTHAND", a); + return "AND" == c ? d && e : d || e; }; Blockly.Blocks.boolean_and = {init:function() { this.setColour("#AEB8FF"); @@ -3326,10 +3228,9 @@ Blockly.Blocks.boolean_and = {init:function() { this.setOutput(!0, "Boolean"); this.setInputsInline(!0); }}; -Entry.block.boolean_and = function(a, b) { - a = b.getBooleanValue("LEFTHAND", b); - b = b.getBooleanValue("RIGHTHAND", b); - return a && b; +Entry.block.boolean_and = function(b, a) { + var c = a.getBooleanValue("LEFTHAND", a), d = a.getBooleanValue("RIGHTHAND", a); + return c && d; }; Blockly.Blocks.boolean_or = {init:function() { this.setColour("#AEB8FF"); @@ -3339,10 +3240,9 @@ Blockly.Blocks.boolean_or = {init:function() { this.setOutput(!0, "Boolean"); this.setInputsInline(!0); }}; -Entry.block.boolean_or = function(a, b) { - a = b.getBooleanValue("LEFTHAND", b); - b = b.getBooleanValue("RIGHTHAND", b); - return a || b; +Entry.block.boolean_or = function(b, a) { + var c = a.getBooleanValue("LEFTHAND", a), d = a.getBooleanValue("RIGHTHAND", a); + return c || d; }; Blockly.Blocks.boolean_not = {init:function() { this.setColour("#AEB8FF"); @@ -3353,8 +3253,8 @@ Blockly.Blocks.boolean_not = {init:function() { this.setOutput(!0, "Boolean"); this.setInputsInline(!0); }}; -Entry.block.boolean_not = function(a, b) { - return !b.getBooleanValue("VALUE"); +Entry.block.boolean_not = function(b, a) { + return !a.getBooleanValue("VALUE"); }; Blockly.Blocks.true_or_false = {init:function() { this.setColour("#AEB8FF"); @@ -3363,8 +3263,8 @@ Blockly.Blocks.true_or_false = {init:function() { this.setOutput(!0, "Boolean"); this.setInputsInline(!0); }}; -Entry.block.true_or_false = function(a, b) { - return "true" == b.children[0].textContent; +Entry.block.true_or_false = function(b, a) { + return "true" == a.children[0].textContent; }; Blockly.Blocks.True = {init:function() { this.setColour("#AEB8FF"); @@ -3372,7 +3272,7 @@ Blockly.Blocks.True = {init:function() { this.setOutput(!0, "Boolean"); this.setInputsInline(!0); }}; -Entry.block.True = function(a, b) { +Entry.block.True = function(b, a) { return !0; }; Blockly.Blocks.False = {init:function() { @@ -3381,7 +3281,7 @@ Blockly.Blocks.False = {init:function() { this.setOutput(!0, "Boolean"); this.setInputsInline(!0); }}; -Entry.block.False = function(a, b) { +Entry.block.False = function(b, a) { return !1; }; Blockly.Blocks.boolean_basic_operator = {init:function() { @@ -3392,21 +3292,19 @@ Blockly.Blocks.boolean_basic_operator = {init:function() { this.setOutput(!0, "Boolean"); this.setInputsInline(!0); }}; -Entry.block.boolean_basic_operator = function(a, b) { - a = b.getField("OPERATOR", b); - var c = b.getStringValue("LEFTHAND", b); - b = b.getStringValue("RIGHTHAND", b); - switch(a) { +Entry.block.boolean_basic_operator = function(b, a) { + var c = a.getField("OPERATOR", a), d = a.getStringValue("LEFTHAND", a), e = a.getStringValue("RIGHTHAND", a); + switch(c) { case "EQUAL": - return c == b; + return d == e; case "GREATER": - return Number(c) > Number(b); + return +d > +e; case "LESS": - return Number(c) < Number(b); + return +d < +e; case "GREATER_OR_EQUAL": - return Number(c) >= Number(b); + return +d >= +e; case "LESS_OR_EQUAL": - return Number(c) <= Number(b); + return +d <= +e; } }; Blockly.Blocks.show = {init:function() { @@ -3416,9 +3314,9 @@ Blockly.Blocks.show = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.show = function(a, b) { - a.setVisible(!0); - return b.callReturn(); +Entry.block.show = function(b, a) { + b.setVisible(!0); + return a.callReturn(); }; Blockly.Blocks.hide = {init:function() { this.setColour("#EC4466"); @@ -3427,9 +3325,9 @@ Blockly.Blocks.hide = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.hide = function(a, b) { - a.setVisible(!1); - return b.callReturn(); +Entry.block.hide = function(b, a) { + b.setVisible(!1); + return a.callReturn(); }; Blockly.Blocks.dialog_time = {init:function() { this.setColour("#EC4466"); @@ -3444,20 +3342,20 @@ Blockly.Blocks.dialog_time = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.dialog_time = function(a, b) { - if (!b.isStart) { - var c = b.getNumberValue("SECOND", b), d = b.getStringValue("VALUE", b), e = b.getField("OPTION", b); - b.isStart = !0; - b.timeFlag = 1; +Entry.block.dialog_time = function(b, a) { + if (!a.isStart) { + var c = a.getNumberValue("SECOND", a), d = a.getStringValue("VALUE", a), e = a.getField("OPTION", a); + a.isStart = !0; + a.timeFlag = 1; d || "number" == typeof d || (d = " "); d = Entry.convertToRoundedDecimals(d, 3); - new Entry.Dialog(a, d, e); - a.syncDialogVisible(a.getVisible()); + new Entry.Dialog(b, d, e); + b.syncDialogVisible(b.getVisible()); setTimeout(function() { - b.timeFlag = 0; + a.timeFlag = 0; }, 1E3 * c); } - return 0 == b.timeFlag ? (delete b.timeFlag, delete b.isStart, a.dialog && a.dialog.remove(), b.callReturn()) : b; + return 0 == a.timeFlag ? (delete a.timeFlag, delete a.isStart, b.dialog && b.dialog.remove(), a.callReturn()) : a; }; Blockly.Blocks.dialog = {init:function() { this.setColour("#EC4466"); @@ -3470,13 +3368,13 @@ Blockly.Blocks.dialog = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.dialog = function(a, b) { - var c = b.getStringValue("VALUE", b); +Entry.block.dialog = function(b, a) { + var c = a.getStringValue("VALUE", a); c || "number" == typeof c || (c = " "); - var d = b.getField("OPTION", b), c = Entry.convertToRoundedDecimals(c, 3); - new Entry.Dialog(a, c, d); - a.syncDialogVisible(a.getVisible()); - return b.callReturn(); + var d = a.getField("OPTION", a), c = Entry.convertToRoundedDecimals(c, 3); + new Entry.Dialog(b, c, d); + b.syncDialogVisible(b.getVisible()); + return a.callReturn(); }; Blockly.Blocks.remove_dialog = {init:function() { this.setColour("#EC4466"); @@ -3485,9 +3383,9 @@ Blockly.Blocks.remove_dialog = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.remove_dialog = function(a, b) { - a.dialog && a.dialog.remove(); - return b.callReturn(); +Entry.block.remove_dialog = function(b, a) { + b.dialog && b.dialog.remove(); + return a.callReturn(); }; Blockly.Blocks.change_to_nth_shape = {init:function() { this.setColour("#EC4466"); @@ -3498,10 +3396,10 @@ Blockly.Blocks.change_to_nth_shape = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.change_to_nth_shape = function(a, b) { - var c = b.getField("VALUE", b), c = a.parent.getPicture(c); - a.setImage(c); - return b.callReturn(); +Entry.block.change_to_nth_shape = function(b, a) { + var c = a.getField("VALUE", a), c = b.parent.getPicture(c); + b.setImage(c); + return a.callReturn(); }; Blockly.Blocks.change_to_next_shape = {init:function() { this.setColour("#EC4466"); @@ -3510,11 +3408,11 @@ Blockly.Blocks.change_to_next_shape = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.change_to_next_shape = function(a, b) { +Entry.block.change_to_next_shape = function(b, a) { var c; - c = b.fields && "prev" === b.getStringField("DRIECTION") ? a.parent.getPrevPicture(a.picture.id) : a.parent.getNextPicture(a.picture.id); - a.setImage(c); - return b.callReturn(); + c = a.fields && "prev" === a.getStringField("DRIECTION") ? b.parent.getPrevPicture(b.picture.id) : b.parent.getNextPicture(b.picture.id); + b.setImage(c); + return a.callReturn(); }; Blockly.Blocks.set_effect_volume = {init:function() { this.setColour("#EC4466"); @@ -3527,11 +3425,11 @@ Blockly.Blocks.set_effect_volume = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.set_effect_volume = function(a, b) { - var c = b.getField("EFFECT", b), d = b.getNumberValue("VALUE", b); - "color" == c ? a.effect.hue = d + a.effect.hue : "lens" != c && "swriling" != c && "pixel" != c && "mosaic" != c && ("brightness" == c ? a.effect.brightness = d + a.effect.brightness : "blur" != c && "opacity" == c && (a.effect.alpha += d / 100)); - a.applyFilter(); - return b.callReturn(); +Entry.block.set_effect_volume = function(b, a) { + var c = a.getField("EFFECT", a), d = a.getNumberValue("VALUE", a); + "color" == c ? b.effect.hue = d + b.effect.hue : "lens" != c && "swriling" != c && "pixel" != c && "mosaic" != c && ("brightness" == c ? b.effect.brightness = d + b.effect.brightness : "blur" != c && "opacity" == c && (b.effect.alpha += d / 100)); + b.applyFilter(); + return a.callReturn(); }; Blockly.Blocks.set_effect = {init:function() { this.setColour("#EC4466"); @@ -3544,11 +3442,11 @@ Blockly.Blocks.set_effect = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.set_effect = function(a, b) { - var c = b.getField("EFFECT", b), d = b.getNumberValue("VALUE", b); - "color" == c ? a.effect.hue = d : "lens" != c && "swriling" != c && "pixel" != c && "mosaic" != c && ("brightness" == c ? a.effect.brightness = d : "blur" != c && "opacity" == c && (a.effect.alpha = d / 100)); - a.applyFilter(); - return b.callReturn(); +Entry.block.set_effect = function(b, a) { + var c = a.getField("EFFECT", a), d = a.getNumberValue("VALUE", a); + "color" == c ? b.effect.hue = d : "lens" != c && "swriling" != c && "pixel" != c && "mosaic" != c && ("brightness" == c ? b.effect.brightness = d : "blur" != c && "opacity" == c && (b.effect.alpha = d / 100)); + b.applyFilter(); + return a.callReturn(); }; Blockly.Blocks.erase_all_effects = {init:function() { this.setColour("#EC4466"); @@ -3557,9 +3455,9 @@ Blockly.Blocks.erase_all_effects = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.erase_all_effects = function(a, b) { - a.resetFilter(); - return b.callReturn(); +Entry.block.erase_all_effects = function(b, a) { + b.resetFilter(); + return a.callReturn(); }; Blockly.Blocks.change_scale_percent = {init:function() { this.setColour("#EC4466"); @@ -3570,11 +3468,11 @@ Blockly.Blocks.change_scale_percent = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.change_scale_percent = function(a, b) { - var c = (b.getNumberValue("VALUE", b) + 100) / 100; - a.setScaleX(a.getScaleX() * c); - a.setScaleY(a.getScaleY() * c); - return b.callReturn(); +Entry.block.change_scale_percent = function(b, a) { + var c = (a.getNumberValue("VALUE", a) + 100) / 100; + b.setScaleX(b.getScaleX() * c); + b.setScaleY(b.getScaleY() * c); + return a.callReturn(); }; Blockly.Blocks.set_scale_percent = {init:function() { this.setColour("#EC4466"); @@ -3585,11 +3483,11 @@ Blockly.Blocks.set_scale_percent = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.set_scale_percent = function(a, b) { - var c = b.getNumberValue("VALUE", b) / 100, d = a.snapshot_; - a.setScaleX(c * d.scaleX); - a.setScaleY(c * d.scaleY); - return b.callReturn(); +Entry.block.set_scale_percent = function(b, a) { + var c = a.getNumberValue("VALUE", a) / 100, d = b.snapshot_; + b.setScaleX(c * d.scaleX); + b.setScaleY(c * d.scaleY); + return a.callReturn(); }; Blockly.Blocks.change_scale_size = {init:function() { this.setColour("#EC4466"); @@ -3600,10 +3498,10 @@ Blockly.Blocks.change_scale_size = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.change_scale_size = function(a, b) { - var c = b.getNumberValue("VALUE", b); - a.setSize(a.getSize() + c); - return b.callReturn(); +Entry.block.change_scale_size = function(b, a) { + var c = a.getNumberValue("VALUE", a); + b.setSize(b.getSize() + c); + return a.callReturn(); }; Blockly.Blocks.set_scale_size = {init:function() { this.setColour("#EC4466"); @@ -3614,10 +3512,10 @@ Blockly.Blocks.set_scale_size = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.set_scale_size = function(a, b) { - var c = b.getNumberValue("VALUE", b); - a.setSize(c); - return b.callReturn(); +Entry.block.set_scale_size = function(b, a) { + var c = a.getNumberValue("VALUE", a); + b.setSize(c); + return a.callReturn(); }; Blockly.Blocks.flip_y = {init:function() { this.setColour("#EC4466"); @@ -3626,9 +3524,9 @@ Blockly.Blocks.flip_y = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.flip_y = function(a, b) { - a.setScaleX(-1 * a.getScaleX()); - return b.callReturn(); +Entry.block.flip_y = function(b, a) { + b.setScaleX(-1 * b.getScaleX()); + return a.callReturn(); }; Blockly.Blocks.flip_x = {init:function() { this.setColour("#EC4466"); @@ -3637,9 +3535,9 @@ Blockly.Blocks.flip_x = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.flip_x = function(a, b) { - a.setScaleY(-1 * a.getScaleY()); - return b.callReturn(); +Entry.block.flip_x = function(b, a) { + b.setScaleY(-1 * b.getScaleY()); + return a.callReturn(); }; Blockly.Blocks.set_object_order = {init:function() { this.setColour("#EC4466"); @@ -3650,11 +3548,10 @@ Blockly.Blocks.set_object_order = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.set_object_order = function(a, b) { - var c = b.getField("VALUE", b); - a = Entry.container.getCurrentObjects().indexOf(a.parent); - if (-1 < a) { - return Entry.container.moveElementByBlock(a, c), b.callReturn(); +Entry.block.set_object_order = function(b, a) { + var c = a.getField("VALUE", a), d = Entry.container.getCurrentObjects().indexOf(b.parent); + if (-1 < d) { + return Entry.container.moveElementByBlock(d, c), a.callReturn(); } throw Error("object is not available"); }; @@ -3666,8 +3563,8 @@ Blockly.Blocks.get_pictures = {init:function() { this.setOutput(!0, "String"); this.setInputsInline(!0); }}; -Entry.block.get_pictures = function(a, b) { - return b.getStringField("VALUE"); +Entry.block.get_pictures = function(b, a) { + return a.getStringField("VALUE"); }; Blockly.Blocks.change_to_some_shape = {init:function() { this.setColour("#EC4466"); @@ -3678,12 +3575,12 @@ Blockly.Blocks.change_to_some_shape = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.change_to_some_shape = function(a, b) { - var c = b.getStringValue("VALUE"); +Entry.block.change_to_some_shape = function(b, a) { + var c = a.getStringValue("VALUE"); Entry.parseNumber(c); - c = a.parent.getPicture(c); - a.setImage(c); - return b.callReturn(); + c = b.parent.getPicture(c); + b.setImage(c); + return a.callReturn(); }; Blockly.Blocks.add_effect_amount = {init:function() { this.setColour("#EC4466"); @@ -3696,11 +3593,11 @@ Blockly.Blocks.add_effect_amount = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.add_effect_amount = function(a, b) { - var c = b.getField("EFFECT", b), d = b.getNumberValue("VALUE", b); - "color" == c ? a.effect.hsv = d + a.effect.hsv : "brightness" == c ? a.effect.brightness = d + a.effect.brightness : "transparency" == c && (a.effect.alpha -= d / 100); - a.applyFilter(); - return b.callReturn(); +Entry.block.add_effect_amount = function(b, a) { + var c = a.getField("EFFECT", a), d = a.getNumberValue("VALUE", a); + "color" == c ? b.effect.hsv = d + b.effect.hsv : "brightness" == c ? b.effect.brightness = d + b.effect.brightness : "transparency" == c && (b.effect.alpha -= d / 100); + b.applyFilter(); + return a.callReturn(); }; Blockly.Blocks.change_effect_amount = {init:function() { this.setColour("#EC4466"); @@ -3713,11 +3610,11 @@ Blockly.Blocks.change_effect_amount = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.change_effect_amount = function(a, b) { - var c = b.getField("EFFECT", b), d = b.getNumberValue("VALUE", b); - "color" == c ? a.effect.hsv = d : "brightness" == c ? a.effect.brightness = d : "transparency" == c && (a.effect.alpha = 1 - d / 100); - a.applyFilter(); - return b.callReturn(); +Entry.block.change_effect_amount = function(b, a) { + var c = a.getField("EFFECT", a), d = a.getNumberValue("VALUE", a); + "color" == c ? b.effect.hsv = d : "brightness" == c ? b.effect.brightness = d : "transparency" == c && (b.effect.alpha = 1 - d / 100); + b.applyFilter(); + return a.callReturn(); }; Blockly.Blocks.set_effect_amount = {init:function() { this.setColour("#EC4466"); @@ -3730,11 +3627,11 @@ Blockly.Blocks.set_effect_amount = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.set_effect_amount = function(a, b) { - var c = b.getField("EFFECT", b), d = b.getNumberValue("VALUE", b); - "color" == c ? a.effect.hue = d + a.effect.hue : "brightness" == c ? a.effect.brightness = d + a.effect.brightness : "transparency" == c && (a.effect.alpha -= d / 100); - a.applyFilter(); - return b.callReturn(); +Entry.block.set_effect_amount = function(b, a) { + var c = a.getField("EFFECT", a), d = a.getNumberValue("VALUE", a); + "color" == c ? b.effect.hue = d + b.effect.hue : "brightness" == c ? b.effect.brightness = d + b.effect.brightness : "transparency" == c && (b.effect.alpha -= d / 100); + b.applyFilter(); + return a.callReturn(); }; Blockly.Blocks.set_entity_effect = {init:function() { this.setColour("#EC4466"); @@ -3747,11 +3644,11 @@ Blockly.Blocks.set_entity_effect = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.set_entity_effect = function(a, b) { - var c = b.getField("EFFECT", b), d = b.getNumberValue("VALUE", b); - "color" == c ? a.effect.hue = d : "brightness" == c ? a.effect.brightness = d : "transparency" == c && (a.effect.alpha = 1 - d / 100); - a.applyFilter(); - return b.callReturn(); +Entry.block.set_entity_effect = function(b, a) { + var c = a.getField("EFFECT", a), d = a.getNumberValue("VALUE", a); + "color" == c ? b.effect.hue = d : "brightness" == c ? b.effect.brightness = d : "transparency" == c && (b.effect.alpha = 1 - d / 100); + b.applyFilter(); + return a.callReturn(); }; Blockly.Blocks.change_object_index = {init:function() { this.setColour("#EC4466"); @@ -3761,11 +3658,9 @@ Blockly.Blocks.change_object_index = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.change_object_index = function(a, b) { - var c, d = b.getField("LOCATION", b), e = Entry.container.getCurrentObjects(); - a = e.indexOf(a.parent); - e = e.length - 1; - if (0 > a) { +Entry.block.change_object_index = function(b, a) { + var c, d = a.getField("LOCATION", a), e = Entry.container.getCurrentObjects(), f = e.indexOf(b.parent), e = e.length - 1; + if (0 > f) { throw Error("object is not available for current scene"); } switch(d) { @@ -3773,16 +3668,16 @@ Entry.block.change_object_index = function(a, b) { c = 0; break; case "FORWARD": - c = Math.max(0, a - 1); + c = Math.max(0, f - 1); break; case "BACKWARD": - c = Math.min(e, a + 1); + c = Math.min(e, f + 1); break; case "BACK": c = e; } - Entry.container.moveElementByBlock(a, c); - return b.callReturn(); + Entry.container.moveElementByBlock(f, c); + return a.callReturn(); }; Blockly.Blocks.move_direction = {init:function() { this.setColour("#A751E3"); @@ -3793,12 +3688,12 @@ Blockly.Blocks.move_direction = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.move_direction = function(a, b) { - var c = b.getNumberValue("VALUE", b); - a.setX(a.getX() + c * Math.cos((a.getRotation() + a.getDirection() - 90) / 180 * Math.PI)); - a.setY(a.getY() - c * Math.sin((a.getRotation() + a.getDirection() - 90) / 180 * Math.PI)); - a.brush && !a.brush.stop && a.brush.lineTo(a.getX(), -1 * a.getY()); - return b.callReturn(); +Entry.block.move_direction = function(b, a) { + var c = a.getNumberValue("VALUE", a); + b.setX(b.getX() + c * Math.cos((b.getRotation() + b.getDirection() - 90) / 180 * Math.PI)); + b.setY(b.getY() - c * Math.sin((b.getRotation() + b.getDirection() - 90) / 180 * Math.PI)); + b.brush && !b.brush.stop && b.brush.lineTo(b.getX(), -1 * b.getY()); + return a.callReturn(); }; Blockly.Blocks.move_x = {init:function() { this.setColour("#A751E3"); @@ -3809,11 +3704,11 @@ Blockly.Blocks.move_x = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.move_x = function(a, b) { - var c = b.getNumberValue("VALUE", b); - a.setX(a.getX() + c); - a.brush && !a.brush.stop && a.brush.lineTo(a.getX(), -1 * a.getY()); - return b.callReturn(); +Entry.block.move_x = function(b, a) { + var c = a.getNumberValue("VALUE", a); + b.setX(b.getX() + c); + b.brush && !b.brush.stop && b.brush.lineTo(b.getX(), -1 * b.getY()); + return a.callReturn(); }; Blockly.Blocks.move_y = {init:function() { this.setColour("#A751E3"); @@ -3824,11 +3719,11 @@ Blockly.Blocks.move_y = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.move_y = function(a, b) { - var c = b.getNumberValue("VALUE", b); - a.setY(a.getY() + c); - a.brush && !a.brush.stop && a.brush.lineTo(a.getX(), -1 * a.getY()); - return b.callReturn(); +Entry.block.move_y = function(b, a) { + var c = a.getNumberValue("VALUE", a); + b.setY(b.getY() + c); + b.brush && !b.brush.stop && b.brush.lineTo(b.getX(), -1 * b.getY()); + return a.callReturn(); }; Blockly.Blocks.locate_xy_time = {init:function() { this.setColour("#A751E3"); @@ -3843,29 +3738,29 @@ Blockly.Blocks.locate_xy_time = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.locate_xy_time = function(a, b) { - if (!b.isStart) { +Entry.block.locate_xy_time = function(b, a) { + if (!a.isStart) { var c; - c = b.getNumberValue("VALUE1", b); - b.isStart = !0; - b.frameCount = Math.floor(c * Entry.FPS); - b.x = b.getNumberValue("VALUE2", b); - b.y = b.getNumberValue("VALUE3", b); - } - if (0 != b.frameCount) { - c = b.x - a.getX(); - var d = b.y - a.getY(); - c /= b.frameCount; - d /= b.frameCount; - a.setX(a.getX() + c); - a.setY(a.getY() + d); - b.frameCount--; - a.brush && !a.brush.stop && a.brush.lineTo(a.getX(), -1 * a.getY()); - return b; + c = a.getNumberValue("VALUE1", a); + a.isStart = !0; + a.frameCount = Math.floor(c * Entry.FPS); + a.x = a.getNumberValue("VALUE2", a); + a.y = a.getNumberValue("VALUE3", a); + } + if (0 != a.frameCount) { + c = a.x - b.getX(); + var d = a.y - b.getY(); + c /= a.frameCount; + d /= a.frameCount; + b.setX(b.getX() + c); + b.setY(b.getY() + d); + a.frameCount--; + b.brush && !b.brush.stop && b.brush.lineTo(b.getX(), -1 * b.getY()); + return a; } - delete b.isStart; - delete b.frameCount; - return b.callReturn(); + delete a.isStart; + delete a.frameCount; + return a.callReturn(); }; Blockly.Blocks.rotate_by_angle = {init:function() { this.setColour("#A751E3"); @@ -3876,10 +3771,10 @@ Blockly.Blocks.rotate_by_angle = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.rotate_by_angle = function(a, b) { - var c = b.getNumberValue("VALUE", b); - a.setRotation(a.getRotation() + c); - return b.callReturn(); +Entry.block.rotate_by_angle = function(b, a) { + var c = a.getNumberValue("VALUE", a); + b.setRotation(b.getRotation() + c); + return a.callReturn(); }; Blockly.Blocks.rotate_by_angle_dropdown = {init:function() { this.setColour("#A751E3"); @@ -3889,10 +3784,10 @@ Blockly.Blocks.rotate_by_angle_dropdown = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.rotate_by_angle_dropdown = function(a, b) { - var c = b.getField("VALUE", b); - a.setRotation(a.getRotation() + Number(c)); - return b.callReturn(); +Entry.block.rotate_by_angle_dropdown = function(b, a) { + var c = a.getField("VALUE", a); + b.setRotation(b.getRotation() + +c); + return a.callReturn(); }; Blockly.Blocks.see_angle = {init:function() { this.setColour("#A751E3"); @@ -3903,10 +3798,10 @@ Blockly.Blocks.see_angle = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.see_angle = function(a, b) { - var c = b.getNumberValue("VALUE", b); - a.setDirection(c); - return b.callReturn(); +Entry.block.see_angle = function(b, a) { + var c = a.getNumberValue("VALUE", a); + b.setDirection(c); + return a.callReturn(); }; Blockly.Blocks.see_direction = {init:function() { this.setColour("#A751E3"); @@ -3917,10 +3812,10 @@ Blockly.Blocks.see_direction = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.see_direction = function(a, b) { - var c = b.getField("VALUE", b), d = Entry.container.getEntity(c), c = d.getX() - a.getX(), d = d.getY() - a.getY(); - 0 <= c ? a.setRotation(Math.atan(d / c) / Math.PI * 180 + 90) : a.setRotation(Math.atan(d / c) / Math.PI * 180 + 270); - return b.callReturn(); +Entry.block.see_direction = function(b, a) { + var c = a.getField("VALUE", a), d = Entry.container.getEntity(c), c = d.getX() - b.getX(), d = d.getY() - b.getY(); + 0 <= c ? b.setRotation(Math.atan(d / c) / Math.PI * 180 + 90) : b.setRotation(Math.atan(d / c) / Math.PI * 180 + 270); + return a.callReturn(); }; Blockly.Blocks.locate_xy = {init:function() { this.setColour("#A751E3"); @@ -3933,13 +3828,13 @@ Blockly.Blocks.locate_xy = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.locate_xy = function(a, b) { - var c = b.getNumberValue("VALUE1", b); - a.setX(c); - c = b.getNumberValue("VALUE2", b); - a.setY(c); - a.brush && !a.brush.stop && a.brush.lineTo(a.getX(), -1 * a.getY()); - return b.callReturn(); +Entry.block.locate_xy = function(b, a) { + var c = a.getNumberValue("VALUE1", a); + b.setX(c); + c = a.getNumberValue("VALUE2", a); + b.setY(c); + b.brush && !b.brush.stop && b.brush.lineTo(b.getX(), -1 * b.getY()); + return a.callReturn(); }; Blockly.Blocks.locate_x = {init:function() { this.setColour("#A751E3"); @@ -3950,11 +3845,11 @@ Blockly.Blocks.locate_x = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.locate_x = function(a, b) { - var c = b.getNumberValue("VALUE", b); - a.setX(c); - a.brush && !a.brush.stop && a.brush.lineTo(a.getX(), -1 * a.getY()); - return b.callReturn(); +Entry.block.locate_x = function(b, a) { + var c = a.getNumberValue("VALUE", a); + b.setX(c); + b.brush && !b.brush.stop && b.brush.lineTo(b.getX(), -1 * b.getY()); + return a.callReturn(); }; Blockly.Blocks.locate_y = {init:function() { this.setColour("#A751E3"); @@ -3965,11 +3860,11 @@ Blockly.Blocks.locate_y = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.locate_y = function(a, b) { - var c = b.getNumberValue("VALUE", b); - a.setY(c); - a.brush && !a.brush.stop && a.brush.lineTo(a.getX(), -1 * a.getY()); - return b.callReturn(); +Entry.block.locate_y = function(b, a) { + var c = a.getNumberValue("VALUE", a); + b.setY(c); + b.brush && !b.brush.stop && b.brush.lineTo(b.getX(), -1 * b.getY()); + return a.callReturn(); }; Blockly.Blocks.locate = {init:function() { this.setColour("#A751E3"); @@ -3980,13 +3875,13 @@ Blockly.Blocks.locate = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.locate = function(a, b) { - var c = b.getField("VALUE", b), d; +Entry.block.locate = function(b, a) { + var c = a.getField("VALUE", a), d; "mouse" == c ? (c = Entry.stage.mouseCoordinate.x, d = Entry.stage.mouseCoordinate.y) : (d = Entry.container.getEntity(c), c = d.getX(), d = d.getY()); - a.setX(Number(c)); - a.setY(Number(d)); - a.brush && !a.brush.stop && a.brush.lineTo(c, -1 * d); - return b.callReturn(); + b.setX(+c); + b.setY(+d); + b.brush && !b.brush.stop && b.brush.lineTo(c, -1 * d); + return a.callReturn(); }; Blockly.Blocks.move_xy_time = {init:function() { this.setColour("#A751E3"); @@ -4001,22 +3896,22 @@ Blockly.Blocks.move_xy_time = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.move_xy_time = function(a, b) { - if (!b.isStart) { +Entry.block.move_xy_time = function(b, a) { + if (!a.isStart) { var c; - c = b.getNumberValue("VALUE1", b); - var d = b.getNumberValue("VALUE2", b), e = b.getNumberValue("VALUE3", b); - b.isStart = !0; - b.frameCount = Math.floor(c * Entry.FPS); - b.dX = d / b.frameCount; - b.dY = e / b.frameCount; + c = a.getNumberValue("VALUE1", a); + var d = a.getNumberValue("VALUE2", a), e = a.getNumberValue("VALUE3", a); + a.isStart = !0; + a.frameCount = Math.floor(c * Entry.FPS); + a.dX = d / a.frameCount; + a.dY = e / a.frameCount; } - if (0 != b.frameCount) { - return a.setX(a.getX() + b.dX), a.setY(a.getY() + b.dY), b.frameCount--, a.brush && !a.brush.stop && a.brush.lineTo(a.getX(), -1 * a.getY()), b; + if (0 != a.frameCount) { + return b.setX(b.getX() + a.dX), b.setY(b.getY() + a.dY), a.frameCount--, b.brush && !b.brush.stop && b.brush.lineTo(b.getX(), -1 * b.getY()), a; } - delete b.isStart; - delete b.frameCount; - return b.callReturn(); + delete a.isStart; + delete a.frameCount; + return a.callReturn(); }; Blockly.Blocks.locate_time = {init:function() { this.setColour("#A751E3"); @@ -4040,21 +3935,21 @@ Blockly.Blocks.rotate_by_angle_time = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.rotate_by_angle_time = function(a, b) { - if (!b.isStart) { +Entry.block.rotate_by_angle_time = function(b, a) { + if (!a.isStart) { var c; - c = b.getNumberValue("VALUE", b); - var d = b.getNumberField("VALUE", b); - b.isStart = !0; - b.frameCount = Math.floor(c * Entry.FPS); - b.dAngle = d / b.frameCount; + c = a.getNumberValue("VALUE", a); + var d = a.getNumberField("VALUE", a); + a.isStart = !0; + a.frameCount = Math.floor(c * Entry.FPS); + a.dAngle = d / a.frameCount; } - if (0 != b.frameCount) { - return a.setRotation(a.getRotation() + b.dAngle), b.frameCount--, b; + if (0 != a.frameCount) { + return b.setRotation(b.getRotation() + a.dAngle), a.frameCount--, a; } - delete b.isStart; - delete b.frameCount; - return b.callReturn(); + delete a.isStart; + delete a.frameCount; + return a.callReturn(); }; Blockly.Blocks.bounce_when = {init:function() { this.setColour("#A751E3"); @@ -4072,23 +3967,22 @@ Blockly.Blocks.bounce_wall = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.bounce_wall = function(a, b) { - var c = a.parent.getRotateMethod(), d = "free" == c ? (a.getRotation() + a.getDirection()).mod(360) : a.getDirection(), e; +Entry.block.bounce_wall = function(b, a) { + var c = b.parent.getRotateMethod(), d = "free" == c ? (b.getRotation() + b.getDirection()).mod(360) : b.getDirection(), e = Entry.Utils.COLLISION.NONE; if (90 > d && 0 <= d || 360 > d && 270 <= d) { - e = a.collision == Entry.Utils.COLLISION.UP; - var f = ndgmr.checkPixelCollision(Entry.stage.wall.up, a.object, 0, !1); - !f && e && (a.collision = Entry.Utils.COLLISION.NONE); + var e = b.collision == Entry.Utils.COLLISION.UP, f = ndgmr.checkPixelCollision(Entry.stage.wall.up, b.object, 0, !1); + !f && e && (b.collision = Entry.Utils.COLLISION.NONE); f && e && (f = !1); - f ? ("free" == c ? a.setRotation(-a.getRotation() - 2 * a.getDirection() + 180) : a.setDirection(-a.getDirection() + 180), a.collision = Entry.Utils.COLLISION.UP) : (e = a.collision == Entry.Utils.COLLISION.DOWN, f = ndgmr.checkPixelCollision(Entry.stage.wall.down, a.object, 0, !1), !f && e && (a.collision = Entry.Utils.COLLISION.NONE), f && e && (f = !1), f && ("free" == c ? a.setRotation(-a.getRotation() - 2 * a.getDirection() + 180) : a.setDirection(-a.getDirection() + 180), a.collision = + f ? ("free" == c ? b.setRotation(-b.getRotation() - 2 * b.getDirection() + 180) : b.setDirection(-b.getDirection() + 180), b.collision = Entry.Utils.COLLISION.UP) : (e = b.collision == Entry.Utils.COLLISION.DOWN, f = ndgmr.checkPixelCollision(Entry.stage.wall.down, b.object, 0, !1), !f && e && (b.collision = Entry.Utils.COLLISION.NONE), f && e && (f = !1), f && ("free" == c ? b.setRotation(-b.getRotation() - 2 * b.getDirection() + 180) : b.setDirection(-b.getDirection() + 180), b.collision = Entry.Utils.COLLISION.DOWN)); } else { - 270 > d && 90 <= d && (e = a.collision == Entry.Utils.COLLISION.DOWN, f = ndgmr.checkPixelCollision(Entry.stage.wall.down, a.object, 0, !1), !f && e && (a.collision = Entry.Utils.COLLISION.NONE), f && e && (f = !1), f ? ("free" == c ? a.setRotation(-a.getRotation() - 2 * a.getDirection() + 180) : a.setDirection(-a.getDirection() + 180), a.collision = Entry.Utils.COLLISION.DOWN) : (e = a.collision == Entry.Utils.COLLISION.UP, f = ndgmr.checkPixelCollision(Entry.stage.wall.up, a.object, 0, !1), - !f && e && (a.collision = Entry.Utils.COLLISION.NONE), f && e && (f = !1), f && ("free" == c ? a.setRotation(-a.getRotation() - 2 * a.getDirection() + 180) : a.setDirection(-a.getDirection() + 180), a.collision = Entry.Utils.COLLISION.UP))); + 270 > d && 90 <= d && (e = b.collision == Entry.Utils.COLLISION.DOWN, f = ndgmr.checkPixelCollision(Entry.stage.wall.down, b.object, 0, !1), !f && e && (b.collision = Entry.Utils.COLLISION.NONE), f && e && (f = !1), f ? ("free" == c ? b.setRotation(-b.getRotation() - 2 * b.getDirection() + 180) : b.setDirection(-b.getDirection() + 180), b.collision = Entry.Utils.COLLISION.DOWN) : (e = b.collision == Entry.Utils.COLLISION.UP, f = ndgmr.checkPixelCollision(Entry.stage.wall.up, b.object, 0, !1), + !f && e && (b.collision = Entry.Utils.COLLISION.NONE), f && e && (f = !1), f && ("free" == c ? b.setRotation(-b.getRotation() - 2 * b.getDirection() + 180) : b.setDirection(-b.getDirection() + 180), b.collision = Entry.Utils.COLLISION.UP))); } - 360 > d && 180 <= d ? (e = a.collision == Entry.Utils.COLLISION.LEFT, d = ndgmr.checkPixelCollision(Entry.stage.wall.left, a.object, 0, !1), !d && e && (a.collision = Entry.Utils.COLLISION.NONE), d && e && (d = !1), d ? ("free" == c ? a.setRotation(-a.getRotation() - 2 * a.getDirection()) : a.setDirection(-a.getDirection() + 360), a.collision = Entry.Utils.COLLISION.LEFT) : (e = a.collision == Entry.Utils.COLLISION.RIGHT, d = ndgmr.checkPixelCollision(Entry.stage.wall.right, a.object, 0, !1), !d && - e && (a.collision = Entry.Utils.COLLISION.NONE), d && e && (d = !1), d && ("free" == c ? a.setRotation(-a.getRotation() - 2 * a.getDirection()) : a.setDirection(-a.getDirection() + 360), a.collision = Entry.Utils.COLLISION.RIGHT))) : 180 > d && 0 <= d && (e = a.collision == Entry.Utils.COLLISION.RIGHT, d = ndgmr.checkPixelCollision(Entry.stage.wall.right, a.object, 0, !1), !d && e && (a.collision = Entry.Utils.COLLISION.NONE), d && e && (d = !1), d ? ("free" == c ? a.setRotation(-a.getRotation() - - 2 * a.getDirection()) : a.setDirection(-a.getDirection() + 360), a.collision = Entry.Utils.COLLISION.RIGHT) : (e = a.collision == Entry.Utils.COLLISION.LEFT, d = ndgmr.checkPixelCollision(Entry.stage.wall.left, a.object, 0, !1), !d && e && (a.collision = Entry.Utils.COLLISION.NONE), d && e && (d = !1), d && ("free" == c ? a.setRotation(-a.getRotation() - 2 * a.getDirection()) : a.setDirection(-a.getDirection() + 360), a.collision = Entry.Utils.COLLISION.LEFT))); - return b.callReturn(); + 360 > d && 180 <= d ? (e = b.collision == Entry.Utils.COLLISION.LEFT, d = ndgmr.checkPixelCollision(Entry.stage.wall.left, b.object, 0, !1), !d && e && (b.collision = Entry.Utils.COLLISION.NONE), d && e && (d = !1), d ? ("free" == c ? b.setRotation(-b.getRotation() - 2 * b.getDirection()) : b.setDirection(-b.getDirection() + 360), b.collision = Entry.Utils.COLLISION.LEFT) : (e = b.collision == Entry.Utils.COLLISION.RIGHT, d = ndgmr.checkPixelCollision(Entry.stage.wall.right, b.object, 0, !1), !d && + e && (b.collision = Entry.Utils.COLLISION.NONE), d && e && (d = !1), d && ("free" == c ? b.setRotation(-b.getRotation() - 2 * b.getDirection()) : b.setDirection(-b.getDirection() + 360), b.collision = Entry.Utils.COLLISION.RIGHT))) : 180 > d && 0 <= d && (e = b.collision == Entry.Utils.COLLISION.RIGHT, d = ndgmr.checkPixelCollision(Entry.stage.wall.right, b.object, 0, !1), !d && e && (b.collision = Entry.Utils.COLLISION.NONE), d && e && (d = !1), d ? ("free" == c ? b.setRotation(-b.getRotation() - + 2 * b.getDirection()) : b.setDirection(-b.getDirection() + 360), b.collision = Entry.Utils.COLLISION.RIGHT) : (e = b.collision == Entry.Utils.COLLISION.LEFT, d = ndgmr.checkPixelCollision(Entry.stage.wall.left, b.object, 0, !1), !d && e && (b.collision = Entry.Utils.COLLISION.NONE), d && e && (d = !1), d && ("free" == c ? b.setRotation(-b.getRotation() - 2 * b.getDirection()) : b.setDirection(-b.getDirection() + 360), b.collision = Entry.Utils.COLLISION.LEFT))); + return a.callReturn(); }; Blockly.Blocks.flip_arrow_horizontal = {init:function() { this.setColour("#A751E3"); @@ -4097,9 +3991,9 @@ Blockly.Blocks.flip_arrow_horizontal = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.flip_arrow_horizontal = function(a, b) { - a.setDirection(a.getDirection() + 180); - return b.callReturn(); +Entry.block.flip_arrow_horizontal = function(b, a) { + b.setDirection(b.getDirection() + 180); + return a.callReturn(); }; Blockly.Blocks.flip_arrow_vertical = {init:function() { this.setColour("#A751E3"); @@ -4108,9 +4002,9 @@ Blockly.Blocks.flip_arrow_vertical = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.flip_arrow_vertical = function(a, b) { - a.setDirection(a.getDirection() + 180); - return b.callReturn(); +Entry.block.flip_arrow_vertical = function(b, a) { + b.setDirection(b.getDirection() + 180); + return a.callReturn(); }; Blockly.Blocks.see_angle_object = {init:function() { this.setColour("#A751E3"); @@ -4121,16 +4015,16 @@ Blockly.Blocks.see_angle_object = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.see_angle_object = function(a, b) { - var c = b.getField("VALUE", b), d = a.getX(), e = a.getY(); - if (a.parent.id == c) { - return b.callReturn(); +Entry.block.see_angle_object = function(b, a) { + var c = a.getField("VALUE", a), d = b.getX(), e = b.getY(); + if (b.parent.id == c) { + return a.callReturn(); } "mouse" == c ? (c = Entry.stage.mouseCoordinate.y, d = Entry.stage.mouseCoordinate.x - d, e = c - e) : (c = Entry.container.getEntity(c), d = c.getX() - d, e = c.getY() - e); - e = 0 === d && 0 === e ? a.getDirection() + a.getRotation() : 0 <= d ? -Math.atan(e / d) / Math.PI * 180 + 90 : -Math.atan(e / d) / Math.PI * 180 + 270; - d = a.getDirection() + a.getRotation(); - a.setRotation(a.getRotation() + e - d); - return b.callReturn(); + e = 0 === d && 0 === e ? b.getDirection() + b.getRotation() : 0 <= d ? -Math.atan(e / d) / Math.PI * 180 + 90 : -Math.atan(e / d) / Math.PI * 180 + 270; + d = b.getDirection() + b.getRotation(); + b.setRotation(b.getRotation() + e - d); + return a.callReturn(); }; Blockly.Blocks.see_angle_direction = {init:function() { this.setColour("#A751E3"); @@ -4141,10 +4035,10 @@ Blockly.Blocks.see_angle_direction = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.see_angle_direction = function(a, b) { - var c = b.getNumberValue("VALUE", b), d = a.getDirection() + a.getRotation(); - a.setRotation(a.getRotation() + c - d); - return b.callReturn(); +Entry.block.see_angle_direction = function(b, a) { + var c = a.getNumberValue("VALUE", a), d = b.getDirection() + b.getRotation(); + b.setRotation(b.getRotation() + c - d); + return a.callReturn(); }; Blockly.Blocks.rotate_direction = {init:function() { this.setColour("#A751E3"); @@ -4155,10 +4049,10 @@ Blockly.Blocks.rotate_direction = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.rotate_direction = function(a, b) { - var c = b.getNumberValue("VALUE", b); - a.setDirection(c + a.getDirection()); - return b.callReturn(); +Entry.block.rotate_direction = function(b, a) { + var c = a.getNumberValue("VALUE", a); + b.setDirection(c + b.getDirection()); + return a.callReturn(); }; Blockly.Blocks.locate_object_time = {init:function() { this.setColour("#A751E3"); @@ -4171,25 +4065,25 @@ Blockly.Blocks.locate_object_time = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.locate_object_time = function(a, b) { - if (!b.isStart) { +Entry.block.locate_object_time = function(b, a) { + if (!a.isStart) { var c, d, e; - d = b.getField("TARGET", b); - c = b.getNumberValue("VALUE", b); + d = a.getField("TARGET", a); + c = a.getNumberValue("VALUE", a); c = Math.floor(c * Entry.FPS); e = Entry.stage.mouseCoordinate; if (0 != c) { - "mouse" == d ? (d = e.x - a.getX(), e = e.y - a.getY()) : (e = Entry.container.getEntity(d), d = e.getX() - a.getX(), e = e.getY() - a.getY()), b.isStart = !0, b.frameCount = c, b.dX = d / b.frameCount, b.dY = e / b.frameCount; + "mouse" == d ? (d = e.x - b.getX(), e = e.y - b.getY()) : (e = Entry.container.getEntity(d), d = e.getX() - b.getX(), e = e.getY() - b.getY()), a.isStart = !0, a.frameCount = c, a.dX = d / a.frameCount, a.dY = e / a.frameCount; } else { - return "mouse" == d ? (d = Number(e.x), e = Number(e.y)) : (e = Entry.container.getEntity(d), d = e.getX(), e = e.getY()), a.setX(d), a.setY(e), a.brush && !a.brush.stop && a.brush.lineTo(a.getX(), -1 * a.getY()), b.callReturn(); + return "mouse" == d ? (d = +e.x, e = +e.y) : (e = Entry.container.getEntity(d), d = e.getX(), e = e.getY()), b.setX(d), b.setY(e), b.brush && !b.brush.stop && b.brush.lineTo(b.getX(), -1 * b.getY()), a.callReturn(); } } - if (0 != b.frameCount) { - return a.setX(a.getX() + b.dX), a.setY(a.getY() + b.dY), b.frameCount--, a.brush && !a.brush.stop && a.brush.lineTo(a.getX(), -1 * a.getY()), b; + if (0 != a.frameCount) { + return b.setX(b.getX() + a.dX), b.setY(b.getY() + a.dY), a.frameCount--, b.brush && !b.brush.stop && b.brush.lineTo(b.getX(), -1 * b.getY()), a; } - delete b.isStart; - delete b.frameCount; - return b.callReturn(); + delete a.isStart; + delete a.frameCount; + return a.callReturn(); }; Blockly.Blocks.rotate_absolute = {init:function() { this.setColour("#A751E3"); @@ -4200,10 +4094,10 @@ Blockly.Blocks.rotate_absolute = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.rotate_absolute = function(a, b) { - var c = b.getNumberValue("VALUE", b); - a.setRotation(c); - return b.callReturn(); +Entry.block.rotate_absolute = function(b, a) { + var c = a.getNumberValue("VALUE", a); + b.setRotation(c); + return a.callReturn(); }; Blockly.Blocks.rotate_relative = {init:function() { this.setColour("#A751E3"); @@ -4214,10 +4108,10 @@ Blockly.Blocks.rotate_relative = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.rotate_relative = function(a, b) { - var c = b.getNumberValue("VALUE", b); - a.setRotation(c + a.getRotation()); - return b.callReturn(); +Entry.block.rotate_relative = function(b, a) { + var c = a.getNumberValue("VALUE", a); + b.setRotation(c + b.getRotation()); + return a.callReturn(); }; Blockly.Blocks.direction_absolute = {init:function() { this.setColour("#A751E3"); @@ -4228,10 +4122,10 @@ Blockly.Blocks.direction_absolute = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.direction_absolute = function(a, b) { - var c = b.getNumberValue("VALUE", b); - a.setDirection(c); - return b.callReturn(); +Entry.block.direction_absolute = function(b, a) { + var c = a.getNumberValue("VALUE", a); + b.setDirection(c); + return a.callReturn(); }; Blockly.Blocks.direction_relative = {init:function() { this.setColour("#A751E3"); @@ -4242,10 +4136,10 @@ Blockly.Blocks.direction_relative = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.direction_relative = function(a, b) { - var c = b.getNumberValue("VALUE", b); - a.setDirection(c + a.getDirection()); - return b.callReturn(); +Entry.block.direction_relative = function(b, a) { + var c = a.getNumberValue("VALUE", a); + b.setDirection(c + b.getDirection()); + return a.callReturn(); }; Blockly.Blocks.move_to_angle = {init:function() { this.setColour("#A751E3"); @@ -4258,12 +4152,12 @@ Blockly.Blocks.move_to_angle = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.move_to_angle = function(a, b) { - var c = b.getNumberValue("VALUE", b), d = b.getNumberValue("ANGLE", b); - a.setX(a.getX() + c * Math.cos((d - 90) / 180 * Math.PI)); - a.setY(a.getY() - c * Math.sin((d - 90) / 180 * Math.PI)); - a.brush && !a.brush.stop && a.brush.lineTo(a.getX(), -1 * a.getY()); - return b.callReturn(); +Entry.block.move_to_angle = function(b, a) { + var c = a.getNumberValue("VALUE", a), d = a.getNumberValue("ANGLE", a); + b.setX(b.getX() + c * Math.cos((d - 90) / 180 * Math.PI)); + b.setY(b.getY() - c * Math.sin((d - 90) / 180 * Math.PI)); + b.brush && !b.brush.stop && b.brush.lineTo(b.getX(), -1 * b.getY()); + return a.callReturn(); }; Blockly.Blocks.rotate_by_time = {init:function() { this.setColour("#A751E3"); @@ -4277,21 +4171,21 @@ Blockly.Blocks.rotate_by_time = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.rotate_by_time = function(a, b) { - if (!b.isStart) { +Entry.block.rotate_by_time = function(b, a) { + if (!a.isStart) { var c; - c = b.getNumberValue("VALUE", b); - var d = b.getNumberValue("ANGLE", b); - b.isStart = !0; - b.frameCount = Math.floor(c * Entry.FPS); - b.dAngle = d / b.frameCount; + c = a.getNumberValue("VALUE", a); + var d = a.getNumberValue("ANGLE", a); + a.isStart = !0; + a.frameCount = Math.floor(c * Entry.FPS); + a.dAngle = d / a.frameCount; } - if (0 != b.frameCount) { - return a.setRotation(a.getRotation() + b.dAngle), b.frameCount--, b; + if (0 != a.frameCount) { + return b.setRotation(b.getRotation() + a.dAngle), a.frameCount--, a; } - delete b.isStart; - delete b.frameCount; - return b.callReturn(); + delete a.isStart; + delete a.frameCount; + return a.callReturn(); }; Blockly.Blocks.direction_relative_duration = {init:function() { this.setColour("#A751E3"); @@ -4304,26 +4198,26 @@ Blockly.Blocks.direction_relative_duration = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.direction_relative_duration = function(a, b) { - if (!b.isStart) { +Entry.block.direction_relative_duration = function(b, a) { + if (!a.isStart) { var c; - c = b.getNumberValue("DURATION", b); - var d = b.getNumberValue("AMOUNT", b); - b.isStart = !0; - b.frameCount = Math.floor(c * Entry.FPS); - b.dDirection = d / b.frameCount; + c = a.getNumberValue("DURATION", a); + var d = a.getNumberValue("AMOUNT", a); + a.isStart = !0; + a.frameCount = Math.floor(c * Entry.FPS); + a.dDirection = d / a.frameCount; } - if (0 != b.frameCount) { - return a.setDirection(a.getDirection() + b.dDirection), b.frameCount--, b; + if (0 != a.frameCount) { + return b.setDirection(b.getDirection() + a.dDirection), a.frameCount--, a; } - delete b.isStart; - delete b.frameCount; - delete b.dDirection; - return b.callReturn(); + delete a.isStart; + delete a.frameCount; + delete a.dDirection; + return a.callReturn(); }; Entry.Neobot = {name:"neobot", LOCAL_MAP:["IN1", "IN2", "IN3", "IR", "BAT"], REMOTE_MAP:"OUT1 OUT2 OUT3 DCR DCL SND FND OPT".split(" "), setZero:function() { - for (var a in Entry.Neobot.REMOTE_MAP) { - Entry.hw.sendQueue[Entry.Neobot.REMOTE_MAP[a]] = 0; + for (var b in Entry.Neobot.REMOTE_MAP) { + Entry.hw.sendQueue[Entry.Neobot.REMOTE_MAP[b]] = 0; } Entry.hw.update(); }, name:"neobot", monitorTemplate:{imgPath:"hw/neobot.png", width:700, height:700, listPorts:{IR:{name:"\ub9ac\ubaa8\ucee8", type:"input", pos:{x:0, y:0}}, BAT:{name:"\ubca0\ud130\ub9ac", type:"input", pos:{x:0, y:0}}, SND:{name:Lang.Hw.buzzer, type:"output", pos:{x:0, y:0}}, FND:{name:"FND", type:"output", pos:{x:0, y:0}}}, ports:{IN1:{name:"IN1", type:"input", pos:{x:270, y:200}}, IN2:{name:"IN2", type:"input", pos:{x:325, y:200}}, IN3:{name:"IN3", type:"input", pos:{x:325, y:500}}, DCL:{name:"L-Motor", @@ -4334,9 +4228,9 @@ Blockly.Blocks.neobot_sensor_value = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.neobot_sensor_value = function(a, b) { - a = b.getStringField("PORT"); - return Entry.hw.portData[a]; +Entry.block.neobot_sensor_value = function(b, a) { + var c = a.getStringField("PORT"); + return Entry.hw.portData[c]; }; Blockly.Blocks.neobot_left_motor = {init:function() { this.setColour("#00979D"); @@ -4346,11 +4240,10 @@ Blockly.Blocks.neobot_left_motor = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.neobot_left_motor = function(a, b) { - a = b.getNumberField("SPEED"); - var c = b.getNumberField("DIRECTION"); - Entry.hw.sendQueue.DCL = a + c; - return b.callReturn(); +Entry.block.neobot_left_motor = function(b, a) { + var c = a.getNumberField("SPEED"), d = a.getNumberField("DIRECTION"); + Entry.hw.sendQueue.DCL = c + d; + return a.callReturn(); }; Blockly.Blocks.neobot_stop_left_motor = {init:function() { this.setColour("#00979D"); @@ -4359,9 +4252,9 @@ Blockly.Blocks.neobot_stop_left_motor = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.neobot_stop_left_motor = function(a, b) { +Entry.block.neobot_stop_left_motor = function(b, a) { Entry.hw.sendQueue.DCL = 0; - return b.callReturn(); + return a.callReturn(); }; Blockly.Blocks.neobot_right_motor = {init:function() { this.setColour("#00979D"); @@ -4371,11 +4264,10 @@ Blockly.Blocks.neobot_right_motor = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.neobot_right_motor = function(a, b) { - a = b.getNumberField("SPEED"); - var c = b.getNumberField("DIRECTION"); - Entry.hw.sendQueue.DCR = a + c; - return b.callReturn(); +Entry.block.neobot_right_motor = function(b, a) { + var c = a.getNumberField("SPEED"), d = a.getNumberField("DIRECTION"); + Entry.hw.sendQueue.DCR = c + d; + return a.callReturn(); }; Blockly.Blocks.neobot_stop_right_motor = {init:function() { this.setColour("#00979D"); @@ -4384,9 +4276,9 @@ Blockly.Blocks.neobot_stop_right_motor = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.neobot_stop_right_motor = function(a, b) { +Entry.block.neobot_stop_right_motor = function(b, a) { Entry.hw.sendQueue.DCR = 0; - return b.callReturn(); + return a.callReturn(); }; Blockly.Blocks.neobot_all_motor = {init:function() { this.setColour("#00979D"); @@ -4397,34 +4289,34 @@ Blockly.Blocks.neobot_all_motor = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.neobot_all_motor = function(a, b) { - b.getNumberField("TYPE"); - a = b.getNumberField("SPEED"); - switch(b.getNumberField("DIRECTION")) { +Entry.block.neobot_all_motor = function(b, a) { + a.getNumberField("TYPE"); + var c = a.getNumberField("SPEED"); + switch(a.getNumberField("DIRECTION")) { case 1: - Entry.hw.sendQueue.DCL = 16 + a; - Entry.hw.sendQueue.DCR = 16 + a; + Entry.hw.sendQueue.DCL = 16 + c; + Entry.hw.sendQueue.DCR = 16 + c; break; case 2: - Entry.hw.sendQueue.DCL = 32 + a; - Entry.hw.sendQueue.DCR = 32 + a; + Entry.hw.sendQueue.DCL = 32 + c; + Entry.hw.sendQueue.DCR = 32 + c; break; case 3: - Entry.hw.sendQueue.DCL = 32 + a; - Entry.hw.sendQueue.DCR = 16 + a; + Entry.hw.sendQueue.DCL = 32 + c; + Entry.hw.sendQueue.DCR = 16 + c; break; case 4: - Entry.hw.sendQueue.DCL = 16 + a; - Entry.hw.sendQueue.DCR = 32 + a; + Entry.hw.sendQueue.DCL = 16 + c; + Entry.hw.sendQueue.DCR = 32 + c; break; case 5: Entry.hw.sendQueue.DCL = 0; - Entry.hw.sendQueue.DCR = 16 + a; + Entry.hw.sendQueue.DCR = 16 + c; break; case 6: - Entry.hw.sendQueue.DCL = 16 + a, Entry.hw.sendQueue.DCR = 0; + Entry.hw.sendQueue.DCL = 16 + c, Entry.hw.sendQueue.DCR = 0; } - return b.callReturn(); + return a.callReturn(); }; Blockly.Blocks.neobot_set_servo = {init:function() { this.setColour("#00979D"); @@ -4434,13 +4326,12 @@ Blockly.Blocks.neobot_set_servo = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.neobot_set_servo = function(a, b) { - a = b.getNumberField("PORT"); - var c = b.getNumberField("DEGREE"); - Entry.hw.sendQueue["OUT" + a] = c; - 3 === a && (a = 4); - Entry.hw.sendQueue.OPT |= a; - return b.callReturn(); +Entry.block.neobot_set_servo = function(b, a) { + var c = a.getNumberField("PORT"), d = a.getNumberField("DEGREE"); + Entry.hw.sendQueue["OUT" + c] = d; + 3 === c && (c = 4); + Entry.hw.sendQueue.OPT |= c; + return a.callReturn(); }; Blockly.Blocks.neobot_set_output = {init:function() { this.setColour("#00979D"); @@ -4451,14 +4342,13 @@ Blockly.Blocks.neobot_set_output = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.neobot_set_output = function(a, b) { - a = b.getStringField("PORT", b); - var c = b.getNumberValue("VALUE", b), d = a; - 0 > c ? c = 0 : 255 < c && (c = 255); - 3 === d && (d = 4); - Entry.hw.sendQueue["OUT" + a] = c; - Entry.hw.sendQueue.OPT &= ~d; - return b.callReturn(); +Entry.block.neobot_set_output = function(b, a) { + var c = a.getStringField("PORT", a), d = a.getNumberValue("VALUE", a), e = c; + 0 > d ? d = 0 : 255 < d && (d = 255); + 3 === e && (e = 4); + Entry.hw.sendQueue["OUT" + c] = d; + Entry.hw.sendQueue.OPT &= ~e; + return a.callReturn(); }; Blockly.Blocks.neobot_set_fnd = {init:function() { this.setColour("#00979D"); @@ -4469,11 +4359,11 @@ Blockly.Blocks.neobot_set_fnd = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.neobot_set_fnd = function(a, b) { - a = b.getNumberValue("VALUE", b); - 255 < a ? a = 255 : 0 > a && (a = 0); - Entry.hw.sendQueue.FND = a; - return b.callReturn(); +Entry.block.neobot_set_fnd = function(b, a) { + var c = a.getNumberValue("VALUE", a); + 255 < c ? c = 255 : 0 > c && (c = 0); + Entry.hw.sendQueue.FND = c; + return a.callReturn(); }; Blockly.Blocks.neobot_play_note_for = {init:function() { this.setColour("#00979D"); @@ -4484,27 +4374,27 @@ Blockly.Blocks.neobot_play_note_for = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.neobot_play_note_for = function(a, b) { - a = Entry.hw.sendQueue; - if (b.isStart) { - if (1 == b.timeFlag) { - return b; +Entry.block.neobot_play_note_for = function(b, a) { + var c = Entry.hw.sendQueue; + if (a.isStart) { + if (1 == a.timeFlag) { + return a; } - delete b.timeFlag; - delete b.isStart; + delete a.timeFlag; + delete a.isStart; Entry.hw.sendQueue.SND = 0; Entry.engine.isContinue = !1; - return b.callReturn(); + return a.callReturn(); } - var c = b.getNumberField("NOTE", b), d = b.getNumberField("OCTAVE", b), e = b.getNumberField("DURATION", b), c = c + 12 * d; - b.isStart = !0; - b.timeFlag = 1; - 65 < c && (c = 65); - a.SND = c; + var d = a.getNumberField("NOTE", a), e = a.getNumberField("OCTAVE", a), f = a.getNumberField("DURATION", a), d = d + 12 * e; + a.isStart = !0; + a.timeFlag = 1; + 65 < d && (d = 65); + c.SND = d; setTimeout(function() { - b.timeFlag = 0; - }, 1 / e * 2E3); - return b; + a.timeFlag = 0; + }, 1 / f * 2E3); + return a; }; Entry.Robotis_carCont = {INSTRUCTION:{NONE:0, WRITE:3, READ:2}, CONTROL_TABLE:{CM_LED:[67, 1], CM_SPRING_RIGHT:[69, 1, 69, 2], CM_SPRING_LEFT:[70, 1, 69, 2], CM_SWITCH:[71, 1], CM_SOUND_DETECTED:[86, 1], CM_SOUND_DETECTING:[87, 1], CM_IR_LEFT:[91, 2, 91, 4], CM_IR_RIGHT:[93, 2, 91, 4], CM_CALIBRATION_LEFT:[95, 2], CM_CALIBRATION_RIGHT:[97, 2], AUX_MOTOR_SPEED_LEFT:[152, 2], AUX_MOTOR_SPEED_RIGHT:[154, 2]}, setZero:function() { this.setRobotisData([[Entry.Robotis_carCont.INSTRUCTION.WRITE, 152, 2, 0], [Entry.Robotis_carCont.INSTRUCTION.WRITE, 154, 2, 0]]); @@ -4513,37 +4403,37 @@ Entry.Robotis_carCont = {INSTRUCTION:{NONE:0, WRITE:3, READ:2}, CONTROL_TABLE:{C this.setRobotisData(null); Entry.hw.sendQueue.setZero = null; this.update(); -}, name:"robotis_carCont", delay:40, postCallReturn:function(a, b, c) { +}, name:"robotis_carCont", delay:40, postCallReturn:function(b, a, c) { if (0 >= c) { - return this.setRobotisData(b), this.update(), a.callReturn(); + return this.setRobotisData(a), this.update(), b.callReturn(); } - if (a.isStart) { - if (1 == a.timeFlag) { - return this.setRobotisData(null), a; + if (b.isStart) { + if (1 == b.timeFlag) { + return this.setRobotisData(null), b; } - delete a.timeFlag; - delete a.isStart; + delete b.timeFlag; + delete b.isStart; Entry.engine.isContinue = !1; this.update(); - return a.callReturn(); + return b.callReturn(); } - a.isStart = !0; - a.timeFlag = 1; - this.setRobotisData(b); + b.isStart = !0; + b.timeFlag = 1; + this.setRobotisData(a); setTimeout(function() { - a.timeFlag = 0; + b.timeFlag = 0; }, c); - return a; -}, wait:function(a, b) { - Entry.hw.socket.send(JSON.stringify(a)); - for (var c = a = (new Date).getTime();c < a + b;) { - c = (new Date).getTime(); + return b; +}, wait:function(b, a) { + Entry.hw.socket.send(JSON.stringify(b)); + for (var c = (new Date).getTime(), d = c;d < c + a;) { + d = (new Date).getTime(); } }, update:function() { Entry.hw.update(); this.setRobotisData(null); -}, setRobotisData:function(a) { - Entry.hw.sendQueue.ROBOTIS_DATA = null == a ? null : Entry.hw.sendQueue.ROBOTIS_DATA ? Entry.hw.sendQueue.ROBOTIS_DATA.concat(a) : a; +}, setRobotisData:function(b) { + Entry.hw.sendQueue.ROBOTIS_DATA = null == b ? null : Entry.hw.sendQueue.ROBOTIS_DATA ? Entry.hw.sendQueue.ROBOTIS_DATA.concat(b) : b; }}; Entry.Robotis_openCM70 = {INSTRUCTION:{NONE:0, WRITE:3, READ:2}, CONTROL_TABLE:{CM_LED_R:[79, 1], CM_LED_G:[80, 1], CM_LED_B:[81, 1], CM_BUZZER_INDEX:[84, 1], CM_BUZZER_TIME:[85, 1], CM_SOUND_DETECTED:[86, 1], CM_SOUND_DETECTING:[87, 1], CM_USER_BUTTON:[26, 1], CM_MOTION:[66, 1], AUX_SERVO_POSITION:[152, 2], AUX_IR:[168, 2], AUX_TOUCH:[202, 1], AUX_TEMPERATURE:[234, 1], AUX_ULTRASONIC:[242, 1], AUX_MAGNETIC:[250, 1], AUX_MOTION_DETECTION:[258, 1], AUX_COLOR:[266, 1], AUX_CUSTOM:[216, 2], AUX_BRIGHTNESS:[288, 2], AUX_HYDRO_THEMO_HUMIDITY:[274, 1], AUX_HYDRO_THEMO_TEMPER:[282, 1], AUX_SERVO_MODE:[126, 1], AUX_SERVO_SPEED:[136, 2], AUX_MOTOR_SPEED:[136, 2], AUX_LED_MODULE:[210, 1]}, setZero:function() { @@ -4566,14 +4456,13 @@ Blockly.Blocks.robotis_openCM70_cm_custom_value = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.robotis_openCM70_cm_custom_value = function(a, b) { - a = Entry.Robotis_openCM70.INSTRUCTION.READ; - var c = 0, d = b.getStringField("SIZE"); - "BYTE" == d ? c = 1 : "WORD" == d ? c = 2 : "DWORD" == d && (c = 4); - b = b.getNumberValue("VALUE"); - Entry.Robotis_carCont.setRobotisData([[a, b, c, 0, c]]); +Entry.block.robotis_openCM70_cm_custom_value = function(b, a) { + var c = Entry.Robotis_openCM70.INSTRUCTION.READ, d = 0, e = 0, f = 0, d = a.getStringField("SIZE"); + "BYTE" == d ? e = 1 : "WORD" == d ? e = 2 : "DWORD" == d && (e = 4); + f = d = a.getNumberValue("VALUE"); + Entry.Robotis_carCont.setRobotisData([[c, d, e, 0, e]]); Entry.Robotis_carCont.update(); - return Entry.hw.portData[b]; + return Entry.hw.portData[f]; }; Blockly.Blocks.robotis_openCM70_sensor_value = {init:function() { this.setColour("#00979D"); @@ -4583,22 +4472,20 @@ Blockly.Blocks.robotis_openCM70_sensor_value = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }, sensorList:function() { - var a = []; - a.push([Lang.Blocks.robotis_cm_sound_detected, "CM_SOUND_DETECTED"]); - a.push([Lang.Blocks.robotis_cm_sound_detecting, "CM_SOUND_DETECTING"]); - a.push([Lang.Blocks.robotis_cm_user_button, "CM_USER_BUTTON"]); - return a; + var b = []; + b.push([Lang.Blocks.robotis_cm_sound_detected, "CM_SOUND_DETECTED"]); + b.push([Lang.Blocks.robotis_cm_sound_detecting, "CM_SOUND_DETECTING"]); + b.push([Lang.Blocks.robotis_cm_user_button, "CM_USER_BUTTON"]); + return b; }}; -Entry.block.robotis_openCM70_sensor_value = function(a, b) { - a = Entry.Robotis_openCM70.INSTRUCTION.READ; - var c = 0, d = 0, e = 0, f = 0; - b = b.getStringField("SENSOR"); - "CM_SOUND_DETECTED" == b ? (e = Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTED[0], f = Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTED[1], c = Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTED[0], d = Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTED[1]) : "CM_SOUND_DETECTING" == b ? (e = Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTING[0], f = Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTING[1], c = Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTING[0], - d = Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTING[1]) : "CM_USER_BUTTON" == b && (e = Entry.Robotis_openCM70.CONTROL_TABLE.CM_USER_BUTTON[0], f = Entry.Robotis_openCM70.CONTROL_TABLE.CM_USER_BUTTON[1], c = Entry.Robotis_openCM70.CONTROL_TABLE.CM_USER_BUTTON[0], d = Entry.Robotis_openCM70.CONTROL_TABLE.CM_USER_BUTTON[1]); - e += 0 * f; - Entry.Robotis_carCont.setRobotisData([[a, c, d, 0, f]]); +Entry.block.robotis_openCM70_sensor_value = function(b, a) { + var c = Entry.Robotis_openCM70.INSTRUCTION.READ, d = 0, e = 0, f = 0, g = 0, h = a.getStringField("SENSOR"); + "CM_SOUND_DETECTED" == h ? (f = Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTED[0], g = Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTED[1], d = Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTED[0], e = Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTED[1]) : "CM_SOUND_DETECTING" == h ? (f = Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTING[0], g = Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTING[1], d = Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTING[0], + e = Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTING[1]) : "CM_USER_BUTTON" == h && (f = Entry.Robotis_openCM70.CONTROL_TABLE.CM_USER_BUTTON[0], g = Entry.Robotis_openCM70.CONTROL_TABLE.CM_USER_BUTTON[1], d = Entry.Robotis_openCM70.CONTROL_TABLE.CM_USER_BUTTON[0], e = Entry.Robotis_openCM70.CONTROL_TABLE.CM_USER_BUTTON[1]); + f += 0 * g; + Entry.Robotis_carCont.setRobotisData([[c, d, e, 0, g]]); Entry.Robotis_carCont.update(); - return Entry.hw.portData[e]; + return Entry.hw.portData[f]; }; Blockly.Blocks.robotis_openCM70_aux_sensor_value = {init:function() { this.setColour("#00979D"); @@ -4610,46 +4497,43 @@ Blockly.Blocks.robotis_openCM70_aux_sensor_value = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }, portList:function() { - var a = []; - a.push([Lang.Blocks.robotis_common_port_3, "PORT_3"]); - a.push([Lang.Blocks.robotis_common_port_4, "PORT_4"]); - a.push([Lang.Blocks.robotis_common_port_5, "PORT_5"]); - a.push([Lang.Blocks.robotis_common_port_6, "PORT_6"]); - return a; + var b = []; + b.push([Lang.Blocks.robotis_common_port_3, "PORT_3"]); + b.push([Lang.Blocks.robotis_common_port_4, "PORT_4"]); + b.push([Lang.Blocks.robotis_common_port_5, "PORT_5"]); + b.push([Lang.Blocks.robotis_common_port_6, "PORT_6"]); + return b; }, sensorList:function() { - var a = []; - a.push([Lang.Blocks.robotis_aux_servo_position, "AUX_SERVO_POSITION"]); - a.push([Lang.Blocks.robotis_aux_ir, "AUX_IR"]); - a.push([Lang.Blocks.robotis_aux_touch, "AUX_TOUCH"]); - a.push([Lang.Blocks.robotis_aux_brightness, "AUX_BRIGHTNESS"]); - a.push([Lang.Blocks.robotis_aux_hydro_themo_humidity, "AUX_HYDRO_THEMO_HUMIDITY"]); - a.push([Lang.Blocks.robotis_aux_hydro_themo_temper, "AUX_HYDRO_THEMO_TEMPER"]); - a.push([Lang.Blocks.robotis_aux_temperature, "AUX_TEMPERATURE"]); - a.push([Lang.Blocks.robotis_aux_ultrasonic, "AUX_ULTRASONIC"]); - a.push([Lang.Blocks.robotis_aux_magnetic, "AUX_MAGNETIC"]); - a.push([Lang.Blocks.robotis_aux_motion_detection, "AUX_MOTION_DETECTION"]); - a.push([Lang.Blocks.robotis_aux_color, "AUX_COLOR"]); - a.push([Lang.Blocks.robotis_aux_custom, "AUX_CUSTOM"]); - return a; + var b = []; + b.push([Lang.Blocks.robotis_aux_servo_position, "AUX_SERVO_POSITION"]); + b.push([Lang.Blocks.robotis_aux_ir, "AUX_IR"]); + b.push([Lang.Blocks.robotis_aux_touch, "AUX_TOUCH"]); + b.push([Lang.Blocks.robotis_aux_brightness, "AUX_BRIGHTNESS"]); + b.push([Lang.Blocks.robotis_aux_hydro_themo_humidity, "AUX_HYDRO_THEMO_HUMIDITY"]); + b.push([Lang.Blocks.robotis_aux_hydro_themo_temper, "AUX_HYDRO_THEMO_TEMPER"]); + b.push([Lang.Blocks.robotis_aux_temperature, "AUX_TEMPERATURE"]); + b.push([Lang.Blocks.robotis_aux_ultrasonic, "AUX_ULTRASONIC"]); + b.push([Lang.Blocks.robotis_aux_magnetic, "AUX_MAGNETIC"]); + b.push([Lang.Blocks.robotis_aux_motion_detection, "AUX_MOTION_DETECTION"]); + b.push([Lang.Blocks.robotis_aux_color, "AUX_COLOR"]); + b.push([Lang.Blocks.robotis_aux_custom, "AUX_CUSTOM"]); + return b; }}; -Entry.block.robotis_openCM70_aux_sensor_value = function(a, b) { - a = Entry.Robotis_openCM70.INSTRUCTION.READ; - var c = 0, d = 0, e = 0, f = 0, g = b.getStringField("PORT"); - b = b.getStringField("SENSOR"); - var h = 0; - "PORT_3" == g ? h = 2 : "PORT_4" == g ? h = 3 : "PORT_5" == g ? h = 4 : "PORT_6" == g && (h = 5); - "AUX_SERVO_POSITION" == b ? (e = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_SERVO_POSITION[0], f = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_SERVO_POSITION[1], c = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_SERVO_POSITION[0], d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_SERVO_POSITION[1]) : "AUX_IR" == b ? (e = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_IR[0], f = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_IR[1], c = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_IR[0], d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_IR[1]) : - "AUX_TOUCH" == b ? (e = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_TOUCH[0], f = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_TOUCH[1], c = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_TOUCH[0], d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_TOUCH[1]) : "AUX_TEMPERATURE" == b ? (e = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_TEMPERATURE[0], f = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_TEMPERATURE[1], c = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_TEMPERATURE[0], d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_TEMPERATURE[1]) : - "AUX_BRIGHTNESS" == b ? (e = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_BRIGHTNESS[0], f = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_BRIGHTNESS[1], c = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_BRIGHTNESS[0], d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_BRIGHTNESS[1]) : "AUX_HYDRO_THEMO_HUMIDITY" == b ? (e = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_HYDRO_THEMO_HUMIDITY[0], f = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_HYDRO_THEMO_HUMIDITY[1], c = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_HYDRO_THEMO_HUMIDITY[0], - d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_HYDRO_THEMO_HUMIDITY[1]) : "AUX_HYDRO_THEMO_TEMPER" == b ? (e = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_HYDRO_THEMO_TEMPER[0], f = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_HYDRO_THEMO_TEMPER[1], c = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_HYDRO_THEMO_TEMPER[0], d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_HYDRO_THEMO_TEMPER[1]) : "AUX_ULTRASONIC" == b ? (e = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_ULTRASONIC[0], f = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_ULTRASONIC[1], - c = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_ULTRASONIC[0], d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_ULTRASONIC[1]) : "AUX_MAGNETIC" == b ? (e = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_MAGNETIC[0], f = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_MAGNETIC[1], c = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_MAGNETIC[0], d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_MAGNETIC[1]) : "AUX_MOTION_DETECTION" == b ? (e = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_MOTION_DETECTION[0], f = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_MOTION_DETECTION[1], - c = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_MOTION_DETECTION[0], d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_MOTION_DETECTION[1]) : "AUX_COLOR" == b ? (e = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_COLOR[0], f = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_COLOR[1], c = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_COLOR[0], d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_COLOR[1]) : "AUX_CUSTOM" == b && (e = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_CUSTOM[0], f = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_CUSTOM[1], - c = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_CUSTOM[0], d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_CUSTOM[1]); - e += h * f; - 0 != h && (d = 6 * f); - Entry.Robotis_carCont.setRobotisData([[a, c, d, 0, f]]); +Entry.block.robotis_openCM70_aux_sensor_value = function(b, a) { + var c = Entry.Robotis_openCM70.INSTRUCTION.READ, d = 0, e = 0, f = 0, g = 0, h = a.getStringField("PORT"), k = a.getStringField("SENSOR"), l = 0; + "PORT_3" == h ? l = 2 : "PORT_4" == h ? l = 3 : "PORT_5" == h ? l = 4 : "PORT_6" == h && (l = 5); + "AUX_SERVO_POSITION" == k ? (f = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_SERVO_POSITION[0], g = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_SERVO_POSITION[1], d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_SERVO_POSITION[0], e = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_SERVO_POSITION[1]) : "AUX_IR" == k ? (f = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_IR[0], g = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_IR[1], d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_IR[0], e = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_IR[1]) : + "AUX_TOUCH" == k ? (f = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_TOUCH[0], g = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_TOUCH[1], d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_TOUCH[0], e = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_TOUCH[1]) : "AUX_TEMPERATURE" == k ? (f = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_TEMPERATURE[0], g = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_TEMPERATURE[1], d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_TEMPERATURE[0], e = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_TEMPERATURE[1]) : + "AUX_BRIGHTNESS" == k ? (f = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_BRIGHTNESS[0], g = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_BRIGHTNESS[1], d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_BRIGHTNESS[0], e = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_BRIGHTNESS[1]) : "AUX_HYDRO_THEMO_HUMIDITY" == k ? (f = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_HYDRO_THEMO_HUMIDITY[0], g = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_HYDRO_THEMO_HUMIDITY[1], d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_HYDRO_THEMO_HUMIDITY[0], + e = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_HYDRO_THEMO_HUMIDITY[1]) : "AUX_HYDRO_THEMO_TEMPER" == k ? (f = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_HYDRO_THEMO_TEMPER[0], g = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_HYDRO_THEMO_TEMPER[1], d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_HYDRO_THEMO_TEMPER[0], e = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_HYDRO_THEMO_TEMPER[1]) : "AUX_ULTRASONIC" == k ? (f = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_ULTRASONIC[0], g = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_ULTRASONIC[1], + d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_ULTRASONIC[0], e = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_ULTRASONIC[1]) : "AUX_MAGNETIC" == k ? (f = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_MAGNETIC[0], g = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_MAGNETIC[1], d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_MAGNETIC[0], e = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_MAGNETIC[1]) : "AUX_MOTION_DETECTION" == k ? (f = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_MOTION_DETECTION[0], g = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_MOTION_DETECTION[1], + d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_MOTION_DETECTION[0], e = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_MOTION_DETECTION[1]) : "AUX_COLOR" == k ? (f = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_COLOR[0], g = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_COLOR[1], d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_COLOR[0], e = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_COLOR[1]) : "AUX_CUSTOM" == k && (f = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_CUSTOM[0], g = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_CUSTOM[1], + d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_CUSTOM[0], e = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_CUSTOM[1]); + f += l * g; + 0 != l && (e = 6 * g); + Entry.Robotis_carCont.setRobotisData([[c, d, e, 0, g]]); Entry.Robotis_carCont.update(); - return Entry.hw.portData[e]; + return Entry.hw.portData[f]; }; Blockly.Blocks.robotis_openCM70_cm_buzzer_index = {init:function() { this.setColour("#00979D"); @@ -4666,14 +4550,12 @@ Blockly.Blocks.robotis_openCM70_cm_buzzer_index = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.robotis_openCM70_cm_buzzer_index = function(a, b) { - a = b.getField("CM_BUZZER_INDEX", b); - var c = b.getNumberValue("CM_BUZZER_TIME", b), d = Entry.Robotis_openCM70.INSTRUCTION.WRITE, e, f, g; - e = Entry.Robotis_openCM70.CONTROL_TABLE.CM_BUZZER_TIME[0]; - f = Entry.Robotis_openCM70.CONTROL_TABLE.CM_BUZZER_TIME[1]; - g = parseInt(10 * c); - 50 < g && (g = 50); - return Entry.Robotis_carCont.postCallReturn(b, [[d, e, f, g], [d, Entry.Robotis_openCM70.CONTROL_TABLE.CM_BUZZER_INDEX[0], Entry.Robotis_openCM70.CONTROL_TABLE.CM_BUZZER_INDEX[1], a]], 1E3 * c); +Entry.block.robotis_openCM70_cm_buzzer_index = function(b, a) { + var c = a.getField("CM_BUZZER_INDEX", a), d = a.getNumberValue("CM_BUZZER_TIME", a), e = Entry.Robotis_openCM70.INSTRUCTION.WRITE, f = 0, g = 0, h = 0, k = 0, l = 0, f = Entry.Robotis_openCM70.CONTROL_TABLE.CM_BUZZER_TIME[0], g = Entry.Robotis_openCM70.CONTROL_TABLE.CM_BUZZER_TIME[1], h = parseInt(10 * d); + 50 < h && (h = 50); + k = Entry.Robotis_openCM70.CONTROL_TABLE.CM_BUZZER_INDEX[0]; + l = Entry.Robotis_openCM70.CONTROL_TABLE.CM_BUZZER_INDEX[1]; + return Entry.Robotis_carCont.postCallReturn(a, [[e, f, g, h], [e, k, l, c]], 1E3 * d); }; Blockly.Blocks.robotis_openCM70_cm_buzzer_melody = {init:function() { this.setColour("#00979D"); @@ -4686,10 +4568,9 @@ Blockly.Blocks.robotis_openCM70_cm_buzzer_melody = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.robotis_openCM70_cm_buzzer_melody = function(a, b) { - a = b.getField("CM_BUZZER_MELODY", b); - var c = Entry.Robotis_openCM70.INSTRUCTION.WRITE; - return Entry.Robotis_carCont.postCallReturn(b, [[c, Entry.Robotis_openCM70.CONTROL_TABLE.CM_BUZZER_TIME[0], Entry.Robotis_openCM70.CONTROL_TABLE.CM_BUZZER_TIME[1], 255], [c, Entry.Robotis_openCM70.CONTROL_TABLE.CM_BUZZER_INDEX[0], Entry.Robotis_openCM70.CONTROL_TABLE.CM_BUZZER_INDEX[1], a]], 1E3); +Entry.block.robotis_openCM70_cm_buzzer_melody = function(b, a) { + var c = a.getField("CM_BUZZER_MELODY", a), d = Entry.Robotis_openCM70.INSTRUCTION.WRITE, e = 0, f = 0, g = 0, h = 0, e = Entry.Robotis_openCM70.CONTROL_TABLE.CM_BUZZER_TIME[0], f = Entry.Robotis_openCM70.CONTROL_TABLE.CM_BUZZER_TIME[1], g = Entry.Robotis_openCM70.CONTROL_TABLE.CM_BUZZER_INDEX[0], h = Entry.Robotis_openCM70.CONTROL_TABLE.CM_BUZZER_INDEX[1]; + return Entry.Robotis_carCont.postCallReturn(a, [[d, e, f, 255], [d, g, h, c]], 1E3); }; Blockly.Blocks.robotis_openCM70_cm_sound_detected_clear = {init:function() { this.setColour("#00979D"); @@ -4698,8 +4579,9 @@ Blockly.Blocks.robotis_openCM70_cm_sound_detected_clear = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.robotis_openCM70_cm_sound_detected_clear = function(a, b) { - return Entry.Robotis_carCont.postCallReturn(b, [[Entry.Robotis_openCM70.INSTRUCTION.WRITE, Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTED[0], Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTED[1], 0]], Entry.Robotis_openCM70.delay); +Entry.block.robotis_openCM70_cm_sound_detected_clear = function(b, a) { + var c = Entry.Robotis_openCM70.INSTRUCTION.WRITE, d = 0, e = 0, d = Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTED[0], e = Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTED[1]; + return Entry.Robotis_carCont.postCallReturn(a, [[c, d, e, 0]], Entry.Robotis_openCM70.delay); }; Blockly.Blocks.robotis_openCM70_cm_led = {init:function() { this.setColour("#00979D"); @@ -4709,11 +4591,10 @@ Blockly.Blocks.robotis_openCM70_cm_led = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.robotis_openCM70_cm_led = function(a, b) { - a = b.getField("CM_LED", b); - var c = b.getField("VALUE", b), d = Entry.Robotis_openCM70.INSTRUCTION.WRITE, e = 0, f = 0; - "CM_LED_R" == a ? (e = Entry.Robotis_openCM70.CONTROL_TABLE.CM_LED_R[0], f = Entry.Robotis_openCM70.CONTROL_TABLE.CM_LED_R[1]) : "CM_LED_G" == a ? (e = Entry.Robotis_openCM70.CONTROL_TABLE.CM_LED_G[0], f = Entry.Robotis_openCM70.CONTROL_TABLE.CM_LED_G[1]) : "CM_LED_B" == a && (e = Entry.Robotis_openCM70.CONTROL_TABLE.CM_LED_B[0], f = Entry.Robotis_openCM70.CONTROL_TABLE.CM_LED_B[1]); - return Entry.Robotis_carCont.postCallReturn(b, [[d, e, f, c]], Entry.Robotis_openCM70.delay); +Entry.block.robotis_openCM70_cm_led = function(b, a) { + var c = a.getField("CM_LED", a), d = a.getField("VALUE", a), e = Entry.Robotis_openCM70.INSTRUCTION.WRITE, f = 0, g = 0; + "CM_LED_R" == c ? (f = Entry.Robotis_openCM70.CONTROL_TABLE.CM_LED_R[0], g = Entry.Robotis_openCM70.CONTROL_TABLE.CM_LED_R[1]) : "CM_LED_G" == c ? (f = Entry.Robotis_openCM70.CONTROL_TABLE.CM_LED_G[0], g = Entry.Robotis_openCM70.CONTROL_TABLE.CM_LED_G[1]) : "CM_LED_B" == c && (f = Entry.Robotis_openCM70.CONTROL_TABLE.CM_LED_B[0], g = Entry.Robotis_openCM70.CONTROL_TABLE.CM_LED_B[1]); + return Entry.Robotis_carCont.postCallReturn(a, [[e, f, g, d]], Entry.Robotis_openCM70.delay); }; Blockly.Blocks.robotis_openCM70_cm_motion = {init:function() { this.setColour("#00979D"); @@ -4725,13 +4606,9 @@ Blockly.Blocks.robotis_openCM70_cm_motion = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.robotis_openCM70_cm_motion = function(a, b) { - a = Entry.Robotis_openCM70.INSTRUCTION.WRITE; - var c, d, e; - c = Entry.Robotis_openCM70.CONTROL_TABLE.CM_MOTION[0]; - d = Entry.Robotis_openCM70.CONTROL_TABLE.CM_MOTION[1]; - e = b.getNumberValue("VALUE", b); - return Entry.Robotis_carCont.postCallReturn(b, [[a, c, d, e]], Entry.Robotis_openCM70.delay); +Entry.block.robotis_openCM70_cm_motion = function(b, a) { + var c = Entry.Robotis_openCM70.INSTRUCTION.WRITE, d = 0, e = 0, f = 0, d = Entry.Robotis_openCM70.CONTROL_TABLE.CM_MOTION[0], e = Entry.Robotis_openCM70.CONTROL_TABLE.CM_MOTION[1], f = a.getNumberValue("VALUE", a); + return Entry.Robotis_carCont.postCallReturn(a, [[c, d, e, f]], Entry.Robotis_openCM70.delay); }; Blockly.Blocks.robotis_openCM70_aux_motor_speed = {init:function() { this.setColour("#00979D"); @@ -4742,13 +4619,10 @@ Blockly.Blocks.robotis_openCM70_aux_motor_speed = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.robotis_openCM70_aux_motor_speed = function(a, b) { - a = b.getField("PORT", b); - var c = b.getField("DIRECTION_ANGLE", b), d = b.getNumberValue("VALUE"), e = Entry.Robotis_openCM70.INSTRUCTION.WRITE, f, g; - f = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_MOTOR_SPEED[0]; - g = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_MOTOR_SPEED[1]; - "CW" == c ? (d += 1024, 2047 < d && (d = 2047)) : 1023 < d && (d = 1023); - return Entry.Robotis_carCont.postCallReturn(b, [[e, f + (a - 1) * g, g, d]], Entry.Robotis_openCM70.delay); +Entry.block.robotis_openCM70_aux_motor_speed = function(b, a) { + var c = a.getField("PORT", a), d = a.getField("DIRECTION_ANGLE", a), e = a.getNumberValue("VALUE"), f = Entry.Robotis_openCM70.INSTRUCTION.WRITE, g = 0, h = 0, g = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_MOTOR_SPEED[0], h = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_MOTOR_SPEED[1]; + "CW" == d ? (e += 1024, 2047 < e && (e = 2047)) : 1023 < e && (e = 1023); + return Entry.Robotis_carCont.postCallReturn(a, [[f, g + (c - 1) * h, h, e]], Entry.Robotis_openCM70.delay); }; Blockly.Blocks.robotis_openCM70_aux_servo_mode = {init:function() { this.setColour("#00979D"); @@ -4758,12 +4632,9 @@ Blockly.Blocks.robotis_openCM70_aux_servo_mode = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.robotis_openCM70_aux_servo_mode = function(a, b) { - a = b.getField("PORT", b); - var c = b.getField("MODE", b), d = Entry.Robotis_openCM70.INSTRUCTION.WRITE, e, f; - e = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_SERVO_MODE[0]; - f = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_SERVO_MODE[1]; - return Entry.Robotis_carCont.postCallReturn(b, [[d, e + (a - 1) * f, f, c]], Entry.Robotis_openCM70.delay); +Entry.block.robotis_openCM70_aux_servo_mode = function(b, a) { + var c = a.getField("PORT", a), d = a.getField("MODE", a), e = Entry.Robotis_openCM70.INSTRUCTION.WRITE, f = 0, g = 0, f = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_SERVO_MODE[0], g = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_SERVO_MODE[1]; + return Entry.Robotis_carCont.postCallReturn(a, [[e, f + (c - 1) * g, g, d]], Entry.Robotis_openCM70.delay); }; Blockly.Blocks.robotis_openCM70_aux_servo_speed = {init:function() { this.setColour("#00979D"); @@ -4774,13 +4645,10 @@ Blockly.Blocks.robotis_openCM70_aux_servo_speed = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.robotis_openCM70_aux_servo_speed = function(a, b) { - a = b.getField("PORT", b); - var c = b.getField("DIRECTION_ANGLE", b), d = b.getNumberValue("VALUE"), e = Entry.Robotis_openCM70.INSTRUCTION.WRITE, f, g; - f = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_SERVO_SPEED[0]; - g = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_SERVO_SPEED[1]; - "CW" == c ? (d += 1024, 2047 < d && (d = 2047)) : 1023 < d && (d = 1023); - return Entry.Robotis_carCont.postCallReturn(b, [[e, f + (a - 1) * g, g, d]], Entry.Robotis_openCM70.delay); +Entry.block.robotis_openCM70_aux_servo_speed = function(b, a) { + var c = a.getField("PORT", a), d = a.getField("DIRECTION_ANGLE", a), e = a.getNumberValue("VALUE"), f = Entry.Robotis_openCM70.INSTRUCTION.WRITE, g = 0, h = 0, g = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_SERVO_SPEED[0], h = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_SERVO_SPEED[1]; + "CW" == d ? (e += 1024, 2047 < e && (e = 2047)) : 1023 < e && (e = 1023); + return Entry.Robotis_carCont.postCallReturn(a, [[f, g + (c - 1) * h, h, e]], Entry.Robotis_openCM70.delay); }; Blockly.Blocks.robotis_openCM70_aux_servo_position = {init:function() { this.setColour("#00979D"); @@ -4791,13 +4659,10 @@ Blockly.Blocks.robotis_openCM70_aux_servo_position = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.robotis_openCM70_aux_servo_position = function(a, b) { - a = b.getField("PORT", b); - var c = b.getNumberValue("VALUE"), d = Entry.Robotis_openCM70.INSTRUCTION.WRITE, e, f; - e = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_SERVO_POSITION[0]; - f = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_SERVO_POSITION[1]; - 1023 < c ? c = 1023 : 0 > c && (c = 0); - return Entry.Robotis_carCont.postCallReturn(b, [[d, e + (a - 1) * f, f, c]], Entry.Robotis_openCM70.delay); +Entry.block.robotis_openCM70_aux_servo_position = function(b, a) { + var c = a.getField("PORT", a), d = a.getNumberValue("VALUE"), e = Entry.Robotis_openCM70.INSTRUCTION.WRITE, f = 0, g = 0, f = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_SERVO_POSITION[0], g = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_SERVO_POSITION[1]; + 1023 < d ? d = 1023 : 0 > d && (d = 0); + return Entry.Robotis_carCont.postCallReturn(a, [[e, f + (c - 1) * g, g, d]], Entry.Robotis_openCM70.delay); }; Blockly.Blocks.robotis_openCM70_aux_led_module = {init:function() { this.setColour("#00979D"); @@ -4808,12 +4673,9 @@ Blockly.Blocks.robotis_openCM70_aux_led_module = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.robotis_openCM70_aux_led_module = function(a, b) { - a = b.getField("PORT", b); - var c = b.getField("LED_MODULE", b), d = Entry.Robotis_openCM70.INSTRUCTION.WRITE, e, f; - e = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_LED_MODULE[0]; - f = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_LED_MODULE[1]; - return Entry.Robotis_carCont.postCallReturn(b, [[d, e + (a - 1) * f, f, c]], Entry.Robotis_openCM70.delay); +Entry.block.robotis_openCM70_aux_led_module = function(b, a) { + var c = a.getField("PORT", a), d = a.getField("LED_MODULE", a), e = Entry.Robotis_openCM70.INSTRUCTION.WRITE, f = 0, g = 0, f = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_LED_MODULE[0], g = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_LED_MODULE[1]; + return Entry.Robotis_carCont.postCallReturn(a, [[e, f + (c - 1) * g, g, d]], Entry.Robotis_openCM70.delay); }; Blockly.Blocks.robotis_openCM70_aux_custom = {init:function() { this.setColour("#00979D"); @@ -4824,12 +4686,9 @@ Blockly.Blocks.robotis_openCM70_aux_custom = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.robotis_openCM70_aux_custom = function(a, b) { - a = b.getField("PORT", b); - var c = b.getNumberValue("VALUE"), d = Entry.Robotis_openCM70.INSTRUCTION.WRITE, e, f; - e = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_CUSTOM[0]; - f = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_CUSTOM[1]; - return Entry.Robotis_carCont.postCallReturn(b, [[d, e + (a - 1) * f, f, c]], Entry.Robotis_openCM70.delay); +Entry.block.robotis_openCM70_aux_custom = function(b, a) { + var c = a.getField("PORT", a), d = a.getNumberValue("VALUE"), e = Entry.Robotis_openCM70.INSTRUCTION.WRITE, f = 0, g = 0, f = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_CUSTOM[0], g = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_CUSTOM[1]; + return Entry.Robotis_carCont.postCallReturn(a, [[e, f + (c - 1) * g, g, d]], Entry.Robotis_openCM70.delay); }; Blockly.Blocks.robotis_openCM70_cm_custom = {init:function() { this.setColour("#00979D"); @@ -4844,12 +4703,9 @@ Blockly.Blocks.robotis_openCM70_cm_custom = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.robotis_openCM70_cm_custom = function(a, b) { - a = Entry.Robotis_openCM70.INSTRUCTION.WRITE; - var c, d; - c = b.getNumberValue("ADDRESS"); - d = b.getNumberValue("VALUE"); - return Entry.Robotis_carCont.postCallReturn(b, [[a, c, 65535 < d ? 4 : 255 < d ? 2 : 1, d]], Entry.Robotis_openCM70.delay); +Entry.block.robotis_openCM70_cm_custom = function(b, a) { + var c = Entry.Robotis_openCM70.INSTRUCTION.WRITE, d = 0, e = 0, d = a.getNumberValue("ADDRESS"), e = a.getNumberValue("VALUE"); + return Entry.Robotis_carCont.postCallReturn(a, [[c, d, 65535 < e ? 4 : 255 < e ? 2 : 1, e]], Entry.Robotis_openCM70.delay); }; Blockly.Blocks.robotis_carCont_sensor_value = {init:function() { this.setColour("#00979D"); @@ -4858,19 +4714,17 @@ Blockly.Blocks.robotis_carCont_sensor_value = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.robotis_carCont_sensor_value = function(a, b) { - a = Entry.Robotis_carCont.INSTRUCTION.READ; - var c = 0, d = 0, e = 0, f = 0; - b = b.getStringField("SENSOR"); - "CM_SPRING_LEFT" == b ? (e = Entry.Robotis_carCont.CONTROL_TABLE.CM_SPRING_LEFT[0], f = Entry.Robotis_carCont.CONTROL_TABLE.CM_SPRING_LEFT[1], c = Entry.Robotis_carCont.CONTROL_TABLE.CM_SPRING_LEFT[2], d = Entry.Robotis_carCont.CONTROL_TABLE.CM_SPRING_LEFT[3]) : "CM_SPRING_RIGHT" == b ? (e = Entry.Robotis_carCont.CONTROL_TABLE.CM_SPRING_RIGHT[0], f = Entry.Robotis_carCont.CONTROL_TABLE.CM_SPRING_RIGHT[1], c = Entry.Robotis_carCont.CONTROL_TABLE.CM_SPRING_RIGHT[2], d = Entry.Robotis_carCont.CONTROL_TABLE.CM_SPRING_RIGHT[3]) : - "CM_SWITCH" == b ? (e = Entry.Robotis_carCont.CONTROL_TABLE.CM_SWITCH[0], f = Entry.Robotis_carCont.CONTROL_TABLE.CM_SWITCH[1], c = Entry.Robotis_carCont.CONTROL_TABLE.CM_SWITCH[0], d = Entry.Robotis_carCont.CONTROL_TABLE.CM_SWITCH[1]) : "CM_SOUND_DETECTED" == b ? (e = Entry.Robotis_carCont.CONTROL_TABLE.CM_SOUND_DETECTED[0], f = Entry.Robotis_carCont.CONTROL_TABLE.CM_SOUND_DETECTED[1], c = Entry.Robotis_carCont.CONTROL_TABLE.CM_SOUND_DETECTED[0], d = Entry.Robotis_carCont.CONTROL_TABLE.CM_SOUND_DETECTED[1]) : - "CM_SOUND_DETECTING" == b ? (e = Entry.Robotis_carCont.CONTROL_TABLE.CM_SOUND_DETECTING[0], f = Entry.Robotis_carCont.CONTROL_TABLE.CM_SOUND_DETECTING[1], c = Entry.Robotis_carCont.CONTROL_TABLE.CM_SOUND_DETECTING[0], d = Entry.Robotis_carCont.CONTROL_TABLE.CM_SOUND_DETECTING[1]) : "CM_IR_LEFT" == b ? (e = Entry.Robotis_carCont.CONTROL_TABLE.CM_IR_LEFT[0], f = Entry.Robotis_carCont.CONTROL_TABLE.CM_IR_LEFT[1], c = Entry.Robotis_carCont.CONTROL_TABLE.CM_IR_LEFT[2], d = Entry.Robotis_carCont.CONTROL_TABLE.CM_IR_LEFT[3]) : - "CM_IR_RIGHT" == b ? (e = Entry.Robotis_carCont.CONTROL_TABLE.CM_IR_RIGHT[0], f = Entry.Robotis_carCont.CONTROL_TABLE.CM_IR_RIGHT[1], c = Entry.Robotis_carCont.CONTROL_TABLE.CM_IR_RIGHT[2], d = Entry.Robotis_carCont.CONTROL_TABLE.CM_IR_RIGHT[3]) : "CM_CALIBRATION_LEFT" == b ? (e = Entry.Robotis_carCont.CONTROL_TABLE.CM_CALIBRATION_LEFT[0], f = Entry.Robotis_carCont.CONTROL_TABLE.CM_CALIBRATION_LEFT[1], c = Entry.Robotis_carCont.CONTROL_TABLE.CM_CALIBRATION_LEFT[0], d = Entry.Robotis_carCont.CONTROL_TABLE.CM_CALIBRATION_LEFT[1]) : - "CM_CALIBRATION_RIGHT" == b ? (e = Entry.Robotis_carCont.CONTROL_TABLE.CM_CALIBRATION_RIGHT[0], f = Entry.Robotis_carCont.CONTROL_TABLE.CM_CALIBRATION_RIGHT[1], c = Entry.Robotis_carCont.CONTROL_TABLE.CM_CALIBRATION_RIGHT[0], d = Entry.Robotis_carCont.CONTROL_TABLE.CM_CALIBRATION_RIGHT[1]) : "CM_BUTTON_STATUS" == b && (e = Entry.Robotis_carCont.CONTROL_TABLE.CM_BUTTON_STATUS[0], f = Entry.Robotis_carCont.CONTROL_TABLE.CM_BUTTON_STATUS[1], c = Entry.Robotis_carCont.CONTROL_TABLE.CM_BUTTON_STATUS[0], - d = Entry.Robotis_carCont.CONTROL_TABLE.CM_BUTTON_STATUS[1]); - Entry.Robotis_carCont.setRobotisData([[a, c, d, 0, f]]); +Entry.block.robotis_carCont_sensor_value = function(b, a) { + var c = Entry.Robotis_carCont.INSTRUCTION.READ, d = 0, e = 0, f = 0, g = 0, h = a.getStringField("SENSOR"); + "CM_SPRING_LEFT" == h ? (f = Entry.Robotis_carCont.CONTROL_TABLE.CM_SPRING_LEFT[0], g = Entry.Robotis_carCont.CONTROL_TABLE.CM_SPRING_LEFT[1], d = Entry.Robotis_carCont.CONTROL_TABLE.CM_SPRING_LEFT[2], e = Entry.Robotis_carCont.CONTROL_TABLE.CM_SPRING_LEFT[3]) : "CM_SPRING_RIGHT" == h ? (f = Entry.Robotis_carCont.CONTROL_TABLE.CM_SPRING_RIGHT[0], g = Entry.Robotis_carCont.CONTROL_TABLE.CM_SPRING_RIGHT[1], d = Entry.Robotis_carCont.CONTROL_TABLE.CM_SPRING_RIGHT[2], e = Entry.Robotis_carCont.CONTROL_TABLE.CM_SPRING_RIGHT[3]) : + "CM_SWITCH" == h ? (f = Entry.Robotis_carCont.CONTROL_TABLE.CM_SWITCH[0], g = Entry.Robotis_carCont.CONTROL_TABLE.CM_SWITCH[1], d = Entry.Robotis_carCont.CONTROL_TABLE.CM_SWITCH[0], e = Entry.Robotis_carCont.CONTROL_TABLE.CM_SWITCH[1]) : "CM_SOUND_DETECTED" == h ? (f = Entry.Robotis_carCont.CONTROL_TABLE.CM_SOUND_DETECTED[0], g = Entry.Robotis_carCont.CONTROL_TABLE.CM_SOUND_DETECTED[1], d = Entry.Robotis_carCont.CONTROL_TABLE.CM_SOUND_DETECTED[0], e = Entry.Robotis_carCont.CONTROL_TABLE.CM_SOUND_DETECTED[1]) : + "CM_SOUND_DETECTING" == h ? (f = Entry.Robotis_carCont.CONTROL_TABLE.CM_SOUND_DETECTING[0], g = Entry.Robotis_carCont.CONTROL_TABLE.CM_SOUND_DETECTING[1], d = Entry.Robotis_carCont.CONTROL_TABLE.CM_SOUND_DETECTING[0], e = Entry.Robotis_carCont.CONTROL_TABLE.CM_SOUND_DETECTING[1]) : "CM_IR_LEFT" == h ? (f = Entry.Robotis_carCont.CONTROL_TABLE.CM_IR_LEFT[0], g = Entry.Robotis_carCont.CONTROL_TABLE.CM_IR_LEFT[1], d = Entry.Robotis_carCont.CONTROL_TABLE.CM_IR_LEFT[2], e = Entry.Robotis_carCont.CONTROL_TABLE.CM_IR_LEFT[3]) : + "CM_IR_RIGHT" == h ? (f = Entry.Robotis_carCont.CONTROL_TABLE.CM_IR_RIGHT[0], g = Entry.Robotis_carCont.CONTROL_TABLE.CM_IR_RIGHT[1], d = Entry.Robotis_carCont.CONTROL_TABLE.CM_IR_RIGHT[2], e = Entry.Robotis_carCont.CONTROL_TABLE.CM_IR_RIGHT[3]) : "CM_CALIBRATION_LEFT" == h ? (f = Entry.Robotis_carCont.CONTROL_TABLE.CM_CALIBRATION_LEFT[0], g = Entry.Robotis_carCont.CONTROL_TABLE.CM_CALIBRATION_LEFT[1], d = Entry.Robotis_carCont.CONTROL_TABLE.CM_CALIBRATION_LEFT[0], e = Entry.Robotis_carCont.CONTROL_TABLE.CM_CALIBRATION_LEFT[1]) : + "CM_CALIBRATION_RIGHT" == h ? (f = Entry.Robotis_carCont.CONTROL_TABLE.CM_CALIBRATION_RIGHT[0], g = Entry.Robotis_carCont.CONTROL_TABLE.CM_CALIBRATION_RIGHT[1], d = Entry.Robotis_carCont.CONTROL_TABLE.CM_CALIBRATION_RIGHT[0], e = Entry.Robotis_carCont.CONTROL_TABLE.CM_CALIBRATION_RIGHT[1]) : "CM_BUTTON_STATUS" == h && (f = Entry.Robotis_carCont.CONTROL_TABLE.CM_BUTTON_STATUS[0], g = Entry.Robotis_carCont.CONTROL_TABLE.CM_BUTTON_STATUS[1], d = Entry.Robotis_carCont.CONTROL_TABLE.CM_BUTTON_STATUS[0], + e = Entry.Robotis_carCont.CONTROL_TABLE.CM_BUTTON_STATUS[1]); + Entry.Robotis_carCont.setRobotisData([[c, d, e, 0, g]]); Entry.Robotis_carCont.update(); - return Entry.hw.portData[e]; + return Entry.hw.portData[f]; }; Blockly.Blocks.robotis_carCont_cm_led = {init:function() { this.setColour("#00979D"); @@ -4879,14 +4733,11 @@ Blockly.Blocks.robotis_carCont_cm_led = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.robotis_carCont_cm_led = function(a, b) { - a = b.getField("VALUE_LEFT", b); - var c = b.getField("VALUE_RIGHT", b), d = Entry.Robotis_carCont.INSTRUCTION.WRITE, e, f, g = 0; - e = Entry.Robotis_carCont.CONTROL_TABLE.CM_LED[0]; - f = Entry.Robotis_carCont.CONTROL_TABLE.CM_LED[1]; - 1 == a && 1 == c ? g = 9 : 1 == a && 0 == c && (g = 8); - 0 == a && 1 == c && (g = 1); - return Entry.Robotis_carCont.postCallReturn(b, [[d, e, f, g]], Entry.Robotis_carCont.delay); +Entry.block.robotis_carCont_cm_led = function(b, a) { + var c = a.getField("VALUE_LEFT", a), d = a.getField("VALUE_RIGHT", a), e = Entry.Robotis_carCont.INSTRUCTION.WRITE, f = 0, g = 0, h = 0, f = Entry.Robotis_carCont.CONTROL_TABLE.CM_LED[0], g = Entry.Robotis_carCont.CONTROL_TABLE.CM_LED[1]; + 1 == c && 1 == d ? h = 9 : 1 == c && 0 == d && (h = 8); + 0 == c && 1 == d && (h = 1); + return Entry.Robotis_carCont.postCallReturn(a, [[e, f, g, h]], Entry.Robotis_carCont.delay); }; Blockly.Blocks.robotis_carCont_cm_sound_detected_clear = {init:function() { this.setColour("#00979D"); @@ -4895,8 +4746,9 @@ Blockly.Blocks.robotis_carCont_cm_sound_detected_clear = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.robotis_carCont_cm_sound_detected_clear = function(a, b) { - return Entry.Robotis_carCont.postCallReturn(b, [[Entry.Robotis_carCont.INSTRUCTION.WRITE, Entry.Robotis_carCont.CONTROL_TABLE.CM_SOUND_DETECTED[0], Entry.Robotis_carCont.CONTROL_TABLE.CM_SOUND_DETECTED[1], 0]], Entry.Robotis_carCont.delay); +Entry.block.robotis_carCont_cm_sound_detected_clear = function(b, a) { + var c = Entry.Robotis_carCont.INSTRUCTION.WRITE, d = 0, e = 0, d = Entry.Robotis_carCont.CONTROL_TABLE.CM_SOUND_DETECTED[0], e = Entry.Robotis_carCont.CONTROL_TABLE.CM_SOUND_DETECTED[1]; + return Entry.Robotis_carCont.postCallReturn(a, [[c, d, e, 0]], Entry.Robotis_carCont.delay); }; Blockly.Blocks.robotis_carCont_aux_motor_speed = {init:function() { this.setColour("#00979D"); @@ -4907,13 +4759,11 @@ Blockly.Blocks.robotis_carCont_aux_motor_speed = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.robotis_carCont_aux_motor_speed = function(a, b) { - var c = b.getField("DIRECTION", b); - a = b.getField("DIRECTION_ANGLE", b); - var d = b.getNumberValue("VALUE"), e = Entry.Robotis_carCont.INSTRUCTION.WRITE, f; - "LEFT" == c ? (c = Entry.Robotis_carCont.CONTROL_TABLE.AUX_MOTOR_SPEED_LEFT[0], f = Entry.Robotis_carCont.CONTROL_TABLE.AUX_MOTOR_SPEED_LEFT[1]) : (c = Entry.Robotis_carCont.CONTROL_TABLE.AUX_MOTOR_SPEED_RIGHT[0], f = Entry.Robotis_carCont.CONTROL_TABLE.AUX_MOTOR_SPEED_RIGHT[1]); - "CW" == a ? (d += 1024, 2047 < d && (d = 2047)) : 1023 < d && (d = 1023); - return Entry.Robotis_carCont.postCallReturn(b, [[e, c, f, d]], Entry.Robotis_carCont.delay); +Entry.block.robotis_carCont_aux_motor_speed = function(b, a) { + var c = a.getField("DIRECTION", a), d = a.getField("DIRECTION_ANGLE", a), e = a.getNumberValue("VALUE"), f = Entry.Robotis_carCont.INSTRUCTION.WRITE, g = 0, h = 0; + "LEFT" == c ? (g = Entry.Robotis_carCont.CONTROL_TABLE.AUX_MOTOR_SPEED_LEFT[0], h = Entry.Robotis_carCont.CONTROL_TABLE.AUX_MOTOR_SPEED_LEFT[1]) : (g = Entry.Robotis_carCont.CONTROL_TABLE.AUX_MOTOR_SPEED_RIGHT[0], h = Entry.Robotis_carCont.CONTROL_TABLE.AUX_MOTOR_SPEED_RIGHT[1]); + "CW" == d ? (e += 1024, 2047 < e && (e = 2047)) : 1023 < e && (e = 1023); + return Entry.Robotis_carCont.postCallReturn(a, [[f, g, h, e]], Entry.Robotis_carCont.delay); }; Blockly.Blocks.robotis_carCont_cm_calibration = {init:function() { this.setColour("#00979D"); @@ -4924,12 +4774,10 @@ Blockly.Blocks.robotis_carCont_cm_calibration = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.robotis_carCont_cm_calibration = function(a, b) { - var c = b.getField("DIRECTION", b); - a = b.getNumberValue("VALUE"); - var d = Entry.Robotis_carCont.INSTRUCTION.WRITE, e; - "LEFT" == c ? (c = Entry.Robotis_carCont.CONTROL_TABLE.CM_CALIBRATION_LEFT[0], e = Entry.Robotis_carCont.CONTROL_TABLE.CM_CALIBRATION_LEFT[1]) : (c = Entry.Robotis_carCont.CONTROL_TABLE.CM_CALIBRATION_RIGHT[0], e = Entry.Robotis_carCont.CONTROL_TABLE.CM_CALIBRATION_RIGHT[1]); - return Entry.Robotis_carCont.postCallReturn(b, [[d, c, e, a]], Entry.Robotis_carCont.delay); +Entry.block.robotis_carCont_cm_calibration = function(b, a) { + var c = a.getField("DIRECTION", a), d = a.getNumberValue("VALUE"), e = Entry.Robotis_carCont.INSTRUCTION.WRITE, f = 0, g = 0; + "LEFT" == c ? (f = Entry.Robotis_carCont.CONTROL_TABLE.CM_CALIBRATION_LEFT[0], g = Entry.Robotis_carCont.CONTROL_TABLE.CM_CALIBRATION_LEFT[1]) : (f = Entry.Robotis_carCont.CONTROL_TABLE.CM_CALIBRATION_RIGHT[0], g = Entry.Robotis_carCont.CONTROL_TABLE.CM_CALIBRATION_RIGHT[1]); + return Entry.Robotis_carCont.postCallReturn(a, [[e, f, g, d]], Entry.Robotis_carCont.delay); }; Blockly.Blocks.when_scene_start = {init:function() { this.setColour("#3BBD70"); @@ -4937,8 +4785,8 @@ Blockly.Blocks.when_scene_start = {init:function() { this.setInputsInline(!0); this.setNextStatement(!0); }}; -Entry.block.when_scene_start = function(a, b) { - return b.callReturn(); +Entry.block.when_scene_start = function(b, a) { + return a.callReturn(); }; Blockly.Blocks.start_scene = {init:function() { this.setColour("#3BBD70"); @@ -4947,10 +4795,10 @@ Blockly.Blocks.start_scene = {init:function() { this.setInputsInline(!0); this.setPreviousStatement(!0); }}; -Entry.block.start_scene = function(a, b) { - a = b.getField("VALUE", b); - if (a = Entry.scene.getSceneById(a)) { - Entry.scene.selectScene(a), Entry.engine.fireEvent("when_scene_start"); +Entry.block.start_scene = function(b, a) { + var c = a.getField("VALUE", a); + if (c = Entry.scene.getSceneById(c)) { + Entry.scene.selectScene(c), Entry.engine.fireEvent("when_scene_start"); } return null; }; @@ -4961,11 +4809,9 @@ Blockly.Blocks.start_neighbor_scene = {init:function() { this.setInputsInline(!0); this.setPreviousStatement(!0); }}; -Entry.block.start_neighbor_scene = function(a, b) { - var c = Entry.scene.selectedScene; - a = Entry.scene.getScenes(); - c = a.indexOf(c); - "next" == b.getField("OPERATOR", b) ? c + 1 < a.length && (b = Entry.scene.getSceneById(a[c + 1].id)) && (Entry.scene.selectScene(b), Entry.engine.fireEvent("when_scene_start")) : 0 < c && (b = Entry.scene.getSceneById(a[c - 1].id)) && (Entry.scene.selectScene(b), Entry.engine.fireEvent("when_scene_start")); +Entry.block.start_neighbor_scene = function(b, a) { + var c = Entry.scene.selectedScene, d = Entry.scene.getScenes(), c = d.indexOf(c); + "next" == a.getField("OPERATOR", a) ? c + 1 < d.length && (d = Entry.scene.getSceneById(d[c + 1].id)) && (Entry.scene.selectScene(d), Entry.engine.fireEvent("when_scene_start")) : 0 < c && (d = Entry.scene.getSceneById(d[c - 1].id)) && (Entry.scene.selectScene(d), Entry.engine.fireEvent("when_scene_start")); return null; }; Blockly.Blocks.sound_something = {init:function() { @@ -4977,10 +4823,10 @@ Blockly.Blocks.sound_something = {init:function() { this.setNextStatement(!0); this.setPreviousStatement(!0); }}; -Entry.block.sound_something = function(a, b) { - var c = b.getField("VALUE", b); - Entry.isExist(c, "id", a.parent.sounds) && createjs.Sound.play(c); - return b.callReturn(); +Entry.block.sound_something = function(b, a) { + var c = a.getField("VALUE", a); + Entry.isExist(c, "id", b.parent.sounds) && createjs.Sound.play(c); + return a.callReturn(); }; Blockly.Blocks.sound_something_second = {init:function() { this.setColour("#A4D01D"); @@ -4993,15 +4839,15 @@ Blockly.Blocks.sound_something_second = {init:function() { this.setNextStatement(!0); this.setPreviousStatement(!0); }}; -Entry.block.sound_something_second = function(a, b) { - var c = b.getField("VALUE", b), d = b.getNumberValue("SECOND", b); - if (Entry.isExist(c, "id", a.parent.sounds)) { +Entry.block.sound_something_second = function(b, a) { + var c = a.getField("VALUE", a), d = a.getNumberValue("SECOND", a); + if (Entry.isExist(c, "id", b.parent.sounds)) { var e = createjs.Sound.play(c); setTimeout(function() { e.stop(); }, 1E3 * d); } - return b.callReturn(); + return a.callReturn(); }; Blockly.Blocks.sound_something_wait = {init:function() { this.setColour("#A4D01D"); @@ -5012,22 +4858,22 @@ Blockly.Blocks.sound_something_wait = {init:function() { this.setNextStatement(!0); this.setPreviousStatement(!0); }}; -Entry.block.sound_something_wait = function(a, b) { - if (b.isPlay) { - if (1 == b.playState) { - return b; +Entry.block.sound_something_wait = function(b, a) { + if (a.isPlay) { + if (1 == a.playState) { + return a; } - delete b.playState; - delete b.isPlay; - return b.callReturn(); + delete a.playState; + delete a.isPlay; + return a.callReturn(); } - b.isPlay = !0; - b.playState = 1; - var c = b.getField("VALUE", b), d = a.parent.getSound(c); - Entry.isExist(c, "id", a.parent.sounds) && (createjs.Sound.play(c), setTimeout(function() { - b.playState = 0; + a.isPlay = !0; + a.playState = 1; + var c = a.getField("VALUE", a), d = b.parent.getSound(c); + Entry.isExist(c, "id", b.parent.sounds) && (createjs.Sound.play(c), setTimeout(function() { + a.playState = 0; }, 1E3 * d.duration)); - return b; + return a; }; Blockly.Blocks.sound_something_second_wait = {init:function() { this.setColour("#A4D01D"); @@ -5040,29 +4886,28 @@ Blockly.Blocks.sound_something_second_wait = {init:function() { this.setNextStatement(!0); this.setPreviousStatement(!0); }}; -Entry.block.sound_something_second_wait = function(a, b) { - if (b.isPlay) { - if (1 == b.playState) { - return b; +Entry.block.sound_something_second_wait = function(b, a) { + if (a.isPlay) { + if (1 == a.playState) { + return a; } - delete b.isPlay; - delete b.playState; - return b.callReturn(); + delete a.isPlay; + delete a.playState; + return a.callReturn(); } - b.isPlay = !0; - b.playState = 1; - var c = b.getField("VALUE", b); - if (Entry.isExist(c, "id", a.parent.sounds)) { - var d = createjs.Sound.play(c); - a = b.getNumberValue("SECOND", b); + a.isPlay = !0; + a.playState = 1; + var c = a.getField("VALUE", a); + if (Entry.isExist(c, "id", b.parent.sounds)) { + var d = createjs.Sound.play(c), c = a.getNumberValue("SECOND", a); setTimeout(function() { d.stop(); - b.playState = 0; - }, 1E3 * a); - d.addEventListener("complete", function(b) { + a.playState = 0; + }, 1E3 * c); + d.addEventListener("complete", function(a) { }); } - return b; + return a; }; Blockly.Blocks.sound_volume_change = {init:function() { this.setColour("#A4D01D"); @@ -5073,13 +4918,12 @@ Blockly.Blocks.sound_volume_change = {init:function() { this.setNextStatement(!0); this.setPreviousStatement(!0); }}; -Entry.block.sound_volume_change = function(a, b) { - a = b.getNumberValue("VALUE", b) / 100; - a += createjs.Sound.getVolume(); - 1 < a && (a = 1); - 0 > a && (a = 0); - createjs.Sound.setVolume(a); - return b.callReturn(); +Entry.block.sound_volume_change = function(b, a) { + var c = a.getNumberValue("VALUE", a) / 100, c = c + createjs.Sound.getVolume(); + 1 < c && (c = 1); + 0 > c && (c = 0); + createjs.Sound.setVolume(c); + return a.callReturn(); }; Blockly.Blocks.sound_volume_set = {init:function() { this.setColour("#A4D01D"); @@ -5090,12 +4934,12 @@ Blockly.Blocks.sound_volume_set = {init:function() { this.setNextStatement(!0); this.setPreviousStatement(!0); }}; -Entry.block.sound_volume_set = function(a, b) { - a = b.getNumberValue("VALUE", b) / 100; - 1 < a && (a = 1); - 0 > a && (a = 0); - createjs.Sound.setVolume(a); - return b.callReturn(); +Entry.block.sound_volume_set = function(b, a) { + var c = a.getNumberValue("VALUE", a) / 100; + 1 < c && (c = 1); + 0 > c && (c = 0); + createjs.Sound.setVolume(c); + return a.callReturn(); }; Blockly.Blocks.sound_silent_all = {init:function() { this.setColour("#A4D01D"); @@ -5104,9 +4948,9 @@ Blockly.Blocks.sound_silent_all = {init:function() { this.setNextStatement(!0); this.setPreviousStatement(!0); }}; -Entry.block.sound_silent_all = function(a, b) { +Entry.block.sound_silent_all = function(b, a) { createjs.Sound.stop(); - return b.callReturn(); + return a.callReturn(); }; Blockly.Blocks.get_sounds = {init:function() { this.setColour("#A4D01D"); @@ -5116,8 +4960,8 @@ Blockly.Blocks.get_sounds = {init:function() { this.setOutput(!0, "String"); this.setInputsInline(!0); }}; -Entry.block.get_sounds = function(a, b) { - return b.getStringField("VALUE"); +Entry.block.get_sounds = function(b, a) { + return a.getStringField("VALUE"); }; Blockly.Blocks.sound_something_with_block = {init:function() { this.setColour("#A4D01D"); @@ -5128,10 +4972,10 @@ Blockly.Blocks.sound_something_with_block = {init:function() { this.setNextStatement(!0); this.setPreviousStatement(!0); }}; -Entry.block.sound_something_with_block = function(a, b) { - var c = b.getStringValue("VALUE", b); - (a = a.parent.getSound(c)) && createjs.Sound.play(a.id); - return b.callReturn(); +Entry.block.sound_something_with_block = function(b, a) { + var c = a.getStringValue("VALUE", a); + (c = b.parent.getSound(c)) && createjs.Sound.play(c.id); + return a.callReturn(); }; Blockly.Blocks.sound_something_second_with_block = {init:function() { this.setColour("#A4D01D"); @@ -5144,10 +4988,10 @@ Blockly.Blocks.sound_something_second_with_block = {init:function() { this.setNextStatement(!0); this.setPreviousStatement(!0); }}; -Entry.block.sound_something_second_with_block = function(a, b) { - var c = b.getStringValue("VALUE", b), d = b.getNumberValue("SECOND", b); - (a = a.parent.getSound(c)) && createjs.Sound.play(a.id, {startTime:0, duration:1E3 * d}); - return b.callReturn(); +Entry.block.sound_something_second_with_block = function(b, a) { + var c = a.getStringValue("VALUE", a), d = a.getNumberValue("SECOND", a); + (c = b.parent.getSound(c)) && createjs.Sound.play(c.id, {startTime:0, duration:1E3 * d}); + return a.callReturn(); }; Blockly.Blocks.sound_something_wait_with_block = {init:function() { this.setColour("#A4D01D"); @@ -5158,24 +5002,24 @@ Blockly.Blocks.sound_something_wait_with_block = {init:function() { this.setNextStatement(!0); this.setPreviousStatement(!0); }}; -Entry.block.sound_something_wait_with_block = function(a, b) { - if (b.isPlay) { - if (1 == b.playState) { - return b; +Entry.block.sound_something_wait_with_block = function(b, a) { + if (a.isPlay) { + if (1 == a.playState) { + return a; } - delete b.playState; - delete b.isPlay; - return b.callReturn(); + delete a.playState; + delete a.isPlay; + return a.callReturn(); } - b.isPlay = !0; - b.playState = 1; - var c = b.getStringValue("VALUE", b); - if (a = a.parent.getSound(c)) { - createjs.Sound.play(a.id), setTimeout(function() { - b.playState = 0; - }, 1E3 * a.duration); + a.isPlay = !0; + a.playState = 1; + var c = a.getStringValue("VALUE", a); + if (c = b.parent.getSound(c)) { + createjs.Sound.play(c.id), setTimeout(function() { + a.playState = 0; + }, 1E3 * c.duration); } - return b; + return a; }; Blockly.Blocks.sound_something_second_wait_with_block = {init:function() { this.setColour("#A4D01D"); @@ -5188,29 +5032,28 @@ Blockly.Blocks.sound_something_second_wait_with_block = {init:function() { this.setNextStatement(!0); this.setPreviousStatement(!0); }}; -Entry.block.sound_something_second_wait_with_block = function(a, b) { - if (b.isPlay) { - if (1 == b.playState) { - return b; +Entry.block.sound_something_second_wait_with_block = function(b, a) { + if (a.isPlay) { + if (1 == a.playState) { + return a; } - delete b.isPlay; - delete b.playState; - return b.callReturn(); + delete a.isPlay; + delete a.playState; + return a.callReturn(); } - b.isPlay = !0; - b.playState = 1; - var c = b.getStringValue("VALUE", b); - if (a = a.parent.getSound(c)) { - var d = createjs.Sound.play(a.id); - a = b.getNumberValue("SECOND", b); + a.isPlay = !0; + a.playState = 1; + var c = a.getStringValue("VALUE", a); + if (c = b.parent.getSound(c)) { + var d = createjs.Sound.play(c.id), c = a.getNumberValue("SECOND", a); setTimeout(function() { d.stop(); - b.playState = 0; - }, 1E3 * a); - d.addEventListener("complete", function(b) { + a.playState = 0; + }, 1E3 * c); + d.addEventListener("complete", function(a) { }); } - return b; + return a; }; Blockly.Blocks.sound_from_to = {init:function() { this.setColour("#A4D01D"); @@ -5225,13 +5068,13 @@ Blockly.Blocks.sound_from_to = {init:function() { this.setNextStatement(!0); this.setPreviousStatement(!0); }}; -Entry.block.sound_from_to = function(a, b) { - var c = b.getStringValue("VALUE", b); - if (a = a.parent.getSound(c)) { - var c = 1E3 * b.getNumberValue("START", b), d = 1E3 * b.getNumberValue("END", b); - createjs.Sound.play(a.id, {startTime:Math.min(c, d), duration:Math.max(c, d) - Math.min(c, d)}); +Entry.block.sound_from_to = function(b, a) { + var c = a.getStringValue("VALUE", a); + if (c = b.parent.getSound(c)) { + var d = 1E3 * a.getNumberValue("START", a), e = 1E3 * a.getNumberValue("END", a); + createjs.Sound.play(c.id, {startTime:Math.min(d, e), duration:Math.max(d, e) - Math.min(d, e)}); } - return b.callReturn(); + return a.callReturn(); }; Blockly.Blocks.sound_from_to_and_wait = {init:function() { this.setColour("#A4D01D"); @@ -5246,26 +5089,26 @@ Blockly.Blocks.sound_from_to_and_wait = {init:function() { this.setNextStatement(!0); this.setPreviousStatement(!0); }}; -Entry.block.sound_from_to_and_wait = function(a, b) { - if (b.isPlay) { - if (1 == b.playState) { - return b; +Entry.block.sound_from_to_and_wait = function(b, a) { + if (a.isPlay) { + if (1 == a.playState) { + return a; } - delete b.isPlay; - delete b.playState; - return b.callReturn(); + delete a.isPlay; + delete a.playState; + return a.callReturn(); } - b.isPlay = !0; - b.playState = 1; - var c = b.getStringValue("VALUE", b); - if (a = a.parent.getSound(c)) { - var d = 1E3 * b.getNumberValue("START", b), e = 1E3 * b.getNumberValue("END", b), c = Math.min(d, e), d = Math.max(d, e) - c; - createjs.Sound.play(a.id, {startTime:c, duration:d}); + a.isPlay = !0; + a.playState = 1; + var c = a.getStringValue("VALUE", a); + if (c = b.parent.getSound(c)) { + var d = 1E3 * a.getNumberValue("START", a), e = 1E3 * a.getNumberValue("END", a), f = Math.min(d, e), d = Math.max(d, e) - f; + createjs.Sound.play(c.id, {startTime:f, duration:d}); setTimeout(function() { - b.playState = 0; + a.playState = 0; }, d); } - return b; + return a; }; Blockly.Blocks.when_run_button_click = {init:function() { this.setColour("#3BBD70"); @@ -5273,8 +5116,8 @@ Blockly.Blocks.when_run_button_click = {init:function() { this.setInputsInline(!0); this.setNextStatement(!0); }}; -Entry.block.when_run_button_click = function(a, b) { - return b.callReturn(); +Entry.block.when_run_button_click = function(b, a) { + return a.callReturn(); }; Blockly.Blocks.press_some_key = {init:function() { this.setColour("#3BBD70"); @@ -5283,8 +5126,8 @@ Blockly.Blocks.press_some_key = {init:function() { this.setInputsInline(!0); this.setNextStatement(!0); }}; -Entry.block.press_some_key = function(a, b) { - return b.callReturn(); +Entry.block.press_some_key = function(b, a) { + return a.callReturn(); }; Blockly.Blocks.when_some_key_pressed = {init:function() { this.setColour("#3BBD70"); @@ -5292,8 +5135,8 @@ Blockly.Blocks.when_some_key_pressed = {init:function() { this.setInputsInline(!0); this.setNextStatement(!0); }}; -Entry.block.when_some_key_pressed = function(a, b) { - return b.callReturn(); +Entry.block.when_some_key_pressed = function(b, a) { + return a.callReturn(); }; Blockly.Blocks.mouse_clicked = {init:function() { this.setColour("#3BBD70"); @@ -5301,8 +5144,8 @@ Blockly.Blocks.mouse_clicked = {init:function() { this.setInputsInline(!0); this.setNextStatement(!0); }}; -Entry.block.mouse_clicked = function(a, b) { - return b.callReturn(); +Entry.block.mouse_clicked = function(b, a) { + return a.callReturn(); }; Blockly.Blocks.mouse_click_cancled = {init:function() { this.setColour("#3BBD70"); @@ -5310,8 +5153,8 @@ Blockly.Blocks.mouse_click_cancled = {init:function() { this.setInputsInline(!0); this.setNextStatement(!0); }}; -Entry.block.mouse_click_cancled = function(a, b) { - return b.callReturn(); +Entry.block.mouse_click_cancled = function(b, a) { + return a.callReturn(); }; Blockly.Blocks.when_object_click = {init:function() { this.setColour("#3BBD70"); @@ -5319,8 +5162,8 @@ Blockly.Blocks.when_object_click = {init:function() { this.setInputsInline(!0); this.setNextStatement(!0); }}; -Entry.block.when_object_click = function(a, b) { - return b.callReturn(); +Entry.block.when_object_click = function(b, a) { + return a.callReturn(); }; Blockly.Blocks.when_object_click_canceled = {init:function() { this.setColour("#3BBD70"); @@ -5328,8 +5171,8 @@ Blockly.Blocks.when_object_click_canceled = {init:function() { this.setInputsInline(!0); this.setNextStatement(!0); }}; -Entry.block.when_object_click_canceled = function(a, b) { - return b.callReturn(); +Entry.block.when_object_click_canceled = function(b, a) { + return a.callReturn(); }; Blockly.Blocks.when_some_key_click = {init:function() { this.setColour("#3BBD70"); @@ -5337,23 +5180,23 @@ Blockly.Blocks.when_some_key_click = {init:function() { this.setInputsInline(!0); this.setNextStatement(!0); }}; -Entry.block.when_some_key_click = function(a, b) { - return b.callReturn(); +Entry.block.when_some_key_click = function(b, a) { + return a.callReturn(); }; Blockly.Blocks.when_message_cast = {init:function() { this.setColour("#3BBD70"); this.appendDummyInput().appendField(new Blockly.FieldIcon(Entry.mediaFilePath + "block_icon/start_icon_signal.png", "*", "start")).appendField(Lang.Blocks.START_when_message_cast_1).appendField(new Blockly.FieldDropdownDynamic("messages"), "VALUE").appendField(Lang.Blocks.START_when_message_cast_2); this.setInputsInline(!0); this.setNextStatement(!0); -}, whenAdd:function(a) { - var b = Entry.variableContainer; - b && b.addRef("_messageRefs", a); -}, whenRemove:function(a) { - var b = Entry.variableContainer; - b && b.removeRef("_messageRefs", a); +}, whenAdd:function(b) { + var a = Entry.variableContainer; + a && a.addRef("_messageRefs", b); +}, whenRemove:function(b) { + var a = Entry.variableContainer; + a && a.removeRef("_messageRefs", b); }}; -Entry.block.when_message_cast = function(a, b) { - return b.callReturn(); +Entry.block.when_message_cast = function(b, a) { + return a.callReturn(); }; Blockly.Blocks.message_cast = {init:function() { this.setColour("#3BBD70"); @@ -5362,21 +5205,20 @@ Blockly.Blocks.message_cast = {init:function() { this.setInputsInline(!0); this.setNextStatement(!0); this.setPreviousStatement(!0); -}, whenAdd:function(a) { - var b = Entry.variableContainer; - b && b.addRef("_messageRefs", a); -}, whenRemove:function(a) { - var b = Entry.variableContainer; - b && b.removeRef("_messageRefs", a); -}}; -Entry.block.message_cast = function(a, b) { - a = b.getField("VALUE", b); - var c = Entry.isExist(a, "id", Entry.variableContainer.messages_); - if ("null" == a || !c) { +}, whenAdd:function(b) { + var a = Entry.variableContainer; + a && a.addRef("_messageRefs", b); +}, whenRemove:function(b) { + var a = Entry.variableContainer; + a && a.removeRef("_messageRefs", b); +}}; +Entry.block.message_cast = function(b, a) { + var c = a.getField("VALUE", a), d = Entry.isExist(c, "id", Entry.variableContainer.messages_); + if ("null" == c || !d) { throw Error("value can not be null or undefined"); } - Entry.container.mapEntityIncludeCloneOnScene(Entry.engine.raiseKeyEvent, ["when_message_cast", a]); - return b.callReturn(); + Entry.container.mapEntityIncludeCloneOnScene(Entry.engine.raiseKeyEvent, ["when_message_cast", c]); + return a.callReturn(); }; Blockly.Blocks.message_cast_wait = {init:function() { this.setColour("#3BBD70"); @@ -5384,33 +5226,32 @@ Blockly.Blocks.message_cast_wait = {init:function() { this.setInputsInline(!0); this.setNextStatement(!0); this.setPreviousStatement(!0); -}, whenAdd:function(a) { - var b = Entry.variableContainer; - b && b.addRef("_messageRefs", a); -}, whenRemove:function(a) { - var b = Entry.variableContainer; - b && b.removeRef("_messageRefs", a); -}}; -Entry.block.message_cast_wait = function(a, b) { - if (b.runningScript) { - a = b.runningScript; - for (var c = a.length, d = 0;d < c;d++) { - var e = a.shift(); - e && !e.isEnd() && a.push(e); - } - return a.length ? b : b.callReturn(); - } - a = b.getField("VALUE", b); - e = Entry.isExist(a, "id", Entry.variableContainer.messages_); - if ("null" == a || !e) { +}, whenAdd:function(b) { + var a = Entry.variableContainer; + a && a.addRef("_messageRefs", b); +}, whenRemove:function(b) { + var a = Entry.variableContainer; + a && a.removeRef("_messageRefs", b); +}}; +Entry.block.message_cast_wait = function(b, a) { + if (a.runningScript) { + for (var c = a.runningScript, d = c.length, e = 0;e < d;e++) { + var f = c.shift(); + f && !f.isEnd() && c.push(f); + } + return c.length ? a : a.callReturn(); + } + c = a.getField("VALUE", a); + f = Entry.isExist(c, "id", Entry.variableContainer.messages_); + if ("null" == c || !f) { throw Error("value can not be null or undefined"); } - c = Entry.container.mapEntityIncludeCloneOnScene(Entry.engine.raiseKeyEvent, ["when_message_cast", a]); - for (a = [];c.length;) { - (e = c.shift()) && (a = a.concat(e)); + d = Entry.container.mapEntityIncludeCloneOnScene(Entry.engine.raiseKeyEvent, ["when_message_cast", c]); + for (c = [];d.length;) { + (f = d.shift()) && (c = c.concat(f)); } - b.runningScript = a; - return b; + a.runningScript = c; + return a; }; var colour = "#FFCA36"; Blockly.Blocks.text = {init:function() { @@ -5419,8 +5260,8 @@ Blockly.Blocks.text = {init:function() { this.setOutput(!0, "String"); this.setInputsInline(!0); }}; -Entry.block.text = function(a, b) { - return b.getField("NAME", b); +Entry.block.text = function(b, a) { + return a.getField("NAME", a); }; Blockly.Blocks.text_write = {init:function() { this.setColour(colour); @@ -5431,10 +5272,10 @@ Blockly.Blocks.text_write = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.text_write = function(a, b) { - var c = b.getStringValue("VALUE", b), c = Entry.convertToRoundedDecimals(c, 3); - a.setText(c); - return b.callReturn(); +Entry.block.text_write = function(b, a) { + var c = a.getStringValue("VALUE", a), c = Entry.convertToRoundedDecimals(c, 3); + b.setText(c); + return a.callReturn(); }; Blockly.Blocks.text_append = {init:function() { this.setColour(colour); @@ -5445,10 +5286,10 @@ Blockly.Blocks.text_append = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.text_append = function(a, b) { - var c = b.getStringValue("VALUE", b); - a.setText(Entry.convertToRoundedDecimals(a.getText(), 3) + Entry.convertToRoundedDecimals(c, 3)); - return b.callReturn(); +Entry.block.text_append = function(b, a) { + var c = a.getStringValue("VALUE", a); + b.setText(Entry.convertToRoundedDecimals(b.getText(), 3) + Entry.convertToRoundedDecimals(c, 3)); + return a.callReturn(); }; Blockly.Blocks.text_prepend = {init:function() { this.setColour(colour); @@ -5459,10 +5300,10 @@ Blockly.Blocks.text_prepend = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.text_prepend = function(a, b) { - var c = b.getStringValue("VALUE", b); - a.setText(Entry.convertToRoundedDecimals(c, 3) + Entry.convertToRoundedDecimals(a.getText(), 3)); - return b.callReturn(); +Entry.block.text_prepend = function(b, a) { + var c = a.getStringValue("VALUE", a); + b.setText(Entry.convertToRoundedDecimals(c, 3) + Entry.convertToRoundedDecimals(b.getText(), 3)); + return a.callReturn(); }; Blockly.Blocks.text_flush = {init:function() { this.setColour(colour); @@ -5471,9 +5312,9 @@ Blockly.Blocks.text_flush = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.text_flush = function(a, b) { - a.setText(""); - return b.callReturn(); +Entry.block.text_flush = function(b, a) { + b.setText(""); + return a.callReturn(); }; Entry.block.variableAddButton = {skeleton:"basic_button", color:"#eee", template:"%1", params:[{type:"Text", text:"\ubcc0\uc218 \ucd94\uac00", color:"#333", align:"center"}], func:function() { }, events:{mousedown:[function() { @@ -5493,22 +5334,22 @@ Blockly.Blocks.change_variable = {init:function() { this.setInputsInline(!0); this.setPreviousStatement(!0); this.setNextStatement(!0); -}, whenAdd:function(a) { - var b = Entry.variableContainer; - b && b.addRef("_variableRefs", a); -}, whenRemove:function(a) { - var b = Entry.variableContainer; - b && b.removeRef("_variableRefs", a); -}}; -Entry.block.change_variable = function(a, b) { - var c = b.getField("VARIABLE", b), d = b.getNumberValue("VALUE", b), d = Entry.parseNumber(d); +}, whenAdd:function(b) { + var a = Entry.variableContainer; + a && a.addRef("_variableRefs", b); +}, whenRemove:function(b) { + var a = Entry.variableContainer; + a && a.removeRef("_variableRefs", b); +}}; +Entry.block.change_variable = function(b, a) { + var c = a.getField("VARIABLE", a), d = a.getNumberValue("VALUE", a), e = 0, d = Entry.parseNumber(d); if (0 == d && "boolean" == typeof d) { throw Error("Type is not correct"); } - c = Entry.variableContainer.getVariable(c, a); - a = Entry.getMaxFloatPoint([d, c.getValue()]); - c.setValue((d + c.getValue()).toFixed(a)); - return b.callReturn(); + c = Entry.variableContainer.getVariable(c, b); + e = Entry.getMaxFloatPoint([d, c.getValue()]); + c.setValue((d + c.getValue()).toFixed(e)); + return a.callReturn(); }; Blockly.Blocks.set_variable = {init:function() { this.setColour("#E457DC"); @@ -5520,17 +5361,17 @@ Blockly.Blocks.set_variable = {init:function() { this.setInputsInline(!0); this.setPreviousStatement(!0); this.setNextStatement(!0); -}, whenAdd:function(a) { - var b = Entry.variableContainer; - b && b.addRef("_variableRefs", a); -}, whenRemove:function(a) { - var b = Entry.variableContainer; - b && b.removeRef("_variableRefs", a); -}}; -Entry.block.set_variable = function(a, b) { - var c = b.getField("VARIABLE", b), d = b.getValue("VALUE", b); - Entry.variableContainer.getVariable(c, a).setValue(d); - return b.callReturn(); +}, whenAdd:function(b) { + var a = Entry.variableContainer; + a && a.addRef("_variableRefs", b); +}, whenRemove:function(b) { + var a = Entry.variableContainer; + a && a.removeRef("_variableRefs", b); +}}; +Entry.block.set_variable = function(b, a) { + var c = a.getField("VARIABLE", a), d = a.getValue("VALUE", a); + Entry.variableContainer.getVariable(c, b).setValue(d); + return a.callReturn(); }; Blockly.Blocks.show_variable = {init:function() { this.setColour("#E457DC"); @@ -5539,19 +5380,18 @@ Blockly.Blocks.show_variable = {init:function() { this.setInputsInline(!0); this.setPreviousStatement(!0); this.setNextStatement(!0); -}, whenAdd:function(a) { - var b = Entry.variableContainer; - b && b.addRef("_variableRefs", a); -}, whenRemove:function(a) { - var b = Entry.variableContainer; - b && b.removeRef("_variableRefs", a); -}}; -Entry.block.show_variable = function(a, b) { - var c = b.getField("VARIABLE", b); - a = Entry.variableContainer.getVariable(c, a); - a.setVisible(!0); - a.updateView(); - return b.callReturn(); +}, whenAdd:function(b) { + var a = Entry.variableContainer; + a && a.addRef("_variableRefs", b); +}, whenRemove:function(b) { + var a = Entry.variableContainer; + a && a.removeRef("_variableRefs", b); +}}; +Entry.block.show_variable = function(b, a) { + var c = a.getField("VARIABLE", a), c = Entry.variableContainer.getVariable(c, b); + c.setVisible(!0); + c.updateView(); + return a.callReturn(); }; Blockly.Blocks.hide_variable = {init:function() { this.setColour("#E457DC"); @@ -5560,17 +5400,17 @@ Blockly.Blocks.hide_variable = {init:function() { this.setInputsInline(!0); this.setPreviousStatement(!0); this.setNextStatement(!0); -}, whenAdd:function(a) { - var b = Entry.variableContainer; - b && b.addRef("_variableRefs", a); -}, whenRemove:function(a) { - var b = Entry.variableContainer; - b && b.removeRef("_variableRefs", a); -}}; -Entry.block.hide_variable = function(a, b) { - var c = b.getField("VARIABLE", b); - Entry.variableContainer.getVariable(c, a).setVisible(!1); - return b.callReturn(); +}, whenAdd:function(b) { + var a = Entry.variableContainer; + a && a.addRef("_variableRefs", b); +}, whenRemove:function(b) { + var a = Entry.variableContainer; + a && a.removeRef("_variableRefs", b); +}}; +Entry.block.hide_variable = function(b, a) { + var c = a.getField("VARIABLE", a); + Entry.variableContainer.getVariable(c, b).setVisible(!1); + return a.callReturn(); }; Blockly.Blocks.get_y = {init:function() { this.setColour(230); @@ -5583,16 +5423,16 @@ Blockly.Blocks.get_variable = {init:function() { this.appendDummyInput().appendField(new Blockly.FieldDropdownDynamic("variables"), "VARIABLE").appendField(Lang.Blocks.VARIABLE_get_variable_2); this.setOutput(!0, "Number"); this.setInputsInline(!0); -}, whenAdd:function(a) { - var b = Entry.variableContainer; - b && b.addRef("_variableRefs", a); -}, whenRemove:function(a) { - var b = Entry.variableContainer; - b && b.removeRef("_variableRefs", a); +}, whenAdd:function(b) { + var a = Entry.variableContainer; + a && a.addRef("_variableRefs", b); +}, whenRemove:function(b) { + var a = Entry.variableContainer; + a && a.removeRef("_variableRefs", b); }}; -Entry.block.get_variable = function(a, b) { - b = b.getField("VARIABLE", b); - return Entry.variableContainer.getVariable(b, a).getValue(); +Entry.block.get_variable = function(b, a) { + var c = a.getField("VARIABLE", a); + return Entry.variableContainer.getVariable(c, b).getValue(); }; Blockly.Blocks.ask_and_wait = {init:function() { this.setColour("#E457DC"); @@ -5604,30 +5444,30 @@ Blockly.Blocks.ask_and_wait = {init:function() { this.setNextStatement(!0); }, whenAdd:function() { Entry.container && Entry.container.showProjectAnswer(); -}, whenRemove:function(a) { - Entry.container && Entry.container.hideProjectAnswer(a); +}, whenRemove:function(b) { + Entry.container && Entry.container.hideProjectAnswer(b); }}; -Entry.block.ask_and_wait = function(a, b) { - var c = Entry.container.inputValue, d = Entry.stage.inputField, e = b.getValue("VALUE", b); +Entry.block.ask_and_wait = function(b, a) { + var c = Entry.container.inputValue, d = Entry.stage.inputField, e = a.getValue("VALUE", a); if (!e) { throw Error("message can not be empty"); } - if (c.sprite == a && d && !d._isHidden) { - return b; + if (c.sprite == b && d && !d._isHidden) { + return a; } - if (c.sprite != a && b.isInit) { - return a.dialog && a.dialog.remove(), delete b.isInit, b.callReturn(); + if (c.sprite != b && a.isInit) { + return b.dialog && b.dialog.remove(), delete a.isInit, a.callReturn(); } - if (c.complete && c.sprite == a && d._isHidden && b.isInit) { - return a.dialog && a.dialog.remove(), delete c.complete, delete b.isInit, b.callReturn(); + if (c.complete && c.sprite == b && d._isHidden && a.isInit) { + return b.dialog && b.dialog.remove(), delete c.complete, delete a.isInit, a.callReturn(); } e = Entry.convertToRoundedDecimals(e, 3); - new Entry.Dialog(a, e, "speak"); + new Entry.Dialog(b, e, "speak"); Entry.stage.showInputField(); - c.script = b; - c.sprite = a; - b.isInit = !0; - return b; + c.script = a; + c.sprite = b; + a.isInit = !0; + return a; }; Blockly.Blocks.get_canvas_input_value = {init:function() { this.setColour("#E457DC"); @@ -5637,10 +5477,10 @@ Blockly.Blocks.get_canvas_input_value = {init:function() { this.setInputsInline(!0); }, whenAdd:function() { Entry.container && Entry.container.showProjectAnswer(); -}, whenRemove:function(a) { - Entry.container && Entry.container.hideProjectAnswer(a); +}, whenRemove:function(b) { + Entry.container && Entry.container.hideProjectAnswer(b); }}; -Entry.block.get_canvas_input_value = function(a, b) { +Entry.block.get_canvas_input_value = function(b, a) { return Entry.container.getInputValue(); }; Blockly.Blocks.add_value_to_list = {init:function() { @@ -5653,20 +5493,19 @@ Blockly.Blocks.add_value_to_list = {init:function() { this.setInputsInline(!0); this.setPreviousStatement(!0); this.setNextStatement(!0); -}, whenAdd:function(a) { - var b = Entry.variableContainer; - b && b.addRef("_variableRefs", a); -}, whenRemove:function(a) { - var b = Entry.variableContainer; - b && b.removeRef("_variableRefs", a); -}}; -Entry.block.add_value_to_list = function(a, b) { - var c = b.getField("LIST", b), d = b.getValue("VALUE", b); - a = Entry.variableContainer.getList(c, a); - a.array_ || (a.array_ = []); - a.array_.push({data:d}); - a.updateView(); - return b.callReturn(); +}, whenAdd:function(b) { + var a = Entry.variableContainer; + a && a.addRef("_variableRefs", b); +}, whenRemove:function(b) { + var a = Entry.variableContainer; + a && a.removeRef("_variableRefs", b); +}}; +Entry.block.add_value_to_list = function(b, a) { + var c = a.getField("LIST", a), d = a.getValue("VALUE", a), c = Entry.variableContainer.getList(c, b); + c.array_ || (c.array_ = []); + c.array_.push({data:d}); + c.updateView(); + return a.callReturn(); }; Blockly.Blocks.remove_value_from_list = {init:function() { this.setColour("#E457DC"); @@ -5679,15 +5518,14 @@ Blockly.Blocks.remove_value_from_list = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.remove_value_from_list = function(a, b) { - var c = b.getField("LIST", b), d = b.getValue("VALUE", b); - a = Entry.variableContainer.getList(c, a); - if (!a.array_ || isNaN(d) || d > a.array_.length) { +Entry.block.remove_value_from_list = function(b, a) { + var c = a.getField("LIST", a), d = a.getValue("VALUE", a), c = Entry.variableContainer.getList(c, b); + if (!c.array_ || isNaN(d) || d > c.array_.length) { throw Error("can not remove value from array"); } - a.array_.splice(d - 1, 1); - a.updateView(); - return b.callReturn(); + c.array_.splice(d - 1, 1); + c.updateView(); + return a.callReturn(); }; Blockly.Blocks.insert_value_to_list = {init:function() { this.setColour("#E457DC"); @@ -5702,15 +5540,14 @@ Blockly.Blocks.insert_value_to_list = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.insert_value_to_list = function(a, b) { - var c = b.getField("LIST", b), d = b.getValue("DATA", b), e = b.getValue("INDEX", b); - a = Entry.variableContainer.getList(c, a); - if (!a.array_ || isNaN(e) || 0 == e || e > a.array_.length + 1) { +Entry.block.insert_value_to_list = function(b, a) { + var c = a.getField("LIST", a), d = a.getValue("DATA", a), e = a.getValue("INDEX", a), c = Entry.variableContainer.getList(c, b); + if (!c.array_ || isNaN(e) || 0 == e || e > c.array_.length + 1) { throw Error("can not insert value to array"); } - a.array_.splice(e - 1, 0, {data:d}); - a.updateView(); - return b.callReturn(); + c.array_.splice(e - 1, 0, {data:d}); + c.updateView(); + return a.callReturn(); }; Blockly.Blocks.change_value_list_index = {init:function() { this.setColour("#E457DC"); @@ -5725,15 +5562,14 @@ Blockly.Blocks.change_value_list_index = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.change_value_list_index = function(a, b) { - var c = b.getField("LIST", b), d = b.getValue("DATA", b), e = b.getValue("INDEX", b); - a = Entry.variableContainer.getList(c, a); - if (!a.array_ || isNaN(e) || e > a.array_.length) { +Entry.block.change_value_list_index = function(b, a) { + var c = a.getField("LIST", a), d = a.getValue("DATA", a), e = a.getValue("INDEX", a), c = Entry.variableContainer.getList(c, b); + if (!c.array_ || isNaN(e) || e > c.array_.length) { throw Error("can not insert value to array"); } - a.array_[e - 1].data = d; - a.updateView(); - return b.callReturn(); + c.array_[e - 1].data = d; + c.updateView(); + return a.callReturn(); }; Blockly.Blocks.value_of_index_from_list = {init:function() { this.setColour("#E457DC"); @@ -5745,15 +5581,12 @@ Blockly.Blocks.value_of_index_from_list = {init:function() { this.setOutput(!0, "String"); this.setInputsInline(!0); }}; -Entry.block.value_of_index_from_list = function(a, b) { - var c = b.getField("LIST", b); - b = b.getValue("INDEX", b); - a = Entry.variableContainer.getList(c, a); - b = Entry.getListRealIndex(b, a); - if (!a.array_ || isNaN(b) || b > a.array_.length) { +Entry.block.value_of_index_from_list = function(b, a) { + var c = a.getField("LIST", a), d = a.getValue("INDEX", a), c = Entry.variableContainer.getList(c, b), d = Entry.getListRealIndex(d, c); + if (!c.array_ || isNaN(d) || d > c.array_.length) { throw Error("can not insert value to array"); } - return a.array_[b - 1].data; + return c.array_[d - 1].data; }; Blockly.Blocks.length_of_list = {init:function() { this.setColour("#E457DC"); @@ -5763,9 +5596,9 @@ Blockly.Blocks.length_of_list = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.length_of_list = function(a, b) { - a = b.getField("LIST", b); - return Entry.variableContainer.getList(a).array_.length; +Entry.block.length_of_list = function(b, a) { + var c = a.getField("LIST", a); + return Entry.variableContainer.getList(c).array_.length; }; Blockly.Blocks.show_list = {init:function() { this.setColour("#E457DC"); @@ -5775,10 +5608,10 @@ Blockly.Blocks.show_list = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.show_list = function(a, b) { - a = b.getField("LIST", b); - Entry.variableContainer.getList(a).setVisible(!0); - return b.callReturn(); +Entry.block.show_list = function(b, a) { + var c = a.getField("LIST", a); + Entry.variableContainer.getList(c).setVisible(!0); + return a.callReturn(); }; Blockly.Blocks.hide_list = {init:function() { this.setColour("#E457DC"); @@ -5788,10 +5621,10 @@ Blockly.Blocks.hide_list = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.hide_list = function(a, b) { - a = b.getField("LIST", b); - Entry.variableContainer.getList(a).setVisible(!1); - return b.callReturn(); +Entry.block.hide_list = function(b, a) { + var c = a.getField("LIST", a); + Entry.variableContainer.getList(c).setVisible(!1); + return a.callReturn(); }; Blockly.Blocks.options_for_list = {init:function() { this.setColour("#E457DC"); @@ -5801,8 +5634,8 @@ Blockly.Blocks.options_for_list = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.options_for_list = function(a, b) { - return b.getField("OPERATOR", b); +Entry.block.options_for_list = function(b, a) { + return a.getField("OPERATOR", a); }; Blockly.Blocks.set_visible_answer = {init:function() { this.setColour("#E457DC"); @@ -5814,12 +5647,12 @@ Blockly.Blocks.set_visible_answer = {init:function() { this.setNextStatement(!0); }, whenAdd:function() { Entry.container && Entry.container.showProjectAnswer(); -}, whenRemove:function(a) { - Entry.container && Entry.container.hideProjectAnswer(a); +}, whenRemove:function(b) { + Entry.container && Entry.container.hideProjectAnswer(b); }}; -Entry.block.set_visible_answer = function(a, b) { - "HIDE" == b.getField("BOOL", b) ? Entry.container.inputValue.setVisible(!1) : Entry.container.inputValue.setVisible(!0); - return b.callReturn(); +Entry.block.set_visible_answer = function(b, a) { + "HIDE" == a.getField("BOOL", a) ? Entry.container.inputValue.setVisible(!1) : Entry.container.inputValue.setVisible(!0); + return a.callReturn(); }; Blockly.Blocks.is_included_in_list = {init:function() { this.setColour("#E457DC"); @@ -5831,37 +5664,34 @@ Blockly.Blocks.is_included_in_list = {init:function() { this.setOutput(!0, "Boolean"); this.setInputsInline(!0); }}; -Entry.block.is_included_in_list = function(a, b) { - a = b.getField("LIST", b); - b = b.getStringValue("DATA", b); - a = Entry.variableContainer.getList(a); - if (!a) { +Entry.block.is_included_in_list = function(b, a) { + var c = a.getField("LIST", a), d = a.getStringValue("DATA", a), c = Entry.variableContainer.getList(c); + if (!c) { return !1; } - a = a.array_; - for (var c = 0, d = a.length;c < d;c++) { - if (a[c].data.toString() == b.toString()) { + for (var c = c.array_, e = 0, f = c.length;e < f;e++) { + if (c[e].data.toString() == d.toString()) { return !0; } } return !1; }; Entry.Xbot = {PORT_MAP:{rightWheel:0, leftWheel:0, head:90, armR:90, armL:90, analogD5:127, analogD6:127, D4:0, D7:0, D12:0, D13:0, ledR:0, ledG:0, ledB:0, lcdNum:0, lcdTxt:" ", note:262, duration:0}, setZero:function() { - var a = Entry.Xbot.PORT_MAP, b = Entry.hw.sendQueue, c; - for (c in a) { - b[c] = a[c]; + var b = Entry.Xbot.PORT_MAP, a = Entry.hw.sendQueue, c; + for (c in b) { + a[c] = b[c]; } Entry.hw.update(); Entry.Xbot.removeAllTimeouts(); -}, timeouts:[], removeTimeout:function(a) { - clearTimeout(a); - var b = this.timeouts; - a = b.indexOf(a); - 0 <= a && b.splice(a, 1); +}, timeouts:[], removeTimeout:function(b) { + clearTimeout(b); + var a = this.timeouts; + b = a.indexOf(b); + 0 <= b && a.splice(b, 1); }, removeAllTimeouts:function() { - var a = this.timeouts, b; - for (b in a) { - clearTimeout(a[b]); + var b = this.timeouts, a; + for (a in b) { + clearTimeout(b[a]); } this.timeouts = []; }, name:"xbot_epor_edge"}; @@ -5871,10 +5701,9 @@ Blockly.Blocks.xbot_digitalInput = {init:function() { this.setInputsInline(!0); this.setOutput(!0, "Boolean"); }}; -Entry.block.xbot_digitalInput = function(a, b) { - a = Entry.hw.portData; - b = b.getField("DEVICE"); - return a[b]; +Entry.block.xbot_digitalInput = function(b, a) { + var c = Entry.hw.portData, d = a.getField("DEVICE"); + return c[d]; }; Blockly.Blocks.xbot_analogValue = {init:function() { this.setColour("#00979D"); @@ -5882,10 +5711,9 @@ Blockly.Blocks.xbot_analogValue = {init:function() { this.setInputsInline(!0); this.setOutput(!0, "Number"); }}; -Entry.block.xbot_analogValue = function(a, b) { - a = Entry.hw.portData; - b = b.getField("DEVICE"); - return a[b]; +Entry.block.xbot_analogValue = function(b, a) { + var c = Entry.hw.portData, d = a.getField("DEVICE"); + return c[d]; }; Blockly.Blocks.xbot_digitalOutput = {init:function() { this.setColour("#00979D"); @@ -5895,14 +5723,13 @@ Blockly.Blocks.xbot_digitalOutput = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.xbot_digitalOutput = function(a, b) { - a = Entry.hw.sendQueue; - var c = b.getStringField("DEVICE", b), d = b.getStringField("VALUE", b); - a.D13 = "D13" == c && "HIGH" == d ? 1 : 0; - a.D4 = "D4" == c && "HIGH" == d ? 1 : 0; - a.D7 = "D7" == c && "HIGH" == d ? 1 : 0; - a.D12 = "D12" == c && "HIGH" == d ? 1 : 0; - return b.callReturn(); +Entry.block.xbot_digitalOutput = function(b, a) { + var c = Entry.hw.sendQueue, d = a.getStringField("DEVICE", a), e = a.getStringField("VALUE", a); + c.D13 = "D13" == d && "HIGH" == e ? 1 : 0; + c.D4 = "D4" == d && "HIGH" == e ? 1 : 0; + c.D7 = "D7" == d && "HIGH" == e ? 1 : 0; + c.D12 = "D12" == d && "HIGH" == e ? 1 : 0; + return a.callReturn(); }; Blockly.Blocks.xbot_analogOutput = {init:function() { this.setColour("#00979D"); @@ -5913,11 +5740,10 @@ Blockly.Blocks.xbot_analogOutput = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.xbot_analogOutput = function(a, b) { - a = Entry.hw.sendQueue; - var c = b.getStringField("DEVICE", b), d = b.getNumberValue("VALUE", b); - "analogD5" == c ? a.analogD5 = d : "analogD6" == c && (a.analogD6 = d); - return b.callReturn(); +Entry.block.xbot_analogOutput = function(b, a) { + var c = Entry.hw.sendQueue, d = a.getStringField("DEVICE", a), e = a.getNumberValue("VALUE", a); + "analogD5" == d ? c.analogD5 = e : "analogD6" == d && (c.analogD6 = e); + return a.callReturn(); }; Blockly.Blocks.xbot_servo = {init:function() { this.setColour("#00979D"); @@ -5928,11 +5754,10 @@ Blockly.Blocks.xbot_servo = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.xbot_servo = function(a, b) { - a = Entry.hw.sendQueue; - var c = b.getStringField("DEVICE", b), d = b.getNumberValue("VALUE", b); - "head" == c ? a.head = d : "right" == c ? a.armR = d : "left" == c && (a.armL = d); - return b.callReturn(); +Entry.block.xbot_servo = function(b, a) { + var c = Entry.hw.sendQueue, d = a.getStringField("DEVICE", a), e = a.getNumberValue("VALUE", a); + "head" == d ? c.head = e : "right" == d ? c.armR = e : "left" == d && (c.armL = e); + return a.callReturn(); }; Blockly.Blocks.xbot_oneWheel = {init:function() { this.setColour("#00979D"); @@ -5943,11 +5768,10 @@ Blockly.Blocks.xbot_oneWheel = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.xbot_oneWheel = function(a, b) { - a = Entry.hw.sendQueue; - var c = b.getStringField("DEVICE", b), d = b.getNumberValue("VALUE", b); - "rightWheel" == c ? a.rightWheel = d : "leftWheel" == c ? a.leftWheel = d : a.rightWheel = a.leftWheel = d; - return b.callReturn(); +Entry.block.xbot_oneWheel = function(b, a) { + var c = Entry.hw.sendQueue, d = a.getStringField("DEVICE", a), e = a.getNumberValue("VALUE", a); + "rightWheel" == d ? c.rightWheel = e : "leftWheel" == d ? c.leftWheel = e : c.rightWheel = c.leftWheel = e; + return a.callReturn(); }; Blockly.Blocks.xbot_twoWheel = {init:function() { this.setColour("#00979D"); @@ -5960,11 +5784,11 @@ Blockly.Blocks.xbot_twoWheel = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.xbot_twoWheel = function(a, b) { - a = Entry.hw.sendQueue; - a.rightWheel = b.getNumberValue("rightWheel"); - a.leftWheel = b.getNumberValue("leftWheel"); - return b.callReturn(); +Entry.block.xbot_twoWheel = function(b, a) { + var c = Entry.hw.sendQueue; + c.rightWheel = a.getNumberValue("rightWheel"); + c.leftWheel = a.getNumberValue("leftWheel"); + return a.callReturn(); }; Blockly.Blocks.xbot_rgb = {init:function() { this.setColour("#00979D"); @@ -5979,12 +5803,12 @@ Blockly.Blocks.xbot_rgb = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.xbot_rgb = function(a, b) { - a = Entry.hw.sendQueue; - a.ledR = b.getNumberValue("ledR"); - a.ledG = b.getNumberValue("ledG"); - a.ledB = b.getNumberValue("ledB"); - return b.callReturn(); +Entry.block.xbot_rgb = function(b, a) { + var c = Entry.hw.sendQueue; + c.ledR = a.getNumberValue("ledR"); + c.ledG = a.getNumberValue("ledG"); + c.ledB = a.getNumberValue("ledB"); + return a.callReturn(); }; Blockly.Blocks.xbot_rgb_picker = {init:function() { this.setColour("#00979D"); @@ -5993,13 +5817,12 @@ Blockly.Blocks.xbot_rgb_picker = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.xbot_rgb_picker = function(a, b) { - a = b.getStringField("VALUE"); - var c = Entry.hw.sendQueue; - c.ledR = parseInt(.3 * parseInt(a.substr(1, 2), 16)); - c.ledG = parseInt(.3 * parseInt(a.substr(3, 2), 16)); - c.ledB = parseInt(.3 * parseInt(a.substr(5, 2), 16)); - return b.callReturn(); +Entry.block.xbot_rgb_picker = function(b, a) { + var c = a.getStringField("VALUE"), d = Entry.hw.sendQueue; + d.ledR = parseInt(.3 * parseInt(c.substr(1, 2), 16)); + d.ledG = parseInt(.3 * parseInt(c.substr(3, 2), 16)); + d.ledB = parseInt(.3 * parseInt(c.substr(5, 2), 16)); + return a.callReturn(); }; Blockly.Blocks.xbot_buzzer = {init:function() { this.setColour("#00979D"); @@ -6010,13 +5833,12 @@ Blockly.Blocks.xbot_buzzer = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.xbot_buzzer = function(a, b) { - a = Entry.hw.sendQueue; - var c = b.getStringField("NOTE", b), d = b.getStringField("OCTAVE", b), e = b.getNumberValue("VALUE", b), c = c + d; - a.note = "C2" == c ? 65 : "D2" == c ? 73 : "E2" == c ? 82 : "F2" == c ? 87 : "G2" == c ? 98 : "A2" == c ? 110 : "B2" == c ? 123 : "C3" == c ? 131 : "D3" == c ? 147 : "E3" == c ? 165 : "F3" == c ? 175 : "G3" == c ? 196 : "A3" == c ? 220 : "B3" == c ? 247 : "C4" == c ? 262 : "D4" == c ? 294 : "E4" == c ? 330 : "F4" == c ? 349 : "G4" == c ? 392 : "A4" == c ? 440 : "B4" == c ? 494 : "C5" == c ? 523 : "D5" == c ? 587 : "E5" == c ? 659 : "F5" == c ? 698 : "G5" == c ? 784 : "A5" == c ? 880 : "B5" == c ? - 988 : "C6" == c ? 1047 : "D6" == c ? 1175 : "E6" == c ? 1319 : "F6" == c ? 1397 : "G6" == c ? 1568 : "A6" == c ? 1760 : "B6" == c ? 1976 : "C7" == c ? 2093 : "D7" == c ? 2349 : "E7" == c ? 2637 : "F7" == c ? 2794 : "G7" == c ? 3136 : "A7" == c ? 3520 : "B7" == c ? 3951 : 262; - a.duration = 40 * e; - return b.callReturn(); +Entry.block.xbot_buzzer = function(b, a) { + var c = Entry.hw.sendQueue, d = a.getStringField("NOTE", a), e = a.getStringField("OCTAVE", a), f = a.getNumberValue("VALUE", a), d = d + e; + c.note = "C2" == d ? 65 : "D2" == d ? 73 : "E2" == d ? 82 : "F2" == d ? 87 : "G2" == d ? 98 : "A2" == d ? 110 : "B2" == d ? 123 : "C3" == d ? 131 : "D3" == d ? 147 : "E3" == d ? 165 : "F3" == d ? 175 : "G3" == d ? 196 : "A3" == d ? 220 : "B3" == d ? 247 : "C4" == d ? 262 : "D4" == d ? 294 : "E4" == d ? 330 : "F4" == d ? 349 : "G4" == d ? 392 : "A4" == d ? 440 : "B4" == d ? 494 : "C5" == d ? 523 : "D5" == d ? 587 : "E5" == d ? 659 : "F5" == d ? 698 : "G5" == d ? 784 : "A5" == d ? 880 : "B5" == d ? + 988 : "C6" == d ? 1047 : "D6" == d ? 1175 : "E6" == d ? 1319 : "F6" == d ? 1397 : "G6" == d ? 1568 : "A6" == d ? 1760 : "B6" == d ? 1976 : "C7" == d ? 2093 : "D7" == d ? 2349 : "E7" == d ? 2637 : "F7" == d ? 2794 : "G7" == d ? 3136 : "A7" == d ? 3520 : "B7" == d ? 3951 : 262; + c.duration = 40 * f; + return a.callReturn(); }; Blockly.Blocks.xbot_lcd = {init:function() { this.setColour("#00979D"); @@ -6027,1720 +5849,1070 @@ Blockly.Blocks.xbot_lcd = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.xbot_lcd = function(a, b) { - a = Entry.hw.sendQueue; - var c = b.getNumberField("LINE", b), d = b.getStringValue("VALUE", b); - 0 == c ? (a.lcdNum = 0, a.lcdTxt = d) : 1 == c && (a.lcdNum = 1, a.lcdTxt = d); - return b.callReturn(); +Entry.block.xbot_lcd = function(b, a) { + var c = Entry.hw.sendQueue, d = a.getNumberField("LINE", a), e = a.getStringValue("VALUE", a); + 0 == d ? (c.lcdNum = 0, c.lcdTxt = e) : 1 == d && (c.lcdNum = 1, c.lcdTxt = e); + return a.callReturn(); }; -Entry.Collection = function(a) { +Entry.Collection = function(b) { this.length = 0; this._hashMap = {}; this._observers = []; - this.set(a); + this.set(b); }; -(function(a, b) { - a.set = function(a) { +(function(b, a) { + b.set = function(b) { for (;this.length;) { - b.pop.call(this); + a.pop.call(this); } var d = this._hashMap, e; for (e in d) { delete d[e]; } - if (void 0 !== a) { + if (void 0 !== b) { e = 0; - for (var f = a.length;e < f;e++) { - var g = a[e]; + for (var f = b.length;e < f;e++) { + var g = b[e]; d[g.id] = g; - b.push.call(this, g); + a.push.call(this, g); } } }; - a.push = function(a) { - this._hashMap[a.id] = a; - b.push.call(this, a); + b.push = function(b) { + this._hashMap[b.id] = b; + a.push.call(this, b); }; - a.unshift = function() { - for (var a = Array.prototype.slice.call(arguments, 0), d = this._hashMap, e = a.length - 1;0 <= e;e--) { - var f = a[e]; - b.unshift.call(this, f); + b.unshift = function() { + for (var b = Array.prototype.slice.call(arguments, 0), d = this._hashMap, e = b.length - 1;0 <= e;e--) { + var f = b[e]; + a.unshift.call(this, f); d[f.id] = f; } }; - a.insert = function(a, d) { - b.splice.call(this, d, 0, a); - this._hashMap[a.id] = a; + b.insert = function(b, d) { + a.splice.call(this, d, 0, b); + this._hashMap[b.id] = b; }; - a.has = function(b) { - return !!this._hashMap[b]; + b.has = function(a) { + return !!this._hashMap[a]; }; - a.get = function(b) { - return this._hashMap[b]; + b.get = function(a) { + return this._hashMap[a]; }; - a.at = function(b) { - return this[b]; + b.at = function(a) { + return this[a]; }; - a.getAll = function() { - for (var b = this.length, a = [], e = 0;e < b;e++) { - a.push(this[e]); + b.getAll = function() { + for (var a = this.length, b = [], e = 0;e < a;e++) { + b.push(this[e]); } - return a; + return b; }; - a.indexOf = function(a) { - return b.indexOf.call(this, a); + b.indexOf = function(b) { + return a.indexOf.call(this, b); }; - a.find = function(b) { - for (var a = [], e, f = 0, g = this.length;f < g;f++) { + b.find = function(a) { + for (var b = [], e, f = 0, g = this.length;f < g;f++) { e = !0; var h = this[f], k; - for (k in b) { - if (b[k] != h[k]) { + for (k in a) { + if (a[k] != h[k]) { e = !1; break; } } - e && a.push(h); + e && b.push(h); } - return a; + return b; }; - a.pop = function() { - var a = b.pop.call(this); - delete this._hashMap[a.id]; - return a; + b.pop = function() { + var b = a.pop.call(this); + delete this._hashMap[b.id]; + return b; }; - a.shift = function() { - var a = b.shift.call(this); - delete this._hashMap[a.id]; - return a; + b.shift = function() { + var b = a.shift.call(this); + delete this._hashMap[b.id]; + return b; }; - a.slice = function(a, d) { - a = b.slice.call(this, a, d); - d = this._hashMap; - for (var e in a) { - delete d[a[e].id]; + b.slice = function(b, d) { + var e = a.slice.call(this, b, d), f = this._hashMap, g; + for (g in e) { + delete f[e[g].id]; } - return a; + return e; }; - a.remove = function(b) { - var a = this.indexOf(b); - -1 < a && (delete this._hashMap[b.id], this.splice(a, 1)); + b.remove = function(a) { + var b = this.indexOf(a); + -1 < b && (delete this._hashMap[a.id], this.splice(b, 1)); }; - a.splice = function(a, d) { - var e = b.slice.call(arguments, 2), f = this._hashMap; - d = void 0 === d ? this.length - a : d; - for (var g = b.splice.call(this, a, d), h = 0, k = g.length;h < k;h++) { + b.splice = function(b, d) { + var e = a.slice.call(arguments, 2), f = this._hashMap; + d = void 0 === d ? this.length - b : d; + for (var g = a.splice.call(this, b, d), h = 0, k = g.length;h < k;h++) { delete f[g[h].id]; } h = 0; for (k = e.length;h < k;h++) { - f = e[h], b.splice.call(this, a++, 0, f), this._hashMap[f.id] = f; + f = e[h], a.splice.call(this, b++, 0, f), this._hashMap[f.id] = f; } return g; }; - a.clear = function() { + b.clear = function() { for (;this.length;) { - b.pop.call(this); + a.pop.call(this); } this._hashMap = {}; }; - a.map = function(b, a) { + b.map = function(a, b) { for (var e = [], f = 0, g = this.length;f < g;f++) { - e.push(b(this[f], a)); + e.push(a(this[f], b)); } return e; }; - a.moveFromTo = function(a, d) { + b.moveFromTo = function(b, d) { var e = this.length - 1; - 0 > a || 0 > d || a > e || d > e || b.splice.call(this, d, 0, b.splice.call(this, a, 1)[0]); + 0 > b || 0 > d || b > e || d > e || a.splice.call(this, d, 0, a.splice.call(this, b, 1)[0]); }; - a.sort = function() { + b.sort = function() { }; - a.fromJSON = function() { + b.fromJSON = function() { }; - a.toJSON = function() { - for (var b = [], a = 0, e = this.length;a < e;a++) { - b.push(this[a].toJSON()); + b.toJSON = function() { + for (var a = [], b = 0, e = this.length;b < e;b++) { + a.push(this[b].toJSON()); } - return b; + return a; }; - a.observe = function() { + b.observe = function() { }; - a.unobserve = function() { + b.unobserve = function() { }; - a.notify = function() { + b.notify = function() { }; - a.destroy = function() { + b.destroy = function() { }; })(Entry.Collection.prototype, Array.prototype); -Entry.Event = function(a) { - this._sender = a; +Entry.Event = function(b) { + this._sender = b; this._listeners = []; }; -(function(a) { - a.attach = function(b, a) { - var d = this; - b = {obj:b, fn:a, destroy:function() { +(function(b) { + b.attach = function(a, b) { + var d = this, e = {obj:a, fn:b, destroy:function() { d.detach(this); }}; - this._listeners.push(b); - return b; + this._listeners.push(e); + return e; }; - a.detach = function(b) { - var a = this._listeners; - b = a.indexOf(b); - if (-1 < b) { - return a.splice(b, 1); + b.detach = function(a) { + var b = this._listeners; + a = b.indexOf(a); + if (-1 < a) { + return b.splice(a, 1); } }; - a.clear = function() { - for (var b = this._listeners;b.length;) { - b.pop(); + b.clear = function() { + for (var a = this._listeners;a.length;) { + a.pop(); } }; - a.notify = function() { - var b = arguments; - this._listeners.slice().forEach(function(a) { - a.fn.apply(a.obj, b); + b.notify = function() { + var a = arguments; + this._listeners.slice().forEach(function(b) { + b.fn.apply(b.obj, a); }); }; })(Entry.Event.prototype); -Entry.Utils = {}; -Entry.overridePrototype = function() { - Number.prototype.mod = function(a) { - return (this % a + a) % a; - }; -}; -Entry.Utils.generateId = function() { - return ("0000" + (Math.random() * Math.pow(36, 4) << 0).toString(36)).substr(-4); -}; -Entry.Utils.intersectArray = function(a, b) { - for (var c = [], d = 0;d < a.length;d++) { - for (var e = 0;e < b.length;e++) { - if (a[d] == b[e]) { - c.push(a[d]); - break; - } - } - } - return c; -}; -Entry.Utils.isPointInMatrix = function(a, b, c) { - c = void 0 === c ? 0 : c; - var d = a.offsetX ? a.x + a.offsetX : a.x, e = a.offsetY ? a.y + a.offsety : a.y; - return d - c <= b.x && d + a.width + c >= b.x && e - c <= b.y && e + a.height + c >= b.y; -}; -Entry.Utils.colorDarken = function(a, b) { - function c(b) { - 2 != b.length && (b = "0" + b); - return b; - } - var d, e; - 7 === a.length ? (d = parseInt(a.substr(1, 2), 16), e = parseInt(a.substr(3, 2), 16), a = parseInt(a.substr(5, 2), 16)) : (d = parseInt(a.substr(1, 2), 16), e = parseInt(a.substr(2, 2), 16), a = parseInt(a.substr(3, 2), 16)); - b = void 0 === b ? .7 : b; - d = c(Math.floor(d * b).toString(16)); - e = c(Math.floor(e * b).toString(16)); - a = c(Math.floor(a * b).toString(16)); - return "#" + d + e + a; -}; -Entry.Utils.colorLighten = function(a, b) { - b = 0 === b ? 0 : b || 20; - a = Entry.Utils.hexToHsl(a); - a.l += b / 100; - a.l = Math.min(1, Math.max(0, a.l)); - return Entry.Utils.hslToHex(a); -}; -Entry.Utils.bound01 = function(a, b) { - var c = a; - "string" == typeof c && -1 != c.indexOf(".") && 1 === parseFloat(c) && (a = "100%"); - c = "string" === typeof a && -1 != a.indexOf("%"); - a = Math.min(b, Math.max(0, parseFloat(a))); - c && (a = parseInt(a * b, 10) / 100); - return 1E-6 > Math.abs(a - b) ? 1 : a % b / parseFloat(b); -}; -Entry.Utils.hexToHsl = function(a) { - var b, c; - 7 === a.length ? (b = parseInt(a.substr(1, 2), 16), c = parseInt(a.substr(3, 2), 16), a = parseInt(a.substr(5, 2), 16)) : (b = parseInt(a.substr(1, 2), 16), c = parseInt(a.substr(2, 2), 16), a = parseInt(a.substr(3, 2), 16)); - b = Entry.Utils.bound01(b, 255); - c = Entry.Utils.bound01(c, 255); - a = Entry.Utils.bound01(a, 255); - var d = Math.max(b, c, a), e = Math.min(b, c, a), f, g = (d + e) / 2; - if (d == e) { - f = e = 0; - } else { - var h = d - e, e = .5 < g ? h / (2 - d - e) : h / (d + e); - switch(d) { - case b: - f = (c - a) / h + (c < a ? 6 : 0); - break; - case c: - f = (a - b) / h + 2; - break; - case a: - f = (b - c) / h + 4; - } - f /= 6; - } - return {h:360 * f, s:e, l:g}; -}; -Entry.Utils.hslToHex = function(a) { - function b(b, a, c) { - 0 > c && (c += 1); - 1 < c && --c; - return c < 1 / 6 ? b + 6 * (a - b) * c : .5 > c ? a : c < 2 / 3 ? b + (a - b) * (2 / 3 - c) * 6 : b; - } - function c(b) { - return 1 == b.length ? "0" + b : "" + b; - } - var d, e; - e = Entry.Utils.bound01(a.h, 360); - d = Entry.Utils.bound01(a.s, 1); - a = Entry.Utils.bound01(a.l, 1); - if (0 === d) { - d = a = e = a; - } else { - var f = .5 > a ? a * (1 + d) : a + d - a * d, g = 2 * a - f; - d = b(g, f, e + 1 / 3); - a = b(g, f, e); - e = b(g, f, e - 1 / 3); - } - a *= 255; - e *= 255; - return "#" + [c(Math.round(255 * d).toString(16)), c(Math.round(a).toString(16)), c(Math.round(e).toString(16))].join(""); -}; -Entry.Utils.bindGlobalEvent = function(a) { - var b = $(document); - void 0 === a && (a = "resize mousedown mousemove keydown keyup dispose".split(" ")); - -1 < a.indexOf("resize") && (Entry.windowReszied && ($(window).off("resize"), Entry.windowReszied.clear()), Entry.windowResized = new Entry.Event(window), $(window).on("resize", function(b) { - Entry.windowResized.notify(b); - })); - -1 < a.indexOf("mousedown") && (Entry.documentMousedown && (b.off("mousedown"), Entry.documentMousedown.clear()), Entry.documentMousedown = new Entry.Event(window), b.on("mousedown", function(b) { - Entry.documentMousedown.notify(b); - })); - -1 < a.indexOf("mousemove") && (Entry.documentMousemove && (b.off("touchmove mousemove"), Entry.documentMousemove.clear()), Entry.mouseCoordinate = {}, Entry.documentMousemove = new Entry.Event(window), b.on("touchmove mousemove", function(b) { - b.originalEvent && b.originalEvent.touches && (b = b.originalEvent.touches[0]); - Entry.documentMousemove.notify(b); - Entry.mouseCoordinate.x = b.clientX; - Entry.mouseCoordinate.y = b.clientY; - })); - -1 < a.indexOf("keydown") && (Entry.keyPressed && (b.off("keydown"), Entry.keyPressed.clear()), Entry.pressedKeys = [], Entry.keyPressed = new Entry.Event(window), b.on("keydown", function(b) { - var a = b.keyCode; - 0 > Entry.pressedKeys.indexOf(a) && Entry.pressedKeys.push(a); - Entry.keyPressed.notify(b); - })); - -1 < a.indexOf("keyup") && (Entry.keyUpped && (b.off("keyup"), Entry.keyUpped.clear()), Entry.keyUpped = new Entry.Event(window), b.on("keyup", function(b) { - var a = Entry.pressedKeys.indexOf(b.keyCode); - -1 < a && Entry.pressedKeys.splice(a, 1); - Entry.keyUpped.notify(b); - })); - -1 < a.indexOf("dispose") && (Entry.disposeEvent && Entry.disposeEvent.clear(), Entry.disposeEvent = new Entry.Event(window), Entry.documentMousedown && Entry.documentMousedown.attach(this, function(b) { - Entry.disposeEvent.notify(b); - })); -}; -Entry.Utils.makeActivityReporter = function() { - Entry.activityReporter = new Entry.ActivityReporter; - Entry.commander && Entry.commander.addReporter(Entry.activityReporter); - return Entry.activityReporter; -}; -Entry.Utils.initEntryEvent_ = function() { - Entry.events_ || (Entry.events_ = []); +Entry.Observer = function(b, a, c, d) { + this.parent = b; + this.object = a; + this.funcName = c; + this.attrs = d; + b.push(this); }; -Entry.sampleColours = []; -Entry.assert = function(a, b) { - if (!a) { - throw Error(b || "Assert failed"); +(function(b) { + b.destroy = function() { + var a = this.parent, b = a.indexOf(this); + -1 < b && a.splice(b, 1); + return this; + }; +})(Entry.Observer.prototype); +Entry.Command = {}; +(function(b) { + b["do"] = {type:EntryStatic.COMMAND_TYPES["do"], log:function(a) { + return [b["do"].type]; + }}; + b.undo = {type:EntryStatic.COMMAND_TYPES.undo, log:function(a) { + return [b.undo.type]; + }}; + b.redo = {type:EntryStatic.COMMAND_TYPES.redo, log:function(a) { + return [b.redo.type]; + }}; +})(Entry.Command); +Entry.Commander = function(b) { + if ("workspace" == b || "phone" == b) { + Entry.stateManager = new Entry.StateManager; } + Entry.do = this.do.bind(this); + Entry.undo = this.undo.bind(this); + this.editor = {}; + this.reporters = []; + this._tempStorage = null; + Entry.Command.editor = this.editor; }; -Entry.parseTexttoXML = function(a) { - var b; - window.ActiveXObject ? (b = new ActiveXObject("Microsoft.XMLDOM"), b.async = "false", b.loadXML(a)) : b = (new DOMParser).parseFromString(a, "text/xml"); - return b; -}; -Entry.createElement = function(a, b) { - a = document.createElement(a); - b && (a.id = b); - a.hasClass = function(b) { - return this.className.match(new RegExp("(\\s|^)" + b + "(\\s|$)")); +(function(b) { + b.do = function(a) { + var b = this, d = Array.prototype.slice.call(arguments); + d.shift(); + var e = Entry.Command[a]; + Entry.stateManager && Entry.stateManager.addCommand.apply(Entry.stateManager, [a, this, this.do, e.undo].concat(e.state.apply(this, d))); + e = Entry.Command[a].do.apply(this, d); + setTimeout(function() { + b.report("do"); + b.report(a, d); + }, 0); + return {value:e, isPass:this.isPass.bind(this)}; }; - a.addClass = function(b) { - for (var a = 0;a < arguments.length;a++) { - b = arguments[a], this.hasClass(b) || (this.className += " " + b); - } + b.undo = function() { + var a = Array.prototype.slice.call(arguments), b = a.shift(), d = Entry.Command[b]; + this.report("undo"); + Entry.stateManager && Entry.stateManager.addCommand.apply(Entry.stateManager, [b, this, this.do, d.undo].concat(d.state.apply(this, a))); + return {value:Entry.Command[b].do.apply(this, a), isPass:this.isPass.bind(this)}; + }; + b.redo = function() { + var a = Array.prototype.slice.call(arguments), b = a.shift(), d = Entry.Command[b]; + that.report("redo"); + Entry.stateManager && Entry.stateManager.addCommand.apply(Entry.stateManager, [b, this, this.undo, b].concat(d.state.apply(null, a))); + d.undo.apply(this, a); + }; + b.setCurrentEditor = function(a, b) { + this.editor[a] = b; }; - a.removeClass = function(b) { - for (var a = 0;a < arguments.length;a++) { - b = arguments[a], this.hasClass(b) && (this.className = this.className.replace(new RegExp("(\\s|^)" + b + "(\\s|$)"), " ")); + b.isPass = function(a) { + a = void 0 === a ? !0 : a; + if (Entry.stateManager) { + var b = Entry.stateManager.getLastCommand(); + b && (b.isPass = a); } }; - a.bindOnClick = function(b) { - $(this).on("click tab", function(a) { - a.stopImmediatePropagation(); - b.call(this, a); - }); + b.addReporter = function(a) { + this.reporters.push(a); }; - return a; + b.removeReporter = function(a) { + a = this.reporters.indexOf(a); + -1 < a && this.reporters.splice(a, 1); + }; + b.report = function(a, b) { + var d = this.reporters; + if (0 !== d.length) { + var e; + e = a && Entry.Command[a] && Entry.Command[a].log ? Entry.Command[a].log.apply(this, b) : b; + d.forEach(function(a) { + a.add(e); + }); + } + }; +})(Entry.Commander.prototype); +(function(b) { + b.addThread = {type:EntryStatic.COMMAND_TYPES.addThread, do:function(a) { + return this.editor.board.code.createThread(a); + }, state:function(a) { + a.length && (a[0].id = Entry.Utils.generateId()); + return [a]; + }, log:function(a) { + a = this.editor.board.code.getThreads().pop(); + return [b.addThread.type, ["thread", a.stringify()], ["code", this.editor.board.code.stringify()]]; + }, undo:"destroyThread"}; + b.destroyThread = {type:EntryStatic.COMMAND_TYPES.destroyThread, do:function(a) { + this.editor.board.findById(a[0].id).destroy(!0, !0); + }, state:function(a) { + return [this.editor.board.findById(a[0].id).thread.toJSON()]; + }, log:function(a) { + a = a[0].id; + this.editor.board.findById(a); + return [b.destroyThread.type, ["blockId", a], ["code", this.editor.board.code.stringify()]]; + }, undo:"addThread"}; + b.destroyBlock = {type:EntryStatic.COMMAND_TYPES.destroyBlock, do:function(a) { + "string" === typeof a && (a = this.editor.board.findById(a)); + a.doDestroy(!0); + }, state:function(a) { + "string" === typeof a && (a = this.editor.board.findById(a)); + return [a.toJSON(), a.pointer()]; + }, log:function(a) { + "string" === typeof a && (a = this.editor.board.findById(a)); + return [b.destroyBlock.type, ["blockId", a.id], ["code", this.editor.board.code.stringify()]]; + }, undo:"recoverBlock"}; + b.recoverBlock = {type:EntryStatic.COMMAND_TYPES.recoverBlock, do:function(a, b) { + var d = this.editor.board.code.createThread([a]).getFirstBlock(); + "string" === typeof d && (d = this.editor.board.findById(d)); + this.editor.board.insert(d, b); + }, state:function(a) { + "string" !== typeof a && (a = a.id); + return [a]; + }, log:function(a, c) { + a = this.editor.board.findById(a.id); + return [b.recoverBlock.type, ["block", a.stringify()], ["pointer", c], ["code", this.editor.board.code.stringify()]]; + }, undo:"destroyBlock"}; + b.insertBlock = {type:EntryStatic.COMMAND_TYPES.insertBlock, do:function(a, b, d) { + "string" === typeof a && (a = this.editor.board.findById(a)); + this.editor.board.insert(a, b, d); + }, state:function(a, b) { + "string" === typeof a && (a = this.editor.board.findById(a)); + var d = [a.id], e = a.targetPointer(); + d.push(e); + "string" !== typeof a && "basic" === a.getBlockType() && d.push(a.thread.getCount(a)); + return d; + }, log:function(a, c, d) { + "string" === typeof a && (a = this.editor.board.findById(a)); + return [b.insertBlock.type, ["blockId", a.id], ["targetPointer", a.targetPointer()], ["count", d], ["code", this.editor.board.code.stringify()]]; + }, undo:"insertBlock"}; + b.separateBlock = {type:EntryStatic.COMMAND_TYPES.separateBlock, do:function(a) { + a.view && a.view._toGlobalCoordinate(Entry.DRAG_MODE_DRAG); + a.doSeparate(); + }, state:function(a) { + var b = [a.id], d = a.targetPointer(); + b.push(d); + "basic" === a.getBlockType() && b.push(a.thread.getCount(a)); + return b; + }, log:function(a) { + "string" === typeof a && (a = this.editor.board.findById(a)); + return [b.separateBlock.type, ["blockId", a.id], ["x", a.x], ["y", a.y], ["code", this.editor.board.code.stringify()]]; + }, undo:"insertBlock"}; + b.moveBlock = {type:EntryStatic.COMMAND_TYPES.moveBlock, do:function(a, b, d) { + void 0 !== b ? (a = this.editor.board.findById(a), a.moveTo(b, d)) : a._updatePos(); + }, state:function(a) { + "string" === typeof a && (a = this.editor.board.findById(a)); + return [a.id, a.x, a.y]; + }, log:function(a, c, d) { + return [b.moveBlock.type, ["blockId", a.id], ["x", a.x], ["y", a.y], ["code", this.editor.board.code.stringify()]]; + }, undo:"moveBlock"}; + b.cloneBlock = {type:EntryStatic.COMMAND_TYPES.cloneBlock, do:function(a) { + "string" === typeof a && (a = this.editor.board.findById(a)); + this.editor.board.code.createThread(a.copy()); + }, state:function(a) { + "string" !== typeof a && (a = a.id); + return [a]; + }, log:function(a) { + "string" === typeof a && (a = this.editor.board.findById(a)); + var c = this.editor.board.code.getThreads().pop(); + return [b.cloneBlock.type, ["blockId", a.id], ["thread", c.stringify()], ["code", this.editor.board.code.stringify()]]; + }, undo:"uncloneBlock"}; + b.uncloneBlock = {type:EntryStatic.COMMAND_TYPES.uncloneBlock, do:function(a) { + a = this.editor.board.code.getThreads().pop().getFirstBlock(); + this._tempStorage = a.id; + a.destroy(!0, !0); + }, state:function(a) { + return [a]; + }, log:function(a) { + a = this._tempStorage; + this._tempStorage = null; + return [b.uncloneBlock.type, ["blockId", a], ["code", this.editor.board.code.stringify()]]; + }, undo:"cloneBlock"}; + b.scrollBoard = {type:EntryStatic.COMMAND_TYPES.scrollBoard, do:function(a, b, d) { + d || this.editor.board.scroller._scroll(a, b); + delete this.editor.board.scroller._diffs; + }, state:function(a, b) { + return [-a, -b]; + }, log:function(a, c) { + return [b.scrollBoard.type, ["dx", a], ["dy", c]]; + }, undo:"scrollBoard"}; + b.setFieldValue = {type:EntryStatic.COMMAND_TYPES.setFieldValue, do:function(a, b, d, e, f) { + b.setValue(f, !0); + }, state:function(a, b, d, e, f) { + return [a, b, d, f, e]; + }, log:function(a, c, d, e, f) { + return [b.setFieldValue.type, ["pointer", d], ["newValue", f], ["code", this.editor.board.code.stringify()]]; + }, undo:"setFieldValue"}; +})(Entry.Command); +(function(b) { + b.selectObject = {type:EntryStatic.COMMAND_TYPES.selectObject, do:function(a) { + return Entry.container.selectObject(a); + }, state:function(a) { + if ((a = Entry.playground) && a.object) { + return [a.object.id]; + } + }, log:function(a) { + return [a]; + }, undo:"selectObject"}; +})(Entry.Command); +Entry.Container = function() { + this.objects_ = []; + this.cachedPicture = {}; + this.inputValue = {}; + this.currentObjects_ = this.copiedObject = null; }; -Entry.makeAutolink = function(a) { - return a ? a.replace(/(http|https|ftp|telnet|news|irc):\/\/([-/.a-zA-Z0-9_~#%$?&=:200-377()][^)\]}]+)/gi, "$1://$2").replace(/([xA1-xFEa-z0-9_-]+@[xA1-xFEa-z0-9-]+.[a-z0-9-]+)/gi, "$1") : ""; +Entry.Container.prototype.generateView = function(b, a) { + this._view = b; + this._view.addClass("entryContainer"); + if (a && "workspace" != a) { + "phone" == a && (this._view.addClass("entryContainerPhone"), c = Entry.createElement("div"), c.addClass("entryAddObjectWorkspace"), c.innerHTML = Lang.Workspace.add_object, c.bindOnClick(function(a) { + Entry.dispatchEvent("openSpriteManager"); + }), c = Entry.createElement("div"), c.addClass("entryContainerListPhoneWrapper"), this._view.appendChild(c), d = Entry.createElement("ul"), d.addClass("entryContainerListPhone"), c.appendChild(d), this.listView_ = d); + } else { + this._view.addClass("entryContainerWorkspace"); + this._view.setAttribute("id", "entryContainerWorkspaceId"); + var c = Entry.createElement("div"); + c.addClass("entryAddObjectWorkspace"); + c.innerHTML = Lang.Workspace.add_object; + c.bindOnClick(function(a) { + Entry.dispatchEvent("openSpriteManager"); + }); + c = Entry.createElement("div"); + c.addClass("entryContainerListWorkspaceWrapper"); + Entry.isForLecture && c.addClass("lecture"); + Entry.Utils.disableContextmenu(c); + $(c).on("contextmenu", function(a) { + a = [{text:Lang.Blocks.Paste_blocks, enable:!Entry.engine.isState("run") && !!Entry.container.copiedObject, callback:function() { + Entry.container.copiedObject ? Entry.container.addCloneObject(Entry.container.copiedObject) : Entry.toast.alert(Lang.Workspace.add_object_alert, Lang.Workspace.object_not_found_for_paste); + }}]; + Entry.ContextMenu.show(a, "workspace-contextmenu"); + }); + this._view.appendChild(c); + var d = Entry.createElement("ul"); + d.addClass("entryContainerListWorkspace"); + c.appendChild(d); + this.listView_ = d; + this.enableSort(); + } }; -Entry.generateHash = function() { - return ("0000" + (Math.random() * Math.pow(36, 4) << 0).toString(36)).substr(-4); +Entry.Container.prototype.enableSort = function() { + $ && $(this.listView_).sortable({start:function(b, a) { + a.item.data("start_pos", a.item.index()); + }, stop:function(b, a) { + var c = a.item.data("start_pos"), d = a.item.index(); + Entry.container.moveElement(c, d); + }, axis:"y", cancel:"input.selectedEditingObject"}); }; -Entry.addEventListener = function(a, b) { - this.events_ || (this.events_ = {}); - this.events_[a] || (this.events_[a] = []); - b instanceof Function && this.events_[a].push(b); - return !0; +Entry.Container.prototype.disableSort = function() { + $ && $(this.listView_).sortable("destroy"); }; -Entry.dispatchEvent = function(a, b) { - this.events_ || (this.events_ = {}); - if (this.events_[a]) { - for (var c = 0, d = this.events_[a].length;c < d;c++) { - this.events_[a][c].call(window, b); +Entry.Container.prototype.updateListView = function() { + if (this.listView_) { + for (var b = this.listView_;b.hasChildNodes();) { + b.removeChild(b.lastChild); } - } -}; -Entry.removeEventListener = function(a, b) { - if (this.events_[a]) { - for (var c = 0, d = this.events_[a].length;c < d;c++) { - if (this.events_[a][c] === b) { - this.events_[a].splice(c, 1); - break; - } + var a = this.getCurrentObjects(), c; + for (c in a) { + b.appendChild(a[c].view_); } + Entry.stage.sortZorder(); } }; -Entry.removeAllEventListener = function(a) { - this.events_ && this.events_[a] && delete this.events_[a]; -}; -Entry.addTwoNumber = function(a, b) { - if (isNaN(a) || isNaN(b)) { - return a + b; +Entry.Container.prototype.setObjects = function(b) { + for (var a in b) { + var c = new Entry.EntryObject(b[a]); + this.objects_.push(c); + c.generateView(); + c.pictures.map(function(a) { + Entry.playground.generatePictureElement(a); + }); + c.sounds.map(function(a) { + Entry.playground.generateSoundElement(a); + }); } - a += ""; - b += ""; - var c = a.indexOf("."), d = b.indexOf("."), e = 0, f = 0; - 0 < c && (e = a.length - c - 1); - 0 < d && (f = b.length - d - 1); - return 0 < e || 0 < f ? e >= f ? (parseFloat(a) + parseFloat(b)).toFixed(e) : (parseFloat(a) + parseFloat(b)).toFixed(f) : parseInt(a) + parseInt(b); -}; -Entry.hex2rgb = function(a) { - return (a = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a)) ? {r:parseInt(a[1], 16), g:parseInt(a[2], 16), b:parseInt(a[3], 16)} : null; -}; -Entry.rgb2hex = function(a, b, c) { - return "#" + (16777216 + (a << 16) + (b << 8) + c).toString(16).slice(1); -}; -Entry.generateRgb = function() { - return {r:Math.floor(256 * Math.random()), g:Math.floor(256 * Math.random()), b:Math.floor(256 * Math.random())}; + this.updateObjectsOrder(); + this.updateListView(); + Entry.stage.sortZorder(); + Entry.variableContainer.updateViews(); + b = Entry.type; + ("workspace" == b || "phone" == b) && (b = this.getCurrentObjects()[0]) && this.selectObject(b.id); }; -Entry.adjustValueWithMaxMin = function(a, b, c) { - return a > c ? c : a < b ? b : a; +Entry.Container.prototype.getPictureElement = function(b, a) { + var c = this.getObject(a).getPicture(b); + if (c) { + return c.view; + } + throw Error("No picture found"); }; -Entry.isExist = function(a, b, c) { - for (var d = 0;d < c.length;d++) { - if (c[d][b] == a) { - return c[d]; +Entry.Container.prototype.setPicture = function(b) { + var a = this.getObject(b.objectId), c; + for (c in a.pictures) { + if (b.id === a.pictures[c].id) { + var d = {}; + d.dimension = b.dimension; + d.id = b.id; + d.filename = b.filename; + d.fileurl = b.fileurl; + d.name = b.name; + d.view = a.pictures[c].view; + a.pictures[c] = d; + return; } } - return !1; + throw Error("No picture found"); }; -Entry.getColourCodes = function() { - return "transparent #660000 #663300 #996633 #003300 #003333 #003399 #000066 #330066 #660066 #FFFFFF #990000 #993300 #CC9900 #006600 #336666 #0033FF #000099 #660099 #990066 #000000 #CC0000 #CC3300 #FFCC00 #009900 #006666 #0066FF #0000CC #663399 #CC0099 #333333 #FF0000 #FF3300 #FFFF00 #00CC00 #009999 #0099FF #0000FF #9900CC #FF0099 #666666 #CC3333 #FF6600 #FFFF33 #00FF00 #00CCCC #00CCFF #3366FF #9933FF #FF00FF #999999 #FF6666 #FF6633 #FFFF66 #66FF66 #66CCCC #00FFFF #3399FF #9966FF #FF66FF #BBBBBB #FF9999 #FF9966 #FFFF99 #99FF99 #66FFCC #99FFFF #66CCff #9999FF #FF99FF #CCCCCC #FFCCCC #FFCC99 #FFFFCC #CCFFCC #99FFCC #CCFFFF #99CCFF #CCCCFF #FFCCFF".split(" "); -}; -Entry.removeElement = function(a) { - a && a.parentNode && a.parentNode.removeChild(a); -}; -Entry.getElementsByClassName = function(a) { - for (var b = [], c = document.getElementsByTagName("*"), d = 0;d < c.length;d++) { - -1 < (" " + c[d].className + " ").indexOf(" " + a + " ") && b.push(c[d]); +Entry.Container.prototype.selectPicture = function(b, a) { + var c = this.getObject(a), d = c.getPicture(b); + if (d) { + return c.selectedPicture = d, c.entity.setImage(d), c.updateThumbnailView(), c.id; } - return b; + throw Error("No picture found"); }; -Entry.parseNumber = function(a) { - return "string" != typeof a || isNaN(Number(a)) ? "number" != typeof a || isNaN(Number(a)) ? !1 : a : Number(a); +Entry.Container.prototype.addObject = function(b, a) { + var c = new Entry.EntryObject(b); + c.name = Entry.getOrderedName(c.name, this.objects_); + Entry.stateManager && Entry.stateManager.addCommand("add object", this, this.removeObject, c); + c.scene || (c.scene = Entry.scene.selectedScene); + "number" == typeof a ? b.sprite.category && "background" == b.sprite.category.main ? (c.setLock(!0), this.objects_.push(c)) : this.objects_.splice(a, 0, c) : b.sprite.category && "background" == b.sprite.category.main ? this.objects_.push(c) : this.objects_.unshift(c); + c.generateView(); + c.pictures.map(function(a) { + Entry.playground.generatePictureElement(a); + }); + c.sounds.map(function(a) { + Entry.playground.generateSoundElement(a); + }); + this.setCurrentObjects(); + this.updateObjectsOrder(); + this.updateListView(); + this.selectObject(c.id); + Entry.variableContainer.updateViews(); + return new Entry.State(this, this.removeObject, c); }; -Entry.countStringLength = function(a) { - var b, c = 0; - for (b = 0;b < a.length;b++) { - 255 < a.charCodeAt(b) ? c += 2 : c++; - } +Entry.Container.prototype.addCloneObject = function(b, a) { + var c = b.toJSON(), d = Entry.generateHash(); + Entry.variableContainer.addCloneLocalVariables({objectId:c.id, newObjectId:d, json:c}); + c.id = d; + c.scene = a || Entry.scene.selectedScene; + this.addObject(c); +}; +Entry.Container.prototype.removeObject = function(b) { + var a = this.objects_.indexOf(b), c = b.toJSON(); + Entry.stateManager && Entry.stateManager.addCommand("remove object", this, this.addObject, c, a); + c = new Entry.State(this.addObject, c, a); + b.destroy(); + this.objects_.splice(a, 1); + this.setCurrentObjects(); + Entry.stage.sortZorder(); + this.objects_.length && 0 !== a ? 0 < this.getCurrentObjects().length ? Entry.container.selectObject(this.getCurrentObjects()[0].id) : Entry.container.selectObject() : this.objects_.length && 0 === a ? Entry.container.selectObject(this.getCurrentObjects()[0].id) : (Entry.container.selectObject(), Entry.playground.flushPlayground()); + Entry.toast.success(Lang.Workspace.remove_object, b.name + " " + Lang.Workspace.remove_object_msg); + Entry.variableContainer.removeLocalVariables(b.id); + Entry.playground.reloadPlayground(); return c; }; -Entry.cutStringByLength = function(a, b) { - var c, d = 0; - for (c = 0;d < b && c < a.length;c++) { - 255 < a.charCodeAt(c) ? d += 2 : d++; - } - return a.substr(0, c); +Entry.Container.prototype.selectObject = function(b, a) { + var c = this.getObject(b); + a && c && Entry.scene.selectScene(c.scene); + this.mapObjectOnScene(function(a) { + a.view_ && a.view_.removeClass("selectedObject"); + a.isSelected_ = !1; + }); + c && (c.view_ && c.view_.addClass("selectedObject"), c.isSelected_ = !0); + Entry.playground && Entry.playground.injectObject(c); + "minimize" != Entry.type && Entry.engine.isState("stop") && Entry.stage.selectObject(c); }; -Entry.isChild = function(a, b) { - if (!b) { - for (;b.parentNode;) { - if ((b = b.parentNode) == a) { - return !0; - } +Entry.Container.prototype.getAllObjects = function() { + return this.objects_; +}; +Entry.Container.prototype.getObject = function(b) { + !b && Entry.playground && Entry.playground.object && (b = Entry.playground.object.id); + for (var a = this.objects_.length, c = 0;c < a;c++) { + var d = this.objects_[c]; + if (d.id == b) { + return d; } } - return !1; }; -Entry.launchFullScreen = function(a) { - a.requestFullscreen ? a.requestFullscreen() : a.mozRequestFulScreen ? a.mozRequestFulScreen() : a.webkitRequestFullscreen ? a.webkitRequestFullscreen() : a.msRequestFullScreen && a.msRequestFullScreen(); +Entry.Container.prototype.getEntity = function(b) { + if (b = this.getObject(b)) { + return b.entity; + } + Entry.toast.alert(Lang.Msgs.runtime_error, Lang.Workspace.object_not_found, !0); }; -Entry.exitFullScreen = function() { - document.exitFullScreen ? document.exitFullScreen() : document.mozCancelFullScreen ? document.mozCancelFullScreen() : document.webkitExitFullscreen && document.webkitExitFullscreen(); +Entry.Container.prototype.getVariable = function(b) { + for (var a = 0;a < this.variables_.length;a++) { + var c = this.variables_[a]; + if (c.getId() == b || c.getName() == b) { + return c; + } + } }; -Entry.isPhone = function() { - return !1; +Entry.Container.prototype.moveElement = function(b, a, c) { + var d; + d = this.getCurrentObjects(); + b = this.getAllObjects().indexOf(d[b]); + a = this.getAllObjects().indexOf(d[a]); + !c && Entry.stateManager && Entry.stateManager.addCommand("reorder object", Entry.container, Entry.container.moveElement, a, b, !0); + this.objects_.splice(a, 0, this.objects_.splice(b, 1)[0]); + this.setCurrentObjects(); + Entry.container.updateListView(); + Entry.requestUpdate = !0; + return new Entry.State(Entry.container, Entry.container.moveElement, a, b, !0); }; -Entry.getKeyCodeMap = function() { - return {65:"a", 66:"b", 67:"c", 68:"d", 69:"e", 70:"f", 71:"g", 72:"h", 73:"i", 74:"j", 75:"k", 76:"l", 77:"m", 78:"n", 79:"o", 80:"p", 81:"q", 82:"r", 83:"s", 84:"t", 85:"u", 86:"v", 87:"w", 88:"x", 89:"y", 90:"z", 32:Lang.Blocks.START_press_some_key_space, 37:Lang.Blocks.START_press_some_key_left, 38:Lang.Blocks.START_press_some_key_up, 39:Lang.Blocks.START_press_some_key_right, 40:Lang.Blocks.START_press_some_key_down, 48:"0", 49:"1", 50:"2", 51:"3", 52:"4", 53:"5", 54:"6", 55:"7", 56:"8", 57:"9", - 13:Lang.Blocks.START_press_some_key_enter}; +Entry.Container.prototype.moveElementByBlock = function(b, a) { + var c = this.getCurrentObjects().splice(b, 1)[0]; + this.getCurrentObjects().splice(a, 0, c); + Entry.stage.sortZorder(); + this.updateListView(); }; -Entry.checkCollisionRect = function(a, b) { - return !(a.y + a.height < b.y || a.y > b.y + b.height || a.x + a.width < b.x || a.x > b.x + b.width); +Entry.Container.prototype.getDropdownList = function(b) { + var a = []; + switch(b) { + case "sprites": + var c = this.getCurrentObjects(), d = c.length; + for (b = 0;b < d;b++) { + var e = c[b]; + a.push([e.name, e.id]); + } + break; + case "spritesWithMouse": + c = this.getCurrentObjects(); + d = c.length; + for (b = 0;b < d;b++) { + e = c[b], a.push([e.name, e.id]); + } + a.push([Lang.Blocks.mouse_pointer, "mouse"]); + break; + case "spritesWithSelf": + c = this.getCurrentObjects(); + d = c.length; + for (b = 0;b < d;b++) { + e = c[b], a.push([e.name, e.id]); + } + a.push([Lang.Blocks.self, "self"]); + break; + case "collision": + a.push([Lang.Blocks.mouse_pointer, "mouse"]); + c = this.getCurrentObjects(); + d = c.length; + for (b = 0;b < d;b++) { + e = c[b], a.push([e.name, e.id]); + } + a.push([Lang.Blocks.wall, "wall"]); + a.push([Lang.Blocks.wall_up, "wall_up"]); + a.push([Lang.Blocks.wall_down, "wall_down"]); + a.push([Lang.Blocks.wall_right, "wall_right"]); + a.push([Lang.Blocks.wall_left, "wall_left"]); + break; + case "pictures": + if (!Entry.playground.object) { + break; + } + c = Entry.playground.object.pictures; + for (b = 0;b < c.length;b++) { + d = c[b], a.push([d.name, d.id]); + } + break; + case "messages": + c = Entry.variableContainer.messages_; + for (b = 0;b < c.length;b++) { + d = c[b], a.push([d.name, d.id]); + } + break; + case "variables": + c = Entry.variableContainer.variables_; + for (b = 0;b < c.length;b++) { + d = c[b], d.object_ && d.object_ != Entry.playground.object.id || a.push([d.getName(), d.getId()]); + } + a && 0 !== a.length || a.push([Lang.Blocks.VARIABLE_variable, "null"]); + break; + case "lists": + c = Entry.variableContainer.lists_; + for (b = 0;b < c.length;b++) { + d = c[b], a.push([d.getName(), d.getId()]); + } + a && 0 !== a.length || a.push([Lang.Blocks.VARIABLE_list, "null"]); + break; + case "scenes": + c = Entry.scene.scenes_; + for (b = 0;b < c.length;b++) { + d = c[b], a.push([d.name, d.id]); + } + break; + case "sounds": + if (!Entry.playground.object) { + break; + } + c = Entry.playground.object.sounds; + for (b = 0;b < c.length;b++) { + d = c[b], a.push([d.name, d.id]); + } + break; + case "clone": + a.push([Lang.Blocks.oneself, "self"]); + d = this.objects_.length; + for (b = 0;b < d;b++) { + e = this.objects_[b], a.push([e.name, e.id]); + } + break; + case "objectSequence": + for (d = this.getCurrentObjects().length, b = 0;b < d;b++) { + a.push([(b + 1).toString(), b.toString()]); + } + ; + } + a.length || (a = [[Lang.Blocks.no_target, "null"]]); + return a; }; -Entry.bindAnimationCallback = function(a, b) { - a.addEventListener("webkitAnimationEnd", b, !1); - a.addEventListener("animationend", b, !1); - a.addEventListener("oanimationend", b, !1); +Entry.Container.prototype.clearRunningState = function() { + this.mapObject(function(b) { + b.clearExecutor(); + for (var a = b.clonedEntities.length;0 < a;a--) { + b.clonedEntities[a - 1].removeClone(); + } + b.clonedEntities = []; + }); }; -Entry.cloneSimpleObject = function(a) { - var b = {}, c; - for (c in a) { - b[c] = a[c]; +Entry.Container.prototype.mapObject = function(b, a) { + for (var c = this.objects_.length, d = [], e = 0;e < c;e++) { + d.push(b(this.objects_[e], a)); } - return b; + return d; }; -Entry.nodeListToArray = function(a) { - for (var b = Array(a.length), c = -1, d = a.length;++c !== d;b[c] = a[c]) { +Entry.Container.prototype.mapObjectOnScene = function(b, a) { + for (var c = this.getCurrentObjects(), d = c.length, e = [], f = 0;f < d;f++) { + e.push(b(c[f], a)); } - return b; -}; -Entry.computeInputWidth = function(a) { - var b = document.createElement("span"); - b.className = "tmp-element"; - b.innerHTML = a.replace(/&/g, "&").replace(//g, ">"); - document.body.appendChild(b); - a = b.offsetWidth; - document.body.removeChild(b); - return Number(a + 10) + "px"; + return e; }; -Entry.isArrowOrBackspace = function(a) { - return -1 < [37, 38, 39, 40, 8].indexOf(a); +Entry.Container.prototype.clearRunningStateOnScene = function() { + this.mapObjectOnScene(function(b) { + b.clearExecutor(); + for (var a = b.clonedEntities.length;0 < a;a--) { + b.clonedEntities[a - 1].removeClone(); + } + b.clonedEntities = []; + }); }; -Entry.hexStringToBin = function(a) { - for (var b = [], c = 0;c < a.length - 1;c += 2) { - b.push(parseInt(a.substr(c, 2), 16)); +Entry.Container.prototype.mapEntity = function(b, a) { + for (var c = this.objects_.length, d = [], e = 0;e < c;e++) { + d.push(b(this.objects_[e].entity, a)); } - return String.fromCharCode.apply(String, b); + return d; }; -Entry.findObjsByKey = function(a, b, c) { - for (var d = [], e = 0;e < a.length;e++) { - a[e][b] == c && d.push(a[e]); +Entry.Container.prototype.mapEntityOnScene = function(b, a) { + for (var c = this.getCurrentObjects(), d = c.length, e = [], f = 0;f < d;f++) { + e.push(b(c[f].entity, a)); } - return d; + return e; }; -Entry.factorials = []; -Entry.factorial = function(a) { - return 0 === a || 1 == a ? 1 : 0 < Entry.factorials[a] ? Entry.factorials[a] : Entry.factorials[a] = Entry.factorial(a - 1) * a; +Entry.Container.prototype.mapEntityIncludeClone = function(b, a) { + for (var c = this.objects_, d = c.length, e = [], f = 0;f < d;f++) { + var g = c[f], h = g.clonedEntities.length; + e.push(b(g.entity, a)); + for (var k = 0;k < h;k++) { + var l = g.clonedEntities[k]; + l && !l.isStamp && e.push(b(l, a)); + } + } + return e; }; -Entry.getListRealIndex = function(a, b) { - if (isNaN(a)) { - switch(a) { - case "FIRST": - a = 1; - break; - case "LAST": - a = b.array_.length; - break; - case "RANDOM": - a = Math.floor(Math.random() * b.array_.length) + 1; +Entry.Container.prototype.mapEntityIncludeCloneOnScene = function(b, a) { + for (var c = this.getCurrentObjects(), d = c.length, e = [], f = 0;f < d;f++) { + var g = c[f], h = g.clonedEntities.length; + e.push(b(g.entity, a)); + for (var k = 0;k < h;k++) { + var l = g.clonedEntities[k]; + l && !l.isStamp && e.push(b(l, a)); } } - return a; + return e; }; -Entry.toRadian = function(a) { - return a * Math.PI / 180; +Entry.Container.prototype.getCachedPicture = function(b) { + Entry.assert("string" == typeof b, "pictureId must be string"); + return this.cachedPicture[b]; }; -Entry.toDegrees = function(a) { - return 180 * a / Math.PI; +Entry.Container.prototype.cachePicture = function(b, a) { + this.cachedPicture[b] = a; }; -Entry.getPicturesJSON = function(a) { - for (var b = [], c = 0, d = a.length;c < d;c++) { - var e = a[c], f = {}; - f._id = e._id; - f.id = e.id; - f.dimension = e.dimension; - f.filename = e.filename; - f.fileurl = e.fileurl; - f.name = e.name; - f.scale = e.scale; - b.push(f); +Entry.Container.prototype.toJSON = function() { + for (var b = [], a = this.objects_.length, c = 0;c < a;c++) { + b.push(this.objects_[c].toJSON()); } return b; }; -Entry.getSoundsJSON = function(a) { - for (var b = [], c = 0, d = a.length;c < d;c++) { - var e = a[c], f = {}; - f._id = e._id; - f.duration = e.duration; - f.ext = e.ext; - f.id = e.id; - f.filename = e.filename; - f.fileurl = e.fileurl; - f.name = e.name; - b.push(f); +Entry.Container.prototype.takeSequenceSnapshot = function() { + for (var b = this.objects_.length, a = this.objects_, c = 0;c < b;c++) { + a[c].index = c; } - return b; -}; -Entry.cutDecimal = function(a) { - return Math.round(100 * a) / 100; }; -Entry.getBrowserType = function() { - if (Entry.userAgent) { - return Entry.userAgent; - } - var a = navigator.userAgent, b, c = a.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || []; - if (/trident/i.test(c[1])) { - return b = /\brv[ :]+(\d+)/g.exec(a) || [], "IE " + (b[1] || ""); - } - if ("Chrome" === c[1] && (b = a.match(/\b(OPR|Edge)\/(\d+)/), null != b)) { - return b.slice(1).join(" ").replace("OPR", "Opera"); +Entry.Container.prototype.loadSequenceSnapshot = function() { + for (var b = this.objects_.length, a = Array(b), c = 0;c < b;c++) { + var d = this.objects_[c]; + a[d.index] = d; + delete d.index; } - c = c[2] ? [c[1], c[2]] : [navigator.appName, navigator.appVersion, "-?"]; - null != (b = a.match(/version\/(\d+)/i)) && c.splice(1, 1, b[1]); - a = c.join(" "); - return Entry.userAgent = a; -}; -Entry.setBasicBrush = function(a) { - var b = new createjs.Graphics; - b.thickness = 1; - b.rgb = Entry.hex2rgb("#ff0000"); - b.opacity = 100; - b.setStrokeStyle(1); - b.beginStroke("rgba(255,0,0,1)"); - var c = new createjs.Shape(b); - Entry.stage.selectedObjectContainer.addChild(c); - a.brush && (a.brush = null); - a.brush = b; - a.shape && (a.shape = null); - a.shape = c; + this.objects_ = a; + this.setCurrentObjects(); + Entry.stage.sortZorder(); + this.updateListView(); }; -Entry.setCloneBrush = function(a, b) { - var c = new createjs.Graphics; - c.thickness = b.thickness; - c.rgb = b.rgb; - c.opacity = b.opacity; - c.setStrokeStyle(c.thickness); - c.beginStroke("rgba(" + c.rgb.r + "," + c.rgb.g + "," + c.rgb.b + "," + c.opacity / 100 + ")"); - b = new createjs.Shape(c); - Entry.stage.selectedObjectContainer.addChild(b); - a.brush && (a.brush = null); - a.brush = c; - a.shape && (a.shape = null); - a.shape = b; +Entry.Container.prototype.getInputValue = function() { + return this.inputValue.getValue(); }; -Entry.isFloat = function(a) { - return /\d+\.{1}\d+/.test(a); +Entry.Container.prototype.setInputValue = function(b) { + b ? this.inputValue.setValue(b) : this.inputValue.setValue(0); }; -Entry.getStringIndex = function(a) { - if (!a) { - return ""; - } - for (var b = {string:a, index:1}, c = 0, d = [], e = a.length - 1;0 < e;--e) { - var f = a.charAt(e); - if (isNaN(f)) { - break; - } else { - d.unshift(f), c = e; - } - } - 0 < c && (b.string = a.substring(0, c), b.index = parseInt(d.join("")) + 1); - return b; +Entry.Container.prototype.resetSceneDuringRun = function() { + this.mapEntityOnScene(function(b) { + b.loadSnapshot(); + b.object.filters = []; + b.resetFilter(); + b.dialog && b.dialog.remove(); + b.shape && b.removeBrush(); + }); + this.clearRunningStateOnScene(); }; -Entry.getOrderedName = function(a, b, c) { - if (!a) { - return "untitled"; - } - if (!b || 0 === b.length) { - return a; - } - c || (c = "name"); - for (var d = 0, e = Entry.getStringIndex(a), f = 0, g = b.length;f < g;f++) { - var h = Entry.getStringIndex(b[f][c]); - e.string === h.string && h.index > d && (d = h.index); - } - return 0 < d ? e.string + d : a; +Entry.Container.prototype.setCopiedObject = function(b) { + this.copiedObject = b; }; -Entry.changeXmlHashId = function(a) { - if (/function_field/.test(a.getAttribute("type"))) { - for (var b = a.getElementsByTagName("mutation"), c = 0, d = b.length;c < d;c++) { - b[c].setAttribute("hashid", Entry.generateHash()); +Entry.Container.prototype.updateObjectsOrder = function() { + for (var b = Entry.scene.getScenes(), a = [], c = 0;c < b.length;c++) { + for (var d = this.getSceneObjects(b[c]), e = 0;e < d.length;e++) { + a.push(d[e]); } } - return a; + this.objects_ = a; }; -Entry.getMaxFloatPoint = function(a) { - for (var b = 0, c = 0, d = a.length;c < d;c++) { - var e = String(a[c]), f = e.indexOf("."); - -1 !== f && (e = e.length - (f + 1), e > b && (b = e)); +Entry.Container.prototype.getSceneObjects = function(b) { + b = b || Entry.scene.selectedScene; + for (var a = [], c = this.getAllObjects(), d = 0;d < c.length;d++) { + b.id == c[d].scene.id && a.push(c[d]); } - return Math.min(b, 20); + return a; }; -Entry.convertToRoundedDecimals = function(a, b) { - return isNaN(a) || !this.isFloat(a) ? a : Number(Math.round(a + "e" + b) + "e-" + b); +Entry.Container.prototype.setCurrentObjects = function() { + this.currentObjects_ = this.getSceneObjects(); }; -Entry.attachEventListener = function(a, b, c) { - setTimeout(function() { - a.addEventListener(b, c); - }, 0); +Entry.Container.prototype.getCurrentObjects = function() { + var b = this.currentObjects_; + b && 0 !== b.length || this.setCurrentObjects(); + return this.currentObjects_; }; -Entry.deAttachEventListener = function(a, b, c) { - a.removeEventListener(b, c); +Entry.Container.prototype.getProjectWithJSON = function(b) { + b.objects = Entry.container.toJSON(); + b.variables = Entry.variableContainer.getVariableJSON(); + b.messages = Entry.variableContainer.getMessageJSON(); + b.scenes = Entry.scene.toJSON(); + return b; }; -Entry.isEmpty = function(a) { - if (!a) { - return !0; - } - for (var b in a) { - if (a.hasOwnProperty(b)) { - return !1; +Entry.Container.prototype.blurAllInputs = function() { + this.getSceneObjects().map(function(b) { + b = b.view_.getElementsByTagName("input"); + for (var a = 0, c = b.length;a < c;a++) { + b[a].blur(); } - } - return !0; -}; -Entry.Utils.disableContextmenu = function(a) { - if (a) { - $(a).on("contextmenu", function(b) { - b.stopPropagation(); - b.preventDefault(); - return !1; - }); - } -}; -Entry.Utils.isRightButton = function(a) { - return 2 == a.button || a.ctrlKey; + }); }; -Entry.Utils.isTouchEvent = function(a) { - return "mousedown" !== a.type.toLowerCase(); +Entry.Container.prototype.showProjectAnswer = function() { + var b = this.inputValue; + b && b.setVisible(!0); }; -Entry.Utils.inherit = function(a, b) { - function c() { +Entry.Container.prototype.hideProjectAnswer = function(b) { + if ((b = this.inputValue) && b.isVisible() && !Entry.engine.isState("run")) { + for (var a = Entry.container.getAllObjects(), c = ["ask_and_wait", "get_canvas_input_value", "set_visible_answer"], d = 0, e = a.length;d < e;d++) { + for (var f = a[d].script, g = 0;g < c.length;g++) { + if (f.hasBlockType(c[g])) { + return; + } + } + } + b.setVisible(!1); } - c.prototype = a.prototype; - b.prototype = new c; - return b; }; -Entry.bindAnimationCallbackOnce = function(a, b) { - a.one("webkitAnimationEnd animationendo animationend", b); -}; -Entry.Utils.isInInput = function(a) { - return "textarea" == a.target.type || "text" == a.target.type; -}; -Entry.Utils.isFunction = function(a) { - return "function" === typeof a; -}; -Entry.Utils.addFilters = function(a, b) { - a = a.elem("defs"); - var c = a.elem("filter", {id:"entryTrashcanFilter_" + b}); - c.elem("feGaussianBlur", {"in":"SourceAlpha", stdDeviation:2, result:"blur"}); - c.elem("feOffset", {"in":"blur", dx:1, dy:1, result:"offsetBlur"}); - c = c.elem("feMerge"); - c.elem("feMergeNode", {"in":"offsetBlur"}); - c.elem("feMergeNode", {"in":"SourceGraphic"}, c); - c = a.elem("filter", {id:"entryBlockShadowFilter_" + b, height:"200%"}); - c.elem("feOffset", {result:"offOut", in:"SourceGraphic", dx:0, dy:1}); - c.elem("feColorMatrix", {result:"matrixOut", in:"offOut", type:"matrix", values:"0.7 0 0 0 0 0 0.7 0 0 0 0 0 0.7 0 0 0 0 0 1 0"}); - c.elem("feBlend", {in:"SourceGraphic", in1:"offOut", mode:"normal"}); - b = a.elem("filter", {id:"entryBlockHighlightFilter_" + b}); - b.elem("feOffset", {result:"offOut", in:"SourceGraphic", dx:0, dy:0}); - b.elem("feColorMatrix", {result:"matrixOut", in:"offOut", type:"matrix", values:"1.3 0 0 0 0 0 1.3 0 0 0 0 0 1.3 0 0 0 0 0 1 0"}); -}; -Entry.Utils.addBlockPattern = function(a, b) { - a = a.elem("pattern", {id:"blockHoverPattern_" + b, class:"blockHoverPattern", patternUnits:"userSpaceOnUse", patternTransform:"translate(12, 0)", x:0, y:0, width:125, height:33, style:"display: none"}); - b = a.elem("g"); - for (var c = b.elem("rect", {x:0, y:0, width:125, height:33}), d = Entry.mediaFilePath + "block_pattern_(order).png", e = 1;5 > e;e++) { - b.elem("image", {class:"pattern" + e, href:d.replace("(order)", e), x:0, y:0, width:125, height:33}); - } - return {pattern:a, rect:c}; +Entry.Container.prototype.getView = function() { + return this._view; }; -Entry.Utils.COLLISION = {NONE:0, UP:1, RIGHT:2, LEFT:3, DOWN:4}; -Entry.Utils.createMouseEvent = function(a, b) { - var c = document.createEvent("MouseEvent"); - c.initMouseEvent(a, !0, !0, window, 0, 0, 0, b.clientX, b.clientY, !1, !1, !1, !1, 0, null); - return c; -}; -Entry.Utils.xmlToJsonData = function(a) { - a = $.parseXML(a); - var b = []; - a = a.childNodes[0].childNodes; - for (var c in a) { - var d = a[c]; - if (d.tagName) { - var e = {category:d.getAttribute("id"), blocks:[]}, d = d.childNodes; - for (c in d) { - var f = d[c]; - f.tagName && (f = f.getAttribute("type")) && e.blocks.push(f); - } - b.push(e); - } - } - return b; -}; -Entry.Utils.stopProjectWithToast = function(a, b) { - b = b || "\ub7f0\ud0c0\uc784 \uc5d0\ub7ec \ubc1c\uc0dd"; - Entry.toast && Entry.toast.alert(Lang.Msgs.warn, Lang.Workspace.check_runtime_error, !0); - Entry.engine && Entry.engine.toggleStop(); - "workspace" === Entry.type && (Entry.container.selectObject(a.getCode().object.id, !0), a.view.getBoard().activateBlock(a)); - throw Error(b); -}; -window.requestAnimFrame = function() { - return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function(a) { - window.setTimeout(a, 1E3 / 60); - }; -}(); -Entry.Model = function(a, b) { - var c = Entry.Model; - c.generateSchema(a); - c.generateSetter(a); - c.generateObserve(a); - (void 0 === b || b) && Object.seal(a); - return a; +Entry.Container.prototype.resize = function() { }; -(function(a) { - a.generateSchema = function(b) { - var a = b.schema; - if (void 0 !== a) { - a = JSON.parse(JSON.stringify(a)); - b.data = {}; - for (var d in a) { - (function(d) { - b.data[d] = a[d]; - Object.defineProperty(b, d, {get:function() { - return b.data[d]; - }}); - })(d); - } - b._toJSON = this._toJSON; - } - }; - a.generateSetter = function(b) { - b.set = this.set; - }; - a.set = function(b, a) { - var d = {}, e; - for (e in this.data) { - void 0 !== b[e] && (b[e] === this.data[e] ? delete b[e] : (d[e] = this.data[e], this.data[e] = b[e] instanceof Array ? b[e].concat() : b[e])); - } - a || this.notify(Object.keys(b), d); - }; - a.generateObserve = function(b) { - b.observers = []; - b.observe = this.observe; - b.unobserve = this.unobserve; - b.notify = this.notify; +Entry.db = {data:{}, typeMap:{}}; +(function(b) { + b.add = function(a) { + this.data[a.id] = a; + var b = a.type; + void 0 === this.typeMap[b] && (this.typeMap[b] = {}); + this.typeMap[b][a.id] = a; }; - a.observe = function(b, a, d, e) { - d = new Entry.Observer(this.observers, b, a, d); - if (!1 !== e) { - b[a]([]); - } - return d; + b.has = function(a) { + return this.data.hasOwnProperty(a); }; - a.unobserve = function(b) { - b.destroy(); + b.remove = function(a) { + this.has(a) && (delete this.typeMap[this.data[a].type][a], delete this.data[a]); }; - a.notify = function(b, a) { - "string" === typeof b && (b = [b]); - var d = this; - d.observers.map(function(e) { - var f = b; - void 0 !== e.attrs && (f = Entry.Utils.intersectArray(e.attrs, b)); - if (f.length) { - e.object[e.funcName](f.map(function(b) { - return {name:b, object:d, oldValue:a[b]}; - })); - } - }); + b.get = function(a) { + return this.data[a]; }; - a._toJSON = function() { - var b = {}, a; - for (a in this.data) { - b[a] = this.data[a]; - } - return b; + b.find = function() { }; -})(Entry.Model); -Entry.Observer = function(a, b, c, d) { - this.parent = a; - this.object = b; - this.funcName = c; - this.attrs = d; - a.push(this); -}; -(function(a) { - a.destroy = function() { - var b = this.parent, a = b.indexOf(this); - -1 < a && b.splice(a, 1); - return this; + b.clear = function() { + this.data = {}; + this.typeMap = {}; }; -})(Entry.Observer.prototype); -Entry.Command = {}; -(function(a) { - a["do"] = {type:EntryStatic.COMMAND_TYPES["do"], log:function(b) { - return [a["do"].type]; - }}; - a.undo = {type:EntryStatic.COMMAND_TYPES.undo, log:function(b) { - return [a.undo.type]; - }}; - a.redo = {type:EntryStatic.COMMAND_TYPES.redo, log:function(b) { - return [a.redo.type]; - }}; -})(Entry.Command); -Entry.Commander = function(a) { - if ("workspace" == a || "phone" == a) { - Entry.stateManager = new Entry.StateManager; +})(Entry.db); +Entry.Dom = function(b, a) { + var c = /<(\w+)>/, d; + d = b instanceof HTMLElement ? $(b) : b instanceof jQuery ? b : c.test(b) ? $(b) : $("<" + b + ">"); + if (void 0 === a) { + return d; } - Entry.do = this.do.bind(this); - Entry.undo = this.undo.bind(this); - this.editor = {}; - this.reporters = []; - this._tempStorage = null; - Entry.Command.editor = this.editor; -}; -(function(a) { - a.do = function(b) { - var a = this, d = Array.prototype.slice.call(arguments); - d.shift(); - var e = Entry.Command[b]; - Entry.stateManager && Entry.stateManager.addCommand.apply(Entry.stateManager, [b, this, this.do, e.undo].concat(e.state.apply(this, d))); - e = Entry.Command[b].do.apply(this, d); - setTimeout(function() { - a.report("do"); - a.report(b, d); - }, 0); - return {value:e, isPass:this.isPass.bind(this)}; - }; - a.undo = function() { - var b = Array.prototype.slice.call(arguments), a = b.shift(), d = Entry.Command[a]; - this.report("undo"); - Entry.stateManager && Entry.stateManager.addCommand.apply(Entry.stateManager, [a, this, this.do, d.undo].concat(d.state.apply(this, b))); - return {value:Entry.Command[a].do.apply(this, b), isPass:this.isPass.bind(this)}; - }; - a.redo = function() { - var b = Array.prototype.slice.call(arguments), a = b.shift(), d = Entry.Command[a]; - that.report("redo"); - Entry.stateManager && Entry.stateManager.addCommand.apply(Entry.stateManager, [a, this, this.undo, a].concat(d.state.apply(null, b))); - d.undo.apply(this, b); - }; - a.setCurrentEditor = function(b, a) { - this.editor[b] = a; - }; - a.isPass = function(b) { - b = void 0 === b ? !0 : b; - if (Entry.stateManager) { - var a = Entry.stateManager.getLastCommand(); - a && (a.isPass = b); - } - }; - a.addReporter = function(b) { - this.reporters.push(b); - }; - a.removeReporter = function(b) { - b = this.reporters.indexOf(b); - -1 < b && this.reporters.splice(b, 1); - }; - a.report = function(b, a) { - var d = this.reporters; - if (0 !== d.length) { - var e; - e = b && Entry.Command[b] && Entry.Command[b].log ? Entry.Command[b].log.apply(this, a) : a; - d.forEach(function(b) { - b.add(e); - }); + a.id && d.attr("id", a.id); + a.class && d.addClass(a.class); + a.classes && a.classes.map(function(a) { + d.addClass(a); + }); + a.src && d.attr("src", a.src); + a.parent && a.parent.append(d); + d.bindOnClick = function() { + var a, b, c = function(a) { + a.stopImmediatePropagation(); + a.handled || (a.handled = !0, b.call(this, a)); + }; + 1 < arguments.length ? (b = arguments[1] instanceof Function ? arguments[1] : function() { + }, a = "string" === typeof arguments[0] ? arguments[0] : "") : b = arguments[0] instanceof Function ? arguments[0] : function() { + }; + if (a) { + $(this).on("click tab", a, c); + } else { + $(this).on("click tab", c); } }; -})(Entry.Commander.prototype); -(function(a) { - a.addThread = {type:EntryStatic.COMMAND_TYPES.addThread, do:function(b) { - return this.editor.board.code.createThread(b); - }, state:function(b) { - b.length && (b[0].id = Entry.Utils.generateId()); - return [b]; - }, log:function(b) { - b = this.editor.board.code.getThreads().pop(); - return [a.addThread.type, ["thread", b.stringify()], ["code", this.editor.board.code.stringify()]]; - }, undo:"destroyThread"}; - a.destroyThread = {type:EntryStatic.COMMAND_TYPES.destroyThread, do:function(b) { - this.editor.board.findById(b[0].id).destroy(!0, !0); - }, state:function(b) { - return [this.editor.board.findById(b[0].id).thread.toJSON()]; - }, log:function(b) { - b = b[0].id; - this.editor.board.findById(b); - return [a.destroyThread.type, ["blockId", b], ["code", this.editor.board.code.stringify()]]; - }, undo:"addThread"}; - a.destroyBlock = {type:EntryStatic.COMMAND_TYPES.destroyBlock, do:function(b) { - "string" === typeof b && (b = this.editor.board.findById(b)); - b.doDestroy(!0); - }, state:function(b) { - "string" === typeof b && (b = this.editor.board.findById(b)); - return [b.toJSON(), b.pointer()]; - }, log:function(b) { - "string" === typeof b && (b = this.editor.board.findById(b)); - return [a.destroyBlock.type, ["blockId", b.id], ["code", this.editor.board.code.stringify()]]; - }, undo:"recoverBlock"}; - a.recoverBlock = {type:EntryStatic.COMMAND_TYPES.recoverBlock, do:function(b, a) { - b = this.editor.board.code.createThread([b]).getFirstBlock(); - "string" === typeof b && (b = this.editor.board.findById(b)); - this.editor.board.insert(b, a); - }, state:function(b) { - "string" !== typeof b && (b = b.id); - return [b]; - }, log:function(b, c) { - b = this.editor.board.findById(b.id); - return [a.recoverBlock.type, ["block", b.stringify()], ["pointer", c], ["code", this.editor.board.code.stringify()]]; - }, undo:"destroyBlock"}; - a.insertBlock = {type:EntryStatic.COMMAND_TYPES.insertBlock, do:function(b, a, d) { - "string" === typeof b && (b = this.editor.board.findById(b)); - this.editor.board.insert(b, a, d); - }, state:function(b, a) { - "string" === typeof b && (b = this.editor.board.findById(b)); - a = [b.id]; - var d = b.targetPointer(); - a.push(d); - "string" !== typeof b && "basic" === b.getBlockType() && a.push(b.thread.getCount(b)); - return a; - }, log:function(b, c, d) { - "string" === typeof b && (b = this.editor.board.findById(b)); - return [a.insertBlock.type, ["blockId", b.id], ["targetPointer", b.targetPointer()], ["count", d], ["code", this.editor.board.code.stringify()]]; - }, undo:"insertBlock"}; - a.separateBlock = {type:EntryStatic.COMMAND_TYPES.separateBlock, do:function(b) { - b.view && b.view._toGlobalCoordinate(Entry.DRAG_MODE_DRAG); - b.doSeparate(); - }, state:function(b) { - var a = [b.id], d = b.targetPointer(); - a.push(d); - "basic" === b.getBlockType() && a.push(b.thread.getCount(b)); - return a; - }, log:function(b) { - "string" === typeof b && (b = this.editor.board.findById(b)); - return [a.separateBlock.type, ["blockId", b.id], ["x", b.x], ["y", b.y], ["code", this.editor.board.code.stringify()]]; - }, undo:"insertBlock"}; - a.moveBlock = {type:EntryStatic.COMMAND_TYPES.moveBlock, do:function(b, a, d) { - void 0 !== a ? (b = this.editor.board.findById(b), b.moveTo(a, d)) : b._updatePos(); - }, state:function(b) { - "string" === typeof b && (b = this.editor.board.findById(b)); - return [b.id, b.x, b.y]; - }, log:function(b, c, d) { - return [a.moveBlock.type, ["blockId", b.id], ["x", b.x], ["y", b.y], ["code", this.editor.board.code.stringify()]]; - }, undo:"moveBlock"}; - a.cloneBlock = {type:EntryStatic.COMMAND_TYPES.cloneBlock, do:function(b) { - "string" === typeof b && (b = this.editor.board.findById(b)); - this.editor.board.code.createThread(b.copy()); - }, state:function(b) { - "string" !== typeof b && (b = b.id); - return [b]; - }, log:function(b) { - "string" === typeof b && (b = this.editor.board.findById(b)); - var c = this.editor.board.code.getThreads().pop(); - return [a.cloneBlock.type, ["blockId", b.id], ["thread", c.stringify()], ["code", this.editor.board.code.stringify()]]; - }, undo:"uncloneBlock"}; - a.uncloneBlock = {type:EntryStatic.COMMAND_TYPES.uncloneBlock, do:function(b) { - b = this.editor.board.code.getThreads().pop().getFirstBlock(); - this._tempStorage = b.id; - b.destroy(!0, !0); - }, state:function(b) { - return [b]; - }, log:function(b) { - b = this._tempStorage; - this._tempStorage = null; - return [a.uncloneBlock.type, ["blockId", b], ["code", this.editor.board.code.stringify()]]; - }, undo:"cloneBlock"}; - a.scrollBoard = {type:EntryStatic.COMMAND_TYPES.scrollBoard, do:function(b, a, d) { - d || this.editor.board.scroller._scroll(b, a); - delete this.editor.board.scroller._diffs; - }, state:function(b, a) { - return [-b, -a]; - }, log:function(b, c) { - return [a.scrollBoard.type, ["dx", b], ["dy", c]]; - }, undo:"scrollBoard"}; - a.setFieldValue = {type:EntryStatic.COMMAND_TYPES.setFieldValue, do:function(b, a, d, e, f) { - a.setValue(f, !0); - }, state:function(b, a, d, e, f) { - return [b, a, d, f, e]; - }, log:function(b, c, d, e, f) { - return [a.setFieldValue.type, ["pointer", d], ["newValue", f], ["code", this.editor.board.code.stringify()]]; - }, undo:"setFieldValue"}; -})(Entry.Command); -(function(a) { - a.selectObject = {type:EntryStatic.COMMAND_TYPES.selectObject, do:function(b) { - return Entry.container.selectObject(b); - }, state:function(b) { - if ((b = Entry.playground) && b.object) { - return [b.object.id]; - } - }, log:function(b) { - return [b]; - }, undo:"selectObject"}; -})(Entry.Command); -Entry.Container = function() { - this.objects_ = []; - this.cachedPicture = {}; - this.inputValue = {}; - this.currentObjects_ = this.copiedObject = null; -}; -Entry.Container.prototype.generateView = function(a, b) { - this._view = a; - this._view.addClass("entryContainer"); - b && "workspace" != b ? "phone" == b && (this._view.addClass("entryContainerPhone"), a = Entry.createElement("div"), a.addClass("entryAddObjectWorkspace"), a.innerHTML = Lang.Workspace.add_object, a.bindOnClick(function(b) { - Entry.dispatchEvent("openSpriteManager"); - }), a = Entry.createElement("div"), a.addClass("entryContainerListPhoneWrapper"), this._view.appendChild(a), b = Entry.createElement("ul"), b.addClass("entryContainerListPhone"), a.appendChild(b), this.listView_ = b) : (this._view.addClass("entryContainerWorkspace"), this._view.setAttribute("id", "entryContainerWorkspaceId"), a = Entry.createElement("div"), a.addClass("entryAddObjectWorkspace"), a.innerHTML = Lang.Workspace.add_object, a.bindOnClick(function(b) { - Entry.dispatchEvent("openSpriteManager"); - }), a = Entry.createElement("div"), a.addClass("entryContainerListWorkspaceWrapper"), Entry.isForLecture && a.addClass("lecture"), Entry.Utils.disableContextmenu(a), $(a).on("contextmenu", function(b) { - b = [{text:Lang.Blocks.Paste_blocks, enable:!Entry.engine.isState("run") && !!Entry.container.copiedObject, callback:function() { - Entry.container.copiedObject ? Entry.container.addCloneObject(Entry.container.copiedObject) : Entry.toast.alert(Lang.Workspace.add_object_alert, Lang.Workspace.object_not_found_for_paste); - }}]; - Entry.ContextMenu.show(b, "workspace-contextmenu"); - }), this._view.appendChild(a), b = Entry.createElement("ul"), b.addClass("entryContainerListWorkspace"), a.appendChild(b), this.listView_ = b, this.enableSort()); -}; -Entry.Container.prototype.enableSort = function() { - $ && $(this.listView_).sortable({start:function(a, b) { - b.item.data("start_pos", b.item.index()); - }, stop:function(a, b) { - a = b.item.data("start_pos"); - b = b.item.index(); - Entry.container.moveElement(a, b); - }, axis:"y", cancel:"input.selectedEditingObject"}); + return d; }; -Entry.Container.prototype.disableSort = function() { - $ && $(this.listView_).sortable("destroy"); +Entry.SVG = function(b) { + b = document.getElementById(b); + return Entry.SVG.createElement(b); }; -Entry.Container.prototype.updateListView = function() { - if (this.listView_) { - for (var a = this.listView_;a.hasChildNodes();) { - a.removeChild(a.lastChild); - } - var b = this.getCurrentObjects(), c; - for (c in b) { - a.appendChild(b[c].view_); +Entry.SVG.NS = "http://www.w3.org/2000/svg"; +Entry.SVG.NS_XLINK = "http://www.w3.org/1999/xlink"; +Entry.SVG.createElement = function(b, a) { + var c; + c = "string" === typeof b ? document.createElementNS(Entry.SVG.NS, b) : b; + if (a) { + a.href && (c.setAttributeNS(Entry.SVG.NS_XLINK, "href", a.href), delete a.href); + for (var d in a) { + c.setAttribute(d, a[d]); } - Entry.stage.sortZorder(); } + this instanceof SVGElement && this.appendChild(c); + c.elem = Entry.SVG.createElement; + c.attr = Entry.SVG.attr; + c.addClass = Entry.SVG.addClass; + c.removeClass = Entry.SVG.removeClass; + c.hasClass = Entry.SVG.hasClass; + c.remove = Entry.SVG.remove; + c.removeAttr = Entry.SVG.removeAttr; + return c; }; -Entry.Container.prototype.setObjects = function(a) { - for (var b in a) { - var c = new Entry.EntryObject(a[b]); - this.objects_.push(c); - c.generateView(); - c.pictures.map(function(b) { - Entry.playground.generatePictureElement(b); - }); - c.sounds.map(function(b) { - Entry.playground.generateSoundElement(b); - }); +Entry.SVG.attr = function(b, a) { + if ("string" === typeof b) { + var c = {}; + c[b] = a; + b = c; } - this.updateObjectsOrder(); - this.updateListView(); - Entry.stage.sortZorder(); - Entry.variableContainer.updateViews(); - a = Entry.type; - ("workspace" == a || "phone" == a) && (a = this.getCurrentObjects()[0]) && this.selectObject(a.id); -}; -Entry.Container.prototype.getPictureElement = function(a, b) { - if (a = this.getObject(b).getPicture(a)) { - return a.view; + if (b) { + b.href && (this.setAttributeNS(Entry.SVG.NS_XLINK, "href", b.href), delete b.href); + for (var d in b) { + this.setAttribute(d, b[d]); + } } - throw Error("No picture found"); + return this; }; -Entry.Container.prototype.setPicture = function(a) { - var b = this.getObject(a.objectId), c; - for (c in b.pictures) { - if (a.id === b.pictures[c].id) { - var d = {}; - d.dimension = a.dimension; - d.id = a.id; - d.filename = a.filename; - d.fileurl = a.fileurl; - d.name = a.name; - d.view = b.pictures[c].view; - b.pictures[c] = d; - return; - } +Entry.SVG.addClass = function(b) { + for (var a = this.getAttribute("class"), c = 0;c < arguments.length;c++) { + b = arguments[c], this.hasClass(b) || (a += " " + b); } - throw Error("No picture found"); + this.setAttribute("class", a); + return this; }; -Entry.Container.prototype.selectPicture = function(a, b) { - b = this.getObject(b); - if (a = b.getPicture(a)) { - return b.selectedPicture = a, b.entity.setImage(a), b.updateThumbnailView(), b.id; +Entry.SVG.removeClass = function(b) { + for (var a = this.getAttribute("class"), c = 0;c < arguments.length;c++) { + b = arguments[c], this.hasClass(b) && (a = a.replace(new RegExp("(\\s|^)" + b + "(\\s|$)"), " ")); } - throw Error("No picture found"); + this.setAttribute("class", a); + return this; }; -Entry.Container.prototype.addObject = function(a, b) { - var c = new Entry.EntryObject(a); - c.name = Entry.getOrderedName(c.name, this.objects_); - Entry.stateManager && Entry.stateManager.addCommand("add object", this, this.removeObject, c); - c.scene || (c.scene = Entry.scene.selectedScene); - "number" == typeof b ? a.sprite.category && "background" == a.sprite.category.main ? (c.setLock(!0), this.objects_.push(c)) : this.objects_.splice(b, 0, c) : a.sprite.category && "background" == a.sprite.category.main ? this.objects_.push(c) : this.objects_.unshift(c); - c.generateView(); - c.pictures.map(function(b) { - Entry.playground.generatePictureElement(b); - }); - c.sounds.map(function(b) { - Entry.playground.generateSoundElement(b); - }); - this.setCurrentObjects(); - this.updateObjectsOrder(); - this.updateListView(); - this.selectObject(c.id); - Entry.variableContainer.updateViews(); - return new Entry.State(this, this.removeObject, c); +Entry.SVG.hasClass = function(b) { + var a = this.getAttribute("class"); + return a ? a.match(new RegExp("(\\s|^)" + b + "(\\s|$)")) : !1; }; -Entry.Container.prototype.addCloneObject = function(a, b) { - a = a.toJSON(); - var c = Entry.generateHash(); - Entry.variableContainer.addCloneLocalVariables({objectId:a.id, newObjectId:c, json:a}); - a.id = c; - a.scene = b || Entry.scene.selectedScene; - this.addObject(a); -}; -Entry.Container.prototype.removeObject = function(a) { - var b = this.objects_.indexOf(a), c = a.toJSON(); - Entry.stateManager && Entry.stateManager.addCommand("remove object", this, this.addObject, c, b); - c = new Entry.State(this.addObject, c, b); - a.destroy(); - this.objects_.splice(b, 1); - this.setCurrentObjects(); - Entry.stage.sortZorder(); - this.objects_.length && 0 !== b ? 0 < this.getCurrentObjects().length ? Entry.container.selectObject(this.getCurrentObjects()[0].id) : Entry.container.selectObject() : this.objects_.length && 0 === b ? Entry.container.selectObject(this.getCurrentObjects()[0].id) : (Entry.container.selectObject(), Entry.playground.flushPlayground()); - Entry.toast.success(Lang.Workspace.remove_object, a.name + " " + Lang.Workspace.remove_object_msg); - Entry.variableContainer.removeLocalVariables(a.id); - Entry.playground.reloadPlayground(); - return c; +Entry.SVG.remove = function() { + this.parentNode && this.parentNode.removeChild(this); }; -Entry.Container.prototype.selectObject = function(a, b) { - a = this.getObject(a); - b && a && Entry.scene.selectScene(a.scene); - this.mapObjectOnScene(function(b) { - b.view_ && b.view_.removeClass("selectedObject"); - b.isSelected_ = !1; - }); - a && (a.view_ && a.view_.addClass("selectedObject"), a.isSelected_ = !0); - Entry.playground && Entry.playground.injectObject(a); - "minimize" != Entry.type && Entry.engine.isState("stop") && Entry.stage.selectObject(a); +Entry.SVG.removeAttr = function(b) { + this.removeAttribute(b); }; -Entry.Container.prototype.getAllObjects = function() { - return this.objects_; +Entry.Dialog = function(b, a, c, d) { + b.dialog && b.dialog.remove(); + b.dialog = this; + this.parent = b; + this.padding = 10; + this.border = 2; + "number" == typeof a && (a = String(a)); + this.message_ = a = a.match(/.{1,15}/g).join("\n"); + this.mode_ = c; + "speak" == c && this.generateSpeak(); + d || Entry.stage.loadDialog(this); }; -Entry.Container.prototype.getObject = function(a) { - !a && Entry.playground && Entry.playground.object && (a = Entry.playground.object.id); - for (var b = this.objects_.length, c = 0;c < b;c++) { - var d = this.objects_[c]; - if (d.id == a) { - return d; - } - } +Entry.Dialog.prototype.generateSpeak = function() { + this.object = new createjs.Container; + var b = new createjs.Text; + b.font = "15px NanumGothic"; + b.textBaseline = "top"; + b.textAlign = "left"; + b.text = this.message_; + var a = b.getTransformedBounds(), c = a.height, a = 10 <= a.width ? a.width : 17, d = new createjs.Shape; + d.graphics.f("#f5f5f5").ss(2, "round").s("#6FC0DD").rr(-this.padding, -this.padding, a + 2 * this.padding, c + 2 * this.padding, this.padding); + this.object.addChild(d); + this.object.regX = a / 2; + this.object.regY = c / 2; + this.width = a; + this.height = c; + this.notch = this.createSpeakNotch("ne"); + this.update(); + this.object.addChild(this.notch); + this.object.addChild(b); + Entry.requestUpdate = !0; }; -Entry.Container.prototype.getEntity = function(a) { - if (a = this.getObject(a)) { - return a.entity; - } - Entry.toast.alert(Lang.Msgs.runtime_error, Lang.Workspace.object_not_found, !0); +Entry.Dialog.prototype.update = function() { + var b = this.parent.object.getTransformedBounds(), a = ""; + -135 < b.y - this.height - 20 - this.border ? (this.object.y = b.y - this.height / 2 - 20 - this.padding, a += "n") : (this.object.y = b.y + b.height + this.height / 2 + 20 + this.padding, a += "s"); + 240 > b.x + b.width + this.width ? (this.object.x = b.x + b.width + this.width / 2, a += "e") : (this.object.x = b.x - this.width / 2, a += "w"); + this.notch.type != a && (this.object.removeChild(this.notch), this.notch = this.createSpeakNotch(a), this.object.addChild(this.notch)); + Entry.requestUpdate = !0; }; -Entry.Container.prototype.getVariable = function(a) { - for (var b = 0;b < this.variables_.length;b++) { - var c = this.variables_[b]; - if (c.getId() == a || c.getName() == a) { - return c; - } - } +Entry.Dialog.prototype.createSpeakNotch = function(b) { + var a = new createjs.Shape; + a.type = b; + "ne" == b ? a.graphics.f("#f5f5f5").ss(2, "round").s("#6FC0DD").mt(0, this.height + this.padding - 1.5).lt(-10, this.height + this.padding + 20).lt(20, this.height + this.padding - 1.5) : "nw" == b ? a.graphics.f("#f5f5f5").ss(2, "round").s("#6FC0DD").mt(this.width, this.height + this.padding - 1.5).lt(this.width + 10, this.height + this.padding + 20).lt(this.width - 20, this.height + this.padding - 1.5) : "se" == b ? a.graphics.f("#f5f5f5").ss(2, "round").s("#6FC0DD").mt(0, -this.padding + 1.5).lt(-10, + -this.padding - 20).lt(20, -this.padding + 1.5) : "sw" == b && a.graphics.f("#f5f5f5").ss(2, "round").s("#6FC0DD").mt(this.width, -this.padding + 1.5).lt(this.width + 10, -this.padding - 20).lt(this.width - 20, -this.padding + 1.5); + return a; }; -Entry.Container.prototype.moveElement = function(a, b, c) { - var d; - d = this.getCurrentObjects(); - a = this.getAllObjects().indexOf(d[a]); - b = this.getAllObjects().indexOf(d[b]); - !c && Entry.stateManager && Entry.stateManager.addCommand("reorder object", Entry.container, Entry.container.moveElement, b, a, !0); - this.objects_.splice(b, 0, this.objects_.splice(a, 1)[0]); - this.setCurrentObjects(); - Entry.container.updateListView(); - Entry.requestUpdate = !0; - return new Entry.State(Entry.container, Entry.container.moveElement, b, a, !0); +Entry.Dialog.prototype.remove = function() { + Entry.stage.unloadDialog(this); + this.parent.dialog = null; }; -Entry.Container.prototype.moveElementByBlock = function(a, b) { - a = this.getCurrentObjects().splice(a, 1)[0]; - this.getCurrentObjects().splice(b, 0, a); - Entry.stage.sortZorder(); - this.updateListView(); -}; -Entry.Container.prototype.getDropdownList = function(a) { - var b = []; - switch(a) { - case "sprites": - var c = this.getCurrentObjects(), d = c.length; - for (a = 0;a < d;a++) { - var e = c[a]; - b.push([e.name, e.id]); - } - break; - case "spritesWithMouse": - c = this.getCurrentObjects(); - d = c.length; - for (a = 0;a < d;a++) { - e = c[a], b.push([e.name, e.id]); - } - b.push([Lang.Blocks.mouse_pointer, "mouse"]); - break; - case "spritesWithSelf": - c = this.getCurrentObjects(); - d = c.length; - for (a = 0;a < d;a++) { - e = c[a], b.push([e.name, e.id]); - } - b.push([Lang.Blocks.self, "self"]); - break; - case "collision": - b.push([Lang.Blocks.mouse_pointer, "mouse"]); - c = this.getCurrentObjects(); - d = c.length; - for (a = 0;a < d;a++) { - e = c[a], b.push([e.name, e.id]); - } - b.push([Lang.Blocks.wall, "wall"]); - b.push([Lang.Blocks.wall_up, "wall_up"]); - b.push([Lang.Blocks.wall_down, "wall_down"]); - b.push([Lang.Blocks.wall_right, "wall_right"]); - b.push([Lang.Blocks.wall_left, "wall_left"]); - break; - case "pictures": - if (!Entry.playground.object) { - break; - } - c = Entry.playground.object.pictures; - for (a = 0;a < c.length;a++) { - d = c[a], b.push([d.name, d.id]); - } - break; - case "messages": - c = Entry.variableContainer.messages_; - for (a = 0;a < c.length;a++) { - d = c[a], b.push([d.name, d.id]); - } - break; - case "variables": - c = Entry.variableContainer.variables_; - for (a = 0;a < c.length;a++) { - d = c[a], d.object_ && d.object_ != Entry.playground.object.id || b.push([d.getName(), d.getId()]); - } - b && 0 !== b.length || b.push([Lang.Blocks.VARIABLE_variable, "null"]); - break; - case "lists": - c = Entry.variableContainer.lists_; - for (a = 0;a < c.length;a++) { - d = c[a], b.push([d.getName(), d.getId()]); - } - b && 0 !== b.length || b.push([Lang.Blocks.VARIABLE_list, "null"]); - break; - case "scenes": - c = Entry.scene.scenes_; - for (a = 0;a < c.length;a++) { - d = c[a], b.push([d.name, d.id]); - } - break; - case "sounds": - if (!Entry.playground.object) { - break; - } - c = Entry.playground.object.sounds; - for (a = 0;a < c.length;a++) { - d = c[a], b.push([d.name, d.id]); - } - break; - case "clone": - b.push([Lang.Blocks.oneself, "self"]); - d = this.objects_.length; - for (a = 0;a < d;a++) { - e = this.objects_[a], b.push([e.name, e.id]); - } - break; - case "objectSequence": - for (d = this.getCurrentObjects().length, a = 0;a < d;a++) { - b.push([(a + 1).toString(), a.toString()]); - } - ; - } - b.length || (b = [[Lang.Blocks.no_target, "null"]]); - return b; -}; -Entry.Container.prototype.clearRunningState = function() { - this.mapObject(function(a) { - a.clearExecutor(); - for (var b = a.clonedEntities.length;0 < b;b--) { - a.clonedEntities[b - 1].removeClone(); - } - a.clonedEntities = []; - }); -}; -Entry.Container.prototype.mapObject = function(a, b) { - for (var c = this.objects_.length, d = [], e = 0;e < c;e++) { - d.push(a(this.objects_[e], b)); - } - return d; -}; -Entry.Container.prototype.mapObjectOnScene = function(a, b) { - for (var c = this.getCurrentObjects(), d = c.length, e = [], f = 0;f < d;f++) { - e.push(a(c[f], b)); - } - return e; -}; -Entry.Container.prototype.clearRunningStateOnScene = function() { - this.mapObjectOnScene(function(a) { - a.clearExecutor(); - for (var b = a.clonedEntities.length;0 < b;b--) { - a.clonedEntities[b - 1].removeClone(); - } - a.clonedEntities = []; - }); -}; -Entry.Container.prototype.mapEntity = function(a, b) { - for (var c = this.objects_.length, d = [], e = 0;e < c;e++) { - d.push(a(this.objects_[e].entity, b)); - } - return d; -}; -Entry.Container.prototype.mapEntityOnScene = function(a, b) { - for (var c = this.getCurrentObjects(), d = c.length, e = [], f = 0;f < d;f++) { - e.push(a(c[f].entity, b)); - } - return e; -}; -Entry.Container.prototype.mapEntityIncludeClone = function(a, b) { - for (var c = this.objects_, d = c.length, e = [], f = 0;f < d;f++) { - var g = c[f], h = g.clonedEntities.length; - e.push(a(g.entity, b)); - for (var k = 0;k < h;k++) { - var l = g.clonedEntities[k]; - l && !l.isStamp && e.push(a(l, b)); - } - } - return e; -}; -Entry.Container.prototype.mapEntityIncludeCloneOnScene = function(a, b) { - for (var c = this.getCurrentObjects(), d = c.length, e = [], f = 0;f < d;f++) { - var g = c[f], h = g.clonedEntities.length; - e.push(a(g.entity, b)); - for (var k = 0;k < h;k++) { - var l = g.clonedEntities[k]; - l && !l.isStamp && e.push(a(l, b)); - } - } - return e; -}; -Entry.Container.prototype.getCachedPicture = function(a) { - Entry.assert("string" == typeof a, "pictureId must be string"); - return this.cachedPicture[a]; -}; -Entry.Container.prototype.cachePicture = function(a, b) { - this.cachedPicture[a] = b; -}; -Entry.Container.prototype.toJSON = function() { - for (var a = [], b = this.objects_.length, c = 0;c < b;c++) { - a.push(this.objects_[c].toJSON()); - } - return a; -}; -Entry.Container.prototype.takeSequenceSnapshot = function() { - for (var a = this.objects_.length, b = this.objects_, c = 0;c < a;c++) { - b[c].index = c; - } -}; -Entry.Container.prototype.loadSequenceSnapshot = function() { - for (var a = this.objects_.length, b = Array(a), c = 0;c < a;c++) { - var d = this.objects_[c]; - b[d.index] = d; - delete d.index; - } - this.objects_ = b; - this.setCurrentObjects(); - Entry.stage.sortZorder(); - this.updateListView(); -}; -Entry.Container.prototype.getInputValue = function() { - return this.inputValue.getValue(); -}; -Entry.Container.prototype.setInputValue = function(a) { - a ? this.inputValue.setValue(a) : this.inputValue.setValue(0); -}; -Entry.Container.prototype.resetSceneDuringRun = function() { - this.mapEntityOnScene(function(a) { - a.loadSnapshot(); - a.object.filters = []; - a.resetFilter(); - a.dialog && a.dialog.remove(); - a.shape && a.removeBrush(); - }); - this.clearRunningStateOnScene(); -}; -Entry.Container.prototype.setCopiedObject = function(a) { - this.copiedObject = a; -}; -Entry.Container.prototype.updateObjectsOrder = function() { - for (var a = Entry.scene.getScenes(), b = [], c = 0;c < a.length;c++) { - for (var d = this.getSceneObjects(a[c]), e = 0;e < d.length;e++) { - b.push(d[e]); - } - } - this.objects_ = b; -}; -Entry.Container.prototype.getSceneObjects = function(a) { - a = a || Entry.scene.selectedScene; - for (var b = [], c = this.getAllObjects(), d = 0;d < c.length;d++) { - a.id == c[d].scene.id && b.push(c[d]); - } - return b; -}; -Entry.Container.prototype.setCurrentObjects = function() { - this.currentObjects_ = this.getSceneObjects(); -}; -Entry.Container.prototype.getCurrentObjects = function() { - var a = this.currentObjects_; - a && 0 !== a.length || this.setCurrentObjects(); - return this.currentObjects_; -}; -Entry.Container.prototype.getProjectWithJSON = function(a) { - a.objects = Entry.container.toJSON(); - a.variables = Entry.variableContainer.getVariableJSON(); - a.messages = Entry.variableContainer.getMessageJSON(); - a.scenes = Entry.scene.toJSON(); - return a; -}; -Entry.Container.prototype.blurAllInputs = function() { - this.getSceneObjects().map(function(a) { - a = a.view_.getElementsByTagName("input"); - for (var b = 0, c = a.length;b < c;b++) { - a[b].blur(); - } - }); -}; -Entry.Container.prototype.showProjectAnswer = function() { - var a = this.inputValue; - a && a.setVisible(!0); -}; -Entry.Container.prototype.hideProjectAnswer = function(a) { - if ((a = this.inputValue) && a.isVisible() && !Entry.engine.isState("run")) { - for (var b = Entry.container.getAllObjects(), c = ["ask_and_wait", "get_canvas_input_value", "set_visible_answer"], d = 0, e = b.length;d < e;d++) { - for (var f = b[d].script, g = 0;g < c.length;g++) { - if (f.hasBlockType(c[g])) { - return; - } - } - } - a.setVisible(!1); - } -}; -Entry.Container.prototype.getView = function() { - return this._view; -}; -Entry.Container.prototype.resize = function() { -}; -Entry.db = {data:{}, typeMap:{}}; -(function(a) { - a.add = function(b) { - this.data[b.id] = b; - var a = b.type; - void 0 === this.typeMap[a] && (this.typeMap[a] = {}); - this.typeMap[a][b.id] = b; - }; - a.has = function(b) { - return this.data.hasOwnProperty(b); - }; - a.remove = function(b) { - this.has(b) && (delete this.typeMap[this.data[b].type][b], delete this.data[b]); - }; - a.get = function(b) { - return this.data[b]; - }; - a.find = function() { - }; - a.clear = function() { - this.data = {}; - this.typeMap = {}; - }; -})(Entry.db); -Entry.Dom = function(a, b) { - var c = /<(\w+)>/, d; - d = a instanceof HTMLElement ? $(a) : a instanceof jQuery ? a : c.test(a) ? $(a) : $("<" + a + ">"); - if (void 0 === b) { - return d; - } - b.id && d.attr("id", b.id); - b.class && d.addClass(b.class); - b.classes && b.classes.map(function(b) { - d.addClass(b); - }); - b.src && d.attr("src", b.src); - b.parent && b.parent.append(d); - d.bindOnClick = function() { - var b, a, c = function(b) { - b.stopImmediatePropagation(); - b.handled || (b.handled = !0, a.call(this, b)); - }; - 1 < arguments.length ? (a = arguments[1] instanceof Function ? arguments[1] : function() { - }, b = "string" === typeof arguments[0] ? arguments[0] : "") : a = arguments[0] instanceof Function ? arguments[0] : function() { - }; - if (b) { - $(this).on("click tab", b, c); - } else { - $(this).on("click tab", c); - } - }; - return d; -}; -Entry.SVG = function(a) { - a = document.getElementById(a); - return Entry.SVG.createElement(a); -}; -Entry.SVG.NS = "http://www.w3.org/2000/svg"; -Entry.SVG.NS_XLINK = "http://www.w3.org/1999/xlink"; -Entry.SVG.createElement = function(a, b) { - a = "string" === typeof a ? document.createElementNS(Entry.SVG.NS, a) : a; - if (b) { - b.href && (a.setAttributeNS(Entry.SVG.NS_XLINK, "href", b.href), delete b.href); - for (var c in b) { - a.setAttribute(c, b[c]); - } - } - this instanceof SVGElement && this.appendChild(a); - a.elem = Entry.SVG.createElement; - a.attr = Entry.SVG.attr; - a.addClass = Entry.SVG.addClass; - a.removeClass = Entry.SVG.removeClass; - a.hasClass = Entry.SVG.hasClass; - a.remove = Entry.SVG.remove; - a.removeAttr = Entry.SVG.removeAttr; - return a; -}; -Entry.SVG.attr = function(a, b) { - if ("string" === typeof a) { - var c = {}; - c[a] = b; - a = c; - } - if (a) { - a.href && (this.setAttributeNS(Entry.SVG.NS_XLINK, "href", a.href), delete a.href); - for (var d in a) { - this.setAttribute(d, a[d]); - } - } - return this; -}; -Entry.SVG.addClass = function(a) { - for (var b = this.getAttribute("class"), c = 0;c < arguments.length;c++) { - a = arguments[c], this.hasClass(a) || (b += " " + a); - } - this.setAttribute("class", b); - return this; -}; -Entry.SVG.removeClass = function(a) { - for (var b = this.getAttribute("class"), c = 0;c < arguments.length;c++) { - a = arguments[c], this.hasClass(a) && (b = b.replace(new RegExp("(\\s|^)" + a + "(\\s|$)"), " ")); - } - this.setAttribute("class", b); - return this; -}; -Entry.SVG.hasClass = function(a) { - var b = this.getAttribute("class"); - return b ? b.match(new RegExp("(\\s|^)" + a + "(\\s|$)")) : !1; -}; -Entry.SVG.remove = function() { - this.parentNode && this.parentNode.removeChild(this); -}; -Entry.SVG.removeAttr = function(a) { - this.removeAttribute(a); -}; -Entry.Dialog = function(a, b, c, d) { - a.dialog && a.dialog.remove(); - a.dialog = this; - this.parent = a; - this.padding = 10; - this.border = 2; - "number" == typeof b && (b = String(b)); - this.message_ = b = b.match(/.{1,15}/g).join("\n"); - this.mode_ = c; - "speak" == c && this.generateSpeak(); - d || Entry.stage.loadDialog(this); -}; -Entry.Dialog.prototype.generateSpeak = function() { - this.object = new createjs.Container; - var a = new createjs.Text; - a.font = "15px NanumGothic"; - a.textBaseline = "top"; - a.textAlign = "left"; - a.text = this.message_; - var b = a.getTransformedBounds(), c = b.height, b = 10 <= b.width ? b.width : 17, d = new createjs.Shape; - d.graphics.f("#f5f5f5").ss(2, "round").s("#6FC0DD").rr(-this.padding, -this.padding, b + 2 * this.padding, c + 2 * this.padding, this.padding); - this.object.addChild(d); - this.object.regX = b / 2; - this.object.regY = c / 2; - this.width = b; - this.height = c; - this.notch = this.createSpeakNotch("ne"); - this.update(); - this.object.addChild(this.notch); - this.object.addChild(a); - Entry.requestUpdate = !0; -}; -Entry.Dialog.prototype.update = function() { - var a = this.parent.object.getTransformedBounds(), b = ""; - -135 < a.y - this.height - 20 - this.border ? (this.object.y = a.y - this.height / 2 - 20 - this.padding, b += "n") : (this.object.y = a.y + a.height + this.height / 2 + 20 + this.padding, b += "s"); - 240 > a.x + a.width + this.width ? (this.object.x = a.x + a.width + this.width / 2, b += "e") : (this.object.x = a.x - this.width / 2, b += "w"); - this.notch.type != b && (this.object.removeChild(this.notch), this.notch = this.createSpeakNotch(b), this.object.addChild(this.notch)); - Entry.requestUpdate = !0; -}; -Entry.Dialog.prototype.createSpeakNotch = function(a) { - var b = new createjs.Shape; - b.type = a; - "ne" == a ? b.graphics.f("#f5f5f5").ss(2, "round").s("#6FC0DD").mt(0, this.height + this.padding - 1.5).lt(-10, this.height + this.padding + 20).lt(20, this.height + this.padding - 1.5) : "nw" == a ? b.graphics.f("#f5f5f5").ss(2, "round").s("#6FC0DD").mt(this.width, this.height + this.padding - 1.5).lt(this.width + 10, this.height + this.padding + 20).lt(this.width - 20, this.height + this.padding - 1.5) : "se" == a ? b.graphics.f("#f5f5f5").ss(2, "round").s("#6FC0DD").mt(0, -this.padding + 1.5).lt(-10, - -this.padding - 20).lt(20, -this.padding + 1.5) : "sw" == a && b.graphics.f("#f5f5f5").ss(2, "round").s("#6FC0DD").mt(this.width, -this.padding + 1.5).lt(this.width + 10, -this.padding - 20).lt(this.width - 20, -this.padding + 1.5); - return b; -}; -Entry.Dialog.prototype.remove = function() { - Entry.stage.unloadDialog(this); - this.parent.dialog = null; -}; -Entry.DoneProject = function(a) { - this.generateView(a); +Entry.DoneProject = function(b) { + this.generateView(b); }; var p = Entry.DoneProject.prototype; -p.init = function(a) { - this.projectId = a; +p.init = function(b) { + this.projectId = b; }; -p.generateView = function(a) { - var b = Entry.createElement("div"); - b.addClass("entryContainerDoneWorkspace"); - this.doneContainer = b; +p.generateView = function(b) { + var a = Entry.createElement("div"); + a.addClass("entryContainerDoneWorkspace"); + this.doneContainer = a; var c = Entry.createElement("iframe"); c.setAttribute("id", "doneProjectframe"); c.setAttribute("frameborder", 0); - c.setAttribute("src", "/api/iframe/project/" + a); + c.setAttribute("src", "/api/iframe/project/" + b); this.doneProjectFrame = c; this.doneContainer.appendChild(c); - b.addClass("entryRemove"); + a.addClass("entryRemove"); }; p.getView = function() { return this.doneContainer; }; p.resize = function() { document.getElementById("entryContainerWorkspaceId"); - var a = document.getElementById("doneProjectframe"), b = this.doneContainer.offsetWidth; - a.width = b + "px"; - a.height = 9 * b / 16 + "px"; + var b = document.getElementById("doneProjectframe"), a = this.doneContainer.offsetWidth; + b.width = a + "px"; + b.height = 9 * a / 16 + "px"; }; Entry.Engine = function() { - function a(b) { - var a = [37, 38, 39, 40, 32], d = b.keyCode || b.which, e = Entry.stage.inputField; - 32 == d && e && e.hasFocus() || -1 < a.indexOf(d) && b.preventDefault(); + function b(a) { + var b = [37, 38, 39, 40, 32], d = a.keyCode || a.which, e = Entry.stage.inputField; + 32 == d && e && e.hasFocus() || -1 < b.indexOf(d) && a.preventDefault(); } this.state = "stop"; this.popup = null; @@ -7748,89 +6920,89 @@ Entry.Engine = function() { this.speeds = [1, 15, 30, 45, 60]; this._mouseMoved = !1; Entry.keyPressed && Entry.keyPressed.attach(this, this.captureKeyEvent); - Entry.addEventListener("canvasClick", function(b) { + Entry.addEventListener("canvasClick", function(a) { Entry.engine.fireEvent("mouse_clicked"); }); - Entry.addEventListener("canvasClickCanceled", function(b) { + Entry.addEventListener("canvasClickCanceled", function(a) { Entry.engine.fireEvent("mouse_click_cancled"); }); - Entry.addEventListener("entityClick", function(b) { - Entry.engine.fireEventOnEntity("when_object_click", b); + Entry.addEventListener("entityClick", function(a) { + Entry.engine.fireEventOnEntity("when_object_click", a); }); - Entry.addEventListener("entityClickCanceled", function(b) { - Entry.engine.fireEventOnEntity("when_object_click_canceled", b); + Entry.addEventListener("entityClickCanceled", function(a) { + Entry.engine.fireEventOnEntity("when_object_click_canceled", a); }); - "phone" != Entry.type && (Entry.addEventListener("stageMouseMove", function(b) { + "phone" != Entry.type && (Entry.addEventListener("stageMouseMove", function(a) { this._mouseMoved = !0; - }.bind(this)), Entry.addEventListener("stageMouseOut", function(b) { + }.bind(this)), Entry.addEventListener("stageMouseOut", function(a) { Entry.engine.hideMouseView(); })); Entry.addEventListener("run", function() { - $(window).bind("keydown", a); + $(window).bind("keydown", b); }); Entry.addEventListener("stop", function() { - $(window).unbind("keydown", a); + $(window).unbind("keydown", b); }); setInterval(function() { this._mouseMoved && (this.updateMouseView(), this._mouseMoved = !1); }.bind(this), 100); }; -Entry.Engine.prototype.generateView = function(a, b) { - if (b && "workspace" != b) { - "minimize" == b ? (this.view_ = a, this.view_.addClass("entryEngine"), this.view_.addClass("entryEngineMinimize"), this.maximizeButton = Entry.createElement("button"), this.maximizeButton.addClass("entryEngineButtonMinimize"), this.maximizeButton.addClass("entryMaximizeButtonMinimize"), this.view_.appendChild(this.maximizeButton), this.maximizeButton.bindOnClick(function(b) { +Entry.Engine.prototype.generateView = function(b, a) { + if (a && "workspace" != a) { + "minimize" == a ? (this.view_ = b, this.view_.addClass("entryEngine"), this.view_.addClass("entryEngineMinimize"), this.maximizeButton = Entry.createElement("button"), this.maximizeButton.addClass("entryEngineButtonMinimize"), this.maximizeButton.addClass("entryMaximizeButtonMinimize"), this.view_.appendChild(this.maximizeButton), this.maximizeButton.bindOnClick(function(a) { Entry.engine.toggleFullscreen(); - }), this.coordinateButton = Entry.createElement("button"), this.coordinateButton.addClass("entryEngineButtonMinimize"), this.coordinateButton.addClass("entryCoordinateButtonMinimize"), this.view_.appendChild(this.coordinateButton), this.coordinateButton.bindOnClick(function(b) { + }), this.coordinateButton = Entry.createElement("button"), this.coordinateButton.addClass("entryEngineButtonMinimize"), this.coordinateButton.addClass("entryCoordinateButtonMinimize"), this.view_.appendChild(this.coordinateButton), this.coordinateButton.bindOnClick(function(a) { this.hasClass("toggleOn") ? this.removeClass("toggleOn") : this.addClass("toggleOn"); Entry.stage.toggleCoordinator(); - }), this.stopButton = Entry.createElement("button"), this.stopButton.addClass("entryEngineButtonMinimize"), this.stopButton.addClass("entryStopButtonMinimize"), this.stopButton.addClass("entryRemove"), this.stopButton.innerHTML = Lang.Workspace.stop, this.view_.appendChild(this.stopButton), this.stopButton.bindOnClick(function(b) { + }), this.stopButton = Entry.createElement("button"), this.stopButton.addClass("entryEngineButtonMinimize"), this.stopButton.addClass("entryStopButtonMinimize"), this.stopButton.addClass("entryRemove"), this.stopButton.innerHTML = Lang.Workspace.stop, this.view_.appendChild(this.stopButton), this.stopButton.bindOnClick(function(a) { this.blur(); Entry.engine.toggleStop(); - }), this.pauseButton = Entry.createElement("button"), this.pauseButton.innerHTML = Lang.Workspace.pause, this.pauseButton.addClass("entryEngineButtonMinimize"), this.pauseButton.addClass("entryPauseButtonMinimize"), this.pauseButton.addClass("entryRemove"), this.view_.appendChild(this.pauseButton), this.pauseButton.bindOnClick(function(b) { + }), this.pauseButton = Entry.createElement("button"), this.pauseButton.innerHTML = Lang.Workspace.pause, this.pauseButton.addClass("entryEngineButtonMinimize"), this.pauseButton.addClass("entryPauseButtonMinimize"), this.pauseButton.addClass("entryRemove"), this.view_.appendChild(this.pauseButton), this.pauseButton.bindOnClick(function(a) { this.blur(); Entry.engine.togglePause(); }), this.mouseView = Entry.createElement("div"), this.mouseView.addClass("entryMouseViewMinimize"), this.mouseView.addClass("entryRemove"), this.view_.appendChild(this.mouseView), Entry.addEventListener("loadComplete", function() { this.runButton = Entry.Dom("div", {class:"entryRunButtonBigMinimize", parent:$("#entryCanvasWrapper")}); - this.runButton.bindOnClick(function(b) { + this.runButton.bindOnClick(function(a) { Entry.engine.toggleRun(); }); - }.bind(this))) : "phone" == b && (this.view_ = a, this.view_.addClass("entryEngine", "entryEnginePhone"), this.headerView_ = Entry.createElement("div", "entryEngineHeader"), this.headerView_.addClass("entryEngineHeaderPhone"), this.view_.appendChild(this.headerView_), this.maximizeButton = Entry.createElement("button"), this.maximizeButton.addClass("entryEngineButtonPhone", "entryMaximizeButtonPhone"), this.headerView_.appendChild(this.maximizeButton), this.maximizeButton.bindOnClick(function(b) { + }.bind(this))) : "phone" == a && (this.view_ = b, this.view_.addClass("entryEngine", "entryEnginePhone"), this.headerView_ = Entry.createElement("div", "entryEngineHeader"), this.headerView_.addClass("entryEngineHeaderPhone"), this.view_.appendChild(this.headerView_), this.maximizeButton = Entry.createElement("button"), this.maximizeButton.addClass("entryEngineButtonPhone", "entryMaximizeButtonPhone"), this.headerView_.appendChild(this.maximizeButton), this.maximizeButton.bindOnClick(function(a) { Entry.engine.footerView_.addClass("entryRemove"); Entry.engine.headerView_.addClass("entryRemove"); Entry.launchFullScreen(Entry.engine.view_); - }), document.addEventListener("fullscreenchange", function(b) { + }), document.addEventListener("fullscreenchange", function(a) { Entry.engine.exitFullScreen(); - }), document.addEventListener("webkitfullscreenchange", function(b) { + }), document.addEventListener("webkitfullscreenchange", function(a) { Entry.engine.exitFullScreen(); - }), document.addEventListener("mozfullscreenchange", function(b) { + }), document.addEventListener("mozfullscreenchange", function(a) { Entry.engine.exitFullScreen(); - }), this.footerView_ = Entry.createElement("div", "entryEngineFooter"), this.footerView_.addClass("entryEngineFooterPhone"), this.view_.appendChild(this.footerView_), this.runButton = Entry.createElement("button"), this.runButton.addClass("entryEngineButtonPhone", "entryRunButtonPhone"), Entry.objectAddable && this.runButton.addClass("small"), this.runButton.innerHTML = Lang.Workspace.run, this.footerView_.appendChild(this.runButton), this.runButton.bindOnClick(function(b) { + }), this.footerView_ = Entry.createElement("div", "entryEngineFooter"), this.footerView_.addClass("entryEngineFooterPhone"), this.view_.appendChild(this.footerView_), this.runButton = Entry.createElement("button"), this.runButton.addClass("entryEngineButtonPhone", "entryRunButtonPhone"), Entry.objectAddable && this.runButton.addClass("small"), this.runButton.innerHTML = Lang.Workspace.run, this.footerView_.appendChild(this.runButton), this.runButton.bindOnClick(function(a) { Entry.engine.toggleRun(); - }), this.stopButton = Entry.createElement("button"), this.stopButton.addClass("entryEngineButtonPhone", "entryStopButtonPhone", "entryRemove"), Entry.objectAddable && this.stopButton.addClass("small"), this.stopButton.innerHTML = Lang.Workspace.stop, this.footerView_.appendChild(this.stopButton), this.stopButton.bindOnClick(function(b) { + }), this.stopButton = Entry.createElement("button"), this.stopButton.addClass("entryEngineButtonPhone", "entryStopButtonPhone", "entryRemove"), Entry.objectAddable && this.stopButton.addClass("small"), this.stopButton.innerHTML = Lang.Workspace.stop, this.footerView_.appendChild(this.stopButton), this.stopButton.bindOnClick(function(a) { Entry.engine.toggleStop(); })); } else { - this.view_ = a; + this.view_ = b; this.view_.addClass("entryEngine_w"); this.view_.addClass("entryEngineWorkspace_w"); var c = Entry.createElement("button"); this.speedButton = c; this.speedButton.addClass("entrySpeedButtonWorkspace", "entryEngineTopWorkspace", "entryEngineButtonWorkspace_w"); this.view_.appendChild(this.speedButton); - this.speedButton.bindOnClick(function(b) { + this.speedButton.bindOnClick(function(a) { Entry.engine.toggleSpeedPanel(); c.blur(); }); this.maximizeButton = Entry.createElement("button"); this.maximizeButton.addClass("entryEngineButtonWorkspace_w", "entryEngineTopWorkspace", "entryMaximizeButtonWorkspace_w"); this.view_.appendChild(this.maximizeButton); - this.maximizeButton.bindOnClick(function(b) { + this.maximizeButton.bindOnClick(function(a) { Entry.engine.toggleFullscreen(); }); var d = Entry.createElement("button"); this.coordinateButton = d; this.coordinateButton.addClass("entryEngineButtonWorkspace_w", "entryEngineTopWorkspace", "entryCoordinateButtonWorkspace_w"); this.view_.appendChild(this.coordinateButton); - this.coordinateButton.bindOnClick(function(b) { + this.coordinateButton.bindOnClick(function(a) { this.hasClass("toggleOn") ? this.removeClass("toggleOn") : this.addClass("toggleOn"); d.blur(); Entry.stage.toggleCoordinator(); @@ -7839,7 +7011,7 @@ Entry.Engine.prototype.generateView = function(a, b) { this.addButton.addClass("entryEngineButtonWorkspace_w"); this.addButton.addClass("entryAddButtonWorkspace_w"); this.addButton.innerHTML = Lang.Workspace.add_object; - this.addButton.bindOnClick(function(b) { + this.addButton.bindOnClick(function(a) { Entry.dispatchEvent("openSpriteManager"); }); this.view_.appendChild(this.addButton); @@ -7848,14 +7020,14 @@ Entry.Engine.prototype.generateView = function(a, b) { this.runButton.addClass("entryRunButtonWorkspace_w"); this.runButton.innerHTML = Lang.Workspace.run; this.view_.appendChild(this.runButton); - this.runButton.bindOnClick(function(b) { + this.runButton.bindOnClick(function(a) { Entry.engine.toggleRun(); }); this.runButton2 = Entry.createElement("button"); this.runButton2.addClass("entryEngineButtonWorkspace_w"); this.runButton2.addClass("entryRunButtonWorkspace_w2"); this.view_.appendChild(this.runButton2); - this.runButton2.bindOnClick(function(b) { + this.runButton2.bindOnClick(function(a) { Entry.engine.toggleRun(); }); this.stopButton = Entry.createElement("button"); @@ -7864,7 +7036,7 @@ Entry.Engine.prototype.generateView = function(a, b) { this.stopButton.addClass("entryRemove"); this.stopButton.innerHTML = Lang.Workspace.stop; this.view_.appendChild(this.stopButton); - this.stopButton.bindOnClick(function(b) { + this.stopButton.bindOnClick(function(a) { Entry.engine.toggleStop(); }); this.stopButton2 = Entry.createElement("button"); @@ -7873,7 +7045,7 @@ Entry.Engine.prototype.generateView = function(a, b) { this.stopButton2.addClass("entryRemove"); this.stopButton2.innerHTML = Lang.Workspace.stop; this.view_.appendChild(this.stopButton2); - this.stopButton2.bindOnClick(function(b) { + this.stopButton2.bindOnClick(function(a) { Entry.engine.toggleStop(); }); this.pauseButton = Entry.createElement("button"); @@ -7881,7 +7053,7 @@ Entry.Engine.prototype.generateView = function(a, b) { this.pauseButton.addClass("entryPauseButtonWorkspace_w"); this.pauseButton.addClass("entryRemove"); this.view_.appendChild(this.pauseButton); - this.pauseButton.bindOnClick(function(b) { + this.pauseButton.bindOnClick(function(a) { Entry.engine.togglePause(); }); this.mouseView = Entry.createElement("div"); @@ -7892,7 +7064,7 @@ Entry.Engine.prototype.generateView = function(a, b) { }; Entry.Engine.prototype.toggleSpeedPanel = function() { if (this.speedPanelOn) { - this.speedPanelOn = !1, $(Entry.stage.canvas.canvas).animate({top:"24px"}), this.coordinateButton.removeClass("entryRemove"), this.maximizeButton.removeClass("entryRemove"), this.mouseView.removeClass("entryRemoveElement"), $(this.speedLabel_).remove(), delete this.speedLabel_, $(this.speedProgress_).fadeOut(null, function(b) { + this.speedPanelOn = !1, $(Entry.stage.canvas.canvas).animate({top:"24px"}), this.coordinateButton.removeClass("entryRemove"), this.maximizeButton.removeClass("entryRemove"), this.mouseView.removeClass("entryRemoveElement"), $(this.speedLabel_).remove(), delete this.speedLabel_, $(this.speedProgress_).fadeOut(null, function(a) { $(this).remove(); delete this.speedProgress_; }), $(this.speedHandle_).remove(), delete this.speedHandle_; @@ -7906,33 +7078,32 @@ Entry.Engine.prototype.toggleSpeedPanel = function() { this.speedLabel_.innerHTML = Lang.Workspace.speed; this.view_.insertBefore(this.speedLabel_, this.maximizeButton); this.speedProgress_ = Entry.createElement("table", "entrySpeedProgressWorkspace"); - for (var a = Entry.createElement("tr"), b = this.speeds, c = 0;5 > c;c++) { + for (var b = Entry.createElement("tr"), a = this.speeds, c = 0;5 > c;c++) { (function(c) { var e = Entry.createElement("td", "progressCell" + c); e.bindOnClick(function() { - Entry.engine.setSpeedMeter(b[c]); + Entry.engine.setSpeedMeter(a[c]); }); - a.appendChild(e); + b.appendChild(e); })(c); } this.view_.insertBefore(this.speedProgress_, this.maximizeButton); - this.speedProgress_.appendChild(a); + this.speedProgress_.appendChild(b); this.speedHandle_ = Entry.createElement("div", "entrySpeedHandleWorkspace"); c = (Entry.interfaceState.canvasWidth - 84) / 5; - $(this.speedHandle_).draggable({axis:"x", grid:[c, c], containment:[80, 0, 4 * c + 80, 0], drag:function(b, a) { - b = (a.position.left - 80) / (Entry.interfaceState.canvasWidth - 84) * 5; - b = Math.floor(b); - 0 > b || Entry.engine.setSpeedMeter(Entry.engine.speeds[b]); + $(this.speedHandle_).draggable({axis:"x", grid:[c, c], containment:[80, 0, 4 * c + 80, 0], drag:function(a, b) { + var c = (b.position.left - 80) / (Entry.interfaceState.canvasWidth - 84) * 5, c = Math.floor(c); + 0 > c || Entry.engine.setSpeedMeter(Entry.engine.speeds[c]); }}); this.view_.insertBefore(this.speedHandle_, this.maximizeButton); this.setSpeedMeter(Entry.FPS); } }; -Entry.Engine.prototype.setSpeedMeter = function(a) { - var b = this.speeds.indexOf(a); - 0 > b || (b = Math.min(4, b), b = Math.max(0, b), this.speedPanelOn && (this.speedHandle_.style.left = (Entry.interfaceState.canvasWidth - 80) / 10 * (2 * b + 1) + 80 - 9 + "px"), Entry.FPS != a && (clearInterval(this.ticker), this.ticker = setInterval(this.update, Math.floor(1E3 / a)), Entry.FPS = a)); +Entry.Engine.prototype.setSpeedMeter = function(b) { + var a = this.speeds.indexOf(b); + 0 > a || (a = Math.min(4, a), a = Math.max(0, a), this.speedPanelOn && (this.speedHandle_.style.left = (Entry.interfaceState.canvasWidth - 80) / 10 * (2 * a + 1) + 80 - 9 + "px"), Entry.FPS != b && (clearInterval(this.ticker), this.ticker = setInterval(this.update, Math.floor(1E3 / b)), Entry.FPS = b)); }; -Entry.Engine.prototype.start = function(a) { +Entry.Engine.prototype.start = function(b) { createjs.Ticker.setFPS(Entry.FPS); this.ticker = setInterval(this.update, Math.floor(1E3 / Entry.FPS)); }; @@ -7946,55 +7117,54 @@ Entry.Engine.prototype.update = function() { Entry.Engine.prototype.computeObjects = function() { Entry.container.mapObjectOnScene(this.computeFunction); }; -Entry.Engine.prototype.computeFunction = function(a) { - a.script.tick(); +Entry.Engine.prototype.computeFunction = function(b) { + b.script.tick(); }; -Entry.Engine.computeThread = function(a, b) { +Entry.Engine.computeThread = function(b, a) { Entry.engine.isContinue = !0; - for (a = !1;b && Entry.engine.isContinue && !a;) { - Entry.engine.isContinue = !b.isRepeat; - var c = b.run(); - a = c && c === b; - b = c; + for (var c = !1;a && Entry.engine.isContinue && !c;) { + Entry.engine.isContinue = !a.isRepeat; + var d = a.run(), c = d && d === a; + a = d; } - return b; + return a; }; -Entry.Engine.prototype.isState = function(a) { - return -1 < this.state.indexOf(a); +Entry.Engine.prototype.isState = function(b) { + return -1 < this.state.indexOf(b); }; Entry.Engine.prototype.run = function() { this.isState("run") ? this.toggleStop() : (this.isState("stop") || this.isState("pause")) && this.toggleRun(); }; Entry.Engine.prototype.toggleRun = function() { - "pause" === this.state ? this.togglePause() : (Entry.addActivity("run"), "stop" == this.state && (Entry.container.mapEntity(function(a) { - a.takeSnapshot(); - }), Entry.variableContainer.mapVariable(function(a) { - a.takeSnapshot(); - }), Entry.variableContainer.mapList(function(a) { - a.takeSnapshot(); + "pause" === this.state ? this.togglePause() : (Entry.addActivity("run"), "stop" == this.state && (Entry.container.mapEntity(function(b) { + b.takeSnapshot(); + }), Entry.variableContainer.mapVariable(function(b) { + b.takeSnapshot(); + }), Entry.variableContainer.mapList(function(b) { + b.takeSnapshot(); }), this.projectTimer.takeSnapshot(), Entry.container.inputValue.takeSnapshot(), Entry.container.takeSequenceSnapshot(), Entry.scene.takeStartSceneSnapshot(), this.state = "run", this.fireEvent("start")), this.state = "run", "mobile" == Entry.type && this.view_.addClass("entryEngineBlueWorkspace"), this.pauseButton.innerHTML = Lang.Workspace.pause, this.runButton.addClass("run"), this.runButton.addClass("entryRemove"), this.stopButton.removeClass("entryRemove"), this.pauseButton && this.pauseButton.removeClass("entryRemove"), this.runButton2 && this.runButton2.addClass("entryRemove"), this.stopButton2 && this.stopButton2.removeClass("entryRemove"), this.isUpdating || (Entry.engine.update(), Entry.engine.isUpdating = !0), Entry.stage.selectObject(), Entry.dispatchEvent("run")); }; Entry.Engine.prototype.toggleStop = function() { Entry.addActivity("stop"); - var a = Entry.container, b = Entry.variableContainer; - a.mapEntity(function(b) { - b.loadSnapshot(); - b.object.filters = []; - b.resetFilter(); - b.dialog && b.dialog.remove(); - b.brush && b.removeBrush(); + var b = Entry.container, a = Entry.variableContainer; + b.mapEntity(function(a) { + a.loadSnapshot(); + a.object.filters = []; + a.resetFilter(); + a.dialog && a.dialog.remove(); + a.brush && a.removeBrush(); }); - b.mapVariable(function(b) { - b.loadSnapshot(); + a.mapVariable(function(a) { + a.loadSnapshot(); }); - b.mapList(function(b) { - b.loadSnapshot(); - b.updateView(); + a.mapList(function(a) { + a.loadSnapshot(); + a.updateView(); }); this.stopProjectTimer(); - a.clearRunningState(); - a.loadSequenceSnapshot(); + b.clearRunningState(); + b.loadSequenceSnapshot(); this.projectTimer.loadSnapshot(); Entry.container.inputValue.loadSnapshot(); Entry.scene.loadStartSceneSnapshot(); @@ -8012,33 +7182,33 @@ Entry.Engine.prototype.toggleStop = function() { Entry.stage.hideInputField(); }; Entry.Engine.prototype.togglePause = function() { - var a = Entry.engine.projectTimer; - "pause" == this.state ? (a.pausedTime += (new Date).getTime() - a.pauseStart, a.isPaused ? a.pauseStart = (new Date).getTime() : delete a.pauseStart, this.state = "run", this.pauseButton.innerHTML = Lang.Workspace.pause, this.runButton.addClass("entryRemove"), this.runButton2 && this.runButton2.addClass("entryRemove")) : (this.state = "pause", a.isPaused && (a.pausedTime += (new Date).getTime() - a.pauseStart), a.pauseStart = (new Date).getTime(), this.pauseButton.innerHTML = Lang.Workspace.restart, + var b = Entry.engine.projectTimer; + "pause" == this.state ? (b.pausedTime += (new Date).getTime() - b.pauseStart, b.isPaused ? b.pauseStart = (new Date).getTime() : delete b.pauseStart, this.state = "run", this.pauseButton.innerHTML = Lang.Workspace.pause, this.runButton.addClass("entryRemove"), this.runButton2 && this.runButton2.addClass("entryRemove")) : (this.state = "pause", b.isPaused && (b.pausedTime += (new Date).getTime() - b.pauseStart), b.pauseStart = (new Date).getTime(), this.pauseButton.innerHTML = Lang.Workspace.restart, this.runButton.removeClass("entryRemove"), this.stopButton.removeClass("entryRemove"), this.runButton2 && this.runButton2.removeClass("entryRemove")); }; -Entry.Engine.prototype.fireEvent = function(a) { - "run" == this.state && Entry.container.mapEntityIncludeCloneOnScene(this.raiseEvent, a); +Entry.Engine.prototype.fireEvent = function(b) { + "run" == this.state && Entry.container.mapEntityIncludeCloneOnScene(this.raiseEvent, b); }; -Entry.Engine.prototype.raiseEvent = function(a, b) { - a.parent.script.raiseEvent(b, a); +Entry.Engine.prototype.raiseEvent = function(b, a) { + b.parent.script.raiseEvent(a, b); }; -Entry.Engine.prototype.fireEventOnEntity = function(a, b) { - "run" == this.state && Entry.container.mapEntityIncludeCloneOnScene(this.raiseEventOnEntity, [b, a]); +Entry.Engine.prototype.fireEventOnEntity = function(b, a) { + "run" == this.state && Entry.container.mapEntityIncludeCloneOnScene(this.raiseEventOnEntity, [a, b]); }; -Entry.Engine.prototype.raiseEventOnEntity = function(a, b) { - a === b[0] && a.parent.script.raiseEvent(b[1], a); +Entry.Engine.prototype.raiseEventOnEntity = function(b, a) { + b === a[0] && b.parent.script.raiseEvent(a[1], b); }; -Entry.Engine.prototype.captureKeyEvent = function(a) { - var b = a.keyCode, c = Entry.type; - a.ctrlKey && "workspace" == c ? 83 == b ? (a.preventDefault(), Entry.dispatchEvent("saveWorkspace")) : 82 == b ? (a.preventDefault(), Entry.engine.run()) : 90 == b && (a.preventDefault(), console.log("engine"), Entry.dispatchEvent(a.shiftKey ? "redo" : "undo")) : Entry.engine.isState("run") && Entry.container.mapEntityIncludeCloneOnScene(Entry.engine.raiseKeyEvent, ["keyPress", b]); - Entry.engine.isState("stop") && "workspace" === c && 37 <= b && 40 >= b && Entry.stage.moveSprite(a); +Entry.Engine.prototype.captureKeyEvent = function(b) { + var a = b.keyCode, c = Entry.type; + b.ctrlKey && "workspace" == c ? 83 == a ? (b.preventDefault(), Entry.dispatchEvent("saveWorkspace")) : 82 == a ? (b.preventDefault(), Entry.engine.run()) : 90 == a && (b.preventDefault(), console.log("engine"), Entry.dispatchEvent(b.shiftKey ? "redo" : "undo")) : Entry.engine.isState("run") && Entry.container.mapEntityIncludeCloneOnScene(Entry.engine.raiseKeyEvent, ["keyPress", a]); + Entry.engine.isState("stop") && "workspace" === c && 37 <= a && 40 >= a && Entry.stage.moveSprite(b); }; -Entry.Engine.prototype.raiseKeyEvent = function(a, b) { - return a.parent.script.raiseEvent(b[0], a, String(b[1])); +Entry.Engine.prototype.raiseKeyEvent = function(b, a) { + return b.parent.script.raiseEvent(a[0], b, String(a[1])); }; Entry.Engine.prototype.updateMouseView = function() { - var a = Entry.stage.mouseCoordinate; - this.mouseView.textContent = "X : " + a.x + ", Y : " + a.y; + var b = Entry.stage.mouseCoordinate; + this.mouseView.textContent = "X : " + b.x + ", Y : " + b.y; this.mouseView.removeClass("entryRemove"); }; Entry.Engine.prototype.hideMouseView = function() { @@ -8050,8 +7220,8 @@ Entry.Engine.prototype.toggleFullscreen = function() { } else { this.popup = new Entry.Popup; if ("workspace" != Entry.type) { - var a = $(document); - $(this.popup.body_).css("top", a.scrollTop()); + var b = $(document); + $(this.popup.body_).css("top", b.scrollTop()); $("body").css("overflow", "hidden"); popup.window_.appendChild(Entry.stage.canvas.canvas); } @@ -8067,16 +7237,16 @@ Entry.Engine.prototype.showProjectTimer = function() { Entry.engine.projectTimer && this.projectTimer.setVisible(!0); }; Entry.Engine.prototype.hideProjectTimer = function() { - var a = this.projectTimer; - if (a && a.isVisible() && !this.isState("run")) { - for (var b = Entry.container.getAllObjects(), c = ["get_project_timer_value", "reset_project_timer", "set_visible_project_timer", "choose_project_timer_action"], d = 0, e = b.length;d < e;d++) { - for (var f = b[d].script, g = 0;g < c.length;g++) { + var b = this.projectTimer; + if (b && b.isVisible() && !this.isState("run")) { + for (var a = Entry.container.getAllObjects(), c = ["get_project_timer_value", "reset_project_timer", "set_visible_project_timer", "choose_project_timer_action"], d = 0, e = a.length;d < e;d++) { + for (var f = a[d].script, g = 0;g < c.length;g++) { if (f.hasBlockType(c[g])) { return; } } } - a.setVisible(!1); + b.setVisible(!1); } }; Entry.Engine.prototype.clearTimer = function() { @@ -8084,25 +7254,25 @@ Entry.Engine.prototype.clearTimer = function() { clearInterval(this.projectTimer.tick); }; Entry.Engine.prototype.startProjectTimer = function() { - var a = this.projectTimer; - a && (a.start = (new Date).getTime(), a.isInit = !0, a.pausedTime = 0, a.tick = setInterval(function(b) { + var b = this.projectTimer; + b && (b.start = (new Date).getTime(), b.isInit = !0, b.pausedTime = 0, b.tick = setInterval(function(a) { Entry.engine.updateProjectTimer(); }, 1E3 / 60)); }; Entry.Engine.prototype.stopProjectTimer = function() { - var a = this.projectTimer; - a && (this.updateProjectTimer(0), a.isPaused = !1, a.isInit = !1, a.pausedTime = 0, clearInterval(a.tick)); + var b = this.projectTimer; + b && (this.updateProjectTimer(0), b.isPaused = !1, b.isInit = !1, b.pausedTime = 0, clearInterval(b.tick)); }; -Entry.Engine.prototype.updateProjectTimer = function(a) { - var b = Entry.engine, c = b.projectTimer; +Entry.Engine.prototype.updateProjectTimer = function(b) { + var a = Entry.engine, c = a.projectTimer; if (c) { var d = (new Date).getTime(); - "undefined" == typeof a ? c.isPaused || b.isState("pause") || c.setValue((d - c.start - c.pausedTime) / 1E3) : (c.setValue(a), c.pausedTime = 0, c.start = d); + "undefined" == typeof b ? c.isPaused || a.isState("pause") || c.setValue((d - c.start - c.pausedTime) / 1E3) : (c.setValue(b), c.pausedTime = 0, c.start = d); } }; -Entry.EntityObject = function(a) { - this.parent = a; - this.type = a.objectType; +Entry.EntityObject = function(b) { + this.parent = b; + this.type = b.objectType; this.flip = !1; this.collision = Entry.Utils.COLLISION.NONE; this.id = Entry.generateHash(); @@ -8110,41 +7280,54 @@ Entry.EntityObject = function(a) { this.fontType = "Nanum Gothic", this.fontSize = 20, this.strike = this.underLine = this.fontItalic = this.fontBold = !1); this.object.entity = this; this.object.cursor = "pointer"; - this.object.on("mousedown", function(b) { - var a = this.entity.parent.id; + this.object.on("mousedown", function(a) { + var b = this.entity.parent.id; Entry.dispatchEvent("entityClick", this.entity); Entry.stage.isObjectClick = !0; - "minimize" != Entry.type && Entry.engine.isState("stop") && (this.offset = {x:-this.parent.x + this.entity.getX() - (.75 * b.stageX - 240), y:-this.parent.y - this.entity.getY() - (.75 * b.stageY - 135)}, this.cursor = "move", this.entity.initCommand(), Entry.container.selectObject(a)); + "minimize" != Entry.type && Entry.engine.isState("stop") && (this.offset = {x:-this.parent.x + this.entity.getX() - (.75 * a.stageX - 240), y:-this.parent.y - this.entity.getY() - (.75 * a.stageY - 135)}, this.cursor = "move", this.entity.initCommand(), Entry.container.selectObject(b)); }); - this.object.on("pressup", function(b) { + this.object.on("pressup", function(a) { Entry.dispatchEvent("entityClickCanceled", this.entity); this.cursor = "pointer"; this.entity.checkCommand(); }); - this.object.on("pressmove", function(b) { - "minimize" != Entry.type && Entry.engine.isState("stop") && !this.entity.parent.getLock() && (this.entity.doCommand(), this.entity.setX(.75 * b.stageX - 240 + this.offset.x), this.entity.setY(-(.75 * b.stageY - 135) - this.offset.y), Entry.stage.updateObject()); + this.object.on("pressmove", function(a) { + "minimize" != Entry.type && Entry.engine.isState("stop") && !this.entity.parent.getLock() && (this.entity.doCommand(), this.entity.setX(.75 * a.stageX - 240 + this.offset.x), this.entity.setY(-(.75 * a.stageY - 135) - this.offset.y), Entry.stage.updateObject()); }); }; -Entry.EntityObject.prototype.injectModel = function(a, b) { - "sprite" == this.type ? this.setImage(a) : "textBox" == this.type && (a = this.parent, b.text = b.text || a.text || a.name, this.setFont(b.font), this.setBGColour(b.bgColor), this.setColour(b.colour), this.setUnderLine(b.underLine), this.setStrike(b.strike), this.setText(b.text)); - b && this.syncModel_(b); -}; -Entry.EntityObject.prototype.syncModel_ = function(a) { - this.setX(a.x); - this.setY(a.y); - this.setRegX(a.regX); - this.setRegY(a.regY); - this.setScaleX(a.scaleX); - this.setScaleY(a.scaleY); - this.setRotation(a.rotation); - this.setDirection(a.direction, !0); - this.setLineBreak(a.lineBreak); - this.setWidth(a.width); - this.setHeight(a.height); - this.setText(a.text); - this.setTextAlign(a.textAlign); - this.setFontSize(a.fontSize || this.getFontSize()); - this.setVisible(a.visible); +Entry.EntityObject.prototype.injectModel = function(b, a) { + if ("sprite" == this.type) { + this.setImage(b); + } else { + if ("textBox" == this.type) { + var c = this.parent; + a.text = a.text || c.text || c.name; + this.setFont(a.font); + this.setBGColour(a.bgColor); + this.setColour(a.colour); + this.setUnderLine(a.underLine); + this.setStrike(a.strike); + this.setText(a.text); + } + } + a && this.syncModel_(a); +}; +Entry.EntityObject.prototype.syncModel_ = function(b) { + this.setX(b.x); + this.setY(b.y); + this.setRegX(b.regX); + this.setRegY(b.regY); + this.setScaleX(b.scaleX); + this.setScaleY(b.scaleY); + this.setRotation(b.rotation); + this.setDirection(b.direction, !0); + this.setLineBreak(b.lineBreak); + this.setWidth(b.width); + this.setHeight(b.height); + this.setText(b.text); + this.setTextAlign(b.textAlign); + this.setFontSize(b.fontSize || this.getFontSize()); + this.setVisible(b.visible); }; Entry.EntityObject.prototype.initCommand = function() { Entry.engine.isState("stop") && (this.isCommandValid = !1, Entry.stateManager && Entry.stateManager.addCommand("edit entity", this, this.restoreEntity, this.toJSON())); @@ -8155,20 +7338,20 @@ Entry.EntityObject.prototype.doCommand = function() { Entry.EntityObject.prototype.checkCommand = function() { Entry.engine.isState("stop") && !this.isCommandValid && Entry.dispatchEvent("cancelLastCommand"); }; -Entry.EntityObject.prototype.restoreEntity = function(a) { - var b = this.toJSON(); - this.syncModel_(a); +Entry.EntityObject.prototype.restoreEntity = function(b) { + var a = this.toJSON(); + this.syncModel_(b); Entry.dispatchEvent("updateObject"); - Entry.stateManager && Entry.stateManager.addCommand("restore object", this, this.restoreEntity, b); + Entry.stateManager && Entry.stateManager.addCommand("restore object", this, this.restoreEntity, a); }; -Entry.EntityObject.prototype.setX = function(a) { - "number" == typeof a && (this.x = a, this.object.x = this.x, this.isClone || this.parent.updateCoordinateView(), this.updateDialog(), Entry.requestUpdate = !0); +Entry.EntityObject.prototype.setX = function(b) { + "number" == typeof b && (this.x = b, this.object.x = this.x, this.isClone || this.parent.updateCoordinateView(), this.updateDialog(), Entry.requestUpdate = !0); }; Entry.EntityObject.prototype.getX = function() { return this.x; }; -Entry.EntityObject.prototype.setY = function(a) { - "number" == typeof a && (this.y = a, this.object.y = -this.y, this.isClone || this.parent.updateCoordinateView(), this.updateDialog(), Entry.requestUpdate = !0); +Entry.EntityObject.prototype.setY = function(b) { + "number" == typeof b && (this.y = b, this.object.y = -this.y, this.isClone || this.parent.updateCoordinateView(), this.updateDialog(), Entry.requestUpdate = !0); }; Entry.EntityObject.prototype.getY = function() { return this.y; @@ -8176,18 +7359,18 @@ Entry.EntityObject.prototype.getY = function() { Entry.EntityObject.prototype.getDirection = function() { return this.direction; }; -Entry.EntityObject.prototype.setDirection = function(a, b) { - a || (a = 0); - "vertical" != this.parent.getRotateMethod() || b || (0 <= this.direction && 180 > this.direction) == (0 <= a && 180 > a) || (this.setScaleX(-this.getScaleX()), Entry.stage.updateObject(), this.flip = !this.flip); - this.direction = a.mod(360); +Entry.EntityObject.prototype.setDirection = function(b, a) { + b || (b = 0); + "vertical" != this.parent.getRotateMethod() || a || (0 <= this.direction && 180 > this.direction) == (0 <= b && 180 > b) || (this.setScaleX(-this.getScaleX()), Entry.stage.updateObject(), this.flip = !this.flip); + this.direction = b.mod(360); this.object.direction = this.direction; this.isClone || this.parent.updateRotationView(); Entry.dispatchEvent("updateObject"); Entry.requestUpdate = !0; }; -Entry.EntityObject.prototype.setRotation = function(a) { - "free" != this.parent.getRotateMethod() && (a = 0); - this.rotation = a.mod(360); +Entry.EntityObject.prototype.setRotation = function(b) { + "free" != this.parent.getRotateMethod() && (b = 0); + this.rotation = b.mod(360); this.object.rotation = this.rotation; this.updateDialog(); this.isClone || this.parent.updateRotationView(); @@ -8197,26 +7380,26 @@ Entry.EntityObject.prototype.setRotation = function(a) { Entry.EntityObject.prototype.getRotation = function() { return this.rotation; }; -Entry.EntityObject.prototype.setRegX = function(a) { - "textBox" == this.type && (a = 0); - this.regX = a; +Entry.EntityObject.prototype.setRegX = function(b) { + "textBox" == this.type && (b = 0); + this.regX = b; this.object.regX = this.regX; Entry.requestUpdate = !0; }; Entry.EntityObject.prototype.getRegX = function() { return this.regX; }; -Entry.EntityObject.prototype.setRegY = function(a) { - "textBox" == this.type && (a = 0); - this.regY = a; +Entry.EntityObject.prototype.setRegY = function(b) { + "textBox" == this.type && (b = 0); + this.regY = b; this.object.regY = this.regY; Entry.requestUpdate = !0; }; Entry.EntityObject.prototype.getRegY = function() { return this.regY; }; -Entry.EntityObject.prototype.setScaleX = function(a) { - this.scaleX = a; +Entry.EntityObject.prototype.setScaleX = function(b) { + this.scaleX = b; this.object.scaleX = this.scaleX; this.parent.updateCoordinateView(); this.updateDialog(); @@ -8225,8 +7408,8 @@ Entry.EntityObject.prototype.setScaleX = function(a) { Entry.EntityObject.prototype.getScaleX = function() { return this.scaleX; }; -Entry.EntityObject.prototype.setScaleY = function(a) { - this.scaleY = a; +Entry.EntityObject.prototype.setScaleY = function(b) { + this.scaleY = b; this.object.scaleY = this.scaleY; this.parent.updateCoordinateView(); this.updateDialog(); @@ -8235,19 +7418,19 @@ Entry.EntityObject.prototype.setScaleY = function(a) { Entry.EntityObject.prototype.getScaleY = function() { return this.scaleY; }; -Entry.EntityObject.prototype.setSize = function(a) { - 1 > a && (a = 1); - a /= this.getSize(); - this.setScaleX(this.getScaleX() * a); - this.setScaleY(this.getScaleY() * a); +Entry.EntityObject.prototype.setSize = function(b) { + 1 > b && (b = 1); + b /= this.getSize(); + this.setScaleX(this.getScaleX() * b); + this.setScaleY(this.getScaleY() * b); this.isClone || this.parent.updateCoordinateView(); Entry.requestUpdate = !0; }; Entry.EntityObject.prototype.getSize = function() { return (this.getWidth() * Math.abs(this.getScaleX()) + this.getHeight() * Math.abs(this.getScaleY())) / 2; }; -Entry.EntityObject.prototype.setWidth = function(a) { - this.width = a; +Entry.EntityObject.prototype.setWidth = function(b) { + this.width = b; this.object.width = this.width; this.textObject && this.getLineBreak() && (this.textObject.lineWidth = this.width); this.updateDialog(); @@ -8257,8 +7440,8 @@ Entry.EntityObject.prototype.setWidth = function(a) { Entry.EntityObject.prototype.getWidth = function() { return this.width; }; -Entry.EntityObject.prototype.setHeight = function(a) { - this.height = a; +Entry.EntityObject.prototype.setHeight = function(b) { + this.height = b; this.textObject && (this.object.height = this.height, this.alignTextBox()); this.updateDialog(); this.updateBG(); @@ -8267,65 +7450,65 @@ Entry.EntityObject.prototype.setHeight = function(a) { Entry.EntityObject.prototype.getHeight = function() { return this.height; }; -Entry.EntityObject.prototype.setColour = function(a) { - a || (a = "#000000"); - this.colour = a; +Entry.EntityObject.prototype.setColour = function(b) { + b || (b = "#000000"); + this.colour = b; this.textObject && (this.textObject.color = this.colour); Entry.requestUpdate = !0; }; Entry.EntityObject.prototype.getColour = function() { return this.colour; }; -Entry.EntityObject.prototype.setBGColour = function(a) { - a || (a = "transparent"); - this.bgColor = a; +Entry.EntityObject.prototype.setBGColour = function(b) { + b || (b = "transparent"); + this.bgColor = b; this.updateBG(); Entry.requestUpdate = !0; }; Entry.EntityObject.prototype.getBGColour = function() { return this.bgColor; }; -Entry.EntityObject.prototype.setUnderLine = function(a) { - void 0 === a && (a = !1); - this.underLine = a; - this.textObject.underLine = a; +Entry.EntityObject.prototype.setUnderLine = function(b) { + void 0 === b && (b = !1); + this.underLine = b; + this.textObject.underLine = b; Entry.requestUpdate = !0; }; Entry.EntityObject.prototype.getUnderLine = function() { return this.underLine; }; -Entry.EntityObject.prototype.setStrike = function(a) { - void 0 === a && (a = !1); - this.strike = a; - this.textObject.strike = a; +Entry.EntityObject.prototype.setStrike = function(b) { + void 0 === b && (b = !1); + this.strike = b; + this.textObject.strike = b; Entry.requestUpdate = !0; }; Entry.EntityObject.prototype.getStrike = function() { return this.strike; }; Entry.EntityObject.prototype.getFont = function() { - var a = []; - this.fontBold && a.push("bold"); - this.fontItalic && a.push("italic"); - a.push(this.getFontSize() + "px"); - a.push(this.fontType); - return a.join(" "); -}; -Entry.EntityObject.prototype.setFont = function(a) { - if ("textBox" == this.parent.objectType && this.font !== a) { - a || (a = "20px Nanum Gothic"); - var b = a.split(" "), c; - if (c = -1 < b.indexOf("bold")) { - b.splice(c - 1, 1), this.setFontBold(!0); - } - if (c = -1 < b.indexOf("italic")) { - b.splice(c - 1, 1), this.setFontItalic(!0); - } - c = parseInt(b.shift()); + var b = []; + this.fontBold && b.push("bold"); + this.fontItalic && b.push("italic"); + b.push(this.getFontSize() + "px"); + b.push(this.fontType); + return b.join(" "); +}; +Entry.EntityObject.prototype.setFont = function(b) { + if ("textBox" == this.parent.objectType && this.font !== b) { + b || (b = "20px Nanum Gothic"); + var a = b.split(" "), c = 0; + if (c = -1 < a.indexOf("bold")) { + a.splice(c - 1, 1), this.setFontBold(!0); + } + if (c = -1 < a.indexOf("italic")) { + a.splice(c - 1, 1), this.setFontItalic(!0); + } + c = parseInt(a.shift()); this.setFontSize(c); - this.setFontType(b.join(" ")); + this.setFontType(a.join(" ")); this.font = this.getFont(); - this.textObject.font = a; + this.textObject.font = b; Entry.stage.update(); this.setWidth(this.textObject.getMeasuredWidth()); this.updateBG(); @@ -8342,17 +7525,17 @@ Entry.EntityObject.prototype.syncFont = function() { Entry.EntityObject.prototype.getFontType = function() { return this.fontType; }; -Entry.EntityObject.prototype.setFontType = function(a) { - "textBox" == this.parent.objectType && (this.fontType = a ? a : "Nanum Gothic", this.syncFont()); +Entry.EntityObject.prototype.setFontType = function(b) { + "textBox" == this.parent.objectType && (this.fontType = b ? b : "Nanum Gothic", this.syncFont()); }; -Entry.EntityObject.prototype.getFontSize = function(a) { +Entry.EntityObject.prototype.getFontSize = function(b) { return this.fontSize; }; -Entry.EntityObject.prototype.setFontSize = function(a) { - "textBox" == this.parent.objectType && this.fontSize != a && (this.fontSize = a ? a : 20, this.syncFont(), this.alignTextBox()); +Entry.EntityObject.prototype.setFontSize = function(b) { + "textBox" == this.parent.objectType && this.fontSize != b && (this.fontSize = b ? b : 20, this.syncFont(), this.alignTextBox()); }; -Entry.EntityObject.prototype.setFontBold = function(a) { - this.fontBold = a; +Entry.EntityObject.prototype.setFontBold = function(b) { + this.fontBold = b; Entry.requestUpdate = !0; }; Entry.EntityObject.prototype.toggleFontBold = function() { @@ -8360,8 +7543,8 @@ Entry.EntityObject.prototype.toggleFontBold = function() { this.syncFont(); return this.fontBold; }; -Entry.EntityObject.prototype.setFontItalic = function(a) { - this.fontItalic = a; +Entry.EntityObject.prototype.setFontItalic = function(b) { + this.fontItalic = b; Entry.requestUpdate = !0; }; Entry.EntityObject.prototype.toggleFontItalic = function() { @@ -8369,50 +7552,50 @@ Entry.EntityObject.prototype.toggleFontItalic = function() { this.syncFont(); return this.fontItalic; }; -Entry.EntityObject.prototype.setFontName = function(a) { - for (var b = this.font.split(" "), c = [], d = 0, e = b.length;d < e;d++) { - ("bold" === b[d] || "italic" === b[d] || -1 < b[d].indexOf("px")) && c.push(b[d]); +Entry.EntityObject.prototype.setFontName = function(b) { + for (var a = this.font.split(" "), c = [], d = 0, e = a.length;d < e;d++) { + ("bold" === a[d] || "italic" === a[d] || -1 < a[d].indexOf("px")) && c.push(a[d]); } - this.setFont(c.join(" ") + " " + a); + this.setFont(c.join(" ") + " " + b); }; Entry.EntityObject.prototype.getFontName = function() { if ("textBox" == this.type) { if (!this.font) { return ""; } - for (var a = this.font.split(" "), b = [], c = 0, d = a.length;c < d;c++) { - "bold" !== a[c] && "italic" !== a[c] && -1 === a[c].indexOf("px") && b.push(a[c]); + for (var b = this.font.split(" "), a = [], c = 0, d = b.length;c < d;c++) { + "bold" !== b[c] && "italic" !== b[c] && -1 === b[c].indexOf("px") && a.push(b[c]); } - return b.join(" ").trim(); + return a.join(" ").trim(); } }; -Entry.EntityObject.prototype.setText = function(a) { - "textBox" == this.parent.objectType && (void 0 === a && (a = ""), this.text = a, this.textObject.text = this.text, this.lineBreak || (this.setWidth(this.textObject.getMeasuredWidth()), this.parent.updateCoordinateView()), this.updateBG(), Entry.stage.updateObject()); +Entry.EntityObject.prototype.setText = function(b) { + "textBox" == this.parent.objectType && (void 0 === b && (b = ""), this.text = b, this.textObject.text = this.text, this.lineBreak || (this.setWidth(this.textObject.getMeasuredWidth()), this.parent.updateCoordinateView()), this.updateBG(), Entry.stage.updateObject()); }; Entry.EntityObject.prototype.getText = function() { return this.text; }; -Entry.EntityObject.prototype.setTextAlign = function(a) { - "textBox" == this.parent.objectType && (void 0 === a && (a = Entry.TEXT_ALIGN_CENTER), this.textAlign = a, this.textObject.textAlign = Entry.TEXT_ALIGNS[this.textAlign], this.alignTextBox(), this.updateBG(), Entry.stage.updateObject()); +Entry.EntityObject.prototype.setTextAlign = function(b) { + "textBox" == this.parent.objectType && (void 0 === b && (b = Entry.TEXT_ALIGN_CENTER), this.textAlign = b, this.textObject.textAlign = Entry.TEXT_ALIGNS[this.textAlign], this.alignTextBox(), this.updateBG(), Entry.stage.updateObject()); }; Entry.EntityObject.prototype.getTextAlign = function() { return this.textAlign; }; -Entry.EntityObject.prototype.setLineBreak = function(a) { +Entry.EntityObject.prototype.setLineBreak = function(b) { if ("textBox" == this.parent.objectType) { - void 0 === a && (a = !1); - var b = this.lineBreak; - this.lineBreak = a; - b && !this.lineBreak ? (this.textObject.lineWidth = null, this.setHeight(this.textObject.getMeasuredLineHeight()), this.setText(this.getText().replace(/\n/g, ""))) : !b && this.lineBreak && (this.setFontSize(this.getFontSize() * this.getScaleX()), this.setHeight(3 * this.textObject.getMeasuredLineHeight()), this.setWidth(this.getWidth() * this.getScaleX()), this.setScaleX(1), this.setScaleY(1), this.textObject.lineWidth = this.getWidth(), this.alignTextBox()); + void 0 === b && (b = !1); + var a = this.lineBreak; + this.lineBreak = b; + a && !this.lineBreak ? (this.textObject.lineWidth = null, this.setHeight(this.textObject.getMeasuredLineHeight()), this.setText(this.getText().replace(/\n/g, ""))) : !a && this.lineBreak && (this.setFontSize(this.getFontSize() * this.getScaleX()), this.setHeight(3 * this.textObject.getMeasuredLineHeight()), this.setWidth(this.getWidth() * this.getScaleX()), this.setScaleX(1), this.setScaleY(1), this.textObject.lineWidth = this.getWidth(), this.alignTextBox()); Entry.stage.updateObject(); } }; Entry.EntityObject.prototype.getLineBreak = function() { return this.lineBreak; }; -Entry.EntityObject.prototype.setVisible = function(a) { - void 0 === a && (a = !0); - this.visible = a; +Entry.EntityObject.prototype.setVisible = function(b) { + void 0 === b && (b = !0); + this.visible = b; this.object.visible = this.visible; this.dialog && this.syncDialogVisible(); Entry.requestUpdate = !0; @@ -8421,28 +7604,28 @@ Entry.EntityObject.prototype.setVisible = function(a) { Entry.EntityObject.prototype.getVisible = function() { return this.visible; }; -Entry.EntityObject.prototype.setImage = function(a) { - delete a._id; +Entry.EntityObject.prototype.setImage = function(b) { + delete b._id; Entry.assert("sprite" == this.type, "Set image is only for sprite object"); - a.id || (a.id = Entry.generateHash()); - this.picture = a; - var b = this.picture.dimension, c = this.getRegX() - this.getWidth() / 2, d = this.getRegY() - this.getHeight() / 2; - this.setWidth(b.width); - this.setHeight(b.height); - b.scaleX || (b.scaleX = this.getScaleX(), b.scaleY = this.getScaleY()); + b.id || (b.id = Entry.generateHash()); + this.picture = b; + var a = this.picture.dimension, c = this.getRegX() - this.getWidth() / 2, d = this.getRegY() - this.getHeight() / 2; + this.setWidth(a.width); + this.setHeight(a.height); + a.scaleX || (a.scaleX = this.getScaleX(), a.scaleY = this.getScaleY()); this.setScaleX(this.scaleX); this.setScaleY(this.scaleY); this.setRegX(this.width / 2 + c); this.setRegY(this.height / 2 + d); - var e = Entry.container.getCachedPicture(a.id); + var e = Entry.container.getCachedPicture(b.id); if (e) { Entry.image = e, this.object.image = e, this.object.cache(0, 0, this.getWidth(), this.getHeight()); } else { e = new Image; - a.fileurl ? e.src = a.fileurl : (b = a.filename, e.src = Entry.defaultPath + "/uploads/" + b.substring(0, 2) + "/" + b.substring(2, 4) + "/image/" + b + ".png"); + b.fileurl ? e.src = b.fileurl : (a = b.filename, e.src = Entry.defaultPath + "/uploads/" + a.substring(0, 2) + "/" + a.substring(2, 4) + "/image/" + a + ".png"); var f = this; - e.onload = function(b) { - Entry.container.cachePicture(a.id, e); + e.onload = function(a) { + Entry.container.cachePicture(b.id, e); Entry.image = e; f.object.image = e; f.object.cache(0, 0, f.getWidth(), f.getHeight()); @@ -8453,35 +7636,35 @@ Entry.EntityObject.prototype.setImage = function(a) { Entry.dispatchEvent("updateObject"); }; Entry.EntityObject.prototype.applyFilter = function() { - var a = this.effect, b = this.object; - (function(b, a) { - for (var e in b) { - if (b[e] !== a[e]) { + var b = this.effect, a = this.object; + (function(a, b) { + for (var e in a) { + if (a[e] !== b[e]) { return !1; } } return !0; - })(a, this.getInitialEffectValue()) || (function(b, a) { + })(b, this.getInitialEffectValue()) || (function(a, b) { var e = [], f = Entry.adjustValueWithMaxMin; - b.brightness = b.brightness; + a.brightness = a.brightness; var g = new createjs.ColorMatrix; - g.adjustColor(f(b.brightness, -100, 100), 0, 0, 0); + g.adjustColor(f(a.brightness, -100, 100), 0, 0, 0); g = new createjs.ColorMatrixFilter(g); e.push(g); - b.hue = b.hue.mod(360); + a.hue = a.hue.mod(360); g = new createjs.ColorMatrix; - g.adjustColor(0, 0, 0, b.hue); + g.adjustColor(0, 0, 0, a.hue); g = new createjs.ColorMatrixFilter(g); e.push(g); - var g = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1], h = 10.8 * b.hsv * Math.PI / 180, k = Math.cos(h), h = Math.sin(h), l = Math.abs(b.hsv / 100); + var g = [1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1], h = 10.8 * a.hsv * Math.PI / 180, k = Math.cos(h), h = Math.sin(h), l = Math.abs(a.hsv / 100); 1 < l && (l -= Math.floor(l)); 0 < l && .33 >= l ? g = [1, 0, 0, 0, 0, 0, k, h, 0, 0, 0, -1 * h, k, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1] : .66 >= l ? g = [k, 0, h, 0, 0, 0, 1, 0, 0, 0, h, 0, k, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1] : .99 >= l && (g = [k, h, 0, 0, 0, -1 * h, k, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]); g = (new createjs.ColorMatrix).concat(g); g = new createjs.ColorMatrixFilter(g); e.push(g); - a.alpha = b.alpha = f(b.alpha, 0, 1); - a.filters = e; - }(a, b), b.cache(0, 0, this.getWidth(), this.getHeight()), Entry.requestUpdate = !0); + b.alpha = a.alpha = f(a.alpha, 0, 1); + b.filters = e; + }(b, a), a.cache(0, 0, this.getWidth(), this.getHeight()), Entry.requestUpdate = !0); }; Entry.EntityObject.prototype.resetFilter = function() { "sprite" == this.parent.objectType && (this.object.filters = [], this.setInitialEffectValue(), this.object.alpha = this.effect.alpha, this.object.cache(0, 0, this.getWidth(), this.getHeight()), Entry.requestUpdate = !0); @@ -8504,8 +7687,8 @@ Entry.EntityObject.prototype.removeClone = function() { this.dialog && this.dialog.remove(); this.brush && this.removeBrush(); Entry.stage.unloadEntity(this); - var a = this.parent.clonedEntities.indexOf(this); - this.parent.clonedEntities.splice(a, 1); + var b = this.parent.clonedEntities.indexOf(this); + this.parent.clonedEntities.splice(b, 1); Entry.Utils.isFunction(this.clearExecutor) && this.clearExecutor(); } }; @@ -8513,21 +7696,21 @@ Entry.EntityObject.prototype.clearExecutor = function() { this.parent.script.clearExecutorsByEntity(this); }; Entry.EntityObject.prototype.toJSON = function() { - var a = {}; - a.x = Entry.cutDecimal(this.getX()); - a.y = Entry.cutDecimal(this.getY()); - a.regX = Entry.cutDecimal(this.getRegX()); - a.regY = Entry.cutDecimal(this.getRegY()); - a.scaleX = this.getScaleX(); - a.scaleY = this.getScaleY(); - a.rotation = Entry.cutDecimal(this.getRotation()); - a.direction = Entry.cutDecimal(this.getDirection()); - a.width = Entry.cutDecimal(this.getWidth()); - a.height = Entry.cutDecimal(this.getHeight()); - a.font = this.getFont(); - a.visible = this.getVisible(); - "textBox" == this.parent.objectType && (a.colour = this.getColour(), a.text = this.getText(), a.textAlign = this.getTextAlign(), a.lineBreak = this.getLineBreak(), a.bgColor = this.getBGColour(), a.underLine = this.getUnderLine(), a.strike = this.getStrike(), a.fontSize = this.getFontSize()); - return a; + var b = {}; + b.x = Entry.cutDecimal(this.getX()); + b.y = Entry.cutDecimal(this.getY()); + b.regX = Entry.cutDecimal(this.getRegX()); + b.regY = Entry.cutDecimal(this.getRegY()); + b.scaleX = this.getScaleX(); + b.scaleY = this.getScaleY(); + b.rotation = Entry.cutDecimal(this.getRotation()); + b.direction = Entry.cutDecimal(this.getDirection()); + b.width = Entry.cutDecimal(this.getWidth()); + b.height = Entry.cutDecimal(this.getHeight()); + b.font = this.getFont(); + b.visible = this.getVisible(); + "textBox" == this.parent.objectType && (b.colour = this.getColour(), b.text = this.getText(), b.textAlign = this.getTextAlign(), b.lineBreak = this.getLineBreak(), b.bgColor = this.getBGColour(), b.underLine = this.getUnderLine(), b.strike = this.getStrike(), b.fontSize = this.getFontSize()); + return b; }; Entry.EntityObject.prototype.setInitialEffectValue = function() { this.effect = this.getInitialEffectValue(); @@ -8543,1220 +7726,374 @@ Entry.EntityObject.prototype.removeBrush = function() { Entry.EntityObject.prototype.updateBG = function() { if (this.bgObject) { this.bgObject.graphics.clear(); - var a = this.getWidth(), b = this.getHeight(); - this.bgObject.graphics.setStrokeStyle(1).beginStroke().beginFill(this.getBGColour()).drawRect(-a / 2, -b / 2, a, b); + 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 = a / 2; + this.bgObject.x = b / 2; break; case Entry.TEXT_ALIGN_CENTER: this.bgObject.x = 0; break; case Entry.TEXT_ALIGN_RIGHT: - this.bgObject.x = -a / 2; + this.bgObject.x = -b / 2; } } } }; Entry.EntityObject.prototype.alignTextBox = function() { if ("textBox" == this.type) { - var a = this.textObject; + var b = this.textObject; if (this.lineBreak) { - var b = a.getMeasuredLineHeight(); - a.y = b / 2 - this.getHeight() / 2; + var a = b.getMeasuredLineHeight(); + b.y = a / 2 - this.getHeight() / 2; switch(this.textAlign) { case Entry.TEXT_ALIGN_CENTER: - a.x = 0; + b.x = 0; break; case Entry.TEXT_ALIGN_LEFT: - a.x = -this.getWidth() / 2; + b.x = -this.getWidth() / 2; break; case Entry.TEXT_ALIGN_RIGHT: - a.x = this.getWidth() / 2; + b.x = this.getWidth() / 2; } - a.maxHeight = this.getHeight(); + b.maxHeight = this.getHeight(); } else { - a.x = 0, a.y = 0; + b.x = 0, b.y = 0; } } }; Entry.EntityObject.prototype.syncDialogVisible = function() { this.dialog && (this.dialog.object.visible = this.visible); }; -Entry.Func = function(a) { - this.id = a ? a.id : Entry.generateHash(); - this.content = a ? new Entry.Code(a.content) : new Entry.Code([[{type:"function_create", copyable:!1, deletable:!1, x:40, y:40}]]); - this.blockMenuBlock = this.block = null; - this.hashMap = {}; - this.paramMap = {}; - var b = function() { - }; - b.prototype = Entry.block.function_general; - b = new b; - b.changeEvent = new Entry.Event; - b.template = Lang.template.function_general; - Entry.block["func_" + this.id] = b; - if (a) { - a = this.content._blockMap; - for (var c in a) { - Entry.Func.registerParamBlock(a[c].type); - } - Entry.Func.generateWsBlock(this); - } - Entry.Func.registerFunction(this); - Entry.Func.updateMenu(); +Entry.Helper = function() { + this.visible = !1; }; -Entry.Func.threads = {}; -Entry.Func.registerFunction = function(a) { - var b = Entry.playground.mainWorkspace; - b && (this._targetFuncBlock = b.getBlockMenu().getCategoryCodes("func").createThread([{type:"func_" + a.id}]), a.blockMenuBlock = this._targetFuncBlock); +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); + 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"])); }; -Entry.Func.executeFunction = function(a) { - var b = this.threads[a]; - if (b = Entry.Engine.computeThread(b.entity, b)) { - return this.threads[a] = b, !0; +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); } - delete this.threads[a]; - return !1; -}; -Entry.Func.clearThreads = function() { - this.threads = {}; -}; -Entry.Func.prototype.init = function(a) { - this.id = a.id; - this.content = Blockly.Xml.textToDom(a.content); - this.block = Blockly.Xml.textToDom("" + a.block + "").childNodes[0]; }; -Entry.Func.prototype.destroy = function() { - this.blockMenuBlock.destroy(); +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}); + } }; -Entry.Func.edit = function(a) { - this.cancelEdit(); - this.targetFunc = a; - this.initEditView(a.content); - this.bindFuncChangeEvent(); - this.updateMenu(); +p.getView = function() { + return this.view; }; -Entry.Func.initEditView = function(a) { - this.menuCode || this.setupMenuCode(); - var b = Entry.playground.mainWorkspace; - b.setMode(Entry.Workspace.MODE_OVERLAYBOARD); - b.changeOverlayBoardCode(a); - this._workspaceStateEvent = b.changeEvent.attach(this, this.endEdit); +p.resize = function() { }; -Entry.Func.endEdit = function(a) { - this.unbindFuncChangeEvent(); - this._workspaceStateEvent.destroy(); - delete this._workspaceStateEvent; - switch(a) { - case "save": - this.save(); - case "cancelEdit": - this.cancelEdit(); +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;d < e;d++) { + var f = a[d]; + c.push({key:f[0], value:f[1]}); + } } + this.data = c; }; -Entry.Func.save = function() { - this.targetFunc.generateBlock(!0); - Entry.variableContainer.saveFunction(this.targetFunc); +Entry.ActivityReporter = function() { + this._activities = []; }; -Entry.Func.syncFuncName = function(a) { - var b = 0; - a = a.split(" "); - var c = "", d; - d = Blockly.mainWorkspace.getAllBlocks(); - for (var e = 0;e < d.length;e++) { - var f = d[e]; - if ("function_general" === f.type) { - for (var f = f.inputList, g = 0;g < f.length;g++) { - var h = f[g]; - 0 < h.fieldRow.length && h.fieldRow[0] instanceof Blockly.FieldLabel && void 0 != h.fieldRow[0].text_ && (c += h.fieldRow[0].text_, c += " "); - } - c = c.trim(); - if (c === this.srcFName && this.srcFName.split(" ").length == a.length) { - for (c = 0;c < f.length;c++) { - if (h = f[c], 0 < h.fieldRow.length && h.fieldRow[0] instanceof Blockly.FieldLabel && void 0 != h.fieldRow[0].text_) { - if (void 0 === a[b]) { - f.splice(c, 1); - break; - } else { - h.fieldRow[0].text_ = a[b]; - } - b++; - } - } +(function(b) { + b.add = function(a) { + if (a && 0 !== a.length) { + if (!(a instanceof Entry.Activity)) { + var b = a.shift(); + a = new Entry.Activity(b, a); } - c = ""; - b = 0; + this._activities.push(a); } - } - b = Blockly.Xml.workspaceToDom(Blockly.mainWorkspace); - Blockly.mainWorkspace.clear(); - Blockly.Xml.domToWorkspace(Blockly.mainWorkspace, b); + }; + b.clear = function() { + this._activities = []; + }; + b.get = function() { + return this._activities; + }; + b.report = function() { + }; +})(Entry.ActivityReporter.prototype); +Entry.State = function(b, a, c, d) { + this.caller = a; + this.func = c; + 3 < arguments.length && (this.params = Array.prototype.slice.call(arguments).slice(3)); + this.message = b; + this.time = Entry.getUpTime(); + this.isPass = Entry.Command[b] ? Entry.Command[b].isPass : !1; }; -Entry.Func.cancelEdit = function() { - this.targetFunc && (Entry.Func.isEdit = !1, this.targetFunc.block || (this._targetFuncBlock.destroy(), delete Entry.variableContainer.functions_[this.targetFunc.id], delete Entry.variableContainer.selected), delete this.targetFunc, this.updateMenu(), Entry.variableContainer.updateList(), Entry.playground.mainWorkspace.setMode(Entry.Workspace.MODE_BOARD)); +Entry.State.prototype.generateMessage = function() { }; -Entry.Func.getMenuXml = function() { - var a = []; - this.targetFunc || (a = a.concat(this.createBtn)); - if (this.targetFunc) { - var b = this.FIELD_BLOCK, b = b.replace("#1", Entry.generateHash()), b = b.replace("#2", Entry.generateHash()), b = Blockly.Xml.textToDom(b).childNodes, a = a.concat(Entry.nodeListToArray(b)) - } - for (var c in Entry.variableContainer.functions_) { - b = Entry.variableContainer.functions_[c], b === this.targetFunc ? (b = Entry.Func.generateBlock(this.targetFunc, Blockly.Xml.workspaceToDom(Entry.Func.workspace), b.id).block, a.push(b)) : a.push(b.block); - } - return a; +Entry.StateManager = function() { + this.undoStack_ = []; + this.redoStack_ = []; + this.isIgnore = this.isRestore = !1; + Entry.addEventListener("cancelLastCommand", function(b) { + Entry.stateManager.cancelLastCommand(); + }); + Entry.addEventListener("run", function(b) { + Entry.stateManager.updateView(); + }); + Entry.addEventListener("stop", function(b) { + Entry.stateManager.updateView(); + }); + Entry.addEventListener("saveWorkspace", function(b) { + Entry.stateManager.addStamp(); + }); + Entry.addEventListener("undo", function(b) { + Entry.stateManager.undo(); + }); + Entry.addEventListener("redo", function(b) { + Entry.stateManager.redo(); + }); }; -Entry.Func.syncFunc = function() { - var a = Entry.Func; - if (a.targetFunc) { - var b = a.workspace.topBlocks_[0].toString(), c = a.workspace.topBlocks_.length; - (a.fieldText != b || a.workspaceLength != c) && 1 > Blockly.Block.dragMode_ && (a.updateMenu(), a.fieldText = b, a.workspaceLength = c); +Entry.StateManager.prototype.generateView = function(b, a) { +}; +Entry.StateManager.prototype.addCommand = function(b, a, c, d) { + if (!this.isIgnoring()) { + if (this.isRestoring()) { + var e = new Entry.State, f = Array.prototype.slice.call(arguments); + Entry.State.prototype.constructor.apply(e, f); + this.redoStack_.push(e); + Entry.reporter && Entry.reporter.report(e); + } else { + e = new Entry.State, f = Array.prototype.slice.call(arguments), Entry.State.prototype.constructor.apply(e, f), this.undoStack_.push(e), Entry.reporter && Entry.reporter.report(e), this.updateView(); + } + Entry.creationChangedEvent && Entry.creationChangedEvent.notify(); } }; -Entry.Func.setupMenuCode = function() { - var a = Entry.playground.mainWorkspace; - a && (a = a.getBlockMenu().getCategoryCodes("func"), this._fieldLabel = a.createThread([{type:"function_field_label"}]).getFirstBlock(), this._fieldString = a.createThread([{type:"function_field_string", params:[{type:this.requestParamBlock("string")}]}]).getFirstBlock(), this._fieldBoolean = a.createThread([{type:"function_field_boolean", params:[{type:this.requestParamBlock("boolean")}]}]).getFirstBlock(), this.menuCode = a); +Entry.StateManager.prototype.cancelLastCommand = function() { + this.canUndo() && (this.undoStack_.pop(), this.updateView(), Entry.creationChangedEvent && Entry.creationChangedEvent.notify()); }; -Entry.Func.refreshMenuCode = function() { - if (Entry.playground.mainWorkspace) { - this.menuCode || this.setupMenuCode(); - var a = Entry.block[this._fieldString.params[0].type].changeEvent._listeners.length; - 2 < a && this._fieldString.params[0].changeType(this.requestParamBlock("string")); - a = Entry.block[this._fieldBoolean.params[0].type].changeEvent._listeners.length; - 2 < a && this._fieldBoolean.params[0].changeType(this.requestParamBlock("boolean")); +Entry.StateManager.prototype.getLastCommand = function() { + return this.undoStack_[this.undoStack_.length - 1]; +}; +Entry.StateManager.prototype.undo = function() { + if (this.canUndo() && !this.isRestoring()) { + this.addActivity("undo"); + for (this.startRestore();this.undoStack_.length;) { + var b = this.undoStack_.pop(); + b.func.apply(b.caller, b.params); + if (!0 !== b.isPass) { + break; + } + } + this.updateView(); + this.endRestore(); + Entry.creationChangedEvent && Entry.creationChangedEvent.notify(); } }; -Entry.Func.requestParamBlock = function(a) { - var b = Entry.generateHash(), c; - switch(a) { - case "string": - c = Entry.block.function_param_string; - break; - case "boolean": - c = Entry.block.function_param_boolean; - break; - default: - return null; +Entry.StateManager.prototype.redo = function() { + if (this.canRedo() && !this.isRestoring()) { + this.addActivity("redo"); + var b = this.redoStack_.pop(); + b.func.apply(b.caller, b.params); + this.updateView(); + Entry.creationChangedEvent && Entry.creationChangedEvent.notify(); } - b = a + "Param_" + b; - a = Entry.Func.createParamBlock(b, c, a); - Entry.block[b] = a; - return b; }; -Entry.Func.registerParamBlock = function(a) { - -1 < a.indexOf("stringParam") ? Entry.Func.createParamBlock(a, Entry.block.function_param_string, a) : -1 < a.indexOf("booleanParam") && Entry.Func.createParamBlock(a, Entry.block.function_param_boolean, a); +Entry.StateManager.prototype.updateView = function() { + this.undoButton && this.redoButton && (this.canUndo() ? this.undoButton.addClass("active") : this.undoButton.removeClass("active"), this.canRedo() ? this.redoButton.addClass("active") : this.redoButton.removeClass("active")); }; -Entry.Func.createParamBlock = function(a, b, c) { - var d = function() { - }; - c = "string" === c ? "function_param_string" : "function_param_boolean"; - d.prototype = b; - d = new d; - d.changeEvent = new Entry.Event; - d.template = Lang.template[c]; - return Entry.block[a] = d; +Entry.StateManager.prototype.startRestore = function() { + this.isRestore = !0; }; -Entry.Func.updateMenu = function() { - var a = Entry.playground.mainWorkspace; - a && (a = a.getBlockMenu(), this.targetFunc ? (this.menuCode || this.setupMenuCode(), a.banClass("functionInit"), a.unbanClass("functionEdit")) : (a.unbanClass("functionInit"), a.banClass("functionEdit")), a.reDraw()); +Entry.StateManager.prototype.endRestore = function() { + this.isRestore = !1; }; -Entry.Func.prototype.edit = function() { - Entry.Func.isEdit || (Entry.Func.isEdit = !0, Entry.Func.svg ? this.parentView.appendChild(this.svg) : Entry.Func.initEditView()); +Entry.StateManager.prototype.isRestoring = function() { + return this.isRestore; }; -Entry.Func.generateBlock = function(a) { - a = Entry.block["func_" + a.id]; - var b = {template:a.template, params:a.params}, c = /(%\d)/mi, d = a.template.split(c), e = "", f = 0, g = 0, h; - for (h in d) { - var k = d[h]; - c.test(k) ? (k = Number(k.split("%")[1]) - 1, k = a.params[k], "Indicator" !== k.type && ("boolean" === k.accept ? (e += Lang.template.function_param_boolean + (f ? f : ""), f++) : (e += Lang.template.function_param_string + (g ? g : ""), g++))) : e += k; - } - return {block:b, description:e}; +Entry.StateManager.prototype.startIgnore = function() { + this.isIgnore = !0; }; -Entry.Func.prototype.generateBlock = function(a) { - a = Entry.Func.generateBlock(this); - this.block = a.block; - this.description = a.description; +Entry.StateManager.prototype.endIgnore = function() { + this.isIgnore = !1; }; -Entry.Func.generateWsBlock = function(a) { - this.unbindFuncChangeEvent(); - a = a ? a : this.targetFunc; - for (var b = a.content.getEventMap("funcDef")[0].params[0], c = 0, d = 0, e = [], f = "", g = a.hashMap, h = a.paramMap;b;) { - var k = b.params[0]; - switch(b.type) { - case "function_field_label": - f = f + " " + k; - break; - case "function_field_boolean": - Entry.Mutator.mutate(k.type, {template:Lang.Blocks.FUNCTION_logical_variable + " " + (c ? c : "")}); - g[k.type] = !1; - h[k.type] = c + d; - c++; - e.push({type:"Block", accept:"boolean"}); - f += " %" + (c + d); - break; - case "function_field_string": - Entry.Mutator.mutate(k.type, {template:Lang.Blocks.FUNCTION_character_variable + " " + (d ? d : "")}), g[k.type] = !1, h[k.type] = c + d, d++, f += " %" + (c + d), e.push({type:"Block", accept:"string"}); - } - b = b.getOutputBlock(); - } - c++; - f += " %" + (c + d); - e.push({type:"Indicator", img:"block_icon/function_03.png", size:12}); - Entry.Mutator.mutate("func_" + a.id, {params:e, template:f}); - for (var l in g) { - g[l] ? (b = -1 < l.indexOf("string") ? Lang.Blocks.FUNCTION_character_variable : Lang.Blocks.FUNCTION_logical_variable, Entry.Mutator.mutate(l, {template:b})) : g[l] = !0; - } - this.bindFuncChangeEvent(a); +Entry.StateManager.prototype.isIgnoring = function() { + return this.isIgnore; }; -Entry.Func.bindFuncChangeEvent = function(a) { - a = a ? a : this.targetFunc; - !this._funcChangeEvent && a.content.getEventMap("funcDef")[0].view && (this._funcChangeEvent = a.content.getEventMap("funcDef")[0].view._contents[1].changeEvent.attach(this, this.generateWsBlock)); +Entry.StateManager.prototype.canUndo = function() { + return 0 < this.undoStack_.length && Entry.engine.isState("stop"); }; -Entry.Func.unbindFuncChangeEvent = function() { - this._funcChangeEvent && this._funcChangeEvent.destroy(); - delete this._funcChangeEvent; +Entry.StateManager.prototype.canRedo = function() { + return 0 < this.redoStack_.length && Entry.engine.isState("stop"); }; -Entry.Helper = function() { - this.visible = !1; +Entry.StateManager.prototype.addStamp = function() { + this.stamp = Entry.generateHash(); + this.undoStack_.length && (this.undoStack_[this.undoStack_.length - 1].stamp = this.stamp); }; -p = Entry.Helper.prototype; -p.generateView = function(a, b) { - this.parentView_ || (this.parentView_ = a, this.blockHelpData = EntryStatic.blockInfo, this.view = a = Entry.createElement("div", "entryBlockHelperWorkspace"), Entry.isForLecture && a.addClass("lecture"), this.parentView_.appendChild(a), b = Entry.createElement("div", "entryBlockHelperContentWorkspace"), b.addClass("entryBlockHelperIntro"), Entry.isForLecture && b.addClass("lecture"), a.appendChild(b), this.blockHelperContent_ = b, this.blockHelperView_ = a, a = Entry.createElement("div", "entryBlockHelperBlockWorkspace"), - this.blockHelperContent_.appendChild(a), b = Entry.createElement("div", "entryBlockHelperDescriptionWorkspace"), this.blockHelperContent_.appendChild(b), b.innerHTML = Lang.Helper.Block_click_msg, this.blockHelperDescription_ = b, this._renderView = new Entry.RenderView($(a), "LEFT"), this.code = new Entry.Code([]), this._renderView.changeCode(this.code), this.first = !0); +Entry.StateManager.prototype.isSaved = function() { + return 0 === this.undoStack_.length || this.undoStack_[this.undoStack_.length - 1].stamp == this.stamp && "string" == typeof this.stamp; }; -p.bindWorkspace = function(a) { - a && (this._blockViewObserver && this._blockViewObserver.destroy(), this.workspace = a, this._blockViewObserver = a.observe(this, "_updateSelectedBlock", ["selectedBlockView"])); +Entry.StateManager.prototype.addActivity = function(b) { + Entry.reporter && Entry.reporter.report(new Entry.State(b)); }; -p._updateSelectedBlock = function() { - var a = this.workspace.selectedBlockView; - if (a && this.visible && a != this._blockView) { - var b = a.block.type; - this._blockView = a; - this.renderBlock(b); - } -}; -p.renderBlock = function(a) { - var b = Lang.Helper[a]; - if (a && this.visible && b && !Entry.block[a].isPrimitive) { - this.first && (this.blockHelperContent_.removeClass("entryBlockHelperIntro"), this.first = !1); - this.code.clear(); - var c = Entry.block[a].def, c = c || {type:a}; - this.code.createThread([c]); - this.code.board.align(); - this.code.board.resize(); - var c = this.code.getThreads()[0].getFirstBlock().view, d = c.svgGroup.getBBox(); - a = d.width; - d = d.height; - c = c.getSkeleton().box(c).offsetX; - isNaN(c) && (c = 0); - this.blockHelperDescription_.innerHTML = b; - this._renderView.align(); - $(this.blockHelperDescription_).css({top:d + 30}); - this._renderView.svgDom.css({"margin-left":-(a / 2) - 20 - c}); - } -}; -p.getView = function() { - return this.view; -}; -p.resize = function() { -}; -Entry.HWMontior = {}; -Entry.HWMonitor = function(a) { - this.svgDom = Entry.Dom($('')); - this._hwModule = a; - var b = this; - Entry.addEventListener("windowResized", function() { - var a = b._hwModule.monitorTemplate.mode; - "both" == a && (b.resize(), b.resizeList()); - "list" == a ? b.resizeList() : b.resize(); - }); - Entry.addEventListener("hwModeChange", function() { - b.changeMode(); - }); - this.changeOffset = 0; - this.scale = .5; - this._listPortViews = {}; -}; -(function(a) { - a.initView = function() { - this.svgDom = Entry.Dom($('')); - }; - a.generateView = function() { - this.snap = Entry.SVG("hwMonitor"); - this._svgGroup = this.snap.elem("g"); - this._portMap = {n:[], e:[], s:[], w:[]}; - var b = this._hwModule.monitorTemplate, a = {href:Entry.mediaFilePath + b.imgPath, x:-b.width / 2, y:-b.height / 2, width:b.width, height:b.height}; - this._portViews = {}; - this.hwView = this._svgGroup.elem("image"); - this.hwView = this.hwView.attr(a); - this._template = b; - b = b.ports; - this.pathGroup = null; - this.pathGroup = this._svgGroup.elem("g"); - var a = [], d; - for (d in b) { - var e = this.generatePortView(b[d], "_svgGroup"); - this._portViews[d] = e; - a.push(e); - } - a.sort(function(b, a) { - return b.box.x - a.box.x; - }); - var f = this._portMap; - a.map(function(b) { - (1 > (Math.atan2(-b.box.y, b.box.x) / Math.PI + 2) % 2 ? f.n : f.s).push(b); - }); - this.resize(); - }; - a.toggleMode = function(b) { - var a = this._hwModule.monitorTemplate; - "list" == b ? (a.TempPort = null, this._hwModule.monitorTemplate.ports && (this._hwModule.monitorTemplate.TempPort = this._hwModule.monitorTemplate.ports, this._hwModule.monitorTemplate.listPorts = this.addPortEle(this._hwModule.monitorTemplate.listPorts, this._hwModule.monitorTemplate.ports)), $(this._svglistGroup).remove(), this._svgGroup && $(this._svgGroup).remove(), $(this._pathGroup).remove(), this._hwModule.monitorTemplate.mode = "list", this.generateListView()) : (this._hwModule.monitorTemplate.TempPort && - (this._hwModule.monitorTemplate.ports = this._hwModule.monitorTemplate.TempPort, this._hwModule.monitorTemplate.listPorts = this.removePortEle(this._hwModule.monitorTemplate.listPorts, this._hwModule.monitorTemplate.ports)), $(this._svglistGroup).remove(), this._hwModule.monitorTemplate.mode = "both", this.generateListView(), this.generateView()); - }; - a.setHwmonitor = function(b) { - this._hwmodule = b; - }; - a.changeMode = function(b) { - "both" == this._hwModule.monitorTemplate.mode ? this.toggleMode("list") : "list" == this._hwModule.monitorTemplate.mode && this.toggleMode("both"); - }; - a.addPortEle = function(b, a) { - if ("object" != typeof a) { - return b; - } - for (var d in a) { - b[d] = a[d]; - } - return b; - }; - a.removePortEle = function(b, a) { - if ("object" != typeof a) { - return b; - } - for (var d in a) { - delete b[d]; - } - return b; - }; - a.generateListView = function() { - this._portMapList = {n:[]}; - this._svglistGroup = null; - this.listsnap = Entry.SVG("hwMonitor"); - this._svglistGroup = this.listsnap.elem("g"); - var b = this._hwModule.monitorTemplate; - this._template = b; - b = b.listPorts; - this.pathGroup = this._svglistGroup.elem("g"); - var a = [], d; - for (d in b) { - var e = this.generatePortView(b[d], "_svglistGroup"); - this._listPortViews[d] = e; - a.push(e); - } - var f = this._portMapList; - a.map(function(b) { - f.n.push(b); - }); - this.resizeList(); - }; - a.generatePortView = function(b, a) { - a = this[a].elem("g"); - a.addClass("hwComponent"); - var d; - d = this.pathGroup.elem("path").attr({d:"m0,0", fill:"none", stroke:"input" === b.type ? "#00979d" : "#A751E3", "stroke-width":3}); - var e = a.elem("rect").attr({x:0, y:0, width:150, height:22, rx:4, ry:4, fill:"#fff", stroke:"#a0a1a1"}), f = a.elem("text").attr({x:4, y:12, fill:"#000", "class":"hwComponentName", "alignment-baseline":"central"}); - f.textContent = b.name; - f = f.getComputedTextLength(); - a.elem("rect").attr({x:f + 8, y:2, width:30, height:18, rx:9, ry:9, fill:"input" === b.type ? "#00979d" : "#A751E3"}); - var g = a.elem("text").attr({x:f + 13, y:12, fill:"#fff", "class":"hwComponentValue", "alignment-baseline":"central"}); - g.textContent = 0; - f += 40; - e.attr({width:f}); - return {group:a, value:g, type:b.type, path:d, box:{x:b.pos.x - this._template.width / 2, y:b.pos.y - this._template.height / 2, width:f}, width:f}; - }; - a.getView = function() { - return this.svgDom; - }; - a.update = function() { - var b = Entry.hw.portData, a = Entry.hw.sendQueue, d = this._hwModule.monitorTemplate.mode, e = this._hwModule.monitorTemplate.keys || [], f = []; - if ("list" == d) { - f = this._listPortViews; - } else { - if ("both" == d) { - if (f = this._listPortViews, this._portViews) { - for (var g in this._portViews) { - f[g] = this._portViews[g]; - } - } - } else { - f = this._portViews; - } - } - if (a) { - for (g in a) { - 0 != a[g] && f[g] && (f[g].type = "output"); - } - } - for (var h in f) { - if (d = f[h], "input" == d.type) { - var k = b[h]; - 0 < e.length && $.each(e, function(b, a) { - if ($.isPlainObject(k)) { - k = k[a] || 0; - } else { - return !1; - } - }); - d.value.textContent = k ? k : 0; - d.group.getElementsByTagName("rect")[1].attr({fill:"#00979D"}); - } else { - k = a[h], 0 < e.length && $.each(e, function(b, a) { - if ($.isPlainObject(k)) { - k = k[a] || 0; - } else { - return !1; - } - }), d.value.textContent = k ? k : 0, d.group.getElementsByTagName("rect")[1].attr({fill:"#A751E3"}); - } - } - }; - a.resize = function() { - this.hwView && this.hwView.attr({transform:"scale(" + this.scale + ")"}); - if (this.svgDom) { - var b = this.svgDom.get(0).getBoundingClientRect() - } - this._svgGroup.attr({transform:"translate(" + b.width / 2 + "," + b.height / 1.8 + ")"}); - this._rect = b; - 0 >= this._template.height || 0 >= b.height || (this.scale = b.height / this._template.height * this._template.height / 1E3, this.align()); - }; - a.resizeList = function() { - var b = this.svgDom.get(0).getBoundingClientRect(); - this._svglistGroup.attr({transform:"translate(" + b.width / 2 + "," + b.height / 2 + ")"}); - this._rect = b; - this.alignList(); - }; - a.align = function() { - var b; - b = this._portMap.s.concat(); - this._alignNS(b, this.scale / 3 * this._template.height + 5, 27); - b = this._portMap.n.concat(); - this._alignNS(b, -this._template.height * this.scale / 3 - 32, -27); - b = this._portMap.e.concat(); - this._alignEW(b, -this._template.width * this.scale / 3 - 5, -27); - b = this._portMap.w.concat(); - this._alignEW(b, this._template.width * this.scale / 3 - 32, -27); - }; - a.alignList = function() { - var b; - b = this._hwModule.monitorTemplate.listPorts; - for (var a = b.length, d = 0;d < b.length;d++) { - b[d].group.attr({transform:"translate(" + this._template.width * (d / a - .5) + "," + (-this._template.width / 2 - 30) + ")"}); - } - b = this._portMapList.n.concat(); - this._alignNSList(b, -this._template.width * this.scale / 2 - 32, -27); - }; - a._alignEW = function(b, a, d) { - var e = b.length, f = this._rect.height - 50; - tP = -f / 2; - bP = f / 2; - height = this._rect.height; - listVLine = wholeHeight = 0; - mode = this._hwModule.monitorTemplate; - for (f = 0;f < e;f++) { - wholeHeight += b[f].height + 5; - } - wholeHeight < bP - tP && (bP = wholeHeight / 2 + 3, tP = -wholeHeight / 2 - 3); - for (;1 < e;) { - var g = b.shift(), f = b.pop(), h = tP, k = bP, l = d; - wholeWidth <= bP - tP ? (tP += g.width + 5, bP -= f.width + 5, l = 0) : 0 === b.length ? (tP = (tP + bP) / 2 - 3, bP = tP + 6) : (tP = Math.max(tP, -width / 2 + g.width) + 15, bP = Math.min(bP, width / 2 - f.width) - 15); - wholeWidth -= g.width + f.width + 10; - a += l; - } - b.length && b[0].group.attr({transform:"translate(" + a + ",60)"}); - g && rPort && (this._movePort(g, a, tP, h), this._movePort(rPort, a, bP, k)); - }; - a._alignNS = function(b, a, d) { - for (var e = -this._rect.width / 2, f = this._rect.width / 2, g = this._rect.width, h = 0, k = 0;k < b.length;k++) { - h += b[k].width + 5; - } - h < f - e && (f = h / 2 + 3, e = -h / 2 - 3); - for (;1 < b.length;) { - var k = b.shift(), l = b.pop(), n = e, m = f, q = d; - h <= f - e ? (e += k.width + 5, f -= l.width + 5, q = 0) : 0 === b.length ? (e = (e + f) / 2 - 3, f = e + 6) : (e = Math.max(e, -g / 2 + k.width) + 15, f = Math.min(f, g / 2 - l.width) - 15); - this._movePort(k, e, a, n); - this._movePort(l, f, a, m); - h -= k.width + l.width + 10; - a += q; - } - b.length && this._movePort(b[0], (f + e - b[0].width) / 2, a, 100); - }; - a._alignNSList = function(b, a) { - a = this._rect.width; - initX = -this._rect.width / 2 + 10; - initY = -this._rect.height / 2 + 10; - for (var d = listLine = wholeWidth = 0;d < b.length;d++) { - wholeWidth += b[d].width; - } - for (var e = 0, f = 0, g = initX, h, k, l = 0, d = 0;d < b.length;d++) { - k = b[d], d != b.length - 1 && (l = b[d + 1]), f += k.width, lP = initX, h = initY + 30 * e, k.group.attr({transform:"translate(" + lP + "," + h + ")"}), initX += k.width + 10, f > a - (k.width + l.width / 2.2) && (e += 1, initX = g, f = 0); - } - }; - a._movePort = function(b, a, d, e) { - var f = a, g = b.box.x * this.scale, h = b.box.y * this.scale; - a > e ? (f = a - b.width, a = a > g && g > e ? "M" + g + "," + d + "L" + g + "," + h : "M" + (a + e) / 2 + "," + d + "l0," + (h > d ? 28 : -3) + "H" + g + "L" + g + "," + h) : a = a < g && g < e ? "m" + g + "," + d + "L" + g + "," + h : "m" + (e + a) / 2 + "," + d + "l0," + (h > d ? 28 : -3) + "H" + g + "L" + g + "," + h; - b.group.attr({transform:"translate(" + f + "," + d + ")"}); - b.path.attr({d:a}); - }; -})(Entry.HWMonitor.prototype); -Entry.HW = function() { - this.connectTrial = 0; - this.isFirstConnect = !0; - this.initSocket(); - this.connected = !1; - this.portData = {}; - this.sendQueue = {}; - this.outputQueue = {}; - this.settingQueue = {}; - this.socketType = this.hwModule = this.selectedDevice = null; - Entry.addEventListener("stop", this.setZero); - this.hwInfo = {11:Entry.Arduino, 12:Entry.SensorBoard, 13:Entry.CODEino, 14:Entry.joystick, 15:Entry.dplay, 16:Entry.nemoino, 17:Entry.Xbot, 18:Entry.ardublock, 24:Entry.Hamster, 25:Entry.Albert, 31:Entry.Bitbrick, 42:Entry.Arduino, 51:Entry.Neobot, 71:Entry.Robotis_carCont, 72:Entry.Robotis_openCM70, 81:Entry.Arduino}; -}; -Entry.HW.TRIAL_LIMIT = 1; -p = Entry.HW.prototype; -p.initSocket = function() { - try { - if (this.connectTrial >= Entry.HW.TRIAL_LIMIT) { - this.isFirstConnect || Entry.toast.alert(Lang.Menus.connect_hw, Lang.Menus.connect_fail, !1), this.isFirstConnect = !1; - } else { - var a = this, b, c; - this.connected = !1; - this.connectTrial++; - if (-1 < location.protocol.indexOf("https")) { - c = new WebSocket("wss://hardware.play-entry.org:23518"); - } else { - try { - b = new WebSocket("ws://127.0.0.1:23518"), b.binaryType = "arraybuffer", b.onopen = function() { - a.socketType = "WebSocket"; - a.initHardware(b); - }.bind(this), b.onmessage = function(b) { - b = JSON.parse(b.data); - a.checkDevice(b); - a.updatePortData(b); - }.bind(this), b.onclose = function() { - "WebSocket" === a.socketType && (this.socket = null, a.initSocket()); - }; - } catch (d) { - } - try { - c = new WebSocket("wss://hardware.play-entry.org:23518"); - } catch (d) { - } - } - c.binaryType = "arraybuffer"; - c.onopen = function() { - a.socketType = "WebSocketSecurity"; - a.initHardware(c); - }; - c.onmessage = function(b) { - b = JSON.parse(b.data); - a.checkDevice(b); - a.updatePortData(b); - }; - c.onclose = function() { - "WebSocketSecurity" === a.socketType && (this.socket = null, a.initSocket()); - }; - Entry.dispatchEvent("hwChanged"); - } - } catch (d) { - } -}; -p.retryConnect = function() { - this.connectTrial = 0; - this.initSocket(); -}; -p.initHardware = function(a) { - this.socket = a; - this.connectTrial = 0; - this.connected = !0; - Entry.dispatchEvent("hwChanged"); - Entry.playground && Entry.playground.object && Entry.playground.setMenu(Entry.playground.object.objectType); -}; -p.setDigitalPortValue = function(a, b) { - this.sendQueue[a] = b; - this.removePortReadable(a); -}; -p.getAnalogPortValue = function(a) { - return this.connected ? this.portData["a" + a] : 0; -}; -p.getDigitalPortValue = function(a) { - if (!this.connected) { - return 0; - } - this.setPortReadable(a); - return void 0 !== this.portData[a] ? this.portData[a] : 0; -}; -p.setPortReadable = function(a) { - this.sendQueue.readablePorts || (this.sendQueue.readablePorts = []); - var b = !1, c; - for (c in this.sendQueue.readablePorts) { - if (this.sendQueue.readablePorts[c] == a) { - b = !0; - break; - } - } - b || this.sendQueue.readablePorts.push(a); -}; -p.removePortReadable = function(a) { - if (this.sendQueue.readablePorts || Array.isArray(this.sendQueue.readablePorts)) { - var b, c; - for (c in this.sendQueue.readablePorts) { - if (this.sendQueue.readablePorts[c] == a) { - b = Number(c); - break; - } - } - this.sendQueue.readablePorts = void 0 != b ? this.sendQueue.readablePorts.slice(0, b).concat(this.sendQueue.readablePorts.slice(b + 1, this.sendQueue.readablePorts.length)) : []; - } -}; -p.update = function() { - this.socket && 1 == this.socket.readyState && this.socket.send(JSON.stringify(this.sendQueue)); -}; -p.updatePortData = function(a) { - this.portData = a; - this.hwMonitor && this.hwMonitor.update(); -}; -p.closeConnection = function() { - this.socket && this.socket.close(); -}; -p.downloadConnector = function() { - window.open("http://download.play-entry.org/apps/Entry_HW_1.5.6_Setup.exe", "_blank").focus(); -}; -p.downloadSource = function() { - window.open("http://play-entry.com/down/board.ino", "_blank").focus(); -}; -p.setZero = function() { - Entry.hw.hwModule && Entry.hw.hwModule.setZero(); -}; -p.checkDevice = function(a) { - void 0 !== a.company && (a = "" + a.company + a.model, a != this.selectedDevice && (this.selectedDevice = a, this.hwModule = this.hwInfo[a], Entry.dispatchEvent("hwChanged"), Entry.toast.success("\ud558\ub4dc\uc6e8\uc5b4 \uc5f0\uacb0 \uc131\uacf5", "\ud558\ub4dc\uc6e8\uc5b4 \uc544\uc774\ucf58\uc744 \ub354\ube14\ud074\ub9ad\ud558\uba74, \uc13c\uc11c\uac12\ub9cc \ud655\uc778\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.", !0), this.hwModule.monitorTemplate && (this.hwMonitor ? (this.hwMonitor._hwModule = - this.hwModule, this.hwMonitor.initView()) : this.hwMonitor = new Entry.HWMonitor(this.hwModule), Entry.propertyPanel.addMode("hw", this.hwMonitor), a = this.hwModule.monitorTemplate, "both" == a.mode ? (a.mode = "list", this.hwMonitor.generateListView(), a.mode = "general", this.hwMonitor.generateView(), a.mode = "both") : "list" == a.mode ? this.hwMonitor.generateListView() : this.hwMonitor.generateView()))); -}; -p.banHW = function() { - var a = this.hwInfo, b; - for (b in a) { - Entry.playground.mainWorkspace.blockMenu.banClass(a[b].name, !0); - } -}; -Entry.PropertyPanel = function() { - this.modes = {}; - this.selected = null; -}; -(function(a) { - a.generateView = function(b, a) { - this._view = Entry.Dom("div", {class:"propertyPanel", parent:$(b)}); - this._tabView = Entry.Dom("div", {class:"propertyTab", parent:this._view}); - this._contentView = Entry.Dom("div", {class:"propertyContent", parent:this._view}); - this._cover = Entry.Dom("div", {classes:["propertyPanelCover", "entryRemove"], parent:this._view}); - b = Entry.Dom("div", {class:"entryObjectSelectedImgWorkspace", parent:this._view}); - this.initializeSplitter(b); - }; - a.addMode = function(b, a) { - var d = a.getView(), d = Entry.Dom(d, {parent:this._contentView}), e = Entry.Dom("
" + Lang.Menus[b] + "
", {classes:["propertyTabElement", "propertyTab" + b], parent:this._tabView}), f = this; - e.bind("click", function() { - f.select(b); - }); - this.modes[b] && (this.modes[b].tabDom.remove(), this.modes[b].contentDom.remove(), "hw" == b && ($(this.modes).removeClass(".propertyTabhw"), $(".propertyTabhw").unbind("dblclick"))); - this.modes[b] = {obj:a, tabDom:e, contentDom:d}; - "hw" == b && $(".propertyTabhw").bind("dblclick", function() { - Entry.dispatchEvent("hwModeChange"); - }); - }; - a.resize = function(b) { - this._view.css({width:b + "px", top:9 * b / 16 + 123 - 22 + "px"}); - 430 <= b ? this._view.removeClass("collapsed") : this._view.addClass("collapsed"); - Entry.dispatchEvent("windowResized"); - b = this.selected; - "hw" == b ? this.modes.hw.obj.listPorts ? this.modes[b].obj.resizeList() : this.modes[b].obj.resize() : this.modes[b].obj.resize(); - }; - a.select = function(b) { - for (var a in this.modes) { - var d = this.modes[a]; - d.tabDom.removeClass("selected"); - d.contentDom.addClass("entryRemove"); - d.obj.visible = !1; - } - a = this.modes[b]; - a.tabDom.addClass("selected"); - a.contentDom.removeClass("entryRemove"); - a.obj.resize && a.obj.resize(); - a.obj.visible = !0; - this.selected = b; - }; - a.initializeSplitter = function(b) { - var a = this; - b.bind("mousedown touchstart", function(b) { - a._cover.removeClass("entryRemove"); - Entry.container.disableSort(); - Entry.container.splitterEnable = !0; - Entry.documentMousemove && (Entry.container.resizeEvent = Entry.documentMousemove.attach(this, function(b) { - Entry.container.splitterEnable && Entry.resizeElement({canvasWidth:b.clientX || b.x}); - })); - }); - $(document).bind("mouseup touchend", function(b) { - if (b = Entry.container.resizeEvent) { - Entry.container.splitterEnable = !1, Entry.documentMousemove.detach(b), a._cover.addClass("entryRemove"), delete Entry.container.resizeEvent; - } - Entry.container.enableSort(); - }); - }; -})(Entry.PropertyPanel.prototype); -Entry.init = function(a, b) { - Entry.assert("object" === typeof b, "Init option is not object"); - this.events_ = {}; - this.interfaceState = {menuWidth:264}; - Entry.Utils.bindGlobalEvent("resize mousedown mousemove keydown keyup dispose".split(" ")); - this.options = b; - this.parseOptions(b); - this.mediaFilePath = (b.libDir ? b.libDir : "/lib") + "/entryjs/images/"; - this.defaultPath = b.defaultDir || ""; - this.blockInjectPath = b.blockInjectDir || ""; - "workspace" == this.type && this.isPhone() && (this.type = "phone"); - this.initialize_(); - this.view_ = a; - this.view_.setAttribute("class", "entry"); - Entry.initFonts(b.fonts); - this.createDom(a, this.type); - this.loadInterfaceState(); - this.overridePrototype(); - this.maxCloneLimit = 302; - this.cloudSavable = !0; - this.startTime = (new Date).getTime(); - document.onkeydown = function(b) { - Entry.dispatchEvent("keyPressed", b); - }; - document.onkeyup = function(b) { - Entry.dispatchEvent("keyUpped", b); - }; - window.onresize = function(b) { - Entry.dispatchEvent("windowResized", b); - }; - window.onbeforeunload = this.beforeUnload; - Entry.addEventListener("saveWorkspace", function(b) { - Entry.addActivity("save"); - }); - "IE" != Entry.getBrowserType().substr(0, 2) || window.flashaudio ? createjs.Sound.registerPlugins([createjs.WebAudioPlugin]) : (createjs.FlashAudioPlugin.swfPath = this.mediaFilePath + "media/", createjs.Sound.registerPlugins([createjs.FlashAudioPlugin]), window.flashaudio = !0); - Entry.soundQueue = new createjs.LoadQueue; - Entry.soundQueue.installPlugin(createjs.Sound); - Entry.loadAudio_([Entry.mediaFilePath + "sounds/click.mp3", Entry.mediaFilePath + "sounds/click.wav", Entry.mediaFilePath + "sounds/click.ogg"], "entryMagneting"); - Entry.loadAudio_([Entry.mediaFilePath + "sounds/delete.mp3", Entry.mediaFilePath + "sounds/delete.ogg", Entry.mediaFilePath + "sounds/delete.wav"], "entryDelete"); - createjs.Sound.stop(); -}; -Entry.loadAudio_ = function(a, b) { - if (window.Audio && a.length) { - for (;0 < a.length;) { - a = a[0]; - a.match(/\/([^.]+)./); - Entry.soundQueue.loadFile({id:b, src:a, type:createjs.LoadQueue.SOUND}); - break; - } - } -}; -Entry.initialize_ = function() { - this.stage = new Entry.Stage; - Entry.engine && Entry.engine.clearTimer(); - this.engine = new Entry.Engine; - this.propertyPanel = new Entry.PropertyPanel; - this.container = new Entry.Container; - this.helper = new Entry.Helper; - this.youtube = new Entry.Youtube; - this.variableContainer = new Entry.VariableContainer; - this.commander = new Entry.Commander(this.type); - this.scene = new Entry.Scene; - this.playground = new Entry.Playground; - this.toast = new Entry.Toast; - this.hw && this.hw.closeConnection(); - this.hw = new Entry.HW; - if (Entry.enableActivityLogging) { - this.reporter = new Entry.Reporter(!1); - } else { - if ("workspace" == this.type || "phone" == this.type) { - this.reporter = new Entry.Reporter(!0); - } - } -}; -Entry.createDom = function(a, b) { - if (b && "workspace" != b) { - "minimize" == b ? (c = Entry.createElement("canvas"), c.className = "entryCanvasWorkspace", c.id = "entryCanvas", c.width = 640, c.height = 360, d = Entry.createElement("div", "entryCanvasWrapper"), d.appendChild(c), a.appendChild(d), this.canvas_ = c, this.stage.initStage(this.canvas_), d = Entry.createElement("div"), a.appendChild(d), this.engineView = d, this.engine.generateView(this.engineView, b)) : "phone" == b && (this.stateManagerView = c = Entry.createElement("div"), this.stateManager.generateView(this.stateManagerView, - b), d = Entry.createElement("div"), a.appendChild(d), this.engineView = d, this.engine.generateView(this.engineView, b), c = Entry.createElement("canvas"), c.addClass("entryCanvasPhone"), c.id = "entryCanvas", c.width = 640, c.height = 360, d.insertBefore(c, this.engine.footerView_), this.canvas_ = c, this.stage.initStage(this.canvas_), c = Entry.createElement("div"), a.appendChild(c), this.containerView = c, this.container.generateView(this.containerView, b), c = Entry.createElement("div"), - a.appendChild(c), this.playgroundView = c, this.playground.generateView(this.playgroundView, b)); - } else { - Entry.documentMousedown.attach(this, this.cancelObjectEdit); - var c = Entry.createElement("div"); - a.appendChild(c); - this.sceneView = c; - this.scene.generateView(this.sceneView, b); - c = Entry.createElement("div"); - this.sceneView.appendChild(c); - this.stateManagerView = c; - this.stateManager.generateView(this.stateManagerView, b); - var d = Entry.createElement("div"); - a.appendChild(d); - this.engineView = d; - this.engine.generateView(this.engineView, b); - c = Entry.createElement("canvas"); - c.addClass("entryCanvasWorkspace"); - c.id = "entryCanvas"; - c.width = 640; - c.height = 360; - d.insertBefore(c, this.engine.addButton); - c.addEventListener("mousewheel", function(b) { - var a = Entry.variableContainer.getListById(Entry.stage.mouseCoordinate); - b = 0 < b.wheelDelta ? !0 : !1; - for (var c = 0;c < a.length;c++) { - var d = a[c]; - d.scrollButton_.y = b ? 46 <= d.scrollButton_.y ? d.scrollButton_.y - 23 : 23 : d.scrollButton_.y + 23; - d.updateView(); - } - }); - this.canvas_ = c; - this.stage.initStage(this.canvas_); - c = Entry.createElement("div"); - this.propertyPanel.generateView(a, b); - this.containerView = c; - this.container.generateView(this.containerView, b); - this.propertyPanel.addMode("object", this.container); - this.helper.generateView(this.containerView, b); - this.propertyPanel.addMode("helper", this.helper); - c = Entry.createElement("div"); - a.appendChild(c); - this.playgroundView = c; - this.playground.generateView(this.playgroundView, b); - this.propertyPanel.select("object"); - this.helper.bindWorkspace(this.playground.mainWorkspace); - } -}; -Entry.start = function(a) { - this.FPS || (this.FPS = 60); - Entry.assert("number" == typeof this.FPS, "FPS must be number"); - Entry.engine.start(this.FPS); -}; -Entry.parseOptions = function(a) { - this.type = a.type; - this.projectSaveable = a.projectsaveable; - void 0 === this.projectSaveable && (this.projectSaveable = !0); - this.objectAddable = a.objectaddable; - void 0 === this.objectAddable && (this.objectAddable = !0); - this.objectEditable = a.objectEditable; - void 0 === this.objectEditable && (this.objectEditable = !0); - this.objectEditable || (this.objectAddable = !1); - this.objectDeletable = a.objectdeletable; - void 0 === this.objectDeletable && (this.objectDeletable = !0); - this.soundEditable = a.soundeditable; - void 0 === this.soundEditable && (this.soundEditable = !0); - this.pictureEditable = a.pictureeditable; - void 0 === this.pictureEditable && (this.pictureEditable = !0); - this.sceneEditable = a.sceneEditable; - void 0 === this.sceneEditable && (this.sceneEditable = !0); - this.functionEnable = a.functionEnable; - void 0 === this.functionEnable && (this.functionEnable = !0); - this.messageEnable = a.messageEnable; - void 0 === this.messageEnable && (this.messageEnable = !0); - this.variableEnable = a.variableEnable; - void 0 === this.variableEnable && (this.variableEnable = !0); - this.listEnable = a.listEnable; - void 0 === this.listEnable && (this.listEnable = !0); - this.hasVariableManager = a.hasvariablemanager; - this.variableEnable || this.messageEnable || this.listEnable || this.functionEnable ? void 0 === this.hasVariableManager && (this.hasVariableManager = !0) : this.hasVariableManager = !1; - this.isForLecture = a.isForLecture; -}; -Entry.initFonts = function(a) { - this.fonts = a; - a || (this.fonts = []); -}; -Entry.Activity = function(a, b) { - this.name = a; - this.timestamp = new Date; - a = []; - if (void 0 !== b) { - for (var c = 0, d = b.length;c < d;c++) { - var e = b[c]; - a.push({key:e[0], value:e[1]}); - } - } - this.data = a; -}; -Entry.ActivityReporter = function() { - this._activities = []; -}; -(function(a) { - a.add = function(b) { - if (b && 0 !== b.length) { - if (!(b instanceof Entry.Activity)) { - var a = b.shift(); - b = new Entry.Activity(a, b); - } - this._activities.push(b); - } - }; - a.clear = function() { - this._activities = []; - }; - a.get = function() { - return this._activities; - }; - a.report = function() { - }; -})(Entry.ActivityReporter.prototype); -Entry.State = function(a, b, c, d) { - this.caller = b; - this.func = c; - 3 < arguments.length && (this.params = Array.prototype.slice.call(arguments).slice(3)); - this.message = a; - this.time = Entry.getUpTime(); - this.isPass = Entry.Command[a] ? Entry.Command[a].isPass : !1; -}; -Entry.State.prototype.generateMessage = function() { -}; -Entry.StateManager = function() { - this.undoStack_ = []; - this.redoStack_ = []; - this.isIgnore = this.isRestore = !1; - Entry.addEventListener("cancelLastCommand", function(a) { - Entry.stateManager.cancelLastCommand(); - }); - Entry.addEventListener("run", function(a) { - Entry.stateManager.updateView(); - }); - Entry.addEventListener("stop", function(a) { - Entry.stateManager.updateView(); - }); - Entry.addEventListener("saveWorkspace", function(a) { - Entry.stateManager.addStamp(); - }); - Entry.addEventListener("undo", function(a) { - Entry.stateManager.undo(); - }); - Entry.addEventListener("redo", function(a) { - Entry.stateManager.redo(); - }); -}; -Entry.StateManager.prototype.generateView = function(a, b) { -}; -Entry.StateManager.prototype.addCommand = function(a, b, c, d) { - if (!this.isIgnoring()) { - if (this.isRestoring()) { - var e = new Entry.State, f = Array.prototype.slice.call(arguments); - Entry.State.prototype.constructor.apply(e, f); - this.redoStack_.push(e); - Entry.reporter && Entry.reporter.report(e); - } else { - e = new Entry.State, f = Array.prototype.slice.call(arguments), Entry.State.prototype.constructor.apply(e, f), this.undoStack_.push(e), Entry.reporter && Entry.reporter.report(e), this.updateView(); - } - Entry.creationChangedEvent && Entry.creationChangedEvent.notify(); - } -}; -Entry.StateManager.prototype.cancelLastCommand = function() { - this.canUndo() && (this.undoStack_.pop(), this.updateView(), Entry.creationChangedEvent && Entry.creationChangedEvent.notify()); -}; -Entry.StateManager.prototype.getLastCommand = function() { - return this.undoStack_[this.undoStack_.length - 1]; -}; -Entry.StateManager.prototype.undo = function() { - if (this.canUndo() && !this.isRestoring()) { - this.addActivity("undo"); - for (this.startRestore();this.undoStack_.length;) { - var a = this.undoStack_.pop(); - a.func.apply(a.caller, a.params); - if (!0 !== a.isPass) { - break; - } - } - this.updateView(); - this.endRestore(); - Entry.creationChangedEvent && Entry.creationChangedEvent.notify(); - } -}; -Entry.StateManager.prototype.redo = function() { - if (this.canRedo() && !this.isRestoring()) { - this.addActivity("redo"); - var a = this.redoStack_.pop(); - a.func.apply(a.caller, a.params); - this.updateView(); - Entry.creationChangedEvent && Entry.creationChangedEvent.notify(); - } -}; -Entry.StateManager.prototype.updateView = function() { - this.undoButton && this.redoButton && (this.canUndo() ? this.undoButton.addClass("active") : this.undoButton.removeClass("active"), this.canRedo() ? this.redoButton.addClass("active") : this.redoButton.removeClass("active")); -}; -Entry.StateManager.prototype.startRestore = function() { - this.isRestore = !0; -}; -Entry.StateManager.prototype.endRestore = function() { - this.isRestore = !1; -}; -Entry.StateManager.prototype.isRestoring = function() { - return this.isRestore; -}; -Entry.StateManager.prototype.startIgnore = function() { - this.isIgnore = !0; -}; -Entry.StateManager.prototype.endIgnore = function() { - this.isIgnore = !1; -}; -Entry.StateManager.prototype.isIgnoring = function() { - return this.isIgnore; -}; -Entry.StateManager.prototype.canUndo = function() { - return 0 < this.undoStack_.length && Entry.engine.isState("stop"); -}; -Entry.StateManager.prototype.canRedo = function() { - return 0 < this.redoStack_.length && Entry.engine.isState("stop"); -}; -Entry.StateManager.prototype.addStamp = function() { - this.stamp = Entry.generateHash(); - this.undoStack_.length && (this.undoStack_[this.undoStack_.length - 1].stamp = this.stamp); -}; -Entry.StateManager.prototype.isSaved = function() { - return 0 === this.undoStack_.length || this.undoStack_[this.undoStack_.length - 1].stamp == this.stamp && "string" == typeof this.stamp; -}; -Entry.StateManager.prototype.addActivity = function(a) { - Entry.reporter && Entry.reporter.report(new Entry.State(a)); -}; -Entry.STATIC = {OBJECT:0, ENTITY:1, SPRITE:2, SOUND:3, VARIABLE:4, FUNCTION:5, SCENE:6, MESSAGE:7, BLOCK_MODEL:8, BLOCK_RENDER_MODEL:9, BOX_MODEL:10, THREAD_MODEL:11, DRAG_INSTANCE:12, BLOCK_STATIC:0, BLOCK_MOVE:1, BLOCK_FOLLOW:2, RETURN:0, CONTINUE:1, BREAK:2, PASS:3}; -Entry.BlockModel = function() { - Entry.Model(this); -}; -Entry.BlockModel.prototype.schema = {id:null, x:0, y:0, type:null, params:{}, statements:{}, prev:null, next:null, view:null}; -Entry.BlockRenderModel = function() { - Entry.Model(this); -}; -Entry.BlockRenderModel.prototype.schema = {id:0, type:Entry.STATIC.BLOCK_RENDER_MODEL, x:0, y:0, width:0, height:0, magneting:!1}; -Entry.BoxModel = function() { - Entry.Model(this); -}; -Entry.BoxModel.prototype.schema = {id:0, type:Entry.STATIC.BOX_MODEL, x:0, y:0, width:0, height:0}; -Entry.DragInstance = function(a) { - Entry.Model(this); - this.set(a); -}; -Entry.DragInstance.prototype.schema = {type:Entry.STATIC.DRAG_INSTANCE, startX:0, startY:0, offsetX:0, offsetY:0, absX:0, absY:0, prev:null, height:0, mode:0, isNew:!1}; -Entry.ThreadModel = function() { - Entry.Model(this); -}; -Entry.ThreadModel.prototype.schema = {id:0, type:Entry.STATIC.THREAD_MODEL, x:0, y:0, width:0, minWidth:0, height:0}; -Entry.EntryObject = function(a) { - if (a) { - this.id = a.id; - this.name = a.name || a.sprite.name; - this.text = a.text || this.name; - this.objectType = a.objectType; - this.objectType || (this.objectType = "sprite"); - this.script = new Entry.Code(a.script ? a.script : [], this); - this.pictures = a.sprite.pictures; - this.sounds = []; - this.sounds = a.sprite.sounds; - for (var b = 0;b < this.sounds.length;b++) { - this.sounds[b].id || (this.sounds[b].id = Entry.generateHash()), Entry.initSound(this.sounds[b]); - } - this.lock = a.lock ? a.lock : !1; - this.isEditing = !1; - "sprite" == this.objectType && (this.selectedPicture = a.selectedPictureId ? this.getPicture(a.selectedPictureId) : this.pictures[0]); - this.scene = Entry.scene.getSceneById(a.scene) || Entry.scene.selectedScene; - this.setRotateMethod(a.rotateMethod); - this.entity = new Entry.EntityObject(this); - this.entity.injectModel(this.selectedPicture ? this.selectedPicture : null, a.entity ? a.entity : this.initEntity(a)); - this.clonedEntities = []; - Entry.stage.loadObject(this); - for (b in this.pictures) { - var c = this.pictures[b]; - c.objectId = this.id; - c.id || (c.id = Entry.generateHash()); - var d = new Image; - c.fileurl ? d.src = c.fileurl : c.fileurl ? d.src = c.fileurl : (a = c.filename, d.src = Entry.defaultPath + "/uploads/" + a.substring(0, 2) + "/" + a.substring(2, 4) + "/image/" + a + ".png"); - Entry.Loader.addQueue(); - d.onload = function(b) { - Entry.container.cachePicture(c.id, d); - Entry.Loader.removeQueue(); - Entry.requestUpdate = !0; - }; - } +Entry.EntryObject = function(b) { + if (b) { + this.id = b.id; + this.name = b.name || b.sprite.name; + this.text = b.text || this.name; + this.objectType = b.objectType; + this.objectType || (this.objectType = "sprite"); + this.script = new Entry.Code(b.script ? b.script : [], this); + this.pictures = b.sprite.pictures; + this.sounds = []; + this.sounds = b.sprite.sounds; + for (var a = 0;a < this.sounds.length;a++) { + this.sounds[a].id || (this.sounds[a].id = Entry.generateHash()), Entry.initSound(this.sounds[a]); + } + this.lock = b.lock ? b.lock : !1; + this.isEditing = !1; + "sprite" == this.objectType && (this.selectedPicture = b.selectedPictureId ? this.getPicture(b.selectedPictureId) : this.pictures[0]); + this.scene = Entry.scene.getSceneById(b.scene) || Entry.scene.selectedScene; + this.setRotateMethod(b.rotateMethod); + this.entity = new Entry.EntityObject(this); + this.entity.injectModel(this.selectedPicture ? this.selectedPicture : null, b.entity ? b.entity : this.initEntity(b)); + this.clonedEntities = []; + Entry.stage.loadObject(this); + for (a in this.pictures) { + var c = this.pictures[a]; + c.objectId = this.id; + c.id || (c.id = Entry.generateHash()); + var d = new Image; + c.fileurl ? d.src = c.fileurl : c.fileurl ? d.src = c.fileurl : (b = c.filename, d.src = Entry.defaultPath + "/uploads/" + b.substring(0, 2) + "/" + b.substring(2, 4) + "/image/" + b + ".png"); + Entry.Loader.addQueue(); + d.onload = function(a) { + Entry.container.cachePicture(c.id, d); + Entry.Loader.removeQueue(); + Entry.requestUpdate = !0; + }; + } } }; Entry.EntryObject.prototype.generateView = function() { if ("workspace" == Entry.type) { - var a = Entry.createElement("li", this.id); - a.addClass("entryContainerListElementWorkspace"); - a.object = this; - a.bindOnClick(function(b) { + var b = Entry.createElement("li", this.id); + b.addClass("entryContainerListElementWorkspace"); + b.object = this; + b.bindOnClick(function(a) { Entry.container.getObject(this.id) && Entry.container.selectObject(this.id); }); - Entry.Utils.disableContextmenu(a); - var b = this; - $(a).on("contextmenu", function(a) { - a = [{text:Lang.Workspace.context_rename, callback:function(a) { - a.stopPropagation(); - a = b; - a.setLock(!1); - a.editObjectValues(!0); - a.nameView_.select(); + Entry.Utils.disableContextmenu(b); + var a = this; + $(b).on("contextmenu", function(b) { + b = [{text:Lang.Workspace.context_rename, callback:function(b) { + b.stopPropagation(); + b = a; + b.setLock(!1); + b.editObjectValues(!0); + b.nameView_.select(); }}, {text:Lang.Workspace.context_duplicate, enable:!Entry.engine.isState("run"), callback:function() { - Entry.container.addCloneObject(b); + Entry.container.addCloneObject(a); }}, {text:Lang.Workspace.context_remove, callback:function() { - Entry.container.removeObject(b); + Entry.container.removeObject(a); }}, {text:Lang.Workspace.copy_file, callback:function() { - Entry.container.setCopiedObject(b); + Entry.container.setCopiedObject(a); }}, {text:Lang.Blocks.Paste_blocks, enable:!Entry.engine.isState("run") && !!Entry.container.copiedObject, callback:function() { Entry.container.copiedObject ? Entry.container.addCloneObject(Entry.container.copiedObject) : Entry.toast.alert(Lang.Workspace.add_object_alert, Lang.Workspace.object_not_found_for_paste); }}]; - Entry.ContextMenu.show(a, "workspace-contextmenu"); + Entry.ContextMenu.show(b, "workspace-contextmenu"); }); - this.view_ = a; - var c = this, a = Entry.createElement("ul"); - a.addClass("objectInfoView"); - Entry.objectEditable || a.addClass("entryHide"); + this.view_ = b; + var c = this, b = Entry.createElement("ul"); + b.addClass("objectInfoView"); + Entry.objectEditable || b.addClass("entryHide"); var d = Entry.createElement("li"); d.addClass("objectInfo_visible"); this.entity.getVisible() || d.addClass("objectInfo_unvisible"); - d.bindOnClick(function(b) { - Entry.engine.isState("run") || (b = c.entity, b.setVisible(!b.getVisible()) ? this.removeClass("objectInfo_unvisible") : this.addClass("objectInfo_unvisible")); + d.bindOnClick(function(a) { + Entry.engine.isState("run") || (a = c.entity, a.setVisible(!a.getVisible()) ? this.removeClass("objectInfo_unvisible") : this.addClass("objectInfo_unvisible")); }); var e = Entry.createElement("li"); e.addClass("objectInfo_unlock"); this.getLock() && e.addClass("objectInfo_lock"); - e.bindOnClick(function(b) { - Entry.engine.isState("run") || (b = c, b.setLock(!b.getLock()) ? this.addClass("objectInfo_lock") : this.removeClass("objectInfo_lock"), b.updateInputViews(b.getLock())); + e.bindOnClick(function(a) { + Entry.engine.isState("run") || (a = c, a.setLock(!a.getLock()) ? this.addClass("objectInfo_lock") : this.removeClass("objectInfo_lock"), a.updateInputViews(a.getLock())); }); - a.appendChild(d); - a.appendChild(e); - this.view_.appendChild(a); - a = Entry.createElement("div"); - a.addClass("entryObjectThumbnailWorkspace"); - this.view_.appendChild(a); - this.thumbnailView_ = a; - a = Entry.createElement("div"); - a.addClass("entryObjectWrapperWorkspace"); - this.view_.appendChild(a); + b.appendChild(d); + b.appendChild(e); + this.view_.appendChild(b); + b = Entry.createElement("div"); + b.addClass("entryObjectThumbnailWorkspace"); + this.view_.appendChild(b); + this.thumbnailView_ = b; + b = Entry.createElement("div"); + b.addClass("entryObjectWrapperWorkspace"); + this.view_.appendChild(b); d = Entry.createElement("input"); - d.bindOnClick(function(b) { - b.preventDefault(); + d.bindOnClick(function(a) { + a.preventDefault(); Entry.container.selectObject(c.id); this.readOnly || (this.focus(), this.select()); }); d.addClass("entryObjectNameWorkspace"); - a.appendChild(d); + b.appendChild(d); this.nameView_ = d; this.nameView_.entryObject = this; d.setAttribute("readonly", !0); var f = this; - this.nameView_.onblur = function(b) { + this.nameView_.onblur = function(a) { this.entryObject.name = this.value; Entry.playground.reloadPlayground(); }; - this.nameView_.onkeypress = function(b) { - 13 == b.keyCode && f.editObjectValues(!1); + this.nameView_.onkeypress = function(a) { + 13 == a.keyCode && f.editObjectValues(!1); }; this.nameView_.value = this.name; d = Entry.createElement("div"); @@ -9764,38 +8101,38 @@ Entry.EntryObject.prototype.generateView = function() { d.object = this; this.editView_ = d; this.view_.appendChild(d); - Entry.objectEditable ? ($(d).mousedown(function(a) { - var c = b.isEditing; - a.stopPropagation(); - Entry.documentMousedown.notify(a); - Entry.engine.isState("run") || !1 !== c || (b.editObjectValues(!c), Entry.playground.object !== b && Entry.container.selectObject(b.id), b.nameView_.select()); - }), d.blur = function(a) { - b.editObjectComplete(); + Entry.objectEditable ? ($(d).mousedown(function(b) { + var c = a.isEditing; + b.stopPropagation(); + Entry.documentMousedown.notify(b); + Entry.engine.isState("run") || !1 !== c || (a.editObjectValues(!c), Entry.playground.object !== a && Entry.container.selectObject(a.id), a.nameView_.select()); + }), d.blur = function(b) { + a.editObjectComplete(); }) : d.addClass("entryRemove"); - Entry.objectEditable && Entry.objectDeletable && (d = Entry.createElement("div"), d.addClass("entryObjectDeleteWorkspace"), d.object = this, this.deleteView_ = d, this.view_.appendChild(d), d.bindOnClick(function(b) { + Entry.objectEditable && Entry.objectDeletable && (d = Entry.createElement("div"), d.addClass("entryObjectDeleteWorkspace"), d.object = this, this.deleteView_ = d, this.view_.appendChild(d), d.bindOnClick(function(a) { Entry.engine.isState("run") || Entry.container.removeObject(this.object); })); d = Entry.createElement("div"); d.addClass("entryObjectInformationWorkspace"); d.object = this; this.isInformationToggle = !1; - a.appendChild(d); + b.appendChild(d); this.informationView_ = d; - a = Entry.createElement("div"); - a.addClass("entryObjectRotationWrapperWorkspace"); - a.object = this; - this.view_.appendChild(a); + b = Entry.createElement("div"); + b.addClass("entryObjectRotationWrapperWorkspace"); + b.object = this; + this.view_.appendChild(b); d = Entry.createElement("span"); d.addClass("entryObjectCoordinateWorkspace"); - a.appendChild(d); + b.appendChild(d); e = Entry.createElement("span"); e.addClass("entryObjectCoordinateSpanWorkspace"); e.innerHTML = "X:"; var g = Entry.createElement("input"); g.addClass("entryObjectCoordinateInputWorkspace"); g.setAttribute("readonly", !0); - g.bindOnClick(function(b) { - b.stopPropagation(); + g.bindOnClick(function(a) { + a.stopPropagation(); this.select(); }); var h = Entry.createElement("span"); @@ -9803,8 +8140,8 @@ Entry.EntryObject.prototype.generateView = function() { h.innerHTML = "Y:"; var k = Entry.createElement("input"); k.addClass("entryObjectCoordinateInputWorkspace entryObjectCoordinateInputWorkspace_right"); - k.bindOnClick(function(b) { - b.stopPropagation(); + k.bindOnClick(function(a) { + a.stopPropagation(); this.select(); }); k.setAttribute("readonly", !0); @@ -9813,8 +8150,8 @@ Entry.EntryObject.prototype.generateView = function() { l.innerHTML = Lang.Workspace.Size + " : "; var n = Entry.createElement("input"); n.addClass("entryObjectCoordinateInputWorkspace", "entryObjectCoordinateInputWorkspace_size"); - n.bindOnClick(function(b) { - b.stopPropagation(); + n.bindOnClick(function(a) { + a.stopPropagation(); this.select(); }); n.setAttribute("readonly", !0); @@ -9829,27 +8166,27 @@ Entry.EntryObject.prototype.generateView = function() { d.sizeInput_ = n; this.coordinateView_ = d; c = this; - g.onkeypress = function(b) { - 13 == b.keyCode && c.editObjectValues(!1); + g.onkeypress = function(a) { + 13 == a.keyCode && c.editObjectValues(!1); }; - g.onblur = function(b) { - isNaN(g.value) || c.entity.setX(Number(g.value)); + g.onblur = function(a) { + isNaN(g.value) || c.entity.setX(+g.value); c.updateCoordinateView(); Entry.stage.updateObject(); }; - k.onkeypress = function(b) { - 13 == b.keyCode && c.editObjectValues(!1); + k.onkeypress = function(a) { + 13 == a.keyCode && c.editObjectValues(!1); }; - k.onblur = function(b) { - isNaN(k.value) || c.entity.setY(Number(k.value)); + k.onblur = function(a) { + isNaN(k.value) || c.entity.setY(+k.value); c.updateCoordinateView(); Entry.stage.updateObject(); }; - n.onkeypress = function(b) { - 13 == b.keyCode && c.editObjectValues(!1); + n.onkeypress = function(a) { + 13 == a.keyCode && c.editObjectValues(!1); }; - n.onblur = function(b) { - isNaN(n.value) || c.entity.setSize(Number(n.value)); + n.onblur = function(a) { + isNaN(n.value) || c.entity.setSize(+n.value); c.updateCoordinateView(); Entry.stage.updateObject(); }; @@ -9863,8 +8200,8 @@ Entry.EntryObject.prototype.generateView = function() { var m = Entry.createElement("input"); m.addClass("entryObjectRotateInputWorkspace"); m.setAttribute("readonly", !0); - m.bindOnClick(function(b) { - b.stopPropagation(); + m.bindOnClick(function(a) { + a.stopPropagation(); this.select(); }); this.rotateSpan_ = e; @@ -9875,8 +8212,8 @@ Entry.EntryObject.prototype.generateView = function() { var q = Entry.createElement("input"); q.addClass("entryObjectDirectionInputWorkspace"); q.setAttribute("readonly", !0); - q.bindOnClick(function(b) { - b.stopPropagation(); + q.bindOnClick(function(a) { + a.stopPropagation(); this.select(); }); this.directionInput_ = q; @@ -9887,59 +8224,59 @@ Entry.EntryObject.prototype.generateView = function() { d.rotateInput_ = m; d.directionInput_ = q; c = this; - m.onkeypress = function(b) { - 13 == b.keyCode && c.editObjectValues(!1); + m.onkeypress = function(a) { + 13 == a.keyCode && c.editObjectValues(!1); }; - m.onblur = function(b) { - b = m.value; - -1 != b.indexOf("\u02da") && (b = b.substring(0, b.indexOf("\u02da"))); - isNaN(b) || c.entity.setRotation(Number(b)); + m.onblur = function(a) { + a = m.value; + -1 != a.indexOf("\u02da") && (a = a.substring(0, a.indexOf("\u02da"))); + isNaN(a) || c.entity.setRotation(+a); c.updateRotationView(); Entry.stage.updateObject(); }; - q.onkeypress = function(b) { - 13 == b.keyCode && c.editObjectValues(!1); + q.onkeypress = function(a) { + 13 == a.keyCode && c.editObjectValues(!1); }; - q.onblur = function(b) { - b = q.value; - -1 != b.indexOf("\u02da") && (b = b.substring(0, b.indexOf("\u02da"))); - isNaN(b) || c.entity.setDirection(Number(b)); + q.onblur = function(a) { + a = q.value; + -1 != a.indexOf("\u02da") && (a = a.substring(0, a.indexOf("\u02da"))); + isNaN(a) || c.entity.setDirection(+a); c.updateRotationView(); Entry.stage.updateObject(); }; d = Entry.createElement("div"); d.addClass("rotationMethodWrapper"); - a.appendChild(d); + b.appendChild(d); this.rotationMethodWrapper_ = d; - a = Entry.createElement("span"); - a.addClass("entryObjectRotateMethodLabelWorkspace"); - d.appendChild(a); - a.innerHTML = Lang.Workspace.rotate_method + " : "; - a = Entry.createElement("div"); - a.addClass("entryObjectRotateModeWorkspace"); - a.addClass("entryObjectRotateModeAWorkspace"); - a.object = this; - this.rotateModeAView_ = a; - d.appendChild(a); - a.bindOnClick(function(b) { + b = Entry.createElement("span"); + b.addClass("entryObjectRotateMethodLabelWorkspace"); + d.appendChild(b); + b.innerHTML = Lang.Workspace.rotate_method + " : "; + b = Entry.createElement("div"); + b.addClass("entryObjectRotateModeWorkspace"); + b.addClass("entryObjectRotateModeAWorkspace"); + b.object = this; + this.rotateModeAView_ = b; + d.appendChild(b); + b.bindOnClick(function(a) { Entry.engine.isState("run") || this.object.getLock() || (this.object.initRotateValue("free"), this.object.setRotateMethod("free")); }); - a = Entry.createElement("div"); - a.addClass("entryObjectRotateModeWorkspace"); - a.addClass("entryObjectRotateModeBWorkspace"); - a.object = this; - this.rotateModeBView_ = a; - d.appendChild(a); - a.bindOnClick(function(b) { + b = Entry.createElement("div"); + b.addClass("entryObjectRotateModeWorkspace"); + b.addClass("entryObjectRotateModeBWorkspace"); + b.object = this; + this.rotateModeBView_ = b; + d.appendChild(b); + b.bindOnClick(function(a) { Entry.engine.isState("run") || this.object.getLock() || (this.object.initRotateValue("vertical"), this.object.setRotateMethod("vertical")); }); - a = Entry.createElement("div"); - a.addClass("entryObjectRotateModeWorkspace"); - a.addClass("entryObjectRotateModeCWorkspace"); - a.object = this; - this.rotateModeCView_ = a; - d.appendChild(a); - a.bindOnClick(function(b) { + b = Entry.createElement("div"); + b.addClass("entryObjectRotateModeWorkspace"); + b.addClass("entryObjectRotateModeCWorkspace"); + b.object = this; + this.rotateModeCView_ = b; + d.appendChild(b); + b.bindOnClick(function(a) { Entry.engine.isState("run") || this.object.getLock() || (this.object.initRotateValue("none"), this.object.setRotateMethod("none")); }); this.updateThumbnailView(); @@ -9951,252 +8288,252 @@ Entry.EntryObject.prototype.generateView = function() { return this.view_; } if ("phone" == Entry.type) { - return a = Entry.createElement("li", this.id), a.addClass("entryContainerListElementWorkspace"), a.object = this, a.bindOnClick(function(b) { + return b = Entry.createElement("li", this.id), b.addClass("entryContainerListElementWorkspace"), b.object = this, b.bindOnClick(function(a) { Entry.container.getObject(this.id) && Entry.container.selectObject(this.id); - }), $ && (b = this, context.attach("#" + this.id, [{text:Lang.Workspace.context_rename, href:"/", action:function(b) { - b.preventDefault(); - }}, {text:Lang.Workspace.context_duplicate, href:"/", action:function(a) { - a.preventDefault(); - Entry.container.addCloneObject(b); - }}, {text:Lang.Workspace.context_remove, href:"/", action:function(a) { + }), $ && (a = this, context.attach("#" + this.id, [{text:Lang.Workspace.context_rename, href:"/", action:function(a) { a.preventDefault(); - Entry.container.removeObject(b); - }}])), this.view_ = a, a = Entry.createElement("ul"), a.addClass("objectInfoView"), d = Entry.createElement("li"), d.addClass("objectInfo_visible"), e = Entry.createElement("li"), e.addClass("objectInfo_lock"), a.appendChild(d), a.appendChild(e), this.view_.appendChild(a), a = Entry.createElement("div"), a.addClass("entryObjectThumbnailWorkspace"), this.view_.appendChild(a), this.thumbnailView_ = a, a = Entry.createElement("div"), a.addClass("entryObjectWrapperWorkspace"), this.view_.appendChild(a), - d = Entry.createElement("input"), d.addClass("entryObjectNameWorkspace"), a.appendChild(d), this.nameView_ = d, this.nameView_.entryObject = this, this.nameView_.onblur = function() { + }}, {text:Lang.Workspace.context_duplicate, href:"/", action:function(b) { + b.preventDefault(); + Entry.container.addCloneObject(a); + }}, {text:Lang.Workspace.context_remove, href:"/", action:function(b) { + b.preventDefault(); + Entry.container.removeObject(a); + }}])), this.view_ = b, b = Entry.createElement("ul"), b.addClass("objectInfoView"), d = Entry.createElement("li"), d.addClass("objectInfo_visible"), e = Entry.createElement("li"), e.addClass("objectInfo_lock"), b.appendChild(d), b.appendChild(e), this.view_.appendChild(b), b = Entry.createElement("div"), b.addClass("entryObjectThumbnailWorkspace"), this.view_.appendChild(b), this.thumbnailView_ = b, b = Entry.createElement("div"), b.addClass("entryObjectWrapperWorkspace"), this.view_.appendChild(b), + d = Entry.createElement("input"), d.addClass("entryObjectNameWorkspace"), b.appendChild(d), this.nameView_ = d, this.nameView_.entryObject = this, this.nameView_.onblur = function() { this.entryObject.name = this.value; Entry.playground.reloadPlayground(); - }, this.nameView_.onkeypress = function(b) { - 13 == b.keyCode && c.editObjectValues(!1); - }, this.nameView_.value = this.name, Entry.objectEditable && Entry.objectDeletable && (d = Entry.createElement("div"), d.addClass("entryObjectDeletePhone"), d.object = this, this.deleteView_ = d, this.view_.appendChild(d), d.bindOnClick(function(b) { + }, this.nameView_.onkeypress = function(a) { + 13 == a.keyCode && c.editObjectValues(!1); + }, this.nameView_.value = this.name, Entry.objectEditable && Entry.objectDeletable && (d = Entry.createElement("div"), d.addClass("entryObjectDeletePhone"), d.object = this, this.deleteView_ = d, this.view_.appendChild(d), d.bindOnClick(function(a) { Entry.engine.isState("run") || Entry.container.removeObject(this.object); - })), d = Entry.createElement("button"), d.addClass("entryObjectEditPhone"), d.object = this, d.bindOnClick(function(b) { - if (b = Entry.container.getObject(this.id)) { - Entry.container.selectObject(b.id), Entry.playground.injectObject(b); + })), d = Entry.createElement("button"), d.addClass("entryObjectEditPhone"), d.object = this, d.bindOnClick(function(a) { + if (a = Entry.container.getObject(this.id)) { + Entry.container.selectObject(a.id), Entry.playground.injectObject(a); } - }), this.view_.appendChild(d), d = Entry.createElement("div"), d.addClass("entryObjectInformationWorkspace"), d.object = this, this.isInformationToggle = !1, a.appendChild(d), this.informationView_ = d, d = Entry.createElement("div"), d.addClass("entryObjectRotateLabelWrapperWorkspace"), this.view_.appendChild(d), this.rotateLabelWrapperView_ = d, e = Entry.createElement("span"), e.addClass("entryObjectRotateSpanWorkspace"), e.innerHTML = Lang.Workspace.rotation + " : ", m = Entry.createElement("input"), - m.addClass("entryObjectRotateInputWorkspace"), this.rotateSpan_ = e, this.rotateInput_ = m, h = Entry.createElement("span"), h.addClass("entryObjectDirectionSpanWorkspace"), h.innerHTML = Lang.Workspace.direction + " : ", q = Entry.createElement("input"), q.addClass("entryObjectDirectionInputWorkspace"), this.directionInput_ = q, d.appendChild(e), d.appendChild(m), d.appendChild(h), d.appendChild(q), d.rotateInput_ = m, d.directionInput_ = q, c = this, m.onkeypress = function(b) { - 13 == b.keyCode && (b = m.value, -1 != b.indexOf("\u02da") && (b = b.substring(0, b.indexOf("\u02da"))), isNaN(b) || c.entity.setRotation(Number(b)), c.updateRotationView(), m.blur()); - }, m.onblur = function(b) { + }), this.view_.appendChild(d), d = Entry.createElement("div"), d.addClass("entryObjectInformationWorkspace"), d.object = this, this.isInformationToggle = !1, b.appendChild(d), this.informationView_ = d, d = Entry.createElement("div"), d.addClass("entryObjectRotateLabelWrapperWorkspace"), this.view_.appendChild(d), this.rotateLabelWrapperView_ = d, e = Entry.createElement("span"), e.addClass("entryObjectRotateSpanWorkspace"), e.innerHTML = Lang.Workspace.rotation + " : ", m = Entry.createElement("input"), + m.addClass("entryObjectRotateInputWorkspace"), this.rotateSpan_ = e, this.rotateInput_ = m, h = Entry.createElement("span"), h.addClass("entryObjectDirectionSpanWorkspace"), h.innerHTML = Lang.Workspace.direction + " : ", q = Entry.createElement("input"), q.addClass("entryObjectDirectionInputWorkspace"), this.directionInput_ = q, d.appendChild(e), d.appendChild(m), d.appendChild(h), d.appendChild(q), d.rotateInput_ = m, d.directionInput_ = q, c = this, m.onkeypress = function(a) { + 13 == a.keyCode && (a = m.value, -1 != a.indexOf("\u02da") && (a = a.substring(0, a.indexOf("\u02da"))), isNaN(a) || c.entity.setRotation(+a), c.updateRotationView(), m.blur()); + }, m.onblur = function(a) { c.entity.setRotation(c.entity.getRotation()); Entry.stage.updateObject(); - }, q.onkeypress = function(b) { - 13 == b.keyCode && (b = q.value, -1 != b.indexOf("\u02da") && (b = b.substring(0, b.indexOf("\u02da"))), isNaN(b) || c.entity.setDirection(Number(b)), c.updateRotationView(), q.blur()); - }, q.onblur = function(b) { + }, q.onkeypress = function(a) { + 13 == a.keyCode && (a = q.value, -1 != a.indexOf("\u02da") && (a = a.substring(0, a.indexOf("\u02da"))), isNaN(a) || c.entity.setDirection(+a), c.updateRotationView(), q.blur()); + }, q.onblur = function(a) { c.entity.setDirection(c.entity.getDirection()); Entry.stage.updateObject(); - }, a = Entry.createElement("div"), a.addClass("entryObjectRotationWrapperWorkspace"), a.object = this, this.view_.appendChild(a), d = Entry.createElement("span"), d.addClass("entryObjectCoordinateWorkspace"), a.appendChild(d), e = Entry.createElement("span"), e.addClass("entryObjectCoordinateSpanWorkspace"), e.innerHTML = "X:", g = Entry.createElement("input"), g.addClass("entryObjectCoordinateInputWorkspace"), h = Entry.createElement("span"), h.addClass("entryObjectCoordinateSpanWorkspace"), + }, b = Entry.createElement("div"), b.addClass("entryObjectRotationWrapperWorkspace"), b.object = this, this.view_.appendChild(b), d = Entry.createElement("span"), d.addClass("entryObjectCoordinateWorkspace"), b.appendChild(d), e = Entry.createElement("span"), e.addClass("entryObjectCoordinateSpanWorkspace"), e.innerHTML = "X:", g = Entry.createElement("input"), g.addClass("entryObjectCoordinateInputWorkspace"), h = Entry.createElement("span"), h.addClass("entryObjectCoordinateSpanWorkspace"), h.innerHTML = "Y:", k = Entry.createElement("input"), k.addClass("entryObjectCoordinateInputWorkspace entryObjectCoordinateInputWorkspace_right"), l = Entry.createElement("span"), l.addClass("entryObjectCoordinateSpanWorkspace"), l.innerHTML = Lang.Workspace.Size, n = Entry.createElement("input"), n.addClass("entryObjectCoordinateInputWorkspace", "entryObjectCoordinateInputWorkspace_size"), d.appendChild(e), d.appendChild(g), d.appendChild(h), d.appendChild(k), d.appendChild(l), d.appendChild(n), - d.xInput_ = g, d.yInput_ = k, d.sizeInput_ = n, this.coordinateView_ = d, c = this, g.onkeypress = function(b) { - 13 == b.keyCode && (isNaN(g.value) || c.entity.setX(Number(g.value)), c.updateCoordinateView(), c.blur()); - }, g.onblur = function(b) { + d.xInput_ = g, d.yInput_ = k, d.sizeInput_ = n, this.coordinateView_ = d, c = this, g.onkeypress = function(a) { + 13 == a.keyCode && (isNaN(g.value) || c.entity.setX(+g.value), c.updateCoordinateView(), c.blur()); + }, g.onblur = function(a) { c.entity.setX(c.entity.getX()); Entry.stage.updateObject(); - }, k.onkeypress = function(b) { - 13 == b.keyCode && (isNaN(k.value) || c.entity.setY(Number(k.value)), c.updateCoordinateView(), c.blur()); - }, k.onblur = function(b) { + }, k.onkeypress = function(a) { + 13 == a.keyCode && (isNaN(k.value) || c.entity.setY(+k.value), c.updateCoordinateView(), c.blur()); + }, k.onblur = function(a) { c.entity.setY(c.entity.getY()); Entry.stage.updateObject(); - }, d = Entry.createElement("div"), d.addClass("rotationMethodWrapper"), a.appendChild(d), this.rotationMethodWrapper_ = d, a = Entry.createElement("span"), a.addClass("entryObjectRotateMethodLabelWorkspace"), d.appendChild(a), a.innerHTML = Lang.Workspace.rotate_method + " : ", a = Entry.createElement("div"), a.addClass("entryObjectRotateModeWorkspace"), a.addClass("entryObjectRotateModeAWorkspace"), a.object = this, this.rotateModeAView_ = a, d.appendChild(a), a.bindOnClick(function(b) { + }, d = Entry.createElement("div"), d.addClass("rotationMethodWrapper"), b.appendChild(d), this.rotationMethodWrapper_ = d, b = Entry.createElement("span"), b.addClass("entryObjectRotateMethodLabelWorkspace"), d.appendChild(b), b.innerHTML = Lang.Workspace.rotate_method + " : ", b = Entry.createElement("div"), b.addClass("entryObjectRotateModeWorkspace"), b.addClass("entryObjectRotateModeAWorkspace"), b.object = this, this.rotateModeAView_ = b, d.appendChild(b), b.bindOnClick(function(a) { Entry.engine.isState("run") || this.object.setRotateMethod("free"); - }), a = Entry.createElement("div"), a.addClass("entryObjectRotateModeWorkspace"), a.addClass("entryObjectRotateModeBWorkspace"), a.object = this, this.rotateModeBView_ = a, d.appendChild(a), a.bindOnClick(function(b) { + }), b = Entry.createElement("div"), b.addClass("entryObjectRotateModeWorkspace"), b.addClass("entryObjectRotateModeBWorkspace"), b.object = this, this.rotateModeBView_ = b, d.appendChild(b), b.bindOnClick(function(a) { Entry.engine.isState("run") || this.object.setRotateMethod("vertical"); - }), a = Entry.createElement("div"), a.addClass("entryObjectRotateModeWorkspace"), a.addClass("entryObjectRotateModeCWorkspace"), a.object = this, this.rotateModeCView_ = a, d.appendChild(a), a.bindOnClick(function(b) { + }), b = Entry.createElement("div"), b.addClass("entryObjectRotateModeWorkspace"), b.addClass("entryObjectRotateModeCWorkspace"), b.object = this, this.rotateModeCView_ = b, d.appendChild(b), b.bindOnClick(function(a) { Entry.engine.isState("run") || this.object.setRotateMethod("none"); }), this.updateThumbnailView(), this.updateCoordinateView(), this.updateRotateMethodView(), this.updateInputViews(), this.view_; } }; -Entry.EntryObject.prototype.setName = function(a) { - Entry.assert("string" == typeof a, "object name must be string"); - this.name = a; - this.nameView_.value = a; +Entry.EntryObject.prototype.setName = function(b) { + Entry.assert("string" == typeof b, "object name must be string"); + this.name = b; + this.nameView_.value = b; }; -Entry.EntryObject.prototype.setText = function(a) { - Entry.assert("string" == typeof a, "object text must be string"); - this.text = a; +Entry.EntryObject.prototype.setText = function(b) { + Entry.assert("string" == typeof b, "object text must be string"); + this.text = b; }; -Entry.EntryObject.prototype.setScript = function(a) { - this.script = a; +Entry.EntryObject.prototype.setScript = function(b) { + this.script = b; }; Entry.EntryObject.prototype.getScriptText = function() { return JSON.stringify(this.script.toJSON()); }; -Entry.EntryObject.prototype.initEntity = function(a) { - var b = {}; - b.x = b.y = 0; - b.rotation = 0; - b.direction = 90; +Entry.EntryObject.prototype.initEntity = function(b) { + var a = {}; + a.x = a.y = 0; + a.rotation = 0; + a.direction = 90; if ("sprite" == this.objectType) { - var c = a.sprite.pictures[0].dimension; - b.regX = c.width / 2; - b.regY = c.height / 2; - b.scaleX = b.scaleY = "background" == a.sprite.category.main ? Math.max(270 / c.height, 480 / c.width) : "new" == a.sprite.category.main ? 1 : 200 / (c.width + c.height); - b.width = c.width; - b.height = c.height; + var c = b.sprite.pictures[0].dimension; + a.regX = c.width / 2; + a.regY = c.height / 2; + a.scaleX = a.scaleY = "background" == b.sprite.category.main ? Math.max(270 / c.height, 480 / c.width) : "new" == b.sprite.category.main ? 1 : 200 / (c.width + c.height); + a.width = c.width; + a.height = c.height; } else { if ("textBox" == this.objectType) { - if (b.regX = 25, b.regY = 12, b.scaleX = b.scaleY = 1.5, b.width = 50, b.height = 24, b.text = a.text, a.options) { - if (a = a.options, c = "", a.bold && (c += "bold "), a.italic && (c += "italic "), b.underline = a.underline, b.strike = a.strike, b.font = c + "20px " + a.font.family, b.colour = a.colour, b.bgColor = a.background, b.lineBreak = a.lineBreak) { - b.width = 256, b.height = .5625 * b.width, b.regX = b.width / 2, b.regY = b.height / 2; + if (a.regX = 25, a.regY = 12, a.scaleX = a.scaleY = 1.5, a.width = 50, a.height = 24, a.text = b.text, b.options) { + if (b = b.options, c = "", b.bold && (c += "bold "), b.italic && (c += "italic "), a.underline = b.underline, a.strike = b.strike, a.font = c + "20px " + b.font.family, a.colour = b.colour, a.bgColor = b.background, a.lineBreak = b.lineBreak) { + a.width = 256, a.height = .5625 * a.width, a.regX = a.width / 2, a.regY = a.height / 2; } } else { - b.underline = !1, b.strike = !1, b.font = "20px Nanum Gothic", b.colour = "#000000", b.bgColor = "#ffffff"; + a.underline = !1, a.strike = !1, a.font = "20px Nanum Gothic", a.colour = "#000000", a.bgColor = "#ffffff"; } } } - return b; + return a; }; Entry.EntryObject.prototype.updateThumbnailView = function() { if ("sprite" == this.objectType) { if (this.entity.picture.fileurl) { this.thumbnailView_.style.backgroundImage = 'url("' + this.entity.picture.fileurl + '")'; } else { - var a = this.entity.picture.filename; - this.thumbnailView_.style.backgroundImage = 'url("' + Entry.defaultPath + "/uploads/" + a.substring(0, 2) + "/" + a.substring(2, 4) + "/thumb/" + a + '.png")'; + var b = this.entity.picture.filename; + this.thumbnailView_.style.backgroundImage = 'url("' + Entry.defaultPath + "/uploads/" + b.substring(0, 2) + "/" + b.substring(2, 4) + "/thumb/" + b + '.png")'; } } else { "textBox" == this.objectType && (this.thumbnailView_.style.backgroundImage = "url(" + (Entry.mediaFilePath + "/text_icon.png") + ")"); } }; -Entry.EntryObject.prototype.updateCoordinateView = function(a) { - if ((this.isSelected() || a) && this.coordinateView_ && this.coordinateView_.xInput_ && this.coordinateView_.yInput_) { - a = this.coordinateView_.xInput_.value; - var b = this.coordinateView_.yInput_.value, c = this.coordinateView_.sizeInput_.value, d = this.entity.getX().toFixed(1), e = this.entity.getY().toFixed(1), f = this.entity.getSize().toFixed(1); - a != d && (this.coordinateView_.xInput_.value = d); - b != e && (this.coordinateView_.yInput_.value = e); +Entry.EntryObject.prototype.updateCoordinateView = function(b) { + if ((this.isSelected() || b) && this.coordinateView_ && this.coordinateView_.xInput_ && this.coordinateView_.yInput_) { + b = this.coordinateView_.xInput_.value; + var a = this.coordinateView_.yInput_.value, c = this.coordinateView_.sizeInput_.value, d = this.entity.getX().toFixed(1), e = this.entity.getY().toFixed(1), f = this.entity.getSize().toFixed(1); + b != d && (this.coordinateView_.xInput_.value = d); + a != e && (this.coordinateView_.yInput_.value = e); c != f && (this.coordinateView_.sizeInput_.value = f); } }; -Entry.EntryObject.prototype.updateRotationView = function(a) { - if (this.isSelected() && this.view_ || a) { - a = "", "free" == this.getRotateMethod() ? (this.rotateSpan_.removeClass("entryRemove"), this.rotateInput_.removeClass("entryRemove"), a += this.entity.getRotation().toFixed(1), this.rotateInput_.value = a + "\u02da") : (this.rotateSpan_.addClass("entryRemove"), this.rotateInput_.addClass("entryRemove")), a = "" + this.entity.getDirection().toFixed(1), this.directionInput_.value = a + "\u02da"; +Entry.EntryObject.prototype.updateRotationView = function(b) { + if (this.isSelected() && this.view_ || b) { + b = "", "free" == this.getRotateMethod() ? (this.rotateSpan_.removeClass("entryRemove"), this.rotateInput_.removeClass("entryRemove"), b += this.entity.getRotation().toFixed(1), this.rotateInput_.value = b + "\u02da") : (this.rotateSpan_.addClass("entryRemove"), this.rotateInput_.addClass("entryRemove")), b = "" + this.entity.getDirection().toFixed(1), b += "\u02da", this.directionInput_.value = b; } }; -Entry.EntryObject.prototype.select = function(a) { +Entry.EntryObject.prototype.select = function(b) { console.log(this); }; -Entry.EntryObject.prototype.addPicture = function(a, b) { - Entry.stateManager && Entry.stateManager.addCommand("add sprite", this, this.removePicture, a.id); - a.objectId = this.id; - b || 0 === b ? (this.pictures.splice(b, 0, a), Entry.playground.injectPicture(this)) : this.pictures.push(a); - return new Entry.State(this, this.removePicture, a.id); +Entry.EntryObject.prototype.addPicture = function(b, a) { + Entry.stateManager && Entry.stateManager.addCommand("add sprite", this, this.removePicture, b.id); + b.objectId = this.id; + a || 0 === a ? (this.pictures.splice(a, 0, b), Entry.playground.injectPicture(this)) : this.pictures.push(b); + return new Entry.State(this, this.removePicture, b.id); }; -Entry.EntryObject.prototype.removePicture = function(a) { +Entry.EntryObject.prototype.removePicture = function(b) { if (2 > this.pictures.length) { return !1; } - a = this.getPicture(a); - var b = this.pictures.indexOf(a); - Entry.stateManager && Entry.stateManager.addCommand("remove sprite", this, this.addPicture, a, b); - this.pictures.splice(b, 1); - a === this.selectedPicture && Entry.playground.selectPicture(this.pictures[0]); + b = this.getPicture(b); + var a = this.pictures.indexOf(b); + Entry.stateManager && Entry.stateManager.addCommand("remove sprite", this, this.addPicture, b, a); + this.pictures.splice(a, 1); + b === this.selectedPicture && Entry.playground.selectPicture(this.pictures[0]); Entry.playground.injectPicture(this); Entry.playground.reloadPlayground(); - return new Entry.State(this, this.addPicture, a, b); + return new Entry.State(this, this.addPicture, b, a); }; -Entry.EntryObject.prototype.getPicture = function(a) { - if (!a) { +Entry.EntryObject.prototype.getPicture = function(b) { + if (!b) { return this.selectedPicture; } - a = a.trim(); - for (var b = this.pictures, c = b.length, d = 0;d < c;d++) { - if (b[d].id == a) { - return b[d]; + b = b.trim(); + for (var a = this.pictures, c = a.length, d = 0;d < c;d++) { + if (a[d].id == b) { + return a[d]; } } for (d = 0;d < c;d++) { - if (b[d].name == a) { - return b[d]; + if (a[d].name == b) { + return a[d]; } } - a = Entry.parseNumber(a); - if ((!1 !== a || "boolean" != typeof a) && c >= a && 0 < a) { - return b[a - 1]; + b = Entry.parseNumber(b); + if ((!1 !== b || "boolean" != typeof b) && c >= b && 0 < b) { + return a[b - 1]; } throw Error("No picture found"); }; -Entry.EntryObject.prototype.setPicture = function(a) { - for (var b in this.pictures) { - if (a.id === this.pictures[b].id) { - this.pictures[b] = a; +Entry.EntryObject.prototype.setPicture = function(b) { + for (var a in this.pictures) { + if (b.id === this.pictures[a].id) { + this.pictures[a] = b; return; } } throw Error("No picture found"); }; -Entry.EntryObject.prototype.getPrevPicture = function(a) { - for (var b = this.pictures, c = b.length, d = 0;d < c;d++) { - if (b[d].id == a) { - return b[0 == d ? c - 1 : d - 1]; +Entry.EntryObject.prototype.getPrevPicture = function(b) { + for (var a = this.pictures, c = a.length, d = 0;d < c;d++) { + if (a[d].id == b) { + return a[0 == d ? c - 1 : d - 1]; } } }; -Entry.EntryObject.prototype.getNextPicture = function(a) { - for (var b = this.pictures, c = b.length, d = 0;d < c;d++) { - if (b[d].id == a) { - return b[d == c - 1 ? 0 : d + 1]; +Entry.EntryObject.prototype.getNextPicture = function(b) { + for (var a = this.pictures, c = a.length, d = 0;d < c;d++) { + if (a[d].id == b) { + return a[d == c - 1 ? 0 : d + 1]; } } }; -Entry.EntryObject.prototype.selectPicture = function(a) { - var b = this.getPicture(a); - if (b) { - this.selectedPicture = b, this.entity.setImage(b), this.updateThumbnailView(); +Entry.EntryObject.prototype.selectPicture = function(b) { + var a = this.getPicture(b); + if (a) { + this.selectedPicture = a, this.entity.setImage(a), this.updateThumbnailView(); } else { - throw Error("No picture with pictureId : " + a); - } -}; -Entry.EntryObject.prototype.addSound = function(a, b) { - a.id || (a.id = Entry.generateHash()); - Entry.stateManager && Entry.stateManager.addCommand("add sound", this, this.removeSound, a.id); - Entry.initSound(a, b); - b || 0 === b ? (this.sounds.splice(b, 0, a), Entry.playground.injectSound(this)) : this.sounds.push(a); - return new Entry.State(this, this.removeSound, a.id); -}; -Entry.EntryObject.prototype.removeSound = function(a) { - var b; - b = this.getSound(a); - a = this.sounds.indexOf(b); - Entry.stateManager && Entry.stateManager.addCommand("remove sound", this, this.addSound, b, a); - this.sounds.splice(a, 1); + throw Error("No picture with pictureId : " + b); + } +}; +Entry.EntryObject.prototype.addSound = function(b, a) { + b.id || (b.id = Entry.generateHash()); + Entry.stateManager && Entry.stateManager.addCommand("add sound", this, this.removeSound, b.id); + Entry.initSound(b, a); + a || 0 === a ? (this.sounds.splice(a, 0, b), Entry.playground.injectSound(this)) : this.sounds.push(b); + return new Entry.State(this, this.removeSound, b.id); +}; +Entry.EntryObject.prototype.removeSound = function(b) { + var a; + a = this.getSound(b); + b = this.sounds.indexOf(a); + Entry.stateManager && Entry.stateManager.addCommand("remove sound", this, this.addSound, a, b); + this.sounds.splice(b, 1); Entry.playground.reloadPlayground(); Entry.playground.injectSound(this); - return new Entry.State(this, this.addSound, b, a); + return new Entry.State(this, this.addSound, a, b); }; Entry.EntryObject.prototype.getRotateMethod = function() { this.rotateMethod || (this.rotateMethod = "free"); return this.rotateMethod; }; -Entry.EntryObject.prototype.setRotateMethod = function(a) { - a || (a = "free"); - this.rotateMethod = a; +Entry.EntryObject.prototype.setRotateMethod = function(b) { + b || (b = "free"); + this.rotateMethod = b; this.updateRotateMethodView(); Entry.stage.selectedObject && Entry.stage.selectedObject.entity && (Entry.stage.updateObject(), Entry.stage.updateHandle()); }; -Entry.EntryObject.prototype.initRotateValue = function(a) { - this.rotateMethod != a && (a = this.entity, a.rotation = 0, a.direction = 90, a.flip = !1); +Entry.EntryObject.prototype.initRotateValue = function(b) { + this.rotateMethod != b && (b = this.entity, b.rotation = 0, b.direction = 90, b.flip = !1); }; Entry.EntryObject.prototype.updateRotateMethodView = function() { - var a = this.rotateMethod; - this.rotateModeAView_ && (this.rotateModeAView_.removeClass("selected"), this.rotateModeBView_.removeClass("selected"), this.rotateModeCView_.removeClass("selected"), "free" == a ? this.rotateModeAView_.addClass("selected") : "vertical" == a ? this.rotateModeBView_.addClass("selected") : this.rotateModeCView_.addClass("selected"), this.updateRotationView()); + var b = this.rotateMethod; + this.rotateModeAView_ && (this.rotateModeAView_.removeClass("selected"), this.rotateModeBView_.removeClass("selected"), this.rotateModeCView_.removeClass("selected"), "free" == b ? this.rotateModeAView_.addClass("selected") : "vertical" == b ? this.rotateModeBView_.addClass("selected") : this.rotateModeCView_.addClass("selected"), this.updateRotationView()); }; -Entry.EntryObject.prototype.toggleInformation = function(a) { +Entry.EntryObject.prototype.toggleInformation = function(b) { this.setRotateMethod(this.getRotateMethod()); - void 0 === a && (a = this.isInformationToggle = !this.isInformationToggle); - a ? this.view_.addClass("informationToggle") : this.view_.removeClass("informationToggle"); + void 0 === b && (b = this.isInformationToggle = !this.isInformationToggle); + b ? this.view_.addClass("informationToggle") : this.view_.removeClass("informationToggle"); }; -Entry.EntryObject.prototype.addCloneEntity = function(a, b, c) { - this.clonedEntities.length > Entry.maxCloneLimit || (a = new Entry.EntityObject(this), b ? (a.injectModel(b.picture ? b.picture : null, b.toJSON()), a.snapshot_ = b.snapshot_, b.effect && (a.effect = Entry.cloneSimpleObject(b.effect), a.applyFilter()), b.brush && Entry.setCloneBrush(a, b.brush)) : (a.injectModel(this.entity.picture ? this.entity.picture : null, this.entity.toJSON(a)), a.snapshot_ = this.entity.snapshot_, this.entity.effect && (a.effect = Entry.cloneSimpleObject(this.entity.effect), - a.applyFilter()), this.entity.brush && Entry.setCloneBrush(a, this.entity.brush)), Entry.engine.raiseEventOnEntity(a, [a, "when_clone_start"]), a.isClone = !0, a.isStarted = !0, this.addCloneVariables(this, a, b ? b.variables : null, b ? b.lists : null), this.clonedEntities.push(a), Entry.stage.loadEntity(a)); +Entry.EntryObject.prototype.addCloneEntity = function(b, a, c) { + this.clonedEntities.length > Entry.maxCloneLimit || (b = new Entry.EntityObject(this), a ? (b.injectModel(a.picture ? a.picture : null, a.toJSON()), b.snapshot_ = a.snapshot_, a.effect && (b.effect = Entry.cloneSimpleObject(a.effect), b.applyFilter()), a.brush && Entry.setCloneBrush(b, a.brush)) : (b.injectModel(this.entity.picture ? this.entity.picture : null, this.entity.toJSON(b)), b.snapshot_ = this.entity.snapshot_, this.entity.effect && (b.effect = Entry.cloneSimpleObject(this.entity.effect), + b.applyFilter()), this.entity.brush && Entry.setCloneBrush(b, this.entity.brush)), Entry.engine.raiseEventOnEntity(b, [b, "when_clone_start"]), b.isClone = !0, b.isStarted = !0, this.addCloneVariables(this, b, a ? a.variables : null, a ? a.lists : null), this.clonedEntities.push(b), Entry.stage.loadEntity(b)); }; -Entry.EntryObject.prototype.initializeSplitter = function(a) { - a.onmousedown = function(b) { +Entry.EntryObject.prototype.initializeSplitter = function(b) { + b.onmousedown = function(a) { Entry.container.disableSort(); Entry.container.splitterEnable = !0; }; - document.addEventListener("mousemove", function(b) { - Entry.container.splitterEnable && Entry.resizeElement({canvasWidth:b.x || b.clientX}); + document.addEventListener("mousemove", function(a) { + Entry.container.splitterEnable && Entry.resizeElement({canvasWidth:a.x || a.clientX}); }); - document.addEventListener("mouseup", function(b) { + document.addEventListener("mouseup", function(a) { Entry.container.splitterEnable = !1; Entry.container.enableSort(); }); @@ -10205,114 +8542,114 @@ Entry.EntryObject.prototype.isSelected = function() { return this.isSelected_; }; Entry.EntryObject.prototype.toJSON = function() { - var a = {}; - a.id = this.id; - a.name = this.name; - "textBox" == this.objectType && (a.text = this.text); - a.script = this.getScriptText(); - "sprite" == this.objectType && (a.selectedPictureId = this.selectedPicture.id); - a.objectType = this.objectType; - a.rotateMethod = this.getRotateMethod(); - a.scene = this.scene.id; - a.sprite = {pictures:Entry.getPicturesJSON(this.pictures), sounds:Entry.getSoundsJSON(this.sounds)}; - a.lock = this.lock; - a.entity = this.entity.toJSON(); - return a; + var b = {}; + b.id = this.id; + b.name = this.name; + "textBox" == this.objectType && (b.text = this.text); + b.script = this.getScriptText(); + "sprite" == this.objectType && (b.selectedPictureId = this.selectedPicture.id); + b.objectType = this.objectType; + b.rotateMethod = this.getRotateMethod(); + b.scene = this.scene.id; + b.sprite = {pictures:Entry.getPicturesJSON(this.pictures), sounds:Entry.getSoundsJSON(this.sounds)}; + b.lock = this.lock; + b.entity = this.entity.toJSON(); + return b; }; Entry.EntryObject.prototype.destroy = function() { Entry.stage.unloadEntity(this.entity); this.view_ && Entry.removeElement(this.view_); }; -Entry.EntryObject.prototype.getSound = function(a) { - a = a.trim(); - for (var b = this.sounds, c = b.length, d = 0;d < c;d++) { - if (b[d].id == a) { - return b[d]; +Entry.EntryObject.prototype.getSound = function(b) { + b = b.trim(); + for (var a = this.sounds, c = a.length, d = 0;d < c;d++) { + if (a[d].id == b) { + return a[d]; } } for (d = 0;d < c;d++) { - if (b[d].name == a) { - return b[d]; + if (a[d].name == b) { + return a[d]; } } - a = Entry.parseNumber(a); - if ((!1 !== a || "boolean" != typeof a) && c >= a && 0 < a) { - return b[a - 1]; + b = Entry.parseNumber(b); + if ((!1 !== b || "boolean" != typeof b) && c >= b && 0 < b) { + return a[b - 1]; } throw Error("No Sound"); }; -Entry.EntryObject.prototype.addCloneVariables = function(a, b, c, d) { - b.variables = []; - b.lists = []; - c || (c = Entry.findObjsByKey(Entry.variableContainer.variables_, "object_", a.id)); - d || (d = Entry.findObjsByKey(Entry.variableContainer.lists_, "object_", a.id)); - for (a = 0;a < c.length;a++) { - b.variables.push(c[a].clone()); +Entry.EntryObject.prototype.addCloneVariables = function(b, a, c, d) { + a.variables = []; + a.lists = []; + c || (c = Entry.findObjsByKey(Entry.variableContainer.variables_, "object_", b.id)); + d || (d = Entry.findObjsByKey(Entry.variableContainer.lists_, "object_", b.id)); + for (b = 0;b < c.length;b++) { + a.variables.push(c[b].clone()); } - for (a = 0;a < d.length;a++) { - b.lists.push(d[a].clone()); + for (b = 0;b < d.length;b++) { + a.lists.push(d[b].clone()); } }; Entry.EntryObject.prototype.getLock = function() { return this.lock; }; -Entry.EntryObject.prototype.setLock = function(a) { - this.lock = a; +Entry.EntryObject.prototype.setLock = function(b) { + this.lock = b; Entry.stage.updateObject(); - return a; + return b; }; -Entry.EntryObject.prototype.updateInputViews = function(a) { - a = a || this.getLock(); - var b = [this.nameView_, this.coordinateView_.xInput_, this.coordinateView_.yInput_, this.rotateInput_, this.directionInput_, this.coordinateView_.sizeInput_]; - if (a && 1 != b[0].getAttribute("readonly")) { - for (a = 0;a < b.length;a++) { - b[a].removeClass("selectedEditingObject"), b[a].setAttribute("readonly", !1), this.isEditing = !1; +Entry.EntryObject.prototype.updateInputViews = function(b) { + b = b || this.getLock(); + var a = [this.nameView_, this.coordinateView_.xInput_, this.coordinateView_.yInput_, this.rotateInput_, this.directionInput_, this.coordinateView_.sizeInput_]; + if (b && 1 != a[0].getAttribute("readonly")) { + for (b = 0;b < a.length;b++) { + a[b].removeClass("selectedEditingObject"), a[b].setAttribute("readonly", !1), this.isEditing = !1; } } }; -Entry.EntryObject.prototype.editObjectValues = function(a) { - var b; - b = this.getLock() ? [this.nameView_] : [this.nameView_, this.coordinateView_.xInput_, this.coordinateView_.yInput_, this.rotateInput_, this.directionInput_, this.coordinateView_.sizeInput_]; - if (a) { - $(b).removeClass("selectedNotEditingObject"); - for (a = 0;a < b.length;a++) { - b[a].removeAttribute("readonly"), b[a].addClass("selectedEditingObject"); +Entry.EntryObject.prototype.editObjectValues = function(b) { + var a; + a = this.getLock() ? [this.nameView_] : [this.nameView_, this.coordinateView_.xInput_, this.coordinateView_.yInput_, this.rotateInput_, this.directionInput_, this.coordinateView_.sizeInput_]; + if (b) { + $(a).removeClass("selectedNotEditingObject"); + for (b = 0;b < a.length;b++) { + a[b].removeAttribute("readonly"), a[b].addClass("selectedEditingObject"); } this.isEditing = !0; } else { - for (a = 0;a < b.length;a++) { - b[a].blur(!0); + for (b = 0;b < a.length;b++) { + a[b].blur(!0); } this.blurAllInput(); this.isEditing = !1; } }; Entry.EntryObject.prototype.blurAllInput = function() { - var a = document.getElementsByClassName("selectedEditingObject"); - $(a).removeClass("selectedEditingObject"); - for (var a = [this.nameView_, this.coordinateView_.xInput_, this.coordinateView_.yInput_, this.rotateInput_, this.directionInput_, this.coordinateView_.sizeInput_], b = 0;b < a.length;b++) { - a[b].addClass("selectedNotEditingObject"), a[b].setAttribute("readonly", !0); + var b = document.getElementsByClassName("selectedEditingObject"); + $(b).removeClass("selectedEditingObject"); + for (var b = [this.nameView_, this.coordinateView_.xInput_, this.coordinateView_.yInput_, this.rotateInput_, this.directionInput_, this.coordinateView_.sizeInput_], a = 0;a < b.length;a++) { + b[a].addClass("selectedNotEditingObject"), b[a].setAttribute("readonly", !0); } }; -Entry.EntryObject.prototype.addStampEntity = function(a) { - a = new Entry.StampEntity(this, a); - Entry.stage.loadEntity(a); - this.clonedEntities.push(a); +Entry.EntryObject.prototype.addStampEntity = function(b) { + b = new Entry.StampEntity(this, b); + Entry.stage.loadEntity(b); + this.clonedEntities.push(b); Entry.stage.sortZorder(); }; Entry.EntryObject.prototype.getClonedEntities = function() { - var a = []; - this.clonedEntities.map(function(b) { - b.isStamp || a.push(b); + var b = []; + this.clonedEntities.map(function(a) { + a.isStamp || b.push(a); }); - return a; + return b; }; Entry.EntryObject.prototype.getStampEntities = function() { - var a = []; - this.clonedEntities.map(function(b) { - b.isStamp && a.push(b); + var b = []; + this.clonedEntities.map(function(a) { + a.isStamp && b.push(a); }); - return a; + return b; }; Entry.EntryObject.prototype.clearExecutor = function() { this.script.clearExecutors(); @@ -10325,8 +8662,8 @@ Entry.Painter = function() { this.selectArea = {}; this.firstStatement = !1; }; -Entry.Painter.prototype.initialize = function(a) { - this.generateView(a); +Entry.Painter.prototype.initialize = function(b) { + this.generateView(b); this.canvas = document.getElementById("entryPainterCanvas"); this.canvas_ = document.getElementById("entryPainterCanvas_"); this.stage = new createjs.Stage(this.canvas); @@ -10350,10 +8687,10 @@ Entry.Painter.prototype.initialize = function(a) { this.initCoordinator(); this.initHandle(); this.initDraw(); - var b = this; + var a = this; Entry.addEventListener("textUpdate", function() { - var a = b.inputField.value(); - "" === a ? (b.inputField.hide(), delete b.inputField) : (b.inputField.hide(), b.drawText(a), b.selectToolbox("cursor")); + var b = a.inputField.value(); + "" === b ? (a.inputField.hide(), delete a.inputField) : (a.inputField.hide(), a.drawText(b), a.selectToolbox("cursor")); }); this.selectToolbox("cursor"); }; @@ -10361,257 +8698,257 @@ Entry.Painter.prototype.initHandle = function() { this._handle = new createjs.Container; this._handle.rect = new createjs.Shape; this._handle.addChild(this._handle.rect); - var a = new createjs.Container; - a.name = "move"; - a.width = 90; - a.height = 90; - a.x = 90; - a.y = 90; - a.rect = new createjs.Shape; - var b = this; - a.rect.on("mousedown", function(c) { - "cursor" === b.toolbox.selected && (b.initCommand(), this.offset = {x:this.parent.x - this.x - c.stageX, y:this.parent.y - this.y - c.stageY}, this.parent.handleMode = "move", a.isSelectCenter = !1); + var b = new createjs.Container; + b.name = "move"; + b.width = 90; + b.height = 90; + b.x = 90; + b.y = 90; + b.rect = new createjs.Shape; + var a = this; + b.rect.on("mousedown", function(c) { + "cursor" === a.toolbox.selected && (a.initCommand(), this.offset = {x:this.parent.x - this.x - c.stageX, y:this.parent.y - this.y - c.stageY}, this.parent.handleMode = "move", b.isSelectCenter = !1); }); - a.rect.on("pressmove", function(c) { - "cursor" !== b.toolbox.selected || a.isSelectCenter || (b.doCommand(), this.parent.x = c.stageX + this.offset.x, this.parent.y = c.stageY + this.offset.y, b.updateImageHandle()); + b.rect.on("pressmove", function(c) { + "cursor" !== a.toolbox.selected || b.isSelectCenter || (a.doCommand(), this.parent.x = c.stageX + this.offset.x, this.parent.y = c.stageY + this.offset.y, a.updateImageHandle()); }); - a.on("mouseup", function(a) { - b.checkCommand(); + b.on("mouseup", function(b) { + a.checkCommand(); }); - a.rect.cursor = "move"; - a.addChild(a.rect); - a.notch = new createjs.Shape; - a.addChild(a.notch); - a.NEHandle = this.generateCornerHandle(); - a.addChild(a.NEHandle); - a.NWHandle = this.generateCornerHandle(); - a.addChild(a.NWHandle); - a.SWHandle = this.generateCornerHandle(); - a.addChild(a.SWHandle); - a.SEHandle = this.generateCornerHandle(); - a.addChild(a.SEHandle); - a.EHandle = this.generateXHandle(); - a.addChild(a.EHandle); - a.WHandle = this.generateXHandle(); - a.addChild(a.WHandle); - a.NHandle = this.generateYHandle(); - a.addChild(a.NHandle); - a.SHandle = this.generateYHandle(); - a.addChild(a.SHandle); - a.RHandle = new createjs.Shape; - a.RHandle.graphics.ss(2, 2, 0).beginFill("#888").s("#c1c7cd").f("#c1c7cd").dr(-2, -2, 8, 8); - a.RHandle.on("mousedown", function(a) { - b.initCommand(); + b.rect.cursor = "move"; + b.addChild(b.rect); + b.notch = new createjs.Shape; + b.addChild(b.notch); + b.NEHandle = this.generateCornerHandle(); + b.addChild(b.NEHandle); + b.NWHandle = this.generateCornerHandle(); + b.addChild(b.NWHandle); + b.SWHandle = this.generateCornerHandle(); + b.addChild(b.SWHandle); + b.SEHandle = this.generateCornerHandle(); + b.addChild(b.SEHandle); + b.EHandle = this.generateXHandle(); + b.addChild(b.EHandle); + b.WHandle = this.generateXHandle(); + b.addChild(b.WHandle); + b.NHandle = this.generateYHandle(); + b.addChild(b.NHandle); + b.SHandle = this.generateYHandle(); + b.addChild(b.SHandle); + b.RHandle = new createjs.Shape; + b.RHandle.graphics.ss(2, 2, 0).beginFill("#888").s("#c1c7cd").f("#c1c7cd").dr(-2, -2, 8, 8); + b.RHandle.on("mousedown", function(b) { + a.initCommand(); }); - a.RHandle.on("pressmove", function(a) { - b.doCommand(); - var d = a.stageX - this.parent.x; - a = a.stageY - this.parent.y; - this.parent.rotation = 0 <= d ? Math.atan(a / d) / Math.PI * 180 + 90 : Math.atan(a / d) / Math.PI * 180 + 270; - b.updateImageHandle(); + b.RHandle.on("pressmove", function(b) { + a.doCommand(); + var d = b.stageX - this.parent.x; + b = b.stageY - this.parent.y; + this.parent.rotation = 0 <= d ? Math.atan(b / d) / Math.PI * 180 + 90 : Math.atan(b / d) / Math.PI * 180 + 270; + a.updateImageHandle(); }); - a.RHandle.cursor = "crosshair"; - a.addChild(a.RHandle); - a.on("mouseup", function(a) { - b.checkCommand(); + b.RHandle.cursor = "crosshair"; + b.addChild(b.RHandle); + b.on("mouseup", function(b) { + a.checkCommand(); }); - a.visible = !1; - this.handle = a; - this.stage.addChild(a); + b.visible = !1; + this.handle = b; + this.stage.addChild(b); this.updateImageHandleCursor(); }; Entry.Painter.prototype.generateCornerHandle = function() { - var a = this, b = new createjs.Shape; - b.graphics.beginFill("#c1c7cd").ss(2, 2, 0).s("#c1c7cd").dr(-4, -4, 8, 8); - b.on("mousedown", function(b) { - a.initCommand(); - this.offset = {x:b.stageX - this.parent.x + this.parent.regX, y:b.stageY - this.parent.y + this.parent.regY}; + var b = this, a = new createjs.Shape; + a.graphics.beginFill("#c1c7cd").ss(2, 2, 0).s("#c1c7cd").dr(-4, -4, 8, 8); + a.on("mousedown", function(a) { + b.initCommand(); + this.offset = {x:a.stageX - this.parent.x + this.parent.regX, y:a.stageY - this.parent.y + this.parent.regY}; }); - b.on("pressmove", function(b) { - a.doCommand(); - var d = Math.sqrt(Math.abs((b.stageX - this.parent.x + this.parent.regX) / this.offset.x * (b.stageY - this.parent.y + this.parent.regY) / this.offset.y)); - 10 < this.parent.width * d && 10 < this.parent.height * d && (this.parent.width *= d, this.parent.height *= d, this.offset = {x:b.stageX - this.parent.x + this.parent.regX, y:b.stageY - this.parent.y + this.parent.regY}); - a.updateImageHandle(); + a.on("pressmove", function(a) { + b.doCommand(); + var d = Math.sqrt(Math.abs((a.stageX - this.parent.x + this.parent.regX) / this.offset.x * (a.stageY - this.parent.y + this.parent.regY) / this.offset.y)); + 10 < this.parent.width * d && 10 < this.parent.height * d && (this.parent.width *= d, this.parent.height *= d, this.offset = {x:a.stageX - this.parent.x + this.parent.regX, y:a.stageY - this.parent.y + this.parent.regY}); + b.updateImageHandle(); }); - b.on("mouseup", function(b) { - a.checkCommand(); + a.on("mouseup", function(a) { + b.checkCommand(); }); - return b; + return a; }; Entry.Painter.prototype.generateXHandle = function() { - var a = this, b = new createjs.Shape; - b.graphics.beginFill("#c1c7cd").ss(2, 2, 0).s("#c1c7cd").dr(-4, -4, 8, 8); - b.on("mousedown", function(b) { - a.initCommand(); - this.offset = {x:b.stageX - this.parent.x + this.parent.regX}; + var b = this, a = new createjs.Shape; + a.graphics.beginFill("#c1c7cd").ss(2, 2, 0).s("#c1c7cd").dr(-4, -4, 8, 8); + a.on("mousedown", function(a) { + b.initCommand(); + this.offset = {x:a.stageX - this.parent.x + this.parent.regX}; }); - b.on("pressmove", function(b) { - a.doCommand(); - var d = Math.abs((b.stageX - this.parent.x + this.parent.regX) / this.offset.x); - 10 < this.parent.width * d && (this.parent.width *= d, this.offset = {x:b.stageX - this.parent.x + this.parent.regX}); - a.updateImageHandle(); + a.on("pressmove", function(a) { + b.doCommand(); + var d = Math.abs((a.stageX - this.parent.x + this.parent.regX) / this.offset.x); + 10 < this.parent.width * d && (this.parent.width *= d, this.offset = {x:a.stageX - this.parent.x + this.parent.regX}); + b.updateImageHandle(); }); - b.on("mouseup", function(b) { - a.checkCommand(); + a.on("mouseup", function(a) { + b.checkCommand(); }); - return b; + return a; }; Entry.Painter.prototype.generateYHandle = function() { - var a = this, b = new createjs.Shape; - b.graphics.beginFill("#c1c7cd").ss(2, 2, 0).s("#c1c7cd").dr(-4, -4, 8, 8); - b.on("mousedown", function(b) { - a.initCommand(); - this.offset = {y:b.stageY - this.parent.y + this.parent.regY}; + var b = this, a = new createjs.Shape; + a.graphics.beginFill("#c1c7cd").ss(2, 2, 0).s("#c1c7cd").dr(-4, -4, 8, 8); + a.on("mousedown", function(a) { + b.initCommand(); + this.offset = {y:a.stageY - this.parent.y + this.parent.regY}; }); - b.on("pressmove", function(b) { - a.doCommand(); - var d = Math.abs((b.stageY - this.parent.y + this.parent.regY) / this.offset.y); - 10 < this.parent.height * d && (this.parent.height *= d, this.offset = {y:b.stageY - this.parent.y + this.parent.regY}); - a.updateImageHandle(); + a.on("pressmove", function(a) { + b.doCommand(); + var d = Math.abs((a.stageY - this.parent.y + this.parent.regY) / this.offset.y); + 10 < this.parent.height * d && (this.parent.height *= d, this.offset = {y:a.stageY - this.parent.y + this.parent.regY}); + b.updateImageHandle(); }); - b.on("mouseup", function(b) { - a.checkCommand(); + a.on("mouseup", function(a) { + b.checkCommand(); }); - return b; + return a; }; Entry.Painter.prototype.updateImageHandle = function() { if (this.handle.visible) { - var a = this.handle, b = a.direction, c = a.width, d = a.height, e = a.regX, f = a.regY; - a.rect.graphics.clear().f("rgba(0,0,1,0.01)").ss(2, 2, 0).s("#c1c7cd").lt(-c / 2, -d / 2).lt(0, -d / 2).lt(0, -d / 2).lt(+c / 2, -d / 2).lt(+c / 2, +d / 2).lt(-c / 2, +d / 2).cp(); - a.notch.graphics.clear().f("rgba(0,0,1,0.01)").ss(2, 2, 0).s("#c1c7cd").lt(0, -d / 2).lt(0, -d / 2 - 20).cp(); - a.NEHandle.x = +a.width / 2; - a.NEHandle.y = -a.height / 2; - a.NWHandle.x = -a.width / 2; - a.NWHandle.y = -a.height / 2; - a.SWHandle.x = -a.width / 2; - a.SWHandle.y = +a.height / 2; - a.SEHandle.x = +a.width / 2; - a.SEHandle.y = +a.height / 2; - a.EHandle.x = +a.width / 2; - a.EHandle.y = 0; - a.WHandle.x = -a.width / 2; - a.WHandle.y = 0; - a.NHandle.x = 0; - a.NHandle.y = -a.height / 2; - a.SHandle.x = 0; - a.SHandle.y = +a.height / 2; - a.RHandle.x = -2; - a.RHandle.y = -a.height / 2 - 20 - 2; - this.handle.visible && (c = this.selectedObject, this.selectedObject.text ? (c.width = this.selectedObject.width, c.height = this.selectedObject.height) : (c.width = c.image.width, c.height = c.image.height), c.scaleX = a.width / c.width, c.scaleY = a.height / c.height, c.x = a.x, c.y = a.y, c.regX = c.width / 2 + e / c.scaleX, c.regY = c.height / 2 + f / c.scaleY, c.rotation = a.rotation, c.direction = b, this.selectArea.x1 = a.x - a.width / 2, this.selectArea.y1 = a.y - a.height / 2, this.selectArea.x2 = - a.width, this.selectArea.y2 = a.height, this.objectWidthInput.value = Math.abs(c.width * c.scaleX).toFixed(0), this.objectHeightInput.value = Math.abs(c.height * c.scaleY).toFixed(0), this.objectRotateInput.value = (1 * c.rotation).toFixed(0)); + var b = this.handle, a = b.direction, c = b.width, d = b.height, e = b.regX, f = b.regY; + b.rect.graphics.clear().f("rgba(0,0,1,0.01)").ss(2, 2, 0).s("#c1c7cd").lt(-c / 2, -d / 2).lt(0, -d / 2).lt(0, -d / 2).lt(+c / 2, -d / 2).lt(+c / 2, +d / 2).lt(-c / 2, +d / 2).cp(); + b.notch.graphics.clear().f("rgba(0,0,1,0.01)").ss(2, 2, 0).s("#c1c7cd").lt(0, -d / 2).lt(0, -d / 2 - 20).cp(); + b.NEHandle.x = +b.width / 2; + b.NEHandle.y = -b.height / 2; + b.NWHandle.x = -b.width / 2; + b.NWHandle.y = -b.height / 2; + b.SWHandle.x = -b.width / 2; + b.SWHandle.y = +b.height / 2; + b.SEHandle.x = +b.width / 2; + b.SEHandle.y = +b.height / 2; + b.EHandle.x = +b.width / 2; + b.EHandle.y = 0; + b.WHandle.x = -b.width / 2; + b.WHandle.y = 0; + b.NHandle.x = 0; + b.NHandle.y = -b.height / 2; + b.SHandle.x = 0; + b.SHandle.y = +b.height / 2; + b.RHandle.x = -2; + b.RHandle.y = -b.height / 2 - 20 - 2; + this.handle.visible && (c = this.selectedObject, this.selectedObject.text ? (c.width = this.selectedObject.width, c.height = this.selectedObject.height) : (c.width = c.image.width, c.height = c.image.height), c.scaleX = b.width / c.width, c.scaleY = b.height / c.height, c.x = b.x, c.y = b.y, c.regX = c.width / 2 + e / c.scaleX, c.regY = c.height / 2 + f / c.scaleY, c.rotation = b.rotation, c.direction = a, this.selectArea.x1 = b.x - b.width / 2, this.selectArea.y1 = b.y - b.height / 2, this.selectArea.x2 = + b.width, this.selectArea.y2 = b.height, this.objectWidthInput.value = Math.abs(c.width * c.scaleX).toFixed(0), this.objectHeightInput.value = Math.abs(c.height * c.scaleY).toFixed(0), this.objectRotateInput.value = (1 * c.rotation).toFixed(0)); this.updateImageHandleCursor(); this.stage.update(); } }; Entry.Painter.prototype.updateImageHandleCursor = function() { - var a = this.handle; - a.rect.cursor = "move"; - a.RHandle.cursor = "crosshair"; - for (var b = ["nwse-resize", "ns-resize", "nesw-resize", "ew-resize"], c = Math.floor((a.rotation + 22.5) % 180 / 45), d = 0;d < c;d++) { - b.push(b.shift()); - } - a.NHandle.cursor = b[1]; - a.NEHandle.cursor = b[2]; - a.EHandle.cursor = b[3]; - a.SEHandle.cursor = b[0]; - a.SHandle.cursor = b[1]; - a.SWHandle.cursor = b[2]; - a.WHandle.cursor = b[3]; - a.NWHandle.cursor = b[0]; -}; -Entry.Painter.prototype.clearCanvas = function(a) { + var b = this.handle; + b.rect.cursor = "move"; + b.RHandle.cursor = "crosshair"; + for (var a = ["nwse-resize", "ns-resize", "nesw-resize", "ew-resize"], c = Math.floor((b.rotation + 22.5) % 180 / 45), d = 0;d < c;d++) { + a.push(a.shift()); + } + b.NHandle.cursor = a[1]; + b.NEHandle.cursor = a[2]; + b.EHandle.cursor = a[3]; + b.SEHandle.cursor = a[0]; + b.SHandle.cursor = a[1]; + b.SWHandle.cursor = a[2]; + b.WHandle.cursor = a[3]; + b.NWHandle.cursor = a[0]; +}; +Entry.Painter.prototype.clearCanvas = function(b) { this.clearHandle(); - a || this.initCommand(); + b || this.initCommand(); this.objectContainer.removeAllChildren(); this.stage.update(); this.colorLayerData = this.ctx.getImageData(0, 0, this.canvas.width, this.canvas.height); - a = 0; - for (var b = this.colorLayerData.data.length;a < b;a++) { - this.colorLayerData.data[a] = 255, this.colorLayerData.data[a + 1] = 255, this.colorLayerData.data[a + 2] = 255, this.colorLayerData.data[a + 3] = 255; + b = 0; + for (var a = this.colorLayerData.data.length;b < a;b++) { + this.colorLayerData.data[b] = 255, this.colorLayerData.data[b + 1] = 255, this.colorLayerData.data[b + 2] = 255, this.colorLayerData.data[b + 3] = 255; } this.reloadContext(); }; Entry.Painter.prototype.newPicture = function() { - var a = {dimension:{height:1, width:1}, fileurl:Entry.mediaFilePath + "_1x1.png", name:Lang.Workspace.new_picture}; - a.id = Entry.generateHash(); - Entry.playground.addPicture(a, !0); + var b = {dimension:{height:1, width:1}, fileurl:Entry.mediaFilePath + "_1x1.png", name:Lang.Workspace.new_picture}; + b.id = Entry.generateHash(); + Entry.playground.addPicture(b, !0); }; Entry.Painter.prototype.initPicture = function() { - var a = this; - Entry.addEventListener("pictureSelected", function(b) { - a.selectToolbox("cursor"); - if (a.file.id !== b.id) { - a.file.modified && confirm("\uc218\uc815\ub41c \ub0b4\uc6a9\uc744 \uc800\uc7a5\ud558\uc2dc\uaca0\uc2b5\ub2c8\uae4c?") && (a.file_ = JSON.parse(JSON.stringify(a.file)), a.file_save(!0)); - a.file.modified = !1; - a.clearCanvas(!0); + var b = this; + Entry.addEventListener("pictureSelected", function(a) { + b.selectToolbox("cursor"); + if (b.file.id !== a.id) { + b.file.modified && confirm("\uc218\uc815\ub41c \ub0b4\uc6a9\uc744 \uc800\uc7a5\ud558\uc2dc\uaca0\uc2b5\ub2c8\uae4c?") && (b.file_ = JSON.parse(JSON.stringify(b.file)), b.file_save(!0)); + b.file.modified = !1; + b.clearCanvas(!0); var c = new Image; - c.id = b.id ? b.id : Entry.generateHash(); - a.file.id = c.id; - a.file.name = b.name; - a.file.mode = "edit"; - c.src = b.fileurl ? b.fileurl : Entry.defaultPath + "/uploads/" + b.filename.substring(0, 2) + "/" + b.filename.substring(2, 4) + "/image/" + b.filename + ".png"; - c.onload = function(b) { - a.addImage(b.target); + c.id = a.id ? a.id : Entry.generateHash(); + b.file.id = c.id; + b.file.name = a.name; + b.file.mode = "edit"; + c.src = a.fileurl ? a.fileurl : Entry.defaultPath + "/uploads/" + a.filename.substring(0, 2) + "/" + a.filename.substring(2, 4) + "/image/" + a.filename + ".png"; + c.onload = function(a) { + b.addImage(a.target); }; } }); - Entry.addEventListener("pictureImport", function(b) { - a.addPicture(b); + Entry.addEventListener("pictureImport", function(a) { + b.addPicture(a); }); - Entry.addEventListener("pictureNameChanged", function(b) { - a.file.name = b.name; + Entry.addEventListener("pictureNameChanged", function(a) { + b.file.name = a.name; }); - Entry.addEventListener("pictureClear", function(b) { - a.file.modified = !1; - a.file.id = ""; - a.file.name = ""; - a.clearCanvas(); + Entry.addEventListener("pictureClear", function(a) { + b.file.modified = !1; + b.file.id = ""; + b.file.name = ""; + b.clearCanvas(); }); }; Entry.Painter.prototype.initDraw = function() { - var a = this; - this.stage.on("stagemousedown", function(b) { - a.stagemousedown(b); + var b = this; + this.stage.on("stagemousedown", function(a) { + b.stagemousedown(a); }); - this.stage.on("stagemouseup", function(b) { - a.stagemouseup(b); + this.stage.on("stagemouseup", function(a) { + b.stagemouseup(a); }); - this.stage.on("stagemousemove", function(b) { - a.stagemousemove(b); + this.stage.on("stagemousemove", function(a) { + b.stagemousemove(a); }); }; -Entry.Painter.prototype.selectObject = function(a, b) { - this.selectedObject = a; - this.handle.visible = a.visible; - b ? (this.handle.width = this.copy.width, this.handle.height = this.copy.height, this.handle.x = this.selectArea.x1 + this.copy.width / 2, this.handle.y = this.selectArea.y1 + this.copy.height / 2) : (this.handle.width = a.scaleX * a.image.width, this.handle.height = a.scaleY * a.image.height, this.handle.x = a.x, this.handle.y = a.y, this.handle.regX = +(a.regX - a.image.width / 2) * a.scaleX, this.handle.regY = +(a.regY - a.image.height / 2) * a.scaleY); - this.handle.rotation = a.rotation; +Entry.Painter.prototype.selectObject = function(b, a) { + this.selectedObject = b; + this.handle.visible = b.visible; + a ? (this.handle.width = this.copy.width, this.handle.height = this.copy.height, this.handle.x = this.selectArea.x1 + this.copy.width / 2, this.handle.y = this.selectArea.y1 + this.copy.height / 2) : (this.handle.width = b.scaleX * b.image.width, this.handle.height = b.scaleY * b.image.height, this.handle.x = b.x, this.handle.y = b.y, this.handle.regX = +(b.regX - b.image.width / 2) * b.scaleX, this.handle.regY = +(b.regY - b.image.height / 2) * b.scaleY); + this.handle.rotation = b.rotation; this.handle.direction = 0; this.updateImageHandle(); }; -Entry.Painter.prototype.selectTextObject = function(a) { - this.selectedObject = a; - var b = a.getTransformedBounds(); - this.handle.visible = a.visible; - a.width || (this.selectedObject.width = b.width); - a.height || (this.selectedObject.height = b.height); - this.handle.width = a.scaleX * this.selectedObject.width; - this.handle.height = a.scaleY * this.selectedObject.height; - this.handle.x = a.x; - this.handle.y = a.y; - a.regX || (a.regX = a.width / 2); - a.regY || (a.regY = a.height / 2); - this.handle.regX = (a.regX - this.selectedObject.width / 2) * a.scaleX; - this.handle.regY = (a.regY - this.selectedObject.height / 2) * a.scaleY; - this.handle.rotation = a.rotation; +Entry.Painter.prototype.selectTextObject = function(b) { + this.selectedObject = b; + var a = b.getTransformedBounds(); + this.handle.visible = b.visible; + b.width || (this.selectedObject.width = a.width); + b.height || (this.selectedObject.height = a.height); + this.handle.width = b.scaleX * this.selectedObject.width; + this.handle.height = b.scaleY * this.selectedObject.height; + this.handle.x = b.x; + this.handle.y = b.y; + b.regX || (b.regX = b.width / 2); + b.regY || (b.regY = b.height / 2); + this.handle.regX = (b.regX - this.selectedObject.width / 2) * b.scaleX; + this.handle.regY = (b.regY - this.selectedObject.height / 2) * b.scaleY; + this.handle.rotation = b.rotation; this.handle.direction = 0; this.updateImageHandle(); }; Entry.Painter.prototype.updateHandle = function() { -1 < this.stage.getChildIndex(this._handle) && this.stage.removeChild(this._handle); -1 === this.stage.getChildIndex(this.handle) && this.stage.addChild(this.handle); - var a = new createjs.Shape; - a.graphics.clear().beginFill("#000").rect(this.selectArea.x1, this.selectArea.y1, this.selectArea.x2, this.selectArea.y2); - this.handle.rect.hitArea = a; + var b = new createjs.Shape; + b.graphics.clear().beginFill("#000").rect(this.selectArea.x1, this.selectArea.y1, this.selectArea.x2, this.selectArea.y2); + this.handle.rect.hitArea = b; this.handle.rect.graphics.clear().setStrokeStyle(1, "round").beginStroke("#000000").drawDashedRect(this.selectArea.x1, this.selectArea.y1, this.selectArea.x2, this.selectArea.y2, 4); this.stage.update(); }; @@ -10620,56 +8957,56 @@ Entry.Painter.prototype.updateHandle_ = function() { this._handle.rect.graphics.clear().setStrokeStyle(1, "round").beginStroke("#cccccc").drawDashedRect(this.selectArea.x1, this.selectArea.y1, this.selectArea.x2, this.selectArea.y2, 2); this.stage.update(); }; -Entry.Painter.prototype.matchTolerance = function(a, b, c, d, e) { - var f = this.colorLayerData.data[a], g = this.colorLayerData.data[a + 1]; - a = this.colorLayerData.data[a + 2]; - return f >= b - e / 100 * b && f <= b + e / 100 * b && g >= c - e / 100 * c && g <= c + e / 100 * c && a >= d - e / 100 * d && a <= d + e / 100 * d; +Entry.Painter.prototype.matchTolerance = function(b, a, c, d, e) { + var f = this.colorLayerData.data[b], g = this.colorLayerData.data[b + 1]; + b = this.colorLayerData.data[b + 2]; + return f >= a - e / 100 * a && f <= a + e / 100 * a && g >= c - e / 100 * c && g <= c + e / 100 * c && b >= d - e / 100 * d && b <= d + e / 100 * d; }; -Entry.Painter.prototype.matchColorOnly = function(a, b, c, d) { - return b === this.colorLayerData.data[a] && c === this.colorLayerData.data[a + 1] && d === this.colorLayerData.data[a + 2] ? !0 : !1; +Entry.Painter.prototype.matchColorOnly = function(b, a, c, d) { + return a === this.colorLayerData.data[b] && c === this.colorLayerData.data[b + 1] && d === this.colorLayerData.data[b + 2] ? !0 : !1; }; -Entry.Painter.prototype.matchColor = function(a, b, c, d, e) { - return b === this.colorLayerData.data[a] && c === this.colorLayerData.data[a + 1] && d === this.colorLayerData.data[a + 2] && e === this.colorLayerData.data[a + 3] ? !0 : !1; +Entry.Painter.prototype.matchColor = function(b, a, c, d, e) { + return a === this.colorLayerData.data[b] && c === this.colorLayerData.data[b + 1] && d === this.colorLayerData.data[b + 2] && e === this.colorLayerData.data[b + 3] ? !0 : !1; }; -Entry.Painter.prototype.colorPixel = function(a, b, c, d, e) { +Entry.Painter.prototype.colorPixel = function(b, a, c, d, e) { e || (e = 255); - this.stroke.transparent && (e = d = c = b = 0); - this.colorLayerData.data[a] = b; - this.colorLayerData.data[a + 1] = c; - this.colorLayerData.data[a + 2] = d; - this.colorLayerData.data[a + 3] = e; -}; -Entry.Painter.prototype.pickStrokeColor = function(a) { - a = 4 * (Math.round(a.stageY) * this.canvas.width + Math.round(a.stageX)); - this.stroke.lineColor = Entry.rgb2hex(this.colorLayerData.data[a], this.colorLayerData.data[a + 1], this.colorLayerData.data[a + 2]); + this.stroke.transparent && (e = d = c = a = 0); + this.colorLayerData.data[b] = a; + this.colorLayerData.data[b + 1] = c; + this.colorLayerData.data[b + 2] = d; + this.colorLayerData.data[b + 3] = e; +}; +Entry.Painter.prototype.pickStrokeColor = function(b) { + b = 4 * (Math.round(b.stageY) * this.canvas.width + Math.round(b.stageX)); + this.stroke.lineColor = Entry.rgb2hex(this.colorLayerData.data[b], this.colorLayerData.data[b + 1], this.colorLayerData.data[b + 2]); document.getElementById("entryPainterAttrCircle").style.backgroundColor = this.stroke.lineColor; document.getElementById("entryPainterAttrCircleInput").value = this.stroke.lineColor; }; -Entry.Painter.prototype.drawText = function(a) { - var b = document.getElementById("entryPainterAttrFontStyle").value, c = document.getElementById("entryPainterAttrFontName").value, d = document.getElementById("entryPainterAttrFontSize").value; - a = new createjs.Text(a, b + " " + d + 'px "' + c + '"', this.stroke.lineColor); - a.textBaseline = "top"; - a.x = this.oldPt.x; - a.y = this.oldPt.y; - this.objectContainer.addChild(a); - this.selectTextObject(a); +Entry.Painter.prototype.drawText = function(b) { + var a = document.getElementById("entryPainterAttrFontStyle").value, c = document.getElementById("entryPainterAttrFontName").value, d = document.getElementById("entryPainterAttrFontSize").value; + b = new createjs.Text(b, a + " " + d + 'px "' + c + '"', this.stroke.lineColor); + b.textBaseline = "top"; + b.x = this.oldPt.x; + b.y = this.oldPt.y; + this.objectContainer.addChild(b); + this.selectTextObject(b); this.file.modified = !0; }; -Entry.Painter.prototype.addImage = function(a) { - var b = new createjs.Bitmap(a); - this.objectContainer.addChild(b); - b.x = this.stage.canvas.width / 2; - b.y = this.stage.canvas.height / 2; - b.regX = b.image.width / 2 | 0; - b.regY = b.image.height / 2 | 0; - if (540 < b.image.height) { - var c = 540 / b.image.height; - b.scaleX = c; - b.scaleY = c; - } - b.name = a.id; - b.id = a.id; - this.selectObject(b); +Entry.Painter.prototype.addImage = function(b) { + var a = new createjs.Bitmap(b); + this.objectContainer.addChild(a); + a.x = this.stage.canvas.width / 2; + a.y = this.stage.canvas.height / 2; + a.regX = a.image.width / 2 | 0; + a.regY = a.image.height / 2 | 0; + if (540 < a.image.height) { + var c = 540 / a.image.height; + a.scaleX = c; + a.scaleY = c; + } + a.name = b.id; + a.id = b.id; + this.selectObject(a); this.stage.update(); }; Entry.Painter.prototype.createBrush = function() { @@ -10690,18 +9027,18 @@ Entry.Painter.prototype.clearHandle = function() { this.stage.update(); }; Entry.Painter.prototype.initCommand = function() { - var a = !1; - this.handle.visible && (a = !0, this.handle.visible = !1); var b = !1; - this.coordinator.visible && (b = !0, this.coordinator.visible = !1); - (a || b) && this.stage.update(); + this.handle.visible && (b = !0, this.handle.visible = !1); + var a = !1; + this.coordinator.visible && (a = !0, this.coordinator.visible = !1); + (b || a) && this.stage.update(); this.isCommandValid = !1; this.colorLayerModel = this.ctx.getImageData(0, 0, this.canvas.width, this.canvas.height); Entry.stateManager && this.firstStatement && Entry.stateManager.addCommand("edit sprite", this, this.restorePainter, this.colorLayerModel); this.firstStatement = !0; - a && (this.handle.visible = !0); - b && (this.coordinator.visible = !0); - (a || b) && this.stage.update(); + b && (this.handle.visible = !0); + a && (this.coordinator.visible = !0); + (b || a) && this.stage.update(); }; Entry.Painter.prototype.doCommand = function() { this.isCommandValid = !0; @@ -10709,20 +9046,20 @@ Entry.Painter.prototype.doCommand = function() { Entry.Painter.prototype.checkCommand = function() { this.isCommandValid || Entry.dispatchEvent("cancelLastCommand"); }; -Entry.Painter.prototype.restorePainter = function(a) { +Entry.Painter.prototype.restorePainter = function(b) { this.clearHandle(); - var b = this.ctx.getImageData(0, 0, this.canvas.width, this.canvas.height); + var a = this.ctx.getImageData(0, 0, this.canvas.width, this.canvas.height); this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); - this.ctx.putImageData(a, 0, 0); - a = new Image; - a.src = this.canvas.toDataURL(); + this.ctx.putImageData(b, 0, 0); + b = new Image; + b.src = this.canvas.toDataURL(); var c = this; - a.onload = function(b) { - b = new createjs.Bitmap(b.target); + b.onload = function(a) { + a = new createjs.Bitmap(a.target); c.objectContainer.removeAllChildren(); - c.objectContainer.addChild(b); + c.objectContainer.addChild(a); }; - Entry.stateManager && Entry.stateManager.addCommand("restore sprite", this, this.restorePainter, b); + Entry.stateManager && Entry.stateManager.addCommand("restore sprite", this, this.restorePainter, a); }; Entry.Painter.prototype.platten = function() { this.colorLayerData = this.ctx.getImageData(0, 0, this.canvas.width, this.canvas.height); @@ -10734,19 +9071,19 @@ Entry.Painter.prototype.fill = function() { this.initCommand(); this.doCommand(); this.clearHandle(); - var a = this.canvas.width, b = this.canvas.height; - this.colorLayerData = this.ctx.getImageData(0, 0, a, b); + var b = this.canvas.width, a = this.canvas.height; + this.colorLayerData = this.ctx.getImageData(0, 0, b, a); var c = new createjs.Point(this.stage.mouseX, this.stage.mouseY); c.x = Math.round(c.x); c.y = Math.round(c.y); - for (var d = 4 * (c.y * a + c.x), e = this.colorLayerData.data[d], f = this.colorLayerData.data[d + 1], g = this.colorLayerData.data[d + 2], h = this.colorLayerData.data[d + 3], k, l, c = [[c.x, c.y]], n = Entry.hex2rgb(this.stroke.lineColor);c.length;) { - for (var d = c.pop(), m = d[0], q = d[1], d = 4 * (q * a + m);0 <= q && this.matchColor(d, e, f, g, h);) { - --q, d -= 4 * a; + for (var d = 4 * (c.y * b + c.x), e = this.colorLayerData.data[d], f = this.colorLayerData.data[d + 1], g = this.colorLayerData.data[d + 2], h = this.colorLayerData.data[d + 3], k, l, c = [[c.x, c.y]], n = Entry.hex2rgb(this.stroke.lineColor);c.length;) { + for (var d = c.pop(), m = d[0], q = d[1], d = 4 * (q * b + m);0 <= q && this.matchColor(d, e, f, g, h);) { + --q, d -= 4 * b; } - d += 4 * a; + d += 4 * b; q += 1; - for (l = k = !1;q < b - 1 && this.matchColor(d, e, f, g, h);) { - q += 1, this.colorPixel(d, n.r, n.g, n.b), 0 < m && (this.matchColor(d - 4, e, f, g, h) ? k || (c.push([m - 1, q]), k = !0) : k && (k = !1)), m < a - 1 && (this.matchColor(d + 4, e, f, g, h) ? l || (c.push([m + 1, q]), l = !0) : l && (l = !1)), d += 4 * a; + for (l = k = !1;q < a - 1 && this.matchColor(d, e, f, g, h);) { + q += 1, this.colorPixel(d, n.r, n.g, n.b), 0 < m && (this.matchColor(d - 4, e, f, g, h) ? k || (c.push([m - 1, q]), k = !0) : k && (k = !1)), m < b - 1 && (this.matchColor(d + 4, e, f, g, h) ? l || (c.push([m + 1, q]), l = !0) : l && (l = !1)), d += 4 * b; } if (1080 < c.length) { break; @@ -10760,23 +9097,23 @@ Entry.Painter.prototype.reloadContext = function() { delete this.selectedObject; this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); this.ctx.putImageData(this.colorLayerData, 0, 0); - var a = new Image; - a.src = this.canvas.toDataURL(); - var b = this; - a.onload = function(a) { - a = new createjs.Bitmap(a.target); - b.objectContainer.removeAllChildren(); - b.objectContainer.addChild(a); - b.stroke.locked = !1; + var b = new Image; + b.src = this.canvas.toDataURL(); + var a = this; + b.onload = function(b) { + b = new createjs.Bitmap(b.target); + a.objectContainer.removeAllChildren(); + a.objectContainer.addChild(b); + a.stroke.locked = !1; }; }; Entry.Painter.prototype.move_pen = function() { - var a = new createjs.Point(this.oldPt.x + this.stage.mouseX >> 1, this.oldPt.y + this.stage.mouseY >> 1); - this.brush.graphics.setStrokeStyle(this.stroke.thickness, "round").beginStroke(this.stroke.lineColor).moveTo(a.x, a.y).curveTo(this.oldPt.x, this.oldPt.y, this.oldMidPt.x, this.oldMidPt.y); + var b = new createjs.Point(this.oldPt.x + this.stage.mouseX >> 1, this.oldPt.y + this.stage.mouseY >> 1); + this.brush.graphics.setStrokeStyle(this.stroke.thickness, "round").beginStroke(this.stroke.lineColor).moveTo(b.x, b.y).curveTo(this.oldPt.x, this.oldPt.y, this.oldMidPt.x, this.oldMidPt.y); this.oldPt.x = this.stage.mouseX; this.oldPt.y = this.stage.mouseY; - this.oldMidPt.x = a.x; - this.oldMidPt.y = a.y; + this.oldMidPt.x = b.x; + this.oldMidPt.y = b.y; this.file.modified = !0; this.stage.update(); }; @@ -10786,18 +9123,18 @@ Entry.Painter.prototype.move_line = function() { this.stage.update(); }; Entry.Painter.prototype.move_rect = function() { - var a = this.stage.mouseX - this.oldPt.x, b = this.stage.mouseY - this.oldPt.y; - event.shiftKey && (b = a); - this.stroke.fill ? 0 === this.stroke.thickness ? this.brush.graphics.clear().setStrokeStyle(this.stroke.thickness, "round").beginFill(this.stroke.fillColor).drawRect(this.oldPt.x, this.oldPt.y, a, b) : this.brush.graphics.clear().beginStroke(this.stroke.lineColor).setStrokeStyle(this.stroke.thickness, "round").beginFill(this.stroke.fillColor).drawRect(this.oldPt.x, this.oldPt.y, a, b) : 0 === this.stroke.thickness ? this.brush.graphics.clear().setStrokeStyle(this.stroke.thickness, "round").drawRect(this.oldPt.x, - this.oldPt.y, a, b) : this.brush.graphics.clear().beginStroke(this.stroke.lineColor).setStrokeStyle(this.stroke.thickness, "round").drawRect(this.oldPt.x, this.oldPt.y, a, b); + var b = this.stage.mouseX - this.oldPt.x, a = this.stage.mouseY - this.oldPt.y; + event.shiftKey && (a = b); + this.stroke.fill ? 0 === this.stroke.thickness ? this.brush.graphics.clear().setStrokeStyle(this.stroke.thickness, "round").beginFill(this.stroke.fillColor).drawRect(this.oldPt.x, this.oldPt.y, b, a) : this.brush.graphics.clear().beginStroke(this.stroke.lineColor).setStrokeStyle(this.stroke.thickness, "round").beginFill(this.stroke.fillColor).drawRect(this.oldPt.x, this.oldPt.y, b, a) : 0 === this.stroke.thickness ? this.brush.graphics.clear().setStrokeStyle(this.stroke.thickness, "round").drawRect(this.oldPt.x, + this.oldPt.y, b, a) : this.brush.graphics.clear().beginStroke(this.stroke.lineColor).setStrokeStyle(this.stroke.thickness, "round").drawRect(this.oldPt.x, this.oldPt.y, b, a); this.file.modified = !0; this.stage.update(); }; Entry.Painter.prototype.move_circle = function() { - var a = this.stage.mouseX - this.oldPt.x, b = this.stage.mouseY - this.oldPt.y; - event.shiftKey && (b = a); - this.stroke.fill ? 0 === this.stroke.thickness ? this.brush.graphics.clear().beginStroke(this.stroke.fillColor).setStrokeStyle(this.stroke.thickness, "round").beginFill(this.stroke.fillColor).drawEllipse(this.oldPt.x, this.oldPt.y, a, b) : this.brush.graphics.clear().beginStroke(this.stroke.lineColor).setStrokeStyle(this.stroke.thickness, "round").beginFill(this.stroke.fillColor).drawEllipse(this.oldPt.x, this.oldPt.y, a, b) : this.stroke.fill || (0 === this.stroke.thickness ? this.brush.graphics.clear().drawEllipse(this.oldPt.x, - this.oldPt.y, a, b) : this.brush.graphics.clear().beginStroke(this.stroke.lineColor).setStrokeStyle(this.stroke.thickness, "round").drawEllipse(this.oldPt.x, this.oldPt.y, a, b)); + var b = this.stage.mouseX - this.oldPt.x, a = this.stage.mouseY - this.oldPt.y; + event.shiftKey && (a = b); + this.stroke.fill ? 0 === this.stroke.thickness ? this.brush.graphics.clear().beginStroke(this.stroke.fillColor).setStrokeStyle(this.stroke.thickness, "round").beginFill(this.stroke.fillColor).drawEllipse(this.oldPt.x, this.oldPt.y, b, a) : this.brush.graphics.clear().beginStroke(this.stroke.lineColor).setStrokeStyle(this.stroke.thickness, "round").beginFill(this.stroke.fillColor).drawEllipse(this.oldPt.x, this.oldPt.y, b, a) : this.stroke.fill || (0 === this.stroke.thickness ? this.brush.graphics.clear().drawEllipse(this.oldPt.x, + this.oldPt.y, b, a) : this.brush.graphics.clear().beginStroke(this.stroke.lineColor).setStrokeStyle(this.stroke.thickness, "round").drawEllipse(this.oldPt.x, this.oldPt.y, b, a)); this.file.modified = !0; this.stage.update(); }; @@ -10810,18 +9147,18 @@ Entry.Painter.prototype.edit_cut = function() { 0), this.ctx.clearRect(this.selectArea.x1, this.selectArea.y1, this.selectArea.x2, this.selectArea.y2), this.colorLayerData = this.ctx.getImageData(0, 0, this.canvas.width, this.canvas.height), this.reloadContext(), this.file.modified = !0) : alert("\uc790\ub97c \uc601\uc5ed\uc744 \uc120\ud0dd\ud558\uc138\uc694."); }; Entry.Painter.prototype.edit_paste = function() { - var a = new Image; - a.src = this.canvas_.toDataURL(); - var b = this; - a.onload = function(a) { - a = new createjs.Bitmap(a.target); - a.x = b.canvas.width / 2; - a.y = b.canvas.height / 2; - a.regX = b.copy.width / 2 | 0; - a.regY = b.copy.height / 2 | 0; - a.id = Entry.generateHash(); - b.objectContainer.addChild(a); - b.selectObject(a, !0); + var b = new Image; + b.src = this.canvas_.toDataURL(); + var a = this; + b.onload = function(b) { + b = new createjs.Bitmap(b.target); + b.x = a.canvas.width / 2; + b.y = a.canvas.height / 2; + b.regX = a.copy.width / 2 | 0; + b.regY = a.copy.height / 2 | 0; + b.id = Entry.generateHash(); + a.objectContainer.addChild(b); + a.selectObject(b, !0); }; this.file.modified = !0; }; @@ -10840,35 +9177,35 @@ Entry.Painter.prototype.edit_select = function() { this.colorLayerData = this.ctx.getImageData(0, 0, this.canvas.width, this.canvas.height); this.ctx.clearRect(0, 0, this.canvas.width, this.canvas.height); this.ctx.putImageData(this.colorLayerData, 0, 0); - var a = new Image; - a.src = this.canvas.toDataURL(); - var b = this; - a.onload = function(a) { - a = new createjs.Bitmap(a.target); - b.objectContainer.removeAllChildren(); - b.objectContainer.addChild(a); - a = new Image; - a.src = b.canvas_.toDataURL(); - a.onload = function(a) { - a = new createjs.Bitmap(a.target); - a.x = b.selectArea.x1 + b.copy.width / 2; - a.y = b.selectArea.y1 + b.copy.height / 2; - a.regX = b.copy.width / 2 | 0; - a.regY = b.copy.height / 2 | 0; - a.id = Entry.generateHash(); - a.name = a.id; - b.objectContainer.addChild(a); - b.selectObject(a, !0); + var b = new Image; + b.src = this.canvas.toDataURL(); + var a = this; + b.onload = function(b) { + b = new createjs.Bitmap(b.target); + a.objectContainer.removeAllChildren(); + a.objectContainer.addChild(b); + b = new Image; + b.src = a.canvas_.toDataURL(); + b.onload = function(b) { + b = new createjs.Bitmap(b.target); + b.x = a.selectArea.x1 + a.copy.width / 2; + b.y = a.selectArea.y1 + a.copy.height / 2; + b.regX = a.copy.width / 2 | 0; + b.regY = a.copy.height / 2 | 0; + b.id = Entry.generateHash(); + b.name = b.id; + a.objectContainer.addChild(b); + a.selectObject(b, !0); }; }; }; -Entry.Painter.prototype.move_erase = function(a) { - a = new createjs.Point(this.oldPt.x + this.stage.mouseX >> 1, this.oldPt.y + this.stage.mouseY >> 1); - this.eraser.graphics.setStrokeStyle(this.stroke.thickness, "round").beginStroke("#ffffff").moveTo(a.x, a.y).curveTo(this.oldPt.x, this.oldPt.y, this.oldMidPt.x, this.oldMidPt.y); +Entry.Painter.prototype.move_erase = function(b) { + b = new createjs.Point(this.oldPt.x + this.stage.mouseX >> 1, this.oldPt.y + this.stage.mouseY >> 1); + this.eraser.graphics.setStrokeStyle(this.stroke.thickness, "round").beginStroke("#ffffff").moveTo(b.x, b.y).curveTo(this.oldPt.x, this.oldPt.y, this.oldMidPt.x, this.oldMidPt.y); this.oldPt.x = this.stage.mouseX; this.oldPt.y = this.stage.mouseY; - this.oldMidPt.x = a.x; - this.oldMidPt.y = a.y; + this.oldMidPt.x = b.x; + this.oldMidPt.y = b.y; this.file.modified = !0; this.stage.update(); }; @@ -10877,110 +9214,111 @@ Entry.Painter.prototype.settingShapeBlur = function() { this.objectHeightInput.blur(); this.objectRotateInput.blur(); }; -Entry.Painter.prototype.stagemousedown = function(a) { - "picture" == Entry.playground.getViewMode() && (this.settingShapeBlur(), this.oldPt = new createjs.Point(a.stageX, a.stageY), this.oldMidPt = this.oldPt.clone(), "select" === this.toolbox.selected ? this.stage.addChild(this._handle) : "spoid" === this.toolbox.selected ? this.pickStrokeColor(a) : "text" === this.toolbox.selected ? (this.showInputField(a), this.stage.update()) : "erase" === this.toolbox.selected ? (this.createEraser(), this.stroke.enabled = !0) : "fill" === this.toolbox.selected ? +Entry.Painter.prototype.stagemousedown = function(b) { + "picture" == Entry.playground.getViewMode() && (this.settingShapeBlur(), this.oldPt = new createjs.Point(b.stageX, b.stageY), this.oldMidPt = this.oldPt.clone(), "select" === this.toolbox.selected ? this.stage.addChild(this._handle) : "spoid" === this.toolbox.selected ? this.pickStrokeColor(b) : "text" === this.toolbox.selected ? (this.showInputField(b), this.stage.update()) : "erase" === this.toolbox.selected ? (this.createEraser(), this.stroke.enabled = !0) : "fill" === this.toolbox.selected ? this.fill() : "cursor" !== this.toolbox.selected && (this.createBrush(), this.stroke.enabled = !0)); }; -Entry.Painter.prototype.stagemousemove = function(a) { - "picture" == Entry.playground.getViewMode() && ("select" === this.toolbox.selected && -1 < this.stage.getChildIndex(this._handle) ? (this.selectArea.x1 = this.oldPt.x, this.selectArea.y1 = this.oldPt.y, this.selectArea.x2 = a.stageX - this.oldPt.x, this.selectArea.y2 = a.stageY - this.oldPt.y, this.updateHandle_()) : this.stroke.enabled && (this.doCommand(), "pen" === this.toolbox.selected ? this.move_pen(a) : "line" === this.toolbox.selected ? this.move_line(a) : "rect" === this.toolbox.selected ? - this.move_rect(a) : "circle" === this.toolbox.selected ? this.move_circle(a) : "erase" === this.toolbox.selected && this.move_erase(a)), this.painterTopStageXY.innerHTML = "x:" + a.stageX.toFixed(1) + ", y:" + a.stageY.toFixed(1)); +Entry.Painter.prototype.stagemousemove = function(b) { + "picture" == Entry.playground.getViewMode() && ("select" === this.toolbox.selected && -1 < this.stage.getChildIndex(this._handle) ? (this.selectArea.x1 = this.oldPt.x, this.selectArea.y1 = this.oldPt.y, this.selectArea.x2 = b.stageX - this.oldPt.x, this.selectArea.y2 = b.stageY - this.oldPt.y, this.updateHandle_()) : this.stroke.enabled && (this.doCommand(), "pen" === this.toolbox.selected ? this.move_pen(b) : "line" === this.toolbox.selected ? this.move_line(b) : "rect" === this.toolbox.selected ? + this.move_rect(b) : "circle" === this.toolbox.selected ? this.move_circle(b) : "erase" === this.toolbox.selected && this.move_erase(b)), this.painterTopStageXY.innerHTML = "x:" + b.stageX.toFixed(1) + ", y:" + b.stageY.toFixed(1)); }; -Entry.Painter.prototype.stagemouseup = function(a) { - "picture" == Entry.playground.getViewMode() && ("select" === this.toolbox.selected ? (this.selectArea.x1 = this.oldPt.x, this.selectArea.y1 = this.oldPt.y, this.selectArea.x2 = a.stageX - this.oldPt.x, this.selectArea.y2 = a.stageY - this.oldPt.y, this.stage.removeChild(this._handle), this.stage.update(), 0 < this.selectArea.x2 && 0 < this.selectArea.y2 && this.edit_select(), this.selectToolbox("cursor")) : "cursor" !== this.toolbox.selected && this.stroke.enabled && (-1 < this.objectContainer.getChildIndex(this.eraser) && +Entry.Painter.prototype.stagemouseup = function(b) { + "picture" == Entry.playground.getViewMode() && ("select" === this.toolbox.selected ? (this.selectArea.x1 = this.oldPt.x, this.selectArea.y1 = this.oldPt.y, this.selectArea.x2 = b.stageX - this.oldPt.x, this.selectArea.y2 = b.stageY - this.oldPt.y, this.stage.removeChild(this._handle), this.stage.update(), 0 < this.selectArea.x2 && 0 < this.selectArea.y2 && this.edit_select(), this.selectToolbox("cursor")) : "cursor" !== this.toolbox.selected && this.stroke.enabled && (-1 < this.objectContainer.getChildIndex(this.eraser) && this.eraser.graphics.endStroke(), -1 < this.objectContainer.getChildIndex(this.brush) && this.brush.graphics.endStroke(), this.clearHandle(), this.platten(), this.stroke.enabled = !1, this.checkCommand())); }; -Entry.Painter.prototype.file_save = function(a) { +Entry.Painter.prototype.file_save = function(b) { this.clearHandle(); this.transparent(); this.trim(); - var b = this.canvas_.toDataURL(); - Entry.dispatchEvent("saveCanvasImage", {file:a ? this.file_ : this.file, image:b}); + var a = this.canvas_.toDataURL(); + Entry.dispatchEvent("saveCanvasImage", {file:b ? this.file_ : this.file, image:a}); this.file.modified = !1; }; Entry.Painter.prototype.transparent = function() { - var a = this.canvas.width, b = this.canvas.height; - this.colorLayerData = this.ctx.getImageData(0, 0, a, b); - var c = a * (b - 1) * 4, d = 4 * (a - 1), e = 4 * (a * b - 1); - this.matchColorOnly(0, 255, 255, 255) ? this.fillTransparent(1, 1) : this.matchColorOnly(c, 255, 255, 255) ? this.fillTransparent(1, b) : this.matchColorOnly(d, 255, 255, 255) ? this.fillTransparent(a, 1) : this.matchColorOnly(e, 255, 255, 255) && this.fillTransparent(a, b); -}; -Entry.Painter.prototype.fillTransparent = function(a, b) { - this.stage.mouseX = a; - this.stage.mouseY = b; + var b = this.canvas.width, a = this.canvas.height; + this.colorLayerData = this.ctx.getImageData(0, 0, b, a); + var c = b * (a - 1) * 4, d = 4 * (b - 1), e = 4 * (b * a - 1); + this.matchColorOnly(0, 255, 255, 255) ? this.fillTransparent(1, 1) : this.matchColorOnly(c, 255, 255, 255) ? this.fillTransparent(1, a) : this.matchColorOnly(d, 255, 255, 255) ? this.fillTransparent(b, 1) : this.matchColorOnly(e, 255, 255, 255) && this.fillTransparent(b, a); +}; +Entry.Painter.prototype.fillTransparent = function(b, a) { + this.stage.mouseX = b; + this.stage.mouseY = a; this.stroke.transparent = !0; this.fill(); }; Entry.Painter.prototype.trim = function() { - var a = this.canvas.width, b = this.ctx.getImageData(0, 0, a, this.canvas.height), c = b.data.length, d, e = null, f = null, g = null, h = null, k; + var b = this.canvas.width, a = this.ctx.getImageData(0, 0, b, this.canvas.height), c = a.data.length, d, e = null, f = null, g = null, h = null, k; for (d = 0;d < c;d += 4) { - 0 !== b.data[d + 3] && (g = d / 4 % a, k = ~~(d / 4 / a), null === e && (e = k), null === f ? f = g : g < f && (f = g), null === h ? h = k : h < k && (h = k)); + 0 !== a.data[d + 3] && (g = d / 4 % b, k = ~~(d / 4 / b), null === e && (e = k), null === f ? f = g : g < f && (f = g), null === h ? h = k : h < k && (h = k)); } - a = h - e; - b = g - f; - 0 === a || 0 === b ? (e = this.ctx.getImageData(0, 0, 1, 1), e.data[0] = 255, e.data[1] = 255, e.data[2] = 255, e.data[3] = 255, this.canvas_.width = 1, this.canvas_.height = 1) : (e = this.ctx.getImageData(f, e, b, a), this.canvas_.width = b, this.canvas_.height = a); - this.ctx_.putImageData(e, 0, 0); + b = h - e; + a = g - f; + c = null; + 0 === b || 0 === a ? (c = this.ctx.getImageData(0, 0, 1, 1), c.data[0] = 255, c.data[1] = 255, c.data[2] = 255, c.data[3] = 255, this.canvas_.width = 1, this.canvas_.height = 1) : (c = this.ctx.getImageData(f, e, a, b), this.canvas_.width = a, this.canvas_.height = b); + this.ctx_.putImageData(c, 0, 0); }; -Entry.Painter.prototype.showInputField = function(a) { - this.inputField ? (Entry.dispatchEvent("textUpdate"), delete this.inputField) : (this.initCommand(), this.doCommand(), this.inputField = new CanvasInput({canvas:document.getElementById("entryPainterCanvas"), fontSize:20, fontFamily:this.font.name, fontColor:"#000", width:650, padding:8, borderWidth:1, borderColor:"#000", borderRadius:3, boxShadow:"1px 1px 0px #fff", innerShadow:"0px 0px 5px rgba(0, 0, 0, 0.5)", x:a.stageX, y:a.stageY, onsubmit:function() { +Entry.Painter.prototype.showInputField = function(b) { + this.inputField ? (Entry.dispatchEvent("textUpdate"), delete this.inputField) : (this.initCommand(), this.doCommand(), this.inputField = new CanvasInput({canvas:document.getElementById("entryPainterCanvas"), fontSize:20, fontFamily:this.font.name, fontColor:"#000", width:650, padding:8, borderWidth:1, borderColor:"#000", borderRadius:3, boxShadow:"1px 1px 0px #fff", innerShadow:"0px 0px 5px rgba(0, 0, 0, 0.5)", x:b.stageX, y:b.stageY, onsubmit:function() { Entry.dispatchEvent("textUpdate"); }}), this.inputField.show()); }; -Entry.Painter.prototype.addPicture = function(a) { +Entry.Painter.prototype.addPicture = function(b) { this.initCommand(); - var b = new Image; - b.id = Entry.generateHash(); - b.src = a.fileurl ? a.fileurl : Entry.defaultPath + "/uploads/" + a.filename.substring(0, 2) + "/" + a.filename.substring(2, 4) + "/image/" + a.filename + ".png"; + var a = new Image; + a.id = Entry.generateHash(); + a.src = b.fileurl ? b.fileurl : Entry.defaultPath + "/uploads/" + b.filename.substring(0, 2) + "/" + b.filename.substring(2, 4) + "/image/" + b.filename + ".png"; var c = this; - b.onload = function(b) { - c.addImage(b.target); + a.onload = function(a) { + c.addImage(a.target); c.selectToolbox("cursor"); }; }; Entry.Painter.prototype.initCoordinator = function() { - var a = new createjs.Container, b = new createjs.Bitmap(Entry.mediaFilePath + "/workspace_coordinate.png"); - a.addChild(b); - this.stage.addChild(a); - a.visible = !1; - this.coordinator = a; + var b = new createjs.Container, a = new createjs.Bitmap(Entry.mediaFilePath + "/workspace_coordinate.png"); + b.addChild(a); + this.stage.addChild(b); + b.visible = !1; + this.coordinator = b; }; Entry.Painter.prototype.toggleCoordinator = function() { this.coordinator.visible = !this.coordinator.visible; this.stage.update(); }; Entry.Painter.prototype.initDashedLine = function() { - createjs.Graphics.prototype.dashedLineTo = function(a, b, c, d, e) { - this.moveTo(a, b); - var f = c - a, g = d - b; + createjs.Graphics.prototype.dashedLineTo = function(b, a, c, d, e) { + this.moveTo(b, a); + var f = c - b, g = d - a; e = Math.floor(Math.sqrt(f * f + g * g) / e); for (var f = f / e, g = g / e, h = 0;h++ < e;) { - a += f, b += g, this[0 === h % 2 ? "moveTo" : "lineTo"](a, b); + b += f, a += g, this[0 === h % 2 ? "moveTo" : "lineTo"](b, a); } this[0 === h % 2 ? "moveTo" : "lineTo"](c, d); return this; }; - createjs.Graphics.prototype.drawDashedRect = function(a, b, c, d, e) { - this.moveTo(a, b); - c = a + c; - d = b + d; - this.dashedLineTo(a, b, c, b, e); - this.dashedLineTo(c, b, c, d, e); - this.dashedLineTo(c, d, a, d, e); - this.dashedLineTo(a, d, a, b, e); + createjs.Graphics.prototype.drawDashedRect = function(b, a, c, d, e) { + this.moveTo(b, a); + c = b + c; + d = a + d; + this.dashedLineTo(b, a, c, a, e); + this.dashedLineTo(c, a, c, d, e); + this.dashedLineTo(c, d, b, d, e); + this.dashedLineTo(b, d, b, a, e); return this; }; - createjs.Graphics.prototype.drawResizableDashedRect = function(a, b, c, d, e, f) { - this.moveTo(a, b); - c = a + c; - d = b + d; - this.dashedLineTo(a + f, b, c - f, b, e); - this.dashedLineTo(c, b + f, c, d - f, e); - this.dashedLineTo(c - f, d, a + f, d, e); - this.dashedLineTo(a, d - f, a, b + f, e); + createjs.Graphics.prototype.drawResizableDashedRect = function(b, a, c, d, e, f) { + this.moveTo(b, a); + c = b + c; + d = a + d; + this.dashedLineTo(b + f, a, c - f, a, e); + this.dashedLineTo(c, a + f, c, d - f, e); + this.dashedLineTo(c - f, d, b + f, d, e); + this.dashedLineTo(b, d - f, b, a + f, e); return this; }; }; -Entry.Painter.prototype.generateView = function(a) { - var b = this; - this.view_ = a; +Entry.Painter.prototype.generateView = function(b) { + var a = this; + this.view_ = b; if (!Entry.type || "workspace" == Entry.type) { this.view_.addClass("entryPainterWorkspace"); var c = Entry.createElement("div", "entryPainterTop"); @@ -11014,26 +9352,26 @@ Entry.Painter.prototype.generateView = function(a) { e = Entry.createElement("div", "entryPictureFlipX"); e.title = "\uc88c\uc6b0\ub4a4\uc9d1\uae30"; e.bindOnClick(function() { - b.selectedObject && (b.selectedObject.scaleX *= -1, b.selectedObject.text ? b.selectTextObject(b.selectedObject) : b.selectObject(b.selectedObject), b.updateImageHandle(), b.stage.update()); + a.selectedObject && (a.selectedObject.scaleX *= -1, a.selectedObject.text ? a.selectTextObject(a.selectedObject) : a.selectObject(a.selectedObject), a.updateImageHandle(), a.stage.update()); }); e.addClass("entryPlaygroundPainterFlipX"); this.flipObject.appendChild(e); e = Entry.createElement("div", "entryPictureFlipY"); e.title = "\uc0c1\ud558\ub4a4\uc9d1\uae30"; e.bindOnClick(function() { - b.selectedObject && (b.selectedObject.scaleY *= -1, b.selectedObject.text ? b.selectTextObject(b.selectedObject) : b.selectObject(b.selectedObject), b.updateImageHandle(), b.stage.update()); + a.selectedObject && (a.selectedObject.scaleY *= -1, a.selectedObject.text ? a.selectTextObject(a.selectedObject) : a.selectObject(a.selectedObject), a.updateImageHandle(), a.stage.update()); }); e.addClass("entryPlaygroundPainterFlipY"); this.flipObject.appendChild(e); - Entry.addEventListener("windowResized", function(b) { + Entry.addEventListener("windowResized", function(a) { var c = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; - b = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; - var d = parseInt(document.getElementById("entryCanvas").style.width), c = c - (d + 240), d = b - 349; - a.style.width = c + "px"; + a = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; + var d = parseInt(document.getElementById("entryCanvas").style.width), c = c - (d + 240), d = a - 349; + b.style.width = c + "px"; f.style.width = c - 54 + "px"; f.style.height = d + "px"; g.style.top = d + 30 + "px"; - g.style.height = b - d + "px"; + g.style.height = a - d + "px"; }); var h = Entry.createElement("nav", "entryPainterTopMenu"); h.addClass("entryPlaygroundPainterTopMenu"); @@ -11044,7 +9382,7 @@ Entry.Painter.prototype.generateView = function(a) { h.appendChild(k); h = Entry.createElement("a", "entryPainterTopMenuFileNew"); h.bindOnClick(function() { - b.newPicture(); + a.newPicture(); }); h.addClass("entryPlaygroundPainterTopMenuFileNew"); h.innerHTML = Lang.Workspace.new_picture; @@ -11059,7 +9397,7 @@ Entry.Painter.prototype.generateView = function(a) { k.appendChild(h); var l = Entry.createElement("a", "entryPainterTopMenuFileSave"); l.bindOnClick(function() { - b.file_save(!1); + a.file_save(!1); }); l.addClass("entryPainterTopMenuFileSave"); l.innerHTML = Lang.Workspace.painter_file_save; @@ -11068,8 +9406,8 @@ Entry.Painter.prototype.generateView = function(a) { k.appendChild(h); k = Entry.createElement("a", "entryPainterTopMenuFileSaveAs"); k.bindOnClick(function() { - b.file.mode = "new"; - b.file_save(!1); + a.file.mode = "new"; + a.file_save(!1); }); k.addClass("entryPlaygroundPainterTopMenuFileSaveAs"); k.innerHTML = Lang.Workspace.painter_file_saveas; @@ -11093,7 +9431,7 @@ Entry.Painter.prototype.generateView = function(a) { e.appendChild(k); h = Entry.createElement("a", "entryPainterTopMenuEditCopy"); h.bindOnClick(function() { - b.edit_copy(); + a.edit_copy(); }); h.addClass("entryPlaygroundPainterTopMenuEditCopy"); h.innerHTML = Lang.Workspace.copy_file; @@ -11102,7 +9440,7 @@ Entry.Painter.prototype.generateView = function(a) { e.appendChild(k); h = Entry.createElement("a", "entryPainterTopMenuEditCut"); h.bindOnClick(function() { - b.edit_cut(); + a.edit_cut(); }); h.addClass("entryPlaygroundPainterTopMenuEditCut"); h.innerHTML = Lang.Workspace.cut_picture; @@ -11111,7 +9449,7 @@ Entry.Painter.prototype.generateView = function(a) { e.appendChild(k); h = Entry.createElement("a", "entryPainterTopMenuEditPaste"); h.bindOnClick(function() { - b.edit_paste(); + a.edit_paste(); }); h.addClass("entryPlaygroundPainterTopMenuEditPaste"); h.innerHTML = Lang.Workspace.paste_picture; @@ -11122,7 +9460,7 @@ Entry.Painter.prototype.generateView = function(a) { e.addClass("entryPlaygroundPainterTopMenuEditEraseAll"); e.innerHTML = Lang.Workspace.remove_all; e.bindOnClick(function() { - b.clearCanvas(); + a.clearCanvas(); }); k.appendChild(e); this.painterTopStageXY = e = Entry.createElement("div", "entryPainterTopStageXY"); @@ -11147,69 +9485,69 @@ Entry.Painter.prototype.generateView = function(a) { this.toolboxCursor = Entry.createElement("li", "entryPainterToolboxCursor"); this.toolboxCursor.title = "\uc774\ub3d9"; this.toolboxCursor.bindOnClick(function() { - b.selectToolbox("cursor"); + a.selectToolbox("cursor"); }); this.toolboxCursor.addClass("entryPlaygroundPainterToolboxCursor"); c.appendChild(this.toolboxCursor); this.toolboxSelect = Entry.createElement("li", "entryPainterToolboxSelect"); this.toolboxSelect.title = "\uc790\ub974\uae30"; this.toolboxSelect.bindOnClick(function() { - b.selectToolbox("select"); + a.selectToolbox("select"); }); this.toolboxSelect.addClass("entryPlaygroundPainterToolboxSelect"); c.appendChild(this.toolboxSelect); this.toolboxPen = Entry.createElement("li", "entryPainterToolboxPen"); this.toolboxPen.title = "\ud39c"; this.toolboxPen.bindOnClick(function() { - b.selectToolbox("pen"); + a.selectToolbox("pen"); }); this.toolboxPen.addClass("entryPlaygroundPainterToolboxPen"); c.appendChild(this.toolboxPen); this.toolboxLine = Entry.createElement("li", "entryPainterToolboxLine"); this.toolboxLine.title = "\uc9c1\uc120"; this.toolboxLine.bindOnClick(function() { - b.selectToolbox("line"); + a.selectToolbox("line"); }); this.toolboxLine.addClass("entryPlaygroundPainterToolboxLine"); c.appendChild(this.toolboxLine); this.toolboxRect = Entry.createElement("li", "entryPainterToolboxRect"); this.toolboxRect.title = "\uc0ac\uac01\ud615"; this.toolboxRect.bindOnClick(function() { - b.selectToolbox("rect"); + a.selectToolbox("rect"); }); this.toolboxRect.addClass("entryPlaygroundPainterToolboxRect"); c.appendChild(this.toolboxRect); this.toolboxCircle = Entry.createElement("li", "entryPainterToolboxCircle"); this.toolboxCircle.title = "\uc6d0"; this.toolboxCircle.bindOnClick(function() { - b.selectToolbox("circle"); + a.selectToolbox("circle"); }); this.toolboxCircle.addClass("entryPlaygroundPainterToolboxCircle"); c.appendChild(this.toolboxCircle); this.toolboxText = Entry.createElement("li", "entryPainterToolboxText"); this.toolboxText.title = "\uae00\uc0c1\uc790"; this.toolboxText.bindOnClick(function() { - b.selectToolbox("text"); + a.selectToolbox("text"); }); this.toolboxText.addClass("entryPlaygroundPainterToolboxText"); c.appendChild(this.toolboxText); this.toolboxFill = Entry.createElement("li", "entryPainterToolboxFill"); this.toolboxFill.bindOnClick(function() { - b.selectToolbox("fill"); + a.selectToolbox("fill"); }); this.toolboxFill.addClass("entryPlaygroundPainterToolboxFill"); c.appendChild(this.toolboxFill); this.toolboxErase = Entry.createElement("li", "entryPainterToolboxErase"); this.toolboxErase.title = "\uc9c0\uc6b0\uae30"; this.toolboxErase.bindOnClick(function() { - b.selectToolbox("erase"); + a.selectToolbox("erase"); }); this.toolboxErase.addClass("entryPlaygroundPainterToolboxErase"); c.appendChild(this.toolboxErase); d = Entry.createElement("li", "entryPainterToolboxCoordinate"); d.title = "\uc88c\ud45c"; d.bindOnClick(function() { - b.toggleCoordinator(); + a.toggleCoordinator(); }); d.addClass("entryPlaygroundPainterToolboxCoordinate"); c.appendChild(d); @@ -11234,8 +9572,8 @@ Entry.Painter.prototype.generateView = function(a) { if (isNaN(this.value)) { return alert("\uc22b\uc790\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4."), !1; } - b.handle.width = this.value; - b.updateImageHandle(); + a.handle.width = this.value; + a.updateImageHandle(); }; this.objectWidthInput.addClass("entryPlaygroundPainterNumberInput"); c.appendChild(this.objectWidthInput); @@ -11255,8 +9593,8 @@ Entry.Painter.prototype.generateView = function(a) { if (isNaN(this.value)) { return alert("\uc22b\uc790\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4."), !1; } - b.handle.height = this.value; - b.updateImageHandle(); + a.handle.height = this.value; + a.updateImageHandle(); }; this.objectHeightInput.addClass("entryPlaygroundPainterNumberInput"); c.appendChild(this.objectHeightInput); @@ -11280,8 +9618,8 @@ Entry.Painter.prototype.generateView = function(a) { return alert("\uc22b\uc790\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4."), !1; } 360 <= this.value ? this.value %= 360 : 0 > this.value && (this.value = 360 + this.value % 360); - b.handle.rotation = this.value; - b.updateImageHandle(); + a.handle.rotation = this.value; + a.updateImageHandle(); }; this.objectRotateInput.addClass("entryPlaygroundPainterNumberInput"); this.objectRotateInput.defaultValue = "0"; @@ -11305,18 +9643,18 @@ Entry.Painter.prototype.generateView = function(a) { this.attrCircleArea.appendChild(d); this.attrColorSpoid = Entry.createElement("div"); this.attrColorSpoid.bindOnClick(function() { - b.selectToolbox("spoid"); + a.selectToolbox("spoid"); }); this.attrColorSpoid.addClass("painterAttrColorSpoid"); g.appendChild(this.attrColorSpoid); - Entry.getColourCodes().forEach(function(a) { + Entry.getColourCodes().forEach(function(b) { var c = Entry.createElement("div"); c.addClass("entryPlaygroundPainterAttrColorElement"); - "transparent" === a ? c.style.backgroundImage = "url(" + (Entry.mediaFilePath + "/transparent.png") + ")" : c.style.backgroundColor = a; + "transparent" === b ? c.style.backgroundImage = "url(" + (Entry.mediaFilePath + "/transparent.png") + ")" : c.style.backgroundColor = b; c.bindOnClick(function(c) { - "transparent" === a ? (b.stroke.transparent = !0, b.stroke.lineColor = "#ffffff") : (b.stroke.transparent = !1, r && (document.getElementById("entryPainterShapeBackgroundColor").style.backgroundColor = a, b.stroke.fillColor = a), r || (document.getElementById("entryPainterShapeLineColor").style.backgroundColor = a, b.stroke.lineColor = a)); - document.getElementById("entryPainterAttrCircle").style.backgroundColor = b.stroke.lineColor; - document.getElementById("entryPainterAttrCircleInput").value = a; + "transparent" === b ? (a.stroke.transparent = !0, a.stroke.lineColor = "#ffffff") : (a.stroke.transparent = !1, r && (document.getElementById("entryPainterShapeBackgroundColor").style.backgroundColor = b, a.stroke.fillColor = b), r || (document.getElementById("entryPainterShapeLineColor").style.backgroundColor = b, a.stroke.lineColor = b)); + document.getElementById("entryPainterAttrCircle").style.backgroundColor = a.stroke.lineColor; + document.getElementById("entryPainterAttrCircleInput").value = b; }); n.appendChild(c); }); @@ -11336,8 +9674,8 @@ Entry.Painter.prototype.generateView = function(a) { e = Entry.createElement("select", "entryPainterAttrThick"); e.addClass("entryPlaygroundPainterAttrThickInput"); e.size = "1"; - e.onchange = function(a) { - b.stroke.thickness = a.target.value; + e.onchange = function(b) { + a.stroke.thickness = b.target.value; }; for (d = 1;10 >= d;d++) { c = Entry.createElement("option"), c.value = d, c.innerHTML = d, e.appendChild(c); @@ -11369,7 +9707,7 @@ Entry.Painter.prototype.generateView = function(a) { this.attrBackgroundArea.painterAttrShapeBackgroundColor = q; c.appendChild(q); var r = !1; - q.bindOnClick(function(b) { + q.bindOnClick(function(a) { m.style.zIndex = "1"; this.style.zIndex = "10"; r = !0; @@ -11389,8 +9727,8 @@ Entry.Painter.prototype.generateView = function(a) { k = Entry.createElement("select", "entryPainterAttrFontName"); k.addClass("entryPlaygroundPainterAttrFontName"); k.size = "1"; - k.onchange = function(a) { - b.font.name = a.target.value; + k.onchange = function(b) { + a.font.name = b.target.value; }; for (d = 0;d < Entry.fonts.length;d++) { h = Entry.fonts[d], c = Entry.createElement("option"), c.value = h.family, c.innerHTML = h.name, k.appendChild(c); @@ -11405,8 +9743,8 @@ Entry.Painter.prototype.generateView = function(a) { k = Entry.createElement("select", "entryPainterAttrFontSize"); k.addClass("entryPlaygroundPainterAttrFontSize"); k.size = "1"; - k.onchange = function(a) { - b.font.size = a.target.value; + k.onchange = function(b) { + a.font.size = b.target.value; }; for (d = 20;72 >= d;d++) { c = Entry.createElement("option"), c.value = d, c.innerHTML = d, k.appendChild(c); @@ -11421,8 +9759,8 @@ Entry.Painter.prototype.generateView = function(a) { k = Entry.createElement("select", "entryPainterAttrFontStyle"); k.addClass("entryPlaygroundPainterAttrFontStyle"); k.size = "1"; - k.onchange = function(a) { - b.font.style = a.target.value; + k.onchange = function(b) { + a.font.style = b.target.value; }; h = [{label:"\ubcf4\ud1b5", value:"normal"}, {label:"\uad75\uac8c", value:"bold"}, {label:"\uae30\uc6b8\uc784", value:"italic"}]; for (d = 0;d < h.length;d++) { @@ -11444,26 +9782,26 @@ Entry.Painter.prototype.generateView = function(a) { d.value = "line"; var v = Entry.createElement("div"); v.addClass("painterAttrLineStyleBackgroundLine"); - u.bindOnClick(function(b) { + u.bindOnClick(function(a) { t.removeClass("entryRemove"); }); - t.blur = function(b) { + t.blur = function(a) { this.addClass("entryRemove"); }; - t.onmouseleave = function(b) { + t.onmouseleave = function(a) { this.addClass("entryRemove"); }; - d.bindOnClick(function(b) { + d.bindOnClick(function(a) { this.attrLineArea.removeClass(u); this.attrLineArea.appendChild(v); - this.attrLineArea.onchange(b); + this.attrLineArea.onchange(a); t.blur(); }); - v.bindOnClick(function(b) { + v.bindOnClick(function(a) { t.removeClass("entryRemove"); }); - this.attrLineArea.onchange = function(a) { - b.stroke.style = a.target.value; + this.attrLineArea.onchange = function(b) { + a.stroke.style = b.target.value; }; t.blur(); } @@ -11509,13 +9847,13 @@ Entry.Painter.prototype.initDisplay = function() { this.attrCircleArea.painterAttrCircle.addClass("entryRemove"); this.inputField && !this.inputField._isHidden && (this.inputField.hide(), this.stage.update()); }; -Entry.Painter.prototype.selectToolbox = function(a) { - this.toolbox.selected = a; - "erase" != a && $(".entryPlaygroundPainterContainer").removeClass("dd"); +Entry.Painter.prototype.selectToolbox = function(b) { + this.toolbox.selected = b; + "erase" != b && $(".entryPlaygroundPainterContainer").removeClass("dd"); this.initDisplay(); - "cursor" !== a && this.clearHandle(); - "text" !== a && this.inputField && delete this.inputField; - switch(a) { + "cursor" !== b && this.clearHandle(); + "text" !== b && this.inputField && delete this.inputField; + switch(b) { case "cursor": this.restoreHandle(); this.toolboxCursor.addClass("entryToolboxCursorClicked"); @@ -11593,668 +9931,1296 @@ Entry.Painter.prototype.selectToolbox = function(a) { this.toggleCoordinator(); } }; -Entry.BlockParser = function(a) { - this.syntax = a; +Entry.BlockParser = function(b) { + this.syntax = b; this._iterVariableCount = 0; this._iterVariableChunk = ["i", "j", "k"]; }; -(function(a) { - a.Code = function(b) { - if (b instanceof Entry.Thread) { - return this.Thread(b); +(function(b) { + b.Code = function(a) { + if (a instanceof Entry.Thread) { + return this.Thread(a); } - if (b instanceof Entry.Block) { - return this.Block(b); + if (a instanceof Entry.Block) { + return this.Block(a); } - var a = ""; - b = b.getThreads(); - for (var d = 0;d < b.length;d++) { - a += this.Thread(b[d]); + var b = ""; + a = a.getThreads(); + for (var d = 0;d < a.length;d++) { + b += this.Thread(a[d]); } - return a; + return b; }; - a.Thread = function(b) { - if (b instanceof Entry.Block) { - return this.Block(b); + b.Thread = function(a) { + if (a instanceof Entry.Block) { + return this.Block(a); } - var a = ""; - b = b.getBlocks(); - for (var d = 0;d < b.length;d++) { - a += this.Block(b[d]); + var b = ""; + a = a.getBlocks(); + for (var d = 0;d < a.length;d++) { + b += this.Block(a[d]); } - return a; + return b; }; - a.Block = function(b) { - var a = b._schema.syntax; - return a ? this[a[0]](b) : ""; + b.Block = function(a) { + var b = a._schema.syntax; + return b ? this[b[0]](a) : ""; }; - a.Program = function(b) { + b.Program = function(a) { return ""; }; - a.Scope = function(b) { - b = b._schema.syntax.concat(); - return b.splice(1, b.length - 1).join(".") + "();\n"; + b.Scope = function(a) { + a = a._schema.syntax.concat(); + return a.splice(1, a.length - 1).join(".") + "();\n"; }; - a.BasicFunction = function(b) { - b = this.Thread(b.statements[0]); - return "function promise() {\n" + this.indent(b) + "}\n"; + b.BasicFunction = function(a) { + a = this.Thread(a.statements[0]); + return "function promise() {\n" + this.indent(a) + "}\n"; }; - a.BasicIteration = function(b) { - var a = b.params[0], d = this.publishIterateVariable(); - b = this.Thread(b.statements[0]); + b.BasicIteration = function(a) { + var b = a.params[0], d = this.publishIterateVariable(); + a = this.Thread(a.statements[0]); this.unpublishIterateVariable(); - return "for (var " + d + " = 0; " + d + " < " + a + "; " + d + "++){\n" + this.indent(b) + "}\n"; + return "for (var " + d + " = 0; " + d + " < " + b + "; " + d + "++){\n" + this.indent(a) + "}\n"; }; - a.BasicIf = function(b) { - var a = this.Thread(b.statements[0]); - return "if (" + b._schema.syntax.concat()[1] + ") {\n" + this.indent(a) + "}\n"; + b.BasicIf = function(a) { + var b = this.Thread(a.statements[0]); + return "if (" + a._schema.syntax.concat()[1] + ") {\n" + this.indent(b) + "}\n"; }; - a.BasicWhile = function(b) { - var a = this.Thread(b.statements[0]); - return "while (" + b._schema.syntax.concat()[1] + ") {\n" + this.indent(a) + "}\n"; + b.BasicWhile = function(a) { + var b = this.Thread(a.statements[0]); + return "while (" + a._schema.syntax.concat()[1] + ") {\n" + this.indent(b) + "}\n"; }; - a.indent = function(b) { - var a = " "; - b = b.split("\n"); - b.pop(); - return a += b.join("\n ") + "\n"; + b.indent = function(a) { + var b = " "; + a = a.split("\n"); + a.pop(); + return b += a.join("\n ") + "\n"; }; - a.publishIterateVariable = function() { - var b = "", a = this._iterVariableCount; + b.publishIterateVariable = function() { + var a = "", b = this._iterVariableCount; do { - b = this._iterVariableChunk[a % 3] + b, a = parseInt(a / 3) - 1, 0 === a && (b = this._iterVariableChunk[0] + b); - } while (0 < a); + a = this._iterVariableChunk[b % 3] + a, b = parseInt(b / 3) - 1, 0 === b && (a = this._iterVariableChunk[0] + a); + } while (0 < b); this._iterVariableCount++; - return b; + return a; }; - a.unpublishIterateVariable = function() { + b.unpublishIterateVariable = function() { this._iterVariableCount && this._iterVariableCount--; }; })(Entry.BlockParser.prototype); -Entry.JSParser = function(a) { - this.syntax = a; +Entry.JSParser = function(b) { + this.syntax = b; this.scopeChain = []; this.scope = null; }; -(function(a) { - a.Program = function(b) { - var a = [], d = []; +(function(b) { + b.Program = function(a) { + var b = [], d = []; d.push({type:this.syntax.Program}); - var e = this.initScope(b), d = d.concat(this.BlockStatement(b)); + var e = this.initScope(a), d = d.concat(this.BlockStatement(a)); this.unloadScope(); - a.push(d); - return a = a.concat(e); + b.push(d); + return b = b.concat(e); }; - a.Identifier = function(b, a) { - return a ? a[b.name] : this.scope[b.name]; + b.Identifier = function(a, b) { + return b ? b[a.name] : this.scope[a.name]; }; - a.ExpressionStatement = function(b) { - b = b.expression; - return this[b.type](b); + b.ExpressionStatement = function(a) { + a = a.expression; + return this[a.type](a); }; - a.ForStatement = function(b) { - var a = b.init, d = b.test, e = b.update, f = b.body; + b.ForStatement = function(a) { + var b = a.init, d = a.test, e = a.update, f = a.body; if (this.syntax.ForStatement) { - throw {message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; + throw {message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; } - var f = this[f.type](f), a = a.declarations[0].init.value, g = d.operator, d = d.right.value, h = 0; - "++" != e.operator && (e = a, a = d, d = e); + var f = this[f.type](f), b = b.declarations[0].init.value, g = d.operator, d = d.right.value, h = 0; + "++" != e.operator && (e = b, b = d, d = e); switch(g) { case "<": - h = d - a; + h = d - b; break; case "<=": - h = d + 1 - a; + h = d + 1 - b; break; case ">": - h = a - d; + h = b - d; break; case ">=": - h = a + 1 - d; + h = b + 1 - d; } - return this.BasicIteration(b, h, f); + return this.BasicIteration(a, h, f); }; - a.BlockStatement = function(b) { - var a = []; - b = b.body; - for (var d = 0;d < b.length;d++) { - var e = b[d], f = this[e.type](e); + b.BlockStatement = function(a) { + var b = []; + a = a.body; + for (var d = 0;d < a.length;d++) { + var e = a[d], f = this[e.type](e); if (f) { if (void 0 === f.type) { throw {message:"\ud574\ub2f9\ud558\ub294 \ube14\ub85d\uc774 \uc5c6\uc2b5\ub2c8\ub2e4.", node:e}; } - f && a.push(f); + f && b.push(f); } } - return a; + return b; }; - a.EmptyStatement = function(b) { - throw {message:"empty\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; + b.EmptyStatement = function(a) { + throw {message:"empty\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; }; - a.DebuggerStatement = function(b) { - throw {message:"debugger\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; + b.DebuggerStatement = function(a) { + throw {message:"debugger\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; }; - a.WithStatement = function(b) { - throw {message:"with\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; + b.WithStatement = function(a) { + throw {message:"with\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; }; - a.ReturnStaement = function(b) { - throw {message:"return\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; + b.ReturnStaement = function(a) { + throw {message:"return\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; }; - a.LabeledStatement = function(b) { - throw {message:"label\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; + b.LabeledStatement = function(a) { + throw {message:"label\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; }; - a.BreakStatement = function(b) { - throw {message:"break\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; + b.BreakStatement = function(a) { + throw {message:"break\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; }; - a.ContinueStatement = function(b) { - throw {message:"continue\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; + b.ContinueStatement = function(a) { + throw {message:"continue\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; }; - a.IfStatement = function(b) { + b.IfStatement = function(a) { if (this.syntax.IfStatement) { - throw {message:"if\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; + throw {message:"if\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; } - return this.BasicIf(b); + return this.BasicIf(a); }; - a.SwitchStatement = function(b) { - throw {message:"switch\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; + b.SwitchStatement = function(a) { + throw {message:"switch\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; }; - a.SwitchCase = function(b) { - throw {message:"switch ~ case\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; + b.SwitchCase = function(a) { + throw {message:"switch ~ case\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; }; - a.ThrowStatement = function(b) { - throw {message:"throw\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; + b.ThrowStatement = function(a) { + throw {message:"throw\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; }; - a.TryStatement = function(b) { - throw {message:"try\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; + b.TryStatement = function(a) { + throw {message:"try\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; }; - a.CatchClause = function(b) { - throw {message:"catch\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; + b.CatchClause = function(a) { + throw {message:"catch\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; }; - a.WhileStatement = function(b) { - var a = b.body, d = this.syntax.WhileStatement, a = this[a.type](a); + b.WhileStatement = function(a) { + var b = a.body, d = this.syntax.WhileStatement, b = this[b.type](b); if (d) { - throw {message:"while\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; + throw {message:"while\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; } - return this.BasicWhile(b, a); + return this.BasicWhile(a, b); }; - a.DoWhileStatement = function(b) { - throw {message:"do ~ while\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; + b.DoWhileStatement = function(a) { + throw {message:"do ~ while\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; }; - a.ForInStatement = function(b) { - throw {message:"for ~ in\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; + b.ForInStatement = function(a) { + throw {message:"for ~ in\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; }; - a.FunctionDeclaration = function(b) { + b.FunctionDeclaration = function(a) { if (this.syntax.FunctionDeclaration) { - throw {message:"function\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; + throw {message:"function\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; } return null; }; - a.VariableDeclaration = function(b) { - throw {message:"var\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; + b.VariableDeclaration = function(a) { + throw {message:"var\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; }; - a.ThisExpression = function(b) { + b.ThisExpression = function(a) { return this.scope.this; }; - a.ArrayExpression = function(b) { - throw {message:"array\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; + b.ArrayExpression = function(a) { + throw {message:"array\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; }; - a.ObjectExpression = function(b) { - throw {message:"object\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; + b.ObjectExpression = function(a) { + throw {message:"object\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; }; - a.Property = function(b) { - throw {message:"init, get, set\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; + b.Property = function(a) { + throw {message:"init, get, set\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; }; - a.FunctionExpression = function(b) { - throw {message:"function\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; + b.FunctionExpression = function(a) { + throw {message:"function\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; }; - a.UnaryExpression = function(b) { - throw {message:b.operator + "\uc740(\ub294) \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \uba85\ub839\uc5b4 \uc785\ub2c8\ub2e4.", node:b}; + b.UnaryExpression = function(a) { + throw {message:a.operator + "\uc740(\ub294) \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \uba85\ub839\uc5b4 \uc785\ub2c8\ub2e4.", node:a}; }; - a.UnaryOperator = function() { + b.UnaryOperator = function() { return "- + ! ~ typeof void delete".split(" "); }; - a.updateOperator = function() { + b.updateOperator = function() { return ["++", "--"]; }; - a.BinaryOperator = function() { + b.BinaryOperator = function() { return "== != === !== < <= > >= << >> >>> + - * / % , ^ & in instanceof".split(" "); }; - a.AssignmentExpression = function(b) { - throw {message:b.operator + "\uc740(\ub294) \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \uba85\ub839\uc5b4 \uc785\ub2c8\ub2e4.", node:b}; + b.AssignmentExpression = function(a) { + throw {message:a.operator + "\uc740(\ub294) \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \uba85\ub839\uc5b4 \uc785\ub2c8\ub2e4.", node:a}; }; - a.AssignmentOperator = function() { + b.AssignmentOperator = function() { return "= += -= *= /= %= <<= >>= >>>= ,= ^= &=".split(" "); }; - a.LogicalExpression = function(b) { - throw {message:b.operator + "\uc740(\ub294) \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \uba85\ub839\uc5b4 \uc785\ub2c8\ub2e4.", node:b}; + b.LogicalExpression = function(a) { + throw {message:a.operator + "\uc740(\ub294) \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \uba85\ub839\uc5b4 \uc785\ub2c8\ub2e4.", node:a}; }; - a.LogicalOperator = function() { + b.LogicalOperator = function() { return ["||", "&&"]; }; - a.MemberExpression = function(b) { - var a = b.object, d = b.property; - console.log(a.type); - a = this[a.type](a); - console.log(a); - d = this[d.type](d, a); - if (Object(a) !== a || Object.getPrototypeOf(a) !== Object.prototype) { - throw {message:a + "\uc740(\ub294) \uc798\ubabb\ub41c \uba64\ubc84 \ubcc0\uc218\uc785\ub2c8\ub2e4.", node:b}; + b.MemberExpression = function(a) { + var b = a.object, d = a.property; + console.log(b.type); + b = this[b.type](b); + console.log(b); + d = this[d.type](d, b); + if (Object(b) !== b || Object.getPrototypeOf(b) !== Object.prototype) { + throw {message:b + "\uc740(\ub294) \uc798\ubabb\ub41c \uba64\ubc84 \ubcc0\uc218\uc785\ub2c8\ub2e4.", node:a}; } - a = d; - if (!a) { - throw {message:d + "\uc774(\uac00) \uc874\uc7ac\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.", node:b}; + b = d; + if (!b) { + throw {message:d + "\uc774(\uac00) \uc874\uc7ac\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.", node:a}; } - return a; + return b; }; - a.ConditionalExpression = function(b) { - throw {message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; + b.ConditionalExpression = function(a) { + throw {message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; }; - a.UpdateExpression = function(b) { - throw {message:b.operator + "\uc740(\ub294) \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \uba85\ub801\uc5b4 \uc785\ub2c8\ub2e4.", node:b}; + b.UpdateExpression = function(a) { + throw {message:a.operator + "\uc740(\ub294) \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \uba85\ub801\uc5b4 \uc785\ub2c8\ub2e4.", node:a}; }; - a.CallExpression = function(b) { - b = b.callee; - return {type:this[b.type](b)}; + b.CallExpression = function(a) { + a = a.callee; + return {type:this[a.type](a)}; }; - a.NewExpression = function(b) { - throw {message:"new\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; + b.NewExpression = function(a) { + throw {message:"new\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; }; - a.SequenceExpression = function(b) { - throw {message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; + b.SequenceExpression = function(a) { + throw {message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; }; - a.initScope = function(b) { + b.initScope = function(a) { if (null === this.scope) { - var a = function() { + var b = function() { }; - a.prototype = this.syntax.Scope; + b.prototype = this.syntax.Scope; } else { - a = function() { - }, a.prototype = this.scope; + b = function() { + }, b.prototype = this.scope; } - this.scope = new a; + this.scope = new b; this.scopeChain.push(this.scope); - return this.scanDefinition(b); + return this.scanDefinition(a); }; - a.unloadScope = function() { + b.unloadScope = function() { this.scopeChain.pop(); this.scope = this.scopeChain.length ? this.scopeChain[this.scopeChain.length - 1] : null; }; - a.scanDefinition = function(b) { - b = b.body; - for (var a = [], d = 0;d < b.length;d++) { - var e = b[d]; - "FunctionDeclaration" === e.type && (this.scope[e.id.name] = this.scope.promise, this.syntax.BasicFunction && (e = e.body, a.push([{type:this.syntax.BasicFunction, statements:[this[e.type](e)]}]))); - } - return a; + b.scanDefinition = function(a) { + a = a.body; + for (var b = [], d = 0;d < a.length;d++) { + var e = a[d]; + "FunctionDeclaration" === e.type && (this.scope[e.id.name] = this.scope.promise, this.syntax.BasicFunction && (e = e.body, b.push([{type:this.syntax.BasicFunction, statements:[this[e.type](e)]}]))); + } + return b; + }; + b.BasicFunction = function(a, b) { + return null; + }; + b.BasicIteration = function(a, b, d) { + var e = this.syntax.BasicIteration; + if (!e) { + throw {message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; + } + return {params:[b], type:e, statements:[d]}; + }; + b.BasicWhile = function(a, b) { + var d = a.test.raw; + if (this.syntax.BasicWhile[d]) { + return {type:this.syntax.BasicWhile[d], statements:[b]}; + } + throw {message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a.test}; + }; + b.BasicIf = function(a) { + var b = a.consequent, b = this[b.type](b); + try { + var d = "", e = "===" === a.test.operator ? "==" : a.test.operator; + if ("Identifier" === a.test.left.type && "Literal" === a.test.right.type) { + d = a.test.left.name + " " + e + " " + a.test.right.raw; + } else { + if ("Literal" === a.test.left.type && "Identifier" === a.test.right.type) { + d = a.test.right.name + " " + e + " " + a.test.left.raw; + } else { + throw Error(); + } + } + if (this.syntax.BasicIf[d]) { + return Array.isArray(b) || "object" !== typeof b || (b = [b]), {type:this.syntax.BasicIf[d], statements:[b]}; + } + throw Error(); + } catch (f) { + throw {message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a.test}; + } + }; +})(Entry.JSParser.prototype); +Entry.Parser = function(b, a, c) { + this._mode = b; + this.syntax = {}; + this.codeMirror = c; + this._lang = a || "js"; + this.availableCode = []; + "maze" === b && (this._stageId = +Ntry.configManager.getConfig("stageId"), "object" == typeof NtryData && this.setAvailableCode(NtryData.config[this._stageId].availableCode, NtryData.player[this._stageId].code)); + this.mappingSyntax(b); + switch(this._lang) { + case "js": + this._parser = new Entry.JSParser(this.syntax); + a = this.syntax; + var d = {}, e; + for (e in a.Scope) { + d[e + "();\n"] = a.Scope[e]; + } + "BasicIf" in a && (d.front = "BasicIf"); + CodeMirror.commands.javascriptComplete = function(a) { + CodeMirror.showHint(a, null, {globalScope:d}); + }; + c.on("keyup", function(a, b) { + !a.state.completionActive && 65 <= b.keyCode && 95 >= b.keyCode && CodeMirror.showHint(a, null, {completeSingle:!1, globalScope:d}); + }); + break; + case "block": + this._parser = new Entry.BlockParser(this.syntax); + } +}; +(function(b) { + b.parse = function(a) { + var b = null; + switch(this._lang) { + case "js": + try { + var d = acorn.parse(a), b = this._parser.Program(d); + } catch (e) { + this.codeMirror && (e instanceof SyntaxError ? (a = {from:{line:e.loc.line - 1, ch:e.loc.column - 2}, to:{line:e.loc.line - 1, ch:e.loc.column + 1}}, e.message = "\ubb38\ubc95 \uc624\ub958\uc785\ub2c8\ub2e4.") : (a = this.getLineNumber(e.node.start, e.node.end), a.message = e.message, a.severity = "error", this.codeMirror.markText(a.from, a.to, {className:"CodeMirror-lint-mark-error", __annotation:a, clearOnEnter:!0})), Entry.toast.alert("Error", e.message)), b = []; + } + break; + case "block": + a = this._parser.Code(a).match(/(.*{.*[\S|\s]+?}|.+)/g), b = Array.isArray(a) ? a.reduce(function(a, b, c) { + var d = ""; + 1 === c && (a += "\n"); + d = -1 < b.indexOf("function") ? b + a : a + b; + return d + "\n"; + }) : ""; + } + return b; + }; + b.getLineNumber = function(a, b) { + var d = this.codeMirror.getValue(), e = {from:{}, to:{}}, f = d.substring(0, a).split(/\n/gi); + e.from.line = f.length - 1; + e.from.ch = f[f.length - 1].length; + d = d.substring(0, b).split(/\n/gi); + e.to.line = d.length - 1; + e.to.ch = d[d.length - 1].length; + return e; + }; + b.mappingSyntax = function(a) { + for (var b = Object.keys(Entry.block), d = 0;d < b.length;d++) { + var e = b[d], f = Entry.block[e]; + if (f.mode === a && -1 < this.availableCode.indexOf(e) && (f = f.syntax)) { + for (var g = this.syntax, h = 0;h < f.length;h++) { + var k = f[h]; + if (h === f.length - 2 && "function" === typeof f[h + 1]) { + g[k] = f[h + 1]; + break; + } + g[k] || (g[k] = {}); + h === f.length - 1 ? g[k] = e : g = g[k]; + } + } + } + }; + b.setAvailableCode = function(a, b) { + var d = []; + a.forEach(function(a, b) { + a.forEach(function(a, b) { + d.push(a.type); + }); + }); + b instanceof Entry.Code ? b.getBlockList().forEach(function(a) { + a.type !== NtryData.START && -1 === d.indexOf(a.type) && d.push(a.type); + }) : b.forEach(function(a, b) { + a.forEach(function(a, b) { + a.type !== NtryData.START && -1 === d.indexOf(a.type) && d.push(a.type); + }); + }); + this.availableCode = this.availableCode.concat(d); + }; +})(Entry.Parser.prototype); +Entry.Pdf = function(b) { + this.generateView(b); +}; +p = Entry.Pdf.prototype; +p.generateView = function(b) { + var a = Entry.createElement("div", "entryPdfWorkspace"); + a.addClass("entryRemove"); + this._view = a; + var c = "/pdfjs/web/viewer.html"; + b && "" != b && (c += "?file=" + b); + pdfViewIframe = Entry.createElement("iframe", "entryPdfIframeWorkspace"); + pdfViewIframe.setAttribute("id", "pdfViewIframe"); + pdfViewIframe.setAttribute("frameborder", 0); + pdfViewIframe.setAttribute("src", c); + a.appendChild(pdfViewIframe); +}; +p.getView = function() { + return this._view; +}; +p.resize = function() { + var b = document.getElementById("entryContainerWorkspaceId"), a = document.getElementById("pdfViewIframe"); + w = b.offsetWidth; + a.width = w + "px"; + a.height = 9 * w / 16 + "px"; +}; +Entry.Popup = function() { + Entry.assert(!window.popup, "Popup exist"); + this.body_ = Entry.createElement("div"); + this.body_.addClass("entryPopup"); + this.body_.bindOnClick(function(b) { + b.target == this && this.popup.remove(); + }); + this.body_.popup = this; + document.body.appendChild(this.body_); + this.window_ = Entry.createElement("div"); + this.window_.addClass("entryPopupWindow"); + this.window_.bindOnClick(function() { + }); + Entry.addEventListener("windowResized", this.resize); + window.popup = this; + this.resize(); + this.body_.appendChild(this.window_); +}; +Entry.Popup.prototype.remove = function() { + for (;this.window_.hasChildNodes();) { + "workspace" == Entry.type ? Entry.view_.insertBefore(this.window_.firstChild, Entry.container.view_) : Entry.view_.insertBefore(this.window_.lastChild, Entry.view_.firstChild); + } + $("body").css("overflow", "auto"); + Entry.removeElement(this.body_); + window.popup = null; + Entry.removeEventListener("windowResized", this.resize); + Entry.engine.popup = null; +}; +Entry.Popup.prototype.resize = function(b) { + b = window.popup.window_; + var a = .9 * window.innerWidth, c = .9 * window.innerHeight - 35; + 9 * a <= 16 * c ? c = a / 16 * 9 : a = 16 * c / 9; + b.style.width = String(a) + "px"; + b.style.height = String(c + 35) + "px"; +}; +Entry.popupHelper = function(b) { + this.popupList = {}; + this.nowContent; + b && (window.popupHelper = null); + Entry.assert(!window.popupHelper, "Popup exist"); + var a = ["confirm", "spinner"], c = ["entryPopupHelperTopSpan", "entryPopupHelperBottomSpan", "entryPopupHelperLeftSpan", "entryPopupHelperRightSpan"]; + this.body_ = Entry.Dom("div", {classes:["entryPopup", "hiddenPopup", "popupHelper"]}); + var d = this; + this.body_.bindOnClick(function(b) { + if (!(d.nowContent && -1 < a.indexOf(d.nowContent.prop("type")))) { + var f = $(b.target); + c.forEach(function(a) { + f.hasClass(a) && this.popup.hide(); + }.bind(this)); + b.target == this && this.popup.hide(); + } + }); + window.popupHelper = this; + this.body_.prop("popup", this); + Entry.Dom("div", {class:"entryPopupHelperTopSpan", parent:this.body_}); + b = Entry.Dom("div", {class:"entryPopupHelperMiddleSpan", parent:this.body_}); + Entry.Dom("div", {class:"entryPopupHelperBottomSpan", parent:this.body_}); + Entry.Dom("div", {class:"entryPopupHelperLeftSpan", parent:b}); + this.window_ = Entry.Dom("div", {class:"entryPopupHelperWindow", parent:b}); + Entry.Dom("div", {class:"entryPopupHelperRightSpan", parent:b}); + $("body").append(this.body_); +}; +Entry.popupHelper.prototype.clearPopup = function() { + for (var b = this.popupWrapper_.children.length - 1;2 < b;b--) { + this.popupWrapper_.removeChild(this.popupWrapper_.children[b]); + } +}; +Entry.popupHelper.prototype.addPopup = function(b, a) { + var c = Entry.Dom("div"), d = Entry.Dom("div", {class:"entryPopupHelperCloseButton"}); + d.bindOnClick(function() { + a.closeEvent ? a.closeEvent(this) : this.hide(); + }.bind(this)); + var e = Entry.Dom("div", {class:"entryPopupHelperWrapper"}); + e.append(d); + a.title && (d = Entry.Dom("div", {class:"entryPopupHelperTitle"}), e.append(d), d.text(a.title)); + c.addClass(b); + c.append(e); + c.popupWrapper_ = e; + c.prop("type", a.type); + "function" === typeof a.setPopupLayout && a.setPopupLayout(c); + this.popupList[b] = c; +}; +Entry.popupHelper.prototype.hasPopup = function(b) { + return !!this.popupList[b]; +}; +Entry.popupHelper.prototype.setPopup = function(b) { +}; +Entry.popupHelper.prototype.remove = function(b) { + 0 < this.window_.children().length && this.window_.children().remove(); + this.window_.remove(); + delete this.popupList[b]; + this.nowContent = void 0; + this.body_.addClass("hiddenPopup"); +}; +Entry.popupHelper.prototype.resize = function(b) { +}; +Entry.popupHelper.prototype.show = function(b) { + 0 < this.window_.children().length && this.window_.children().detach(); + this.window_.append(this.popupList[b]); + this.nowContent = this.popupList[b]; + this.body_.removeClass("hiddenPopup"); +}; +Entry.popupHelper.prototype.hide = function() { + this.nowContent = void 0; + this.body_.addClass("hiddenPopup"); +}; +Entry.getStartProject = function(b) { + return {category:"\uae30\ud0c0", scenes:[{name:"\uc7a5\uba74 1", id:"7dwq"}], variables:[{name:"\ucd08\uc2dc\uacc4", id:"brih", visible:!1, value:"0", variableType:"timer", x:150, y:-70, array:[], object:null, isCloud:!1}, {name:"\ub300\ub2f5", id:"1vu8", visible:!1, value:"0", variableType:"answer", x:150, y:-100, array:[], object:null, isCloud:!1}], objects:[{id:"7y0y", name:"\uc5d4\ud2b8\ub9ac\ubd07", script:[[{type:"when_run_button_click", x:40, y:50}, {type:"repeat_basic", statements:[[{type:"move_direction"}]]}]], + selectedPictureId:"vx80", objectType:"sprite", rotateMethod:"free", scene:"7dwq", sprite:{sounds:[{duration:1.3, ext:".mp3", id:"8el5", fileurl:b + "media/bark.mp3", name:"\uac15\uc544\uc9c0 \uc9d6\ub294\uc18c\ub9ac"}], pictures:[{id:"vx80", fileurl:b + "media/entrybot1.png", name:Lang.Blocks.walking_entryBot + "1", scale:100, dimension:{width:284, height:350}}, {id:"4t48", fileurl:b + "media/entrybot2.png", name:Lang.Blocks.walking_entryBot + "2", scale:100, dimension:{width:284, height:350}}]}, + entity:{x:0, y:0, regX:142, regY:175, scaleX:.3154574132492113, scaleY:.3154574132492113, rotation:0, direction:90, width:284, height:350, visible:!0}, lock:!1, active:!0}], speed:60}; +}; +Entry.PropertyPanel = function() { + this.modes = {}; + this.selected = null; +}; +(function(b) { + b.generateView = function(a, b) { + this._view = Entry.Dom("div", {class:"propertyPanel", parent:$(a)}); + this._tabView = Entry.Dom("div", {class:"propertyTab", parent:this._view}); + this._contentView = Entry.Dom("div", {class:"propertyContent", parent:this._view}); + this._cover = Entry.Dom("div", {classes:["propertyPanelCover", "entryRemove"], parent:this._view}); + var d = Entry.Dom("div", {class:"entryObjectSelectedImgWorkspace", parent:this._view}); + this.initializeSplitter(d); + }; + b.addMode = function(a, b) { + var d = b.getView(), d = Entry.Dom(d, {parent:this._contentView}), e = Entry.Dom("
" + Lang.Menus[a] + "
", {classes:["propertyTabElement", "propertyTab" + a], parent:this._tabView}), f = this; + e.bind("click", function() { + f.select(a); + }); + this.modes[a] && (this.modes[a].tabDom.remove(), this.modes[a].contentDom.remove(), "hw" == a && ($(this.modes).removeClass(".propertyTabhw"), $(".propertyTabhw").unbind("dblclick"))); + this.modes[a] = {obj:b, tabDom:e, contentDom:d}; + "hw" == a && $(".propertyTabhw").bind("dblclick", function() { + Entry.dispatchEvent("hwModeChange"); + }); + }; + b.resize = function(a) { + this._view.css({width:a + "px", top:9 * a / 16 + 123 - 22 + "px"}); + 430 <= a ? this._view.removeClass("collapsed") : this._view.addClass("collapsed"); + Entry.dispatchEvent("windowResized"); + a = this.selected; + "hw" == a ? this.modes.hw.obj.listPorts ? this.modes[a].obj.resizeList() : this.modes[a].obj.resize() : this.modes[a].obj.resize(); + }; + b.select = function(a) { + for (var b in this.modes) { + var d = this.modes[b]; + d.tabDom.removeClass("selected"); + d.contentDom.addClass("entryRemove"); + d.obj.visible = !1; + } + b = this.modes[a]; + b.tabDom.addClass("selected"); + b.contentDom.removeClass("entryRemove"); + b.obj.resize && b.obj.resize(); + b.obj.visible = !0; + this.selected = a; + }; + b.initializeSplitter = function(a) { + var b = this; + a.bind("mousedown touchstart", function(a) { + b._cover.removeClass("entryRemove"); + Entry.container.disableSort(); + Entry.container.splitterEnable = !0; + Entry.documentMousemove && (Entry.container.resizeEvent = Entry.documentMousemove.attach(this, function(a) { + Entry.container.splitterEnable && Entry.resizeElement({canvasWidth:a.clientX || a.x}); + })); + }); + $(document).bind("mouseup touchend", function(a) { + if (a = Entry.container.resizeEvent) { + Entry.container.splitterEnable = !1, Entry.documentMousemove.detach(a), b._cover.addClass("entryRemove"), delete Entry.container.resizeEvent; + } + Entry.container.enableSort(); + }); + }; +})(Entry.PropertyPanel.prototype); +Entry.init = function(b, a) { + Entry.assert("object" === typeof a, "Init option is not object"); + this.events_ = {}; + this.interfaceState = {menuWidth:264}; + Entry.Utils.bindGlobalEvent("resize mousedown mousemove keydown keyup dispose".split(" ")); + this.options = a; + this.parseOptions(a); + this.mediaFilePath = (a.libDir ? a.libDir : "/lib") + "/entryjs/images/"; + this.defaultPath = a.defaultDir || ""; + this.blockInjectPath = a.blockInjectDir || ""; + "workspace" == this.type && this.isPhone() && (this.type = "phone"); + this.initialize_(); + this.view_ = b; + this.view_.setAttribute("class", "entry"); + Entry.initFonts(a.fonts); + this.createDom(b, this.type); + this.loadInterfaceState(); + this.overridePrototype(); + this.maxCloneLimit = 302; + this.cloudSavable = !0; + this.startTime = (new Date).getTime(); + document.onkeydown = function(a) { + Entry.dispatchEvent("keyPressed", a); }; - a.BasicFunction = function(b, a) { - return null; + document.onkeyup = function(a) { + Entry.dispatchEvent("keyUpped", a); }; - a.BasicIteration = function(b, a, d) { - var e = this.syntax.BasicIteration; - if (!e) { - throw {message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; - } - return {params:[a], type:e, statements:[d]}; + window.onresize = function(a) { + Entry.dispatchEvent("windowResized", a); }; - a.BasicWhile = function(b, a) { - var d = b.test.raw; - if (this.syntax.BasicWhile[d]) { - return {type:this.syntax.BasicWhile[d], statements:[a]}; + window.onbeforeunload = this.beforeUnload; + Entry.addEventListener("saveWorkspace", function(a) { + Entry.addActivity("save"); + }); + "IE" != Entry.getBrowserType().substr(0, 2) || window.flashaudio ? createjs.Sound.registerPlugins([createjs.WebAudioPlugin]) : (createjs.FlashAudioPlugin.swfPath = this.mediaFilePath + "media/", createjs.Sound.registerPlugins([createjs.FlashAudioPlugin]), window.flashaudio = !0); + Entry.soundQueue = new createjs.LoadQueue; + Entry.soundQueue.installPlugin(createjs.Sound); + Entry.loadAudio_([Entry.mediaFilePath + "sounds/click.mp3", Entry.mediaFilePath + "sounds/click.wav", Entry.mediaFilePath + "sounds/click.ogg"], "entryMagneting"); + Entry.loadAudio_([Entry.mediaFilePath + "sounds/delete.mp3", Entry.mediaFilePath + "sounds/delete.ogg", Entry.mediaFilePath + "sounds/delete.wav"], "entryDelete"); + createjs.Sound.stop(); +}; +Entry.loadAudio_ = function(b, a) { + if (window.Audio && b.length) { + for (;0 < b.length;) { + var c = b[0]; + c.match(/\/([^.]+)./); + Entry.soundQueue.loadFile({id:a, src:c, type:createjs.LoadQueue.SOUND}); + break; } - throw {message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b.test}; - }; - a.BasicIf = function(b) { - var a = b.consequent, a = this[a.type](a); - try { - var d = "", e = "===" === b.test.operator ? "==" : b.test.operator; - if ("Identifier" === b.test.left.type && "Literal" === b.test.right.type) { - d = b.test.left.name + " " + e + " " + b.test.right.raw; - } else { - if ("Literal" === b.test.left.type && "Identifier" === b.test.right.type) { - d = b.test.right.name + " " + e + " " + b.test.left.raw; - } else { - throw Error(); - } - } - if (this.syntax.BasicIf[d]) { - return Array.isArray(a) || "object" !== typeof a || (a = [a]), {type:this.syntax.BasicIf[d], statements:[a]}; - } - throw Error(); - } catch (f) { - throw {message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b.test}; + } +}; +Entry.initialize_ = function() { + this.stage = new Entry.Stage; + Entry.engine && Entry.engine.clearTimer(); + this.engine = new Entry.Engine; + this.propertyPanel = new Entry.PropertyPanel; + this.container = new Entry.Container; + this.helper = new Entry.Helper; + this.youtube = new Entry.Youtube; + this.variableContainer = new Entry.VariableContainer; + this.commander = new Entry.Commander(this.type); + this.scene = new Entry.Scene; + this.playground = new Entry.Playground; + this.toast = new Entry.Toast; + this.hw && this.hw.closeConnection(); + this.hw = new Entry.HW; + if (Entry.enableActivityLogging) { + this.reporter = new Entry.Reporter(!1); + } else { + if ("workspace" == this.type || "phone" == this.type) { + this.reporter = new Entry.Reporter(!0); } - }; -})(Entry.JSParser.prototype); -Entry.Parser = function(a, b, c) { - this._mode = a; - this.syntax = {}; - this.codeMirror = c; - this._lang = b || "js"; - this.availableCode = []; - "maze" === a && (this._stageId = Number(Ntry.configManager.getConfig("stageId")), "object" == typeof NtryData && this.setAvailableCode(NtryData.config[this._stageId].availableCode, NtryData.player[this._stageId].code)); - this.mappingSyntax(a); - switch(this._lang) { - case "js": - this._parser = new Entry.JSParser(this.syntax); - b = this.syntax; - var d = {}, e; - for (e in b.Scope) { - d[e + "();\n"] = b.Scope[e]; + } +}; +Entry.createDom = function(b, a) { + if (a && "workspace" != a) { + "minimize" == a ? (c = Entry.createElement("canvas"), c.className = "entryCanvasWorkspace", c.id = "entryCanvas", c.width = 640, c.height = 360, d = Entry.createElement("div", "entryCanvasWrapper"), d.appendChild(c), b.appendChild(d), this.canvas_ = c, this.stage.initStage(this.canvas_), d = Entry.createElement("div"), b.appendChild(d), this.engineView = d, this.engine.generateView(this.engineView, a)) : "phone" == a && (this.stateManagerView = c = Entry.createElement("div"), this.stateManager.generateView(this.stateManagerView, + a), d = Entry.createElement("div"), b.appendChild(d), this.engineView = d, this.engine.generateView(this.engineView, a), c = Entry.createElement("canvas"), c.addClass("entryCanvasPhone"), c.id = "entryCanvas", c.width = 640, c.height = 360, d.insertBefore(c, this.engine.footerView_), this.canvas_ = c, this.stage.initStage(this.canvas_), c = Entry.createElement("div"), b.appendChild(c), this.containerView = c, this.container.generateView(this.containerView, a), c = Entry.createElement("div"), + b.appendChild(c), this.playgroundView = c, this.playground.generateView(this.playgroundView, a)); + } else { + Entry.documentMousedown.attach(this, this.cancelObjectEdit); + var c = Entry.createElement("div"); + b.appendChild(c); + this.sceneView = c; + this.scene.generateView(this.sceneView, a); + c = Entry.createElement("div"); + this.sceneView.appendChild(c); + this.stateManagerView = c; + this.stateManager.generateView(this.stateManagerView, a); + var d = Entry.createElement("div"); + b.appendChild(d); + this.engineView = d; + this.engine.generateView(this.engineView, a); + c = Entry.createElement("canvas"); + c.addClass("entryCanvasWorkspace"); + c.id = "entryCanvas"; + c.width = 640; + c.height = 360; + d.insertBefore(c, this.engine.addButton); + c.addEventListener("mousewheel", function(a) { + var b = Entry.variableContainer.getListById(Entry.stage.mouseCoordinate); + a = 0 < a.wheelDelta ? !0 : !1; + for (var c = 0;c < b.length;c++) { + var d = b[c]; + d.scrollButton_.y = a ? 46 <= d.scrollButton_.y ? d.scrollButton_.y - 23 : 23 : d.scrollButton_.y + 23; + d.updateView(); } - "BasicIf" in b && (d.front = "BasicIf"); - CodeMirror.commands.javascriptComplete = function(b) { - CodeMirror.showHint(b, null, {globalScope:d}); - }; - c.on("keyup", function(b, a) { - !b.state.completionActive && 65 <= a.keyCode && 95 >= a.keyCode && CodeMirror.showHint(b, null, {completeSingle:!1, globalScope:d}); - }); - break; - case "block": - this._parser = new Entry.BlockParser(this.syntax); + }); + this.canvas_ = c; + this.stage.initStage(this.canvas_); + c = Entry.createElement("div"); + this.propertyPanel.generateView(b, a); + this.containerView = c; + this.container.generateView(this.containerView, a); + this.propertyPanel.addMode("object", this.container); + this.helper.generateView(this.containerView, a); + this.propertyPanel.addMode("helper", this.helper); + c = Entry.createElement("div"); + b.appendChild(c); + this.playgroundView = c; + this.playground.generateView(this.playgroundView, a); + this.propertyPanel.select("object"); + this.helper.bindWorkspace(this.playground.mainWorkspace); } }; -(function(a) { - a.parse = function(b) { - var a = null; - switch(this._lang) { - case "js": - try { - var d = acorn.parse(b), a = this._parser.Program(d); - } catch (e) { - this.codeMirror && (e instanceof SyntaxError ? (b = {from:{line:e.loc.line - 1, ch:e.loc.column - 2}, to:{line:e.loc.line - 1, ch:e.loc.column + 1}}, e.message = "\ubb38\ubc95 \uc624\ub958\uc785\ub2c8\ub2e4.") : (b = this.getLineNumber(e.node.start, e.node.end), b.message = e.message, b.severity = "error", this.codeMirror.markText(b.from, b.to, {className:"CodeMirror-lint-mark-error", __annotation:b, clearOnEnter:!0})), Entry.toast.alert("Error", e.message)), a = []; - } - break; - case "block": - b = this._parser.Code(b).match(/(.*{.*[\S|\s]+?}|.+)/g), a = Array.isArray(b) ? b.reduce(function(b, a, c) { - 1 === c && (b += "\n"); - return (-1 < a.indexOf("function") ? a + b : b + a) + "\n"; - }) : ""; +Entry.start = function(b) { + this.FPS || (this.FPS = 60); + Entry.assert("number" == typeof this.FPS, "FPS must be number"); + Entry.engine.start(this.FPS); +}; +Entry.parseOptions = function(b) { + this.type = b.type; + this.projectSaveable = b.projectsaveable; + void 0 === this.projectSaveable && (this.projectSaveable = !0); + this.objectAddable = b.objectaddable; + void 0 === this.objectAddable && (this.objectAddable = !0); + this.objectEditable = b.objectEditable; + void 0 === this.objectEditable && (this.objectEditable = !0); + this.objectEditable || (this.objectAddable = !1); + this.objectDeletable = b.objectdeletable; + void 0 === this.objectDeletable && (this.objectDeletable = !0); + this.soundEditable = b.soundeditable; + void 0 === this.soundEditable && (this.soundEditable = !0); + this.pictureEditable = b.pictureeditable; + void 0 === this.pictureEditable && (this.pictureEditable = !0); + this.sceneEditable = b.sceneEditable; + void 0 === this.sceneEditable && (this.sceneEditable = !0); + this.functionEnable = b.functionEnable; + void 0 === this.functionEnable && (this.functionEnable = !0); + this.messageEnable = b.messageEnable; + void 0 === this.messageEnable && (this.messageEnable = !0); + this.variableEnable = b.variableEnable; + void 0 === this.variableEnable && (this.variableEnable = !0); + this.listEnable = b.listEnable; + void 0 === this.listEnable && (this.listEnable = !0); + this.hasVariableManager = b.hasvariablemanager; + this.variableEnable || this.messageEnable || this.listEnable || this.functionEnable ? void 0 === this.hasVariableManager && (this.hasVariableManager = !0) : this.hasVariableManager = !1; + this.isForLecture = b.isForLecture; +}; +Entry.initFonts = function(b) { + this.fonts = b; + b || (this.fonts = []); +}; +Entry.Reporter = function(b) { + this.projectId = this.userId = null; + this.isRealTime = b; + this.activities = []; +}; +Entry.Reporter.prototype.start = function(b, a, c) { + this.isRealTime && (-1 < window.location.href.indexOf("localhost") ? this.io = io("localhost:7000") : this.io = io("play04.play-entry.com:7000"), this.io.emit("activity", {message:"start", userId:a, projectId:b, time:c})); + this.userId = a; + this.projectId = b; +}; +Entry.Reporter.prototype.report = function(b) { + if (!this.isRealTime || this.io) { + var a = [], c; + for (c in b.params) { + var d = b.params[c]; + "object" !== typeof d ? a.push(d) : d.id && a.push(d.id); } - return a; + b = {message:b.message, userId:this.userId, projectId:this.projectId, time:b.time, params:a}; + this.isRealTime ? this.io.emit("activity", b) : this.activities.push(b); + } +}; +Entry.Scene = function() { + var b = this; + this.scenes_ = []; + this.selectedScene = null; + this.maxCount = 20; + $(window).on("resize", function(a) { + b.resize(); + }); +}; +Entry.Scene.viewBasicWidth = 70; +Entry.Scene.prototype.generateView = function(b, a) { + var c = this; + this.view_ = b; + this.view_.addClass("entryScene"); + if (!a || "workspace" == a) { + this.view_.addClass("entrySceneWorkspace"); + $(this.view_).on("mousedown", function(a) { + var b = $(this).offset(), d = $(window), h = a.pageX - b.left + d.scrollLeft(); + a = a.pageY - b.top + d.scrollTop(); + a = 40 - a; + b = -40 / 55; + d = $(c.selectedScene.view).find(".entrySceneRemoveButtonCoverWorkspace").offset().left; + !(h < d || h > d + 55) && a > 40 + b * (h - d) && (h = c.getNextScene()) && (h = $(h.view), $(document).trigger("mouseup"), h.trigger("mousedown")); + }); + var d = Entry.createElement("ul"); + d.addClass("entrySceneListWorkspace"); + Entry.sceneEditable && $ && $(d).sortable({start:function(a, b) { + b.item.data("start_pos", b.item.index()); + $(b.item[0]).clone(!0); + }, stop:function(a, b) { + var c = b.item.data("start_pos"), d = b.item.index(); + Entry.scene.moveScene(c, d); + }, axis:"x", tolerance:"pointer"}); + this.view_.appendChild(d); + this.listView_ = d; + Entry.sceneEditable && (d = Entry.createElement("span"), d.addClass("entrySceneElementWorkspace"), d.addClass("entrySceneAddButtonWorkspace"), d.bindOnClick(function(a) { + Entry.engine.isState("run") || Entry.scene.addScene(); + }), this.view_.appendChild(d), this.addButton_ = d); + } +}; +Entry.Scene.prototype.generateElement = function(b) { + var a = this, c = Entry.createElement("li", b.id); + c.addClass("entrySceneElementWorkspace"); + c.addClass("entrySceneButtonWorkspace"); + c.addClass("minValue"); + $(c).on("mousedown", function(a) { + Entry.engine.isState("run") ? a.preventDefault() : Entry.scene.selectScene(b); + }); + var d = Entry.createElement("input"); + d.addClass("entrySceneFieldWorkspace"); + d.value = b.name; + Entry.sceneEditable || (d.disabled = "disabled"); + var e = Entry.createElement("span"); + e.addClass("entrySceneLeftWorkspace"); + c.appendChild(e); + var f = Entry.createElement("span"); + f.addClass("entrySceneInputCover"); + f.style.width = Entry.computeInputWidth(b.name); + c.appendChild(f); + b.inputWrapper = f; + d.onkeyup = function(c) { + c = c.keyCode; + Entry.isArrowOrBackspace(c) || (b.name = this.value, f.style.width = Entry.computeInputWidth(b.name), a.resize(), 13 == c && this.blur(), 9 < this.value.length && (this.value = this.value.substring(0, 10), this.blur())); }; - a.getLineNumber = function(b, a) { - var d = this.codeMirror.getValue(), e = {from:{}, to:{}}; - b = d.substring(0, b).split(/\n/gi); - e.from.line = b.length - 1; - e.from.ch = b[b.length - 1].length; - a = d.substring(0, a).split(/\n/gi); - e.to.line = a.length - 1; - e.to.ch = a[a.length - 1].length; - return e; + d.onblur = function(a) { + d.value = this.value; + b.name = this.value; + f.style.width = Entry.computeInputWidth(b.name); }; - a.mappingSyntax = function(b) { - for (var a = Object.keys(Entry.block), d = 0;d < a.length;d++) { - var e = a[d], f = Entry.block[e]; - if (f.mode === b && -1 < this.availableCode.indexOf(e) && (f = f.syntax)) { - for (var g = this.syntax, h = 0;h < f.length;h++) { - var k = f[h]; - if (h === f.length - 2 && "function" === typeof f[h + 1]) { - g[k] = f[h + 1]; - break; - } - g[k] || (g[k] = {}); - h === f.length - 1 ? g[k] = e : g = g[k]; - } - } + f.appendChild(d); + e = Entry.createElement("span"); + e.addClass("entrySceneRemoveButtonCoverWorkspace"); + c.appendChild(e); + if (Entry.sceneEditable) { + var g = Entry.createElement("button"); + g.addClass("entrySceneRemoveButtonWorkspace"); + g.innerHTML = "x"; + g.scene = b; + g.bindOnClick(function(a) { + a.stopPropagation(); + Entry.engine.isState("run") || confirm(Lang.Workspace.will_you_delete_scene) && Entry.scene.removeScene(this.scene); + }); + e.appendChild(g); + } + Entry.Utils.disableContextmenu(c); + $(c).on("contextmenu", function() { + var a = [{text:Lang.Workspace.duplicate_scene, enable:Entry.engine.isState("stop"), callback:function() { + Entry.scene.cloneScene(b); + }}]; + Entry.ContextMenu.show(a, "workspace-contextmenu"); + }); + return b.view = c; +}; +Entry.Scene.prototype.updateView = function() { + if (!Entry.type || "workspace" == Entry.type) { + for (var b = this.listView_, a = $(b).children().length;a < this.getScenes().length;a++) { + b.appendChild(this.getScenes()[a].view); + } + this.addButton_ && (this.getScenes().length < this.maxCount ? this.addButton_.removeClass("entryRemove") : this.addButton_.addClass("entryRemove")); + } + this.resize(); +}; +Entry.Scene.prototype.addScenes = function(b) { + if ((this.scenes_ = b) && 0 !== b.length) { + for (var a = 0, c = b.length;a < c;a++) { + this.generateElement(b[a]); + } + } else { + this.scenes_ = [], this.scenes_.push(this.createScene()); + } + this.selectScene(this.getScenes()[0]); + this.updateView(); +}; +Entry.Scene.prototype.addScene = function(b, a) { + void 0 === b && (b = this.createScene()); + b.view || this.generateElement(b); + a || "number" == typeof a ? this.getScenes().splice(a, 0, b) : this.getScenes().push(b); + Entry.stage.objectContainers.push(Entry.stage.createObjectContainer(b)); + Entry.playground.flushPlayground(); + this.selectScene(b); + this.updateView(); + return b; +}; +Entry.Scene.prototype.removeScene = function(b) { + if (1 >= this.getScenes().length) { + Entry.toast.alert(Lang.Msgs.runtime_error, Lang.Workspace.Scene_delete_error, !1); + } else { + var a = this.getScenes().indexOf(this.getSceneById(b.id)); + this.getScenes().splice(a, 1); + for (var a = Entry.container.getSceneObjects(b), c = 0;c < a.length;c++) { + Entry.container.removeObject(a[c]); + } + Entry.stage.removeObjectContainer(b); + $(b.view).remove(); + this.selectScene(); + } +}; +Entry.Scene.prototype.selectScene = function(b) { + b = b || this.getScenes()[0]; + if (!this.selectedScene || this.selectedScene.id != b.id) { + Entry.engine.isState("run") && Entry.container.resetSceneDuringRun(); + var a = this.selectedScene; + a && (a = a.view, a.removeClass("selectedScene"), a = $(a), a.find("input").blur()); + this.selectedScene = b; + b.view.addClass("selectedScene"); + Entry.container.setCurrentObjects(); + Entry.stage.objectContainers && 0 !== Entry.stage.objectContainers.length && Entry.stage.selectObjectContainer(b); + (b = Entry.container.getCurrentObjects()[0]) && "minimize" != Entry.type ? (Entry.container.selectObject(b.id), Entry.playground.refreshPlayground()) : (Entry.stage.selectObject(null), Entry.playground.flushPlayground(), Entry.variableContainer.updateList()); + Entry.container.listView_ || Entry.stage.sortZorder(); + Entry.container.updateListView(); + this.updateView(); + Entry.requestUpdate = !0; + } +}; +Entry.Scene.prototype.toJSON = function() { + for (var b = [], a = this.getScenes().length, c = 0;c < a;c++) { + var d = this.getScenes()[c], e = d.view, f = d.inputWrapper; + delete d.view; + delete d.inputWrapper; + b.push(JSON.parse(JSON.stringify(d))); + d.view = e; + d.inputWrapper = f; + } + return b; +}; +Entry.Scene.prototype.moveScene = function(b, a) { + this.getScenes().splice(a, 0, this.getScenes().splice(b, 1)[0]); + Entry.container.updateObjectsOrder(); + Entry.stage.sortZorder(); + $(".entrySceneElementWorkspace").removeAttr("style"); +}; +Entry.Scene.prototype.getSceneById = function(b) { + for (var a = this.getScenes(), c = 0;c < a.length;c++) { + if (a[c].id == b) { + return a[c]; } - }; - a.setAvailableCode = function(b, a) { - var d = []; - b.forEach(function(b, a) { - b.forEach(function(b, a) { - d.push(b.type); - }); - }); - a instanceof Entry.Code ? a.getBlockList().forEach(function(b) { - b.type !== NtryData.START && -1 === d.indexOf(b.type) && d.push(b.type); - }) : a.forEach(function(b, a) { - b.forEach(function(b, a) { - b.type !== NtryData.START && -1 === d.indexOf(b.type) && d.push(b.type); - }); - }); - this.availableCode = this.availableCode.concat(d); - }; -})(Entry.Parser.prototype); -Entry.Pdf = function(a) { - this.generateView(a); + } + return !1; }; -p = Entry.Pdf.prototype; -p.generateView = function(a) { - var b = Entry.createElement("div", "entryPdfWorkspace"); - b.addClass("entryRemove"); - this._view = b; - var c = "/pdfjs/web/viewer.html"; - a && "" != a && (c += "?file=" + a); - pdfViewIframe = Entry.createElement("iframe", "entryPdfIframeWorkspace"); - pdfViewIframe.setAttribute("id", "pdfViewIframe"); - pdfViewIframe.setAttribute("frameborder", 0); - pdfViewIframe.setAttribute("src", c); - b.appendChild(pdfViewIframe); +Entry.Scene.prototype.getScenes = function() { + return this.scenes_; }; -p.getView = function() { - return this._view; +Entry.Scene.prototype.takeStartSceneSnapshot = function() { + this.sceneBeforeRun = this.selectedScene; }; -p.resize = function() { - var a = document.getElementById("entryContainerWorkspaceId"), b = document.getElementById("pdfViewIframe"); - w = a.offsetWidth; - b.width = w + "px"; - b.height = 9 * w / 16 + "px"; +Entry.Scene.prototype.loadStartSceneSnapshot = function() { + this.selectScene(this.sceneBeforeRun); + this.sceneBeforeRun = null; }; -Entry.FieldTrashcan = function(a) { - a && this.setBoard(a); - this.dragBlockObserver = this.dragBlock = null; - this.isOver = !1; - Entry.windowResized && Entry.windowResized.attach(this, this.setPosition); +Entry.Scene.prototype.createScene = function() { + var b = {name:Lang.Blocks.SCENE + " " + (this.getScenes().length + 1), id:Entry.generateHash()}; + this.generateElement(b); + return b; }; -(function(a) { - a._generateView = function() { - this.svgGroup = this.board.svg.elem("g"); - this.renderStart(); - this._addControl(); - }; - a.renderStart = function() { - var b = Entry.mediaFilePath + "delete_"; - this.trashcanTop = this.svgGroup.elem("image", {href:b + "cover.png", width:60, height:20}); - this.svgGroup.elem("image", {href:b + "body.png", y:20, width:60, height:60}); - }; - a._addControl = function() { - $(this.svgGroup).bind("mousedown", function(b) { - Entry.Utils.isRightButton(b) && (b.stopPropagation(), $("#entryWorkspaceBoard").css("background", "white")); - }); - }; - a.updateDragBlock = function() { - var b = this.board.dragBlock, a = this.dragBlockObserver; - a && (a.destroy(), this.dragBlockObserver = null); - b ? this.dragBlockObserver = b.observe(this, "checkBlock", ["x", "y"]) : (this.isOver && this.dragBlock && !this.dragBlock.block.getPrevBlock() && (this.dragBlock.block.doDestroyBelow(!0), createjs.Sound.play("entryDelete")), this.tAnimation(!1)); - this.dragBlock = b; - }; - a.checkBlock = function() { - var b = this.dragBlock; - if (b && b.block.isDeletable()) { - var a = this.board.offset(), d = this.getPosition(), e = d.x + a.left, a = d.y + a.top, f, g; - if (b = b.dragInstance) { - f = b.offsetX, g = b.offsetY; - } - this.tAnimation(f >= e && g >= a); +Entry.Scene.prototype.cloneScene = function(b) { + if (this.scenes_.length >= this.maxCount) { + Entry.toast.alert(Lang.Msgs.runtime_error, Lang.Workspace.Scene_add_error, !1); + } else { + var a = {name:b.name + Lang.Workspace.replica_of_object, id:Entry.generateHash()}; + this.generateElement(a); + this.addScene(a); + b = Entry.container.getSceneObjects(b); + for (var c = b.length - 1;0 <= c;c--) { + Entry.container.addCloneObject(b[c], a.id); } - }; - a.align = function() { - var b = this.getPosition(); - this.svgGroup.attr({transform:"translate(" + b.x + "," + b.y + ")"}); - }; - a.setPosition = function() { - if (this.board) { - var b = this.board.svgDom; - this._x = b.width() - 110; - this._y = b.height() - 110; - this.align(); + } +}; +Entry.Scene.prototype.resize = function() { + var b = this.getScenes(), a = this.selectedScene, c = b[0]; + if (0 !== b.length && c) { + var d = $(c.view).offset().left, c = parseFloat($(a.view).css("margin-left")), e = $(this.view_).width() - d, f = 0, g; + for (g in b) { + var d = b[g], h = d.view; + h.addClass("minValue"); + $(d.inputWrapper).width(Entry.computeInputWidth(d.name)); + h = $(h); + f = f + h.width() + c; } - }; - a.getPosition = function() { - return {x:this._x, y:this._y}; - }; - a.tAnimation = function(b) { - if (b !== this.isOver) { - b = void 0 === b ? !0 : b; - var a, d = this.trashcanTop; - a = b ? {translateX:15, translateY:-25, rotateZ:30} : {translateX:0, translateY:0, rotateZ:0}; - $(d).velocity(a, {duration:50}); - this.isOver = b; + if (f > e) { + for (g in e -= $(a.view).width(), c = e / (b.length - 1) - (Entry.Scene.viewBasicWidth + c), b) { + d = b[g], a.id != d.id ? (d.view.removeClass("minValue"), $(d.inputWrapper).width(c)) : d.view.addClass("minValue"); + } } - }; - a.setBoard = function(b) { - this._dragBlockObserver && this._dragBlockObserver.destroy(); - this.board = b; - this.svgGroup || this._generateView(); - var a = b.svg, d = a.firstChild; - d ? a.insertBefore(this.svgGroup, d) : a.appendChild(this.svgGroup); - this._dragBlockObserver = b.observe(this, "updateDragBlock", ["dragBlock"]); - this.svgGroup.attr({filter:"url(#entryTrashcanFilter_" + b.suffix + ")"}); - this.setPosition(); - }; -})(Entry.FieldTrashcan.prototype); -Entry.Workspace = function(a) { - Entry.Model(this, !1); - this.observe(this, "_handleChangeBoard", ["selectedBoard"], !1); - this.trashcan = new Entry.FieldTrashcan; - var b = a.blockMenu; - b && (this.blockMenu = new Entry.BlockMenu(b.dom, b.align, b.categoryData, b.scroll), this.blockMenu.workspace = this, this.blockMenu.observe(this, "_setSelectedBlockView", ["selectedBlockView"], !1)); - if (b = a.board) { - b.workspace = this, this.board = new Entry.Board(b), this.board.observe(this, "_setSelectedBlockView", ["selectedBlockView"], !1), this.set({selectedBoard:this.board}); } - if (b = a.vimBoard) { - this.vimBoard = new Entry.Vim(b.dom), this.vimBoard.workspace = this; +}; +Entry.Scene.prototype.getNextScene = function() { + var b = this.getScenes(); + return b[b.indexOf(this.selectedScene) + 1]; +}; +Entry.Script = function(b) { + this.entity = b; +}; +p = Entry.Script.prototype; +p.init = function(b, a, c) { + Entry.assert("BLOCK" == b.tagName.toUpperCase(), b.tagName); + this.type = b.getAttribute("type"); + this.id = +b.getAttribute("id"); + b.getElementsByTagName("mutation").length && b.getElementsByTagName("mutation")[0].hasAttribute("hashid") && (this.hashId = b.childNodes[0].getAttribute("hashid")); + "REPEAT" == this.type.substr(0, 6).toUpperCase() && (this.isRepeat = !0); + a instanceof Entry.Script && (this.previousScript = a, a.parentScript && (this.parentScript = a.parentScript)); + c instanceof Entry.Script && (this.parentScript = c); + b = b.childNodes; + for (a = 0;a < b.length;a++) { + if (c = b[a], "NEXT" == c.tagName.toUpperCase()) { + this.nextScript = new Entry.Script(this.entity), this.register && (this.nextScript.register = this.register), this.nextScript.init(b[a].childNodes[0], this); + } else { + if ("VALUE" == c.tagName.toUpperCase()) { + this.values || (this.values = {}); + var d = new Entry.Script(this.entity); + this.register && (d.register = this.register); + d.init(c.childNodes[0]); + this.values[c.getAttribute("name")] = d; + } else { + "FIELD" == c.tagName.toUpperCase() ? (this.fields || (this.fields = {}), this.fields[c.getAttribute("name")] = c.textContent) : "STATEMENT" == c.tagName.toUpperCase() && (this.statements || (this.statements = {}), d = new Entry.Script(this.entity), this.register && (d.register = this.register), d.init(c.childNodes[0], null, this), d.key = c.getAttribute("name"), this.statements[c.getAttribute("name")] = d); + } + } } - this.board && this.vimBoard && this.vimBoard.hide(); - Entry.GlobalSvg.createDom(); - this.mode = Entry.Workspace.MODE_BOARD; - Entry.keyPressed && Entry.keyPressed.attach(this, this._keyboardControl); - this.changeEvent = new Entry.Event(this); - Entry.commander.setCurrentEditor("board", this.board); }; -Entry.Workspace.MODE_BOARD = 0; -Entry.Workspace.MODE_VIMBOARD = 1; -Entry.Workspace.MODE_OVERLAYBOARD = 2; -(function(a) { - a.schema = {selectedBlockView:null, selectedBoard:null}; - a.getBoard = function() { - return this.board; - }; - a.getSelectedBoard = function() { - return this.selectedBoard; - }; - a.getBlockMenu = function() { - return this.blockMenu; - }; - a.getVimBoard = function() { - return this.vimBoard; - }; - a.getMode = function() { - return this.mode; - }; - a.setMode = function(b, a) { - b = Number(b); - var d = this.mode; - this.mode = b; - switch(b) { - case d: - return; - case Entry.Workspace.MODE_VIMBOARD: - this.board && this.board.hide(); - this.overlayBoard && this.overlayBoard.hide(); - this.set({selectedBoard:this.vimBoard}); - this.vimBoard.show(); - this.vimBoard.codeToText(this.board.code); - this.blockMenu.renderText(); - this.board.clear(); - break; - case Entry.Workspace.MODE_BOARD: - try { - this.board.show(), this.set({selectedBoard:this.board}), this.textToCode(d), this.vimBoard && this.vimBoard.hide(), this.overlayBoard && this.overlayBoard.hide(), this.blockMenu.renderBlock(); - } catch (e) { - throw this.board && this.board.hide(), this.set({selectedBoard:this.vimBoard}), Entry.dispatchEvent("setProgrammingMode", Entry.Workspace.MODE_VIMBOARD), e; - } - Entry.commander.setCurrentEditor("board", this.board); - break; - case Entry.Workspace.MODE_OVERLAYBOARD: - this.overlayBoard || this.initOverlayBoard(), this.overlayBoard.show(), this.set({selectedBoard:this.overlayBoard}), Entry.commander.setCurrentEditor("board", this.overlayBoard); +p.clone = function(b, a) { + var c = new Entry.Script(b); + c.id = this.id; + c.type = this.type; + c.isRepeat = this.isRepeat; + if (this.parentScript && !this.previousScript && 2 != a) { + c.parentScript = this.parentScript.clone(b); + for (var d = c.parentScript.statements[this.key] = c;d.nextScript;) { + d = d.nextScript, d.parentScript = c.parentScript; } - this.changeEvent.notify(a); - }; - a.changeBoardCode = function(b) { - this.board.changeCode(b); - }; - a.changeOverlayBoardCode = function(b) { - this.overlayBoard && this.overlayBoard.changeCode(b); - }; - a.changeBlockMenuCode = function(b) { - this.blockMenu.changeCode(b); - }; - a.textToCode = function(b) { - if (b == Entry.Workspace.MODE_VIMBOARD) { - b = this.vimBoard.textToCode(); - var a = this.board, d = a.code; - d.load(b); - d.createView(a); - a.reDraw(); - this.board.alignThreads(); + } + this.nextScript && 1 != a && (c.nextScript = this.nextScript.clone(b, 0), c.nextScript.previousScript = this); + this.previousScript && 0 !== a && (c.previousScript = this.previousScript.clone(b, 1), c.previousScript.previousScript = this); + if (this.fields) { + c.fields = {}; + for (var e in this.fields) { + c.fields[e] = this.fields[e]; } - }; - a.codeToText = function(a) { - return this.vimBoard.codeToText(a); - }; - a.getCodeToText = function(a) { - return this.vimBoard.getCodeToText(a); - }; - a._setSelectedBlockView = function() { - this.set({selectedBlockView:this.board.selectedBlockView || this.blockMenu.selectedBlockView || (this.overlayBoard ? this.overlayBoard.selectedBlockView : null)}); - }; - a.initOverlayBoard = function() { - this.overlayBoard = new Entry.Board({dom:this.board.view, workspace:this, isOverlay:!0}); - this.overlayBoard.changeCode(new Entry.Code([])); - this.overlayBoard.workspace = this; - this.overlayBoard.observe(this, "_setSelectedBlockView", ["selectedBlockView"], !1); - }; - a._keyboardControl = function(a) { - var c = a.keyCode || a.which, d = a.ctrlKey; - if (!Entry.Utils.isInInput(a)) { - var e = this.selectedBlockView; - e && !e.isInBlockMenu && e.block.isDeletable() && (8 == c || 46 == c ? (Entry.do("destroyBlock", e.block), a.preventDefault()) : d && (67 == c ? e.block.copyToClipboard() : 88 == c && (a = e.block, a.copyToClipboard(), a.destroy(!0, !0), e.getBoard().setSelectedBlock(null)))); - d && 86 == c && (c = this.selectedBoard) && c instanceof Entry.Board && Entry.clipboard && Entry.do("addThread", Entry.clipboard).value.getFirstBlock().copyToClipboard(); + } + if (this.values) { + for (e in c.values = {}, this.values) { + c.values[e] = this.values[e].clone(b); } - }; - a._handleChangeBoard = function() { - var a = this.selectedBoard; - a && a.constructor === Entry.Board && this.trashcan.setBoard(a); - }; -})(Entry.Workspace.prototype); + } + if (this.statements) { + for (e in c.statements = {}, this.statements) { + for (c.statements[e] = this.statements[e].clone(b, 2), d = c.statements[e], d.parentScript = c;d.nextScript;) { + d = d.nextScript, d.parentScript = c; + } + } + } + return c; +}; +p.getStatement = function(b) { + return this.statements[b]; +}; +p.compute = function() { +}; +p.getValue = function(b) { + return this.values[b].run(); +}; +p.getNumberValue = function(b) { + return +this.values[b].run(); +}; +p.getStringValue = function(b) { + return String(this.values[b].run()); +}; +p.getBooleanValue = function(b) { + return this.values[b].run() ? !0 : !1; +}; +p.getField = function(b) { + return this.fields[b]; +}; +p.getStringField = function(b) { + return String(this.fields[b]); +}; +p.getNumberField = function(b) { + return +this.fields[b]; +}; +p.callReturn = function() { + return this.nextScript ? this.nextScript : this.parentScript ? this.parentScript : null; +}; +p.run = function() { + return Entry.block[this.type](this.entity, this); +}; +Entry.StampEntity = function(b, a) { + this.parent = b; + this.type = b.objectType; + this.isStamp = this.isClone = !0; + this.width = a.getWidth(); + this.height = a.getHeight(); + "sprite" == this.type && (this.object = a.object.clone(!0), this.object.filters = null, a.effect && (this.effect = Entry.cloneSimpleObject(a.effect), this.applyFilter())); + this.object.entity = this; + if (a.dialog) { + var c = a.dialog; + new Entry.Dialog(this, c.message_, c.mode_, !0); + this.dialog.object = a.dialog.object.clone(!0); + Entry.stage.loadDialog(this.dialog); + } +}; +var EntityPrototype = Entry.EntityObject.prototype; +Entry.StampEntity.prototype.applyFilter = EntityPrototype.applyFilter; +Entry.StampEntity.prototype.removeClone = EntityPrototype.removeClone; +Entry.StampEntity.prototype.getWidth = EntityPrototype.getWidth; +Entry.StampEntity.prototype.getHeight = EntityPrototype.getHeight; +Entry.StampEntity.prototype.getInitialEffectValue = EntityPrototype.getInitialEffectValue; +Entry.Toast = function() { + this.toasts_ = []; + var b = document.getElementById("entryToastContainer"); + b && document.body.removeChild(b); + this.body_ = Entry.createElement("div", "entryToastContainer"); + this.body_.addClass("entryToastContainer"); + document.body.appendChild(this.body_); +}; +Entry.Toast.prototype.warning = function(b, a, c) { + var d = Entry.createElement("div", "entryToast"); + d.addClass("entryToast"); + d.addClass("entryToastWarning"); + d.bindOnClick(function() { + Entry.toast.body_.removeChild(this); + }); + var e = Entry.createElement("div", "entryToast"); + e.addClass("entryToastTitle"); + e.innerHTML = b; + d.appendChild(e); + b = Entry.createElement("p", "entryToast"); + b.addClass("entryToastMessage"); + b.innerHTML = a; + d.appendChild(b); + this.toasts_.push(d); + this.body_.appendChild(d); + c || window.setTimeout(function() { + d.style.opacity = 1; + var a = setInterval(function() { + .05 > d.style.opacity && (clearInterval(a), d.style.display = "none", Entry.removeElement(d)); + d.style.opacity *= .9; + }, 20); + }, 1E3); +}; +Entry.Toast.prototype.success = function(b, a, c) { + var d = Entry.createElement("div", "entryToast"); + d.addClass("entryToast"); + d.addClass("entryToastSuccess"); + d.bindOnClick(function() { + Entry.toast.body_.removeChild(this); + }); + var e = Entry.createElement("div", "entryToast"); + e.addClass("entryToastTitle"); + e.innerHTML = b; + d.appendChild(e); + b = Entry.createElement("p", "entryToast"); + b.addClass("entryToastMessage"); + b.innerHTML = a; + d.appendChild(b); + this.toasts_.push(d); + this.body_.appendChild(d); + c || window.setTimeout(function() { + d.style.opacity = 1; + var a = setInterval(function() { + .05 > d.style.opacity && (clearInterval(a), d.style.display = "none", Entry.removeElement(d)); + d.style.opacity *= .9; + }, 20); + }, 1E3); +}; +Entry.Toast.prototype.alert = function(b, a, c) { + var d = Entry.createElement("div", "entryToast"); + d.addClass("entryToast"); + d.addClass("entryToastAlert"); + d.bindOnClick(function() { + Entry.toast.body_.removeChild(this); + }); + var e = Entry.createElement("div", "entryToast"); + e.addClass("entryToastTitle"); + e.innerHTML = b; + d.appendChild(e); + b = Entry.createElement("p", "entryToast"); + b.addClass("entryToastMessage"); + b.innerHTML = a; + d.appendChild(b); + this.toasts_.push(d); + this.body_.appendChild(d); + c || window.setTimeout(function() { + d.style.opacity = 1; + var a = setInterval(function() { + .05 > d.style.opacity && (clearInterval(a), d.style.display = "none", Entry.toast.body_.removeChild(d)); + d.style.opacity *= .9; + }, 20); + }, 5E3); +}; +Entry.TvCast = function(b) { + this.generateView(b); +}; +p = Entry.TvCast.prototype; +p.init = function(b) { + this.tvCastHash = b; +}; +p.generateView = function(b) { + var a = Entry.createElement("div"); + a.addClass("entryContainerMovieWorkspace"); + a.addClass("entryRemove"); + this.movieContainer = a; + a = Entry.createElement("iframe"); + a.setAttribute("id", "tvCastIframe"); + a.setAttribute("allowfullscreen", ""); + a.setAttribute("frameborder", 0); + a.setAttribute("src", b); + this.movieFrame = a; + this.movieContainer.appendChild(this.movieFrame); +}; +p.getView = function() { + return this.movieContainer; +}; +p.resize = function() { + document.getElementById("entryContainerWorkspaceId"); + var b = document.getElementById("tvCastIframe"); + w = this.movieContainer.offsetWidth; + b.width = w + "px"; + b.height = 9 * w / 16 + "px"; +}; Entry.BlockDriver = function() { }; -(function(a) { - a.convert = function() { - var a = new Date, c; - for (c in Entry.block) { - "function" === typeof Entry.block[c] && this._convertBlock(c); +(function(b) { + b.convert = function() { + var a = new Date, b; + for (b in Entry.block) { + "function" === typeof Entry.block[b] && this._convertBlock(b); } console.log((new Date).getTime() - a.getTime()); }; - a._convertBlock = function(a) { - function c(a) { - var b = {type:a.getAttribute("type"), index:{}}; + b._convertBlock = function(a) { + function b(a) { + var d = {type:a.getAttribute("type"), index:{}}; a = $(a).children(); if (!a) { - return b; + return d; } - for (var d = 0;d < a.length;d++) { - var e = a[d], f = e.tagName, g = $(e).children()[0], h = e.getAttribute("name"); - "value" === f ? "block" == g.nodeName && (b.params || (b.params = []), b.params.push(c(g)), b.index[h] = b.params.length - 1) : "field" === f && (b.params || (b.params = []), b.params.push(e.textContent), b.index[h] = b.params.length - 1); + for (var e = 0;e < a.length;e++) { + var f = a[e], g = f.tagName, h = $(f).children()[0], u = f.getAttribute("name"); + "value" === g ? "block" == h.nodeName && (d.params || (d.params = []), d.params.push(b(h)), d.index[u] = d.params.length - 1) : "field" === g && (d.params || (d.params = []), d.params.push(f.textContent), d.index[u] = d.params.length - 1); } - return b; + return d; } var d = Blockly.Blocks[a], e = EntryStatic.blockInfo[a], f, g; if (e && (f = e.class, g = e.isNotFor, e = e.xml)) { - var e = $.parseXML(e), h = c(e.childNodes[0]) + var e = $.parseXML(e), h = b(e.childNodes[0]) } d = (new Entry.BlockMockup(d, h, a)).toJSON(); d.class = f; @@ -12266,7 +11232,7 @@ Entry.BlockDriver = function() { Entry.block[a] = d; }; })(Entry.BlockDriver.prototype); -Entry.BlockMockup = function(a, b, c) { +Entry.BlockMockup = function(b, a, c) { this.templates = []; this.params = []; this.statements = []; @@ -12274,1385 +11240,1456 @@ Entry.BlockMockup = function(a, b, c) { this.output = this.isNext = this.isPrev = !1; this.fieldCount = 0; this.events = {}; - this.def = b || {}; + this.def = a || {}; this.paramsKeyMap = {}; this.statementsKeyMap = {}; this.definition = {params:[], type:this.def.type}; - this.simulate(a); + this.simulate(b); this.def = this.definition; }; -(function(a) { - a.simulate = function(a) { +(function(b) { + b.simulate = function(a) { a.sensorList && (this.sensorList = a.sensorList); a.portList && (this.portList = a.portList); a.init.call(this); a.whenAdd && (this.events.blockViewAdd || (this.events.blockViewAdd = []), this.events.blockViewAdd.push(a.whenAdd)); a.whenRemove && (this.events.blockViewDestroy || (this.events.blockViewDestroy = []), this.events.blockViewDestroy.push(a.whenRemove)); }; - a.toJSON = function() { - function a(c) { - if (c && (c = c.params)) { - for (var d = 0;d < c.length;d++) { - var e = c[d]; - e && (delete e.index, a(e)); + b.toJSON = function() { + function a(b) { + if (b && (b = b.params)) { + for (var c = 0;c < b.length;c++) { + var d = b[c]; + d && (delete d.index, a(d)); } } } - var c = ""; - this.output ? c = "Boolean" === this.output ? "basic_boolean_field" : "basic_string_field" : !this.isPrev && this.isNext ? c = "basic_event" : 1 == this.statements.length ? c = "basic_loop" : 2 == this.statements.length ? c = "basic_double_loop" : this.isPrev && this.isNext ? c = "basic" : this.isPrev && !this.isNext && (c = "basic_without_next"); - a(this.def); - var d = /dummy_/mi, e; - for (e in this.paramsKeyMap) { - d.test(e) && delete this.paramsKeyMap[e]; - } - for (e in this.statementsKeyMap) { - d.test(e) && delete this.statementsKeyMap[e]; - } - return {color:this.color, skeleton:c, statements:this.statements, template:this.templates.filter(function(a) { - return "string" === typeof a; - }).join(" "), params:this.params, events:this.events, def:this.def, paramsKeyMap:this.paramsKeyMap, statementsKeyMap:this.statementsKeyMap}; - }; - a.appendDummyInput = function() { - return this; - }; - a.appendValueInput = function(a) { - this.def && this.def.index && (void 0 !== this.def.index[a] ? this.definition.params.push(this.def.params[this.def.index[a]]) : this.definition.params.push(null)); - this.params.push({type:"Block", accept:"string"}); - this._addToParamsKeyMap(a); - this.templates.push(this.getFieldCount()); - return this; - }; - a.appendStatementInput = function(a) { - this._addToStatementsKeyMap(a); - this.statements.push({accept:"basic"}); - }; - a.setCheck = function(a) { - var c = this.params; - "Boolean" === a && (c[c.length - 1].accept = "boolean"); - }; - a.appendField = function(a, c) { - if (!a) { - return this; - } - "string" === typeof a && 0 < a.length ? c ? (a = {type:"Text", text:a, color:c}, this.params.push(a), this._addToParamsKeyMap(), this.templates.push(this.getFieldCount()), this.def && this.def.index && void 0 !== this.def.index[c] ? this.definition.params.push(this.def.params[this.def.index[c]]) : this.definition.params.push(void 0)) : this.templates.push(a) : a.constructor == Blockly.FieldIcon ? ("start" === a.type ? this.params.push({type:"Indicator", img:a.src_, size:17, position:{x:0, y:-2}}) : - this.params.push({type:"Indicator", img:a.src_, size:12}), this._addToParamsKeyMap(), this.templates.push(this.getFieldCount()), this.definition && this.definition.params.push(null)) : a.constructor == Blockly.FieldDropdown ? (this.params.push({type:"Dropdown", options:a.menuGenerator_, value:a.menuGenerator_[0][1], fontSize:11}), this._addToParamsKeyMap(c), this.templates.push(this.getFieldCount()), this.def && this.def.index && void 0 !== this.def.index[c] ? this.definition.params.push(this.def.params[this.def.index[c]]) : - this.definition.params.push(void 0)) : a.constructor == Blockly.FieldDropdownDynamic ? (this.params.push({type:"DropdownDynamic", value:null, menuName:a.menuName_, fontSize:11}), this.templates.push(this.getFieldCount()), this.def && this.def.index && void 0 !== this.def.index[c] ? this.definition.params.push(this.def.params[this.def.index[c]]) : this.definition.params.push(void 0), this._addToParamsKeyMap(c)) : a.constructor == Blockly.FieldTextInput ? (this.params.push({type:"TextInput", value:10}), - this.templates.push(this.getFieldCount()), this._addToParamsKeyMap(c)) : a.constructor == Blockly.FieldAngle ? (this.params.push({type:"Angle"}), this.templates.push(this.getFieldCount()), this.def && this.def.index && void 0 !== this.def.index[c] ? this.definition.params.push(this.def.params[this.def.index[c]]) : this.definition.params.push(null), this._addToParamsKeyMap(c)) : a.constructor == Blockly.FieldKeydownInput ? (this.params.push({type:"Keyboard", value:81}), this.templates.push(this.getFieldCount()), - void 0 !== this.def.index[c] ? this.definition.params.push(this.def.params[this.def.index[c]]) : this.definition.params.push(void 0), this._addToParamsKeyMap(c)) : a.constructor == Blockly.FieldColour ? (this.params.push({type:"Color"}), this.templates.push(this.getFieldCount()), this._addToParamsKeyMap(c)) : console.log("else", a); - return this; - }; - a.setColour = function(a) { - this.color = a; - }; - a.setInputsInline = function() { - }; - a.setOutput = function(a, c) { - a && (this.output = c); - }; - a.setPreviousStatement = function(a) { - this.isPrev = a; - }; - a.setNextStatement = function(a) { - this.isNext = a; - }; - a.setEditable = function(a) { - }; - a.getFieldCount = function() { - this.fieldCount++; - return "%" + this.fieldCount; - }; - a._addToParamsKeyMap = function(a) { - a = a ? a : "dummy_" + Entry.Utils.generateId(); - var c = this.paramsKeyMap; - c[a] = Object.keys(c).length; - }; - a._addToStatementsKeyMap = function(a) { - a = a ? a : "dummy_" + Entry.Utils.generateId(); - var c = this.statementsKeyMap; - c[a] = Object.keys(c).length; - }; -})(Entry.BlockMockup.prototype); -Entry.Playground = function() { - this.enableArduino = this.isTextBGMode_ = !1; - this.viewMode_ = "default"; - Entry.addEventListener("textEdited", this.injectText); - Entry.addEventListener("hwChanged", this.updateHW); -}; -Entry.Playground.prototype.generateView = function(a, b) { - this.view_ = a; - this.view_.addClass("entryPlayground"); - b && "workspace" != b ? "phone" == b && (this.view_.addClass("entryPlaygroundPhone"), a = Entry.createElement("div", "entryCategoryTab"), a.addClass("entryPlaygroundTabPhone"), Entry.view_.insertBefore(a, this.view_), this.generateTabView(a), this.tabView_ = a, a = Entry.createElement("div", "entryCurtain"), a.addClass("entryPlaygroundCurtainPhone"), a.addClass("entryRemove"), a.innerHTML = Lang.Workspace.cannot_edit_click_to_stop, a.bindOnClick(function() { - Entry.engine.toggleStop(); - }), this.view_.appendChild(a), this.curtainView_ = a, Entry.pictureEditable && (a = Entry.createElement("div", "entryPicture"), a.addClass("entryPlaygroundPicturePhone"), a.addClass("entryRemove"), this.view_.appendChild(a), this.generatePictureView(a), this.pictureView_ = a), a = Entry.createElement("div", "entryText"), a.addClass("entryRemove"), this.view_.appendChild(a), this.generateTextView(a), this.textView_ = a, Entry.soundEditable && (a = Entry.createElement("div", "entrySound"), a.addClass("entryPlaygroundSoundWorkspacePhone"), - a.addClass("entryRemove"), this.view_.appendChild(a), this.generateSoundView(a), this.soundView_ = a), a = Entry.createElement("div", "entryDefault"), this.view_.appendChild(a), this.generateDefaultView(a), this.defaultView_ = a, a = Entry.createElement("div", "entryCode"), a.addClass("entryPlaygroundCodePhone"), this.view_.appendChild(a), this.generateCodeView(a), this.codeView_ = this.codeView_ = a, Entry.addEventListener("run", function(a) { - Entry.playground.curtainView_.removeClass("entryRemove"); - }), Entry.addEventListener("stop", function(a) { - Entry.playground.curtainView_.addClass("entryRemove"); - })) : (this.view_.addClass("entryPlaygroundWorkspace"), a = Entry.createElement("div", "entryCategoryTab"), a.addClass("entryPlaygroundTabWorkspace"), this.view_.appendChild(a), this.generateTabView(a), this.tabView_ = a, a = Entry.createElement("div", "entryCurtain"), a.addClass("entryPlaygroundCurtainWorkspace"), a.addClass("entryRemove"), b = Lang.Workspace.cannot_edit_click_to_stop.split("."), a.innerHTML = b[0] + ".
" + b[1], a.addEventListener("click", function() { - Entry.engine.toggleStop(); - }), this.view_.appendChild(a), this.curtainView_ = a, Entry.pictureEditable && (a = Entry.createElement("div", "entryPicture"), a.addClass("entryPlaygroundPictureWorkspace"), a.addClass("entryRemove"), this.view_.appendChild(a), this.generatePictureView(a), this.pictureView_ = a), a = Entry.createElement("div", "entryText"), a.addClass("entryPlaygroundTextWorkspace"), a.addClass("entryRemove"), this.view_.appendChild(a), this.generateTextView(a), this.textView_ = a, Entry.soundEditable && (a = - Entry.createElement("div", "entrySound"), a.addClass("entryPlaygroundSoundWorkspace"), a.addClass("entryRemove"), this.view_.appendChild(a), this.generateSoundView(a), this.soundView_ = a), a = Entry.createElement("div", "entryDefault"), a.addClass("entryPlaygroundDefaultWorkspace"), this.view_.appendChild(a), this.generateDefaultView(a), this.defaultView_ = a, a = Entry.createElement("div", "entryCode"), a.addClass("entryPlaygroundCodeWorkspace"), a.addClass("entryRemove"), this.view_.appendChild(a), - this.generateCodeView(a), this.codeView_ = a, b = Entry.createElement("div"), b.addClass("entryPlaygroundResizeWorkspace", "entryRemove"), this.resizeHandle_ = b, this.view_.appendChild(b), this.initializeResizeHandle(b), this.codeView_ = a, Entry.addEventListener("run", function(a) { - Entry.playground.curtainView_.removeClass("entryRemove"); - }), Entry.addEventListener("stop", function(a) { - Entry.playground.curtainView_.addClass("entryRemove"); - })); -}; -Entry.Playground.prototype.generateDefaultView = function(a) { - return a; -}; -Entry.Playground.prototype.generateTabView = function(a) { - var b = this, c = Entry.createElement("ul"); - c.addClass("entryTabListWorkspace"); - this.tabList_ = c; - a.appendChild(c); - this.tabViewElements = {}; - a = Entry.createElement("li", "entryCodeTab"); - a.innerHTML = Lang.Workspace.tab_code; - a.addClass("entryTabListItemWorkspace"); - a.addClass("entryTabSelected"); - c.appendChild(a); - a.bindOnClick(function(a) { - b.changeViewMode("code"); - b.blockMenu.reDraw(); - }); - this.tabViewElements.code = a; - Entry.pictureEditable && (a = Entry.createElement("li", "entryPictureTab"), a.innerHTML = Lang.Workspace.tab_picture, a.addClass("entryTabListItemWorkspace"), c.appendChild(a), a.bindOnClick(function(a) { - Entry.playground.changeViewMode("picture"); - }), this.tabViewElements.picture = a, a = Entry.createElement("li", "entryTextboxTab"), a.innerHTML = Lang.Workspace.tab_text, a.addClass("entryTabListItemWorkspace"), c.appendChild(a), a.bindOnClick(function(a) { - Entry.playground.changeViewMode("text"); - }), this.tabViewElements.text = a, a.addClass("entryRemove")); - Entry.soundEditable && (a = Entry.createElement("li", "entrySoundTab"), a.innerHTML = Lang.Workspace.tab_sound, a.addClass("entryTabListItemWorkspace"), c.appendChild(a), a.bindOnClick(function(a) { - Entry.playground.changeViewMode("sound"); - }), this.tabViewElements.sound = a); - Entry.hasVariableManager && (a = Entry.createElement("li", "entryVariableTab"), a.innerHTML = Lang.Workspace.tab_attribute, a.addClass("entryTabListItemWorkspace"), a.addClass("entryVariableTabWorkspace"), c.appendChild(a), a.bindOnClick(function(a) { - Entry.playground.toggleOnVariableView(); - Entry.playground.changeViewMode("variable"); - }), this.tabViewElements.variable = a); -}; -Entry.Playground.prototype.generateCodeView = function(a) { - var b = this.createVariableView(); - a.appendChild(b); - this.variableView_ = b; - a = Entry.Dom(a); - b = Entry.Dom("div", {parent:a, id:"entryWorkspaceBoard", class:"entryWorkspaceBoard"}); - a = Entry.Dom("div", {parent:a, id:"entryWorkspaceBlockMenu", class:"entryWorkspaceBlockMenu"}); - this.mainWorkspace = new Entry.Workspace({blockMenu:{dom:a, align:"LEFT", categoryData:EntryStatic.getAllBlocks(), scroll:!0}, board:{dom:b}}); - this.blockMenu = this.mainWorkspace.blockMenu; - this.board = this.mainWorkspace.board; - Entry.hw && this.updateHW(); -}; -Entry.Playground.prototype.generatePictureView = function(a) { - if ("workspace" == Entry.type) { - var b = Entry.createElement("div", "entryAddPicture"); - b.addClass("entryPlaygroundAddPicture"); - b.bindOnClick(function(a) { - Entry.dispatchEvent("openPictureManager"); - }); - var c = Entry.createElement("div", "entryAddPictureInner"); - c.addClass("entryPlaygroundAddPictureInner"); - c.innerHTML = Lang.Workspace.picture_add; - b.appendChild(c); - a.appendChild(b); - b = Entry.createElement("ul", "entryPictureList"); - b.addClass("entryPlaygroundPictureList"); - $ && $(b).sortable({start:function(a, b) { - b.item.data("start_pos", b.item.index()); - }, stop:function(a, b) { - a = b.item.data("start_pos"); - b = b.item.index(); - Entry.playground.movePicture(a, b); - }, axis:"y"}); - a.appendChild(b); - this.pictureListView_ = b; - b = Entry.createElement("div", "entryPainter"); - b.addClass("entryPlaygroundPainter"); - a.appendChild(b); - this.painter = new Entry.Painter; - this.painter.initialize(b); - } else { - "phone" == Entry.type && (b = Entry.createElement("div", "entryAddPicture"), b.addClass("entryPlaygroundAddPicturePhone"), b.bindOnClick(function(a) { - Entry.dispatchEvent("openPictureManager"); - }), c = Entry.createElement("div", "entryAddPictureInner"), c.addClass("entryPlaygroundAddPictureInnerPhone"), c.innerHTML = Lang.Workspace.picture_add, b.appendChild(c), a.appendChild(b), b = Entry.createElement("ul", "entryPictureList"), b.addClass("entryPlaygroundPictureListPhone"), $ && $(b).sortable({start:function(a, b) { - b.item.data("start_pos", b.item.index()); - }, stop:function(a, b) { - a = b.item.data("start_pos"); - b = b.item.index(); - Entry.playground.movePicture(a, b); - }, axis:"y"}), a.appendChild(b), this.pictureListView_ = b); - } -}; -Entry.Playground.prototype.generateTextView = function(a) { - var b = Entry.createElement("div"); - a.appendChild(b); - a = Entry.createElement("div"); - a.addClass("textProperties"); - b.appendChild(a); - var c = Entry.createElement("div"); - c.addClass("entryTextFontSelect"); - a.appendChild(c); - var d = Entry.createElement("select", "entryPainterAttrFontName"); - d.addClass("entryPlaygroundPainterAttrFontName", "entryTextFontSelecter"); - d.size = "1"; - d.onchange = function(a) { - Entry.playground.object.entity.setFontType(a.target.value); - }; - for (var e = 0;e < Entry.fonts.length;e++) { - var f = Entry.fonts[e], g = Entry.createElement("option"); - g.value = f.family; - g.innerHTML = f.name; - d.appendChild(g); - } - this.fontName_ = d; - c.appendChild(d); - e = Entry.createElement("ul"); - e.addClass("entryPlayground_text_buttons"); - a.appendChild(e); - c = Entry.createElement("li"); - c.addClass("entryPlaygroundTextAlignLeft"); - c.bindOnClick(function(a) { - Entry.playground.setFontAlign(Entry.TEXT_ALIGN_LEFT); - }); - e.appendChild(c); - this.alignLeftBtn = c; - c = Entry.createElement("li"); - c.addClass("entryPlaygroundTextAlignCenter"); - c.bindOnClick(function(a) { - Entry.playground.setFontAlign(Entry.TEXT_ALIGN_CENTER); - }); - e.appendChild(c); - this.alignCenterBtn = c; - c = Entry.createElement("li"); - c.addClass("entryPlaygroundTextAlignRight"); - c.bindOnClick(function(a) { - Entry.playground.setFontAlign(Entry.TEXT_ALIGN_RIGHT); - }); - e.appendChild(c); - this.alignRightBtn = c; - c = Entry.createElement("li"); - e.appendChild(c); - d = Entry.createElement("a"); - c.appendChild(d); - d.bindOnClick(function() { - Entry.playground.object.entity.toggleFontBold() ? h.src = Entry.mediaFilePath + "text_button_bold_true.png" : h.src = Entry.mediaFilePath + "text_button_bold_false.png"; - }); - var h = Entry.createElement("img", "entryPlaygroundText_boldImage"); - d.appendChild(h); - h.src = Entry.mediaFilePath + "text_button_bold_false.png"; - c = Entry.createElement("li"); - e.appendChild(c); - d = Entry.createElement("a"); - c.appendChild(d); - d.bindOnClick(function() { - var a = !Entry.playground.object.entity.getUnderLine() || !1; - k.src = Entry.mediaFilePath + "text_button_underline_" + a + ".png"; - Entry.playground.object.entity.setUnderLine(a); - }); - var k = Entry.createElement("img", "entryPlaygroundText_underlineImage"); - d.appendChild(k); - k.src = Entry.mediaFilePath + "text_button_underline_false.png"; - c = Entry.createElement("li"); - e.appendChild(c); - d = Entry.createElement("a"); - c.appendChild(d); - d.bindOnClick(function() { - Entry.playground.object.entity.toggleFontItalic() ? l.src = Entry.mediaFilePath + "text_button_italic_true.png" : l.src = Entry.mediaFilePath + "/text_button_italic_false.png"; - }); - var l = Entry.createElement("img", "entryPlaygroundText_italicImage"); - d.appendChild(l); - l.src = Entry.mediaFilePath + "text_button_italic_false.png"; - c = Entry.createElement("li"); - e.appendChild(c); - d = Entry.createElement("a"); - c.appendChild(d); - d.bindOnClick(function() { - var a = !Entry.playground.object.entity.getStrike() || !1; - Entry.playground.object.entity.setStrike(a); - n.src = Entry.mediaFilePath + "text_button_strike_" + a + ".png"; - }); - var n = Entry.createElement("img", "entryPlaygroundText_strikeImage"); - d.appendChild(n); - n.src = Entry.mediaFilePath + "text_button_strike_false.png"; - d = Entry.createElement("li"); - e.appendChild(d); - c = Entry.createElement("a"); - d.appendChild(c); - c.bindOnClick(function() { - Entry.playground.toggleColourChooser("foreground"); - }); - d = Entry.createElement("img"); - c.appendChild(d); - d.src = Entry.mediaFilePath + "text_button_color_false.png"; - c = Entry.createElement("li"); - e.appendChild(c); - e = Entry.createElement("a"); - c.appendChild(e); - e.bindOnClick(function() { - Entry.playground.toggleColourChooser("background"); - }); - c = Entry.createElement("img"); - e.appendChild(c); - c.src = Entry.mediaFilePath + "text_button_background_false.png"; - e = Entry.createElement("div"); - e.addClass("entryPlayground_fgColorDiv"); - c = Entry.createElement("div"); - c.addClass("entryPlayground_bgColorDiv"); - a.appendChild(e); - a.appendChild(c); - d = Entry.createElement("div"); - d.addClass("entryPlaygroundTextColoursWrapper"); - this.coloursWrapper = d; - b.appendChild(d); - a = Entry.getColourCodes(); - for (e = 0;e < a.length;e++) { - c = Entry.createElement("div"), c.addClass("modal_colour"), c.setAttribute("colour", a[e]), c.style.backgroundColor = a[e], 0 === e && c.addClass("modalColourTrans"), c.bindOnClick(function(a) { - Entry.playground.setTextColour(a.target.getAttribute("colour")); - }), d.appendChild(c); - } - d.style.display = "none"; - d = Entry.createElement("div"); - d.addClass("entryPlaygroundTextBackgroundsWrapper"); - this.backgroundsWrapper = d; - b.appendChild(d); - for (e = 0;e < a.length;e++) { - c = Entry.createElement("div"), c.addClass("modal_colour"), c.setAttribute("colour", a[e]), c.style.backgroundColor = a[e], 0 === e && c.addClass("modalColourTrans"), c.bindOnClick(function(a) { - Entry.playground.setBackgroundColour(a.target.getAttribute("colour")); - }), d.appendChild(c); - } - d.style.display = "none"; - a = Entry.createElement("input"); - a.addClass("entryPlayground_textBox"); - a.onkeyup = function() { - Entry.playground.object.setText(this.value); - Entry.playground.object.entity.setText(this.value); + var b = ""; + this.output ? b = "Boolean" === this.output ? "basic_boolean_field" : "basic_string_field" : !this.isPrev && this.isNext ? b = "basic_event" : 1 == this.statements.length ? b = "basic_loop" : 2 == this.statements.length ? b = "basic_double_loop" : this.isPrev && this.isNext ? b = "basic" : this.isPrev && !this.isNext && (b = "basic_without_next"); + a(this.def); + var d = /dummy_/mi, e; + for (e in this.paramsKeyMap) { + d.test(e) && delete this.paramsKeyMap[e]; + } + for (e in this.statementsKeyMap) { + d.test(e) && delete this.statementsKeyMap[e]; + } + return {color:this.color, skeleton:b, statements:this.statements, template:this.templates.filter(function(a) { + return "string" === typeof a; + }).join(" "), params:this.params, events:this.events, def:this.def, paramsKeyMap:this.paramsKeyMap, statementsKeyMap:this.statementsKeyMap}; }; - a.onblur = function() { - Entry.dispatchEvent("textEdited"); + b.appendDummyInput = function() { + return this; }; - this.textEditInput = a; - b.appendChild(a); - a = Entry.createElement("textarea"); - a.addClass("entryPlayground_textArea"); - a.style.display = "none"; - a.onkeyup = function() { - Entry.playground.object.setText(this.value); - Entry.playground.object.entity.setText(this.value); + b.appendValueInput = function(a) { + this.def && this.def.index && (void 0 !== this.def.index[a] ? this.definition.params.push(this.def.params[this.def.index[a]]) : this.definition.params.push(null)); + this.params.push({type:"Block", accept:"string"}); + this._addToParamsKeyMap(a); + this.templates.push(this.getFieldCount()); + return this; }; - a.onblur = function() { - Entry.dispatchEvent("textEdited"); + b.appendStatementInput = function(a) { + this._addToStatementsKeyMap(a); + this.statements.push({accept:"basic"}); }; - this.textEditArea = a; - b.appendChild(a); - a = Entry.createElement("div"); - a.addClass("entryPlaygroundFontSizeWrapper"); - b.appendChild(a); - this.fontSizeWrapper = a; - var m = Entry.createElement("div"); - m.addClass("entryPlaygroundFontSizeSlider"); - a.appendChild(m); - var q = Entry.createElement("div"); - q.addClass("entryPlaygroundFontSizeIndicator"); - m.appendChild(q); - this.fontSizeIndiciator = q; - var r = Entry.createElement("div"); - r.addClass("entryPlaygroundFontSizeKnob"); - m.appendChild(r); - this.fontSizeKnob = r; - e = Entry.createElement("div"); - e.addClass("entryPlaygroundFontSizeLabel"); - e.innerHTML = "\uae00\uc790 \ud06c\uae30"; - a.appendChild(e); - var u = !1, t = 0; - r.onmousedown = function(a) { - u = !0; - t = $(m).offset().left; + b.setCheck = function(a) { + var b = this.params; + "Boolean" === a && (b[b.length - 1].accept = "boolean"); }; - document.addEventListener("mousemove", function(a) { - u && (a = a.pageX - t, a = Math.max(a, 5), a = Math.min(a, 88), r.style.left = a + "px", a /= .88, q.style.width = a + "%", Entry.playground.object.entity.setFontSize(a)); - }); - document.addEventListener("mouseup", function(a) { - u = !1; - }); - a = Entry.createElement("div"); - a.addClass("entryPlaygroundLinebreakWrapper"); - b.appendChild(a); - b = Entry.createElement("hr"); - b.addClass("entryPlaygroundLinebreakHorizontal"); - a.appendChild(b); - b = Entry.createElement("div"); - b.addClass("entryPlaygroundLinebreakButtons"); - a.appendChild(b); - e = Entry.createElement("img"); - e.bindOnClick(function() { - Entry.playground.toggleLineBreak(!1); - v.innerHTML = Lang.Menus.linebreak_off_desc_1; - x.innerHTML = Lang.Menus.linebreak_off_desc_2; - y.innerHTML = Lang.Menus.linebreak_off_desc_3; - }); - e.src = Entry.mediaFilePath + "text-linebreak-off-true.png"; - b.appendChild(e); - this.linebreakOffImage = e; - e = Entry.createElement("img"); - e.bindOnClick(function() { - Entry.playground.toggleLineBreak(!0); - v.innerHTML = Lang.Menus.linebreak_on_desc_1; - x.innerHTML = Lang.Menus.linebreak_on_desc_2; - y.innerHTML = Lang.Menus.linebreak_on_desc_3; - }); - e.src = Entry.mediaFilePath + "text-linebreak-on-false.png"; - b.appendChild(e); - this.linebreakOnImage = e; - b = Entry.createElement("div"); - b.addClass("entryPlaygroundLinebreakDescription"); - a.appendChild(b); - var v = Entry.createElement("p"); - v.innerHTML = Lang.Menus.linebreak_off_desc_1; - b.appendChild(v); - a = Entry.createElement("ul"); - b.appendChild(a); - var x = Entry.createElement("li"); - x.innerHTML = Lang.Menus.linebreak_off_desc_2; - a.appendChild(x); - var y = Entry.createElement("li"); - y.innerHTML = Lang.Menus.linebreak_off_desc_3; - a.appendChild(y); -}; -Entry.Playground.prototype.generateSoundView = function(a) { - if ("workspace" == Entry.type) { - var b = Entry.createElement("div", "entryAddSound"); - b.addClass("entryPlaygroundAddSound"); - b.bindOnClick(function(a) { - Entry.dispatchEvent("openSoundManager"); + b.appendField = function(a, b) { + if (!a) { + return this; + } + "string" === typeof a && 0 < a.length ? b ? (a = {type:"Text", text:a, color:b}, this.params.push(a), this._addToParamsKeyMap(), this.templates.push(this.getFieldCount()), this.def && this.def.index && void 0 !== this.def.index[b] ? this.definition.params.push(this.def.params[this.def.index[b]]) : this.definition.params.push(void 0)) : this.templates.push(a) : a.constructor == Blockly.FieldIcon ? ("start" === a.type ? this.params.push({type:"Indicator", img:a.src_, size:17, position:{x:0, y:-2}}) : + this.params.push({type:"Indicator", img:a.src_, size:12}), this._addToParamsKeyMap(), this.templates.push(this.getFieldCount()), this.definition && this.definition.params.push(null)) : a.constructor == Blockly.FieldDropdown ? (this.params.push({type:"Dropdown", options:a.menuGenerator_, value:a.menuGenerator_[0][1], fontSize:11}), this._addToParamsKeyMap(b), this.templates.push(this.getFieldCount()), this.def && this.def.index && void 0 !== this.def.index[b] ? this.definition.params.push(this.def.params[this.def.index[b]]) : + this.definition.params.push(void 0)) : a.constructor == Blockly.FieldDropdownDynamic ? (this.params.push({type:"DropdownDynamic", value:null, menuName:a.menuName_, fontSize:11}), this.templates.push(this.getFieldCount()), this.def && this.def.index && void 0 !== this.def.index[b] ? this.definition.params.push(this.def.params[this.def.index[b]]) : this.definition.params.push(void 0), this._addToParamsKeyMap(b)) : a.constructor == Blockly.FieldTextInput ? (this.params.push({type:"TextInput", value:10}), + this.templates.push(this.getFieldCount()), this._addToParamsKeyMap(b)) : a.constructor == Blockly.FieldAngle ? (this.params.push({type:"Angle"}), this.templates.push(this.getFieldCount()), this.def && this.def.index && void 0 !== this.def.index[b] ? this.definition.params.push(this.def.params[this.def.index[b]]) : this.definition.params.push(null), this._addToParamsKeyMap(b)) : a.constructor == Blockly.FieldKeydownInput ? (this.params.push({type:"Keyboard", value:81}), this.templates.push(this.getFieldCount()), + void 0 !== this.def.index[b] ? this.definition.params.push(this.def.params[this.def.index[b]]) : this.definition.params.push(void 0), this._addToParamsKeyMap(b)) : a.constructor == Blockly.FieldColour ? (this.params.push({type:"Color"}), this.templates.push(this.getFieldCount()), this._addToParamsKeyMap(b)) : console.log("else", a); + return this; + }; + b.setColour = function(a) { + this.color = a; + }; + b.setInputsInline = function() { + }; + b.setOutput = function(a, b) { + a && (this.output = b); + }; + b.setPreviousStatement = function(a) { + this.isPrev = a; + }; + b.setNextStatement = function(a) { + this.isNext = a; + }; + b.setEditable = function(a) { + }; + b.getFieldCount = function() { + this.fieldCount++; + return "%" + this.fieldCount; + }; + b._addToParamsKeyMap = function(a) { + a = a ? a : "dummy_" + Entry.Utils.generateId(); + var b = this.paramsKeyMap; + b[a] = Object.keys(b).length; + }; + b._addToStatementsKeyMap = function(a) { + a = a ? a : "dummy_" + Entry.Utils.generateId(); + var b = this.statementsKeyMap; + b[a] = Object.keys(b).length; + }; +})(Entry.BlockMockup.prototype); +Entry.ContextMenu = {}; +(function(b) { + b.createDom = function() { + this.dom = Entry.Dom("ul", {id:"entry-contextmenu", parent:$("body")}); + Entry.Utils.disableContextmenu(this.dom); + Entry.documentMousedown.attach(this, function() { + this.hide(); }); - var c = Entry.createElement("div", "entryAddSoundInner"); - c.addClass("entryPlaygroundAddSoundInner"); - c.innerHTML = Lang.Workspace.sound_add; - b.appendChild(c); - a.appendChild(b); - b = Entry.createElement("ul", "entrySoundList"); - b.addClass("entryPlaygroundSoundList"); - $ && $(b).sortable({start:function(a, b) { - b.item.data("start_pos", b.item.index()); - }, stop:function(a, b) { - a = b.item.data("start_pos"); - b = b.item.index(); - Entry.playground.moveSound(a, b); - }, axis:"y"}); - a.appendChild(b); - this.soundListView_ = b; - } else { - "phone" == Entry.type && (b = Entry.createElement("div", "entryAddSound"), b.addClass("entryPlaygroundAddSoundPhone"), b.bindOnClick(function(a) { - Entry.dispatchEvent("openSoundManager"); - }), c = Entry.createElement("div", "entryAddSoundInner"), c.addClass("entryPlaygroundAddSoundInnerPhone"), c.innerHTML = Lang.Workspace.sound_add, b.appendChild(c), a.appendChild(b), b = Entry.createElement("ul", "entrySoundList"), b.addClass("entryPlaygroundSoundListPhone"), $ && $(b).sortable({start:function(a, b) { - b.item.data("start_pos", b.item.index()); - }, stop:function(a, b) { - a = b.item.data("start_pos"); - b = b.item.index(); - Entry.playground.moveSound(a, b); - }, axis:"y"}), a.appendChild(b), this.soundListView_ = b); + }; + b.show = function(a, b) { + this.dom || this.createDom(); + if (0 !== a.length) { + var d = this; + void 0 !== b && (this._className = b, this.dom.addClass(b)); + var e = this.dom; + e.empty(); + for (var f = 0, g = a.length;f < g;f++) { + var h = a[f], k = h.text, l = !1 !== h.enable, n = Entry.Dom("li", {class:l ? "menuAble" : "menuDisable", parent:e}); + n.text(k); + l && h.callback && function(a, b) { + a.mousedown(function(a) { + a.preventDefault(); + d.hide(); + b(a); + }); + }(n, h.callback); + } + e.removeClass("entryRemove"); + this.position(Entry.mouseCoordinate); + } + }; + b.position = function(a) { + var b = this.dom; + b.css({left:0, top:0}); + var d = b.width(), e = b.height(), f = $(window), g = f.width(), f = f.height(); + a.x + d > g && (a.x -= d + 3); + a.y + e > f && (a.y -= e); + b.css({left:a.x, top:a.y}); + }; + b.hide = function() { + this.dom.empty(); + this.dom.addClass("entryRemove"); + this._className && (this.dom.removeClass(this._className), delete this._className); + }; +})(Entry.ContextMenu); +Entry.Loader = {queueCount:0}; +Entry.Loader.addQueue = function(b) { + this.queueCount || Entry.dispatchEvent("loadStart"); + this.queueCount++; +}; +Entry.Loader.removeQueue = function(b) { + this.queueCount--; + this.queueCount || Entry.dispatchEvent("loadComplete"); +}; +Entry.STATIC = {OBJECT:0, ENTITY:1, SPRITE:2, SOUND:3, VARIABLE:4, FUNCTION:5, SCENE:6, MESSAGE:7, BLOCK_MODEL:8, BLOCK_RENDER_MODEL:9, BOX_MODEL:10, THREAD_MODEL:11, DRAG_INSTANCE:12, BLOCK_STATIC:0, BLOCK_MOVE:1, BLOCK_FOLLOW:2, RETURN:0, CONTINUE:1, BREAK:2, PASS:3}; +Entry.Utils = {}; +Entry.overridePrototype = function() { + Number.prototype.mod = function(b) { + return (this % b + b) % b; + }; +}; +Entry.Utils.generateId = function() { + return ("0000" + (Math.random() * Math.pow(36, 4) << 0).toString(36)).substr(-4); +}; +Entry.Utils.intersectArray = function(b, a) { + for (var c = [], d = 0;d < b.length;d++) { + for (var e = 0;e < a.length;e++) { + if (b[d] == a[e]) { + c.push(b[d]); + break; + } + } } + return c; }; -Entry.Playground.prototype.injectObject = function(a) { - if (!a) { - this.changeViewMode("code"), this.object = null; +Entry.Utils.isPointInMatrix = function(b, a, c) { + c = void 0 === c ? 0 : c; + var d = b.offsetX ? b.x + b.offsetX : b.x, e = b.offsetY ? b.y + b.offsety : b.y; + return d - c <= a.x && d + b.width + c >= a.x && e - c <= a.y && e + b.height + c >= a.y; +}; +Entry.Utils.colorDarken = function(b, a) { + function c(a) { + 2 != a.length && (a = "0" + a); + return a; + } + var d, e, f; + 7 === b.length ? (d = parseInt(b.substr(1, 2), 16), e = parseInt(b.substr(3, 2), 16), f = parseInt(b.substr(5, 2), 16)) : (d = parseInt(b.substr(1, 2), 16), e = parseInt(b.substr(2, 2), 16), f = parseInt(b.substr(3, 2), 16)); + a = void 0 === a ? .7 : a; + d = c(Math.floor(d * a).toString(16)); + e = c(Math.floor(e * a).toString(16)); + f = c(Math.floor(f * a).toString(16)); + return "#" + d + e + f; +}; +Entry.Utils.colorLighten = function(b, a) { + a = 0 === a ? 0 : a || 20; + var c = Entry.Utils.hexToHsl(b); + c.l += a / 100; + c.l = Math.min(1, Math.max(0, c.l)); + return Entry.Utils.hslToHex(c); +}; +Entry.Utils.bound01 = function(b, a) { + var c = b; + "string" == typeof c && -1 != c.indexOf(".") && 1 === parseFloat(c) && (b = "100%"); + c = "string" === typeof b && -1 != b.indexOf("%"); + b = Math.min(a, Math.max(0, parseFloat(b))); + c && (b = parseInt(b * a, 10) / 100); + return 1E-6 > Math.abs(b - a) ? 1 : b % a / parseFloat(a); +}; +Entry.Utils.hexToHsl = function(b) { + var a, c; + 7 === b.length ? (a = parseInt(b.substr(1, 2), 16), c = parseInt(b.substr(3, 2), 16), b = parseInt(b.substr(5, 2), 16)) : (a = parseInt(b.substr(1, 2), 16), c = parseInt(b.substr(2, 2), 16), b = parseInt(b.substr(3, 2), 16)); + a = Entry.Utils.bound01(a, 255); + c = Entry.Utils.bound01(c, 255); + b = Entry.Utils.bound01(b, 255); + var d = Math.max(a, c, b), e = Math.min(a, c, b), f, g = (d + e) / 2; + if (d == e) { + f = e = 0; } else { - if (a !== this.object) { - this.object && this.object.toggleInformation(!1); - this.object = a; - this.setMenu(a.objectType); - this.injectCode(); - "sprite" == a.objectType && Entry.pictureEditable ? (this.tabViewElements.text && this.tabViewElements.text.addClass("entryRemove"), this.tabViewElements.picture && this.tabViewElements.picture.removeClass("entryRemove")) : "textBox" == a.objectType && (this.tabViewElements.picture && this.tabViewElements.picture.addClass("entryRemove"), this.tabViewElements.text && this.tabViewElements.text.removeClass("entryRemove")); - var b = this.viewMode_; - "default" == b ? this.changeViewMode("code") : "picture" != b && "text" != b || "textBox" != a.objectType ? "text" != b && "picture" != b || "sprite" != a.objectType ? "sound" == b && this.changeViewMode("sound") : this.changeViewMode("picture") : this.changeViewMode("text"); - this.reloadPlayground(); + var h = d - e, e = .5 < g ? h / (2 - d - e) : h / (d + e); + switch(d) { + case a: + f = (c - b) / h + (c < b ? 6 : 0); + break; + case c: + f = (b - a) / h + 2; + break; + case b: + f = (a - c) / h + 4; } + f /= 6; } + return {h:360 * f, s:e, l:g}; }; -Entry.Playground.prototype.injectCode = function() { - var a = this.mainWorkspace; - a.changeBoardCode(this.object.script); - a.getBoard().adjustThreadsPosition(); +Entry.Utils.hslToHex = function(b) { + function a(a, b, c) { + 0 > c && (c += 1); + 1 < c && --c; + return c < 1 / 6 ? a + 6 * (b - a) * c : .5 > c ? b : c < 2 / 3 ? a + (b - a) * (2 / 3 - c) * 6 : a; + } + function c(a) { + return 1 == a.length ? "0" + a : "" + a; + } + var d, e; + e = Entry.Utils.bound01(b.h, 360); + d = Entry.Utils.bound01(b.s, 1); + b = Entry.Utils.bound01(b.l, 1); + if (0 === d) { + d = b = e = b; + } else { + var f = .5 > b ? b * (1 + d) : b + d - b * d, g = 2 * b - f; + d = a(g, f, e + 1 / 3); + b = a(g, f, e); + e = a(g, f, e - 1 / 3); + } + b *= 255; + e *= 255; + return "#" + [c(Math.round(255 * d).toString(16)), c(Math.round(b).toString(16)), c(Math.round(e).toString(16))].join(""); }; -Entry.Playground.prototype.injectPicture = function() { - var a = this.pictureListView_; - if (a) { - for (;a.hasChildNodes();) { - a.removeChild(a.lastChild); +Entry.Utils.bindGlobalEvent = function(b) { + var a = $(document); + void 0 === b && (b = "resize mousedown mousemove keydown keyup dispose".split(" ")); + -1 < b.indexOf("resize") && (Entry.windowReszied && ($(window).off("resize"), Entry.windowReszied.clear()), Entry.windowResized = new Entry.Event(window), $(window).on("resize", function(a) { + Entry.windowResized.notify(a); + })); + -1 < b.indexOf("mousedown") && (Entry.documentMousedown && (a.off("mousedown"), Entry.documentMousedown.clear()), Entry.documentMousedown = new Entry.Event(window), a.on("mousedown", function(a) { + Entry.documentMousedown.notify(a); + })); + -1 < b.indexOf("mousemove") && (Entry.documentMousemove && (a.off("touchmove mousemove"), Entry.documentMousemove.clear()), Entry.mouseCoordinate = {}, Entry.documentMousemove = new Entry.Event(window), a.on("touchmove mousemove", function(a) { + a.originalEvent && a.originalEvent.touches && (a = a.originalEvent.touches[0]); + Entry.documentMousemove.notify(a); + Entry.mouseCoordinate.x = a.clientX; + Entry.mouseCoordinate.y = a.clientY; + })); + -1 < b.indexOf("keydown") && (Entry.keyPressed && (a.off("keydown"), Entry.keyPressed.clear()), Entry.pressedKeys = [], Entry.keyPressed = new Entry.Event(window), a.on("keydown", function(a) { + var b = a.keyCode; + 0 > Entry.pressedKeys.indexOf(b) && Entry.pressedKeys.push(b); + Entry.keyPressed.notify(a); + })); + -1 < b.indexOf("keyup") && (Entry.keyUpped && (a.off("keyup"), Entry.keyUpped.clear()), Entry.keyUpped = new Entry.Event(window), a.on("keyup", function(a) { + var b = Entry.pressedKeys.indexOf(a.keyCode); + -1 < b && Entry.pressedKeys.splice(b, 1); + Entry.keyUpped.notify(a); + })); + -1 < b.indexOf("dispose") && (Entry.disposeEvent && Entry.disposeEvent.clear(), Entry.disposeEvent = new Entry.Event(window), Entry.documentMousedown && Entry.documentMousedown.attach(this, function(a) { + Entry.disposeEvent.notify(a); + })); +}; +Entry.Utils.makeActivityReporter = function() { + Entry.activityReporter = new Entry.ActivityReporter; + Entry.commander && Entry.commander.addReporter(Entry.activityReporter); + return Entry.activityReporter; +}; +Entry.Utils.initEntryEvent_ = function() { + Entry.events_ || (Entry.events_ = []); +}; +Entry.sampleColours = []; +Entry.assert = function(b, a) { + if (!b) { + throw Error(a || "Assert failed"); + } +}; +Entry.parseTexttoXML = function(b) { + var a; + window.ActiveXObject ? (a = new ActiveXObject("Microsoft.XMLDOM"), a.async = "false", a.loadXML(b)) : a = (new DOMParser).parseFromString(b, "text/xml"); + return a; +}; +Entry.createElement = function(b, a) { + var c = document.createElement(b); + a && (c.id = a); + c.hasClass = function(a) { + return this.className.match(new RegExp("(\\s|^)" + a + "(\\s|$)")); + }; + c.addClass = function(a) { + for (var b = 0;b < arguments.length;b++) { + a = arguments[b], this.hasClass(a) || (this.className += " " + a); } - if (this.object) { - for (var b = this.object.pictures, c = 0, d = b.length;c < d;c++) { - var e = b[c].view; - e || console.log(e); - e.orderHolder.innerHTML = c + 1; - a.appendChild(e); + }; + c.removeClass = function(a) { + for (var b = 0;b < arguments.length;b++) { + a = arguments[b], this.hasClass(a) && (this.className = this.className.replace(new RegExp("(\\s|^)" + a + "(\\s|$)"), " ")); + } + }; + c.bindOnClick = function(a) { + $(this).on("click tab", function(b) { + b.stopImmediatePropagation(); + a.call(this, b); + }); + }; + return c; +}; +Entry.makeAutolink = function(b) { + return b ? b.replace(/(http|https|ftp|telnet|news|irc):\/\/([-/.a-zA-Z0-9_~#%$?&=:200-377()][^)\]}]+)/gi, "$1://$2").replace(/([xA1-xFEa-z0-9_-]+@[xA1-xFEa-z0-9-]+.[a-z0-9-]+)/gi, "$1") : ""; +}; +Entry.generateHash = function() { + return ("0000" + (Math.random() * Math.pow(36, 4) << 0).toString(36)).substr(-4); +}; +Entry.addEventListener = function(b, a) { + this.events_ || (this.events_ = {}); + this.events_[b] || (this.events_[b] = []); + a instanceof Function && this.events_[b].push(a); + return !0; +}; +Entry.dispatchEvent = function(b, a) { + this.events_ || (this.events_ = {}); + if (this.events_[b]) { + for (var c = 0, d = this.events_[b].length;c < d;c++) { + this.events_[b][c].call(window, a); + } + } +}; +Entry.removeEventListener = function(b, a) { + if (this.events_[b]) { + for (var c = 0, d = this.events_[b].length;c < d;c++) { + if (this.events_[b][c] === a) { + this.events_[b].splice(c, 1); + break; } - this.selectPicture(this.object.selectedPicture); - } else { - Entry.dispatchEvent("pictureClear"); } } }; -Entry.Playground.prototype.addPicture = function(a, b) { - a = Entry.cloneSimpleObject(a); - delete a.id; - delete a.view; - a = JSON.parse(JSON.stringify(a)); - a.id = Entry.generateHash(); - a.name = Entry.getOrderedName(a.name, this.object.pictures); - this.generatePictureElement(a); - this.object.addPicture(a); - this.injectPicture(); - this.selectPicture(a); +Entry.removeAllEventListener = function(b) { + this.events_ && this.events_[b] && delete this.events_[b]; +}; +Entry.addTwoNumber = function(b, a) { + if (isNaN(b) || isNaN(a)) { + return b + a; + } + b += ""; + a += ""; + var c = b.indexOf("."), d = a.indexOf("."), e = 0, f = 0; + 0 < c && (e = b.length - c - 1); + 0 < d && (f = a.length - d - 1); + return 0 < e || 0 < f ? e >= f ? (parseFloat(b) + parseFloat(a)).toFixed(e) : (parseFloat(b) + parseFloat(a)).toFixed(f) : parseInt(b) + parseInt(a); +}; +Entry.hex2rgb = function(b) { + return (b = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(b)) ? {r:parseInt(b[1], 16), g:parseInt(b[2], 16), b:parseInt(b[3], 16)} : null; +}; +Entry.rgb2hex = function(b, a, c) { + return "#" + (16777216 + (b << 16) + (a << 8) + c).toString(16).slice(1); +}; +Entry.generateRgb = function() { + return {r:Math.floor(256 * Math.random()), g:Math.floor(256 * Math.random()), b:Math.floor(256 * Math.random())}; }; -Entry.Playground.prototype.setPicture = function(a) { - var b = Entry.container.getPictureElement(a.id, a.objectId), c = $(b); - if (b) { - a.view = b; - b.picture = a; - b = c.find("#t_" + a.id)[0]; - if (a.fileurl) { - b.style.backgroundImage = 'url("' + a.fileurl + '")'; - } else { - var d = a.filename; - b.style.backgroundImage = 'url("' + Entry.defaultPath + "/uploads/" + d.substring(0, 2) + "/" + d.substring(2, 4) + "/thumb/" + d + '.png")'; +Entry.adjustValueWithMaxMin = function(b, a, c) { + return b > c ? c : b < a ? a : b; +}; +Entry.isExist = function(b, a, c) { + for (var d = 0;d < c.length;d++) { + if (c[d][a] == b) { + return c[d]; } - c.find("#s_" + a.id)[0].innerHTML = a.dimension.width + " X " + a.dimension.height; } - Entry.container.setPicture(a); + return !1; +}; +Entry.getColourCodes = function() { + return "transparent #660000 #663300 #996633 #003300 #003333 #003399 #000066 #330066 #660066 #FFFFFF #990000 #993300 #CC9900 #006600 #336666 #0033FF #000099 #660099 #990066 #000000 #CC0000 #CC3300 #FFCC00 #009900 #006666 #0066FF #0000CC #663399 #CC0099 #333333 #FF0000 #FF3300 #FFFF00 #00CC00 #009999 #0099FF #0000FF #9900CC #FF0099 #666666 #CC3333 #FF6600 #FFFF33 #00FF00 #00CCCC #00CCFF #3366FF #9933FF #FF00FF #999999 #FF6666 #FF6633 #FFFF66 #66FF66 #66CCCC #00FFFF #3399FF #9966FF #FF66FF #BBBBBB #FF9999 #FF9966 #FFFF99 #99FF99 #66FFCC #99FFFF #66CCff #9999FF #FF99FF #CCCCCC #FFCCCC #FFCC99 #FFFFCC #CCFFCC #99FFCC #CCFFFF #99CCFF #CCCCFF #FFCCFF".split(" "); }; -Entry.Playground.prototype.clonePicture = function(a) { - a = Entry.playground.object.getPicture(a); - this.addPicture(a, !0); +Entry.removeElement = function(b) { + b && b.parentNode && b.parentNode.removeChild(b); }; -Entry.Playground.prototype.selectPicture = function(a) { - for (var b = this.object.pictures, c = 0, d = b.length;c < d;c++) { - var e = b[c]; - e.id === a.id ? e.view.addClass("entryPictureSelected") : e.view.removeClass("entryPictureSelected"); +Entry.getElementsByClassName = function(b) { + for (var a = [], c = document.getElementsByTagName("*"), d = 0;d < c.length;d++) { + -1 < (" " + c[d].className + " ").indexOf(" " + b + " ") && a.push(c[d]); } - var f; - a && a.id && (f = Entry.container.selectPicture(a.id, a.objectId)); - this.object.id === f && Entry.dispatchEvent("pictureSelected", a); + return a; }; -Entry.Playground.prototype.movePicture = function(a, b) { - this.object.pictures.splice(b, 0, this.object.pictures.splice(a, 1)[0]); - this.injectPicture(); - Entry.stage.sortZorder(); +Entry.parseNumber = function(b) { + return "string" != typeof b || isNaN(+b) ? "number" != typeof b || isNaN(+b) ? !1 : b : +b; }; -Entry.Playground.prototype.injectText = function() { - if (Entry.playground.object) { - Entry.playground.textEditInput.value = Entry.playground.object.entity.getText(); - Entry.playground.textEditArea.value = Entry.playground.object.entity.getText(); - Entry.playground.fontName_.value = Entry.playground.object.entity.getFontName(); - if (Entry.playground.object.entity.font) { - var a = -1 < Entry.playground.object.entity.font.indexOf("bold") || !1; - $("#entryPlaygroundText_boldImage").attr("src", Entry.mediaFilePath + "text_button_bold_" + a + ".png"); - a = -1 < Entry.playground.object.entity.font.indexOf("italic") || !1; - $("#entryPlaygroundText_italicImage").attr("src", Entry.mediaFilePath + "text_button_italic_" + a + ".png"); - } - a = Entry.playground.object.entity.getUnderLine() || !1; - $("#entryPlaygroundText_underlineImage").attr("src", Entry.mediaFilePath + "text_button_underline_" + a + ".png"); - a = Entry.playground.object.entity.getStrike() || !1; - $("#entryPlaygroundText_strikeImage").attr("src", Entry.mediaFilePath + "text_button_strike_" + a + ".png"); - $(".entryPlayground_fgColorDiv").css("backgroundColor", Entry.playground.object.entity.colour); - $(".entryPlayground_bgColorDiv").css("backgroundColor", Entry.playground.object.entity.bgColour); - Entry.playground.toggleLineBreak(Entry.playground.object.entity.getLineBreak()); - Entry.playground.object.entity.getLineBreak() && ($(".entryPlaygroundLinebreakDescription > p").html(Lang.Menus.linebreak_on_desc_1), $(".entryPlaygroundLinebreakDescription > ul > li").eq(0).html(Lang.Menus.linebreak_on_desc_2), $(".entryPlaygroundLinebreakDescription > ul > li").eq(1).html(Lang.Menus.linebreak_on_desc_3)); - Entry.playground.setFontAlign(Entry.playground.object.entity.getTextAlign()); - a = Entry.playground.object.entity.getFontSize(); - Entry.playground.fontSizeIndiciator.style.width = a + "%"; - Entry.playground.fontSizeKnob.style.left = .88 * a + "px"; +Entry.countStringLength = function(b) { + var a, c = 0; + for (a = 0;a < b.length;a++) { + 255 < b.charCodeAt(a) ? c += 2 : c++; } + return c; }; -Entry.Playground.prototype.injectSound = function() { - var a = this.soundListView_; - if (a) { - for (;a.hasChildNodes();) { - a.removeChild(a.lastChild); - } - if (this.object) { - for (var b = this.object.sounds, c = 0, d = b.length;c < d;c++) { - var e = b[c].view; - e.orderHolder.innerHTML = c + 1; - a.appendChild(e); +Entry.cutStringByLength = function(b, a) { + var c, d = 0; + for (c = 0;d < a && c < b.length;c++) { + 255 < b.charCodeAt(c) ? d += 2 : d++; + } + return b.substr(0, c); +}; +Entry.isChild = function(b, a) { + if (!a) { + for (;a.parentNode;) { + if ((a = a.parentNode) == b) { + return !0; } } } + return !1; }; -Entry.Playground.prototype.moveSound = function(a, b) { - this.object.sounds.splice(b, 0, this.object.sounds.splice(a, 1)[0]); - this.updateListViewOrder("sound"); - Entry.stage.sortZorder(); +Entry.launchFullScreen = function(b) { + b.requestFullscreen ? b.requestFullscreen() : b.mozRequestFulScreen ? b.mozRequestFulScreen() : b.webkitRequestFullscreen ? b.webkitRequestFullscreen() : b.msRequestFullScreen && b.msRequestFullScreen(); }; -Entry.Playground.prototype.addSound = function(a, b) { - a = Entry.cloneSimpleObject(a); - delete a.view; - delete a.id; - a = JSON.parse(JSON.stringify(a)); - a.id = Entry.generateHash(); - a.name = Entry.getOrderedName(a.name, this.object.sounds); - this.generateSoundElement(a); - this.object.addSound(a); - this.injectSound(); +Entry.exitFullScreen = function() { + document.exitFullScreen ? document.exitFullScreen() : document.mozCancelFullScreen ? document.mozCancelFullScreen() : document.webkitExitFullscreen && document.webkitExitFullscreen(); }; -Entry.Playground.prototype.changeViewMode = function(a) { - for (var b in this.tabViewElements) { - this.tabViewElements[b].removeClass("entryTabSelected"); - } - "default" != a && this.tabViewElements[a].addClass("entryTabSelected"); - if ("variable" != a) { - var c = this.view_.children; - for (b = 0;b < c.length;b++) { - var d = c[b]; - -1 < d.id.toUpperCase().indexOf(a.toUpperCase()) ? d.removeClass("entryRemove") : d.addClass("entryRemove"); - } - if ("picture" == a && (!this.pictureView_.object || this.pictureView_.object != this.object)) { - this.pictureView_.object = this.object, this.injectPicture(); - } else { - if ("sound" == a && (!this.soundView_.object || this.soundView_.object != this.object)) { - this.soundView_.object = this.object, this.injectSound(); - } else { - if ("text" == a && "textBox" == this.object.objectType || this.textView_.object != this.object) { - this.textView_.object = this.object, this.injectText(); - } - } - } - "code" == a && this.resizeHandle_ && this.resizeHandle_.removeClass("entryRemove"); - Entry.engine.isState("run") && this.curtainView_.removeClass("entryRemove"); - this.viewMode_ = a; - this.toggleOffVariableView(); - } +Entry.isPhone = function() { + return !1; }; -Entry.Playground.prototype.createVariableView = function() { - var a = Entry.createElement("div"); - Entry.type && "workspace" != Entry.type ? "phone" == Entry.type && a.addClass("entryVariablePanelPhone") : a.addClass("entryVariablePanelWorkspace"); - this.variableViewWrapper_ = a; - Entry.variableContainer.createDom(a); - return a; +Entry.getKeyCodeMap = function() { + return {65:"a", 66:"b", 67:"c", 68:"d", 69:"e", 70:"f", 71:"g", 72:"h", 73:"i", 74:"j", 75:"k", 76:"l", 77:"m", 78:"n", 79:"o", 80:"p", 81:"q", 82:"r", 83:"s", 84:"t", 85:"u", 86:"v", 87:"w", 88:"x", 89:"y", 90:"z", 32:Lang.Blocks.START_press_some_key_space, 37:Lang.Blocks.START_press_some_key_left, 38:Lang.Blocks.START_press_some_key_up, 39:Lang.Blocks.START_press_some_key_right, 40:Lang.Blocks.START_press_some_key_down, 48:"0", 49:"1", 50:"2", 51:"3", 52:"4", 53:"5", 54:"6", 55:"7", 56:"8", 57:"9", + 13:Lang.Blocks.START_press_some_key_enter}; }; -Entry.Playground.prototype.toggleOnVariableView = function() { - Entry.playground.changeViewMode("code"); - this.hideBlockMenu(); - Entry.variableContainer.updateList(); - this.variableView_.removeClass("entryRemove"); - this.resizeHandle_.removeClass("entryRemove"); +Entry.checkCollisionRect = function(b, a) { + return !(b.y + b.height < a.y || b.y > a.y + a.height || b.x + b.width < a.x || b.x > a.x + a.width); }; -Entry.Playground.prototype.toggleOffVariableView = function() { - this.showBlockMenu(); - this.variableView_.addClass("entryRemove"); +Entry.bindAnimationCallback = function(b, a) { + b.addEventListener("webkitAnimationEnd", a, !1); + b.addEventListener("animationend", a, !1); + b.addEventListener("oanimationend", a, !1); }; -Entry.Playground.prototype.editBlock = function() { - var a = Entry.playground; - Entry.stateManager && Entry.stateManager.addCommand("edit block", a, a.restoreBlock, a.object, a.object.getScriptText()); +Entry.cloneSimpleObject = function(b) { + var a = {}, c; + for (c in b) { + a[c] = b[c]; + } + return a; }; -Entry.Playground.prototype.mouseupBlock = function() { - if (Entry.reporter) { - var a = Entry.playground, b = a.object; - Entry.reporter.report(new Entry.State("edit block mouseup", a, a.restoreBlock, b, b.getScriptText())); +Entry.nodeListToArray = function(b) { + for (var a = Array(b.length), c = -1, d = b.length;++c !== d;a[c] = b[c]) { } + return a; }; -Entry.Playground.prototype.restoreBlock = function(a, b) { - Entry.container.selectObject(a.id); - Entry.stateManager && Entry.stateManager.addCommand("restore block", this, this.restoreBlock, this.object, this.object.getScriptText()); - Blockly.Xml.textToDom(b); +Entry.computeInputWidth = function(b) { + var a = document.createElement("span"); + a.className = "tmp-element"; + a.innerHTML = b.replace(/&/g, "&").replace(//g, ">"); + document.body.appendChild(a); + b = a.offsetWidth; + document.body.removeChild(a); + return +(b + 10) + "px"; }; -Entry.Playground.prototype.setMenu = function(a) { - if (this.currentObjectType != a) { - var b = this.blockMenu; - b.unbanClass(this.currentObjectType); - b.banClass(a); - b.setMenu(); - b.selectMenu(0, !0); - this.currentObjectType = a; +Entry.isArrowOrBackspace = function(b) { + return -1 < [37, 38, 39, 40, 8].indexOf(b); +}; +Entry.hexStringToBin = function(b) { + for (var a = [], c = 0;c < b.length - 1;c += 2) { + a.push(parseInt(b.substr(c, 2), 16)); } + return String.fromCharCode.apply(String, a); }; -Entry.Playground.prototype.hideTabs = function() { - var a = ["picture", "text", "sound", "variable"], b; - for (b in a) { - this.hideTab([a[b]]); +Entry.findObjsByKey = function(b, a, c) { + for (var d = [], e = 0;e < b.length;e++) { + b[e][a] == c && d.push(b[e]); } + return d; }; -Entry.Playground.prototype.hideTab = function(a) { - this.tabViewElements[a] && (this.tabViewElements[a].addClass("hideTab"), this.tabViewElements[a].removeClass("showTab")); +Entry.factorials = []; +Entry.factorial = function(b) { + return 0 === b || 1 == b ? 1 : 0 < Entry.factorials[b] ? Entry.factorials[b] : Entry.factorials[b] = Entry.factorial(b - 1) * b; }; -Entry.Playground.prototype.showTabs = function() { - var a = ["picture", "text", "sound", "variable"], b; - for (b in a) { - this.showTab(a[b]); +Entry.getListRealIndex = function(b, a) { + if (isNaN(b)) { + switch(b) { + case "FIRST": + b = 1; + break; + case "LAST": + b = a.array_.length; + break; + case "RANDOM": + b = Math.floor(Math.random() * a.array_.length) + 1; + } } + return b; }; -Entry.Playground.prototype.showTab = function(a) { - this.tabViewElements[a] && (this.tabViewElements[a].addClass("showTab"), this.tabViewElements[a].removeClass("hideTab")); +Entry.toRadian = function(b) { + return b * Math.PI / 180; }; -Entry.Playground.prototype.initializeResizeHandle = function(a) { - a.onmousedown = function(a) { - Entry.playground.resizing = !0; - Entry.documentMousemove && (Entry.playground.resizeEvent = Entry.documentMousemove.attach(this, function(a) { - Entry.playground.resizing && Entry.resizeElement({menuWidth:a.clientX - Entry.interfaceState.canvasWidth}); - })); - }; - document.addEventListener("mouseup", function(a) { - if (a = Entry.playground.resizeEvent) { - Entry.playground.resizing = !1, Entry.documentMousemove.detach(a), delete Entry.playground.resizeEvent; - } - }); +Entry.toDegrees = function(b) { + return 180 * b / Math.PI; }; -Entry.Playground.prototype.reloadPlayground = function() { - var a = this.mainWorkspace; - a && (a.getBlockMenu().reDraw(), this.object && this.object.script.view.reDraw()); +Entry.getPicturesJSON = function(b) { + for (var a = [], c = 0, d = b.length;c < d;c++) { + var e = b[c], f = {}; + f._id = e._id; + f.id = e.id; + f.dimension = e.dimension; + f.filename = e.filename; + f.fileurl = e.fileurl; + f.name = e.name; + f.scale = e.scale; + a.push(f); + } + return a; }; -Entry.Playground.prototype.flushPlayground = function() { - this.object = null; - if (Entry.playground && Entry.playground.view_) { - this.injectPicture(); - this.injectSound(); - var a = Entry.playground.mainWorkspace.getBoard(); - a.clear(); - a.changeCode(null); +Entry.getSoundsJSON = function(b) { + for (var a = [], c = 0, d = b.length;c < d;c++) { + var e = b[c], f = {}; + f._id = e._id; + f.duration = e.duration; + f.ext = e.ext; + f.id = e.id; + f.filename = e.filename; + f.fileurl = e.fileurl; + f.name = e.name; + a.push(f); } + return a; }; -Entry.Playground.prototype.refreshPlayground = function() { - Entry.playground && Entry.playground.view_ && ("picture" === this.getViewMode() && this.injectPicture(), "sound" === this.getViewMode() && this.injectSound()); +Entry.cutDecimal = function(b) { + return Math.round(100 * b) / 100; }; -Entry.Playground.prototype.updateListViewOrder = function(a) { - a = "picture" == a ? this.pictureListView_.childNodes : this.soundListView_.childNodes; - for (var b = 0, c = a.length;b < c;b++) { - a[b].orderHolder.innerHTML = b + 1; +Entry.getBrowserType = function() { + if (Entry.userAgent) { + return Entry.userAgent; } -}; -Entry.Playground.prototype.generatePictureElement = function(a) { - function b() { - if ("" === this.value.trim()) { - Entry.deAttachEventListener(this, "blur", b), alert("\uc774\ub984\uc744 \uc785\ub825\ud558\uc5ec \uc8fc\uc138\uc694."), this.focus(), Entry.attachEventListener(this, "blur", b); - } else { - for (var a = $(".entryPlaygroundPictureName"), c = 0;c < a.length;c++) { - if (a.eq(c).val() == f.value && a[c] != this) { - Entry.deAttachEventListener(this, "blur", b); - alert("\uc774\ub984\uc774 \uc911\ubcf5 \ub418\uc5c8\uc2b5\ub2c8\ub2e4."); - this.focus(); - Entry.attachEventListener(this, "blur", b); - return; - } - } - this.picture.name = this.value; - Entry.playground.reloadPlayground(); - Entry.dispatchEvent("pictureNameChanged", this.picture); - } + var b = navigator.userAgent, a, c = b.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || []; + if (/trident/i.test(c[1])) { + return a = /\brv[ :]+(\d+)/g.exec(b) || [], "IE " + (a[1] || ""); } - var c = Entry.createElement("li", a.id); - a.view = c; - c.addClass("entryPlaygroundPictureElement"); - c.picture = a; - c.bindOnClick(function(a) { - Entry.playground.selectPicture(this.picture); - }); - Entry.Utils.disableContextmenu(a.view); - $(a.view).on("contextmenu", function() { - Entry.ContextMenu.show([{text:Lang.Workspace.context_rename, callback:function() { - f.focus(); - }}, {text:Lang.Workspace.context_duplicate, callback:function() { - Entry.playground.clonePicture(a.id); - }}, {text:Lang.Workspace.context_remove, callback:function() { - Entry.playground.object.removePicture(a.id) ? (Entry.removeElement(c), Entry.toast.success(Lang.Workspace.shape_remove_ok, a.name + " " + Lang.Workspace.shape_remove_ok_msg)) : Entry.toast.alert(Lang.Workspace.shape_remove_fail, Lang.Workspace.shape_remove_fail_msg); - }}, {divider:!0}, {text:Lang.Workspace.context_download, callback:function() { - a.fileurl ? window.open(a.fileurl) : window.open("/api/sprite/download/image/" + encodeURIComponent(a.filename) + "/" + encodeURIComponent(a.name) + ".png"); - }}], "workspace-contextmenu"); - }); - var d = Entry.createElement("div"); - d.addClass("entryPlaygroundPictureOrder"); - c.orderHolder = d; - c.appendChild(d); - d = Entry.createElement("div", "t_" + a.id); - d.addClass("entryPlaygroundPictureThumbnail"); - if (a.fileurl) { - d.style.backgroundImage = 'url("' + a.fileurl + '")'; - } else { - var e = a.filename; - d.style.backgroundImage = 'url("' + Entry.defaultPath + "/uploads/" + e.substring(0, 2) + "/" + e.substring(2, 4) + "/thumb/" + e + '.png")'; + if ("Chrome" === c[1] && (a = b.match(/\b(OPR|Edge)\/(\d+)/), null != a)) { + return a.slice(1).join(" ").replace("OPR", "Opera"); } - c.appendChild(d); - var f = Entry.createElement("input"); - f.addClass("entryPlaygroundPictureName"); - f.addClass("entryEllipsis"); - f.picture = a; - f.value = a.name; - Entry.attachEventListener(f, "blur", b); - f.onkeypress = function(a) { - 13 == a.keyCode && this.blur(); - }; - c.appendChild(f); - d = Entry.createElement("div", "s_" + a.id); - d.addClass("entryPlaygroundPictureSize"); - d.innerHTML = a.dimension.width + " X " + a.dimension.height; - c.appendChild(d); -}; -Entry.Playground.prototype.generateSoundElement = function(a) { - var b = Entry.createElement("sound", a.id); - a.view = b; - b.addClass("entryPlaygroundSoundElement"); - b.sound = a; - Entry.Utils.disableContextmenu(a.view); - $(a.view).on("contextmenu", function() { - Entry.ContextMenu.show([{text:Lang.Workspace.context_rename, callback:function() { - g.focus(); - }}, {text:Lang.Workspace.context_duplicate, callback:function() { - Entry.playground.addSound(a, !0); - }}, {text:Lang.Workspace.context_remove, callback:function() { - Entry.playground.object.removeSound(a.id) ? (Entry.removeElement(b), Entry.toast.success(Lang.Workspace.sound_remove_ok, a.name + " " + Lang.Workspace.sound_remove_ok_msg)) : Entry.toast.alert(Lang.Workspace.sound_remove_fail, ""); - Entry.removeElement(b); - }}], "workspace-contextmenu"); - }); - var c = Entry.createElement("div"); - c.addClass("entryPlaygroundSoundOrder"); - b.orderHolder = c; - b.appendChild(c); - var d = Entry.createElement("div"); - d.addClass("entryPlaygroundSoundThumbnail"); - d.addClass("entryPlaygroundSoundPlay"); - var e = !1, f; - d.addEventListener("click", function() { - e ? (e = !1, d.removeClass("entryPlaygroundSoundStop"), d.addClass("entryPlaygroundSoundPlay"), f.stop()) : (e = !0, d.removeClass("entryPlaygroundSoundPlay"), d.addClass("entryPlaygroundSoundStop"), f = createjs.Sound.play(a.id), f.addEventListener("complete", function(a) { - d.removeClass("entryPlaygroundSoundStop"); - d.addClass("entryPlaygroundSoundPlay"); - e = !1; - }), f.addEventListener("loop", function(a) { - }), f.addEventListener("failed", function(a) { - })); - }); - b.appendChild(d); - var g = Entry.createElement("input"); - g.addClass("entryPlaygroundSoundName"); - g.sound = a; - g.value = a.name; - var h = document.getElementsByClassName("entryPlaygroundSoundName"); - g.onblur = function() { - if ("" === this.value) { - alert("\uc774\ub984\uc744 \uc785\ub825\ud558\uc5ec \uc8fc\uc138\uc694."), this.focus(); - } else { - for (var a = 0, b = 0;b < h.length;b++) { - if (h[b].value == g.value && (a += 1, 1 < a)) { - alert("\uc774\ub984\uc774 \uc911\ubcf5 \ub418\uc5c8\uc2b5\ub2c8\ub2e4."); - this.focus(); - return; - } - } - this.sound.name = this.value; - Entry.playground.reloadPlayground(); - } - }; - g.onkeypress = function(a) { - 13 == a.keyCode && this.blur(); - }; - b.appendChild(g); - c = Entry.createElement("div"); - c.addClass("entryPlaygroundSoundLength"); - c.innerHTML = a.duration + " \ucd08"; - b.appendChild(c); -}; -Entry.Playground.prototype.toggleColourChooser = function(a) { - "foreground" === a ? "none" === this.coloursWrapper.style.display ? (this.coloursWrapper.style.display = "block", this.backgroundsWrapper.style.display = "none") : this.coloursWrapper.style.display = "none" : "background" === a && ("none" === this.backgroundsWrapper.style.display ? (this.backgroundsWrapper.style.display = "block", this.coloursWrapper.style.display = "none") : this.backgroundsWrapper.style.display = "none"); -}; -Entry.Playground.prototype.setTextColour = function(a) { - Entry.playground.object.entity.setColour(a); - Entry.playground.toggleColourChooser("foreground"); - $(".entryPlayground_fgColorDiv").css("backgroundColor", a); -}; -Entry.Playground.prototype.setBackgroundColour = function(a) { - Entry.playground.object.entity.setBGColour(a); - Entry.playground.toggleColourChooser("background"); - $(".entryPlayground_bgColorDiv").css("backgroundColor", a); + c = c[2] ? [c[1], c[2]] : [navigator.appName, navigator.appVersion, "-?"]; + null != (a = b.match(/version\/(\d+)/i)) && c.splice(1, 1, a[1]); + b = c.join(" "); + return Entry.userAgent = b; +}; +Entry.setBasicBrush = function(b) { + var a = new createjs.Graphics; + a.thickness = 1; + a.rgb = Entry.hex2rgb("#ff0000"); + a.opacity = 100; + a.setStrokeStyle(1); + a.beginStroke("rgba(255,0,0,1)"); + var c = new createjs.Shape(a); + Entry.stage.selectedObjectContainer.addChild(c); + b.brush && (b.brush = null); + b.brush = a; + b.shape && (b.shape = null); + b.shape = c; }; -Entry.Playground.prototype.isTextBGMode = function() { - return this.isTextBGMode_; +Entry.setCloneBrush = function(b, a) { + var c = new createjs.Graphics; + c.thickness = a.thickness; + c.rgb = a.rgb; + c.opacity = a.opacity; + c.setStrokeStyle(c.thickness); + c.beginStroke("rgba(" + c.rgb.r + "," + c.rgb.g + "," + c.rgb.b + "," + c.opacity / 100 + ")"); + var d = new createjs.Shape(c); + Entry.stage.selectedObjectContainer.addChild(d); + b.brush && (b.brush = null); + b.brush = c; + b.shape && (b.shape = null); + b.shape = d; }; -Entry.Playground.prototype.checkVariables = function() { - Entry.forEBS || (Entry.variableContainer.lists_.length ? this.blockMenu.unbanClass("listNotExist") : this.blockMenu.banClass("listNotExist"), Entry.variableContainer.variables_.length ? this.blockMenu.unbanClass("variableNotExist") : this.blockMenu.banClass("variableNotExist")); +Entry.isFloat = function(b) { + return /\d+\.{1}\d+/.test(b); }; -Entry.Playground.prototype.getViewMode = function() { - return this.viewMode_; +Entry.getStringIndex = function(b) { + if (!b) { + return ""; + } + for (var a = {string:b, index:1}, c = 0, d = [], e = b.length - 1;0 < e;--e) { + var f = b.charAt(e); + if (isNaN(f)) { + break; + } else { + d.unshift(f), c = e; + } + } + 0 < c && (a.string = b.substring(0, c), a.index = parseInt(d.join("")) + 1); + return a; }; -Entry.Playground.prototype.updateHW = function() { - var a = Entry.playground.mainWorkspace.blockMenu; - if (a) { - var b = Entry.hw; - b && b.connected ? (a.unbanClass("arduinoConnected", !0), a.banClass("arduinoDisconnected", !0), b.banHW(), b.hwModule && a.unbanClass(b.hwModule.name)) : (a.banClass("arduinoConnected", !0), a.unbanClass("arduinoDisconnected", !0), Entry.hw.banHW()); - a.reDraw(); +Entry.getOrderedName = function(b, a, c) { + if (!b) { + return "untitled"; + } + if (!a || 0 === a.length) { + return b; + } + c || (c = "name"); + for (var d = 0, e = Entry.getStringIndex(b), f = 0, g = a.length;f < g;f++) { + var h = Entry.getStringIndex(a[f][c]); + e.string === h.string && h.index > d && (d = h.index); } + return 0 < d ? e.string + d : b; }; -Entry.Playground.prototype.toggleLineBreak = function(a) { - this.object && "textBox" == this.object.objectType && (a ? (Entry.playground.object.entity.setLineBreak(!0), $(".entryPlayground_textArea").css("display", "block"), $(".entryPlayground_textBox").css("display", "none"), this.linebreakOffImage.src = Entry.mediaFilePath + "text-linebreak-off-false.png", this.linebreakOnImage.src = Entry.mediaFilePath + "text-linebreak-on-true.png", this.fontSizeWrapper.removeClass("entryHide")) : (Entry.playground.object.entity.setLineBreak(!1), $(".entryPlayground_textArea").css("display", - "none"), $(".entryPlayground_textBox").css("display", "block"), this.linebreakOffImage.src = Entry.mediaFilePath + "text-linebreak-off-true.png", this.linebreakOnImage.src = Entry.mediaFilePath + "text-linebreak-on-false.png", this.fontSizeWrapper.addClass("entryHide"))); -}; -Entry.Playground.prototype.setFontAlign = function(a) { - if ("textBox" == this.object.objectType) { - this.alignLeftBtn.removeClass("toggle"); - this.alignCenterBtn.removeClass("toggle"); - this.alignRightBtn.removeClass("toggle"); - switch(a) { - case Entry.TEXT_ALIGN_LEFT: - this.alignLeftBtn.addClass("toggle"); - break; - case Entry.TEXT_ALIGN_CENTER: - this.alignCenterBtn.addClass("toggle"); - break; - case Entry.TEXT_ALIGN_RIGHT: - this.alignRightBtn.addClass("toggle"); +Entry.changeXmlHashId = function(b) { + if (/function_field/.test(b.getAttribute("type"))) { + for (var a = b.getElementsByTagName("mutation"), c = 0, d = a.length;c < d;c++) { + a[c].setAttribute("hashid", Entry.generateHash()); } - this.object.entity.setTextAlign(a); } + return b; }; -Entry.Playground.prototype.hideBlockMenu = function() { - this.mainWorkspace.getBlockMenu().hide(); -}; -Entry.Playground.prototype.showBlockMenu = function() { - this.mainWorkspace.getBlockMenu().show(); +Entry.getMaxFloatPoint = function(b) { + for (var a = 0, c = 0, d = b.length;c < d;c++) { + var e = String(b[c]), f = e.indexOf("."); + -1 !== f && (e = e.length - (f + 1), e > a && (a = e)); + } + return Math.min(a, 20); }; -Entry.Popup = function() { - Entry.assert(!window.popup, "Popup exist"); - this.body_ = Entry.createElement("div"); - this.body_.addClass("entryPopup"); - this.body_.bindOnClick(function(a) { - a.target == this && this.popup.remove(); - }); - this.body_.popup = this; - document.body.appendChild(this.body_); - this.window_ = Entry.createElement("div"); - this.window_.addClass("entryPopupWindow"); - this.window_.bindOnClick(function() { - }); - Entry.addEventListener("windowResized", this.resize); - window.popup = this; - this.resize(); - this.body_.appendChild(this.window_); +Entry.convertToRoundedDecimals = function(b, a) { + return isNaN(b) || !this.isFloat(b) ? b : +(Math.round(b + "e" + a) + "e-" + a); }; -Entry.Popup.prototype.remove = function() { - for (;this.window_.hasChildNodes();) { - "workspace" == Entry.type ? Entry.view_.insertBefore(this.window_.firstChild, Entry.container.view_) : Entry.view_.insertBefore(this.window_.lastChild, Entry.view_.firstChild); - } - $("body").css("overflow", "auto"); - Entry.removeElement(this.body_); - window.popup = null; - Entry.removeEventListener("windowResized", this.resize); - Entry.engine.popup = null; +Entry.attachEventListener = function(b, a, c) { + setTimeout(function() { + b.addEventListener(a, c); + }, 0); }; -Entry.Popup.prototype.resize = function(a) { - a = window.popup.window_; - var b = .9 * window.innerWidth, c = .9 * window.innerHeight - 35; - 9 * b <= 16 * c ? c = b / 16 * 9 + 35 : (b = 16 * c / 9, c += 35); - a.style.width = String(b) + "px"; - a.style.height = String(c) + "px"; +Entry.deAttachEventListener = function(b, a, c) { + b.removeEventListener(a, c); }; -Entry.popupHelper = function(a) { - this.popupList = {}; - this.nowContent; - a && (window.popupHelper = null); - Entry.assert(!window.popupHelper, "Popup exist"); - var b = ["confirm", "spinner"], c = ["entryPopupHelperTopSpan", "entryPopupHelperBottomSpan", "entryPopupHelperLeftSpan", "entryPopupHelperRightSpan"]; - this.body_ = Entry.Dom("div", {classes:["entryPopup", "hiddenPopup", "popupHelper"]}); - var d = this; - this.body_.bindOnClick(function(a) { - if (!(d.nowContent && -1 < b.indexOf(d.nowContent.prop("type")))) { - var f = $(a.target); - c.forEach(function(a) { - f.hasClass(a) && this.popup.hide(); - }.bind(this)); - a.target == this && this.popup.hide(); +Entry.isEmpty = function(b) { + if (!b) { + return !0; + } + for (var a in b) { + if (b.hasOwnProperty(a)) { + return !1; } - }); - window.popupHelper = this; - this.body_.prop("popup", this); - Entry.Dom("div", {class:"entryPopupHelperTopSpan", parent:this.body_}); - a = Entry.Dom("div", {class:"entryPopupHelperMiddleSpan", parent:this.body_}); - Entry.Dom("div", {class:"entryPopupHelperBottomSpan", parent:this.body_}); - Entry.Dom("div", {class:"entryPopupHelperLeftSpan", parent:a}); - this.window_ = Entry.Dom("div", {class:"entryPopupHelperWindow", parent:a}); - Entry.Dom("div", {class:"entryPopupHelperRightSpan", parent:a}); - $("body").append(this.body_); -}; -Entry.popupHelper.prototype.clearPopup = function() { - for (var a = this.popupWrapper_.children.length - 1;2 < a;a--) { - this.popupWrapper_.removeChild(this.popupWrapper_.children[a]); } + return !0; }; -Entry.popupHelper.prototype.addPopup = function(a, b) { - var c = Entry.Dom("div"), d = Entry.Dom("div", {class:"entryPopupHelperCloseButton"}); - d.bindOnClick(function() { - b.closeEvent ? b.closeEvent(this) : this.hide(); - }.bind(this)); - var e = Entry.Dom("div", {class:"entryPopupHelperWrapper"}); - e.append(d); - b.title && (d = Entry.Dom("div", {class:"entryPopupHelperTitle"}), e.append(d), d.text(b.title)); - c.addClass(a); - c.append(e); - c.popupWrapper_ = e; - c.prop("type", b.type); - "function" === typeof b.setPopupLayout && b.setPopupLayout(c); - this.popupList[a] = c; +Entry.Utils.disableContextmenu = function(b) { + if (b) { + $(b).on("contextmenu", function(a) { + a.stopPropagation(); + a.preventDefault(); + return !1; + }); + } }; -Entry.popupHelper.prototype.hasPopup = function(a) { - return !!this.popupList[a]; +Entry.Utils.isRightButton = function(b) { + return 2 == b.button || b.ctrlKey; }; -Entry.popupHelper.prototype.setPopup = function(a) { +Entry.Utils.isTouchEvent = function(b) { + return "mousedown" !== b.type.toLowerCase(); }; -Entry.popupHelper.prototype.remove = function(a) { - 0 < this.window_.children().length && this.window_.children().remove(); - this.window_.remove(); - delete this.popupList[a]; - this.nowContent = void 0; - this.body_.addClass("hiddenPopup"); +Entry.Utils.inherit = function(b, a) { + function c() { + } + c.prototype = b.prototype; + a.prototype = new c; + return a; }; -Entry.popupHelper.prototype.resize = function(a) { +Entry.bindAnimationCallbackOnce = function(b, a) { + b.one("webkitAnimationEnd animationendo animationend", a); }; -Entry.popupHelper.prototype.show = function(a) { - 0 < this.window_.children().length && this.window_.children().detach(); - this.window_.append(this.popupList[a]); - this.nowContent = this.popupList[a]; - this.body_.removeClass("hiddenPopup"); +Entry.Utils.isInInput = function(b) { + return "textarea" == b.target.type || "text" == b.target.type; }; -Entry.popupHelper.prototype.hide = function() { - this.nowContent = void 0; - this.body_.addClass("hiddenPopup"); +Entry.Utils.isFunction = function(b) { + return "function" === typeof b; }; -Entry.getStartProject = function(a) { - return {category:"\uae30\ud0c0", scenes:[{name:"\uc7a5\uba74 1", id:"7dwq"}], variables:[{name:"\ucd08\uc2dc\uacc4", id:"brih", visible:!1, value:"0", variableType:"timer", x:150, y:-70, array:[], object:null, isCloud:!1}, {name:"\ub300\ub2f5", id:"1vu8", visible:!1, value:"0", variableType:"answer", x:150, y:-100, array:[], object:null, isCloud:!1}], objects:[{id:"7y0y", name:"\uc5d4\ud2b8\ub9ac\ubd07", script:[[{type:"when_run_button_click", x:40, y:50}, {type:"repeat_basic", statements:[[{type:"move_direction"}]]}]], - selectedPictureId:"vx80", objectType:"sprite", rotateMethod:"free", scene:"7dwq", sprite:{sounds:[{duration:1.3, ext:".mp3", id:"8el5", fileurl:a + "media/bark.mp3", name:"\uac15\uc544\uc9c0 \uc9d6\ub294\uc18c\ub9ac"}], pictures:[{id:"vx80", fileurl:a + "media/entrybot1.png", name:Lang.Blocks.walking_entryBot + "1", scale:100, dimension:{width:284, height:350}}, {id:"4t48", fileurl:a + "media/entrybot2.png", name:Lang.Blocks.walking_entryBot + "2", scale:100, dimension:{width:284, height:350}}]}, - entity:{x:0, y:0, regX:142, regY:175, scaleX:.3154574132492113, scaleY:.3154574132492113, rotation:0, direction:90, width:284, height:350, visible:!0}, lock:!1, active:!0}], speed:60}; +Entry.Utils.addFilters = function(b, a) { + var c = b.elem("defs"), d = c.elem("filter", {id:"entryTrashcanFilter_" + a}); + d.elem("feGaussianBlur", {"in":"SourceAlpha", stdDeviation:2, result:"blur"}); + d.elem("feOffset", {"in":"blur", dx:1, dy:1, result:"offsetBlur"}); + d = d.elem("feMerge"); + d.elem("feMergeNode", {"in":"offsetBlur"}); + d.elem("feMergeNode", {"in":"SourceGraphic"}, d); + d = c.elem("filter", {id:"entryBlockShadowFilter_" + a, height:"200%"}); + d.elem("feOffset", {result:"offOut", in:"SourceGraphic", dx:0, dy:1}); + d.elem("feColorMatrix", {result:"matrixOut", in:"offOut", type:"matrix", values:"0.7 0 0 0 0 0 0.7 0 0 0 0 0 0.7 0 0 0 0 0 1 0"}); + d.elem("feBlend", {in:"SourceGraphic", in1:"offOut", mode:"normal"}); + c = c.elem("filter", {id:"entryBlockHighlightFilter_" + a}); + c.elem("feOffset", {result:"offOut", in:"SourceGraphic", dx:0, dy:0}); + c.elem("feColorMatrix", {result:"matrixOut", in:"offOut", type:"matrix", values:"1.3 0 0 0 0 0 1.3 0 0 0 0 0 1.3 0 0 0 0 0 1 0"}); }; -Entry.Reporter = function(a) { - this.projectId = this.userId = null; - this.isRealTime = a; - this.activities = []; +Entry.Utils.addBlockPattern = function(b, a) { + for (var c = b.elem("pattern", {id:"blockHoverPattern_" + a, class:"blockHoverPattern", patternUnits:"userSpaceOnUse", patternTransform:"translate(12, 0)", x:0, y:0, width:125, height:33, style:"display: none"}), d = c.elem("g"), e = d.elem("rect", {x:0, y:0, width:125, height:33}), f = Entry.mediaFilePath + "block_pattern_(order).png", g = 1;5 > g;g++) { + d.elem("image", {class:"pattern" + g, href:f.replace("(order)", g), x:0, y:0, width:125, height:33}); + } + return {pattern:c, rect:e}; }; -Entry.Reporter.prototype.start = function(a, b, c) { - this.isRealTime && (-1 < window.location.href.indexOf("localhost") ? this.io = io("localhost:7000") : this.io = io("play04.play-entry.com:7000"), this.io.emit("activity", {message:"start", userId:b, projectId:a, time:c})); - this.userId = b; - this.projectId = a; +Entry.Utils.COLLISION = {NONE:0, UP:1, RIGHT:2, LEFT:3, DOWN:4}; +Entry.Utils.createMouseEvent = function(b, a) { + var c = document.createEvent("MouseEvent"); + c.initMouseEvent(b, !0, !0, window, 0, 0, 0, a.clientX, a.clientY, !1, !1, !1, !1, 0, null); + return c; }; -Entry.Reporter.prototype.report = function(a) { - if (!this.isRealTime || this.io) { - var b = [], c; - for (c in a.params) { - var d = a.params[c]; - "object" !== typeof d ? b.push(d) : d.id && b.push(d.id); +Entry.Utils.xmlToJsonData = function(b) { + b = $.parseXML(b); + var a = []; + b = b.childNodes[0].childNodes; + for (var c in b) { + var d = b[c]; + if (d.tagName) { + var e = {category:d.getAttribute("id"), blocks:[]}, d = d.childNodes; + for (c in d) { + var f = d[c]; + f.tagName && (f = f.getAttribute("type")) && e.blocks.push(f); + } + a.push(e); } - a = {message:a.message, userId:this.userId, projectId:this.projectId, time:a.time, params:b}; - this.isRealTime ? this.io.emit("activity", a) : this.activities.push(a); } + return a; }; -Entry.Scene = function() { - var a = this; - this.scenes_ = []; - this.selectedScene = null; - this.maxCount = 20; - $(window).on("resize", function(b) { - a.resize(); - }); +Entry.Utils.stopProjectWithToast = function(b, a) { + a = a || "\ub7f0\ud0c0\uc784 \uc5d0\ub7ec \ubc1c\uc0dd"; + Entry.toast && Entry.toast.alert(Lang.Msgs.warn, Lang.Workspace.check_runtime_error, !0); + Entry.engine && Entry.engine.toggleStop(); + "workspace" === Entry.type && (Entry.container.selectObject(b.getCode().object.id, !0), b.view.getBoard().activateBlock(b)); + throw Error(a); }; -Entry.Scene.viewBasicWidth = 70; -Entry.Scene.prototype.generateView = function(a, b) { - var c = this; - this.view_ = a; - this.view_.addClass("entryScene"); - b && "workspace" != b || (this.view_.addClass("entrySceneWorkspace"), $(this.view_).on("mousedown", function(a) { - var b = $(this).offset(), f = $(window), g = a.pageX - b.left + f.scrollLeft(); - a = a.pageY - b.top + f.scrollTop(); - a = 40 - a; - b = -40 / 55; - f = $(c.selectedScene.view).find(".entrySceneRemoveButtonCoverWorkspace").offset().left; - !(g < f || g > f + 55) && a > 40 + b * (g - f) && (g = c.getNextScene()) && (g = $(g.view), $(document).trigger("mouseup"), g.trigger("mousedown")); - }), a = Entry.createElement("ul"), a.addClass("entrySceneListWorkspace"), Entry.sceneEditable && $ && $(a).sortable({start:function(a, b) { - b.item.data("start_pos", b.item.index()); - $(b.item[0]).clone(!0); - }, stop:function(a, b) { - a = b.item.data("start_pos"); - b = b.item.index(); - Entry.scene.moveScene(a, b); - }, axis:"x", tolerance:"pointer"}), this.view_.appendChild(a), this.listView_ = a, Entry.sceneEditable && (a = Entry.createElement("span"), a.addClass("entrySceneElementWorkspace"), a.addClass("entrySceneAddButtonWorkspace"), a.bindOnClick(function(a) { - Entry.engine.isState("run") || Entry.scene.addScene(); - }), this.view_.appendChild(a), this.addButton_ = a)); -}; -Entry.Scene.prototype.generateElement = function(a) { - var b = this, c = Entry.createElement("li", a.id); - c.addClass("entrySceneElementWorkspace"); - c.addClass("entrySceneButtonWorkspace"); - c.addClass("minValue"); - $(c).on("mousedown", function(b) { - Entry.engine.isState("run") ? b.preventDefault() : Entry.scene.selectScene(a); - }); - var d = Entry.createElement("input"); - d.addClass("entrySceneFieldWorkspace"); - d.value = a.name; - Entry.sceneEditable || (d.disabled = "disabled"); - var e = Entry.createElement("span"); - e.addClass("entrySceneLeftWorkspace"); - c.appendChild(e); - var f = Entry.createElement("span"); - f.addClass("entrySceneInputCover"); - f.style.width = Entry.computeInputWidth(a.name); - c.appendChild(f); - a.inputWrapper = f; - d.onkeyup = function(c) { - c = c.keyCode; - Entry.isArrowOrBackspace(c) || (a.name = this.value, f.style.width = Entry.computeInputWidth(a.name), b.resize(), 13 == c && this.blur(), 9 < this.value.length && (this.value = this.value.substring(0, 10), this.blur())); +window.requestAnimFrame = function() { + return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function(b) { + window.setTimeout(b, 1E3 / 60); }; - d.onblur = function(b) { - d.value = this.value; - a.name = this.value; - f.style.width = Entry.computeInputWidth(a.name); +}(); +Entry.Model = function(b, a) { + var c = Entry.Model; + c.generateSchema(b); + c.generateSetter(b); + c.generateObserve(b); + (void 0 === a || a) && Object.seal(b); + return b; +}; +(function(b) { + b.generateSchema = function(a) { + var b = a.schema; + if (void 0 !== b) { + b = JSON.parse(JSON.stringify(b)); + a.data = {}; + for (var d in b) { + (function(d) { + a.data[d] = b[d]; + Object.defineProperty(a, d, {get:function() { + return a.data[d]; + }}); + })(d); + } + a._toJSON = this._toJSON; + } }; - f.appendChild(d); - e = Entry.createElement("span"); - e.addClass("entrySceneRemoveButtonCoverWorkspace"); - c.appendChild(e); - if (Entry.sceneEditable) { - var g = Entry.createElement("button"); - g.addClass("entrySceneRemoveButtonWorkspace"); - g.innerHTML = "x"; - g.scene = a; - g.bindOnClick(function(a) { - a.stopPropagation(); - Entry.engine.isState("run") || confirm(Lang.Workspace.will_you_delete_scene) && Entry.scene.removeScene(this.scene); + b.generateSetter = function(a) { + a.set = this.set; + }; + b.set = function(a, b) { + var d = {}, e; + for (e in this.data) { + void 0 !== a[e] && (a[e] === this.data[e] ? delete a[e] : (d[e] = this.data[e], this.data[e] = a[e] instanceof Array ? a[e].concat() : a[e])); + } + b || this.notify(Object.keys(a), d); + }; + b.generateObserve = function(a) { + a.observers = []; + a.observe = this.observe; + a.unobserve = this.unobserve; + a.notify = this.notify; + }; + b.observe = function(a, b, d, e) { + d = new Entry.Observer(this.observers, a, b, d); + if (!1 !== e) { + a[b]([]); + } + return d; + }; + b.unobserve = function(a) { + a.destroy(); + }; + b.notify = function(a, b) { + "string" === typeof a && (a = [a]); + var d = this; + d.observers.map(function(e) { + var f = a; + void 0 !== e.attrs && (f = Entry.Utils.intersectArray(e.attrs, a)); + if (f.length) { + e.object[e.funcName](f.map(function(a) { + return {name:a, object:d, oldValue:b[a]}; + })); + } }); - e.appendChild(g); + }; + b._toJSON = function() { + var a = {}, 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 = {}; + 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; + if (b) { + b = this.content._blockMap; + for (var c in b) { + Entry.Func.registerParamBlock(b[c].type); + } + Entry.Func.generateWsBlock(this); } - Entry.Utils.disableContextmenu(c); - $(c).on("contextmenu", function() { - var b = [{text:Lang.Workspace.duplicate_scene, enable:Entry.engine.isState("stop"), callback:function() { - Entry.scene.cloneScene(a); - }}]; - Entry.ContextMenu.show(b, "workspace-contextmenu"); - }); - return a.view = c; + Entry.Func.registerFunction(this); + Entry.Func.updateMenu(); }; -Entry.Scene.prototype.updateView = function() { - if (!Entry.type || "workspace" == Entry.type) { - for (var a = this.listView_, b = $(a).children().length;b < this.getScenes().length;b++) { - a.appendChild(this.getScenes()[b].view); - } - this.addButton_ && (this.getScenes().length < this.maxCount ? this.addButton_.removeClass("entryRemove") : this.addButton_.addClass("entryRemove")); +Entry.Func.threads = {}; +Entry.Func.registerFunction = function(b) { + 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(); } - this.resize(); }; -Entry.Scene.prototype.addScenes = function(a) { - if ((this.scenes_ = a) && 0 !== a.length) { - for (var b = 0, c = a.length;b < c;b++) { - this.generateElement(a[b]); +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;e < b.length;e++) { + var f = b[e]; + if ("function_general" === f.type) { + for (var g = [], g = f.inputList, h = 0;h < g.length;h++) { + f = g[h], 0 < f.fieldRow.length && f.fieldRow[0] instanceof Blockly.FieldLabel && void 0 != f.fieldRow[0].text_ && (d += f.fieldRow[0].text_, d += " "); + } + d = d.trim(); + if (d === this.srcFName && this.srcFName.split(" ").length == c.length) { + for (d = 0;d < g.length;d++) { + if (f = g[d], 0 < f.fieldRow.length && f.fieldRow[0] instanceof Blockly.FieldLabel && void 0 != f.fieldRow[0].text_) { + if (void 0 === c[a]) { + g.splice(d, 1); + break; + } else { + f.fieldRow[0].text_ = c[a]; + } + a++; + } + } + } + d = ""; + a = 0; } - } else { - this.scenes_ = [], this.scenes_.push(this.createScene()); } - this.selectScene(this.getScenes()[0]); - this.updateView(); + a = Blockly.Xml.workspaceToDom(Blockly.mainWorkspace); + Blockly.mainWorkspace.clear(); + Blockly.Xml.domToWorkspace(Blockly.mainWorkspace, a); }; -Entry.Scene.prototype.addScene = function(a, b) { - void 0 === a && (a = this.createScene()); - a.view || this.generateElement(a); - b || "number" == typeof b ? this.getScenes().splice(b, 0, a) : this.getScenes().push(a); - Entry.stage.objectContainers.push(Entry.stage.createObjectContainer(a)); - Entry.playground.flushPlayground(); - this.selectScene(a); - this.updateView(); - return a; +Entry.Func.cancelEdit = function() { + this.targetFunc && (Entry.Func.isEdit = !1, this.targetFunc.block || (this._targetFuncBlock.destroy(), delete Entry.variableContainer.functions_[this.targetFunc.id], delete Entry.variableContainer.selected), delete this.targetFunc, this.updateMenu(), Entry.variableContainer.updateList(), Entry.playground.mainWorkspace.setMode(Entry.Workspace.MODE_BOARD)); +}; +Entry.Func.getMenuXml = function() { + var b = []; + this.targetFunc || (b = b.concat(this.createBtn)); + if (this.targetFunc) { + var a = this.FIELD_BLOCK, a = a.replace("#1", Entry.generateHash()), a = a.replace("#2", Entry.generateHash()), a = Blockly.Xml.textToDom(a).childNodes, b = b.concat(Entry.nodeListToArray(a)) + } + for (var c in Entry.variableContainer.functions_) { + a = Entry.variableContainer.functions_[c], a === this.targetFunc ? (a = Entry.Func.generateBlock(this.targetFunc, Blockly.Xml.workspaceToDom(Entry.Func.workspace), a.id).block, b.push(a)) : b.push(a.block); + } + return b; }; -Entry.Scene.prototype.removeScene = function(a) { - if (1 >= this.getScenes().length) { - Entry.toast.alert(Lang.Msgs.runtime_error, Lang.Workspace.Scene_delete_error, !1); - } else { - var b = this.getScenes().indexOf(this.getSceneById(a.id)); - this.getScenes().splice(b, 1); - for (var b = Entry.container.getSceneObjects(a), c = 0;c < b.length;c++) { - Entry.container.removeObject(b[c]); - } - Entry.stage.removeObjectContainer(a); - $(a.view).remove(); - this.selectScene(); +Entry.Func.syncFunc = function() { + var b = Entry.Func; + if (b.targetFunc) { + var a = b.workspace.topBlocks_[0].toString(), c = b.workspace.topBlocks_.length; + (b.fieldText != a || b.workspaceLength != c) && 1 > Blockly.Block.dragMode_ && (b.updateMenu(), b.fieldText = a, b.workspaceLength = c); } }; -Entry.Scene.prototype.selectScene = function(a) { - a = a || this.getScenes()[0]; - if (!this.selectedScene || this.selectedScene.id != a.id) { - Entry.engine.isState("run") && Entry.container.resetSceneDuringRun(); - var b = this.selectedScene; - b && (b = b.view, b.removeClass("selectedScene"), b = $(b), b.find("input").blur()); - this.selectedScene = a; - a.view.addClass("selectedScene"); - Entry.container.setCurrentObjects(); - Entry.stage.objectContainers && 0 !== Entry.stage.objectContainers.length && Entry.stage.selectObjectContainer(a); - (a = Entry.container.getCurrentObjects()[0]) && "minimize" != Entry.type ? (Entry.container.selectObject(a.id), Entry.playground.refreshPlayground()) : (Entry.stage.selectObject(null), Entry.playground.flushPlayground(), Entry.variableContainer.updateList()); - Entry.container.listView_ || Entry.stage.sortZorder(); - Entry.container.updateListView(); - this.updateView(); - Entry.requestUpdate = !0; +Entry.Func.setupMenuCode = function() { + var b = Entry.playground.mainWorkspace; + b && (b = b.getBlockMenu().getCategoryCodes("func"), this._fieldLabel = b.createThread([{type:"function_field_label"}]).getFirstBlock(), this._fieldString = b.createThread([{type:"function_field_string", params:[{type:this.requestParamBlock("string")}]}]).getFirstBlock(), this._fieldBoolean = b.createThread([{type:"function_field_boolean", params:[{type:this.requestParamBlock("boolean")}]}]).getFirstBlock(), this.menuCode = b); +}; +Entry.Func.refreshMenuCode = function() { + if (Entry.playground.mainWorkspace) { + this.menuCode || this.setupMenuCode(); + var b = Entry.block[this._fieldString.params[0].type].changeEvent._listeners.length; + 2 < b && this._fieldString.params[0].changeType(this.requestParamBlock("string")); + b = Entry.block[this._fieldBoolean.params[0].type].changeEvent._listeners.length; + 2 < b && this._fieldBoolean.params[0].changeType(this.requestParamBlock("boolean")); } }; -Entry.Scene.prototype.toJSON = function() { - for (var a = [], b = this.getScenes().length, c = 0;c < b;c++) { - var d = this.getScenes()[c], e = d.view, f = d.inputWrapper; - delete d.view; - delete d.inputWrapper; - a.push(JSON.parse(JSON.stringify(d))); - d.view = e; - d.inputWrapper = f; +Entry.Func.requestParamBlock = function(b) { + var a = Entry.generateHash(), c; + switch(b) { + case "string": + c = Entry.block.function_param_string; + break; + case "boolean": + c = Entry.block.function_param_boolean; + break; + default: + return null; } + a = b + "Param_" + a; + b = Entry.Func.createParamBlock(a, c, b); + Entry.block[a] = b; return a; }; -Entry.Scene.prototype.moveScene = function(a, b) { - this.getScenes().splice(b, 0, this.getScenes().splice(a, 1)[0]); - Entry.container.updateObjectsOrder(); - Entry.stage.sortZorder(); - $(".entrySceneElementWorkspace").removeAttr("style"); +Entry.Func.registerParamBlock = function(b) { + -1 < b.indexOf("stringParam") ? Entry.Func.createParamBlock(b, Entry.block.function_param_string, b) : -1 < b.indexOf("booleanParam") && Entry.Func.createParamBlock(b, Entry.block.function_param_boolean, b); }; -Entry.Scene.prototype.getSceneById = function(a) { - for (var b = this.getScenes(), c = 0;c < b.length;c++) { - if (b[c].id == a) { - return b[c]; - } - } - return !1; +Entry.Func.createParamBlock = function(b, a, c) { + var d = function() { + }; + c = "string" === c ? "function_param_string" : "function_param_boolean"; + d.prototype = a; + d = new d; + d.changeEvent = new Entry.Event; + d.template = Lang.template[c]; + return Entry.block[b] = d; }; -Entry.Scene.prototype.getScenes = function() { - return this.scenes_; +Entry.Func.updateMenu = function() { + var b = Entry.playground.mainWorkspace; + b && (b = b.getBlockMenu(), this.targetFunc ? (this.menuCode || this.setupMenuCode(), b.banClass("functionInit"), b.unbanClass("functionEdit")) : (b.unbanClass("functionInit"), b.banClass("functionEdit")), b.reDraw()); }; -Entry.Scene.prototype.takeStartSceneSnapshot = function() { - this.sceneBeforeRun = this.selectedScene; +Entry.Func.prototype.edit = function() { + Entry.Func.isEdit || (Entry.Func.isEdit = !0, Entry.Func.svg ? this.parentView.appendChild(this.svg) : Entry.Func.initEditView()); }; -Entry.Scene.prototype.loadStartSceneSnapshot = function() { - this.selectScene(this.sceneBeforeRun); - this.sceneBeforeRun = null; +Entry.Func.generateBlock = function(b) { + b = Entry.block["func_" + b.id]; + var a = {template:b.template, params:b.params}, c = /(%\d)/mi, d = b.template.split(c), e = "", f = 0, g = 0, h; + for (h in d) { + var k = d[h]; + c.test(k) ? (k = +k.split("%")[1] - 1, k = b.params[k], "Indicator" !== k.type && ("boolean" === k.accept ? (e += Lang.template.function_param_boolean + (f ? f : ""), f++) : (e += Lang.template.function_param_string + (g ? g : ""), g++))) : e += k; + } + return {block:a, description:e}; }; -Entry.Scene.prototype.createScene = function() { - var a = {name:Lang.Blocks.SCENE + " " + (this.getScenes().length + 1), id:Entry.generateHash()}; - this.generateElement(a); - return a; +Entry.Func.prototype.generateBlock = function(b) { + b = Entry.Func.generateBlock(this); + this.block = b.block; + this.description = b.description; }; -Entry.Scene.prototype.cloneScene = function(a) { - if (this.scenes_.length >= this.maxCount) { - Entry.toast.alert(Lang.Msgs.runtime_error, Lang.Workspace.Scene_add_error, !1); - } else { - var b = {name:a.name + Lang.Workspace.replica_of_object, id:Entry.generateHash()}; - this.generateElement(b); - this.addScene(b); - a = Entry.container.getSceneObjects(a); - for (var c = a.length - 1;0 <= c;c--) { - Entry.container.addCloneObject(a[c], b.id); +Entry.Func.generateWsBlock = function(b) { + this.unbindFuncChangeEvent(); + b = b ? b : this.targetFunc; + for (var a = b.content.getEventMap("funcDef")[0].params[0], c = 0, d = 0, e = [], f = "", g = b.hashMap, h = b.paramMap;a;) { + var k = a.params[0]; + switch(a.type) { + case "function_field_label": + f = f + " " + k; + break; + case "function_field_boolean": + Entry.Mutator.mutate(k.type, {template:Lang.Blocks.FUNCTION_logical_variable + " " + (c ? c : "")}); + g[k.type] = !1; + h[k.type] = c + d; + c++; + e.push({type:"Block", accept:"boolean"}); + f += " %" + (c + d); + break; + case "function_field_string": + Entry.Mutator.mutate(k.type, {template:Lang.Blocks.FUNCTION_character_variable + " " + (d ? d : "")}), g[k.type] = !1, h[k.type] = c + d, d++, f += " %" + (c + d), e.push({type:"Block", accept:"string"}); } + a = a.getOutputBlock(); + } + c++; + f += " %" + (c + d); + e.push({type:"Indicator", img:"block_icon/function_03.png", size:12}); + Entry.Mutator.mutate("func_" + b.id, {params:e, template:f}); + for (var l in g) { + g[l] ? (a = -1 < l.indexOf("string") ? Lang.Blocks.FUNCTION_character_variable : Lang.Blocks.FUNCTION_logical_variable, Entry.Mutator.mutate(l, {template:a})) : g[l] = !0; } + this.bindFuncChangeEvent(b); }; -Entry.Scene.prototype.resize = function() { - var a = this.getScenes(), b = this.selectedScene, c = a[0]; - if (0 !== a.length && c) { - var d = $(c.view).offset().left, c = parseFloat($(b.view).css("margin-left")), e = $(this.view_).width() - d, f = 0, g; - for (g in a) { - var d = a[g], h = d.view; - h.addClass("minValue"); - $(d.inputWrapper).width(Entry.computeInputWidth(d.name)); - h = $(h); - f = f + h.width() + c; +Entry.Func.bindFuncChangeEvent = function(b) { + b = b ? b : this.targetFunc; + !this._funcChangeEvent && b.content.getEventMap("funcDef")[0].view && (this._funcChangeEvent = b.content.getEventMap("funcDef")[0].view._contents[1].changeEvent.attach(this, this.generateWsBlock)); +}; +Entry.Func.unbindFuncChangeEvent = function() { + this._funcChangeEvent && this._funcChangeEvent.destroy(); + delete this._funcChangeEvent; +}; +Entry.HWMontior = {}; +Entry.HWMonitor = function(b) { + this.svgDom = Entry.Dom($('')); + this._hwModule = b; + var a = this; + Entry.addEventListener("windowResized", function() { + var b = a._hwModule.monitorTemplate.mode; + "both" == b && (a.resize(), a.resizeList()); + "list" == b ? a.resizeList() : a.resize(); + }); + Entry.addEventListener("hwModeChange", function() { + a.changeMode(); + }); + this.changeOffset = 0; + this.scale = .5; + this._listPortViews = {}; +}; +(function(b) { + b.initView = function() { + this.svgDom = Entry.Dom($('')); + }; + b.generateView = function() { + this.snap = Entry.SVG("hwMonitor"); + this._svgGroup = this.snap.elem("g"); + this._portMap = {n:[], e:[], s:[], w:[]}; + var a = this._hwModule.monitorTemplate, b = {href:Entry.mediaFilePath + a.imgPath, x:-a.width / 2, y:-a.height / 2, width:a.width, height:a.height}; + this._portViews = {}; + this.hwView = this._svgGroup.elem("image"); + this.hwView = this.hwView.attr(b); + this._template = a; + a = a.ports; + this.pathGroup = null; + this.pathGroup = this._svgGroup.elem("g"); + var b = [], d; + for (d in a) { + var e = this.generatePortView(a[d], "_svgGroup"); + this._portViews[d] = e; + b.push(e); } - if (f > e) { - for (g in e -= $(b.view).width(), c = e / (a.length - 1) - (Entry.Scene.viewBasicWidth + c), a) { - d = a[g], b.id != d.id ? (d.view.removeClass("minValue"), $(d.inputWrapper).width(c)) : d.view.addClass("minValue"); + b.sort(function(a, b) { + return a.box.x - b.box.x; + }); + var f = this._portMap; + b.map(function(a) { + (1 > (Math.atan2(-a.box.y, a.box.x) / Math.PI + 2) % 2 ? f.n : f.s).push(a); + }); + this.resize(); + }; + b.toggleMode = function(a) { + var b = this._hwModule.monitorTemplate; + "list" == a ? (b.TempPort = null, this._hwModule.monitorTemplate.ports && (this._hwModule.monitorTemplate.TempPort = this._hwModule.monitorTemplate.ports, this._hwModule.monitorTemplate.listPorts = this.addPortEle(this._hwModule.monitorTemplate.listPorts, this._hwModule.monitorTemplate.ports)), $(this._svglistGroup).remove(), this._svgGroup && $(this._svgGroup).remove(), $(this._pathGroup).remove(), this._hwModule.monitorTemplate.mode = "list", this.generateListView()) : (this._hwModule.monitorTemplate.TempPort && + (this._hwModule.monitorTemplate.ports = this._hwModule.monitorTemplate.TempPort, this._hwModule.monitorTemplate.listPorts = this.removePortEle(this._hwModule.monitorTemplate.listPorts, this._hwModule.monitorTemplate.ports)), $(this._svglistGroup).remove(), this._hwModule.monitorTemplate.mode = "both", this.generateListView(), this.generateView()); + }; + b.setHwmonitor = function(a) { + this._hwmodule = a; + }; + b.changeMode = function(a) { + "both" == this._hwModule.monitorTemplate.mode ? this.toggleMode("list") : "list" == this._hwModule.monitorTemplate.mode && this.toggleMode("both"); + }; + b.addPortEle = function(a, b) { + if ("object" != typeof b) { + return a; + } + for (var d in b) { + a[d] = b[d]; + } + return a; + }; + b.removePortEle = function(a, b) { + if ("object" != typeof b) { + return a; + } + for (var d in b) { + delete a[d]; + } + return a; + }; + b.generateListView = function() { + this._portMapList = {n:[]}; + this._svglistGroup = null; + this.listsnap = Entry.SVG("hwMonitor"); + this._svglistGroup = this.listsnap.elem("g"); + var a = this._hwModule.monitorTemplate; + this._template = a; + a = a.listPorts; + this.pathGroup = this._svglistGroup.elem("g"); + var b = [], d; + for (d in a) { + var e = this.generatePortView(a[d], "_svglistGroup"); + this._listPortViews[d] = e; + b.push(e); + } + var f = this._portMapList; + b.map(function(a) { + f.n.push(a); + }); + this.resizeList(); + }; + b.generatePortView = function(a, b) { + var d = this[b].elem("g"); + d.addClass("hwComponent"); + var e = null, e = this.pathGroup.elem("path").attr({d:"m0,0", fill:"none", stroke:"input" === a.type ? "#00979d" : "#A751E3", "stroke-width":3}), f = d.elem("rect").attr({x:0, y:0, width:150, height:22, rx:4, ry:4, fill:"#fff", stroke:"#a0a1a1"}), g = d.elem("text").attr({x:4, y:12, fill:"#000", "class":"hwComponentName", "alignment-baseline":"central"}); + g.textContent = a.name; + g = g.getComputedTextLength(); + d.elem("rect").attr({x:g + 8, y:2, width:30, height:18, rx:9, ry:9, fill:"input" === a.type ? "#00979d" : "#A751E3"}); + var h = d.elem("text").attr({x:g + 13, y:12, fill:"#fff", "class":"hwComponentValue", "alignment-baseline":"central"}); + h.textContent = 0; + g += 40; + f.attr({width:g}); + return {group:d, value:h, type:a.type, path:e, box:{x:a.pos.x - this._template.width / 2, y:a.pos.y - this._template.height / 2, width:g}, width:g}; + }; + b.getView = function() { + return this.svgDom; + }; + b.update = function() { + var a = Entry.hw.portData, b = Entry.hw.sendQueue, d = this._hwModule.monitorTemplate.mode, e = this._hwModule.monitorTemplate.keys || [], f = []; + if ("list" == d) { + f = this._listPortViews; + } else { + if ("both" == d) { + if (f = this._listPortViews, this._portViews) { + for (var g in this._portViews) { + f[g] = this._portViews[g]; + } + } + } else { + f = this._portViews; + } + } + if (b) { + for (g in b) { + 0 != b[g] && f[g] && (f[g].type = "output"); + } + } + for (var h in f) { + if (d = f[h], "input" == d.type) { + var k = a[h]; + 0 < e.length && $.each(e, function(a, b) { + if ($.isPlainObject(k)) { + k = k[b] || 0; + } else { + return !1; + } + }); + d.value.textContent = k ? k : 0; + d.group.getElementsByTagName("rect")[1].attr({fill:"#00979D"}); + } else { + k = b[h], 0 < e.length && $.each(e, function(a, b) { + if ($.isPlainObject(k)) { + k = k[b] || 0; + } else { + return !1; + } + }), d.value.textContent = k ? k : 0, d.group.getElementsByTagName("rect")[1].attr({fill:"#A751E3"}); + } + } + }; + b.resize = function() { + this.hwView && this.hwView.attr({transform:"scale(" + this.scale + ")"}); + if (this.svgDom) { + var a = this.svgDom.get(0).getBoundingClientRect() + } + this._svgGroup.attr({transform:"translate(" + a.width / 2 + "," + a.height / 1.8 + ")"}); + this._rect = a; + 0 >= this._template.height || 0 >= a.height || (this.scale = a.height / this._template.height * this._template.height / 1E3, this.align()); + }; + b.resizeList = function() { + var a = this.svgDom.get(0).getBoundingClientRect(); + this._svglistGroup.attr({transform:"translate(" + a.width / 2 + "," + a.height / 2 + ")"}); + this._rect = a; + this.alignList(); + }; + b.align = function() { + var a = [], a = this._portMap.s.concat(); + this._alignNS(a, this.scale / 3 * this._template.height + 5, 27); + a = this._portMap.n.concat(); + this._alignNS(a, -this._template.height * this.scale / 3 - 32, -27); + a = this._portMap.e.concat(); + this._alignEW(a, -this._template.width * this.scale / 3 - 5, -27); + a = this._portMap.w.concat(); + this._alignEW(a, this._template.width * this.scale / 3 - 32, -27); + }; + b.alignList = function() { + for (var a = {}, a = this._hwModule.monitorTemplate.listPorts, b = a.length, d = 0;d < a.length;d++) { + a[d].group.attr({transform:"translate(" + this._template.width * (d / b - .5) + "," + (-this._template.width / 2 - 30) + ")"}); + } + a = this._portMapList.n.concat(); + this._alignNSList(a, -this._template.width * this.scale / 2 - 32, -27); + }; + b._alignEW = function(a, b, d) { + var e = a.length, f = this._rect.height - 50; + tP = -f / 2; + bP = f / 2; + height = this._rect.height; + listVLine = wholeHeight = 0; + mode = this._hwModule.monitorTemplate; + for (f = 0;f < e;f++) { + wholeHeight += a[f].height + 5; + } + wholeHeight < bP - tP && (bP = wholeHeight / 2 + 3, tP = -wholeHeight / 2 - 3); + for (;1 < e;) { + var g = a.shift(), f = a.pop(), h = tP, k = bP, l = d; + wholeWidth <= bP - tP ? (tP += g.width + 5, bP -= f.width + 5, l = 0) : 0 === a.length ? (tP = (tP + bP) / 2 - 3, bP = tP + 6) : (tP = Math.max(tP, -width / 2 + g.width) + 15, bP = Math.min(bP, width / 2 - f.width) - 15); + wholeWidth -= g.width + f.width + 10; + b += l; + } + a.length && a[0].group.attr({transform:"translate(" + b + ",60)"}); + g && rPort && (this._movePort(g, b, tP, h), this._movePort(rPort, b, bP, k)); + }; + b._alignNS = function(a, b, d) { + for (var e = -this._rect.width / 2, f = this._rect.width / 2, g = this._rect.width, h = 0, k = 0;k < a.length;k++) { + h += a[k].width + 5; + } + h < f - e && (f = h / 2 + 3, e = -h / 2 - 3); + for (;1 < a.length;) { + var k = a.shift(), l = a.pop(), n = e, m = f, q = d; + h <= f - e ? (e += k.width + 5, f -= l.width + 5, q = 0) : 0 === a.length ? (e = (e + f) / 2 - 3, f = e + 6) : (e = Math.max(e, -g / 2 + k.width) + 15, f = Math.min(f, g / 2 - l.width) - 15); + this._movePort(k, e, b, n); + this._movePort(l, f, b, m); + h -= k.width + l.width + 10; + b += q; + } + a.length && this._movePort(a[0], (f + e - a[0].width) / 2, b, 100); + }; + b._alignNSList = function(a, b) { + var d = this._rect.width; + initX = -this._rect.width / 2 + 10; + initY = -this._rect.height / 2 + 10; + for (var e = listLine = wholeWidth = 0;e < a.length;e++) { + wholeWidth += a[e].width; + } + for (var f = 0, g = 0, h = initX, k = 0, l = 0, n = 0, e = 0;e < a.length;e++) { + l = a[e], e != a.length - 1 && (n = a[e + 1]), g += l.width, lP = initX, k = initY + 30 * f, l.group.attr({transform:"translate(" + lP + "," + k + ")"}), initX += l.width + 10, g > d - (l.width + n.width / 2.2) && (f += 1, initX = h, g = 0); + } + }; + b._movePort = function(a, b, d, e) { + var f = b, g = a.box.x * this.scale, h = a.box.y * this.scale; + b > e ? (f = b - a.width, b = b > g && g > e ? "M" + g + "," + d + "L" + g + "," + h : "M" + (b + e) / 2 + "," + d + "l0," + (h > d ? 28 : -3) + "H" + g + "L" + g + "," + h) : b = b < g && g < e ? "m" + g + "," + d + "L" + g + "," + h : "m" + (e + b) / 2 + "," + d + "l0," + (h > d ? 28 : -3) + "H" + g + "L" + g + "," + h; + a.group.attr({transform:"translate(" + f + "," + d + ")"}); + a.path.attr({d:b}); + }; +})(Entry.HWMonitor.prototype); +Entry.HW = function() { + this.connectTrial = 0; + this.isFirstConnect = !0; + this.initSocket(); + this.connected = !1; + this.portData = {}; + this.sendQueue = {}; + this.outputQueue = {}; + this.settingQueue = {}; + this.socketType = this.hwModule = this.selectedDevice = null; + Entry.addEventListener("stop", this.setZero); + this.hwInfo = {11:Entry.Arduino, 12:Entry.SensorBoard, 13:Entry.CODEino, 14:Entry.joystick, 15:Entry.dplay, 16:Entry.nemoino, 17:Entry.Xbot, 18:Entry.ardublock, 24:Entry.Hamster, 25:Entry.Albert, 31:Entry.Bitbrick, 42:Entry.Arduino, 51:Entry.Neobot, 71:Entry.Robotis_carCont, 72:Entry.Robotis_openCM70, 81:Entry.Arduino}; +}; +Entry.HW.TRIAL_LIMIT = 1; +p = Entry.HW.prototype; +p.initSocket = function() { + try { + if (this.connectTrial >= Entry.HW.TRIAL_LIMIT) { + this.isFirstConnect || Entry.toast.alert(Lang.Menus.connect_hw, Lang.Menus.connect_fail, !1), this.isFirstConnect = !1; + } else { + var b = this, a, c; + this.connected = !1; + this.connectTrial++; + if (-1 < location.protocol.indexOf("https")) { + c = new WebSocket("wss://hardware.play-entry.org:23518"); + } else { + try { + a = new WebSocket("ws://127.0.0.1:23518"), a.binaryType = "arraybuffer", a.onopen = function() { + b.socketType = "WebSocket"; + b.initHardware(a); + }.bind(this), a.onmessage = function(a) { + a = JSON.parse(a.data); + b.checkDevice(a); + b.updatePortData(a); + }.bind(this), a.onclose = function() { + "WebSocket" === b.socketType && (this.socket = null, b.initSocket()); + }; + } catch (d) { + } + try { + c = new WebSocket("wss://hardware.play-entry.org:23518"); + } catch (d) { + } } + c.binaryType = "arraybuffer"; + c.onopen = function() { + b.socketType = "WebSocketSecurity"; + b.initHardware(c); + }; + c.onmessage = function(a) { + a = JSON.parse(a.data); + b.checkDevice(a); + b.updatePortData(a); + }; + c.onclose = function() { + "WebSocketSecurity" === b.socketType && (this.socket = null, b.initSocket()); + }; + Entry.dispatchEvent("hwChanged"); } + } catch (d) { } }; -Entry.Scene.prototype.getNextScene = function() { - var a = this.getScenes(); - return a[a.indexOf(this.selectedScene) + 1]; +p.retryConnect = function() { + this.connectTrial = 0; + this.initSocket(); }; -Entry.Script = function(a) { - this.entity = a; +p.initHardware = function(b) { + this.socket = b; + this.connectTrial = 0; + this.connected = !0; + Entry.dispatchEvent("hwChanged"); + Entry.playground && Entry.playground.object && Entry.playground.setMenu(Entry.playground.object.objectType); }; -p = Entry.Script.prototype; -p.init = function(a, b, c) { - Entry.assert("BLOCK" == a.tagName.toUpperCase(), a.tagName); - this.type = a.getAttribute("type"); - this.id = Number(a.getAttribute("id")); - a.getElementsByTagName("mutation").length && a.getElementsByTagName("mutation")[0].hasAttribute("hashid") && (this.hashId = a.childNodes[0].getAttribute("hashid")); - "REPEAT" == this.type.substr(0, 6).toUpperCase() && (this.isRepeat = !0); - b instanceof Entry.Script && (this.previousScript = b, b.parentScript && (this.parentScript = b.parentScript)); - c instanceof Entry.Script && (this.parentScript = c); - a = a.childNodes; - for (b = 0;b < a.length;b++) { - if (c = a[b], "NEXT" == c.tagName.toUpperCase()) { - this.nextScript = new Entry.Script(this.entity), this.register && (this.nextScript.register = this.register), this.nextScript.init(a[b].childNodes[0], this); - } else { - if ("VALUE" == c.tagName.toUpperCase()) { - this.values || (this.values = {}); - var d = new Entry.Script(this.entity); - this.register && (d.register = this.register); - d.init(c.childNodes[0]); - this.values[c.getAttribute("name")] = d; - } else { - "FIELD" == c.tagName.toUpperCase() ? (this.fields || (this.fields = {}), this.fields[c.getAttribute("name")] = c.textContent) : "STATEMENT" == c.tagName.toUpperCase() && (this.statements || (this.statements = {}), d = new Entry.Script(this.entity), this.register && (d.register = this.register), d.init(c.childNodes[0], null, this), d.key = c.getAttribute("name"), this.statements[c.getAttribute("name")] = d); - } - } - } +p.setDigitalPortValue = function(b, a) { + this.sendQueue[b] = a; + this.removePortReadable(b); }; -p.clone = function(a, b) { - var c = new Entry.Script(a); - c.id = this.id; - c.type = this.type; - c.isRepeat = this.isRepeat; - if (this.parentScript && !this.previousScript && 2 != b) { - c.parentScript = this.parentScript.clone(a); - for (var d = c.parentScript.statements[this.key] = c;d.nextScript;) { - d = d.nextScript, d.parentScript = c.parentScript; - } - } - this.nextScript && 1 != b && (c.nextScript = this.nextScript.clone(a, 0), c.nextScript.previousScript = this); - this.previousScript && 0 !== b && (c.previousScript = this.previousScript.clone(a, 1), c.previousScript.previousScript = this); - if (this.fields) { - c.fields = {}; - for (var e in this.fields) { - c.fields[e] = this.fields[e]; - } +p.getAnalogPortValue = function(b) { + return this.connected ? this.portData["a" + b] : 0; +}; +p.getDigitalPortValue = function(b) { + if (!this.connected) { + return 0; } - if (this.values) { - for (e in c.values = {}, this.values) { - c.values[e] = this.values[e].clone(a); + this.setPortReadable(b); + return void 0 !== this.portData[b] ? this.portData[b] : 0; +}; +p.setPortReadable = function(b) { + this.sendQueue.readablePorts || (this.sendQueue.readablePorts = []); + var a = !1, c; + for (c in this.sendQueue.readablePorts) { + if (this.sendQueue.readablePorts[c] == b) { + a = !0; + break; } } - if (this.statements) { - for (e in c.statements = {}, this.statements) { - for (c.statements[e] = this.statements[e].clone(a, 2), d = c.statements[e], d.parentScript = c;d.nextScript;) { - d = d.nextScript, d.parentScript = c; + a || this.sendQueue.readablePorts.push(b); +}; +p.removePortReadable = function(b) { + if (this.sendQueue.readablePorts || Array.isArray(this.sendQueue.readablePorts)) { + var a, c; + for (c in this.sendQueue.readablePorts) { + if (this.sendQueue.readablePorts[c] == b) { + a = +c; + break; } } + this.sendQueue.readablePorts = void 0 != a ? this.sendQueue.readablePorts.slice(0, a).concat(this.sendQueue.readablePorts.slice(a + 1, this.sendQueue.readablePorts.length)) : []; } - return c; }; -p.getStatement = function(a) { - return this.statements[a]; +p.update = function() { + this.socket && 1 == this.socket.readyState && this.socket.send(JSON.stringify(this.sendQueue)); +}; +p.updatePortData = function(b) { + this.portData = b; + this.hwMonitor && this.hwMonitor.update(); }; -p.compute = function() { +p.closeConnection = function() { + this.socket && this.socket.close(); +}; +p.downloadConnector = function() { + window.open("http://download.play-entry.org/apps/Entry_HW_1.5.6_Setup.exe", "_blank").focus(); }; -p.getValue = function(a) { - return this.values[a].run(); +p.downloadSource = function() { + window.open("http://play-entry.com/down/board.ino", "_blank").focus(); }; -p.getNumberValue = function(a) { - return Number(this.values[a].run()); +p.setZero = function() { + Entry.hw.hwModule && Entry.hw.hwModule.setZero(); }; -p.getStringValue = function(a) { - return String(this.values[a].run()); +p.checkDevice = function(b) { + void 0 !== b.company && (b = "" + b.company + b.model, b != this.selectedDevice && (this.selectedDevice = b, this.hwModule = this.hwInfo[b], Entry.dispatchEvent("hwChanged"), Entry.toast.success("\ud558\ub4dc\uc6e8\uc5b4 \uc5f0\uacb0 \uc131\uacf5", "\ud558\ub4dc\uc6e8\uc5b4 \uc544\uc774\ucf58\uc744 \ub354\ube14\ud074\ub9ad\ud558\uba74, \uc13c\uc11c\uac12\ub9cc \ud655\uc778\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.", !0), this.hwModule.monitorTemplate && (this.hwMonitor ? (this.hwMonitor._hwModule = + this.hwModule, this.hwMonitor.initView()) : this.hwMonitor = new Entry.HWMonitor(this.hwModule), Entry.propertyPanel.addMode("hw", this.hwMonitor), b = this.hwModule.monitorTemplate, "both" == b.mode ? (b.mode = "list", this.hwMonitor.generateListView(), b.mode = "general", this.hwMonitor.generateView(), b.mode = "both") : "list" == b.mode ? this.hwMonitor.generateListView() : this.hwMonitor.generateView()))); }; -p.getBooleanValue = function(a) { - return this.values[a].run() ? !0 : !1; +p.banHW = function() { + var b = this.hwInfo, a; + for (a in b) { + Entry.playground.mainWorkspace.blockMenu.banClass(b[a].name, !0); + } }; -p.getField = function(a) { - return this.fields[a]; +Entry.BlockModel = function() { + Entry.Model(this); }; -p.getStringField = function(a) { - return String(this.fields[a]); +Entry.BlockModel.prototype.schema = {id:null, x:0, y:0, type:null, params:{}, statements:{}, prev:null, next:null, view:null}; +Entry.BlockRenderModel = function() { + Entry.Model(this); }; -p.getNumberField = function(a) { - return Number(this.fields[a]); +Entry.BlockRenderModel.prototype.schema = {id:0, type:Entry.STATIC.BLOCK_RENDER_MODEL, x:0, y:0, width:0, height:0, magneting:!1}; +Entry.BoxModel = function() { + Entry.Model(this); }; -p.callReturn = function() { - return this.nextScript ? this.nextScript : this.parentScript ? this.parentScript : null; +Entry.BoxModel.prototype.schema = {id:0, type:Entry.STATIC.BOX_MODEL, x:0, y:0, width:0, height:0}; +Entry.DragInstance = function(b) { + Entry.Model(this); + this.set(b); }; -p.run = function() { - return Entry.block[this.type](this.entity, this); +Entry.DragInstance.prototype.schema = {type:Entry.STATIC.DRAG_INSTANCE, startX:0, startY:0, offsetX:0, offsetY:0, absX:0, absY:0, prev:null, height:0, mode:0, isNew:!1}; +Entry.ThreadModel = function() { + Entry.Model(this); }; +Entry.ThreadModel.prototype.schema = {id:0, type:Entry.STATIC.THREAD_MODEL, x:0, y:0, width:0, minWidth:0, height:0}; Entry.Stage = function() { this.variables = {}; this.background = new createjs.Shape; @@ -13664,8 +12701,8 @@ Entry.Stage = function() { this.selectedObject = null; this.isObjectClick = !1; }; -Entry.Stage.prototype.initStage = function(a) { - this.canvas = new createjs.Stage(a.id); +Entry.Stage.prototype.initStage = function(b) { + this.canvas = new createjs.Stage(b.id); this.canvas.x = 320; this.canvas.y = 180; this.canvas.scaleX = this.canvas.scaleY = 2 / 1.5; @@ -13680,26 +12717,26 @@ Entry.Stage.prototype.initStage = function(a) { this.initHandle(); this.mouseCoordinate = {x:0, y:0}; if (Entry.isPhone()) { - a.ontouchstart = function(a) { + b.ontouchstart = function(a) { Entry.dispatchEvent("canvasClick", a); Entry.stage.isClick = !0; - }, a.ontouchend = function(a) { + }, b.ontouchend = function(a) { Entry.stage.isClick = !1; Entry.dispatchEvent("canvasClickCanceled", a); }; } else { - var b = function(a) { + var a = function(a) { Entry.dispatchEvent("canvasClick", a); Entry.stage.isClick = !0; }; - a.onmousedown = b; - a.ontouchstart = b; - b = function(a) { + b.onmousedown = a; + b.ontouchstart = a; + a = function(a) { Entry.stage.isClick = !1; Entry.dispatchEvent("canvasClickCanceled", a); }; - a.onmouseup = b; - a.ontouchend = b; + b.onmouseup = a; + b.ontouchend = a; $(document).click(function(a) { Entry.stage.focused = "entryCanvas" === a.target.id ? !0 : !1; }); @@ -13710,7 +12747,7 @@ Entry.Stage.prototype.initStage = function(a) { Entry.windowResized.attach(this, function() { Entry.stage.updateBoundRect(); }); - b = function(a) { + a = function(a) { a.preventDefault(); var b = Entry.stage.getBoundRect(), e; -1 < Entry.getBrowserType().indexOf("IE") ? (e = 480 * ((a.pageX - b.left - document.documentElement.scrollLeft) / b.width - .5), a = -270 * ((a.pageY - b.top - document.documentElement.scrollTop) / b.height - .5)) : a.changedTouches ? (e = 480 * ((a.changedTouches[0].pageX - b.left - document.body.scrollLeft) / b.width - .5), a = -270 * ((a.changedTouches[0].pageY - b.top - document.body.scrollTop) / b.height - .5)) : (e = 480 * ((a.pageX - b.left - document.body.scrollLeft) / b.width - .5), @@ -13718,9 +12755,9 @@ Entry.Stage.prototype.initStage = function(a) { Entry.stage.mouseCoordinate = {x:e.toFixed(1), y:a.toFixed(1)}; Entry.dispatchEvent("stageMouseMove"); }; - a.onmousemove = b; - a.ontouchmove = b; - a.onmouseout = function(a) { + b.onmousemove = a; + b.ontouchmove = a; + b.onmouseout = function(a) { Entry.dispatchEvent("stageMouseOut"); }; Entry.addEventListener("updateObject", function(a) { @@ -13743,68 +12780,68 @@ Entry.Stage.prototype.initStage = function(a) { }; Entry.Stage.prototype.render = function() { Entry.stage.timer && clearTimeout(Entry.stage.timer); - var a = (new Date).getTime(); + var b = (new Date).getTime(); Entry.stage.update(); - a = (new Date).getTime() - a; - Entry.stage.timer = setTimeout(Entry.stage.render, 16 - a % 16 + 16 * Math.floor(a / 16)); + b = (new Date).getTime() - b; + Entry.stage.timer = setTimeout(Entry.stage.render, 16 - b % 16 + 16 * Math.floor(b / 16)); }; Entry.Stage.prototype.update = function() { Entry.requestUpdate && (Entry.engine.isState("stop") && this.objectUpdated ? (this.canvas.update(), this.objectUpdated = !1) : this.canvas.update(), this.inputField && !this.inputField._isHidden && this.inputField.render()); Entry.requestUpdate = !1; }; -Entry.Stage.prototype.loadObject = function(a) { - var b = a.entity.object; - this.getObjectContainerByScene(a.scene).addChild(b); +Entry.Stage.prototype.loadObject = function(b) { + var a = b.entity.object; + this.getObjectContainerByScene(b.scene).addChild(a); this.canvas.update(); }; -Entry.Stage.prototype.loadEntity = function(a) { - Entry.stage.getObjectContainerByScene(a.parent.scene).addChild(a.object); +Entry.Stage.prototype.loadEntity = function(b) { + Entry.stage.getObjectContainerByScene(b.parent.scene).addChild(b.object); this.sortZorder(); }; -Entry.Stage.prototype.unloadEntity = function(a) { - Entry.stage.getObjectContainerByScene(a.parent.scene).removeChild(a.object); +Entry.Stage.prototype.unloadEntity = function(b) { + Entry.stage.getObjectContainerByScene(b.parent.scene).removeChild(b.object); }; -Entry.Stage.prototype.loadVariable = function(a) { - var b = a.view_; - this.variables[a.id] = b; - this.variableContainer.addChild(b); +Entry.Stage.prototype.loadVariable = function(b) { + var a = b.view_; + this.variables[b.id] = a; + this.variableContainer.addChild(a); Entry.requestUpdate = !0; }; -Entry.Stage.prototype.removeVariable = function(a) { - this.variableContainer.removeChild(a.view_); +Entry.Stage.prototype.removeVariable = function(b) { + this.variableContainer.removeChild(b.view_); Entry.requestUpdate = !0; }; -Entry.Stage.prototype.loadDialog = function(a) { - this.dialogContainer.addChild(a.object); +Entry.Stage.prototype.loadDialog = function(b) { + this.dialogContainer.addChild(b.object); }; -Entry.Stage.prototype.unloadDialog = function(a) { - this.dialogContainer.removeChild(a.object); +Entry.Stage.prototype.unloadDialog = function(b) { + this.dialogContainer.removeChild(b.object); }; Entry.Stage.prototype.sortZorder = function() { - for (var a = Entry.container.getCurrentObjects(), b = this.selectedObjectContainer, c = 0, d = a.length - 1;0 <= d;d--) { - for (var e = a[d], f = e.entity, e = e.clonedEntities, g = 0, h = e.length;g < h;g++) { - e[g].shape && b.setChildIndex(e[g].shape, c++), b.setChildIndex(e[g].object, c++); + for (var b = Entry.container.getCurrentObjects(), a = this.selectedObjectContainer, c = 0, d = b.length - 1;0 <= d;d--) { + for (var e = b[d], f = e.entity, e = e.clonedEntities, g = 0, h = e.length;g < h;g++) { + e[g].shape && a.setChildIndex(e[g].shape, c++), a.setChildIndex(e[g].object, c++); } - f.shape && b.setChildIndex(f.shape, c++); - b.setChildIndex(f.object, c++); + f.shape && a.setChildIndex(f.shape, c++); + a.setChildIndex(f.object, c++); } }; Entry.Stage.prototype.initCoordinator = function() { - var a = new createjs.Container, b = new createjs.Bitmap(Entry.mediaFilePath + "workspace_coordinate.png"); - b.scaleX = .5; - b.scaleY = .5; - b.x = -240; - b.y = -135; - a.addChild(b); - this.canvas.addChild(a); - a.visible = !1; - this.coordinator = a; + var b = new createjs.Container, a = new createjs.Bitmap(Entry.mediaFilePath + "workspace_coordinate.png"); + a.scaleX = .5; + a.scaleY = .5; + a.x = -240; + a.y = -135; + b.addChild(a); + this.canvas.addChild(b); + b.visible = !1; + this.coordinator = b; }; Entry.Stage.prototype.toggleCoordinator = function() { this.coordinator.visible = !this.coordinator.visible; }; -Entry.Stage.prototype.selectObject = function(a) { - this.selectedObject = a ? a : null; +Entry.Stage.prototype.selectObject = function(b) { + this.selectedObject = b ? b : null; this.updateObject(); }; Entry.Stage.prototype.initHandle = function() { @@ -13817,47 +12854,47 @@ Entry.Stage.prototype.updateObject = function() { Entry.requestUpdate = !0; this.handle.setDraggable(!0); if (!this.editEntity) { - var a = this.selectedObject; - if (a) { - "textBox" == a.objectType ? this.handle.toggleCenter(!1) : this.handle.toggleCenter(!0); - "free" == a.getRotateMethod() ? this.handle.toggleRotation(!0) : this.handle.toggleRotation(!1); + var b = this.selectedObject; + if (b) { + "textBox" == b.objectType ? this.handle.toggleCenter(!1) : this.handle.toggleCenter(!0); + "free" == b.getRotateMethod() ? this.handle.toggleRotation(!0) : this.handle.toggleRotation(!1); this.handle.toggleDirection(!0); - a.getLock() ? (this.handle.toggleRotation(!1), this.handle.toggleDirection(!1), this.handle.toggleResize(!1), this.handle.toggleCenter(!1), this.handle.setDraggable(!1)) : this.handle.toggleResize(!0); + b.getLock() ? (this.handle.toggleRotation(!1), this.handle.toggleDirection(!1), this.handle.toggleResize(!1), this.handle.toggleCenter(!1), this.handle.setDraggable(!1)) : this.handle.toggleResize(!0); this.handle.setVisible(!0); - var b = a.entity; - this.handle.setWidth(b.getScaleX() * b.getWidth()); - this.handle.setHeight(b.getScaleY() * b.getHeight()); + var a = b.entity; + this.handle.setWidth(a.getScaleX() * a.getWidth()); + this.handle.setHeight(a.getScaleY() * a.getHeight()); var c, d; - if ("textBox" == b.type) { - if (b.getLineBreak()) { - c = b.regX * b.scaleX, d = -b.regY * b.scaleY; + if ("textBox" == a.type) { + if (a.getLineBreak()) { + c = a.regX * a.scaleX, d = -a.regY * a.scaleY; } else { - var e = b.getTextAlign(); - d = -b.regY * b.scaleY; + var e = a.getTextAlign(); + d = -a.regY * a.scaleY; switch(e) { case Entry.TEXT_ALIGN_LEFT: - c = -b.getWidth() / 2 * b.scaleX; + c = -a.getWidth() / 2 * a.scaleX; break; case Entry.TEXT_ALIGN_CENTER: - c = b.regX * b.scaleX; + c = a.regX * a.scaleX; break; case Entry.TEXT_ALIGN_RIGHT: - c = b.getWidth() / 2 * b.scaleX; + c = a.getWidth() / 2 * a.scaleX; } } } else { - c = (b.regX - b.width / 2) * b.scaleX, d = (b.height / 2 - b.regY) * b.scaleY; + c = (a.regX - a.width / 2) * a.scaleX, d = (a.height / 2 - a.regY) * a.scaleY; } - e = b.getRotation() / 180 * Math.PI; - this.handle.setX(b.getX() - c * Math.cos(e) - d * Math.sin(e)); - this.handle.setY(-b.getY() - c * Math.sin(e) + d * Math.cos(e)); - this.handle.setRegX((b.regX - b.width / 2) * b.scaleX); - this.handle.setRegY((b.regY - b.height / 2) * b.scaleY); - this.handle.setRotation(b.getRotation()); - this.handle.setDirection(b.getDirection()); + e = a.getRotation() / 180 * Math.PI; + this.handle.setX(a.getX() - c * Math.cos(e) - d * Math.sin(e)); + this.handle.setY(-a.getY() - c * Math.sin(e) + d * Math.cos(e)); + this.handle.setRegX((a.regX - a.width / 2) * a.scaleX); + this.handle.setRegY((a.regY - a.height / 2) * a.scaleY); + this.handle.setRotation(a.getRotation()); + this.handle.setDirection(a.getDirection()); this.objectUpdated = !0; - this.handle.setVisible(a.entity.getVisible()); - a.entity.getVisible() && this.handle.render(); + this.handle.setVisible(b.entity.getVisible()); + b.entity.getVisible() && this.handle.render(); } else { this.handle.setVisible(!1); } @@ -13865,41 +12902,41 @@ Entry.Stage.prototype.updateObject = function() { }; Entry.Stage.prototype.updateHandle = function() { this.editEntity = !0; - var a = this.handle, b = this.selectedObject.entity; - if (b.lineBreak) { - b.setHeight(a.height / b.getScaleY()), b.setWidth(a.width / b.getScaleX()); + var b = this.handle, a = this.selectedObject.entity; + if (a.lineBreak) { + a.setHeight(b.height / a.getScaleY()), a.setWidth(b.width / a.getScaleX()); } else { - if (0 !== b.width) { - var c = Math.abs(a.width / b.width); - b.flip && (c *= -1); - b.setScaleX(c); - } - 0 !== b.height && b.setScaleY(a.height / b.height); - } - c = a.rotation / 180 * Math.PI; - if ("textBox" == b.type) { - var d; - if (b.getLineBreak()) { - b.setX(a.x), b.setY(-a.y); + if (0 !== a.width) { + var c = Math.abs(b.width / a.width); + a.flip && (c *= -1); + a.setScaleX(c); + } + 0 !== a.height && a.setScaleY(b.height / a.height); + } + c = b.rotation / 180 * Math.PI; + if ("textBox" == a.type) { + var d = b.regX / a.scaleX, d = b.regY / a.scaleY; + if (a.getLineBreak()) { + a.setX(b.x), a.setY(-b.y); } else { - switch(b.getTextAlign()) { + switch(a.getTextAlign()) { case Entry.TEXT_ALIGN_LEFT: - b.setX(a.x - a.width / 2 * Math.cos(c)); - b.setY(-a.y + a.width / 2 * Math.sin(c)); + a.setX(b.x - b.width / 2 * Math.cos(c)); + a.setY(-b.y + b.width / 2 * Math.sin(c)); break; case Entry.TEXT_ALIGN_CENTER: - b.setX(a.x); - b.setY(-a.y); + a.setX(b.x); + a.setY(-b.y); break; case Entry.TEXT_ALIGN_RIGHT: - b.setX(a.x + a.width / 2 * Math.cos(c)), b.setY(-a.y - a.width / 2 * Math.sin(c)); + a.setX(b.x + b.width / 2 * Math.cos(c)), a.setY(-b.y - b.width / 2 * Math.sin(c)); } } } else { - d = b.width / 2 + a.regX / b.scaleX, b.setX(a.x + a.regX * Math.cos(c) - a.regY * Math.sin(c)), b.setRegX(d), d = b.height / 2 + a.regY / b.scaleY, b.setY(-a.y - a.regX * Math.sin(c) - a.regY * Math.cos(c)), b.setRegY(d); + d = a.width / 2 + b.regX / a.scaleX, a.setX(b.x + b.regX * Math.cos(c) - b.regY * Math.sin(c)), a.setRegX(d), d = a.height / 2 + b.regY / a.scaleY, a.setY(-b.y - b.regX * Math.sin(c) - b.regY * Math.cos(c)), a.setRegY(d); } - b.setDirection(a.direction); - b.setRotation(a.rotation); + a.setDirection(b.direction); + a.setRotation(b.rotation); this.selectedObject.entity.doCommand(); this.editEntity = !1; }; @@ -13910,55 +12947,55 @@ Entry.Stage.prototype.endEdit = function() { this.selectedObject.entity.checkCommand(); }; Entry.Stage.prototype.initWall = function() { - var a = new createjs.Container, b = new Image; - b.src = Entry.mediaFilePath + "media/bound.png"; - a.up = new createjs.Bitmap; - a.up.scaleX = 16; - a.up.y = -165; - a.up.x = -240; - a.up.image = b; - a.addChild(a.up); - a.down = new createjs.Bitmap; - a.down.scaleX = 16; - a.down.y = 135; - a.down.x = -240; - a.down.image = b; - a.addChild(a.down); - a.right = new createjs.Bitmap; - a.right.scaleY = 9; - a.right.y = -135; - a.right.x = 240; - a.right.image = b; - a.addChild(a.right); - a.left = new createjs.Bitmap; - a.left.scaleY = 9; - a.left.y = -135; - a.left.x = -270; - a.left.image = b; - a.addChild(a.left); - this.canvas.addChild(a); - this.wall = a; -}; -Entry.Stage.prototype.showInputField = function(a) { - a = 1 / 1.5; - this.inputField || (this.inputField = new CanvasInput({canvas:document.getElementById("entryCanvas"), fontSize:30 * a, fontFamily:"NanumGothic", fontColor:"#212121", width:556 * a, height:26 * a, padding:8 * a, borderWidth:1 * a, borderColor:"#000", borderRadius:3 * a, boxShadow:"none", innerShadow:"0px 0px 5px rgba(0, 0, 0, 0.5)", x:202 * a, y:450 * a, topPosition:!0, onsubmit:function() { + var b = new createjs.Container, a = new Image; + a.src = Entry.mediaFilePath + "media/bound.png"; + b.up = new createjs.Bitmap; + b.up.scaleX = 16; + b.up.y = -165; + b.up.x = -240; + b.up.image = a; + b.addChild(b.up); + b.down = new createjs.Bitmap; + b.down.scaleX = 16; + b.down.y = 135; + b.down.x = -240; + b.down.image = a; + b.addChild(b.down); + b.right = new createjs.Bitmap; + b.right.scaleY = 9; + b.right.y = -135; + b.right.x = 240; + b.right.image = a; + b.addChild(b.right); + b.left = new createjs.Bitmap; + b.left.scaleY = 9; + b.left.y = -135; + b.left.x = -270; + b.left.image = a; + b.addChild(b.left); + this.canvas.addChild(b); + this.wall = b; +}; +Entry.Stage.prototype.showInputField = function(b) { + b = 1 / 1.5; + this.inputField || (this.inputField = new CanvasInput({canvas:document.getElementById("entryCanvas"), fontSize:30 * b, fontFamily:"NanumGothic", fontColor:"#212121", width:556 * b, height:26 * b, padding:8 * b, borderWidth:1 * b, borderColor:"#000", borderRadius:3 * b, boxShadow:"none", innerShadow:"0px 0px 5px rgba(0, 0, 0, 0.5)", x:202 * b, y:450 * b, topPosition:!0, onsubmit:function() { Entry.dispatchEvent("canvasInputComplete"); }})); - a = new createjs.Container; - var b = new Image; - b.src = Entry.mediaFilePath + "confirm_button.png"; + b = new createjs.Container; + var a = new Image; + a.src = Entry.mediaFilePath + "confirm_button.png"; var c = new createjs.Bitmap; c.scaleX = .23; c.scaleY = .23; c.x = 160; c.y = 89; c.cursor = "pointer"; - c.image = b; - a.addChild(c); - a.on("mousedown", function(a) { + c.image = a; + b.addChild(c); + b.on("mousedown", function(a) { Entry.dispatchEvent("canvasInputComplete"); }); - this.inputSubmitButton || (this.inputField.value(""), this.canvas.addChild(a), this.inputSubmitButton = a); + this.inputSubmitButton || (this.inputField.value(""), this.canvas.addChild(b), this.inputSubmitButton = b); this.inputField.show(); }; Entry.Stage.prototype.hideInputField = function() { @@ -13967,286 +13004,103 @@ Entry.Stage.prototype.hideInputField = function() { this.inputField && this.inputField.hide(); }; Entry.Stage.prototype.initObjectContainers = function() { - var a = Entry.scene.scenes_; - if (a && 0 !== a.length) { - for (var b = 0;b < a.length;b++) { - this.objectContainers[b] = this.createObjectContainer(a[b]); + var b = Entry.scene.scenes_; + if (b && 0 !== b.length) { + for (var a = 0;a < b.length;a++) { + this.objectContainers[a] = this.createObjectContainer(b[a]); } this.selectedObjectContainer = this.objectContainers[0]; } else { - a = this.createObjectContainer(Entry.scene.selectedScene), this.objectContainers.push(a), this.selectedObjectContainer = a; + b = this.createObjectContainer(Entry.scene.selectedScene), this.objectContainers.push(b), this.selectedObjectContainer = b; } this.canvas.addChild(this.selectedObjectContainer); this.selectObjectContainer(Entry.scene.selectedScene); }; -Entry.Stage.prototype.selectObjectContainer = function(a) { +Entry.Stage.prototype.selectObjectContainer = function(b) { if (this.canvas) { - for (var b = this.objectContainers, c = 0;c < b.length;c++) { - this.canvas.removeChild(b[c]); + for (var a = this.objectContainers, c = 0;c < a.length;c++) { + this.canvas.removeChild(a[c]); } - this.selectedObjectContainer = this.getObjectContainerByScene(a); + this.selectedObjectContainer = this.getObjectContainerByScene(b); this.canvas.addChildAt(this.selectedObjectContainer, 2); } }; Entry.Stage.prototype.reAttachToCanvas = function() { - for (var a = [this.selectedObjectContainer, this.variableContainer, this.coordinator, this.handle, this.dialogContainer], b = 0;b < a.length;b++) { - this.canvas.removeChild(a[b]), this.canvas.addChild(a[b]); + for (var b = [this.selectedObjectContainer, this.variableContainer, this.coordinator, this.handle, this.dialogContainer], a = 0;a < b.length;a++) { + this.canvas.removeChild(b[a]), this.canvas.addChild(b[a]); } console.log(this.canvas.getChildIndex(this.selectedObjectContainer)); }; -Entry.Stage.prototype.createObjectContainer = function(a) { - var b = new createjs.Container; - b.scene = a; - return b; +Entry.Stage.prototype.createObjectContainer = function(b) { + var a = new createjs.Container; + a.scene = b; + return a; }; -Entry.Stage.prototype.removeObjectContainer = function(a) { - var b = this.objectContainers; - a = this.getObjectContainerByScene(a); - this.canvas.removeChild(a); - b.splice(this.objectContainers.indexOf(a), 1); +Entry.Stage.prototype.removeObjectContainer = function(b) { + var a = this.objectContainers; + b = this.getObjectContainerByScene(b); + this.canvas.removeChild(b); + a.splice(this.objectContainers.indexOf(b), 1); }; -Entry.Stage.prototype.getObjectContainerByScene = function(a) { - for (var b = this.objectContainers, c = 0;c < b.length;c++) { - if (b[c].scene.id == a.id) { - return b[c]; +Entry.Stage.prototype.getObjectContainerByScene = function(b) { + for (var a = this.objectContainers, c = 0;c < a.length;c++) { + if (a[c].scene.id == b.id) { + return a[c]; } } }; -Entry.Stage.prototype.moveSprite = function(a) { +Entry.Stage.prototype.moveSprite = function(b) { if (this.selectedObject && Entry.stage.focused && !this.selectedObject.getLock()) { - var b = 5; - a.shiftKey && (b = 1); + var a = 5; + b.shiftKey && (a = 1); var c = this.selectedObject.entity; - switch(a.keyCode) { + switch(b.keyCode) { case 38: - c.setY(c.getY() + b); + c.setY(c.getY() + a); break; case 40: - c.setY(c.getY() - b); + c.setY(c.getY() - a); break; case 37: - c.setX(c.getX() - b); + c.setX(c.getX() - a); break; case 39: - c.setX(c.getX() + b); + c.setX(c.getX() + a); } this.updateObject(); } }; -Entry.Stage.prototype.getBoundRect = function(a) { +Entry.Stage.prototype.getBoundRect = function(b) { this._boundRect || this.updateBoundRect(); return this._boundRect; }; -Entry.Stage.prototype.updateBoundRect = function(a) { +Entry.Stage.prototype.updateBoundRect = function(b) { this._boundRect = this.canvas.canvas.getBoundingClientRect(); }; -Entry.StampEntity = function(a, b) { - this.parent = a; - this.type = a.objectType; - this.isStamp = this.isClone = !0; - this.width = b.getWidth(); - this.height = b.getHeight(); - "sprite" == this.type && (this.object = b.object.clone(!0), this.object.filters = null, b.effect && (this.effect = Entry.cloneSimpleObject(b.effect), this.applyFilter())); - this.object.entity = this; - b.dialog && (a = b.dialog, new Entry.Dialog(this, a.message_, a.mode_, !0), this.dialog.object = b.dialog.object.clone(!0), Entry.stage.loadDialog(this.dialog)); -}; -var EntityPrototype = Entry.EntityObject.prototype; -Entry.StampEntity.prototype.applyFilter = EntityPrototype.applyFilter; -Entry.StampEntity.prototype.removeClone = EntityPrototype.removeClone; -Entry.StampEntity.prototype.getWidth = EntityPrototype.getWidth; -Entry.StampEntity.prototype.getHeight = EntityPrototype.getHeight; -Entry.StampEntity.prototype.getInitialEffectValue = EntityPrototype.getInitialEffectValue; -Entry.Toast = function() { - this.toasts_ = []; - var a = document.getElementById("entryToastContainer"); - a && document.body.removeChild(a); - this.body_ = Entry.createElement("div", "entryToastContainer"); - this.body_.addClass("entryToastContainer"); - document.body.appendChild(this.body_); -}; -Entry.Toast.prototype.warning = function(a, b, c) { - var d = Entry.createElement("div", "entryToast"); - d.addClass("entryToast"); - d.addClass("entryToastWarning"); - d.bindOnClick(function() { - Entry.toast.body_.removeChild(this); - }); - var e = Entry.createElement("div", "entryToast"); - e.addClass("entryToastTitle"); - e.innerHTML = a; - d.appendChild(e); - a = Entry.createElement("p", "entryToast"); - a.addClass("entryToastMessage"); - a.innerHTML = b; - d.appendChild(a); - this.toasts_.push(d); - this.body_.appendChild(d); - c || window.setTimeout(function() { - d.style.opacity = 1; - var a = setInterval(function() { - .05 > d.style.opacity && (clearInterval(a), d.style.display = "none", Entry.removeElement(d)); - d.style.opacity *= .9; - }, 20); - }, 1E3); -}; -Entry.Toast.prototype.success = function(a, b, c) { - var d = Entry.createElement("div", "entryToast"); - d.addClass("entryToast"); - d.addClass("entryToastSuccess"); - d.bindOnClick(function() { - Entry.toast.body_.removeChild(this); - }); - var e = Entry.createElement("div", "entryToast"); - e.addClass("entryToastTitle"); - e.innerHTML = a; - d.appendChild(e); - a = Entry.createElement("p", "entryToast"); - a.addClass("entryToastMessage"); - a.innerHTML = b; - d.appendChild(a); - this.toasts_.push(d); - this.body_.appendChild(d); - c || window.setTimeout(function() { - d.style.opacity = 1; - var a = setInterval(function() { - .05 > d.style.opacity && (clearInterval(a), d.style.display = "none", Entry.removeElement(d)); - d.style.opacity *= .9; - }, 20); - }, 1E3); -}; -Entry.Toast.prototype.alert = function(a, b, c) { - var d = Entry.createElement("div", "entryToast"); - d.addClass("entryToast"); - d.addClass("entryToastAlert"); - d.bindOnClick(function() { - Entry.toast.body_.removeChild(this); - }); - var e = Entry.createElement("div", "entryToast"); - e.addClass("entryToastTitle"); - e.innerHTML = a; - d.appendChild(e); - a = Entry.createElement("p", "entryToast"); - a.addClass("entryToastMessage"); - a.innerHTML = b; - d.appendChild(a); - this.toasts_.push(d); - this.body_.appendChild(d); - c || window.setTimeout(function() { - d.style.opacity = 1; - var a = setInterval(function() { - .05 > d.style.opacity && (clearInterval(a), d.style.display = "none", Entry.toast.body_.removeChild(d)); - d.style.opacity *= .9; - }, 20); - }, 5E3); -}; -Entry.TvCast = function(a) { - this.generateView(a); -}; -p = Entry.TvCast.prototype; -p.init = function(a) { - this.tvCastHash = a; -}; -p.generateView = function(a) { - var b = Entry.createElement("div"); - b.addClass("entryContainerMovieWorkspace"); - b.addClass("entryRemove"); - this.movieContainer = b; - b = Entry.createElement("iframe"); - b.setAttribute("id", "tvCastIframe"); - b.setAttribute("allowfullscreen", ""); - b.setAttribute("frameborder", 0); - b.setAttribute("src", a); - this.movieFrame = b; - this.movieContainer.appendChild(this.movieFrame); -}; -p.getView = function() { - return this.movieContainer; -}; -p.resize = function() { - document.getElementById("entryContainerWorkspaceId"); - var a = document.getElementById("tvCastIframe"); - w = this.movieContainer.offsetWidth; - a.width = w + "px"; - a.height = 9 * w / 16 + "px"; -}; -Entry.ContextMenu = {}; -(function(a) { - a.createDom = function() { - this.dom = Entry.Dom("ul", {id:"entry-contextmenu", parent:$("body")}); - Entry.Utils.disableContextmenu(this.dom); - Entry.documentMousedown.attach(this, function() { - this.hide(); - }); - }; - a.show = function(a, c) { - this.dom || this.createDom(); - if (0 !== a.length) { - var d = this; - void 0 !== c && (this._className = c, this.dom.addClass(c)); - c = this.dom; - c.empty(); - for (var e = 0, f = a.length;e < f;e++) { - var g = a[e], h = g.text, k = !1 !== g.enable, l = Entry.Dom("li", {class:k ? "menuAble" : "menuDisable", parent:c}); - l.text(h); - k && g.callback && function(a, b) { - a.mousedown(function(a) { - a.preventDefault(); - d.hide(); - b(a); - }); - }(l, g.callback); - } - c.removeClass("entryRemove"); - this.position(Entry.mouseCoordinate); - } - }; - a.position = function(a) { - var c = this.dom; - c.css({left:0, top:0}); - var d = c.width(), e = c.height(), f = $(window), g = f.width(), f = f.height(); - a.x + d > g && (a.x -= d + 3); - a.y + e > f && (a.y -= e); - c.css({left:a.x, top:a.y}); - }; - a.hide = function() { - this.dom.empty(); - this.dom.addClass("entryRemove"); - this._className && (this.dom.removeClass(this._className), delete this._className); - }; -})(Entry.ContextMenu); -Entry.Loader = {queueCount:0}; -Entry.Loader.addQueue = function(a) { - this.queueCount || Entry.dispatchEvent("loadStart"); - this.queueCount++; -}; -Entry.Loader.removeQueue = function(a) { - this.queueCount--; - this.queueCount || Entry.dispatchEvent("loadComplete"); -}; -Entry.Variable = function(a) { - Entry.assert("string" == typeof a.name, "Variable name must be given"); - this.name_ = a.name; - this.id_ = a.id ? a.id : Entry.generateHash(); - this.type = a.variableType ? a.variableType : "variable"; - this.object_ = a.object || null; - this.isCloud_ = a.isCloud || !1; +Entry.Variable = function(b) { + Entry.assert("string" == typeof b.name, "Variable name must be given"); + this.name_ = b.name; + this.id_ = b.id ? b.id : Entry.generateHash(); + this.type = b.variableType ? b.variableType : "variable"; + this.object_ = b.object || null; + this.isCloud_ = b.isCloud || !1; this._valueWidth = this._nameWidth = null; - var b = Entry.parseNumber(a.value); - this.value_ = "number" == typeof b ? b : a.value ? a.value : 0; - "slide" == this.type ? (this.minValue_ = Number(a.minValue ? a.minValue : 0), this.maxValue_ = Number(a.maxValue ? a.maxValue : 100)) : "list" == this.type && (this.array_ = a.array ? a.array : []); - a.isClone || (this.visible_ = a.visible || "boolean" == typeof a.visible ? a.visible : !0, this.x_ = a.x ? a.x : null, this.y_ = a.y ? a.y : null, "list" == this.type && (this.width_ = a.width ? a.width : 100, this.height_ = a.height ? a.height : 120, this.scrollPosition = 0), this.BORDER = 6, this.FONT = "10pt NanumGothic"); -}; -Entry.Variable.prototype.generateView = function(a) { - var b = this.type; - if ("variable" == b || "timer" == b || "answer" == b) { + var a = Entry.parseNumber(b.value); + this.value_ = "number" == typeof a ? a : b.value ? b.value : 0; + "slide" == this.type ? (this.minValue_ = +(b.minValue ? b.minValue : 0), this.maxValue_ = +(b.maxValue ? b.maxValue : 100)) : "list" == this.type && (this.array_ = b.array ? b.array : []); + b.isClone || (this.visible_ = b.visible || "boolean" == typeof b.visible ? b.visible : !0, this.x_ = b.x ? b.x : null, this.y_ = b.y ? b.y : null, "list" == this.type && (this.width_ = b.width ? b.width : 100, this.height_ = b.height ? b.height : 120, this.scrollPosition = 0), this.BORDER = 6, this.FONT = "10pt NanumGothic"); +}; +Entry.Variable.prototype.generateView = function(b) { + var a = this.type; + if ("variable" == a || "timer" == a || "answer" == a) { this.view_ = new createjs.Container, this.rect_ = new createjs.Shape, this.view_.addChild(this.rect_), this.view_.variable = this, this.wrapper_ = new createjs.Shape, this.view_.addChild(this.wrapper_), this.textView_ = new createjs.Text("asdf", this.FONT, "#000000"), this.textView_.textBaseline = "alphabetic", this.textView_.x = 4, this.textView_.y = 1, this.view_.addChild(this.textView_), this.valueView_ = new createjs.Text("asdf", "10pt NanumGothic", "#ffffff"), this.valueView_.textBaseline = - "alphabetic", b = Entry.variableContainer.variables_.length, this.getX() && this.getY() ? (this.setX(this.getX()), this.setY(this.getY())) : (this.setX(-230 + 80 * Math.floor(b / 11)), this.setY(24 * a + 20 - 135 - 264 * Math.floor(b / 11))), this.view_.visible = this.visible_, this.view_.addChild(this.valueView_), this.view_.on("mousedown", function(a) { + "alphabetic", a = Entry.variableContainer.variables_.length, this.getX() && this.getY() ? (this.setX(this.getX()), this.setY(this.getY())) : (this.setX(-230 + 80 * Math.floor(a / 11)), this.setY(24 * b + 20 - 135 - 264 * Math.floor(a / 11))), this.view_.visible = this.visible_, this.view_.addChild(this.valueView_), this.view_.on("mousedown", function(a) { "workspace" == Entry.type && (this.offset = {x:this.x - (.75 * a.stageX - 240), y:this.y - (.75 * a.stageY - 135)}, this.cursor = "move"); }), this.view_.on("pressmove", function(a) { "workspace" == Entry.type && (this.variable.setX(.75 * a.stageX - 240 + this.offset.x), this.variable.setY(.75 * a.stageY - 135 + this.offset.y), this.variable.updateView()); }); } else { - if ("slide" == b) { + if ("slide" == a) { var c = this; this.view_ = new createjs.Container; this.rect_ = new createjs.Shape; @@ -14269,15 +13123,15 @@ Entry.Variable.prototype.generateView = function(a) { }); this.view_.visible = this.visible_; this.view_.addChild(this.valueView_); - b = this.textView_.getMeasuredWidth() + this.valueView_.getMeasuredWidth() + 26; - b = Math.max(b, 90); - this.maxWidth = b - 20; + a = this.textView_.getMeasuredWidth() + this.valueView_.getMeasuredWidth() + 26; + a = Math.max(a, 90); + this.maxWidth = a - 20; this.slideBar_ = new createjs.Shape; this.slideBar_.graphics.beginFill("#A0A1A1").s("#A0A1A1").ss(1).dr(10, 10, this.maxWidth, 1.5); this.view_.addChild(this.slideBar_); - b = this.getSlidePosition(this.maxWidth); + a = this.getSlidePosition(this.maxWidth); this.valueSetter_ = new createjs.Shape; - this.valueSetter_.graphics.beginFill("#1bafea").s("#A0A1A1").ss(1).dc(b, 10.5, 3); + this.valueSetter_.graphics.beginFill("#1bafea").s("#A0A1A1").ss(1).dc(a, 10.5, 3); this.valueSetter_.cursor = "pointer"; this.valueSetter_.on("mousedown", function(a) { Entry.engine.isState("run") && (c.isAdjusting = !0, this.offsetX = -(this.x - .75 * a.stageX + 240)); @@ -14293,8 +13147,8 @@ Entry.Variable.prototype.generateView = function(a) { c.isAdjusting = !1; }); this.view_.addChild(this.valueSetter_); - b = Entry.variableContainer.variables_.length; - this.getX() && this.getY() ? (this.setX(this.getX()), this.setY(this.getY())) : (this.setX(-230 + 80 * Math.floor(b / 11)), this.setY(24 * a + 20 - 135 - 264 * Math.floor(b / 11))); + a = Entry.variableContainer.variables_.length; + this.getX() && this.getY() ? (this.setX(this.getX()), this.setY(this.getY())) : (this.setX(-230 + 80 * Math.floor(a / 11)), this.setY(24 * b + 20 - 135 - 264 * Math.floor(a / 11))); } else { this.view_ = new createjs.Container, this.rect_ = new createjs.Shape, this.view_.addChild(this.rect_), this.view_.variable = this, this.titleView_ = new createjs.Text("asdf", this.FONT, "#000"), this.titleView_.textBaseline = "alphabetic", this.titleView_.textAlign = "center", this.titleView_.width = this.width_ - 2 * this.BORDER, this.titleView_.y = this.BORDER + 10, this.titleView_.x = this.width_ / 2, this.view_.addChild(this.titleView_), this.resizeHandle_ = new createjs.Shape, this.resizeHandle_.graphics.f("#1bafea").ss(1, 0, 0).s("#1bafea").lt(0, -9).lt(-9, 0).lt(0, 0), this.view_.addChild(this.resizeHandle_), this.resizeHandle_.list = this, this.resizeHandle_.on("mouseover", function(a) { @@ -14316,7 +13170,7 @@ Entry.Variable.prototype.generateView = function(a) { this.variable.isResizing = !1; }), this.view_.on("pressmove", function(a) { "workspace" != Entry.type || this.variable.isResizing || (this.variable.setX(.75 * a.stageX - 240 + this.offset.x), this.variable.setY(.75 * a.stageY - 135 + this.offset.y), this.variable.updateView()); - }), this.elementView = new createjs.Container, b = new createjs.Text("asdf", this.FONT, "#000"), b.textBaseline = "middle", b.y = 5, this.elementView.addChild(b), this.elementView.indexView = b, b = new createjs.Shape, this.elementView.addChild(b), this.elementView.valueWrapper = b, b = new createjs.Text("fdsa", this.FONT, "#eee"), b.x = 24, b.y = 6, b.textBaseline = "middle", this.elementView.addChild(b), this.elementView.valueView = b, this.elementView.x = this.BORDER, this.scrollButton_ = + }), this.elementView = new createjs.Container, a = new createjs.Text("asdf", this.FONT, "#000"), a.textBaseline = "middle", a.y = 5, this.elementView.addChild(a), this.elementView.indexView = a, a = new createjs.Shape, this.elementView.addChild(a), this.elementView.valueWrapper = a, a = new createjs.Text("fdsa", this.FONT, "#eee"), a.x = 24, a.y = 6, a.textBaseline = "middle", this.elementView.addChild(a), this.elementView.valueView = a, this.elementView.x = this.BORDER, this.scrollButton_ = new createjs.Shape, this.scrollButton_.graphics.f("#aaa").rr(0, 0, 7, 30, 3.5), this.view_.addChild(this.scrollButton_), this.scrollButton_.y = 23, this.scrollButton_.list = this, this.scrollButton_.on("mousedown", function(a) { this.list.isResizing = !0; this.cursor = "pointer"; @@ -14328,7 +13182,7 @@ Entry.Variable.prototype.generateView = function(a) { this.list.updateView(); }), this.scrollButton_.on("pressup", function(a) { this.moveAmount = void 0; - }), this.getX() && this.getY() ? (this.setX(this.getX()), this.setY(this.getY())) : (b = Entry.variableContainer.lists_.length, this.setX(110 * -Math.floor(b / 6) + 120), this.setY(24 * a + 20 - 135 - 145 * Math.floor(b / 6))); + }), this.getX() && this.getY() ? (this.setX(this.getX()), this.setY(this.getY())) : (a = Entry.variableContainer.lists_.length, this.setX(110 * -Math.floor(a / 6) + 120), this.setY(24 * b + 20 - 135 - 145 * Math.floor(a / 6))); } } this.setVisible(this.isVisible()); @@ -14342,8 +13196,8 @@ Entry.Variable.prototype.updateView = function() { this.view_.x = this.getX(); this.view_.y = this.getY(); if (this.object_) { - var a = Entry.container.getObject(this.object_); - this.textView_.text = a ? a.name + ":" + this.getName() : this.getName(); + var b = Entry.container.getObject(this.object_); + this.textView_.text = b ? b.name + ":" + this.getName() : this.getName(); } else { this.textView_.text = this.getName(); } @@ -14356,32 +13210,32 @@ Entry.Variable.prototype.updateView = function() { this.wrapper_.graphics.clear().f("#1bafea").ss(1, 2, 0).s("#1bafea").rc(this._nameWidth + 7, -11, this._valueWidth + 15, 14, 7, 7, 7, 7); } else { if ("slide" == this.type) { - this.view_.x = this.getX(), this.view_.y = this.getY(), this.object_ ? (a = Entry.container.getObject(this.object_), this.textView_.text = a ? a.name + ":" + this.getName() : this.getName()) : this.textView_.text = this.getName(), null === this._nameWidth && (this._nameWidth = this.textView_.getMeasuredWidth()), this.valueView_.x = this._nameWidth + 14, this.valueView_.y = 1, this.isNumber() ? this.valueView_.text = this.getValue().toFixed(2).replace(".00", "") : this.valueView_.text = - this.getValue(), null === this._valueWidth && (this._valueWidth = this.valueView_.getMeasuredWidth()), a = this._nameWidth + this._valueWidth + 26, a = Math.max(a, 90), this.rect_.graphics.clear().f("#ffffff").ss(1, 2, 0).s("#A0A1A1").rc(0, -14, a, 33, 4, 4, 4, 4), this.wrapper_.graphics.clear().f("#1bafea").ss(1, 2, 0).s("#1bafea").rc(this._nameWidth + 7, -11, this._valueWidth + 15, 14, 7, 7, 7, 7), a = this._nameWidth + this._valueWidth + 26, a = Math.max(a, 90), this.maxWidth = a - 20, - this.slideBar_.graphics.clear().beginFill("#A0A1A1").s("#A0A1A1").ss(1).dr(10, 10, this.maxWidth, 1.5), a = this.getSlidePosition(this.maxWidth), this.valueSetter_.graphics.clear().beginFill("#1bafea").s("#A0A1A1").ss(1).dc(a, 10.5, 3); + this.view_.x = this.getX(), this.view_.y = this.getY(), this.object_ ? (b = Entry.container.getObject(this.object_), this.textView_.text = b ? b.name + ":" + this.getName() : this.getName()) : this.textView_.text = this.getName(), null === this._nameWidth && (this._nameWidth = this.textView_.getMeasuredWidth()), this.valueView_.x = this._nameWidth + 14, this.valueView_.y = 1, this.isNumber() ? this.valueView_.text = this.getValue().toFixed(2).replace(".00", "") : this.valueView_.text = + this.getValue(), null === this._valueWidth && (this._valueWidth = this.valueView_.getMeasuredWidth()), b = this._nameWidth + this._valueWidth + 26, b = Math.max(b, 90), this.rect_.graphics.clear().f("#ffffff").ss(1, 2, 0).s("#A0A1A1").rc(0, -14, b, 33, 4, 4, 4, 4), this.wrapper_.graphics.clear().f("#1bafea").ss(1, 2, 0).s("#1bafea").rc(this._nameWidth + 7, -11, this._valueWidth + 15, 14, 7, 7, 7, 7), b = this._nameWidth + this._valueWidth + 26, b = Math.max(b, 90), this.maxWidth = b - 20, + this.slideBar_.graphics.clear().beginFill("#A0A1A1").s("#A0A1A1").ss(1).dr(10, 10, this.maxWidth, 1.5), b = this.getSlidePosition(this.maxWidth), this.valueSetter_.graphics.clear().beginFill("#1bafea").s("#A0A1A1").ss(1).dc(b, 10.5, 3); } else { if ("list" == this.type) { this.view_.x = this.getX(); this.view_.y = this.getY(); this.resizeHandle_.x = this.width_ - 2; this.resizeHandle_.y = this.height_ - 2; - var b = this.getName(); - this.object_ && (a = Entry.container.getObject(this.object_)) && (b = a.name + ":" + b); - b = 7 < b.length ? b.substr(0, 6) + ".." : b; - this.titleView_.text = b; + var a = this.getName(); + this.object_ && (b = Entry.container.getObject(this.object_)) && (a = b.name + ":" + a); + a = 7 < a.length ? a.substr(0, 6) + ".." : a; + this.titleView_.text = a; this.titleView_.x = this.width_ / 2; for (this.rect_.graphics.clear().f("#ffffff").ss(1, 2, 0).s("#A0A1A1").rect(0, 0, this.width_, this.height_);this.view_.children[4];) { this.view_.removeChild(this.view_.children[4]); } - a = Math.floor((this.getHeight() - 20) / 20); - a < this.array_.length ? (this.scrollButton_.y > this.getHeight() - 40 && (this.scrollButton_.y = this.getHeight() - 40), this.elementView.valueWrapper.graphics.clear().f("#1bafea").rr(20, -2, this.getWidth() - 20 - 10 - 2 * this.BORDER, 17, 2), this.scrollButton_.visible = !0, this.scrollButton_.x = this.getWidth() - 12, this.scrollPosition = Math.floor((this.scrollButton_.y - 23) / (this.getHeight() - 23 - 40) * (this.array_.length - a))) : (this.elementView.valueWrapper.graphics.clear().f("#1bafea").rr(20, + b = Math.floor((this.getHeight() - 20) / 20); + b < this.array_.length ? (this.scrollButton_.y > this.getHeight() - 40 && (this.scrollButton_.y = this.getHeight() - 40), this.elementView.valueWrapper.graphics.clear().f("#1bafea").rr(20, -2, this.getWidth() - 20 - 10 - 2 * this.BORDER, 17, 2), this.scrollButton_.visible = !0, this.scrollButton_.x = this.getWidth() - 12, this.scrollPosition = Math.floor((this.scrollButton_.y - 23) / (this.getHeight() - 23 - 40) * (this.array_.length - b))) : (this.elementView.valueWrapper.graphics.clear().f("#1bafea").rr(20, -2, this.getWidth() - 20 - 2 * this.BORDER, 17, 2), this.scrollButton_.visible = !1, this.scrollPosition = 0); - for (b = this.scrollPosition;b < this.scrollPosition + a && b < this.array_.length;b++) { - this.elementView.indexView.text = b + 1; - var c = String(this.array_[b].data), d = Math.floor((this.getWidth() - 50) / 7), c = Entry.cutStringByLength(c, d), c = String(this.array_[b].data).length > c.length ? c + ".." : c; + for (a = this.scrollPosition;a < this.scrollPosition + b && a < this.array_.length;a++) { + this.elementView.indexView.text = a + 1; + var c = String(this.array_[a].data), d = Math.floor((this.getWidth() - 50) / 7), c = Entry.cutStringByLength(c, d), c = String(this.array_[a].data).length > c.length ? c + ".." : c; this.elementView.valueView.text = c; c = this.elementView.clone(!0); - c.y = 20 * (b - this.scrollPosition) + 23; + c.y = 20 * (a - this.scrollPosition) + 23; this.view_.addChild(c); } } else { @@ -14399,9 +13253,9 @@ Entry.Variable.prototype.updateView = function() { Entry.Variable.prototype.getName = function() { return this.name_; }; -Entry.Variable.prototype.setName = function(a) { - Entry.assert("string" == typeof a, "Variable name must be string"); - this.name_ = a; +Entry.Variable.prototype.setName = function(b) { + Entry.assert("string" == typeof b, "Variable name must be string"); + this.name_ = b; this._nameWidth = null; this.updateView(); }; @@ -14409,13 +13263,13 @@ Entry.Variable.prototype.getId = function() { return this.id_; }; Entry.Variable.prototype.getValue = function() { - return this.isNumber() ? Number(this.value_) : this.value_; + return this.isNumber() ? +this.value_ : this.value_; }; Entry.Variable.prototype.isNumber = function() { return isNaN(this.value_) ? !1 : !0; }; -Entry.Variable.prototype.setValue = function(a) { - "slide" != this.type ? this.value_ = a : (a = Number(a), this.value_ = a < this.minValue_ ? this.minValue_ : a > this.maxValue_ ? this.maxValue_ : a); +Entry.Variable.prototype.setValue = function(b) { + "slide" != this.type ? this.value_ = b : (b = +b, this.value_ = b < this.minValue_ ? this.minValue_ : b > this.maxValue_ ? this.maxValue_ : b); this.isCloud_ && Entry.variableContainer.updateCloudVariables(); this._valueWidth = null; this.updateView(); @@ -14423,37 +13277,37 @@ Entry.Variable.prototype.setValue = function(a) { Entry.Variable.prototype.isVisible = function() { return this.visible_; }; -Entry.Variable.prototype.setVisible = function(a) { - Entry.assert("boolean" == typeof a, "Variable visible state must be boolean"); - (this.visible_ = this.view_.visible = a) && this.updateView(); +Entry.Variable.prototype.setVisible = function(b) { + Entry.assert("boolean" == typeof b, "Variable visible state must be boolean"); + (this.visible_ = this.view_.visible = b) && this.updateView(); }; -Entry.Variable.prototype.setX = function(a) { - this.x_ = a; +Entry.Variable.prototype.setX = function(b) { + this.x_ = b; this.updateView(); }; Entry.Variable.prototype.getX = function() { return this.x_; }; -Entry.Variable.prototype.setY = function(a) { - this.y_ = a; +Entry.Variable.prototype.setY = function(b) { + this.y_ = b; this.updateView(); }; Entry.Variable.prototype.getY = function() { return this.y_; }; -Entry.Variable.prototype.setWidth = function(a) { - this.width_ = 100 > a ? 100 : a; +Entry.Variable.prototype.setWidth = function(b) { + this.width_ = 100 > b ? 100 : b; this.updateView(); }; Entry.Variable.prototype.getWidth = function() { return this.width_; }; -Entry.Variable.prototype.isInList = function(a, b) { +Entry.Variable.prototype.isInList = function(b, a) { this.getX(); this.getY(); }; -Entry.Variable.prototype.setHeight = function(a) { - this.height_ = 100 > a ? 100 : a; +Entry.Variable.prototype.setHeight = function(b) { + this.height_ = 100 > b ? 100 : b; this.updateView(); }; Entry.Variable.prototype.getHeight = function() { @@ -14465,79 +13319,79 @@ Entry.Variable.prototype.takeSnapshot = function() { Entry.Variable.prototype.loadSnapshot = function() { this.snapshot_ && !this.isCloud_ && this.syncModel_(this.snapshot_); }; -Entry.Variable.prototype.syncModel_ = function(a) { - this.setX(a.x); - this.setY(a.y); - this.id_ = a.id; - this.setVisible(a.visible); - this.setValue(a.value); - this.setName(a.name); - this.isCloud_ = a.isCloud; - "list" == this.type && (this.setWidth(a.width), this.setHeight(a.height), this.array_ = a.array); +Entry.Variable.prototype.syncModel_ = function(b) { + this.setX(b.x); + this.setY(b.y); + this.id_ = b.id; + this.setVisible(b.visible); + this.setValue(b.value); + this.setName(b.name); + this.isCloud_ = b.isCloud; + "list" == this.type && (this.setWidth(b.width), this.setHeight(b.height), this.array_ = b.array); }; Entry.Variable.prototype.toJSON = function() { - var a = {}; - a.name = this.name_; - a.id = this.id_; - a.visible = this.visible_; - a.value = this.value_; - a.variableType = this.type; - "list" == this.type ? (a.width = this.getWidth(), a.height = this.getHeight(), a.array = JSON.parse(JSON.stringify(this.array_))) : "slide" == this.type && (a.minValue = this.minValue_, a.maxValue = this.maxValue_); - a.isCloud = this.isCloud_; - a.object = this.object_; - a.x = this.x_; - a.y = this.y_; - return a; + var b = {}; + b.name = this.name_; + b.id = this.id_; + b.visible = this.visible_; + b.value = this.value_; + b.variableType = this.type; + "list" == this.type ? (b.width = this.getWidth(), b.height = this.getHeight(), b.array = JSON.parse(JSON.stringify(this.array_))) : "slide" == this.type && (b.minValue = this.minValue_, b.maxValue = this.maxValue_); + b.isCloud = this.isCloud_; + b.object = this.object_; + b.x = this.x_; + b.y = this.y_; + return b; }; Entry.Variable.prototype.remove = function() { Entry.stage.removeVariable(this); }; Entry.Variable.prototype.clone = function() { - var a = this.toJSON(); - a.isClone = !0; - return a = new Entry.Variable(a); + var b = this.toJSON(); + b.isClone = !0; + return b = new Entry.Variable(b); }; Entry.Variable.prototype.getType = function() { return this.type; }; -Entry.Variable.prototype.setType = function(a) { - this.type = a; +Entry.Variable.prototype.setType = function(b) { + this.type = b; }; -Entry.Variable.prototype.getSlidePosition = function(a) { - var b = this.minValue_; - return Math.abs(this.value_ - b) / Math.abs(this.maxValue_ - b) * a + 10; +Entry.Variable.prototype.getSlidePosition = function(b) { + var a = this.minValue_; + return Math.abs(this.value_ - a) / Math.abs(this.maxValue_ - a) * b + 10; }; -Entry.Variable.prototype.setSlideCommandX = function(a) { - var b = this.valueSetter_.graphics.command; - a = Math.max("undefined" == typeof a ? 10 : a, 10); - a = Math.min(this.maxWidth + 10, a); - b.x = a; +Entry.Variable.prototype.setSlideCommandX = function(b) { + var a = this.valueSetter_.graphics.command; + b = Math.max("undefined" == typeof b ? 10 : b, 10); + b = Math.min(this.maxWidth + 10, b); + a.x = b; this.updateSlideValueByView(); }; Entry.Variable.prototype.updateSlideValueByView = function() { - var a = Math.max(this.valueSetter_.graphics.command.x - 10, 0) / this.maxWidth; - 0 > a && (a = 0); - 1 < a && (a = 1); - var b = parseFloat(this.minValue_), c = parseFloat(this.maxValue_), a = (b + Number(Math.abs(c - b) * a)).toFixed(2), a = parseFloat(a); - a < b ? a = this.minValue_ : a > c && (a = this.maxValue_); - this.isFloatPoint() || (a = Math.round(a)); - this.setValue(a); + var b = Math.max(this.valueSetter_.graphics.command.x - 10, 0) / this.maxWidth; + 0 > b && (b = 0); + 1 < b && (b = 1); + var a = parseFloat(this.minValue_), c = parseFloat(this.maxValue_), b = (a + Math.abs(c - a) * b).toFixed(2), b = parseFloat(b); + b < a ? b = this.minValue_ : b > c && (b = this.maxValue_); + this.isFloatPoint() || (b = Math.round(b)); + this.setValue(b); }; Entry.Variable.prototype.getMinValue = function() { return this.minValue_; }; -Entry.Variable.prototype.setMinValue = function(a) { - this.minValue_ = a; - this.value_ < a && (this.value_ = a); +Entry.Variable.prototype.setMinValue = function(b) { + this.minValue_ = b; + this.value_ < b && (this.value_ = b); this.updateView(); this.isMinFloat = Entry.isFloat(this.minValue_); }; Entry.Variable.prototype.getMaxValue = function() { return this.maxValue_; }; -Entry.Variable.prototype.setMaxValue = function(a) { - this.maxValue_ = a; - this.value_ > a && (this.value_ = a); +Entry.Variable.prototype.setMaxValue = function(b) { + this.maxValue_ = b; + this.value_ > b && (this.value_ = b); this.updateView(); this.isMaxFloat = Entry.isFloat(this.maxValue_); }; @@ -14558,9 +13412,9 @@ Entry.VariableContainer = function() { this._messageRefs = []; this._functionRefs = []; }; -Entry.VariableContainer.prototype.createDom = function(a) { - var b = this; - this.view_ = a; +Entry.VariableContainer.prototype.createDom = function(b) { + var a = this; + this.view_ = b; var c = Entry.createElement("table"); c.addClass("entryVariableSelectorWorkspace"); this.view_.appendChild(c); @@ -14586,10 +13440,10 @@ Entry.VariableContainer.prototype.createDom = function(a) { c.innerHTML = "+ " + Lang.Workspace.variable_add; var f = this; this.variableAddButton_ = c; - c.bindOnClick(function(a) { - a = f.variableAddPanel; - var c = a.view.name.value.trim(); - a.isOpen ? c && 0 !== c.length ? b.addVariable() : (a.view.addClass("entryRemove"), a.isOpen = !1) : (a.view.removeClass("entryRemove"), a.view.name.focus(), a.isOpen = !0); + c.bindOnClick(function(b) { + b = f.variableAddPanel; + var c = b.view.name.value.trim(); + b.isOpen ? c && 0 !== c.length ? a.addVariable() : (b.view.addClass("entryRemove"), b.isOpen = !1) : (b.view.removeClass("entryRemove"), b.view.name.focus(), b.isOpen = !0); }); this.generateVariableAddView(); this.generateListAddView(); @@ -14601,71 +13455,71 @@ Entry.VariableContainer.prototype.createDom = function(a) { c.addClass("entryVariableListElementWorkspace"); c.innerHTML = "+ " + Lang.Workspace.message_create; this.messageAddButton_ = c; - c.bindOnClick(function(a) { - b.addMessage({name:Lang.Workspace.message + " " + (b.messages_.length + 1)}); + c.bindOnClick(function(b) { + a.addMessage({name:Lang.Workspace.message + " " + (a.messages_.length + 1)}); }); c = Entry.createElement("li"); c.addClass("entryVariableAddWorkspace"); c.addClass("entryVariableListElementWorkspace"); c.innerHTML = "+ " + Lang.Workspace.list_create; this.listAddButton_ = c; - c.bindOnClick(function(a) { - a = f.listAddPanel; - var c = a.view.name.value.trim(); - a.isOpen ? c && 0 !== c.length ? b.addList() : (a.view.addClass("entryRemove"), a.isOpen = !1) : (a.view.removeClass("entryRemove"), a.view.name.focus(), a.isOpen = !0); + c.bindOnClick(function(b) { + b = f.listAddPanel; + var c = b.view.name.value.trim(); + b.isOpen ? c && 0 !== c.length ? a.addList() : (b.view.addClass("entryRemove"), b.isOpen = !1) : (b.view.removeClass("entryRemove"), b.view.name.focus(), b.isOpen = !0); }); c = Entry.createElement("li"); c.addClass("entryVariableAddWorkspace"); c.addClass("entryVariableListElementWorkspace"); c.innerHTML = "+ " + Lang.Workspace.function_add; this.functionAddButton_ = c; - c.bindOnClick(function(a) { - a = b._getBlockMenu(); + c.bindOnClick(function(b) { + b = a._getBlockMenu(); Entry.playground.changeViewMode("code"); - "func" != a.lastSelector && a.selectMenu("func"); - b.createFunction(); + "func" != b.lastSelector && b.selectMenu("func"); + a.createFunction(); }); - return a; + return b; }; -Entry.VariableContainer.prototype.createSelectButton = function(a, b) { +Entry.VariableContainer.prototype.createSelectButton = function(b, a) { var c = this; - void 0 === b && (b = !0); + void 0 === a && (a = !0); var d = Entry.createElement("td"); - d.addClass("entryVariableSelectButtonWorkspace", a); - d.innerHTML = Lang.Workspace[a]; - b ? d.bindOnClick(function(b) { - c.selectFilter(a); + d.addClass("entryVariableSelectButtonWorkspace", b); + d.innerHTML = Lang.Workspace[b]; + a ? d.bindOnClick(function(a) { + c.selectFilter(b); this.addClass("selected"); }) : d.addClass("disable"); return d; }; -Entry.VariableContainer.prototype.selectFilter = function(a) { - for (var b = this.view_.getElementsByTagName("td"), c = 0;c < b.length;c++) { - b[c].removeClass("selected"), b[c].hasClass(a) && b[c].addClass("selected"); +Entry.VariableContainer.prototype.selectFilter = function(b) { + for (var a = this.view_.getElementsByTagName("td"), c = 0;c < a.length;c++) { + a[c].removeClass("selected"), a[c].hasClass(b) && a[c].addClass("selected"); } - this.viewMode_ = a; + this.viewMode_ = b; this.select(); this.updateList(); }; -Entry.VariableContainer.prototype.updateVariableAddView = function(a) { - a = "variable" == (a ? a : "variable") ? this.variableAddPanel : this.listAddPanel; - var b = a.info, c = a.view; - a.view.addClass("entryRemove"); +Entry.VariableContainer.prototype.updateVariableAddView = function(b) { + b = "variable" == (b ? b : "variable") ? this.variableAddPanel : this.listAddPanel; + var a = b.info, c = b.view; + b.view.addClass("entryRemove"); c.cloudCheck.removeClass("entryVariableAddChecked"); c.localCheck.removeClass("entryVariableAddChecked"); c.globalCheck.removeClass("entryVariableAddChecked"); c.cloudWrapper.removeClass("entryVariableAddSpaceUnCheckedWorkspace"); - b.isCloud && c.cloudCheck.addClass("entryVariableAddChecked"); - a.isOpen && (c.removeClass("entryRemove"), c.name.focus()); - b.object ? (c.localCheck.addClass("entryVariableAddChecked"), c.cloudWrapper.addClass("entryVariableAddSpaceUnCheckedWorkspace")) : c.globalCheck.addClass("entryVariableAddChecked"); + a.isCloud && c.cloudCheck.addClass("entryVariableAddChecked"); + b.isOpen && (c.removeClass("entryRemove"), c.name.focus()); + a.object ? (c.localCheck.addClass("entryVariableAddChecked"), c.cloudWrapper.addClass("entryVariableAddSpaceUnCheckedWorkspace")) : c.globalCheck.addClass("entryVariableAddChecked"); }; -Entry.VariableContainer.prototype.select = function(a) { - a = this.selected == a ? null : a; +Entry.VariableContainer.prototype.select = function(b) { + b = this.selected == b ? null : b; this.selected && (this.selected.listElement.removeClass("selected"), this.selected.callerListElement && (this.listView_.removeChild(this.selected.callerListElement), delete this.selected.callerListElement), this.selected = null); - a && (a.listElement.addClass("selected"), this.selected = a, a instanceof Entry.Variable ? (this.renderVariableReference(a), a.object_ && Entry.container.selectObject(a.object_, !0)) : a instanceof Entry.Func ? this.renderFunctionReference(a) : this.renderMessageReference(a)); + b && (b.listElement.addClass("selected"), this.selected = b, b instanceof Entry.Variable ? (this.renderVariableReference(b), b.object_ && Entry.container.selectObject(b.object_, !0)) : b instanceof Entry.Func ? this.renderFunctionReference(b) : this.renderMessageReference(b)); }; -Entry.VariableContainer.prototype.renderMessageReference = function(a) { - for (var b = this, c = this._messageRefs, d = a.id, e = [], f = 0;f < c.length;f++) { +Entry.VariableContainer.prototype.renderMessageReference = function(b) { + for (var a = this, c = this._messageRefs, d = b.id, e = [], f = 0;f < c.length;f++) { -1 < c[f].block.params.indexOf(d) && e.push(c[f]); } c = Entry.createElement("ul"); @@ -14679,21 +13533,21 @@ Entry.VariableContainer.prototype.renderMessageReference = function(a) { h.innerHTML = d.object.name + " : " + Lang.Blocks["START_" + d.block.type]; g.appendChild(h); g.caller = d; - g.message = a; - g.bindOnClick(function(a) { - Entry.playground.object != this.caller.object && (Entry.container.selectObject(), Entry.container.selectObject(this.caller.object.id, !0), b.select(null), b.select(this.message)); + g.message = b; + g.bindOnClick(function(b) { + Entry.playground.object != this.caller.object && (Entry.container.selectObject(), Entry.container.selectObject(this.caller.object.id, !0), a.select(null), a.select(this.message)); Entry.playground.toggleOnVariableView(); Entry.playground.changeViewMode("variable"); }); c.appendChild(g); } 0 === e.length && (g = Entry.createElement("li"), g.addClass("entryVariableListCallerWorkspace"), g.addClass("entryVariableListCallerNoneWorkspace"), g.innerHTML = Lang.Workspace.no_use, c.appendChild(g)); - a.callerListElement = c; - this.listView_.insertBefore(c, a.listElement); - this.listView_.insertBefore(a.listElement, c); + b.callerListElement = c; + this.listView_.insertBefore(c, b.listElement); + this.listView_.insertBefore(b.listElement, c); }; -Entry.VariableContainer.prototype.renderVariableReference = function(a) { - for (var b = this, c = this._variableRefs, d = a.id_, e = [], f = 0;f < c.length;f++) { +Entry.VariableContainer.prototype.renderVariableReference = function(b) { + for (var a = this, c = this._variableRefs, d = b.id_, e = [], f = 0;f < c.length;f++) { -1 < c[f].block.params.indexOf(d) && e.push(c[f]); } c = Entry.createElement("ul"); @@ -14707,24 +13561,24 @@ Entry.VariableContainer.prototype.renderVariableReference = function(a) { h.innerHTML = d.object.name + " : " + Lang.Blocks["VARIABLE_" + d.block.type]; g.appendChild(h); g.caller = d; - g.variable = a; - g.bindOnClick(function(a) { - Entry.playground.object != this.caller.object && (Entry.container.selectObject(), Entry.container.selectObject(this.caller.object.id, !0), b.select(null)); - a = this.caller; - a = a.funcBlock || a.block; - a.view.getBoard().activateBlock(a); + g.variable = b; + g.bindOnClick(function(b) { + Entry.playground.object != this.caller.object && (Entry.container.selectObject(), Entry.container.selectObject(this.caller.object.id, !0), a.select(null)); + b = this.caller; + b = b.funcBlock || b.block; + b.view.getBoard().activateBlock(b); Entry.playground.toggleOnVariableView(); Entry.playground.changeViewMode("variable"); }); c.appendChild(g); } 0 === e.length && (g = Entry.createElement("li"), g.addClass("entryVariableListCallerWorkspace"), g.addClass("entryVariableListCallerNoneWorkspace"), g.innerHTML = Lang.Workspace.no_use, c.appendChild(g)); - a.callerListElement = c; - this.listView_.insertBefore(c, a.listElement); - this.listView_.insertBefore(a.listElement, c); + b.callerListElement = c; + this.listView_.insertBefore(c, b.listElement); + this.listView_.insertBefore(b.listElement, c); }; -Entry.VariableContainer.prototype.renderFunctionReference = function(a) { - for (var b = this, c = this._functionRefs, d = [], e = 0;e < c.length;e++) { +Entry.VariableContainer.prototype.renderFunctionReference = function(b) { + for (var a = this, c = this._functionRefs, d = [], e = 0;e < c.length;e++) { d.push(c[e]); } c = Entry.createElement("ul"); @@ -14739,7 +13593,7 @@ Entry.VariableContainer.prototype.renderFunctionReference = function(a) { g.appendChild(h); g.caller = f; g.bindOnClick(function(c) { - Entry.playground.object != this.caller.object && (Entry.container.selectObject(), Entry.container.selectObject(this.caller.object.id, !0), b.select(null), b.select(a)); + Entry.playground.object != this.caller.object && (Entry.container.selectObject(), Entry.container.selectObject(this.caller.object.id, !0), a.select(null), a.select(b)); c = this.caller.block; Entry.playground.toggleOnVariableView(); c.view.getBoard().activateBlock(c); @@ -14748,9 +13602,9 @@ Entry.VariableContainer.prototype.renderFunctionReference = function(a) { c.appendChild(g); } 0 === d.length && (g = Entry.createElement("li"), g.addClass("entryVariableListCallerWorkspace"), g.addClass("entryVariableListCallerNoneWorkspace"), g.innerHTML = Lang.Workspace.no_use, c.appendChild(g)); - a.callerListElement = c; - this.listView_.insertBefore(c, a.listElement); - this.listView_.insertBefore(a.listElement, c); + b.callerListElement = c; + this.listView_.insertBefore(c, b.listElement); + this.listView_.insertBefore(b.listElement, c); }; Entry.VariableContainer.prototype.updateList = function() { if (this.listView_) { @@ -14758,19 +13612,19 @@ Entry.VariableContainer.prototype.updateList = function() { for (this.listSettingView.addClass("entryRemove");this.listView_.firstChild;) { this.listView_.removeChild(this.listView_.firstChild); } - var a = this.viewMode_, b = []; - if ("all" == a || "message" == a) { - "message" == a && this.listView_.appendChild(this.messageAddButton_); + var b = this.viewMode_, a = []; + if ("all" == b || "message" == b) { + "message" == b && this.listView_.appendChild(this.messageAddButton_); for (var c in this.messages_) { var d = this.messages_[c]; - b.push(d); + a.push(d); var e = d.listElement; this.listView_.appendChild(e); d.callerListElement && this.listView_.appendChild(d.callerListElement); } } - if ("all" == a || "variable" == a) { - if ("variable" == a) { + if ("all" == b || "variable" == b) { + if ("variable" == b) { e = this.variableAddPanel.info; e.object && !Entry.playground.object && (e.object = null); this.listView_.appendChild(this.variableAddButton_); @@ -14778,22 +13632,22 @@ Entry.VariableContainer.prototype.updateList = function() { this.variableSplitters.top.innerHTML = Lang.Workspace.Variable_used_at_all_objects; this.listView_.appendChild(this.variableSplitters.top); for (c in this.variables_) { - d = this.variables_[c], d.object_ || (b.push(d), e = d.listElement, this.listView_.appendChild(e), d.callerListElement && this.listView_.appendChild(d.callerListElement)); + d = this.variables_[c], d.object_ || (a.push(d), e = d.listElement, this.listView_.appendChild(e), d.callerListElement && this.listView_.appendChild(d.callerListElement)); } this.variableSplitters.bottom.innerHTML = Lang.Workspace.Variable_used_at_special_object; this.listView_.appendChild(this.variableSplitters.bottom); for (c in this.variables_) { - d = this.variables_[c], d.object_ && (b.push(d), e = d.listElement, this.listView_.appendChild(e), d.callerListElement && this.listView_.appendChild(d.callerListElement)); + d = this.variables_[c], d.object_ && (a.push(d), e = d.listElement, this.listView_.appendChild(e), d.callerListElement && this.listView_.appendChild(d.callerListElement)); } this.updateVariableAddView("variable"); } else { for (c in this.variables_) { - d = this.variables_[c], b.push(d), e = d.listElement, this.listView_.appendChild(e), d.callerListElement && this.listView_.appendChild(d.callerListElement); + d = this.variables_[c], a.push(d), e = d.listElement, this.listView_.appendChild(e), d.callerListElement && this.listView_.appendChild(d.callerListElement); } } } - if ("all" == a || "list" == a) { - if ("list" == a) { + if ("all" == b || "list" == b) { + if ("list" == b) { e = this.listAddPanel.info; e.object && !Entry.playground.object && (e.object = null); this.listView_.appendChild(this.listAddButton_); @@ -14802,32 +13656,32 @@ Entry.VariableContainer.prototype.updateList = function() { this.listView_.appendChild(this.variableSplitters.top); this.updateVariableAddView("list"); for (c in this.lists_) { - d = this.lists_[c], d.object_ || (b.push(d), e = d.listElement, this.listView_.appendChild(e), d.callerListElement && this.listView_.appendChild(d.callerListElement)); + d = this.lists_[c], d.object_ || (a.push(d), e = d.listElement, this.listView_.appendChild(e), d.callerListElement && this.listView_.appendChild(d.callerListElement)); } this.variableSplitters.bottom.innerHTML = Lang.Workspace.list_used_specific_objects; this.listView_.appendChild(this.variableSplitters.bottom); for (c in this.lists_) { - d = this.lists_[c], d.object_ && (b.push(d), e = d.listElement, this.listView_.appendChild(e), d.callerListElement && this.listView_.appendChild(d.callerListElement)); + d = this.lists_[c], d.object_ && (a.push(d), e = d.listElement, this.listView_.appendChild(e), d.callerListElement && this.listView_.appendChild(d.callerListElement)); } this.updateVariableAddView("variable"); } else { for (c in this.lists_) { - d = this.lists_[c], b.push(d), e = d.listElement, this.listView_.appendChild(e), d.callerListElement && this.listView_.appendChild(d.callerListElement); + d = this.lists_[c], a.push(d), e = d.listElement, this.listView_.appendChild(e), d.callerListElement && this.listView_.appendChild(d.callerListElement); } } } - if ("all" == a || "func" == a) { - for (c in "func" == a && this.listView_.appendChild(this.functionAddButton_), this.functions_) { - a = this.functions_[c], b.push(a), e = a.listElement, this.listView_.appendChild(e), a.callerListElement && this.listView_.appendChild(a.callerListElement); + if ("all" == b || "func" == b) { + for (c in "func" == b && this.listView_.appendChild(this.functionAddButton_), this.functions_) { + b = this.functions_[c], a.push(b), e = b.listElement, this.listView_.appendChild(e), b.callerListElement && this.listView_.appendChild(b.callerListElement); } } this.listView_.appendChild(this.variableSettingView); this.listView_.appendChild(this.listSettingView); } }; -Entry.VariableContainer.prototype.setMessages = function(a) { - for (var b in a) { - var c = a[b]; +Entry.VariableContainer.prototype.setMessages = function(b) { + for (var a in b) { + var c = b[a]; c.id || (c.id = Entry.generateHash()); this.createMessageView(c); this.messages_.push(c); @@ -14835,9 +13689,9 @@ Entry.VariableContainer.prototype.setMessages = function(a) { Entry.playground.reloadPlayground(); this.updateList(); }; -Entry.VariableContainer.prototype.setVariables = function(a) { - for (var b in a) { - var c = new Entry.Variable(a[b]), d = c.getType(); +Entry.VariableContainer.prototype.setVariables = function(b) { + for (var a in b) { + var c = new Entry.Variable(b[a]), d = c.getType(); "variable" == d || "slide" == d ? (c.generateView(this.variables_.length), this.createVariableView(c), this.variables_.push(c)) : "list" == d ? (c.generateView(this.lists_.length), this.createListView(c), this.lists_.push(c)) : "timer" == d ? this.generateTimer(c) : "answer" == d && this.generateAnswer(c); } Entry.isEmpty(Entry.engine.projectTimer) && Entry.variableContainer.generateTimer(); @@ -14845,169 +13699,169 @@ Entry.VariableContainer.prototype.setVariables = function(a) { Entry.playground.reloadPlayground(); this.updateList(); }; -Entry.VariableContainer.prototype.setFunctions = function(a) { - for (var b in a) { - var c = new Entry.Func(a[b]); +Entry.VariableContainer.prototype.setFunctions = function(b) { + for (var a in b) { + var c = new Entry.Func(b[a]); c.generateBlock(); this.createFunctionView(c); this.functions_[c.id] = c; } this.updateList(); }; -Entry.VariableContainer.prototype.getFunction = function(a) { - return this.functions_[a]; +Entry.VariableContainer.prototype.getFunction = function(b) { + return this.functions_[b]; }; -Entry.VariableContainer.prototype.getVariable = function(a, b) { - var c = Entry.findObjsByKey(this.variables_, "id_", a)[0]; - b && b.isClone && c.object_ && (c = Entry.findObjsByKey(b.variables, "id_", a)[0]); +Entry.VariableContainer.prototype.getVariable = function(b, a) { + var c = Entry.findObjsByKey(this.variables_, "id_", b)[0]; + a && a.isClone && c.object_ && (c = Entry.findObjsByKey(a.variables, "id_", b)[0]); return c; }; -Entry.VariableContainer.prototype.getList = function(a, b) { - var c = Entry.findObjsByKey(this.lists_, "id_", a)[0]; - b && b.isClone && c.object_ && (c = Entry.findObjsByKey(b.lists, "id_", a)[0]); +Entry.VariableContainer.prototype.getList = function(b, a) { + var c = Entry.findObjsByKey(this.lists_, "id_", b)[0]; + a && a.isClone && c.object_ && (c = Entry.findObjsByKey(a.lists, "id_", b)[0]); return c; }; Entry.VariableContainer.prototype.createFunction = function() { if (!Entry.Func.isEdit) { - var a = new Entry.Func; - Entry.Func.edit(a); + var b = new Entry.Func; + Entry.Func.edit(b); } }; -Entry.VariableContainer.prototype.addFunction = function(a) { +Entry.VariableContainer.prototype.addFunction = function(b) { }; -Entry.VariableContainer.prototype.removeFunction = function(a) { - this.functions_[a.id].destroy(); - delete this.functions_[a.id]; +Entry.VariableContainer.prototype.removeFunction = function(b) { + this.functions_[b.id].destroy(); + delete this.functions_[b.id]; this.updateList(); }; -Entry.VariableContainer.prototype.checkListPosition = function(a, b) { - var c = a.x_ + a.width_, d = -a.y_, e = -a.y_ + -a.height_; - return b.x > a.x_ && b.x < c && b.y < d && b.y > e ? !0 : !1; +Entry.VariableContainer.prototype.checkListPosition = function(b, a) { + var c = b.x_ + b.width_, d = -b.y_, e = -b.y_ + -b.height_; + return a.x > b.x_ && a.x < c && a.y < d && a.y > e ? !0 : !1; }; -Entry.VariableContainer.prototype.getListById = function(a) { - var b = this.lists_, c = []; - if (0 < b.length) { - for (var d = 0;d < b.length;d++) { - this.checkListPosition(b[d], a) && c.push(b[d]); +Entry.VariableContainer.prototype.getListById = function(b) { + var a = this.lists_, c = []; + if (0 < a.length) { + for (var d = 0;d < a.length;d++) { + this.checkListPosition(a[d], b) && c.push(a[d]); } return c; } return !1; }; -Entry.VariableContainer.prototype.editFunction = function(a, b) { +Entry.VariableContainer.prototype.editFunction = function(b, a) { }; -Entry.VariableContainer.prototype.saveFunction = function(a) { - this.functions_[a.id] || (this.functions_[a.id] = a, this.createFunctionView(a)); - a.listElement.nameField.innerHTML = a.description; +Entry.VariableContainer.prototype.saveFunction = function(b) { + this.functions_[b.id] || (this.functions_[b.id] = b, this.createFunctionView(b)); + b.listElement.nameField.innerHTML = b.description; this.updateList(); }; -Entry.VariableContainer.prototype.createFunctionView = function(a) { - var b = this; +Entry.VariableContainer.prototype.createFunctionView = function(b) { + var a = this; if (this.view_) { var c = Entry.createElement("li"); c.addClass("entryVariableListElementWorkspace"); c.addClass("entryFunctionElementWorkspace"); c.bindOnClick(function(c) { c.stopPropagation(); - b.select(a); + a.select(b); }); var d = Entry.createElement("button"); d.addClass("entryVariableListElementDeleteWorkspace"); d.bindOnClick(function(c) { c.stopPropagation(); - b.removeFunction(a); - b.selected = null; + a.removeFunction(b); + a.selected = null; }); var e = Entry.createElement("button"); e.addClass("entryVariableListElementEditWorkspace"); var f = this._getBlockMenu(); - e.bindOnClick(function(b) { - b.stopPropagation(); - Entry.Func.edit(a); + e.bindOnClick(function(a) { + a.stopPropagation(); + Entry.Func.edit(b); Entry.playground && (Entry.playground.changeViewMode("code"), "func" != f.lastSelector && f.selectMenu("func")); }); var g = Entry.createElement("div"); g.addClass("entryVariableFunctionElementNameWorkspace"); - g.innerHTML = a.description; + g.innerHTML = b.description; c.nameField = g; c.appendChild(g); c.appendChild(e); c.appendChild(d); - a.listElement = c; + b.listElement = c; } }; -Entry.VariableContainer.prototype.checkAllVariableName = function(a, b) { - b = this[b]; - for (var c = 0;c < b.length;c++) { - if (b[c].name_ == a) { +Entry.VariableContainer.prototype.checkAllVariableName = function(b, a) { + a = this[a]; + for (var c = 0;c < a.length;c++) { + if (a[c].name_ == b) { return !0; } } return !1; }; -Entry.VariableContainer.prototype.addVariable = function(a) { - if (!a) { - var b = this.variableAddPanel; - a = b.view.name.value.trim(); - a && 0 !== a.length || (a = Lang.Workspace.variable); - a.length > this._maxNameLength && (a = this._truncName(a, "variable")); - a = this.checkAllVariableName(a, "variables_") ? Entry.getOrderedName(a, this.variables_, "name_") : a; - var c = b.info; - a = {name:a, isCloud:c.isCloud, object:c.object, variableType:"variable"}; - b.view.addClass("entryRemove"); +Entry.VariableContainer.prototype.addVariable = function(b) { + if (!b) { + var a = this.variableAddPanel; + b = a.view.name.value.trim(); + b && 0 !== b.length || (b = Lang.Workspace.variable); + b.length > this._maxNameLength && (b = this._truncName(b, "variable")); + b = this.checkAllVariableName(b, "variables_") ? Entry.getOrderedName(b, this.variables_, "name_") : b; + var c = a.info; + b = {name:b, isCloud:c.isCloud, object:c.object, variableType:"variable"}; + a.view.addClass("entryRemove"); this.resetVariableAddPanel("variable"); } - a = new Entry.Variable(a); - Entry.stateManager && Entry.stateManager.addCommand("add variable", this, this.removeVariable, a); - a.generateView(this.variables_.length); - this.createVariableView(a); - this.variables_.unshift(a); + b = new Entry.Variable(b); + Entry.stateManager && Entry.stateManager.addCommand("add variable", this, this.removeVariable, b); + b.generateView(this.variables_.length); + this.createVariableView(b); + this.variables_.unshift(b); Entry.playground.reloadPlayground(); this.updateList(); - return new Entry.State(this, this.removeVariable, a); + return new Entry.State(this, this.removeVariable, b); }; -Entry.VariableContainer.prototype.removeVariable = function(a) { - var b = this.variables_.indexOf(a), c = a.toJSON(); - this.selected == a && this.select(null); - a.remove(); - this.variables_.splice(b, 1); +Entry.VariableContainer.prototype.removeVariable = function(b) { + var a = this.variables_.indexOf(b), c = b.toJSON(); + this.selected == b && this.select(null); + b.remove(); + this.variables_.splice(a, 1); Entry.stateManager && Entry.stateManager.addCommand("remove variable", this, this.addVariable, c); Entry.playground.reloadPlayground(); this.updateList(); return new Entry.State(this, this.addVariable, c); }; -Entry.VariableContainer.prototype.changeVariableName = function(a, b) { - a.name_ != b && (Entry.isExist(b, "name_", this.variables_) ? (a.listElement.nameField.value = a.name_, Entry.toast.alert(Lang.Workspace.variable_rename_failed, Lang.Workspace.variable_dup)) : 10 < b.length ? (a.listElement.nameField.value = a.name_, Entry.toast.alert(Lang.Workspace.variable_rename_failed, Lang.Workspace.variable_too_long)) : (a.name_ = b, a.updateView(), Entry.playground.reloadPlayground(), Entry.toast.success(Lang.Workspace.variable_rename, Lang.Workspace.variable_rename_ok))); +Entry.VariableContainer.prototype.changeVariableName = function(b, a) { + b.name_ != a && (Entry.isExist(a, "name_", this.variables_) ? (b.listElement.nameField.value = b.name_, Entry.toast.alert(Lang.Workspace.variable_rename_failed, Lang.Workspace.variable_dup)) : 10 < a.length ? (b.listElement.nameField.value = b.name_, Entry.toast.alert(Lang.Workspace.variable_rename_failed, Lang.Workspace.variable_too_long)) : (b.name_ = a, b.updateView(), Entry.playground.reloadPlayground(), Entry.toast.success(Lang.Workspace.variable_rename, Lang.Workspace.variable_rename_ok))); }; -Entry.VariableContainer.prototype.changeListName = function(a, b) { - a.name_ != b && (Entry.isExist(b, "name_", this.lists_) ? (a.listElement.nameField.value = a.name_, Entry.toast.alert(Lang.Workspace.list_rename_failed, Lang.Workspace.list_dup)) : 10 < b.length ? (a.listElement.nameField.value = a.name_, Entry.toast.alert(Lang.Workspace.list_rename_failed, Lang.Workspace.list_too_long)) : (a.name_ = b, a.updateView(), Entry.playground.reloadPlayground(), Entry.toast.success(Lang.Workspace.list_rename, Lang.Workspace.list_rename_ok))); +Entry.VariableContainer.prototype.changeListName = function(b, a) { + b.name_ != a && (Entry.isExist(a, "name_", this.lists_) ? (b.listElement.nameField.value = b.name_, Entry.toast.alert(Lang.Workspace.list_rename_failed, Lang.Workspace.list_dup)) : 10 < a.length ? (b.listElement.nameField.value = b.name_, Entry.toast.alert(Lang.Workspace.list_rename_failed, Lang.Workspace.list_too_long)) : (b.name_ = a, b.updateView(), Entry.playground.reloadPlayground(), Entry.toast.success(Lang.Workspace.list_rename, Lang.Workspace.list_rename_ok))); }; -Entry.VariableContainer.prototype.removeList = function(a) { - var b = this.lists_.indexOf(a), c = a.toJSON(); +Entry.VariableContainer.prototype.removeList = function(b) { + var a = this.lists_.indexOf(b), c = b.toJSON(); Entry.stateManager && Entry.stateManager.addCommand("remove list", this, this.addList, c); - this.selected == a && this.select(null); - a.remove(); - this.lists_.splice(b, 1); + this.selected == b && this.select(null); + b.remove(); + this.lists_.splice(a, 1); Entry.playground.reloadPlayground(); this.updateList(); return new Entry.State(this, this.addList, c); }; -Entry.VariableContainer.prototype.createVariableView = function(a) { - var b = this, c = Entry.createElement("li"), d = Entry.createElement("div"); +Entry.VariableContainer.prototype.createVariableView = function(b) { + var a = this, c = Entry.createElement("li"), d = Entry.createElement("div"); d.addClass("entryVariableListElementWrapperWorkspace"); c.appendChild(d); c.addClass("entryVariableListElementWorkspace"); - a.object_ ? c.addClass("entryVariableLocalElementWorkspace") : a.isCloud_ ? c.addClass("entryVariableCloudElementWorkspace") : c.addClass("entryVariableGlobalElementWorkspace"); + b.object_ ? c.addClass("entryVariableLocalElementWorkspace") : b.isCloud_ ? c.addClass("entryVariableCloudElementWorkspace") : c.addClass("entryVariableGlobalElementWorkspace"); c.bindOnClick(function(c) { - b.select(a); + a.select(b); }); var e = Entry.createElement("button"); e.addClass("entryVariableListElementDeleteWorkspace"); e.bindOnClick(function(c) { c.stopPropagation(); - b.removeVariable(a); - b.selectedVariable = null; - b.variableSettingView.addClass("entryRemove"); + a.removeVariable(b); + a.selectedVariable = null; + a.variableSettingView.addClass("entryRemove"); }); var f = Entry.createElement("button"); f.addClass("entryVariableListElementEditWorkspace"); @@ -15016,31 +13870,31 @@ Entry.VariableContainer.prototype.createVariableView = function(a) { h.removeAttribute("disabled"); g.removeClass("entryRemove"); this.addClass("entryRemove"); - b.updateSelectedVariable(a); + a.updateSelectedVariable(b); h.focus(); }); c.editButton = f; var g = Entry.createElement("button"); g.addClass("entryVariableListElementEditWorkspace"); g.addClass("entryRemove"); - g.bindOnClick(function(a) { - a.stopPropagation(); + g.bindOnClick(function(b) { + b.stopPropagation(); h.blur(); h.setAttribute("disabled", "disabled"); f.removeClass("entryRemove"); this.addClass("entryRemove"); - b.updateSelectedVariable(null, "variable"); + a.updateSelectedVariable(null, "variable"); }); c.editSaveButton = g; var h = Entry.createElement("input"); h.addClass("entryVariableListElementNameWorkspace"); h.setAttribute("disabled", "disabled"); - h.value = a.name_; + h.value = b.name_; h.bindOnClick(function(a) { a.stopPropagation(); }); h.onblur = function(c) { - (c = this.value.trim()) && 0 !== c.length ? b.changeVariableName(a, this.value) : (Entry.toast.alert(Lang.Msgs.warn, Lang.Workspace.variable_can_not_space), this.value = a.getName()); + (c = this.value.trim()) && 0 !== c.length ? a.changeVariableName(b, this.value) : (Entry.toast.alert(Lang.Msgs.warn, Lang.Workspace.variable_can_not_space), this.value = b.getName()); }; h.onkeydown = function(a) { 13 == a.keyCode && this.blur(); @@ -15050,42 +13904,42 @@ Entry.VariableContainer.prototype.createVariableView = function(a) { d.appendChild(f); d.appendChild(g); d.appendChild(e); - a.listElement = c; + b.listElement = c; }; -Entry.VariableContainer.prototype.addMessage = function(a) { - a.id || (a.id = Entry.generateHash()); - Entry.stateManager && Entry.stateManager.addCommand("add message", this, this.removeMessage, a); - this.createMessageView(a); - this.messages_.unshift(a); +Entry.VariableContainer.prototype.addMessage = function(b) { + b.id || (b.id = Entry.generateHash()); + Entry.stateManager && Entry.stateManager.addCommand("add message", this, this.removeMessage, b); + this.createMessageView(b); + this.messages_.unshift(b); Entry.playground.reloadPlayground(); this.updateList(); - a.listElement.nameField.focus(); - return new Entry.State(this, this.removeMessage, a); -}; -Entry.VariableContainer.prototype.removeMessage = function(a) { - this.selected == a && this.select(null); - Entry.stateManager && Entry.stateManager.addCommand("remove message", this, this.addMessage, a); - var b = this.messages_.indexOf(a); - this.messages_.splice(b, 1); + b.listElement.nameField.focus(); + return new Entry.State(this, this.removeMessage, b); +}; +Entry.VariableContainer.prototype.removeMessage = function(b) { + this.selected == b && this.select(null); + Entry.stateManager && Entry.stateManager.addCommand("remove message", this, this.addMessage, b); + var a = this.messages_.indexOf(b); + this.messages_.splice(a, 1); this.updateList(); Entry.playground.reloadPlayground(); - return new Entry.State(this, this.addMessage, a); + return new Entry.State(this, this.addMessage, b); }; -Entry.VariableContainer.prototype.changeMessageName = function(a, b) { - a.name != b && (Entry.isExist(b, "name", this.messages_) ? (a.listElement.nameField.value = a.name, Entry.toast.alert(Lang.Workspace.message_rename_failed, Lang.Workspace.message_dup)) : 10 < b.length ? (a.listElement.nameField.value = a.name, Entry.toast.alert(Lang.Workspace.message_rename_failed, Lang.Workspace.message_too_long)) : (a.name = b, Entry.playground.reloadPlayground(), Entry.toast.success(Lang.Workspace.message_rename, Lang.Workspace.message_rename_ok))); +Entry.VariableContainer.prototype.changeMessageName = function(b, a) { + b.name != a && (Entry.isExist(a, "name", this.messages_) ? (b.listElement.nameField.value = b.name, Entry.toast.alert(Lang.Workspace.message_rename_failed, Lang.Workspace.message_dup)) : 10 < a.length ? (b.listElement.nameField.value = b.name, Entry.toast.alert(Lang.Workspace.message_rename_failed, Lang.Workspace.message_too_long)) : (b.name = a, Entry.playground.reloadPlayground(), Entry.toast.success(Lang.Workspace.message_rename, Lang.Workspace.message_rename_ok))); }; -Entry.VariableContainer.prototype.createMessageView = function(a) { - var b = this, c = Entry.createElement("li"); +Entry.VariableContainer.prototype.createMessageView = function(b) { + var a = this, c = Entry.createElement("li"); c.addClass("entryVariableListElementWorkspace"); c.addClass("entryMessageElementWorkspace"); c.bindOnClick(function(c) { - b.select(a); + a.select(b); }); var d = Entry.createElement("button"); d.addClass("entryVariableListElementDeleteWorkspace"); d.bindOnClick(function(c) { c.stopPropagation(); - b.removeMessage(a); + a.removeMessage(b); }); var e = Entry.createElement("button"); e.addClass("entryVariableListElementEditWorkspace"); @@ -15107,12 +13961,12 @@ Entry.VariableContainer.prototype.createMessageView = function(a) { }); var g = Entry.createElement("input"); g.addClass("entryVariableListElementNameWorkspace"); - g.value = a.name; + g.value = b.name; g.bindOnClick(function(a) { a.stopPropagation(); }); g.onblur = function(c) { - (c = this.value.trim()) && 0 !== c.length ? (b.changeMessageName(a, this.value), e.removeClass("entryRemove"), f.addClass("entryRemove"), g.setAttribute("disabled", "disabled")) : (Entry.toast.alert(Lang.Msgs.warn, Lang.Msgs.sign_can_not_space), this.value = a.name); + (c = this.value.trim()) && 0 !== c.length ? (a.changeMessageName(b, this.value), e.removeClass("entryRemove"), f.addClass("entryRemove"), g.setAttribute("disabled", "disabled")) : (Entry.toast.alert(Lang.Msgs.warn, Lang.Msgs.sign_can_not_space), this.value = b.name); }; g.onkeydown = function(a) { 13 == a.keyCode && this.blur(); @@ -15122,45 +13976,45 @@ Entry.VariableContainer.prototype.createMessageView = function(a) { c.appendChild(e); c.appendChild(f); c.appendChild(d); - a.listElement = c; + b.listElement = c; }; -Entry.VariableContainer.prototype.addList = function(a) { - if (!a) { - var b = this.listAddPanel; - a = b.view.name.value.trim(); - a && 0 !== a.length || (a = Lang.Workspace.list); - var c = b.info; - a.length > this._maxNameLength && (a = this._truncName(a, "list")); - a = this.checkAllVariableName(a, "lists_") ? Entry.getOrderedName(a, this.lists_, "name_") : a; - a = {name:a, isCloud:c.isCloud, object:c.object, variableType:"list"}; - b.view.addClass("entryRemove"); +Entry.VariableContainer.prototype.addList = function(b) { + if (!b) { + var a = this.listAddPanel; + b = a.view.name.value.trim(); + b && 0 !== b.length || (b = Lang.Workspace.list); + var c = a.info; + b.length > this._maxNameLength && (b = this._truncName(b, "list")); + b = this.checkAllVariableName(b, "lists_") ? Entry.getOrderedName(b, this.lists_, "name_") : b; + b = {name:b, isCloud:c.isCloud, object:c.object, variableType:"list"}; + a.view.addClass("entryRemove"); this.resetVariableAddPanel("list"); } - a = new Entry.Variable(a); - Entry.stateManager && Entry.stateManager.addCommand("add list", this, this.removeList, a); - a.generateView(this.lists_.length); - this.createListView(a); - this.lists_.unshift(a); + b = new Entry.Variable(b); + Entry.stateManager && Entry.stateManager.addCommand("add list", this, this.removeList, b); + b.generateView(this.lists_.length); + this.createListView(b); + this.lists_.unshift(b); Entry.playground.reloadPlayground(); this.updateList(); - return new Entry.State(this, this.removelist, a); + return new Entry.State(this, this.removelist, b); }; -Entry.VariableContainer.prototype.createListView = function(a) { - var b = this, c = Entry.createElement("li"), d = Entry.createElement("div"); +Entry.VariableContainer.prototype.createListView = function(b) { + var a = this, c = Entry.createElement("li"), d = Entry.createElement("div"); d.addClass("entryVariableListElementWrapperWorkspace"); c.appendChild(d); c.addClass("entryVariableListElementWorkspace"); - a.object_ ? c.addClass("entryListLocalElementWorkspace") : a.isCloud_ ? c.addClass("entryListCloudElementWorkspace") : c.addClass("entryListGlobalElementWorkspace"); + b.object_ ? c.addClass("entryListLocalElementWorkspace") : b.isCloud_ ? c.addClass("entryListCloudElementWorkspace") : c.addClass("entryListGlobalElementWorkspace"); c.bindOnClick(function(c) { - b.select(a); + a.select(b); }); var e = Entry.createElement("button"); e.addClass("entryVariableListElementDeleteWorkspace"); e.bindOnClick(function(c) { c.stopPropagation(); - b.removeList(a); - b.selectedList = null; - b.listSettingView.addClass("entryRemove"); + a.removeList(b); + a.selectedList = null; + a.listSettingView.addClass("entryRemove"); }); var f = Entry.createElement("button"); f.addClass("entryVariableListElementEditWorkspace"); @@ -15169,7 +14023,7 @@ Entry.VariableContainer.prototype.createListView = function(a) { h.removeAttribute("disabled"); g.removeClass("entryRemove"); this.addClass("entryRemove"); - b.updateSelectedVariable(a); + a.updateSelectedVariable(b); h.focus(); }); c.editButton = f; @@ -15182,19 +14036,19 @@ Entry.VariableContainer.prototype.createListView = function(a) { h.setAttribute("disabled", "disabled"); f.removeClass("entryRemove"); this.addClass("entryRemove"); - b.select(a); - b.updateSelectedVariable(null, "list"); + a.select(b); + a.updateSelectedVariable(null, "list"); }); c.editSaveButton = g; var h = Entry.createElement("input"); h.setAttribute("disabled", "disabled"); h.addClass("entryVariableListElementNameWorkspace"); - h.value = a.name_; + h.value = b.name_; h.bindOnClick(function(a) { a.stopPropagation(); }); h.onblur = function(c) { - (c = this.value.trim()) && 0 !== c.length ? b.changeListName(a, this.value) : (Entry.toast.alert(Lang.Msgs.warn, Lang.Msgs.list_can_not_space), this.value = a.getName()); + (c = this.value.trim()) && 0 !== c.length ? a.changeListName(b, this.value) : (Entry.toast.alert(Lang.Msgs.warn, Lang.Msgs.list_can_not_space), this.value = b.getName()); }; h.onkeydown = function(a) { 13 == a.keyCode && this.blur(); @@ -15204,78 +14058,78 @@ Entry.VariableContainer.prototype.createListView = function(a) { d.appendChild(f); d.appendChild(g); d.appendChild(e); - a.listElement = c; + b.listElement = c; }; -Entry.VariableContainer.prototype.mapVariable = function(a, b) { +Entry.VariableContainer.prototype.mapVariable = function(b, a) { for (var c = this.variables_.length, d = 0;d < c;d++) { - a(this.variables_[d], b); + b(this.variables_[d], a); } }; -Entry.VariableContainer.prototype.mapList = function(a, b) { +Entry.VariableContainer.prototype.mapList = function(b, a) { for (var c = this.lists_.length, d = 0;d < c;d++) { - a(this.lists_[d], b); + b(this.lists_[d], a); } }; Entry.VariableContainer.prototype.getVariableJSON = function() { - for (var a = [], b = 0;b < this.variables_.length;b++) { - a.push(this.variables_[b].toJSON()); + for (var b = [], a = 0;a < this.variables_.length;a++) { + b.push(this.variables_[a].toJSON()); } - for (b = 0;b < this.lists_.length;b++) { - a.push(this.lists_[b].toJSON()); + for (a = 0;a < this.lists_.length;a++) { + b.push(this.lists_[a].toJSON()); } - Entry.engine.projectTimer && a.push(Entry.engine.projectTimer); - b = Entry.container.inputValue; - Entry.isEmpty(b) || a.push(b); - return a; + Entry.engine.projectTimer && b.push(Entry.engine.projectTimer); + a = Entry.container.inputValue; + Entry.isEmpty(a) || b.push(a); + return b; }; Entry.VariableContainer.prototype.getMessageJSON = function() { - for (var a = [], b = 0;b < this.messages_.length;b++) { - a.push({id:this.messages_[b].id, name:this.messages_[b].name}); + for (var b = [], a = 0;a < this.messages_.length;a++) { + b.push({id:this.messages_[a].id, name:this.messages_[a].name}); } - return a; + return b; }; Entry.VariableContainer.prototype.getFunctionJSON = function() { - var a = [], b; - for (b in this.functions_) { - var c = this.functions_[b], c = {id:c.id, content:JSON.stringify(c.content.toJSON())}; - a.push(c); + var b = [], a; + for (a in this.functions_) { + var c = this.functions_[a], c = {id:c.id, content:JSON.stringify(c.content.toJSON())}; + b.push(c); } - return a; + return b; }; -Entry.VariableContainer.prototype.resetVariableAddPanel = function(a) { - a = a || "variable"; - var b = "variable" == a ? this.variableAddPanel : this.listAddPanel, c = b.info; +Entry.VariableContainer.prototype.resetVariableAddPanel = function(b) { + b = b || "variable"; + var a = "variable" == b ? this.variableAddPanel : this.listAddPanel, c = a.info; c.isCloud = !1; c.object = null; - b.view.name.value = ""; - b.isOpen = !1; - this.updateVariableAddView(a); + a.view.name.value = ""; + a.isOpen = !1; + this.updateVariableAddView(b); }; Entry.VariableContainer.prototype.generateVariableAddView = function() { - var a = this, b = Entry.createElement("li"); - this.variableAddPanel.view = b; + var b = this, a = Entry.createElement("li"); + this.variableAddPanel.view = a; this.variableAddPanel.isOpen = !1; - b.addClass("entryVariableAddSpaceWorkspace"); - b.addClass("entryRemove"); + a.addClass("entryVariableAddSpaceWorkspace"); + a.addClass("entryRemove"); var c = Entry.createElement("div"); c.addClass("entryVariableAddSpaceNameWrapperWorkspace"); - b.appendChild(c); + a.appendChild(c); var d = Entry.createElement("input"); d.addClass("entryVariableAddSpaceInputWorkspace"); d.setAttribute("placeholder", Lang.Workspace.Variable_placeholder_name); d.variableContainer = this; - d.onkeypress = function(b) { - 13 == b.keyCode && (Entry.variableContainer.addVariable(), a.updateSelectedVariable(a.variables_[0]), b = a.variables_[0].listElement, b.editButton.addClass("entryRemove"), b.editSaveButton.removeClass("entryRemove"), b.nameField.removeAttribute("disabled")); + d.onkeypress = function(a) { + 13 == a.keyCode && (Entry.variableContainer.addVariable(), b.updateSelectedVariable(b.variables_[0]), a = b.variables_[0].listElement, a.editButton.addClass("entryRemove"), a.editSaveButton.removeClass("entryRemove"), a.nameField.removeAttribute("disabled")); }; this.variableAddPanel.view.name = d; c.appendChild(d); c = Entry.createElement("div"); c.addClass("entryVariableAddSpaceGlobalWrapperWorkspace"); - c.bindOnClick(function(b) { - a.variableAddPanel.info.object = null; - a.updateVariableAddView("variable"); + c.bindOnClick(function(a) { + b.variableAddPanel.info.object = null; + b.updateVariableAddView("variable"); }); - b.appendChild(c); + a.appendChild(c); d = Entry.createElement("span"); d.innerHTML = Lang.Workspace.Variable_use_all_objects; c.appendChild(d); @@ -15286,10 +14140,10 @@ Entry.VariableContainer.prototype.generateVariableAddView = function() { c.appendChild(d); c = Entry.createElement("div"); c.addClass("entryVariableAddSpaceLocalWrapperWorkspace"); - c.bindOnClick(function(b) { - Entry.playground.object && (b = a.variableAddPanel.info, b.object = Entry.playground.object.id, b.isCloud = !1, a.updateVariableAddView("variable")); + c.bindOnClick(function(a) { + Entry.playground.object && (a = b.variableAddPanel.info, a.object = Entry.playground.object.id, a.isCloud = !1, b.updateVariableAddView("variable")); }); - b.appendChild(c); + a.appendChild(c); d = Entry.createElement("span"); d.innerHTML = Lang.Workspace.Variable_use_this_object; c.appendChild(d); @@ -15299,13 +14153,13 @@ Entry.VariableContainer.prototype.generateVariableAddView = function() { this.variableAddPanel.info.object && d.addClass("entryVariableAddChecked"); c.appendChild(d); c = Entry.createElement("div"); - b.cloudWrapper = c; + a.cloudWrapper = c; c.addClass("entryVariableAddSpaceCloudWrapperWorkspace"); - c.bindOnClick(function(b) { - b = a.variableAddPanel.info; - b.object || (b.isCloud = !b.isCloud, a.updateVariableAddView("variable")); + c.bindOnClick(function(a) { + a = b.variableAddPanel.info; + a.object || (a.isCloud = !a.isCloud, b.updateVariableAddView("variable")); }); - b.appendChild(c); + a.appendChild(c); d = Entry.createElement("span"); d.addClass("entryVariableAddSpaceCloudSpanWorkspace"); d.innerHTML = Lang.Workspace.Variable_create_cloud; @@ -15318,57 +14172,57 @@ Entry.VariableContainer.prototype.generateVariableAddView = function() { c.appendChild(d); c = Entry.createElement("div"); c.addClass("entryVariableAddSpaceButtonWrapperWorkspace"); - b.appendChild(c); - b = Entry.createElement("span"); - b.addClass("entryVariableAddSpaceCancelWorkspace"); - b.addClass("entryVariableAddSpaceButtonWorkspace"); - b.innerHTML = Lang.Buttons.cancel; - b.bindOnClick(function(b) { - a.variableAddPanel.view.addClass("entryRemove"); - a.resetVariableAddPanel("variable"); + a.appendChild(c); + a = Entry.createElement("span"); + a.addClass("entryVariableAddSpaceCancelWorkspace"); + a.addClass("entryVariableAddSpaceButtonWorkspace"); + a.innerHTML = Lang.Buttons.cancel; + a.bindOnClick(function(a) { + b.variableAddPanel.view.addClass("entryRemove"); + b.resetVariableAddPanel("variable"); }); - c.appendChild(b); - b = Entry.createElement("span"); - b.addClass("entryVariableAddSpaceConfirmWorkspace"); - b.addClass("entryVariableAddSpaceButtonWorkspace"); - b.innerHTML = Lang.Buttons.save; - b.variableContainer = this; - b.bindOnClick(function(b) { + c.appendChild(a); + a = Entry.createElement("span"); + a.addClass("entryVariableAddSpaceConfirmWorkspace"); + a.addClass("entryVariableAddSpaceButtonWorkspace"); + a.innerHTML = Lang.Buttons.save; + a.variableContainer = this; + a.bindOnClick(function(a) { Entry.variableContainer.addVariable(); - a.updateSelectedVariable(a.variables_[0]); - b = a.variables_[0].listElement; - b.editButton.addClass("entryRemove"); - b.editSaveButton.removeClass("entryRemove"); - b.nameField.removeAttribute("disabled"); + b.updateSelectedVariable(b.variables_[0]); + a = b.variables_[0].listElement; + a.editButton.addClass("entryRemove"); + a.editSaveButton.removeClass("entryRemove"); + a.nameField.removeAttribute("disabled"); }); - c.appendChild(b); + c.appendChild(a); }; Entry.VariableContainer.prototype.generateListAddView = function() { - var a = this, b = Entry.createElement("li"); - this.listAddPanel.view = b; + var b = this, a = Entry.createElement("li"); + this.listAddPanel.view = a; this.listAddPanel.isOpen = !1; - b.addClass("entryVariableAddSpaceWorkspace"); - b.addClass("entryRemove"); + a.addClass("entryVariableAddSpaceWorkspace"); + a.addClass("entryRemove"); var c = Entry.createElement("div"); c.addClass("entryVariableAddSpaceNameWrapperWorkspace"); c.addClass("entryListAddSpaceNameWrapperWorkspace"); - b.appendChild(c); + a.appendChild(c); var d = Entry.createElement("input"); d.addClass("entryVariableAddSpaceInputWorkspace"); d.setAttribute("placeholder", Lang.Workspace.list_name); this.listAddPanel.view.name = d; d.variableContainer = this; - d.onkeypress = function(b) { - 13 == b.keyCode && (a.addList(), b = a.lists_[0], a.updateSelectedVariable(b), b = b.listElement, b.editButton.addClass("entryRemove"), b.editSaveButton.removeClass("entryRemove"), b.nameField.removeAttribute("disabled")); + d.onkeypress = function(a) { + 13 == a.keyCode && (b.addList(), a = b.lists_[0], b.updateSelectedVariable(a), a = a.listElement, a.editButton.addClass("entryRemove"), a.editSaveButton.removeClass("entryRemove"), a.nameField.removeAttribute("disabled")); }; c.appendChild(d); c = Entry.createElement("div"); c.addClass("entryVariableAddSpaceGlobalWrapperWorkspace"); - c.bindOnClick(function(b) { - a.listAddPanel.info.object = null; - a.updateVariableAddView("list"); + c.bindOnClick(function(a) { + b.listAddPanel.info.object = null; + b.updateVariableAddView("list"); }); - b.appendChild(c); + a.appendChild(c); d = Entry.createElement("span"); d.innerHTML = Lang.Workspace.use_all_objects; c.appendChild(d); @@ -15379,10 +14233,10 @@ Entry.VariableContainer.prototype.generateListAddView = function() { c.appendChild(d); c = Entry.createElement("div"); c.addClass("entryVariableAddSpaceLocalWrapperWorkspace"); - c.bindOnClick(function(b) { - Entry.playground.object && (b = a.listAddPanel.info, b.object = Entry.playground.object.id, b.isCloud = !1, a.updateVariableAddView("list")); + c.bindOnClick(function(a) { + Entry.playground.object && (a = b.listAddPanel.info, a.object = Entry.playground.object.id, a.isCloud = !1, b.updateVariableAddView("list")); }); - b.appendChild(c); + a.appendChild(c); d = Entry.createElement("span"); d.innerHTML = Lang.Workspace.Variable_use_this_object; c.appendChild(d); @@ -15392,13 +14246,13 @@ Entry.VariableContainer.prototype.generateListAddView = function() { this.variableAddPanel.info.object && addVariableLocalCheck.addClass("entryVariableAddChecked"); c.appendChild(d); c = Entry.createElement("div"); - b.cloudWrapper = c; + a.cloudWrapper = c; c.addClass("entryVariableAddSpaceCloudWrapperWorkspace"); - c.bindOnClick(function(b) { - b = a.listAddPanel.info; - b.object || (b.isCloud = !b.isCloud, a.updateVariableAddView("list")); + c.bindOnClick(function(a) { + a = b.listAddPanel.info; + a.object || (a.isCloud = !a.isCloud, b.updateVariableAddView("list")); }); - b.appendChild(c); + a.appendChild(c); d = Entry.createElement("span"); d.addClass("entryVariableAddSpaceCloudSpanWorkspace"); d.innerHTML = Lang.Workspace.List_create_cloud; @@ -15411,158 +14265,167 @@ Entry.VariableContainer.prototype.generateListAddView = function() { c.appendChild(d); c = Entry.createElement("div"); c.addClass("entryVariableAddSpaceButtonWrapperWorkspace"); - b.appendChild(c); - b = Entry.createElement("span"); - b.addClass("entryVariableAddSpaceCancelWorkspace"); - b.addClass("entryVariableAddSpaceButtonWorkspace"); - b.innerHTML = Lang.Buttons.cancel; - b.bindOnClick(function(b) { - a.listAddPanel.view.addClass("entryRemove"); - a.resetVariableAddPanel("list"); + a.appendChild(c); + a = Entry.createElement("span"); + a.addClass("entryVariableAddSpaceCancelWorkspace"); + a.addClass("entryVariableAddSpaceButtonWorkspace"); + a.innerHTML = Lang.Buttons.cancel; + a.bindOnClick(function(a) { + b.listAddPanel.view.addClass("entryRemove"); + b.resetVariableAddPanel("list"); }); - c.appendChild(b); - b = Entry.createElement("span"); - b.addClass("entryVariableAddSpaceConfirmWorkspace"); - b.addClass("entryVariableAddSpaceButtonWorkspace"); - b.innerHTML = Lang.Buttons.save; - b.variableContainer = this; - b.bindOnClick(function(b) { - a.addList(); - b = a.lists_[0]; - a.updateSelectedVariable(b); - b = b.listElement; - b.editButton.addClass("entryRemove"); - b.editSaveButton.removeClass("entryRemove"); - b.nameField.removeAttribute("disabled"); + c.appendChild(a); + a = Entry.createElement("span"); + a.addClass("entryVariableAddSpaceConfirmWorkspace"); + a.addClass("entryVariableAddSpaceButtonWorkspace"); + a.innerHTML = Lang.Buttons.save; + a.variableContainer = this; + a.bindOnClick(function(a) { + b.addList(); + a = b.lists_[0]; + b.updateSelectedVariable(a); + a = a.listElement; + a.editButton.addClass("entryRemove"); + a.editSaveButton.removeClass("entryRemove"); + a.nameField.removeAttribute("disabled"); }); - c.appendChild(b); + c.appendChild(a); }; Entry.VariableContainer.prototype.generateVariableSplitterView = function() { - var a = Entry.createElement("li"); - a.addClass("entryVariableSplitterWorkspace"); var b = Entry.createElement("li"); b.addClass("entryVariableSplitterWorkspace"); - this.variableSplitters = {top:a, bottom:b}; + var a = Entry.createElement("li"); + a.addClass("entryVariableSplitterWorkspace"); + this.variableSplitters = {top:b, bottom:a}; }; -Entry.VariableContainer.prototype.openVariableAddPanel = function(a) { - a = a ? a : "variable"; +Entry.VariableContainer.prototype.openVariableAddPanel = function(b) { + b = b ? b : "variable"; Entry.playground.toggleOnVariableView(); Entry.playground.changeViewMode("variable"); - "variable" == a ? this.variableAddPanel.isOpen = !0 : this.listAddPanel.isOpen = !0; - this.selectFilter(a); - this.updateVariableAddView(a); + "variable" == b ? this.variableAddPanel.isOpen = !0 : this.listAddPanel.isOpen = !0; + this.selectFilter(b); + this.updateVariableAddView(b); }; -Entry.VariableContainer.prototype.getMenuXml = function(a) { - for (var b = [], c = 0 !== this.variables_.length, d = 0 !== this.lists_.length, e, f = 0, g;g = a[f];f++) { +Entry.VariableContainer.prototype.getMenuXml = function(b) { + for (var a = [], c = 0 !== this.variables_.length, d = 0 !== this.lists_.length, e, f = 0, g;g = b[f];f++) { var h = g.tagName; - h && "BLOCK" == h.toUpperCase() ? (e = g.getAttribute("bCategory"), !c && "variable" == e || !d && "list" == e || b.push(g)) : !h || "SPLITTER" != h.toUpperCase() && "BTN" != h.toUpperCase() || !c && "variable" == e || (d || "list" != e) && b.push(g); + h && "BLOCK" == h.toUpperCase() ? (e = g.getAttribute("bCategory"), !c && "variable" == e || !d && "list" == e || a.push(g)) : !h || "SPLITTER" != h.toUpperCase() && "BTN" != h.toUpperCase() || !c && "variable" == e || (d || "list" != e) && a.push(g); } - return b; + return a; }; -Entry.VariableContainer.prototype.addCloneLocalVariables = function(a) { - var b = [], c = this; - this.mapVariable(function(a, c) { - a.object_ && a.object_ == c.objectId && (a = a.toJSON(), a.originId = a.id, a.id = Entry.generateHash(), a.object = c.newObjectId, delete a.x, delete a.y, b.push(a), c.json.script = c.json.script.replace(new RegExp(a.originId, "g"), a.id)); - }, a); - b.map(function(a) { +Entry.VariableContainer.prototype.addCloneLocalVariables = function(b) { + var a = [], c = this; + this.mapVariable(function(b, c) { + if (b.object_ && b.object_ == c.objectId) { + var f = b.toJSON(); + f.originId = f.id; + f.id = Entry.generateHash(); + f.object = c.newObjectId; + delete f.x; + delete f.y; + a.push(f); + c.json.script = c.json.script.replace(new RegExp(f.originId, "g"), f.id); + } + }, b); + a.map(function(a) { c.addVariable(a); }); }; -Entry.VariableContainer.prototype.generateTimer = function(a) { - a || (a = {}, a.id = Entry.generateHash(), a.name = Lang.Workspace.Variable_Timer, a.value = 0, a.variableType = "timer", a.visible = !1, a.x = 150, a.y = -70, a = new Entry.Variable(a)); - a.generateView(); - a.tick = null; - Entry.engine.projectTimer = a; +Entry.VariableContainer.prototype.generateTimer = function(b) { + b || (b = {}, b.id = Entry.generateHash(), b.name = Lang.Workspace.Variable_Timer, b.value = 0, b.variableType = "timer", b.visible = !1, b.x = 150, b.y = -70, b = new Entry.Variable(b)); + b.generateView(); + b.tick = null; + Entry.engine.projectTimer = b; Entry.addEventListener("stop", function() { Entry.engine.stopProjectTimer(); }); }; -Entry.VariableContainer.prototype.generateAnswer = function(a) { - a || (a = new Entry.Variable({id:Entry.generateHash(), name:Lang.Blocks.VARIABLE_get_canvas_input_value, value:0, variableType:"answer", visible:!1, x:150, y:-100})); - a.generateView(); - Entry.container.inputValue = a; +Entry.VariableContainer.prototype.generateAnswer = function(b) { + b || (b = new Entry.Variable({id:Entry.generateHash(), name:Lang.Blocks.VARIABLE_get_canvas_input_value, value:0, variableType:"answer", visible:!1, x:150, y:-100})); + b.generateView(); + Entry.container.inputValue = b; }; Entry.VariableContainer.prototype.generateVariableSettingView = function() { - var a = this, b = Entry.createElement("div"); - b.bindOnClick(function(a) { + var b = this, a = Entry.createElement("div"); + a.bindOnClick(function(a) { a.stopPropagation(); }); - this.variableSettingView = b; - b.addClass("entryVariableSettingWorkspace"); - this.listView_.appendChild(b); - b.addClass("entryRemove"); + this.variableSettingView = a; + a.addClass("entryVariableSettingWorkspace"); + this.listView_.appendChild(a); + a.addClass("entryRemove"); var c = Entry.createElement("div"); c.addClass("entryVariableSettingVisibleWrapperWorkspace"); - c.bindOnClick(function(b) { - b = a.selectedVariable; - var c = a.variableSettingView.visibleCheck; - b.setVisible(!b.isVisible()); - b.isVisible() ? c.addClass("entryVariableSettingChecked") : c.removeClass("entryVariableSettingChecked"); + c.bindOnClick(function(a) { + a = b.selectedVariable; + var c = b.variableSettingView.visibleCheck; + a.setVisible(!a.isVisible()); + a.isVisible() ? c.addClass("entryVariableSettingChecked") : c.removeClass("entryVariableSettingChecked"); }); - b.appendChild(c); + a.appendChild(c); var d = Entry.createElement("span"); d.innerHTML = Lang.Workspace.show_variable; c.appendChild(d); d = Entry.createElement("span"); d.addClass("entryVariableSettingCheckWorkspace"); - b.visibleCheck = d; + a.visibleCheck = d; c.appendChild(d); c = Entry.createElement("div"); c.addClass("entryVariableSettingInitValueWrapperWorkspace"); - b.appendChild(c); + a.appendChild(c); d = Entry.createElement("span"); d.innerHTML = Lang.Workspace.default_value; c.appendChild(d); d = Entry.createElement("input"); d.addClass("entryVariableSettingInitValueInputWorkspace"); - b.initValueInput = d; + a.initValueInput = d; d.value = 0; - d.onkeyup = function(b) { - a.selectedVariable.setValue(this.value); + d.onkeyup = function(a) { + b.selectedVariable.setValue(this.value); }; - d.onblur = function(b) { - a.selectedVariable.setValue(this.value); + d.onblur = function(a) { + b.selectedVariable.setValue(this.value); }; - b.initValueInput = d; + a.initValueInput = d; c.appendChild(d); c = Entry.createElement("div"); c.addClass("entryVariableSettingSplitterWorkspace"); - b.appendChild(c); + a.appendChild(c); c = Entry.createElement("div"); c.addClass("entryVariableSettingSlideWrapperWorkspace"); - b.appendChild(c); + a.appendChild(c); d = Entry.createElement("span"); d.innerHTML = Lang.Workspace.slide; c.appendChild(d); d = Entry.createElement("span"); d.addClass("entryVariableSettingCheckWorkspace"); - b.slideCheck = d; + a.slideCheck = d; c.appendChild(d); - c.bindOnClick(function(b) { + c.bindOnClick(function(a) { var c; - b = a.selectedVariable; - var d = a.variables_, f = b.getType(); - "variable" == f ? (c = b.toJSON(), c.variableType = "slide", c = new Entry.Variable(c), d.splice(d.indexOf(b), 0, c), 0 > c.getValue() && c.setValue(0), 100 < c.getValue() && c.setValue(100), e.removeAttribute("disabled"), g.removeAttribute("disabled")) : "slide" == f && (c = b.toJSON(), c.variableType = "variable", c = new Entry.Variable(c), d.splice(d.indexOf(b), 0, c), e.setAttribute("disabled", "disabled"), g.setAttribute("disabled", "disabled")); - a.createVariableView(c); - a.removeVariable(b); - a.updateSelectedVariable(c); + a = b.selectedVariable; + var d = b.variables_, f = a.getType(); + "variable" == f ? (c = a.toJSON(), c.variableType = "slide", c = new Entry.Variable(c), d.splice(d.indexOf(a), 0, c), 0 > c.getValue() && c.setValue(0), 100 < c.getValue() && c.setValue(100), e.removeAttribute("disabled"), g.removeAttribute("disabled")) : "slide" == f && (c = a.toJSON(), c.variableType = "variable", c = new Entry.Variable(c), d.splice(d.indexOf(a), 0, c), e.setAttribute("disabled", "disabled"), g.setAttribute("disabled", "disabled")); + b.createVariableView(c); + b.removeVariable(a); + b.updateSelectedVariable(c); c.generateView(); }); c = Entry.createElement("div"); - b.minMaxWrapper = c; + a.minMaxWrapper = c; c.addClass("entryVariableSettingMinMaxWrapperWorkspace"); - b.appendChild(c); + a.appendChild(c); d = Entry.createElement("span"); d.innerHTML = Lang.Workspace.min_value; c.appendChild(d); var e = Entry.createElement("input"); e.addClass("entryVariableSettingMinValueInputWorkspace"); - d = a.selectedVariable; + d = b.selectedVariable; e.value = d && "slide" == d.type ? d.minValue_ : 0; - e.onblur = function(b) { - isNaN(this.value) || (b = a.selectedVariable, b.setMinValue(this.value), a.updateVariableSettingView(b)); + e.onblur = function(a) { + isNaN(this.value) || (a = b.selectedVariable, a.setMinValue(this.value), b.updateVariableSettingView(a)); }; - b.minValueInput = e; + a.minValueInput = e; c.appendChild(e); var f = Entry.createElement("span"); f.addClass("entryVariableSettingMaxValueSpanWorkspace"); @@ -15571,46 +14434,46 @@ Entry.VariableContainer.prototype.generateVariableSettingView = function() { var g = Entry.createElement("input"); g.addClass("entryVariableSettingMaxValueInputWorkspace"); g.value = d && "slide" == d.type ? d.maxValue_ : 100; - g.onblur = function(b) { - isNaN(this.value) || (b = a.selectedVariable, b.setMaxValue(this.value), a.updateVariableSettingView(b)); + g.onblur = function(a) { + isNaN(this.value) || (a = b.selectedVariable, a.setMaxValue(this.value), b.updateVariableSettingView(a)); }; - b.maxValueInput = g; + a.maxValueInput = g; c.appendChild(g); }; -Entry.VariableContainer.prototype.updateVariableSettingView = function(a) { - var b = this.variableSettingView, c = b.visibleCheck, d = b.initValueInput, e = b.slideCheck, f = b.minValueInput, g = b.maxValueInput, h = b.minMaxWrapper; +Entry.VariableContainer.prototype.updateVariableSettingView = function(b) { + var a = this.variableSettingView, c = a.visibleCheck, d = a.initValueInput, e = a.slideCheck, f = a.minValueInput, g = a.maxValueInput, h = a.minMaxWrapper; c.removeClass("entryVariableSettingChecked"); - a.isVisible() && c.addClass("entryVariableSettingChecked"); + b.isVisible() && c.addClass("entryVariableSettingChecked"); e.removeClass("entryVariableSettingChecked"); - "slide" == a.getType() ? (e.addClass("entryVariableSettingChecked"), f.removeAttribute("disabled"), g.removeAttribute("disabled"), f.value = a.getMinValue(), g.value = a.getMaxValue(), h.removeClass("entryVariableMinMaxDisabledWorkspace")) : (h.addClass("entryVariableMinMaxDisabledWorkspace"), f.setAttribute("disabled", "disabled"), g.setAttribute("disabled", "disabled")); - d.value = a.getValue(); - a.listElement.appendChild(b); - b.removeClass("entryRemove"); + "slide" == b.getType() ? (e.addClass("entryVariableSettingChecked"), f.removeAttribute("disabled"), g.removeAttribute("disabled"), f.value = b.getMinValue(), g.value = b.getMaxValue(), h.removeClass("entryVariableMinMaxDisabledWorkspace")) : (h.addClass("entryVariableMinMaxDisabledWorkspace"), f.setAttribute("disabled", "disabled"), g.setAttribute("disabled", "disabled")); + d.value = b.getValue(); + b.listElement.appendChild(a); + a.removeClass("entryRemove"); }; Entry.VariableContainer.prototype.generateListSettingView = function() { - var a = this, b = Entry.createElement("div"); - b.bindOnClick(function(a) { + var b = this, a = Entry.createElement("div"); + a.bindOnClick(function(a) { a.stopPropagation(); }); - this.listSettingView = b; - b.addClass("entryListSettingWorkspace"); - this.listView_.appendChild(b); - b.addClass("entryRemove"); + this.listSettingView = a; + a.addClass("entryListSettingWorkspace"); + this.listView_.appendChild(a); + a.addClass("entryRemove"); var c = Entry.createElement("div"); c.addClass("entryListSettingVisibleWrapperWorkspace"); - c.bindOnClick(function(b) { - b = a.selectedList; - var c = a.listSettingView.visibleCheck; - b.setVisible(!b.isVisible()); - b.isVisible() ? c.addClass("entryListSettingCheckedWorkspace") : c.removeClass("entryListSettingCheckedWorkspace"); + c.bindOnClick(function(a) { + a = b.selectedList; + var c = b.listSettingView.visibleCheck; + a.setVisible(!a.isVisible()); + a.isVisible() ? c.addClass("entryListSettingCheckedWorkspace") : c.removeClass("entryListSettingCheckedWorkspace"); }); - b.appendChild(c); + a.appendChild(c); var d = Entry.createElement("span"); d.innerHTML = Lang.Workspace.show_list_workspace; c.appendChild(d); d = Entry.createElement("span"); d.addClass("entryListSettingCheckWorkspace"); - b.visibleCheck = d; + a.visibleCheck = d; c.appendChild(d); d = Entry.createElement("div"); d.addClass("entryListSettingLengthWrapperWorkspace"); @@ -15618,54 +14481,54 @@ Entry.VariableContainer.prototype.generateListSettingView = function() { c.addClass("entryListSettingLengthSpanWorkspace"); c.innerHTML = Lang.Workspace.number_of_list; d.appendChild(c); - b.appendChild(d); + a.appendChild(d); c = Entry.createElement("div"); c.addClass("entryListSettingLengthControllerWorkspace"); d.appendChild(c); d = Entry.createElement("span"); d.addClass("entryListSettingMinusWorkspace"); - d.bindOnClick(function(b) { - a.selectedList.array_.pop(); - a.updateListSettingView(a.selectedList); + d.bindOnClick(function(a) { + b.selectedList.array_.pop(); + b.updateListSettingView(b.selectedList); }); c.appendChild(d); d = Entry.createElement("input"); d.addClass("entryListSettingLengthInputWorkspace"); d.onblur = function() { - a.setListLength(this.value); + b.setListLength(this.value); }; d.onkeypress = function(a) { 13 == a.keyCode && this.blur(); }; - b.lengthInput = d; + a.lengthInput = d; c.appendChild(d); d = Entry.createElement("span"); d.addClass("entryListSettingPlusWorkspace"); - d.bindOnClick(function(b) { - a.selectedList.array_.push({data:0}); - a.updateListSettingView(a.selectedList); + d.bindOnClick(function(a) { + b.selectedList.array_.push({data:0}); + b.updateListSettingView(b.selectedList); }); c.appendChild(d); c = Entry.createElement("div"); - b.seperator = c; - b.appendChild(c); + a.seperator = c; + a.appendChild(c); c.addClass("entryListSettingSeperatorWorkspace"); c = Entry.createElement("div"); c.addClass("entryListSettingListValuesWorkspace"); - b.listValues = c; - b.appendChild(c); + a.listValues = c; + a.appendChild(c); }; -Entry.VariableContainer.prototype.updateListSettingView = function(a) { - var b = this; - a = a || this.selectedList; +Entry.VariableContainer.prototype.updateListSettingView = function(b) { + var a = this; + b = b || this.selectedList; var c = this.listSettingView, d = c.listValues, e = c.visibleCheck, f = c.lengthInput, g = c.seperator; e.removeClass("entryListSettingCheckedWorkspace"); - a.isVisible() && e.addClass("entryListSettingCheckedWorkspace"); - f.value = a.array_.length; - for (a.listElement.appendChild(c);d.firstChild;) { + b.isVisible() && e.addClass("entryListSettingCheckedWorkspace"); + f.value = b.array_.length; + for (b.listElement.appendChild(c);d.firstChild;) { d.removeChild(d.firstChild); } - var h = a.array_; + var h = b.array_; 0 === h.length ? g.addClass("entryRemove") : g.removeClass("entryRemove"); for (e = 0;e < h.length;e++) { (function(c) { @@ -15679,7 +14542,7 @@ Entry.VariableContainer.prototype.updateListSettingView = function(a) { f.value = h[c].data; f.onblur = function() { h[c].data = this.value; - a.updateView(); + b.updateView(); }; f.onkeypress = function(a) { 13 == a.keyCode && this.blur(); @@ -15689,106 +14552,105 @@ Entry.VariableContainer.prototype.updateListSettingView = function(a) { f = Entry.createElement("span"); f.bindOnClick(function() { h.splice(c, 1); - b.updateListSettingView(); + a.updateListSettingView(); }); f.addClass("entryListSettingValueRemoveWorkspace"); e.appendChild(f); d.appendChild(e); })(e); } - a.updateView(); + b.updateView(); c.removeClass("entryRemove"); }; -Entry.VariableContainer.prototype.setListLength = function(a) { - a = Number(a); - var b = this.selectedList.array_; - if (!isNaN(a)) { - var c = b.length; - if (c < a) { - for (a -= c, c = 0;c < a;c++) { - b.push({data:0}); +Entry.VariableContainer.prototype.setListLength = function(b) { + b = +b; + var a = this.selectedList.array_; + if (!isNaN(b)) { + var c = a.length; + if (c < b) { + for (b -= c, c = 0;c < b;c++) { + a.push({data:0}); } } else { - c > a && (b.length = a); + c > b && (a.length = b); } } this.updateListSettingView(); }; Entry.VariableContainer.prototype.updateViews = function() { - var a = this.lists_; + var b = this.lists_; this.variables_.map(function(a) { a.updateView(); }); - a.map(function(a) { + b.map(function(a) { a.updateView(); }); }; -Entry.VariableContainer.prototype.updateSelectedVariable = function(a, b) { - a ? "variable" == a.type ? (this.selectedVariable = a, this.updateVariableSettingView(a)) : "slide" == a.type ? (this.selectedVariable = a, this.updateVariableSettingView(a)) : "list" == a.type && (this.selectedList = a, this.updateListSettingView(a)) : (this.selectedVariable = null, "variable" == (b || "variable") ? this.variableSettingView.addClass("entryRemove") : this.listSettingView.addClass("entryRemove")); +Entry.VariableContainer.prototype.updateSelectedVariable = function(b, a) { + b ? "variable" == b.type ? (this.selectedVariable = b, this.updateVariableSettingView(b)) : "slide" == b.type ? (this.selectedVariable = b, this.updateVariableSettingView(b)) : "list" == b.type && (this.selectedList = b, this.updateListSettingView(b)) : (this.selectedVariable = null, "variable" == (a || "variable") ? this.variableSettingView.addClass("entryRemove") : this.listSettingView.addClass("entryRemove")); }; -Entry.VariableContainer.prototype.removeLocalVariables = function(a) { - var b = [], c = this; - this.mapVariable(function(a, c) { - a.object_ && a.object_ == c && b.push(a); - }, a); - b.map(function(a) { +Entry.VariableContainer.prototype.removeLocalVariables = function(b) { + var a = [], c = this; + this.mapVariable(function(b, c) { + b.object_ && b.object_ == c && a.push(b); + }, b); + a.map(function(a) { c.removeVariable(a); }); }; Entry.VariableContainer.prototype.updateCloudVariables = function() { - var a = Entry.projectId; - if (Entry.cloudSavable && a) { - var b = Entry.variableContainer, a = b.variables_.filter(function(a) { + var b = Entry.projectId; + if (Entry.cloudSavable && b) { + var a = Entry.variableContainer, b = a.variables_.filter(function(a) { return a.isCloud_; - }), a = a.map(function(a) { + }), b = b.map(function(a) { return a.toJSON(); - }), b = b.lists_.filter(function(a) { + }), a = a.lists_.filter(function(a) { return a.isCloud_; - }), b = b.map(function(a) { + }), a = a.map(function(a) { return a.toJSON(); }); - $.ajax({url:"/api/project/variable/" + Entry.projectId, type:"PUT", data:{variables:a, lists:b}}).done(function() { + $.ajax({url:"/api/project/variable/" + Entry.projectId, type:"PUT", data:{variables:b, lists:a}}).done(function() { }); } }; -Entry.VariableContainer.prototype.addRef = function(a, b) { +Entry.VariableContainer.prototype.addRef = function(b, a) { if (this.view_ && Entry.playground.mainWorkspace.getMode() === Entry.Workspace.MODE_BOARD) { - var c = {object:b.getCode().object, block:b}; - b.funcBlock && (c.funcBlock = b.funcBlock, delete b.funcBlock); - this[a].push(c); - if ("_functionRefs" == a) { - a = b.type.substr(5); - for (var d = Entry.variableContainer.functions_[a].content.getBlockList(), e = 0;e < d.length;e++) { - b = d[e]; - var f = b.events; - -1 < b.type.indexOf("func_") && b.type.substr(5) == a || (f && f.viewAdd && f.viewAdd.forEach(function(a) { - b.getCode().object = c.object; - a && (b.funcBlock = c.block, a(b)); - }), f && f.dataAdd && f.dataAdd.forEach(function(a) { - b.getCode().object = c.object; - a && (b.funcBlock = c.block, a(b)); + var c = {object:a.getCode().object, block:a}; + a.funcBlock && (c.funcBlock = a.funcBlock, delete a.funcBlock); + this[b].push(c); + if ("_functionRefs" == b) { + for (var d = a.type.substr(5), e = Entry.variableContainer.functions_[d].content.getBlockList(), f = 0;f < e.length;f++) { + a = e[f]; + var g = a.events; + -1 < a.type.indexOf("func_") && a.type.substr(5) == d || (g && g.viewAdd && g.viewAdd.forEach(function(b) { + a.getCode().object = c.object; + b && (a.funcBlock = c.block, b(a)); + }), g && g.dataAdd && g.dataAdd.forEach(function(b) { + a.getCode().object = c.object; + b && (a.funcBlock = c.block, b(a)); })); } } return c; } }; -Entry.VariableContainer.prototype.removeRef = function(a, b) { +Entry.VariableContainer.prototype.removeRef = function(b, a) { if (Entry.playground.mainWorkspace.getMode() === Entry.Workspace.MODE_BOARD) { - for (var c = this[a], d = 0;d < c.length;d++) { - if (c[d].block == b) { + for (var c = this[b], d = 0;d < c.length;d++) { + if (c[d].block == a) { c.splice(d, 1); break; } } - if ("_functionRefs" == a && (a = b.type.substr(5), d = Entry.variableContainer.functions_[a])) { - for (c = d.content.getBlockList(), d = 0;d < c.length;d++) { - b = c[d]; - var e = b.events; - -1 < b.type.indexOf("func_") && b.type.substr(5) == a || (e && e.viewDestroy && e.viewDestroy.forEach(function(a) { - a && a(b); - }), e && e.dataDestroy && e.dataDestroy.forEach(function(a) { - a && a(b); + if ("_functionRefs" == b && (c = a.type.substr(5), d = Entry.variableContainer.functions_[c])) { + for (var e = d.content.getBlockList(), d = 0;d < e.length;d++) { + a = e[d]; + var f = a.events; + -1 < a.type.indexOf("func_") && a.type.substr(5) == c || (f && f.viewDestroy && f.viewDestroy.forEach(function(b) { + b && b(a); + }), f && f.dataDestroy && f.dataDestroy.forEach(function(b) { + b && b(a); })); } } @@ -15797,10 +14659,10 @@ Entry.VariableContainer.prototype.removeRef = function(a, b) { Entry.VariableContainer.prototype._getBlockMenu = function() { return Entry.playground.mainWorkspace.getBlockMenu(); }; -Entry.VariableContainer.prototype._truncName = function(a, b) { - a = a.substring(0, this._maxNameLength); - Entry.toast.warning(Lang.Workspace[b + "_name_auto_edited_title"], Lang.Workspace[b + "_name_auto_edited_content"]); - return a; +Entry.VariableContainer.prototype._truncName = function(b, a) { + b = b.substring(0, this._maxNameLength); + Entry.toast.warning(Lang.Workspace[a + "_name_auto_edited_title"], Lang.Workspace[a + "_name_auto_edited_content"]); + return b; }; Entry.VariableContainer.prototype._maxNameLength = 10; Entry.block.run = {skeleton:"basic", color:"#3BBD70", contents:["this is", "basic block"], func:function() { @@ -15808,9 +14670,9 @@ Entry.block.run = {skeleton:"basic", color:"#3BBD70", contents:["this is", "basi Entry.block.mutant = {skeleton:"basic", event:"start", color:"#3BBD70", template:"test mutant block", params:[], func:function() { }, changeEvent:new Entry.Event}; Entry.block.jr_start = {skeleton:"pebble_event", event:"start", color:"#3BBD70", template:"%1", params:[{type:"Indicator", img:"/img/assets/ntry/bitmap/jr/block_play_image.png", highlightColor:"#3BBD70", position:{x:0, y:0}, size:22}], func:function() { - var a = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT), b; - for (b in a) { - this._unit = a[b]; + var b = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT), a; + for (a in b) { + this._unit = b[a]; } Ntry.unitComp = Ntry.entityManager.getComponent(this._unit.id, Ntry.STATIC.UNIT); }}; @@ -15820,9 +14682,9 @@ Entry.block.jr_repeat = {skeleton:"pebble_loop", color:"#127CDB", template:"%1 \ } if (0 < this.repeatCount) { this.repeatCount--; - var a = this.block.statements[0]; - if (0 !== a.getBlocks().length) { - return this.executor.stepInto(a), Entry.STATIC.CONTINUE; + var b = this.block.statements[0]; + if (0 !== b.getBlocks().length) { + return this.executor.stepInto(b), Entry.STATIC.CONTINUE; } } else { delete this.repeatCount; @@ -15837,10 +14699,10 @@ Entry.block.jr_item = {skeleton:"pebble_basic", color:"#F46C6C", template:"\uaf4 delete this.isContinue; } else { this.isAction = this.isContinue = !0; - var a = this; + var b = this; Ntry.dispatchEvent("unitAction", Ntry.STATIC.GET_ITEM, function() { Ntry.dispatchEvent("getItem"); - a.isAction = !1; + b.isAction = !1; }); return Entry.STATIC.CONTINUE; } @@ -15854,10 +14716,10 @@ Entry.block.cparty_jr_item = {skeleton:"pebble_basic", color:"#8ABC1D", template delete this.isContinue; } else { this.isAction = this.isContinue = !0; - var a = this; + var b = this; Ntry.dispatchEvent("unitAction", Ntry.STATIC.GET_ITEM, function() { Ntry.dispatchEvent("getItem"); - a.isAction = !1; + b.isAction = !1; }); return Entry.STATIC.CONTINUE; } @@ -15871,22 +14733,22 @@ Entry.block.jr_north = {skeleton:"pebble_basic", color:"#A751E3", template:"%1 % delete this.isContinue; } else { this.isAction = this.isContinue = !0; - var a = Ntry.STATIC, b = this, c = function() { + var b = Ntry.STATIC, a = this, c = function() { window.setTimeout(function() { Ntry.dispatchEvent("unitAction", Ntry.STATIC.WALK, function() { - b.isAction = !1; + a.isAction = !1; }); }, 3); }, d; switch(Ntry.unitComp.direction) { case Ntry.STATIC.EAST: - d = a.TURN_LEFT; + d = b.TURN_LEFT; break; case Ntry.STATIC.SOUTH: - d = a.HALF_ROTATION; + d = b.HALF_ROTATION; break; case Ntry.STATIC.WEST: - d = a.TURN_RIGHT; + d = b.TURN_RIGHT; break; default: c(); @@ -15896,7 +14758,7 @@ Entry.block.jr_north = {skeleton:"pebble_basic", color:"#A751E3", template:"%1 % } }}; Entry.block.jr_east = {skeleton:"pebble_basic", color:"#A751E3", template:"%1 %2", params:[{type:"Text", text:Lang.Menus.go_right}, {type:"Indicator", img:"/img/assets/ntry/bitmap/jr/block_right_image.png", position:{x:83, y:0}, size:22}], func:function() { - var a = Ntry.STATIC; + var b = Ntry.STATIC; if (this.isContinue) { if (this.isAction) { return Entry.STATIC.CONTINUE; @@ -15905,22 +14767,22 @@ Entry.block.jr_east = {skeleton:"pebble_basic", color:"#A751E3", template:"%1 %2 delete this.isContinue; } else { this.isAction = this.isContinue = !0; - var b = this, c = function() { + var a = this, c = function() { window.setTimeout(function() { - Ntry.dispatchEvent("unitAction", a.WALK, function() { - b.isAction = !1; + Ntry.dispatchEvent("unitAction", b.WALK, function() { + a.isAction = !1; }); }, 3); }, d; switch(Ntry.unitComp.direction) { - case a.SOUTH: - d = a.TURN_LEFT; + case b.SOUTH: + d = b.TURN_LEFT; break; - case a.WEST: - d = a.HALF_ROTATION; + case b.WEST: + d = b.HALF_ROTATION; break; - case a.NORTH: - d = a.TURN_RIGHT; + case b.NORTH: + d = b.TURN_RIGHT; break; default: c(); @@ -15938,22 +14800,22 @@ Entry.block.jr_south = {skeleton:"pebble_basic", color:"#A751E3", template:"%1 % delete this.isContinue; } else { this.isAction = this.isContinue = !0; - var a = Ntry.STATIC, b = this, c = function() { + var b = Ntry.STATIC, a = this, c = function() { window.setTimeout(function() { Ntry.dispatchEvent("unitAction", Ntry.STATIC.WALK, function() { - b.isAction = !1; + a.isAction = !1; }); }, 3); }, d; switch(Ntry.unitComp.direction) { - case a.EAST: - d = a.TURN_RIGHT; + case b.EAST: + d = b.TURN_RIGHT; break; - case a.NORTH: - d = a.HALF_ROTATION; + case b.NORTH: + d = b.HALF_ROTATION; break; - case a.WEST: - d = a.TURN_LEFT; + case b.WEST: + d = b.TURN_LEFT; break; default: c(); @@ -15971,22 +14833,22 @@ Entry.block.jr_west = {skeleton:"pebble_basic", color:"#A751E3", template:"%1 %2 delete this.isContinue; } else { this.isAction = this.isContinue = !0; - var a = Ntry.STATIC, b = this, c = function() { + var b = Ntry.STATIC, a = this, c = function() { window.setTimeout(function() { - Ntry.dispatchEvent("unitAction", a.WALK, function() { - b.isAction = !1; + Ntry.dispatchEvent("unitAction", b.WALK, function() { + a.isAction = !1; }); }, 3); }, d; switch(Ntry.unitComp.direction) { - case a.SOUTH: - d = a.TURN_RIGHT; + case b.SOUTH: + d = b.TURN_RIGHT; break; - case a.EAST: - d = a.HALF_ROTATION; + case b.EAST: + d = b.HALF_ROTATION; break; - case a.NORTH: - d = a.TURN_LEFT; + case b.NORTH: + d = b.TURN_LEFT; break; default: c(); @@ -15996,9 +14858,9 @@ Entry.block.jr_west = {skeleton:"pebble_basic", color:"#A751E3", template:"%1 %2 } }}; Entry.block.jr_start_basic = {skeleton:"basic_event", event:"start", color:"#3BBD70", template:"%1 %2", params:[{type:"Indicator", boxMultiplier:2, img:"/img/assets/block_icon/start_icon_play.png", highlightColor:"#3BBD70", size:17, position:{x:0, y:-2}}, Lang.Menus.maze_when_run], func:function() { - var a = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT), b; - for (b in a) { - this._unit = a[b]; + var b = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT), a; + for (a in b) { + this._unit = b[a]; } Ntry.unitComp = Ntry.entityManager.getComponent(this._unit.id, Ntry.STATIC.UNIT); }}; @@ -16011,9 +14873,9 @@ Entry.block.jr_go_straight = {skeleton:"basic", color:"#A751E3", template:"%1 %2 delete this.isContinue; } else { this.isAction = this.isContinue = !0; - var a = this; + var b = this; Ntry.dispatchEvent("unitAction", Ntry.STATIC.WALK, function() { - a.isAction = !1; + b.isAction = !1; }); return Entry.STATIC.CONTINUE; } @@ -16027,9 +14889,9 @@ Entry.block.jr_turn_left = {skeleton:"basic", color:"#A751E3", template:"%1 %2", delete this.isContinue; } else { this.isAction = this.isContinue = !0; - var a = this; + var b = this; Ntry.dispatchEvent("unitAction", Ntry.STATIC.TURN_LEFT, function() { - a.isAction = !1; + b.isAction = !1; }); return Entry.STATIC.CONTINUE; } @@ -16043,9 +14905,9 @@ Entry.block.jr_turn_right = {skeleton:"basic", color:"#A751E3", template:"%1 %2" delete this.isContinue; } else { this.isAction = this.isContinue = !0; - var a = this; + var b = this; Ntry.dispatchEvent("unitAction", Ntry.STATIC.TURN_RIGHT, function() { - a.isAction = !1; + b.isAction = !1; }); return Entry.STATIC.CONTINUE; } @@ -16059,59 +14921,59 @@ Entry.block.jr_go_slow = {skeleton:"basic", color:"#f46c6c", template:"%1 %2", p delete this.isContinue; } else { this.isAction = this.isContinue = !0; - var a = this; + var b = this; Ntry.dispatchEvent("unitAction", Ntry.STATIC.GO_SLOW, function() { - a.isAction = !1; + b.isAction = !1; }); return Entry.STATIC.CONTINUE; } }}; Entry.block.jr_repeat_until_dest = {skeleton:"basic_loop", color:"#498DEB", template:"%1 %2 %3 %4", syntax:["BasicWhile", "true"], params:[Lang.Menus.repeat_until_reach_2, {type:"Image", img:"/img/assets/ntry/bitmap/jr/jr_goal_image.png", size:18}, Lang.Menus.repeat_until_reach_1, {type:"Image", img:"/img/assets/week/blocks/for.png", size:24}], statements:[{accept:"basic"}], func:function() { - var a = this.block.statements[0]; - if (0 !== a.getBlocks().length) { - return this.executor.stepInto(a), Entry.STATIC.CONTINUE; + var b = this.block.statements[0]; + if (0 !== b.getBlocks().length) { + return this.executor.stepInto(b), Entry.STATIC.CONTINUE; } }}; Entry.block.jr_if_construction = {skeleton:"basic_loop", color:"#498DEB", template:"%1 %2 %3 %4", params:[Lang.Menus.jr_if_1, {type:"Image", img:"/img/assets/ntry/bitmap/jr/jr_construction_image.png", size:18}, Lang.Menus.jr_if_2, {type:"Image", img:"/img/assets/week/blocks/for.png", size:24}], statements:[{accept:"basic"}], func:function() { if (!this.isContinue) { - var a = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT), b, c; - for (c in a) { - b = a[c]; + var b = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT), a, c; + for (c in b) { + a = b[c]; } - a = Ntry.entityManager.getComponent(b.id, Ntry.STATIC.UNIT); - b = Ntry.entityManager.getComponent(b.id, Ntry.STATIC.GRID); - b = {x:b.x, y:b.y}; - Ntry.addVectorByDirection(b, a.direction, 1); - b = Ntry.entityManager.find({type:Ntry.STATIC.GRID, x:b.x, y:b.y}, {type:Ntry.STATIC.TILE, tileType:Ntry.STATIC.OBSTACLE_REPAIR}); + b = Ntry.entityManager.getComponent(a.id, Ntry.STATIC.UNIT); + a = Ntry.entityManager.getComponent(a.id, Ntry.STATIC.GRID); + a = {x:a.x, y:a.y}; + Ntry.addVectorByDirection(a, b.direction, 1); + a = Ntry.entityManager.find({type:Ntry.STATIC.GRID, x:a.x, y:a.y}, {type:Ntry.STATIC.TILE, tileType:Ntry.STATIC.OBSTACLE_REPAIR}); this.isContinue = !0; - a = this.block.statements[0]; - if (0 !== b.length && 0 !== a.getBlocks().length) { - return this.executor.stepInto(a), Entry.STATIC.CONTINUE; + b = this.block.statements[0]; + if (0 !== a.length && 0 !== b.getBlocks().length) { + return this.executor.stepInto(b), Entry.STATIC.CONTINUE; } } }}; Entry.block.jr_if_speed = {skeleton:"basic_loop", color:"#498DEB", template:Lang.Menus.jr_if_1 + " %1 " + Lang.Menus.jr_if_2 + " %2", params:[{type:"Image", img:"/img/assets/ntry/bitmap/jr/jr_speed_image.png", size:18}, {type:"Image", img:"/img/assets/week/blocks/for.png", size:24}], statements:[{accept:"basic"}], func:function() { if (!this.isContinue) { - var a = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT), b, c; - for (c in a) { - b = a[c]; + var b = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT), a, c; + for (c in b) { + a = b[c]; } - a = Ntry.entityManager.getComponent(b.id, Ntry.STATIC.UNIT); - b = Ntry.entityManager.getComponent(b.id, Ntry.STATIC.GRID); - b = {x:b.x, y:b.y}; - Ntry.addVectorByDirection(b, a.direction, 1); - b = Ntry.entityManager.find({type:Ntry.STATIC.GRID, x:b.x, y:b.y}, {type:Ntry.STATIC.TILE, tileType:Ntry.STATIC.OBSTACLE_SLOW}); + b = Ntry.entityManager.getComponent(a.id, Ntry.STATIC.UNIT); + a = Ntry.entityManager.getComponent(a.id, Ntry.STATIC.GRID); + a = {x:a.x, y:a.y}; + Ntry.addVectorByDirection(a, b.direction, 1); + a = Ntry.entityManager.find({type:Ntry.STATIC.GRID, x:a.x, y:a.y}, {type:Ntry.STATIC.TILE, tileType:Ntry.STATIC.OBSTACLE_SLOW}); this.isContinue = !0; - a = this.block.statements[0]; - if (0 !== b.length && 0 !== a.getBlocks().length) { - return this.executor.stepInto(a), Entry.STATIC.CONTINUE; + b = this.block.statements[0]; + if (0 !== a.length && 0 !== b.getBlocks().length) { + return this.executor.stepInto(b), Entry.STATIC.CONTINUE; } } }}; Entry.block.maze_step_start = {skeleton:"basic_event", mode:"maze", event:"start", color:"#3BBD70", template:"%1 \uc2dc\uc791\ud558\uae30\ub97c \ud074\ub9ad\ud588\uc744 \ub54c", syntax:["Program"], params:[{type:"Indicator", boxMultiplier:2, img:"/img/assets/block_icon/start_icon_play.png", highlightColor:"#3BBD70", size:17, position:{x:0, y:-2}}], func:function() { - var a = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT), b; - for (b in a) { - this._unit = a[b]; + var b = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT), a; + for (a in b) { + this._unit = b[a]; } Ntry.unitComp = Ntry.entityManager.getComponent(this._unit.id, Ntry.STATIC.UNIT); }}; @@ -16124,9 +14986,9 @@ Entry.block.maze_step_jump = {skeleton:"basic", mode:"maze", color:"#FF6E4B", te delete this.isContinue; } else { this.isAction = this.isContinue = !0; - var a = this; + var b = this; Ntry.dispatchEvent("unitAction", Ntry.STATIC.JUMP, function() { - a.isAction = !1; + b.isAction = !1; }); return Entry.STATIC.CONTINUE; } @@ -16137,9 +14999,9 @@ Entry.block.maze_step_for = {skeleton:"basic_loop", mode:"maze", color:"#498DEB" } if (0 < this.repeatCount) { this.repeatCount--; - var a = this.block.statements[0]; - if (0 !== a.getBlocks().length) { - return this.executor.stepInto(a), Entry.STATIC.CONTINUE; + var b = this.block.statements[0]; + if (0 !== b.getBlocks().length) { + return this.executor.stepInto(b), Entry.STATIC.CONTINUE; } } else { delete this.repeatCount; @@ -16148,62 +15010,62 @@ Entry.block.maze_step_for = {skeleton:"basic_loop", mode:"maze", color:"#498DEB" Entry.block.test = {skeleton:"basic_boolean_field", mode:"maze", color:"#127CDB", template:"%1 this is test block %2", params:[{type:"Angle", value:"90"}, {type:"Dropdown", options:[[1, 1], [2, 2], [3, 3], [4, 4], [5, 5], [6, 6], [7, 7], [8, 8], [9, 9], [10, 10]], value:1}], func:function() { }}; Entry.block.maze_repeat_until_1 = {skeleton:"basic_loop", mode:"maze", color:"#498DEB", template:"%1 \ub9cc\ub0a0 \ub54c \uae4c\uc9c0 \ubc18\ubcf5%2", syntax:["BasicWhile", "true"], params:[{type:"Image", img:"/img/assets/ntry/block_inner/repeat_goal_1.png", size:18}, {type:"Image", img:"/img/assets/week/blocks/for.png", size:24}], statements:[{accept:"basic"}], func:function() { - var a = this.block.statements[0]; - if (0 !== a.getBlocks().length) { - return this.executor.stepInto(a), Entry.STATIC.CONTINUE; + var b = this.block.statements[0]; + if (0 !== b.getBlocks().length) { + return this.executor.stepInto(b), Entry.STATIC.CONTINUE; } }}; Entry.block.maze_repeat_until_2 = {skeleton:"basic_loop", mode:"maze", color:"#498DEB", template:"\ubaa8\ub4e0 %1 \ub9cc\ub0a0 \ub54c \uae4c\uc9c0 \ubc18\ubcf5%2", syntax:["BasicWhile", "true"], params:[{type:"Image", img:"/img/assets/ntry/block_inner/repeat_goal_1.png", size:18}, {type:"Image", img:"/img/assets/week/blocks/for.png", size:24}], statements:[{accept:"basic"}], func:function() { - var a = this.block.statements[0]; - if (0 !== a.getBlocks().length) { - return this.executor.stepInto(a), Entry.STATIC.CONTINUE; + var b = this.block.statements[0]; + if (0 !== b.getBlocks().length) { + return this.executor.stepInto(b), Entry.STATIC.CONTINUE; } }}; Entry.block.maze_step_if_1 = {skeleton:"basic_loop", mode:"maze", color:"#498DEB", template:"\ub9cc\uc57d \uc55e\uc5d0 %1 \uc788\ub2e4\uba74%2", syntax:["BasicIf", 'front == "wall"'], params:[{type:"Image", img:"/img/assets/ntry/block_inner/if_target_1.png", size:18}, {type:"Image", img:"/img/assets/week/blocks/if.png", size:24}], statements:[{accept:"basic"}], func:function() { if (!this.isContinue) { - var a = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT), b, c; - for (c in a) { - b = a[c]; - } - a = Ntry.entityManager.getComponent(b.id, Ntry.STATIC.UNIT); - b = Ntry.entityManager.getComponent(b.id, Ntry.STATIC.GRID); - b = {x:b.x, y:b.y}; - Ntry.addVectorByDirection(b, a.direction, 1); - c = Ntry.entityManager.find({type:Ntry.STATIC.GRID, x:b.x, y:b.y}); - a = this.block.statements[0]; + var b = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT), a, c; + for (c in b) { + a = b[c]; + } + b = Ntry.entityManager.getComponent(a.id, Ntry.STATIC.UNIT); + a = Ntry.entityManager.getComponent(a.id, Ntry.STATIC.GRID); + a = {x:a.x, y:a.y}; + Ntry.addVectorByDirection(a, b.direction, 1); + c = Ntry.entityManager.find({type:Ntry.STATIC.GRID, x:a.x, y:a.y}); + b = this.block.statements[0]; if (0 === c.length) { - return this.executor.stepInto(a), Entry.STATIC.CONTINUE; + return this.executor.stepInto(b), Entry.STATIC.CONTINUE; } - b = Ntry.entityManager.find({type:Ntry.STATIC.GRID, x:b.x, y:b.y}, {type:Ntry.STATIC.TILE, tileType:Ntry.STATIC.WALL}); + a = Ntry.entityManager.find({type:Ntry.STATIC.GRID, x:a.x, y:a.y}, {type:Ntry.STATIC.TILE, tileType:Ntry.STATIC.WALL}); this.isContinue = !0; - if (0 !== b.length && 0 !== a.getBlocks().length) { - return this.executor.stepInto(a), Entry.STATIC.CONTINUE; + if (0 !== a.length && 0 !== b.getBlocks().length) { + return this.executor.stepInto(b), Entry.STATIC.CONTINUE; } } }}; Entry.block.maze_step_if_2 = {skeleton:"basic_loop", mode:"maze", color:"#498DEB", template:"\ub9cc\uc57d \uc55e\uc5d0 %1 \uc788\ub2e4\uba74%2", syntax:["BasicIf", 'front == "bee"'], params:[{type:"Image", img:"/img/assets/ntry/bitmap/maze2/obstacle_01.png", size:18}, {type:"Image", img:"/img/assets/week/blocks/if.png", size:24}], statements:[{accept:"basic"}], func:function() { if (!this.isContinue) { - var a = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT), b, c; - for (c in a) { - b = a[c]; + var b = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT), a, c; + for (c in b) { + a = b[c]; } - a = Ntry.entityManager.getComponent(b.id, Ntry.STATIC.UNIT); - b = Ntry.entityManager.getComponent(b.id, Ntry.STATIC.GRID); - b = {x:b.x, y:b.y}; - Ntry.addVectorByDirection(b, a.direction, 1); - b = Ntry.entityManager.find({type:Ntry.STATIC.GRID, x:b.x, y:b.y}, {type:Ntry.STATIC.TILE, tileType:Ntry.STATIC.OBSTACLE_BEE}); + b = Ntry.entityManager.getComponent(a.id, Ntry.STATIC.UNIT); + a = Ntry.entityManager.getComponent(a.id, Ntry.STATIC.GRID); + a = {x:a.x, y:a.y}; + Ntry.addVectorByDirection(a, b.direction, 1); + a = Ntry.entityManager.find({type:Ntry.STATIC.GRID, x:a.x, y:a.y}, {type:Ntry.STATIC.TILE, tileType:Ntry.STATIC.OBSTACLE_BEE}); this.isContinue = !0; - a = this.block.statements[0]; - if (0 !== b.length && 0 !== a.getBlocks().length) { - return this.executor.stepInto(a), Entry.STATIC.CONTINUE; + b = this.block.statements[0]; + if (0 !== a.length && 0 !== b.getBlocks().length) { + return this.executor.stepInto(b), Entry.STATIC.CONTINUE; } } }}; Entry.block.maze_call_function = {skeleton:"basic", mode:"maze", color:"#B57242", template:"\uc57d\uc18d \ubd88\ub7ec\uc624\uae30%1", syntax:["Scope", "promise"], params:[{type:"Image", img:"/img/assets/week/blocks/function.png", size:24}], func:function() { if (!this.funcExecutor) { - var a = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.CODE), b; - for (b in a) { - this.funcExecutor = new Entry.Executor(a[b].components[Ntry.STATIC.CODE].code.getEventMap("define")[0]); + var b = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.CODE), a; + for (a in b) { + this.funcExecutor = new Entry.Executor(b[a].components[Ntry.STATIC.CODE].code.getEventMap("define")[0]); } } this.funcExecutor.execute(); @@ -16211,44 +15073,44 @@ Entry.block.maze_call_function = {skeleton:"basic", mode:"maze", color:"#B57242" return Entry.STATIC.CONTINUE; } }}; -Entry.block.maze_define_function = {skeleton:"basic_define", mode:"maze", color:"#B57242", event:"define", template:"\uc57d\uc18d\ud558\uae30%1", syntax:["BasicFunction"], params:[{type:"Image", img:"/img/assets/week/blocks/function.png", size:24}], statements:[{accept:"basic"}], func:function(a) { - if (!this.executed && (a = this.block.statements[0], 0 !== a.getBlocks().length)) { - return this.executor.stepInto(a), this.executed = !0, Entry.STATIC.CONTINUE; +Entry.block.maze_define_function = {skeleton:"basic_define", mode:"maze", color:"#B57242", event:"define", template:"\uc57d\uc18d\ud558\uae30%1", syntax:["BasicFunction"], params:[{type:"Image", img:"/img/assets/week/blocks/function.png", size:24}], statements:[{accept:"basic"}], func:function(b) { + if (!this.executed && (b = this.block.statements[0], 0 !== b.getBlocks().length)) { + return this.executor.stepInto(b), this.executed = !0, Entry.STATIC.CONTINUE; } }}; Entry.block.maze_step_if_3 = {skeleton:"basic_loop", mode:"maze", color:"#498DEB", template:"\ub9cc\uc57d \uc55e\uc5d0 %1 \uc788\ub2e4\uba74%2", syntax:["BasicIf", 'front == "banana"'], params:[{type:"Image", img:"/img/assets/ntry/block_inner/if_target_3.png", size:18}, {type:"Image", img:"/img/assets/week/blocks/if.png", size:24}], statements:[{accept:"basic"}], func:function() { if (!this.isContinue) { - var a = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT), b, c; - for (c in a) { - b = a[c]; + var b = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT), a, c; + for (c in b) { + a = b[c]; } - a = Ntry.entityManager.getComponent(b.id, Ntry.STATIC.UNIT); - b = Ntry.entityManager.getComponent(b.id, Ntry.STATIC.GRID); - b = {x:b.x, y:b.y}; - Ntry.addVectorByDirection(b, a.direction, 1); - b = Ntry.entityManager.find({type:Ntry.STATIC.GRID, x:b.x, y:b.y}, {type:Ntry.STATIC.TILE, tileType:Ntry.STATIC.OBSTACLE_BANANA}); + b = Ntry.entityManager.getComponent(a.id, Ntry.STATIC.UNIT); + a = Ntry.entityManager.getComponent(a.id, Ntry.STATIC.GRID); + a = {x:a.x, y:a.y}; + Ntry.addVectorByDirection(a, b.direction, 1); + a = Ntry.entityManager.find({type:Ntry.STATIC.GRID, x:a.x, y:a.y}, {type:Ntry.STATIC.TILE, tileType:Ntry.STATIC.OBSTACLE_BANANA}); this.isContinue = !0; - a = this.block.statements[0]; - if (0 !== b.length && 0 !== a.getBlocks().length) { - return this.executor.stepInto(a), Entry.STATIC.CONTINUE; + b = this.block.statements[0]; + if (0 !== a.length && 0 !== b.getBlocks().length) { + return this.executor.stepInto(b), Entry.STATIC.CONTINUE; } } }}; Entry.block.maze_step_if_4 = {skeleton:"basic_loop", mode:"maze", color:"#498DEB", template:"\ub9cc\uc57d \uc55e\uc5d0 %1 \uc788\ub2e4\uba74%2", syntax:["BasicIf", 'front == "wall"'], params:[{type:"Image", img:"/img/assets/ntry/block_inner/if_target_2.png", size:18}, {type:"Image", img:"/img/assets/week/blocks/if.png", size:24}], statements:[{accept:"basic"}], func:function() { if (!this.isContinue) { - var a = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT), b, c; - for (c in a) { - b = a[c]; + var b = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT), a, c; + for (c in b) { + a = b[c]; } - a = Ntry.entityManager.getComponent(b.id, Ntry.STATIC.UNIT); - b = Ntry.entityManager.getComponent(b.id, Ntry.STATIC.GRID); - b = {x:b.x, y:b.y}; - Ntry.addVectorByDirection(b, a.direction, 1); - b = Ntry.entityManager.find({type:Ntry.STATIC.GRID, x:b.x, y:b.y}, {type:Ntry.STATIC.TILE, tileType:Ntry.STATIC.WALL}); + b = Ntry.entityManager.getComponent(a.id, Ntry.STATIC.UNIT); + a = Ntry.entityManager.getComponent(a.id, Ntry.STATIC.GRID); + a = {x:a.x, y:a.y}; + Ntry.addVectorByDirection(a, b.direction, 1); + a = Ntry.entityManager.find({type:Ntry.STATIC.GRID, x:a.x, y:a.y}, {type:Ntry.STATIC.TILE, tileType:Ntry.STATIC.WALL}); this.isContinue = !0; - a = this.block.statements[0]; - if (0 !== b.length && 0 !== a.getBlocks().length) { - return this.executor.stepInto(a), Entry.STATIC.CONTINUE; + b = this.block.statements[0]; + if (0 !== a.length && 0 !== b.getBlocks().length) { + return this.executor.stepInto(b), Entry.STATIC.CONTINUE; } } }}; @@ -16261,9 +15123,9 @@ Entry.block.maze_step_move_step = {skeleton:"basic", mode:"maze", color:"#A751E3 delete this.isContinue; } else { this.isAction = this.isContinue = !0; - var a = this; + var b = this; Ntry.dispatchEvent("unitAction", Ntry.STATIC.WALK, function() { - a.isAction = !1; + b.isAction = !1; }); return Entry.STATIC.CONTINUE; } @@ -16277,9 +15139,9 @@ Entry.block.maze_step_rotate_left = {skeleton:"basic", mode:"maze", color:"#A751 delete this.isContinue; } else { this.isAction = this.isContinue = !0; - var a = this; + var b = this; Ntry.dispatchEvent("unitAction", Ntry.STATIC.TURN_LEFT, function() { - a.isAction = !1; + b.isAction = !1; }); return Entry.STATIC.CONTINUE; } @@ -16293,9 +15155,9 @@ Entry.block.maze_step_rotate_right = {skeleton:"basic", mode:"maze", color:"#A75 delete this.isContinue; } else { this.isAction = this.isContinue = !0; - var a = this; + var b = this; Ntry.dispatchEvent("unitAction", Ntry.STATIC.TURN_RIGHT, function() { - a.isAction = !1; + b.isAction = !1; }); return Entry.STATIC.CONTINUE; } @@ -16304,1876 +15166,2538 @@ Entry.block.test_wrapper = {skeleton:"basic", mode:"maze", color:"#3BBD70", temp }}; Entry.block.basic_button = {skeleton:"basic_button", color:"#eee", template:"%1", params:[{type:"Text", text:"basic button", color:"#333", align:"center"}], func:function() { }}; -Entry.Thread = function(a, b, c) { - this._data = new Entry.Collection; - this._code = b; +Entry.BlockMenu = function(b, a, c, d) { + Entry.Model(this, !1); + this._align = a || "CENTER"; + this._scroll = void 0 !== d ? d : !1; + this._bannedClass = []; + this._categories = []; + this.suffix = "blockMenu"; + b = "string" === typeof b ? $("#" + b) : $(b); + if ("DIV" !== b.prop("tagName")) { + return console.error("Dom is not div element"); + } + this.view = b; + this.visible = !0; + this._svgId = "blockMenu" + (new Date).getTime(); + this._clearCategory(); + this._categoryData = c; + this._generateView(c); + this._splitters = []; + this.setWidth(); + this.svg = Entry.SVG(this._svgId); + Entry.Utils.addFilters(this.svg, this.suffix); + a = Entry.Utils.addBlockPattern(this.svg, this.suffix); + this.patternRect = a.rect; + this.pattern = a.pattern; + this.svgGroup = this.svg.elem("g"); + this.svgThreadGroup = this.svgGroup.elem("g"); + this.svgThreadGroup.board = this; + this.svgBlockGroup = this.svgGroup.elem("g"); + this.svgBlockGroup.board = this; this.changeEvent = new Entry.Event(this); - this.changeEvent.attach(this, this.handleChange); - this._event = null; - this.parent = c ? c : b; - this.load(a); -}; -(function(a) { - a.load = function(a, c) { - void 0 === a && (a = []); - if (!(a instanceof Array)) { - return console.error("thread must be array"); + c && this._generateCategoryCodes(c); + this.observe(this, "_handleDragBlock", ["dragBlock"]); + this._scroll && (this._scroller = new Entry.BlockMenuScroller(this), this._addControl(b)); + Entry.documentMousedown && Entry.documentMousedown.attach(this, this.setSelectedBlock); + this._categoryCodes && Entry.keyPressed && Entry.keyPressed.attach(this, this._captureKeyEvent); + Entry.windowResized && (b = _.debounce(this.updateOffset, 200), Entry.windowResized.attach(this, b)); +}; +(function(b) { + b.schema = {code:null, dragBlock:null, closeBlock:null, selectedBlockView:null}; + b._generateView = function(a) { + var b = this.view, d = this; + a && (this._categoryCol = Entry.Dom("ul", {class:"entryCategoryListWorkspace", parent:b}), this._generateCategoryView(a)); + this.blockMenuContainer = Entry.Dom("div", {"class":"blockMenuContainer", parent:b}); + this.svgDom = Entry.Dom($(''), {parent:this.blockMenuContainer}); + this.svgDom.mouseenter(function(a) { + d._scroller && d._scroller.setOpacity(1); + a = d.workspace.selectedBlockView; + !Entry.playground || Entry.playground.resizing || a && a.dragMode === Entry.DRAG_MODE_DRAG || (Entry.playground.focusBlockMenu = !0, a = d.svgGroup.getBBox(), a = a.width + a.x + 64, a > Entry.interfaceState.menuWidth && (this.widthBackup = Entry.interfaceState.menuWidth - 64, $(this).stop().animate({width:a - 62}, 200))); + }); + this.svgDom.mouseleave(function(a) { + Entry.playground && !Entry.playground.resizing && (d._scroller && d._scroller.setOpacity(0), (a = this.widthBackup) && $(this).stop().animate({width:a}, 200), delete this.widthBackup, delete Entry.playground.focusBlockMenu); + }); + $(window).scroll(function() { + d.updateOffset(); + }); + }; + b.changeCode = function(a) { + if (!(a instanceof Entry.Code)) { + return console.error("You must inject code instance"); } - for (var d = 0;d < a.length;d++) { - var e = a[d]; - e instanceof Entry.Block || e.isDummy ? (e.setThread(this), this._data.push(e)) : this._data.push(new Entry.Block(e, this)); + this.codeListener && this.code.changeEvent.detach(this.codeListener); + var b = this; + this.set({code:a}); + this.codeListener = this.code.changeEvent.attach(this, function() { + b.changeEvent.notify(); + }); + a.createView(this); + this.align(); + }; + b.bindCodeView = function(a) { + this.svgBlockGroup.remove(); + this.svgThreadGroup.remove(); + this.svgBlockGroup = a.svgBlockGroup; + this.svgThreadGroup = a.svgThreadGroup; + this.svgGroup.appendChild(this.svgThreadGroup); + this.svgGroup.appendChild(this.svgBlockGroup); + this._scroller && this.svgGroup.appendChild(this._scroller.svgGroup); + }; + b.align = function(a) { + var b = this.code; + if (b) { + this._clearSplitters(); + b.view && !a && b.view.reDraw(); + a = b.getThreads(); + for (var b = 10, d = "LEFT" == this._align ? 10 : this.svgDom.width() / 2, e, f = 0, g = a.length;f < g;f++) { + var h = a[f].getFirstBlock(), k = h.view, h = Entry.block[h.type]; + this.checkBanClass(h) ? k.set({display:!1}) : (k.set({display:!0}), h = h.class, e && e !== h && (this._createSplitter(b), b += 15), e = h, h = d - k.offsetX, "CENTER" == this._align && (h -= k.width / 2), b -= k.offsetY, k._moveTo(h, b, !1), b += k.height + 15); + } + this.updateSplitters(); + this.changeEvent.notify(); + } + }; + b.cloneToGlobal = function(a) { + if (!this._boardBlockView && null !== this.dragBlock) { + var b = this.workspace, d = b.getMode(), e = this.dragBlock, f = this._svgWidth, g = b.selectedBoard; + if (!g || d != Entry.Workspace.MODE_BOARD && d != Entry.Workspace.MODE_OVERLAYBOARD) { + Entry.GlobalSvg.setView(e, b.getMode()) && Entry.GlobalSvg.addControl(a); + } else { + if (g.code && (b = e.block, d = b.getThread(), b && d)) { + b = d.toJSON(!0); + this._boardBlockView = Entry.do("addThread", b).value.getFirstBlock().view; + var g = this.offset().top - g.offset().top, h, k; + if (b = this.dragBlock.mouseDownCoordinate) { + h = a.pageX - b.x, k = a.pageY - b.y; + } + this._boardBlockView._moveTo(e.x - f + (h || 0), e.y + g + (k || 0), !1); + this._boardBlockView.onMouseDown.call(this._boardBlockView, a); + this._boardBlockView.dragInstance.set({isNew:!0}); + } + } + } + }; + b.terminateDrag = function() { + if (this._boardBlockView) { + var a = 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 b < a - d; + } + } + }; + b.getCode = function(a) { + return this._code; + }; + b.setSelectedBlock = function(a) { + var b = this.selectedBlockView; + b && b.removeSelected(); + a instanceof Entry.BlockView ? a.addSelected() : a = null; + this.set({selectedBlockView:a}); + }; + b.hide = function() { + this.view.addClass("entryRemove"); + }; + b.show = function() { + this.view.removeClass("entryRemove"); + }; + b.renderText = function() { + for (var a = this.code.getThreads(), b = 0;b < a.length;b++) { + a[b].view.renderText(); } - (a = this._code.view) && this.createView(a.board, c); }; - a.registerEvent = function(a, c) { - this._event = c; - this._code.registerEvent(a, c); + b.renderBlock = function() { + for (var a = this.code.getThreads(), b = 0;b < a.length;b++) { + a[b].view.renderBlock(); + } }; - a.unregisterEvent = function(a, c) { - this._code.unregisterEvent(a, c); + b._createSplitter = function(a) { + a = this.svgBlockGroup.elem("line", {x1:20, y1:a, x2:this._svgWidth - 20, y2:a, stroke:"#b5b5b5"}); + this._splitters.push(a); }; - a.createView = function(a, c) { - this.view || (this.view = new Entry.ThreadView(this, a)); - this._data.map(function(d) { - d.createView(a, c); + b.updateSplitters = function(a) { + a = void 0 === a ? 0 : a; + var b = this._svgWidth - 20, d; + this._splitters.forEach(function(e) { + d = parseFloat(e.getAttribute("y1")) + a; + e.attr({x2:b, y1:d, y2:d}); }); }; - a.separate = function(a, c) { - this._data.has(a.id) && (a = this._data.splice(this._data.indexOf(a), c), this._code.createThread(a), this.changeEvent.notify()); + b._clearSplitters = function() { + for (var a = this._splitters, b = a.length - 1;0 <= b;b--) { + a[b].remove(), a.pop(); + } }; - a.cut = function(a) { - a = this._data.indexOf(a); - a = this._data.splice(a); - this.changeEvent.notify(); - return a; + b.setWidth = function() { + this._svgWidth = this.blockMenuContainer.width(); + this.updateSplitters(); }; - a.insertByBlock = function(a, c) { - a = a ? this._data.indexOf(a) : -1; - for (var d = 0;d < c.length;d++) { - c[d].setThread(this); + b.setMenu = function() { + var a = this._categoryCodes, b = this._categoryElems, d; + for (d in a) { + for (var e = a[d], e = e instanceof Entry.Code ? e.getThreads() : e, f = e.length, g = 0;g < e.length;g++) { + var h = e[g], h = h instanceof Entry.Thread ? h.getFirstBlock().type : h[0].type; + this.checkBanClass(Entry.block[h]) && f--; + } + 0 === f ? b[d].addClass("entryRemove") : b[d].removeClass("entryRemove"); } - this._data.splice.apply(this._data, [a + 1, 0].concat(c)); - this.changeEvent.notify(); }; - a.insertToTop = function(a) { - a.setThread(this); - this._data.unshift.apply(this._data, [a]); - this.changeEvent.notify(); + b.getCategoryCodes = function(a) { + a = this._convertSelector(a); + var b = this._categoryCodes[a]; + b || (this._generateCategoryElement(a), b = []); + b instanceof Entry.Code || (b = this._categoryCodes[a] = new Entry.Code(b)); + return b; }; - a.clone = function(a, c) { - a = a || this._code; - a = new Entry.Thread([], a); - for (var d = this._data, e = [], f = 0, g = d.length;f < g;f++) { - e.push(d[f].clone(a)); + b._convertSelector = function(a) { + if (isNaN(a)) { + return a; + } + a = +a; + for (var b = this._categories, d = this._categoryElems, e = 0;e < b.length;e++) { + var f = b[e]; + if (!d[f].hasClass("entryRemove") && 0 === a--) { + return f; + } } - a.load(e, c); - return a; }; - a.toJSON = function(a, c) { - var d = []; - for (c = void 0 === c ? 0 : c;c < this._data.length;c++) { - this._data[c] instanceof Entry.Block && d.push(this._data[c].toJSON(a)); + b.selectMenu = function(a, b) { + var d = this._convertSelector(a); + if (d) { + "variable" == d && Entry.playground.checkVariables(); + "arduino" == d && this._generateHwCode(); + var e = this._categoryElems[d], f = this._selectedCategoryView, g = !1, h = this.workspace.board, k = h.view; + f && f.removeClass("entrySelectedCategory"); + e != f || b ? f || (this.visible || (g = !0, k.addClass("foldOut"), Entry.playground.showTabs()), k.removeClass("folding"), this.visible = !0) : (k.addClass("folding"), this._selectedCategoryView = null, e.removeClass("entrySelectedCategory"), Entry.playground.hideTabs(), g = !0, this.visible = !1); + g && Entry.bindAnimationCallbackOnce(k, function() { + h.scroller.resizeScrollBar.call(h.scroller); + k.removeClass("foldOut"); + Entry.windowResized.notify(); + }); + this.visible && (f = this._categoryCodes[d], this._selectedCategoryView = e, e.addClass("entrySelectedCategory"), f.constructor !== Entry.Code && (f = this._categoryCodes[d] = new Entry.Code(f)), this.changeCode(f)); + this.lastSelector = d; } - return d; }; - a.destroy = function(a) { - this._code.destroyThread(this, !1); - this.view && this.view.destroy(a); - for (var c = this._data, d = c.length - 1;0 <= d;d--) { - c[d].destroy(a); + b._generateCategoryCodes = function(a) { + this._categoryCodes = {}; + for (var b = 0;b < a.length;b++) { + var d = a[b], e = []; + d.blocks.forEach(function(a) { + var b = Entry.block[a]; + if (b && b.def) { + if (b.defs) { + for (a = 0;a < b.defs.length;a++) { + e.push([b.defs[a]]); + } + } else { + e.push([b.def]); + } + } else { + e.push([{type:a}]); + } + }); + d = d.category; + this._categories.push(d); + this._categoryCodes[d] = e; } }; - a.getBlock = function(a) { - return this._data[a]; + b.banClass = function(a, b) { + 0 > this._bannedClass.indexOf(a) && this._bannedClass.push(a); + this.align(b); }; - a.getBlocks = function() { - return this._data.map(function(a) { - return a; - }); + b.unbanClass = function(a, b) { + var d = this._bannedClass.indexOf(a); + -1 < d && this._bannedClass.splice(d, 1); + this.align(b); }; - a.countBlock = function() { - for (var a = 0, c = 0;c < this._data.length;c++) { - var d = this._data[c]; - if (d.type && (a++, d = d.statements)) { - for (var e = 0;e < d.length;e++) { - a += d[e].countBlock(); + b.checkBanClass = function(a) { + if (a) { + a = a.isNotFor; + for (var b in this._bannedClass) { + if (a && -1 < a.indexOf(this._bannedClass[b])) { + return !0; } } + return !1; } - return a; - }; - a.handleChange = function() { - 0 === this._data.length && this.destroy(); }; - a.getCode = function() { - return this._code; + b._addControl = function(a) { + var b = this; + a.on("wheel", function() { + b._mouseWheel.apply(b, arguments); + }); }; - a.setCode = function(a) { - this._code = a; + b._mouseWheel = function(a) { + a = a.originalEvent; + a.preventDefault(); + var b = Entry.disposeEvent; + b && b.notify(a); + this._scroller.scroll(-a.wheelDeltaY || a.deltaY / 3); }; - a.spliceBlock = function(a) { - var c = this._data; - c.remove(a); - 0 === c.length && this.view.getParent().constructor !== Entry.FieldStatement && this.destroy(); - this.changeEvent.notify(); + b.dominate = function(a) { + this.svgBlockGroup.appendChild(a.view.svgGroup); }; - a.getFirstBlock = function() { - return this._data[0]; + b.reDraw = function() { + this.selectMenu(this.lastSelector, !0); }; - a.getPrevBlock = function(a) { - a = this._data.indexOf(a); - return this._data.at(a - 1); + b._handleDragBlock = function() { + this._boardBlockView = null; + this._scroller && this._scroller.setOpacity(0); }; - a.getNextBlock = function(a) { - a = this._data.indexOf(a); - return this._data.at(a + 1); + b._captureKeyEvent = function(a) { + var b = a.keyCode, d = Entry.type; + a.ctrlKey && "workspace" == d && 48 < b && 58 > b && (a.preventDefault(), this.selectMenu(b - 49)); }; - a.getLastBlock = function() { - return this._data.at(this._data.length - 1); + b.setPatternRectFill = function(a) { + this.patternRect.attr({fill:a}); + this.pattern.attr({style:""}); }; - a.getRootBlock = function() { - return this._data.at(0); + b.disablePattern = function() { + this.pattern.attr({style:"display: none"}); }; - a.hasBlockType = function(a) { - function c(d) { - if (a == d.type) { - return !0; - } - for (var f = d.params, g = 0;g < f.length;g++) { - var h = f[g]; - if (h && h.constructor == Entry.Block && c(h)) { - return !0; - } - } - if (d = d.statements) { - for (f = 0;f < d.length;f++) { - if (d[f].hasBlockType(a)) { - return !0; - } - } - } - return !1; + b._clearCategory = function() { + this._selectedCategoryView = null; + this._categories = []; + var a = this._categoryElems, b; + for (b in a) { + a[b].remove(); } - for (var d = 0;d < this._data.length;d++) { - if (c(this._data[d])) { - return !0; - } + this._categoryElems = {}; + a = this._categoryCodes; + for (b in a) { + var d = a[b]; + d.constructor == Entry.Code && d.clear(); } - return !1; - }; - a.getCount = function(a) { - var c = this._data.length; - a && (c -= this._data.indexOf(a)); - return c; - }; - a.indexOf = function(a) { - return this._data.indexOf(a); + this._categoryCodes = null; }; - a.pointer = function(a, c) { - c = this.indexOf(c); - a.unshift(c); - this.parent instanceof Entry.Block && a.unshift(this.parent.indexOfStatements(this)); - return this._code === this.parent ? (a.unshift(this._code.indexOf(this)), c = this._data[0], a.unshift(c.y), a.unshift(c.x), a) : this.parent.pointer(a); + b.setCategoryData = function(a) { + this._clearCategory(); + this._categoryData = a; + this._generateCategoryView(a); + this._generateCategoryCodes(a); }; - a.getBlockList = function(a) { - for (var c = [], d = 0;d < this._data.length;d++) { - c = c.concat(this._data[d].getBlockList(a)); + b._generateCategoryView = function(a) { + if (a) { + for (var b = 0;b < a.length;b++) { + this._generateCategoryElement(a[b].category); + } } - return c; - }; - a.stringify = function() { - return JSON.stringify(this.toJSON()); }; -})(Entry.Thread.prototype); -Entry.skeleton = function() { -}; -Entry.skeleton.basic = {path:function(a) { - var b = a.contentWidth; - a = a.contentHeight; - a = Math.max(30, a + 2); - b = Math.max(0, b + 9 - a / 2); - return "m -8,0 l 8,8 8,-8 h %w a %h,%h 0 0,1 0,%wh h -%w l -8,8 -8,-8 v -%wh z".replace(/%wh/gi, a).replace(/%w/gi, b).replace(/%h/gi, a / 2); -}, box:function(a) { - return {offsetX:-8, offsetY:0, width:(a ? a.contentWidth : 150) + 30, height:Math.max(30, (a ? a.contentHeight : 28) + 2), marginBottom:0}; -}, magnets:function(a) { - return {previous:{x:0, y:0}, next:{x:0, y:(a ? Math.max(a.height, 30) : 30) + 1 + a.offsetY}}; -}, contentPos:function(a) { - return {x:14, y:Math.max(a.contentHeight, 28) / 2 + 1}; -}}; -Entry.skeleton.basic_create = {path:function(a) { - var b = a.contentWidth; - a = a.contentHeight; - a = Math.max(30, a + 2); - b = Math.max(0, b + 9 - a / 2); - return "m -8,0 l 16,0 h %w a %h,%h 0 0,1 0,%wh h -%w l -8,8 -8,-8 v -%wh z".replace(/%wh/gi, a).replace(/%w/gi, b).replace(/%h/gi, a / 2); -}, box:function(a) { - return {offsetX:-8, offsetY:0, width:(a ? a.contentWidth : 150) + 30, height:Math.max(30, (a ? a.contentHeight : 28) + 2), marginBottom:0}; -}, magnets:function(a) { - return {next:{x:0, y:(a ? Math.max(a.height, 30) : 30) + 1 + a.offsetY}}; -}, contentPos:function(a) { - return {x:14, y:Math.max(a.contentHeight, 28) / 2 + 1}; -}}; -Entry.skeleton.basic_event = {path:function(a) { - a = a.contentWidth; - a = Math.max(0, a); - return "m -8,0 m 0,-5 a 19.5,19.5 0, 0,1 16,0 c 10,5 15,5 20,5 h %w a 15,15 0 0,1 0,30 H 8 l -8,8 -8,-8 l 0,0.5 a 19.5,19.5 0, 0,1 0,-35 z".replace(/%w/gi, a - 30); -}, box:function(a) { - return {offsetX:-19, offsetY:-7, width:a.contentWidth + 30, height:30, marginBottom:0}; -}, magnets:function(a) { - return {next:{x:0, y:(a ? Math.max(a.height + a.offsetY + 7, 30) : 30) + 1}}; -}, contentPos:function(a) { - return {x:1, y:15}; -}}; -Entry.skeleton.basic_loop = {path:function(a) { - var b = a.contentWidth, c = a.contentHeight, c = Math.max(30, c + 2), b = Math.max(0, b + 9 - c / 2); - a = a._statements[0] ? a._statements[0].height : 20; - a = Math.max(a, 20); - return "m -8,0 l 8,8 8,-8 h %w a %h,%h 0 0,1 0,%wh H 24 l -8,8 -8,-8 h -0.4 v %sh h 0.4 l 8,8 8,-8 h %bw a 8,8 0 0,1 0,16 H 8 l -8,8 -8,-8 z".replace(/%wh/gi, c).replace(/%w/gi, b).replace(/%bw/gi, b - 8).replace(/%h/gi, c / 2).replace(/%sh/gi, a + 1); -}, magnets:function(a) { - var b = Math.max(a.contentHeight + 2, 30), c = a._statements[0] ? a._statements[0].height : 20, c = Math.max(c, 20); - return {previous:{x:0, y:0}, next:{x:0, y:c + b + 18 + a.offsetY}}; -}, box:function(a) { - var b = a.contentWidth, c = Math.max(a.contentHeight + 2, 30); - a = a._statements[0] ? a._statements[0].height : 20; - a = Math.max(a, 20); - return {offsetX:-8, offsetY:0, width:b + 30, height:c + a + 17, marginBottom:0}; -}, statementPos:function(a) { - return [{x:16, y:Math.max(30, a.contentHeight + 2) + 1}]; -}, contentPos:function(a) { - return {x:14, y:Math.max(a.contentHeight, 28) / 2 + 1}; -}}; -Entry.skeleton.basic_define = {path:function(a) { - var b = a.contentWidth, c = a.contentHeight, c = Math.max(30, c + 2), b = Math.max(0, b + 9 - c / 2); - a = a._statements[0] ? a._statements[0].height : 30; - a = Math.max(a, 20); - return "m -8,0 l 16,0 h %w a %h,%h 0 0,1 0,%wh H 24 l -8,8 -8,-8 h -0.4 v %sh h 0.4 l 8,8 8,-8 h %bw a 8,8 0 0,1 0,16 H -8 z".replace(/%wh/gi, c).replace(/%w/gi, b).replace(/%h/gi, c / 2).replace(/%bw/gi, b - 8).replace(/%sh/gi, a + 1); -}, magnets:function() { - return {}; -}, box:function(a) { - return {offsetX:0, offsetY:0, width:a.contentWidth, height:Math.max(a.contentHeight, 25) + 46, marginBottom:0}; -}, statementPos:function(a) { - return [{x:16, y:Math.max(30, a.contentHeight + 2)}]; -}, contentPos:function() { - return {x:14, y:15}; -}}; -Entry.skeleton.pebble_event = {path:function(a) { - return "m 0,0 a 25,25 0 0,1 9,48.3 a 9,9 0 0,1 -18,0 a 25,25 0 0,1 9,-48.3 z"; -}, box:function(a) { - return {offsetX:-25, offsetY:0, width:50, height:48.3, marginBottom:0}; -}, magnets:function(a) { - return {next:{x:0, y:(a ? Math.max(a.height, 49.3) : 49.3) + a.offsetY}}; -}, contentPos:function() { - return {x:0, y:25}; -}}; -Entry.skeleton.pebble_loop = {fontSize:16, dropdownHeight:23, path:function(a) { - a = Math.max(a._statements[0] ? a._statements[0].height : 50, 50); - return "M 0,9 a 9,9 0 0,0 9,-9 h %cw q 25,0 25,25 v %ch q 0,25 -25,25 h -%cw a 9,9 0 0,1 -18,0 h -%cw q -25,0 -25,-25 v -%ch q 0,-25 25,-25 h %cw a 9,9 0 0,0 9,9 M 0,49 a 9,9 0 0,1 -9,-9 h -28 a 25,25 0 0,0 -25,25 v %cih a 25,25 0 0,0 25,25 h 28 a 9,9 0 0,0 18,0 h 28 a 25,25 0 0,0 25,-25 v -%cih a 25,25 0 0,0 -25,-25 h -28 a 9,9 0 0,1 -9,9 z".replace(/%cw/gi, 41).replace(/%ch/gi, a + 4).replace(/%cih/gi, a - 50); -}, magnets:function(a) { - var b = Math.max(a.contentHeight + 2, 41), c = a._statements[0] ? a._statements[0].height : 20, c = Math.max(c, 51); - return {previous:{x:0, y:0}, next:{x:0, y:c + b + 13 + a.offsetY}}; -}, box:function(a) { - var b = a.contentWidth, c = Math.max(a.contentHeight + 2, 41); - a = a._statements[0] ? a._statements[0].height : 20; - a = Math.max(a, 51); - return {offsetX:-(b / 2 + 13), offsetY:0, width:b + 30, height:c + a + 13, marginBottom:0}; -}, statementPos:function(a) { - return [{x:0, y:Math.max(39, a.contentHeight + 2) + 1.5}]; -}, contentPos:function() { - return {x:-46, y:25}; -}}; -Entry.skeleton.pebble_basic = {fontSize:15, morph:["prev", "next"], path:function(a) { - return "m 0,9 a 9,9 0 0,0 9,-9 h 28 q 25,0 25,25q 0,25 -25,25h -28 a 9,9 0 0,1 -18,0 h -28 q -25,0 -25,-25q 0,-25 25,-25h 28 a 9,9 0 0,0 9,9 z"; -}, magnets:function(a) { - return {previous:{x:0, y:0}, next:{x:0, y:(a ? Math.max(a.height, 51) : 51) + a.offsetY}}; -}, box:function() { - return {offsetX:-62, offsetY:0, width:124, height:50, marginBottom:0}; -}, contentPos:function() { - return {x:-46, y:25}; -}}; -Entry.skeleton.basic_string_field = {path:function(a) { - var b = a.contentWidth; - a = a.contentHeight; - a = Math.max(18, a + 2); - b = Math.max(0, b - a + 12); - return "m %h,0 h %w a %h,%h 0 1,1 0,%wh H %h A %h,%h 0 1,1 %h,0 z".replace(/%wh/gi, a).replace(/%w/gi, b).replace(/%h/gi, a / 2); -}, color:"#000", outerLine:"#768dce", box:function(a) { - return {offsetX:0, offsetY:0, width:(a ? a.contentWidth : 5) + 12, height:Math.max((a ? a.contentHeight : 18) + 2, 18), marginBottom:0}; -}, magnets:function() { - return {string:{}}; -}, contentPos:function(a) { - return {x:6, y:Math.max(a.contentHeight, 16) / 2 + 1}; -}}; -Entry.skeleton.basic_boolean_field = {path:function(a) { - var b = a.contentWidth; - a = a.contentHeight; - a = Math.max(18, a + 2); - b = Math.max(0, b - a + 19); - return "m %h,0 h %w l %h,%h -%h,%h H %h l -%h,-%h %h,-%h z".replace(/%wh/gi, a).replace(/%w/gi, b).replace(/%h/gi, a / 2); -}, color:"#000", outerLine:"#768dce", box:function(a) { - return {offsetX:0, offsetY:0, width:(a ? a.contentWidth : 5) + 19, height:Math.max((a ? a.contentHeight : 18) + 2, 18), marginBottom:0}; -}, magnets:function() { - return {boolean:{}}; -}, contentPos:function(a) { - return {x:10, y:Math.max(a.contentHeight, 16) / 2 + 1}; -}}; -Entry.skeleton.basic_param = {path:function(a) { - var b = a.contentWidth; - (a = a._contents[a._contents.length - 1]) && (b -= a.box.width + Entry.BlockView.PARAM_SPACE - 2); - b = Math.max(0, b); - return "m 4,0 h 10 h %w l 2,2 0,3 3,0 1,1 0,12 -1,1 -3,0 0,3 -2,2h -%w h -10 l -2,-2 0,-3 3,0 1,-1 0,-12 -1,-1 -3,0 0,-3 2,-2".replace(/%w/gi, b); -}, outerLine:"#768dce", box:function(a) { - return {offsetX:0, offsetY:0, width:(a ? a.contentWidth : 5) + 11, height:24, marginBottom:0}; -}, magnets:function() { - return {param:{}}; -}, contentPos:function(a) { - return {x:11, y:12}; -}}; -Entry.skeleton.basic_button = {path:function() { - return "m -64,0 h 128 a 6,6 0, 0,1 6,6 v 18 a 6,6 0, 0,1 -6,6 h -128 a 6,6 0, 0,1 -6,-6 v -18 a 6,6 0, 0,1 6,-6 z"; -}, box:function() { - return {offsetX:-80, offsetY:0, width:140, height:30}; -}, contentPos:function() { - return {x:0, y:15}; -}, movable:!1, readOnly:!0, nextShadow:!0, classes:["basicButtonView"]}; -Entry.skeleton.basic_without_next = {box:Entry.skeleton.basic.box, contentPos:Entry.skeleton.basic.contentPos, path:function(a) { - var b = a.contentWidth; - a = a.contentHeight; - a = Math.max(30, a + 2); - b = Math.max(0, b + 9 - a / 2); - return "m -8,0 l 8,8 8,-8 h %w a %h,%h 0 0,1 0, %wh H -8 z".replace(/%wh/gi, a).replace(/%w/gi, b).replace(/%h/gi, a / 2); -}, magnets:function(a) { - return {previous:{x:0, y:0}}; -}}; -Entry.skeleton.basic_double_loop = {path:function(a) { - var b = a.contentWidth, c = a.contentHeight % 1E3, d = Math.floor(a.contentHeight / 1E3), c = Math.max(30, c + 2), d = Math.max(30, d + 2), b = Math.max(0, b + 5 - c / 2), e = a._statements; - a = e[0] ? e[0].height : 20; - e = e[1] ? e[1].height : 20; - a = Math.max(a, 20); - e = Math.max(e, 20); - return "m -8,0 l 8,8 8,-8 h %w a %h1,%h1 0 0,1 0,%wh1 H 24 l -8,8 -8,-8 h -0.4 v %sh1 h 0.4 l 8,8 8,-8 h %bw a %h2,%h2 0 0,1 0,%wh2 H 24 l -8,8 -8,-8 h -0.4 v %sh2 h 0.4 l 8,8 8,-8 h %bw a 8,8 0 0,1 0,16 H 8 l -8,8 -8,-8 z".replace(/%wh1/gi, c).replace(/%wh2/gi, d).replace(/%w/gi, b).replace(/%bw/gi, b - 8).replace(/%h1/gi, c / 2).replace(/%h2/gi, d / 2).replace(/%sh1/gi, a + 1).replace(/%sh2/gi, e + 1); -}, magnets:function(a) { - var b = Math.max(a.contentHeight % 1E3 + 2, 30), c = Math.max(Math.floor(a.contentHeight / 1E3) + 2, 30), d = a._statements[0] ? a._statements[0].height : 20, e = a._statements[1] ? a._statements[1].height : 20, d = Math.max(d, 20), e = Math.max(e, 20); - return {previous:{x:0, y:0}, next:{x:0, y:d + e + b + c + 19 + a.offsetY}}; -}, box:function(a) { - var b = a.contentWidth, c = Math.max(Math.floor(a.contentHeight / 1E3) + 2, 30), d = Math.max(a.contentHeight % 1E3 + 2, 30), e = a._statements[0] ? a._statements[0].height % 1E3 : 20; - a = a._statements[1] ? a._statements[1].height : 20; - e = Math.max(e, 20); - a = Math.max(a, 20); - return {offsetX:-8, offsetY:0, width:b + 30, height:c + d + e + a + 17, marginBottom:0}; -}, statementPos:function(a) { - var b = Math.max(30, a.contentHeight % 1E3 + 2) + 1; - return [{x:16, y:b}, {x:16, y:b + Math.max(a._statements[0] ? a._statements[0].height % 1E3 : 20, 20) + Math.max(Math.floor(a.contentHeight / 1E3) + 2, 30) + 1}]; -}, contentPos:function(a) { - return {x:14, y:Math.max(a.contentHeight % 1E3, 28) / 2 + 1}; -}}; -Entry.Block = function(a, b) { - var c = this; - Entry.Model(this, !1); - this._schema = null; - this.setThread(b); - this.load(a); - a = this.getCode(); - a.registerBlock(this); - (b = this.events.dataAdd) && a.object && b.forEach(function(a) { - Entry.Utils.isFunction(a) && a(c); - }); -}; -Entry.Block.MAGNET_RANGE = 10; -Entry.Block.MAGNET_OFFSET = .4; -Entry.Block.DELETABLE_TRUE = 1; -Entry.Block.DELETABLE_FALSE = 2; -Entry.Block.DELETABLE_FALSE_LIGHTEN = 3; -(function(a) { - a.schema = {id:null, x:0, y:0, type:null, params:[], statements:[], view:null, thread:null, movable:null, deletable:Entry.Block.DELETABLE_TRUE, readOnly:null, copyable:!0, events:{}}; - a.load = function(a) { - a.id || (a.id = Entry.Utils.generateId()); - this.set(a); - this.loadSchema(); + 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); }; - a.changeSchema = function(a) { - this.set({params:[]}); - this.loadSchema(); + b.updateOffset = function() { + this._offset = this.svgDom.offset(); }; - a.getSchema = function() { - this._schema || this.loadSchema(); - return this._schema; + b.offset = function() { + (!this._offset || 0 === this._offset.top && 0 === this._offset.left) && this.updateOffset(); + return this._offset; }; - a.loadSchema = function() { - if (this._schema = Entry.block[this.type]) { - !this._schemaChangeEvent && this._schema.changeEvent && (this._schemaChangeEvent = this._schema.changeEvent.attach(this, this.changeSchema)); - var a = this._schema.events; - if (a) { - for (var c in a) { - this.events[c] || (this.events[c] = []); - for (var d = a[c], e = 0;e < d.length;e++) { - var f = d[e]; - f && 0 > this.events[c].indexOf(f) && this.events[c].push(f); - } - } - } - this._schema.event && this.thread.registerEvent(this, this._schema.event); - a = this.params; - c = this._schema.params; - for (e = 0;c && e < c.length;e++) { - d = void 0 === a[e] || null === a[e] ? c[e].value : a[e], f = a[e] || e < a.length, !d || "Output" !== c[e].type && "Block" !== c[e].type || (d = new Entry.Block(d, this.thread)), f ? a.splice(e, 1, d) : a.push(d); + b._generateHwCode = function() { + var a = this._categoryCodes.arduino; + a instanceof Entry.Code && a.clear(); + for (var b = this._categoryData, d, a = b.length - 1;0 <= a;a--) { + if ("arduino" === b[a].category) { + d = b[a].blocks; + break; } - if (a = this._schema.statements) { - for (e = 0;e < a.length;e++) { - this.statements.splice(e, 1, new Entry.Thread(this.statements[e], this.getCode(), this)); + } + b = []; + for (a = 0;a < d.length;a++) { + var e = d[a], f = Entry.block[e]; + if (!this.checkBanClass(f)) { + if (f && f.def) { + if (f.defs) { + for (a = 0;a < f.defs.length;a++) { + b.push([f.defs[a]]); + } + } else { + b.push([f.def]); + } + } else { + b.push([{type:e}]); } } } + this._categoryCodes.arduino = b; + }; +})(Entry.BlockMenu.prototype); +Entry.BlockMenuScroller = function(b) { + var a = this; + this.board = b; + this.board.changeEvent.attach(this, this._reset); + this.svgGroup = null; + this.vRatio = this.vY = this.vWidth = this.hX = 0; + this._visible = !0; + this._opacity = -1; + this.mouseHandler = function() { + a.onMouseDown.apply(a, arguments); + }; + this.createScrollBar(); + this.setOpacity(0); + this._addControl(); + Entry.windowResized && Entry.windowResized.attach(this, this.resizeScrollBar); +}; +Entry.BlockMenuScroller.RADIUS = 7; +(function(b) { + b.createScrollBar = function() { + this.svgGroup = this.board.svgGroup.elem("g", {class:"boardScrollbar"}); + this.vScrollbar = this.svgGroup.elem("rect", {rx:4, ry:4}); + this.resizeScrollBar(); + }; + b.resizeScrollBar = function() { + this._updateRatio(); + if (this._visible && 0 !== this.vRatio) { + var a = this.board.blockMenuContainer; + this.vScrollbar.attr({width:9, height:a.height() / this.vRatio, x:a.width() - 9}); + } }; - a.changeType = function(a) { - this._schemaChangeEvent && this._schemaChangeEvent.destroy(); - this.set({type:a}); - this.loadSchema(); - this.view && this.view.changeType(a); + b.updateScrollBar = function(a) { + this.vY += a; + this.vScrollbar.attr({y:this.vY}); }; - a.setThread = function(a) { - this.set({thread:a}); + b.scroll = function(a) { + this.isVisible() && (a = this._adjustValue(a) - this.vY, 0 !== a && (this.board.code.moveBy(0, -a * this.vRatio), this.updateScrollBar(a))); }; - a.getThread = function() { - return this.thread; + b._adjustValue = function(a) { + var b = this.board.svgDom.height(), b = b - b / this.vRatio; + a = this.vY + a; + a = Math.max(0, a); + return a = Math.min(b, a); }; - a.insertAfter = function(a) { - this.thread.insertByBlock(this, a); + b.setVisible = function(a) { + a != this.isVisible() && (this._visible = a, this.svgGroup.attr({display:!0 === a ? "block" : "none"})); }; - a._updatePos = function() { - this.view && this.set({x:this.view.x, y:this.view.y}); + b.setOpacity = function(a) { + this._opacity != a && (this.vScrollbar.attr({opacity:a}), this._opacity = a); }; - a.moveTo = function(a, c) { - this.view && this.view._moveTo(a, c); - this._updatePos(); - this.getCode().changeEvent.notify(); + b.isVisible = function() { + return this._visible; }; - a.createView = function(a, c) { - this.view || (this.set({view:new Entry.BlockView(this, a, c)}), this._updatePos()); + b._updateRatio = function() { + var a = this.board, b = a.svgBlockGroup.getBoundingClientRect(), d = a.blockMenuContainer.height(), a = a.offset(); + this.vRatio = b = (b.height + (b.top - a.top) + 10) / d; + 1 >= b ? this.setVisible(!1) : this.setVisible(!0); }; - a.clone = function(a) { - return new Entry.Block(this.toJSON(!0), a); + b._reset = function() { + this.vY = 0; + this.vScrollbar.attr({y:this.vY}); + this.resizeScrollBar(); }; - a.toJSON = function(a) { - var c = this._toJSON(); - delete c.view; - delete c.thread; - delete c.events; - a && delete c.id; - c.params = c.params.map(function(c) { - c instanceof Entry.Block && (c = c.toJSON(a)); - return c; - }); - c.statements = c.statements.map(function(c) { - return c.toJSON(a); + 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; + e.scroll(a.pageY - c.offsetY); + c.set({offsetY:a.pageY}); + } + function d(a) { + $(document).unbind(".scroll"); + delete e.dragInstance; + } + var e = this; + a.stopPropagation && a.stopPropagation(); + a.preventDefault && a.preventDefault(); + if (0 === a.button || a.originalEvent && a.originalEvent.touches) { + Entry.documentMousedown && Entry.documentMousedown.notify(a); + var f; + f = a.originalEvent && a.originalEvent.touches ? a.originalEvent.touches[0] : a; + var g = $(document); + g.bind("mousemove.scroll", b); + g.bind("mouseup.scroll", d); + g.bind("touchmove.scroll", b); + g.bind("touchend.scroll", d); + e.dragInstance = new Entry.DragInstance({startY:f.pageY, offsetY:f.pageY}); + } + a.stopPropagation(); + }; + b._addControl = function() { + $(this.vScrollbar).bind("mousedown touchstart", this.mouseHandler); + }; +})(Entry.BlockMenuScroller.prototype); +Entry.BlockView = function(b, a, c) { + Entry.Model(this, !1); + this.block = b; + this._lazyUpdatePos = _.debounce(b._updatePos.bind(b), 200); + this._board = a; + this._observers = []; + this.set(b); + this.svgGroup = a.svgBlockGroup.elem("g"); + this._schema = Entry.block[b.type]; + this._schema.changeEvent && (this._schemaChangeEvent = this._schema.changeEvent.attach(this, this._updateSchema)); + var d = this._skeleton = Entry.skeleton[this._schema.skeleton]; + this._contents = []; + this._statements = []; + this.magnet = {}; + this._paramMap = {}; + d.magnets && d.magnets(this).next && (this.svgGroup.nextMagnet = this.block, this._nextGroup = this.svgGroup.elem("g"), this._observers.push(this.observe(this, "_updateMagnet", ["contentHeight"]))); + this.isInBlockMenu = this.getBoard() instanceof Entry.BlockMenu; + var e = this; + this.mouseHandler = function() { + var a = e.block.events; + a && a.mousedown && a.mousedown.forEach(function(a) { + a(e); }); - c.x = this.x; - c.y = this.y; - c.movable = this.movable; - c.deletable = this.deletable; - c.readOnly = this.readOnly; - return c; + e.onMouseDown.apply(e, arguments); }; - a.destroy = function(a, c) { - var d = this, e = this.params; - if (e) { - for (var f = 0;f < e.length;f++) { - var g = e[f]; - g instanceof Entry.Block && (g.doNotSplice = !0, g.destroy(a)); + this._startRender(b, c); + this._observers.push(this.block.observe(this, "_setMovable", ["movable"])); + this._observers.push(this.block.observe(this, "_setReadOnly", ["movable"])); + this._observers.push(this.block.observe(this, "_setCopyable", ["copyable"])); + this._observers.push(this.block.observe(this, "_updateColor", ["deletable"], !1)); + this._observers.push(this.observe(this, "_updateBG", ["magneting"], !1)); + this._observers.push(this.observe(this, "_updateOpacity", ["visible"], !1)); + this._observers.push(this.observe(this, "_updateDisplay", ["display"], !1)); + this._observers.push(this.observe(this, "_updateShadow", ["shadow"])); + this._observers.push(this.observe(this, "_updateMagnet", ["offsetY"])); + this._observers.push(a.code.observe(this, "_setBoard", ["board"], !1)); + this.dragMode = Entry.DRAG_MODE_NONE; + Entry.Utils.disableContextmenu(this.svgGroup.node); + (a = b.events.viewAdd) && !this.isInBlockMenu && a.forEach(function(a) { + Entry.Utils.isFunction(a) && a(b); + }); +}; +Entry.BlockView.PARAM_SPACE = 5; +Entry.BlockView.DRAG_RADIUS = 5; +(function(b) { + b.schema = {id:0, type:Entry.STATIC.BLOCK_RENDER_MODEL, x:0, y:0, offsetX:0, offsetY:0, width:0, height:0, contentWidth:0, contentHeight:0, magneting:!1, visible:!0, animating:!1, shadow:!0, display:!0}; + b._startRender = function(a, b) { + var d = this, e = this._skeleton; + this.svgGroup.attr({class:"block"}); + var f = e.classes; + f && 0 !== f.length && f.forEach(function(a) { + d.svgGroup.addClass(a); + }); + f = e.path(this); + this.pathGroup = this.svgGroup.elem("g"); + this._updateMagnet(); + this._path = this.pathGroup.elem("path"); + this.getBoard().patternRect && ($(this._path).mouseenter(function(a) { + d._mouseEnable && d._changeFill(!0); + }), $(this._path).mouseleave(function(a) { + d._mouseEnable && d._changeFill(!1); + })); + var g = this._schema.color; + this.block.deletable === Entry.Block.DELETABLE_FALSE_LIGHTEN && (g = Entry.Utils.colorLighten(g)); + this._fillColor = g; + f = {d:f, fill:g, class:"blockPath"}; + if (this.magnet.next || this._skeleton.nextShadow) { + g = this.getBoard().suffix, this.pathGroup.attr({filter:"url(#entryBlockShadowFilter_" + g + ")"}); + } else { + if (this.magnet.string || this.magnet.boolean) { + f.stroke = e.outerLine; } } - if (e = this.statements) { - for (f = 0;f < e.length;f++) { - e[f].destroy(a); - } + e.outerLine && (f["stroke-width"] = "0.6"); + this._path.attr(f); + this._moveTo(this.x, this.y, !1); + this._startContentRender(b); + !0 !== this._board.disableMouseEvent && this._addControl(); + this.bindPrev(); + }; + b._startContentRender = function(a) { + a = void 0 === a ? Entry.Workspace.MODE_BOARD : a; + this.contentSvgGroup && this.contentSvgGroup.remove(); + var b = this._schema; + b.statements && b.statements.length && this.statementSvgGroup && this.statementSvgGroup.remove(); + this._contents = []; + this.contentSvgGroup = this.svgGroup.elem("g"); + b.statements && b.statements.length && (this.statementSvgGroup = this.svgGroup.elem("g")); + switch(a) { + case Entry.Workspace.MODE_BOARD: + ; + case Entry.Workspace.MODE_OVERLAYBOARD: + for (var d = /(%\d)/mi, e = (b.template ? b.template : Lang.template[this.block.type]).split(d), f = b.params, g = 0;g < e.length;g++) { + var h = e[g].trim(); + if (0 !== h.length) { + if (d.test(h)) { + var k = +h.split("%")[1] - 1, h = f[k], h = new Entry["Field" + h.type](h, this, k, a, g); + this._contents.push(h); + this._paramMap[k] = h; + } else { + this._contents.push(new Entry.FieldText({text:h}, this)); + } + } + } + if ((a = b.statements) && a.length) { + for (g = 0;g < a.length;g++) { + this._statements.push(new Entry.FieldStatement(a[g], this, g)); + } + } + break; + case Entry.Workspace.MODE_VIMBOARD: + g = this.getBoard().workspace.getCodeToText(this.block), this._contents.push(new Entry.FieldText({text:g, color:"white"}, this)); } - g = this.getPrevBlock(); - f = this.getNextBlock(); - this.getCode().unregisterBlock(this); - e = this.getThread(); - this._schema.event && e.unregisterEvent(this, this._schema.event); - f && (c ? f.destroy(a, c) : g ? f.view.bindPrev(g) : (c = this.getThread().view.getParent(), c.constructor === Entry.FieldStatement ? (f.view.bindPrev(c), c.insertTopBlock(f)) : c.constructor === Entry.FieldStatement ? f.replace(c._valueBlock) : f.view._toGlobalCoordinate())); - this.doNotSplice ? delete this.doNotSplice : e.spliceBlock(this); - this.view && this.view.destroy(a); - this._schemaChangeEvent && this._schemaChangeEvent.destroy(); - (a = this.events.dataDestroy) && this.getCode().object && a.forEach(function(a) { - Entry.Utils.isFunction(a) && a(d); - }); + this.alignContent(!1); }; - a.getView = function() { - return this.view; + b._updateSchema = function() { + this._startContentRender(); }; - a.setMovable = function(a) { - this.movable != a && this.set({movable:a}); + b.changeType = function(a) { + this._schemaChangeEvent && this._schemaChangeEvent.destroy(); + this._schema = Entry.block[a]; + this._schema.changeEvent && (this._schemaChangeEvent = this._schema.changeEvent.attach(this, this._updateSchema)); + this._updateSchema(); }; - a.setCopyable = function(a) { - this.copyable != a && this.set({copyable:a}); + b.alignContent = function(a) { + !0 !== a && (a = !1); + for (var b = 0, d = 0, e = 0, f = 0, g = 0, h = 0, k = 0;k < this._contents.length;k++) { + var l = this._contents[k]; + l instanceof Entry.FieldLineBreak ? (this._alignStatement(a, f), l.align(f), f++, d = l.box.y, b = 8) : (l.align(b, d, a), k === this._contents.length - 1 || l instanceof Entry.FieldText && 0 == l._text.length || (b += Entry.BlockView.PARAM_SPACE)); + l = l.box; + 0 !== f ? h = Math.max(1E3 * Math.round(l.height), h) : e = Math.max(l.height, e); + b += l.width; + g = Math.max(g, b); + this.set({contentWidth:g, contentHeight:e}); + } + this.set({contentHeight:e + h}); + this._statements.length != f && this._alignStatement(a, f); + a = this.getContentPos(); + this.contentSvgGroup.attr("transform", "translate(" + a.x + "," + a.y + ")"); + this.contentPos = a; + this._render(); + this._updateMagnet(); }; - a.isMovable = function() { - return this.movable; + b._alignStatement = function(a, b) { + var d = this._skeleton.statementPos ? this._skeleton.statementPos(this) : [], e = this._statements[b]; + e && (d = d[b]) && e.align(d.x, d.y, a); }; - a.isCopyable = function() { - return this.copyable; + b._render = function() { + this._renderPath(); + this.set(this._skeleton.box(this)); }; - a.setDeletable = function(a) { - this.deletable != a && this.set({deletable:a}); + b._renderPath = function() { + var a = this._skeleton.path(this); + this._path.attr({d:a}); + this.set({animating:!1}); }; - a.isDeletable = function() { - return this.deletable === Entry.Block.DELETABLE_TRUE; + b._setPosition = function(a) { + this.svgGroup.attr("transform", "translate(" + this.x + "," + this.y + ")"); }; - a.isReadOnly = function() { - return this.readOnly; + b._toLocalCoordinate = function(a) { + this._moveTo(0, 0, !1); + a.appendChild(this.svgGroup); }; - a.getCode = function() { - return this.thread.getCode(); + b._toGlobalCoordinate = function(a) { + a = this.getAbsoluteCoordinate(a); + this._moveTo(a.x, a.y, !1); + this.getBoard().svgBlockGroup.appendChild(this.svgGroup); }; - a.doAdd = function() { - this.getCode().changeEvent.notify(); + b._moveTo = function(a, b, d) { + this.set({x:a, y:b}); + this._lazyUpdatePos(); + this.visible && this.display && this._setPosition(d); }; - a.doMove = function() { - this._updatePos(); - this.getCode().changeEvent.notify(); + b._moveBy = function(a, b, d) { + return this._moveTo(this.x + a, this.y + b, d); }; - a.doSeparate = function() { - this.separate(); + b._addControl = function() { + var a = this; + this._mouseEnable = !0; + $(this.svgGroup).bind("mousedown.blockViewMousedown touchstart.blockViewMousedown", a.mouseHandler); + var b = a.block.events; + b && b.dblclick && $(this.svgGroup).dblclick(function() { + b.dblclick.forEach(function(b) { + b && b(a); + }); + }); }; - a.doInsert = function(a) { - "basic" === this.getBlockType() ? this.insert(a) : this.replace(a); + b.removeControl = function() { + this._mouseEnable = !1; + $(this.svgGroup).unbind(".blockViewMousedown"); + }; + b.onMouseDown = function(a) { + function c(a) { + a.stopPropagation(); + var c = e.workspace.getMode(), d; + c === Entry.Workspace.MODE_VIMBOARD && b.vimBoardEvent(a, "dragOver"); + d = a.originalEvent && a.originalEvent.touches ? a.originalEvent.touches[0] : a; + var f = m.mouseDownCoordinate, f = Math.sqrt(Math.pow(d.pageX - f.x, 2) + Math.pow(d.pageY - f.y, 2)); + (m.dragMode == Entry.DRAG_MODE_DRAG || f > Entry.BlockView.DRAG_RADIUS) && m.movable && (m.isInBlockMenu ? e.cloneToGlobal(a) : (a = !1, m.dragMode != Entry.DRAG_MODE_DRAG && (m._toGlobalCoordinate(), m.dragMode = Entry.DRAG_MODE_DRAG, m.block.getThread().changeEvent.notify(), Entry.GlobalSvg.setView(m, c), a = !0), this.animating && this.set({animating:!1}), 0 === m.dragInstance.height && m.dragInstance.set({height:-1 + m.height}), c = m.dragInstance, m._moveBy(d.pageX - c.offsetX, d.pageY - + c.offsetY, !1), c.set({offsetX:d.pageX, offsetY:d.pageY}), Entry.GlobalSvg.position(), m.originPos || (m.originPos = {x:m.x, y:m.y}), a && e.generateCodeMagnetMap(), m._updateCloseBlock())); + } + function d(a) { + $(document).unbind(".block"); + m.terminateDrag(a); + e && e.set({dragBlock:null}); + m._changeFill(!1); + Entry.GlobalSvg.remove(); + delete this.mouseDownCoordinate; + delete m.dragInstance; + } + a.stopPropagation && a.stopPropagation(); + a.preventDefault && a.preventDefault(); + this._changeFill(!1); + var e = this.getBoard(); + Entry.documentMousedown && Entry.documentMousedown.notify(a); + if (!this.readOnly && !e.viewOnly) { + e.setSelectedBlock(this); + this.dominate(); + if (0 === a.button || a.originalEvent && a.originalEvent.touches) { + var f; + f = a.originalEvent && a.originalEvent.touches ? a.originalEvent.touches[0] : a; + this.mouseDownCoordinate = {x:f.pageX, y:f.pageY}; + var g = $(document); + g.bind("mousemove.block touchmove.block", c); + g.bind("mouseup.block touchend.block", d); + this.dragInstance = new Entry.DragInstance({startX:f.pageX, startY:f.pageY, offsetX:f.pageX, offsetY:f.pageY, height:0, mode:!0}); + e.set({dragBlock:this}); + this.addDragging(); + this.dragMode = Entry.DRAG_MODE_MOUSEDOWN; + } else { + if (Entry.Utils.isRightButton(a)) { + var h = this, k = h.block; + if (this.isInBlockMenu) { + return; + } + f = []; + var g = {text:Lang.Blocks.Duplication_option, enable:this.copyable, callback:function() { + Entry.do("cloneBlock", k); + }}, l = {text:Lang.Blocks.CONTEXT_COPY_option, enable:this.copyable, callback:function() { + h.block.copyToClipboard(); + }}, n = {text:Lang.Blocks.Delete_Blocks, enable:k.isDeletable(), callback:function() { + Entry.do("destroyBlock", h.block); + }}; + f.push(g); + f.push(l); + f.push(n); + Entry.ContextMenu.show(f); + } + } + var m = this; + e.workspace.getMode() === Entry.Workspace.MODE_VIMBOARD && a && document.getElementsByClassName("CodeMirror")[0].dispatchEvent(Entry.Utils.createMouseEvent("dragStart", event)); + } }; - a.doDestroy = function(a) { - this.destroy(a); - this.getCode().changeEvent.notify(); - return this; + b.vimBoardEvent = function(a, b, d) { + a && (a = Entry.Utils.createMouseEvent(b, a), d && (a.block = d), document.getElementsByClassName("CodeMirror")[0].dispatchEvent(a)); }; - a.doDestroyBelow = function(a) { - console.log("destroyBelow", this.id, this.x, this.y); - this.destroy(a, !0); - this.getCode().changeEvent.notify(); - return this; + b.terminateDrag = function(a) { + var b = this.getBoard(), d = this.dragMode, e = this.block, f = b.workspace.getMode(); + this.removeDragging(); + this.set({visible:!0}); + this.dragMode = Entry.DRAG_MODE_NONE; + if (f === Entry.Workspace.MODE_VIMBOARD) { + b instanceof Entry.BlockMenu ? (b.terminateDrag(), this.vimBoardEvent(a, "dragEnd", e)) : b.clear(); + } else { + if (d === Entry.DRAG_MODE_DRAG) { + var f = this.dragInstance && this.dragInstance.isNew, g = Entry.GlobalSvg; + a = !1; + var h = this.block.getPrevBlock(this.block); + a = !1; + switch(Entry.GlobalSvg.terminateDrag(this)) { + case g.DONE: + g = b.magnetedBlockView; + g instanceof Entry.BlockView && (g = g.block); + h && !g ? Entry.do("separateBlock", e) : h || g || f ? g ? ("next" === g.view.magneting ? (h = e.getLastBlock(), this.dragMode = d, b.separate(e), this.dragMode = Entry.DRAG_MODE_NONE, Entry.do("insertBlock", g, h).isPass(f), Entry.ConnectionRipple.setView(g.view).dispose()) : (Entry.do("insertBlock", e, g).isPass(f), a = !0), createjs.Sound.play("entryMagneting")) : Entry.do("moveBlock", e).isPass(f) : e.getThread().view.isGlobal() ? Entry.do("moveBlock", e) : Entry.do("separateBlock", + e); + break; + case g.RETURN: + e = this.block; + d = this.originPos; + h ? (this.set({animating:!1}), createjs.Sound.play("entryMagneting"), this.bindPrev(h), e.insert(h)) : (f = e.getThread().view.getParent(), f instanceof Entry.Board ? this._moveTo(d.x, d.y, !1) : (createjs.Sound.play("entryMagneting"), Entry.do("insertBlock", e, f))); + break; + case g.REMOVE: + createjs.Sound.play("entryDelete"), f ? this.block.destroy(!1, !0) : this.block.doDestroyBelow(!1); + } + b.setMagnetedBlock(null); + a && Entry.ConnectionRipple.setView(e.view).dispose(); + } + } + this.destroyShadow(); + delete this.originPos; + this.dominate(); }; - a.copy = function() { - var a = this.getThread(), c = []; - if (a instanceof Entry.Thread) { - for (var d = a.getBlocks().indexOf(this), a = a.toJSON(!0, d), d = 0;d < a.length;d++) { - c.push(a[d]); + b._updateCloseBlock = function() { + var a = this.getBoard(), b; + if (this._skeleton.magnets) { + for (var d in this.magnet) { + if (b = "next" === d ? this.getBoard().getNearestMagnet(this.x, this.y + this.getBelowHeight(), d) : this.getBoard().getNearestMagnet(this.x, this.y, d)) { + return a.setMagnetedBlock(b.view, d); + } } - } else { - c.push(this.toJSON(!0)); + a.setMagnetedBlock(null); } - a = this.view.getAbsoluteCoordinate(); - d = c[0]; - d.x = a.x + 15; - d.y = a.y + 15; - d.id = Entry.Utils.generateId(); - return c; }; - a.copyToClipboard = function() { - Entry.clipboard = this.copy(); + b.dominate = function() { + this.block.getThread().view.dominate(); }; - a.separate = function(a) { - this.thread.separate(this, a); - this._updatePos(); - this.getCode().changeEvent.notify(); + b.getSvgRoot = function() { + for (var a = this.getBoard().svgBlockGroup, b = this.svgGroup;b.parentNode !== a;) { + b = b.parentNode; + } + return b; }; - a.insert = function(a) { - var c = this.thread.cut(this); - a instanceof Entry.Thread ? a.insertByBlock(null, c) : a.insertAfter(c); - this._updatePos(); - this.getCode().changeEvent.notify(); + b.getBoard = function() { + return this._board; }; - a.replace = function(a) { - this.thread.cut(this); - a.getThread().replace(this); - this.getCode().changeEvent.notify(); + b._setBoard = function() { + this._board = this._board.code.board; }; - a.getPrevBlock = function() { - return this.thread.getPrevBlock(this); + b.destroy = function(a) { + this._destroyObservers(); + var b = this.svgGroup; + a ? $(b).fadeOut(100, function() { + b.remove(); + }) : b.remove(); + this._contents.forEach(function(a) { + a.constructor !== Entry.Block && a.destroy(); + }); + var d = this.block; + (a = d.events.viewDestroy) && !this.isInBlockMenu && a.forEach(function(a) { + Entry.Utils.isFunction(a) && a(d); + }); + this._schemaChangeEvent && this._schemaChangeEvent.destroy(); }; - a.getNextBlock = function() { - return this.thread.getNextBlock(this) || null; + b.getShadow = function() { + this._shadow || (this._shadow = Entry.SVG.createElement(this.svgGroup.cloneNode(!0), {opacity:.5}), this.getBoard().svgGroup.appendChild(this._shadow)); + return this._shadow; }; - a.getLastBlock = function() { - return this.thread.getLastBlock(); + b.destroyShadow = function() { + this._shadow && (this._shadow.remove(), delete this._shadow); }; - a.getOutputBlock = function() { - for (var a = this._schema.params, c = 0;a && c < a.length;c++) { - if ("Output" === a[c].type) { - return this.params[c]; - } + b._updateMagnet = function() { + if (this._skeleton.magnets) { + var a = this._skeleton.magnets(this); + a.next && this._nextGroup.attr("transform", "translate(" + a.next.x + "," + a.next.y + ")"); + this.magnet = a; + this.block.getThread().changeEvent.notify(); } - return null; }; - a.getTerminateOutputBlock = function() { - for (var a = this;;) { - var c = a.getOutputBlock(); - if (!c) { - return a; + b._updateBG = function() { + if (this._board.dragBlock && this._board.dragBlock.dragInstance) { + var a = this.svgGroup; + if (this.magnet.next) { + if (a = this.magneting) { + var b = this._board.dragBlock.getShadow(), d = this.getAbsoluteCoordinate(), e; + if ("previous" === a) { + e = this.magnet.next, e = "translate(" + (d.x + e.x) + "," + (d.y + e.y) + ")"; + } else { + if ("next" === a) { + e = this.magnet.previous; + var f = this._board.dragBlock.getBelowHeight(); + e = "translate(" + (d.x + e.x) + "," + (d.y + e.y - f) + ")"; + } + } + $(b).attr({transform:e, display:"block"}); + this._clonedShadow = b; + this.background && (this.background.remove(), this.nextBackground.remove(), delete this.background, delete this.nextBackground); + "previous" === a && (a = this._board.dragBlock.getBelowHeight() + this.offsetY, this.originalHeight = this.offsetY, this.set({offsetY:a})); + } else { + this._clonedShadow && (this._clonedShadow.attr({display:"none"}), delete this._clonedShadow), a = this.originalHeight, void 0 !== a && (this.background && (this.background.remove(), this.nextBackground.remove(), delete this.background, delete this.nextBackground), this.set({offsetY:a}), delete this.originalHeight); + } + (a = this.block.thread.changeEvent) && a.notify(); + } else { + this.magneting ? (a.attr({filter:"url(#entryBlockHighlightFilter_" + this.getBoard().suffix + ")"}), a.addClass("outputHighlight")) : (a.removeClass("outputHighlight"), a.removeAttr("filter")); } - a = c; } }; - a.getBlockType = function() { - if (!this.view) { - return null; - } - var a = Entry.skeleton[this._schema.skeleton].magnets(this.view); - return a.next || a.previous ? "basic" : a.boolean || a.string ? "field" : a.output ? "output" : null; + b.addDragging = function() { + this.svgGroup.addClass("dragging"); }; - a.indexOfStatements = function(a) { - return this.statements.indexOf(a); + b.removeDragging = function() { + this.svgGroup.removeClass("dragging"); }; - a.pointer = function(a) { - a || (a = []); - return this.thread.pointer(a, this); + b.addSelected = function() { + this.svgGroup.addClass("selected"); }; - a.targetPointer = function() { - var a = this.thread.pointer([], this); - 4 === a.length && 0 === a[3] && a.pop(); - return a; + b.removeSelected = function() { + this.svgGroup.removeClass("selected"); }; - a.getBlockList = function(a) { - var c = []; - if (!this._schema) { - return []; - } - if (a && this._schema.isPrimitive) { - return c; - } - c.push(this); - for (var d = this.params, e = 0;e < d.length;e++) { - var f = d[e]; - f && f.constructor == Entry.Block && (c = c.concat(f.getBlockList(a))); - } - if (d = this.statements) { - for (e = 0;e < d.length;e++) { - c = c.concat(d[e].getBlockList(a)); - } - } - return c; + b.getSkeleton = function() { + return this._skeleton; }; - a.stringify = function() { - return JSON.stringify(this.toJSON()); + b.getContentPos = function() { + return this._skeleton.contentPos(this); }; -})(Entry.Block.prototype); -Entry.BlockMenu = function(a, b, c, d) { - Entry.Model(this, !1); - this._align = b || "CENTER"; - this._scroll = void 0 !== d ? d : !1; - this._bannedClass = []; - this._categories = []; - this.suffix = "blockMenu"; - a = "string" === typeof a ? $("#" + a) : $(a); - if ("DIV" !== a.prop("tagName")) { - return console.error("Dom is not div element"); - } - this.view = a; - this.visible = !0; - this._svgId = "blockMenu" + (new Date).getTime(); - this._clearCategory(); - this._categoryData = c; - this._generateView(c); - this._splitters = []; - this.setWidth(); - this.svg = Entry.SVG(this._svgId); - Entry.Utils.addFilters(this.svg, this.suffix); - b = Entry.Utils.addBlockPattern(this.svg, this.suffix); - this.patternRect = b.rect; - this.pattern = b.pattern; - this.svgGroup = this.svg.elem("g"); - this.svgThreadGroup = this.svgGroup.elem("g"); - this.svgThreadGroup.board = this; - this.svgBlockGroup = this.svgGroup.elem("g"); - this.svgBlockGroup.board = this; - this.changeEvent = new Entry.Event(this); - c && this._generateCategoryCodes(c); - this.observe(this, "_handleDragBlock", ["dragBlock"]); - this._scroll && (this._scroller = new Entry.BlockMenuScroller(this), this._addControl(a)); - Entry.documentMousedown && Entry.documentMousedown.attach(this, this.setSelectedBlock); - this._categoryCodes && Entry.keyPressed && Entry.keyPressed.attach(this, this._captureKeyEvent); - Entry.windowResized && (a = _.debounce(this.updateOffset, 200), Entry.windowResized.attach(this, a)); -}; -(function(a) { - a.schema = {code:null, dragBlock:null, closeBlock:null, selectedBlockView:null}; - a._generateView = function(a) { - var c = this.view, d = this; - a && (this._categoryCol = Entry.Dom("ul", {class:"entryCategoryListWorkspace", parent:c}), this._generateCategoryView(a)); - this.blockMenuContainer = Entry.Dom("div", {"class":"blockMenuContainer", parent:c}); - this.svgDom = Entry.Dom($(''), {parent:this.blockMenuContainer}); - this.svgDom.mouseenter(function(a) { - d._scroller && d._scroller.setOpacity(1); - a = d.workspace.selectedBlockView; - !Entry.playground || Entry.playground.resizing || a && a.dragMode === Entry.DRAG_MODE_DRAG || (Entry.playground.focusBlockMenu = !0, a = d.svgGroup.getBBox(), a = a.width + a.x + 64, a > Entry.interfaceState.menuWidth && (this.widthBackup = Entry.interfaceState.menuWidth - 64, $(this).stop().animate({width:a - 62}, 200))); - }); - this.svgDom.mouseleave(function(a) { - Entry.playground && !Entry.playground.resizing && (d._scroller && d._scroller.setOpacity(0), (a = this.widthBackup) && $(this).stop().animate({width:a}, 200), delete this.widthBackup, delete Entry.playground.focusBlockMenu); - }); - $(window).scroll(function() { - d.updateOffset(); - }); + b.renderText = function() { + this._startContentRender(Entry.Workspace.MODE_VIMBOARD); }; - a.changeCode = function(a) { - if (!(a instanceof Entry.Code)) { - return console.error("You must inject code instance"); - } - this.codeListener && this.code.changeEvent.detach(this.codeListener); - var c = this; - this.set({code:a}); - this.codeListener = this.code.changeEvent.attach(this, function() { - c.changeEvent.notify(); - }); - a.createView(this); - this.align(); + b.renderBlock = function() { + this._startContentRender(Entry.Workspace.MODE_BOARD); }; - a.bindCodeView = function(a) { - this.svgBlockGroup.remove(); - this.svgThreadGroup.remove(); - this.svgBlockGroup = a.svgBlockGroup; - this.svgThreadGroup = a.svgThreadGroup; - this.svgGroup.appendChild(this.svgThreadGroup); - this.svgGroup.appendChild(this.svgBlockGroup); - this._scroller && this.svgGroup.appendChild(this._scroller.svgGroup); + b._updateOpacity = function() { + this.svgGroup.attr({opacity:!1 === this.visible ? 0 : 1}); + this.visible && this._setPosition(); }; - a.align = function(a) { - var c = this.code; - if (c) { - this._clearSplitters(); - c.view && !a && c.view.reDraw(); - a = c.getThreads(); - for (var c = 10, d = "LEFT" == this._align ? 10 : this.svgDom.width() / 2, e, f = 0, g = a.length;f < g;f++) { - var h = a[f].getFirstBlock(), k = h.view, h = Entry.block[h.type]; - this.checkBanClass(h) ? k.set({display:!1}) : (k.set({display:!0}), h = h.class, e && e !== h && (this._createSplitter(c), c += 15), e = h, h = d - k.offsetX, "CENTER" == this._align && (h -= k.width / 2), c -= k.offsetY, k._moveTo(h, c, !1), c += k.height + 15); - } - this.updateSplitters(); - this.changeEvent.notify(); - } + b._updateShadow = function() { + this.shadow && Entry.Utils.colorDarken(this._schema.color, .7); }; - a.cloneToGlobal = function(a) { - if (!this._boardBlockView && null !== this.dragBlock) { - var c = this.workspace, d = c.getMode(), e = this.dragBlock, f = this._svgWidth, g = c.selectedBoard; - if (!g || d != Entry.Workspace.MODE_BOARD && d != Entry.Workspace.MODE_OVERLAYBOARD) { - Entry.GlobalSvg.setView(e, c.getMode()) && Entry.GlobalSvg.addControl(a); - } else { - if (g.code && (c = e.block, d = c.getThread(), c && d)) { - c = d.toJSON(!0); - this._boardBlockView = Entry.do("addThread", c).value.getFirstBlock().view; - var g = this.offset().top - g.offset().top, h, k; - if (c = this.dragBlock.mouseDownCoordinate) { - h = a.pageX - c.x, k = a.pageY - c.y; - } - this._boardBlockView._moveTo(e.x - f + (h || 0), e.y + g + (k || 0), !1); - this._boardBlockView.onMouseDown.call(this._boardBlockView, a); - this._boardBlockView.dragInstance.set({isNew:!0}); - } - } - } + b._setMovable = function() { + this.movable = null !== this.block.isMovable() ? this.block.isMovable() : void 0 !== this._skeleton.movable ? this._skeleton.movable : !0; }; - a.terminateDrag = function() { - if (this._boardBlockView) { - var a = this._boardBlockView; - if (a) { - this.workspace.getBoard(); - this._boardBlockView = null; - var c = Entry.GlobalSvg.left, d = Entry.GlobalSvg.width / 2, a = a.getBoard().offset().left; - return c < a - d; + b._setReadOnly = function() { + this.readOnly = null !== this.block.isReadOnly() ? this.block.isReadOnly() : void 0 !== this._skeleton.readOnly ? this._skeleton.readOnly : !1; + }; + b._setCopyable = function() { + this.copyable = null !== this.block.isCopyable() ? this.block.isCopyable() : void 0 !== this._skeleton.copyable ? this._skeleton.copyable : !0; + }; + b.bumpAway = function(a, b) { + var d = this; + a = a || 15; + b ? window.setTimeout(function() { + d._moveBy(a, a, !1); + }, b) : d._moveBy(a, a, !1); + }; + b.bindPrev = function(a) { + if (a) { + if (this._toLocalCoordinate(a.view._nextGroup), (a = a.getNextBlock()) && a !== this.block) { + var b = this.block.getLastBlock(); + b.view.magnet.next ? a.view._toLocalCoordinate(b.view._nextGroup) : (a.view._toGlobalCoordinate(), a.separate(), a.view.bumpAway(null, 100)); + } + } else { + if (a = this.block.getPrevBlock()) { + this._toLocalCoordinate(a.view._nextGroup), (a = this.block.getNextBlock()) && a.view && a.view._toLocalCoordinate(this._nextGroup); } } }; - a.getCode = function(a) { - return this._code; + b.getAbsoluteCoordinate = function(a) { + a = void 0 !== a ? a : this.dragMode; + if (a === Entry.DRAG_MODE_DRAG) { + return {x:this.x, y:this.y}; + } + a = this.block.getThread().view.requestAbsoluteCoordinate(this); + a.x += this.x; + a.y += this.y; + return a; }; - a.setSelectedBlock = function(a) { - var c = this.selectedBlockView; - c && c.removeSelected(); - a instanceof Entry.BlockView ? a.addSelected() : a = null; - this.set({selectedBlockView:a}); + b.getBelowHeight = function() { + return this.block.getThread().view.requestPartHeight(this); }; - a.hide = function() { - this.view.addClass("entryRemove"); + b._updateDisplay = function() { + this.svgGroup.attr({display:!1 === this.display ? "none" : "block"}); + this.display && this._setPosition(); }; - a.show = function() { - this.view.removeClass("entryRemove"); + b._updateColor = function() { + var a = this._schema.color; + this.block.deletable === Entry.Block.DELETABLE_FALSE_LIGHTEN && (a = Entry.Utils.colorLighten(a)); + this._fillColor = a; + this._path.attr({fill:a}); + this._updateContents(); }; - a.renderText = function() { - for (var a = this.code.getThreads(), c = 0;c < a.length;c++) { - a[c].view.renderText(); + b._updateContents = function() { + for (var a = 0;a < this._contents.length;a++) { + this._contents[a].renderStart(); } + this.alignContent(!1); }; - a.renderBlock = function() { - for (var a = this.code.getThreads(), c = 0;c < a.length;c++) { - a[c].view.renderBlock(); + b._destroyObservers = function() { + for (var a = this._observers;a.length;) { + a.pop().destroy(); } }; - a._createSplitter = function(a) { - a = this.svgBlockGroup.elem("line", {x1:20, y1:a, x2:this._svgWidth - 20, y2:a, stroke:"#b5b5b5"}); - this._splitters.push(a); - }; - a.updateSplitters = function(a) { - a = void 0 === a ? 0 : a; - var c = this._svgWidth - 20, d; - this._splitters.forEach(function(e) { - d = parseFloat(e.getAttribute("y1")) + a; - e.attr({x2:c, y1:d, y2:d}); - }); - }; - a._clearSplitters = function() { - for (var a = this._splitters, c = a.length - 1;0 <= c;c--) { - a[c].remove(), a.pop(); + b._changeFill = function(a) { + var b = this.getBoard(); + if (b.patternRect && !b.dragBlock) { + var d = this._fillColor, e = this._path, b = this.getBoard(); + a ? (b.setPatternRectFill(d), d = "url(#blockHoverPattern_" + this.getBoard().suffix + ")") : b.disablePattern(); + e.attr({fill:d}); } }; - a.setWidth = function() { - this._svgWidth = this.blockMenuContainer.width(); - this.updateSplitters(); + b.addActivated = function() { + this.svgGroup.addClass("activated"); }; - a.setMenu = function() { - var a = this._categoryCodes, c = this._categoryElems, d; - for (d in a) { - for (var e = a[d], e = e instanceof Entry.Code ? e.getThreads() : e, f = e.length, g = 0;g < e.length;g++) { - var h = e[g], h = h instanceof Entry.Thread ? h.getFirstBlock().type : h[0].type; - this.checkBanClass(Entry.block[h]) && f--; + b.removeActivated = function() { + this.svgGroup.removeClass("activated"); + }; + b.reDraw = function() { + if (this.visible) { + var a = this.block; + requestAnimationFrame(this._updateContents.bind(this)); + var b = a.params; + if (b) { + for (var d = 0;d < b.length;d++) { + var e = b[d]; + e instanceof Entry.Block && e.view.reDraw(); + } + } + if (a = a.statements) { + for (d = 0;d < a.length;d++) { + a[d].view.reDraw(); + } } - 0 === f ? c[d].addClass("entryRemove") : c[d].removeClass("entryRemove"); } }; - a.getCategoryCodes = function(a) { - a = this._convertSelector(a); - var c = this._categoryCodes[a]; - c || (this._generateCategoryElement(a), c = []); - c instanceof Entry.Code || (c = this._categoryCodes[a] = new Entry.Code(c)); - return c; + b.getParam = function(a) { + return this._paramMap[a]; }; - a._convertSelector = function(a) { - if (isNaN(a)) { - return a; - } - a = Number(a); - for (var c = this._categories, d = this._categoryElems, e = 0;e < c.length;e++) { - var f = c[e]; - if (!d[f].hasClass("entryRemove") && 0 === a--) { - return f; - } +})(Entry.BlockView.prototype); +Entry.Code = function(b, a) { + Entry.Model(this, !1); + a && (this.object = a); + this._data = new Entry.Collection; + this._eventMap = {}; + this._blockMap = {}; + this.executors = []; + this.executeEndEvent = new Entry.Event(this); + this.changeEvent = new Entry.Event(this); + this.changeEvent.attach(this, this._handleChange); + this._maxZIndex = 0; + this.load(b); +}; +Entry.STATEMENT = 0; +Entry.PARAM = -1; +(function(b) { + b.schema = {view:null, board:null}; + b.load = function(a) { + a instanceof Array || (a = JSON.parse(a)); + this.clear(); + for (var b = 0;b < a.length;b++) { + this._data.push(new Entry.Thread(a[b], this)); } + return this; }; - a.selectMenu = function(a, c) { - if (a = this._convertSelector(a)) { - "variable" == a && Entry.playground.checkVariables(); - "arduino" == a && this._generateHwCode(); - var d = this._categoryElems[a], e = this._selectedCategoryView, f = !1, g = this.workspace.board, h = g.view; - e && e.removeClass("entrySelectedCategory"); - d != e || c ? e || (this.visible || (f = !0, h.addClass("foldOut"), Entry.playground.showTabs()), h.removeClass("folding"), this.visible = !0) : (h.addClass("folding"), this._selectedCategoryView = null, d.removeClass("entrySelectedCategory"), Entry.playground.hideTabs(), f = !0, this.visible = !1); - f && Entry.bindAnimationCallbackOnce(h, function() { - g.scroller.resizeScrollBar.call(g.scroller); - h.removeClass("foldOut"); - Entry.windowResized.notify(); - }); - this.visible && (c = this._categoryCodes[a], this._selectedCategoryView = d, d.addClass("entrySelectedCategory"), c.constructor !== Entry.Code && (c = this._categoryCodes[a] = new Entry.Code(c)), this.changeCode(c)); - this.lastSelector = a; + b.clear = function() { + for (var a = this._data.length - 1;0 <= a;a--) { + this._data[a].destroy(!1); } + this.clearExecutors(); + this._eventMap = {}; }; - a._generateCategoryCodes = function(a) { - this._categoryCodes = {}; - for (var c = 0;c < a.length;c++) { - var d = a[c], e = []; - d.blocks.forEach(function(a) { - var b = Entry.block[a]; - if (b && b.def) { - if (b.defs) { - for (a = 0;a < b.defs.length;a++) { - e.push([b.defs[a]]); - } - } else { - e.push([b.def]); - } - } else { - e.push([{type:a}]); - } - }); - d = d.category; - this._categories.push(d); - this._categoryCodes[d] = e; - } + b.createView = function(a) { + null === this.view ? this.set({view:new Entry.CodeView(this, a), board:a}) : (this.set({board:a}), a.bindCodeView(this.view)); }; - a.banClass = function(a, c) { - 0 > this._bannedClass.indexOf(a) && this._bannedClass.push(a); - this.align(c); + b.registerEvent = function(a, b) { + this._eventMap[b] || (this._eventMap[b] = []); + this._eventMap[b].push(a); }; - a.unbanClass = function(a, c) { - a = this._bannedClass.indexOf(a); - -1 < a && this._bannedClass.splice(a, 1); - this.align(c); + b.unregisterEvent = function(a, b) { + var d = this._eventMap[b]; + if (d && 0 !== d.length) { + var e = d.indexOf(a); + 0 > e || d.splice(e, 1); + } }; - a.checkBanClass = function(a) { - if (a) { - a = a.isNotFor; - for (var c in this._bannedClass) { - if (a && -1 < a.indexOf(this._bannedClass[c])) { - return !0; + b.raiseEvent = function(a, b, d) { + a = this._eventMap[a]; + var e = []; + if (void 0 !== a) { + for (var f = 0;f < a.length;f++) { + var g = a[f]; + if (void 0 === d || -1 < g.params.indexOf(d)) { + g = new Entry.Executor(a[f], b), this.executors.push(g), e.push(g); } } - return !1; + return e; } }; - a._addControl = function(a) { - var c = this; - a.on("wheel", function() { - c._mouseWheel.apply(c, arguments); - }); - }; - a._mouseWheel = function(a) { - a = a.originalEvent; - a.preventDefault(); - var c = Entry.disposeEvent; - c && c.notify(a); - this._scroller.scroll(-a.wheelDeltaY || a.deltaY / 3); - }; - a.dominate = function(a) { - this.svgBlockGroup.appendChild(a.view.svgGroup); - }; - a.reDraw = function() { - this.selectMenu(this.lastSelector, !0); + b.getEventMap = function(a) { + return this._eventMap[a]; }; - a._handleDragBlock = function() { - this._boardBlockView = null; - this._scroller && this._scroller.setOpacity(0); + b.map = function(a) { + this._data.map(a); }; - a._captureKeyEvent = function(a) { - var c = a.keyCode, d = Entry.type; - a.ctrlKey && "workspace" == d && 48 < c && 58 > c && (a.preventDefault(), this.selectMenu(c - 49)); + b.tick = function() { + for (var a = this.executors, b = 0;b < a.length;b++) { + var d = a[b]; + d.isEnd() ? (a.splice(b--, 1), 0 === a.length && this.executeEndEvent.notify()) : d.execute(); + } }; - a.setPatternRectFill = function(a) { - this.patternRect.attr({fill:a}); - this.pattern.attr({style:""}); + b.removeExecutor = function(a) { + a = this.executors.indexOf(a); + -1 < a && this.executors.splice(a, 1); }; - a.disablePattern = function() { - this.pattern.attr({style:"display: none"}); + b.clearExecutors = function() { + this.executors.forEach(function(a) { + a.end(); + }); + this.executors = []; }; - a._clearCategory = function() { - this._selectedCategoryView = null; - this._categories = []; - var a = this._categoryElems, c; - for (c in a) { - a[c].remove(); - } - this._categoryElems = {}; - a = this._categoryCodes; - for (c in a) { - var d = a[c]; - d.constructor == Entry.Code && d.clear(); + b.clearExecutorsByEntity = function(a) { + for (var b = this.executors, d = 0;d < b.length;d++) { + var e = b[d]; + e.entity === a && e.end(); } - this._categoryCodes = null; }; - a.setCategoryData = function(a) { - this._clearCategory(); - this._categoryData = a; - this._generateCategoryView(a); - this._generateCategoryCodes(a); + b.addExecutor = function(a) { + this.executors.push(a); }; - a._generateCategoryView = function(a) { - if (a) { - for (var c = 0;c < a.length;c++) { - this._generateCategoryElement(a[c].category); - } + b.createThread = function(a, b) { + if (!(a instanceof Array)) { + return console.error("blocks must be array"); } + var d = new Entry.Thread(a, this); + void 0 === b ? this._data.push(d) : this._data.insert(d, b); + return d; }; - a._generateCategoryElement = function(a) { - var c = this; - (function(a, b) { - a.text(Lang.Blocks[b.toUpperCase()]); - c._categoryElems[b] = a; - a.bindOnClick(function(a) { - c.selectMenu(b); - }); - })(Entry.Dom("li", {id:"entryCategory" + a, class:"entryCategoryElementWorkspace", parent:this._categoryCol}), a); + b.cloneThread = function(a, b) { + var d = a.clone(this, b); + this._data.push(d); + return d; }; - a.updateOffset = function() { - this._offset = this.svgDom.offset(); + b.destroyThread = function(a, b) { + var d = this._data, e = d.indexOf(a); + 0 > e || d.splice(e, 1); }; - a.offset = function() { - (!this._offset || 0 === this._offset.top && 0 === this._offset.left) && this.updateOffset(); - return this._offset; + b.doDestroyThread = function(a, b) { + var d = this._data, e = d.indexOf(a); + 0 > e || d.splice(e, 1); }; - a._generateHwCode = function() { - var a = this._categoryCodes.arduino; - a instanceof Entry.Code && a.clear(); - for (var c = this._categoryData, d, a = c.length - 1;0 <= a;a--) { - if ("arduino" === c[a].category) { - d = c[a].blocks; - break; - } - } - c = []; - for (a = 0;a < d.length;a++) { - var e = d[a], f = Entry.block[e]; - if (!this.checkBanClass(f)) { - if (f && f.def) { - if (f.defs) { - for (a = 0;a < f.defs.length;a++) { - c.push([f.defs[a]]); - } - } else { - c.push([f.def]); - } - } else { - c.push([{type:e}]); - } - } - } - this._categoryCodes.arduino = c; + b.getThreads = function() { + return this._data.map(function(a) { + return a; + }); }; -})(Entry.BlockMenu.prototype); -Entry.BlockMenuScroller = function(a) { - var b = this; - this.board = a; - this.board.changeEvent.attach(this, this._reset); - this.svgGroup = null; - this.vRatio = this.vY = this.vWidth = this.hX = 0; - this._visible = !0; - this._opacity = -1; - this.mouseHandler = function() { - b.onMouseDown.apply(b, arguments); + b.toJSON = function() { + for (var a = this.getThreads(), b = [], d = 0, e = a.length;d < e;d++) { + b.push(a[d].toJSON()); + } + return b; }; - this.createScrollBar(); - this.setOpacity(0); - this._addControl(); - Entry.windowResized && Entry.windowResized.attach(this, this.resizeScrollBar); -}; -Entry.BlockMenuScroller.RADIUS = 7; -(function(a) { - a.createScrollBar = function() { - this.svgGroup = this.board.svgGroup.elem("g", {class:"boardScrollbar"}); - this.vScrollbar = this.svgGroup.elem("rect", {rx:4, ry:4}); - this.resizeScrollBar(); + b.countBlock = function() { + for (var a = this.getThreads(), b = 0, d = 0;d < a.length;d++) { + b += a[d].countBlock(); + } + return b; }; - a.resizeScrollBar = function() { - this._updateRatio(); - if (this._visible && 0 !== this.vRatio) { - var a = this.board.blockMenuContainer; - this.vScrollbar.attr({width:9, height:a.height() / this.vRatio, x:a.width() - 9}); + b.moveBy = function(a, b) { + for (var d = this.getThreads(), e = 0, f = d.length;e < f;e++) { + var g = d[e].getFirstBlock(); + g && g.view._moveBy(a, b, !1); } + d = this.board; + d instanceof Entry.BlockMenu && d.updateSplitters(b); }; - a.updateScrollBar = function(a) { - this.vY += a; - this.vScrollbar.attr({y:this.vY}); + b.stringify = function() { + return JSON.stringify(this.toJSON()); }; - a.scroll = function(a) { - this.isVisible() && (a = this._adjustValue(a) - this.vY, 0 !== a && (this.board.code.moveBy(0, -a * this.vRatio), this.updateScrollBar(a))); + b.dominate = function(a) { + a.view.setZIndex(this._maxZIndex++); }; - a._adjustValue = function(a) { - var c = this.board.svgDom.height(), c = c - c / this.vRatio; - a = this.vY + a; - a = Math.max(0, a); - return a = Math.min(c, a); + b.indexOf = function(a) { + return this._data.indexOf(a); }; - a.setVisible = function(a) { - a != this.isVisible() && (this._visible = a, this.svgGroup.attr({display:!0 === a ? "block" : "none"})); + b._handleChange = function() { + Entry.creationChangedEvent && Entry.creationChangedEvent.notify(); }; - a.setOpacity = function(a) { - this._opacity != a && (this.vScrollbar.attr({opacity:a}), this._opacity = a); + b.hasBlockType = function(a) { + for (var b = this.getThreads(), d = 0;d < b.length;d++) { + if (b[d].hasBlockType(a)) { + return !0; + } + } + return !1; }; - a.isVisible = function() { - return this._visible; + b.findById = function(a) { + return this._blockMap[a]; }; - a._updateRatio = function() { - var a = this.board, c = a.svgBlockGroup.getBoundingClientRect(), d = a.blockMenuContainer.height(), a = a.offset(); - this.vRatio = c = (c.height + (c.top - a.top) + 10) / d; - 1 >= c ? this.setVisible(!1) : this.setVisible(!0); + b.registerBlock = function(a) { + this._blockMap[a.id] = a; }; - a._reset = function() { - this.vY = 0; - this.vScrollbar.attr({y:this.vY}); - this.resizeScrollBar(); + b.unregisterBlock = function(a) { + delete this._blockMap[a.id]; }; - a.onMouseDown = function(a) { - function c(a) { - a.stopPropagation && a.stopPropagation(); - a.preventDefault && a.preventDefault(); - a = a.originalEvent && a.originalEvent.touches ? a.originalEvent.touches[0] : a; - var b = e.dragInstance; - e.scroll(a.pageY - b.offsetY); - b.set({offsetY:a.pageY}); - } - function d(a) { - $(document).unbind(".scroll"); - delete e.dragInstance; + b.getByPointer = function(a) { + a = a.concat(); + a.shift(); + a.shift(); + for (var b = this._data[a.shift()].getBlock(a.shift());a.length;) { + b instanceof Entry.Block || (b = b.getValueBlock()); + var d = a.shift(), e = a.shift(); + -1 < d ? b = b.statements[d].getBlock(e) : -1 === d && (b = b.view.getParam(e)); } - var e = this; - a.stopPropagation && a.stopPropagation(); - a.preventDefault && a.preventDefault(); - if (0 === a.button || a.originalEvent && a.originalEvent.touches) { - Entry.documentMousedown && Entry.documentMousedown.notify(a); - var f; - f = a.originalEvent && a.originalEvent.touches ? a.originalEvent.touches[0] : a; - var g = $(document); - g.bind("mousemove.scroll", c); - g.bind("mouseup.scroll", d); - g.bind("touchmove.scroll", c); - g.bind("touchend.scroll", d); - e.dragInstance = new Entry.DragInstance({startY:f.pageY, offsetY:f.pageY}); + return b; + }; + b.getTargetByPointer = function(a) { + a = a.concat(); + a.shift(); + a.shift(); + var b = this._data[a.shift()], d; + if (1 === a.length) { + d = b.getBlock(a.shift() - 1); + } else { + for (d = b.getBlock(a.shift());a.length;) { + d instanceof Entry.Block || (d = d.getValueBlock()); + var e = a.shift(), b = a.shift(); + -1 < e ? (d = d.statements[e], d = a.length ? d.getBlock(b) : 0 === b ? d.view.getParent() : d.getBlock(b - 1)) : -1 === e && (d = d.view.getParam(b)); + } } - a.stopPropagation(); + return d; }; - a._addControl = function() { - $(this.vScrollbar).bind("mousedown touchstart", this.mouseHandler); + b.getBlockList = function(a) { + for (var b = this.getThreads(), d = [], e = 0;e < b.length;e++) { + d = d.concat(b[e].getBlockList(a)); + } + return d; }; -})(Entry.BlockMenuScroller.prototype); -Entry.BlockView = function(a, b, c) { +})(Entry.Code.prototype); +Entry.CodeView = function(b, a) { Entry.Model(this, !1); - this.block = a; - this._lazyUpdatePos = _.debounce(a._updatePos.bind(a), 200); - this._board = b; - this._observers = []; - this.set(a); - this.svgGroup = b.svgBlockGroup.elem("g"); - this._schema = Entry.block[a.type]; - this._schema.changeEvent && (this._schemaChangeEvent = this._schema.changeEvent.attach(this, this._updateSchema)); - var d = this._skeleton = Entry.skeleton[this._schema.skeleton]; - this._contents = []; - this._statements = []; - this.magnet = {}; - this._paramMap = {}; - d.magnets && d.magnets(this).next && (this.svgGroup.nextMagnet = this.block, this._nextGroup = this.svgGroup.elem("g"), this._observers.push(this.observe(this, "_updateMagnet", ["contentHeight"]))); - this.isInBlockMenu = this.getBoard() instanceof Entry.BlockMenu; - var e = this; - this.mouseHandler = function() { - var a = e.block.events; - a && a.mousedown && a.mousedown.forEach(function(a) { - a(e); - }); - e.onMouseDown.apply(e, arguments); - }; - this._startRender(a, c); - this._observers.push(this.block.observe(this, "_setMovable", ["movable"])); - this._observers.push(this.block.observe(this, "_setReadOnly", ["movable"])); - this._observers.push(this.block.observe(this, "_setCopyable", ["copyable"])); - this._observers.push(this.block.observe(this, "_updateColor", ["deletable"], !1)); - this._observers.push(this.observe(this, "_updateBG", ["magneting"], !1)); - this._observers.push(this.observe(this, "_updateOpacity", ["visible"], !1)); - this._observers.push(this.observe(this, "_updateDisplay", ["display"], !1)); - this._observers.push(this.observe(this, "_updateShadow", ["shadow"])); - this._observers.push(this.observe(this, "_updateMagnet", ["offsetY"])); - this._observers.push(b.code.observe(this, "_setBoard", ["board"], !1)); - this.dragMode = Entry.DRAG_MODE_NONE; - Entry.Utils.disableContextmenu(this.svgGroup.node); - (b = a.events.viewAdd) && !this.isInBlockMenu && b.forEach(function(b) { - Entry.Utils.isFunction(b) && b(a); + this.code = b; + this.set({board:a}); + this.svgThreadGroup = a.svgGroup.elem("g"); + this.svgThreadGroup.attr({class:"svgThreadGroup"}); + this.svgThreadGroup.board = a; + this.svgBlockGroup = a.svgGroup.elem("g"); + this.svgBlockGroup.attr({class:"svgBlockGroup"}); + this.svgBlockGroup.board = a; + a.bindCodeView(this); + this.code.map(function(b) { + b.createView(a); }); + b.observe(this, "_setBoard", ["board"]); }; -Entry.BlockView.PARAM_SPACE = 5; -Entry.BlockView.DRAG_RADIUS = 5; -(function(a) { - a.schema = {id:0, type:Entry.STATIC.BLOCK_RENDER_MODEL, x:0, y:0, offsetX:0, offsetY:0, width:0, height:0, contentWidth:0, contentHeight:0, magneting:!1, visible:!0, animating:!1, shadow:!0, display:!0}; - a._startRender = function(a, c) { - var d = this; - a = this._skeleton; - this.svgGroup.attr({class:"block"}); - var e = a.classes; - e && 0 !== e.length && e.forEach(function(a) { - d.svgGroup.addClass(a); +(function(b) { + b.schema = {board:null, scrollX:0, scrollY:0}; + b._setBoard = function() { + this.set({board:this.code.board}); + }; + b.reDraw = function() { + this.code.map(function(a) { + a.view.reDraw(); }); - e = a.path(this); - this.pathGroup = this.svgGroup.elem("g"); - this._updateMagnet(); - this._path = this.pathGroup.elem("path"); - this.getBoard().patternRect && ($(this._path).mouseenter(function(a) { - d._mouseEnable && d._changeFill(!0); - }), $(this._path).mouseleave(function(a) { - d._mouseEnable && d._changeFill(!1); - })); - var f = this._schema.color; - this.block.deletable === Entry.Block.DELETABLE_FALSE_LIGHTEN && (f = Entry.Utils.colorLighten(f)); - this._fillColor = f; - e = {d:e, fill:f, class:"blockPath"}; - if (this.magnet.next || this._skeleton.nextShadow) { - f = this.getBoard().suffix, this.pathGroup.attr({filter:"url(#entryBlockShadowFilter_" + f + ")"}); - } else { - if (this.magnet.string || this.magnet.boolean) { - e.stroke = a.outerLine; - } - } - a.outerLine && (e["stroke-width"] = "0.6"); - this._path.attr(e); - this._moveTo(this.x, this.y, !1); - this._startContentRender(c); - !0 !== this._board.disableMouseEvent && this._addControl(); - this.bindPrev(); }; - a._startContentRender = function(a) { - a = void 0 === a ? Entry.Workspace.MODE_BOARD : a; - this.contentSvgGroup && this.contentSvgGroup.remove(); - var c = this._schema; - c.statements && c.statements.length && this.statementSvgGroup && this.statementSvgGroup.remove(); - this._contents = []; - this.contentSvgGroup = this.svgGroup.elem("g"); - c.statements && c.statements.length && (this.statementSvgGroup = this.svgGroup.elem("g")); - switch(a) { - case Entry.Workspace.MODE_BOARD: - ; - case Entry.Workspace.MODE_OVERLAYBOARD: - for (var d = /(%\d)/mi, e = (c.template ? c.template : Lang.template[this.block.type]).split(d), f = c.params, g = 0;g < e.length;g++) { - var h = e[g].trim(); - if (0 !== h.length) { - if (d.test(h)) { - var k = Number(h.split("%")[1]) - 1, h = f[k], h = new Entry["Field" + h.type](h, this, k, a, g); - this._contents.push(h); - this._paramMap[k] = h; +})(Entry.CodeView.prototype); +Entry.ConnectionRipple = {}; +(function(b) { + b.createDom = function(a) { + this.svgDom || (this._ripple = a.getBoard().svgGroup.elem("circle", {cx:0, cy:0, r:0, stroke:"#888", "stroke-width":10})); + }; + b.setView = function(a) { + this._ripple || this.createDom(a); + var b = this._ripple, d = a.getBoard().svgGroup; + b.remove(); + a = a.getAbsoluteCoordinate(); + b.attr({cx:a.x, cy:a.y}); + d.appendChild(b); + b._startTime = new Date; + return this; + }; + b.dispose = function() { + var a = this, b = this._ripple, d = (new Date - b._startTime) / 150; + 1 < d ? b.remove() : (b.attr({r:25 * d, opacity:1 - d}), window.setTimeout(function() { + a.dispose(); + }, 10)); + }; +})(Entry.ConnectionRipple); +Entry.Executor = function(b, a) { + this.scope = new Entry.Scope(b, this); + this.entity = a; + this._callStack = []; + this.register = {}; +}; +(function(b) { + b.execute = function() { + if (!this.isEnd()) { + for (;;) { + try { + var a = this.scope.block.getSchema().func.call(this.scope, this.entity, this.scope); + } catch (b) { + Entry.Utils.stopProjectWithToast(this.scope.block, "\ub7f0\ud0c0\uc784 \uc5d0\ub7ec"); + } + if (this.isEnd()) { + break; + } + if (void 0 === a || null === a || a === Entry.STATIC.PASS) { + if (this.scope = new Entry.Scope(this.scope.block.getNextBlock(), this), null === this.scope.block) { + if (this._callStack.length) { + var c = this.scope; + this.scope = this._callStack.pop(); + if (this.scope.isLooped !== c.isLooped) { + break; + } } else { - this._contents.push(new Entry.FieldText({text:h}, this)); + break; } } - } - if ((a = c.statements) && a.length) { - for (g = 0;g < a.length;g++) { - this._statements.push(new Entry.FieldStatement(a[g], this, g)); + } else { + if (a !== Entry.STATIC.CONTINUE && (a === Entry.STATIC.BREAK || this.scope === a)) { + break; } } - break; - case Entry.Workspace.MODE_VIMBOARD: - g = this.getBoard().workspace.getCodeToText(this.block), this._contents.push(new Entry.FieldText({text:g, color:"white"}, this)); + } } - this.alignContent(!1); }; - a._updateSchema = function() { - this._startContentRender(); + b.stepInto = function(a) { + a instanceof Entry.Thread || console.error("Must step in to thread"); + a = a.getFirstBlock(); + if (!a) { + return Entry.STATIC.BREAK; + } + this._callStack.push(this.scope); + this.scope = new Entry.Scope(a, this); + return Entry.STATIC.CONTINUE; }; - a.changeType = function(a) { - this._schemaChangeEvent && this._schemaChangeEvent.destroy(); - this._schema = Entry.block[a]; - this._schema.changeEvent && (this._schemaChangeEvent = this._schema.changeEvent.attach(this, this._updateSchema)); - this._updateSchema(); + b.break = function() { + this._callStack.length && (this.scope = this._callStack.pop()); + return Entry.STATIC.PASS; }; - a.alignContent = function(a) { - !0 !== a && (a = !1); - for (var c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, k = 0;k < this._contents.length;k++) { - var l = this._contents[k]; - l instanceof Entry.FieldLineBreak ? (this._alignStatement(a, f), l.align(f), f++, d = l.box.y, c = 8) : (l.align(c, d, a), k === this._contents.length - 1 || l instanceof Entry.FieldText && 0 == l._text.length || (c += Entry.BlockView.PARAM_SPACE)); - l = l.box; - 0 !== f ? h = Math.max(1E3 * Math.round(l.height), h) : e = Math.max(l.height, e); - c += l.width; - g = Math.max(g, c); - this.set({contentWidth:g, contentHeight:e}); + b.breakLoop = function() { + this._callStack.length && (this.scope = this._callStack.pop()); + for (;this._callStack.length && "repeat" !== Entry.block[this.scope.block.type].class;) { + this.scope = this._callStack.pop(); } - this.set({contentHeight:e + h}); - this._statements.length != f && this._alignStatement(a, f); - a = this.getContentPos(); - this.contentSvgGroup.attr("transform", "translate(" + a.x + "," + a.y + ")"); - this.contentPos = a; - this._render(); - this._updateMagnet(); + return Entry.STATIC.PASS; }; - a._alignStatement = function(a, c) { - var d = this._skeleton.statementPos ? this._skeleton.statementPos(this) : [], e = this._statements[c]; - e && (c = d[c]) && e.align(c.x, c.y, a); + b.end = function() { + this.scope.block = null; }; - a._render = function() { - this._renderPath(); - this.set(this._skeleton.box(this)); + b.isEnd = function() { + return null === this.scope.block; }; - a._renderPath = function() { - var a = this._skeleton.path(this); - this._path.attr({d:a}); - this.set({animating:!1}); +})(Entry.Executor.prototype); +Entry.Scope = function(b, a) { + this.type = (this.block = b) ? b.type : null; + this.executor = a; + this.entity = a.entity; +}; +(function(b) { + b.callReturn = function() { }; - a._setPosition = function(a) { - this.svgGroup.attr("transform", "translate(" + this.x + "," + this.y + ")"); + b.getParam = function(a) { + a = this.block.params[a]; + var b = new Entry.Scope(a, this.executor); + return Entry.block[a.type].func.call(b, this.entity, b); }; - a._toLocalCoordinate = function(a) { - this._moveTo(0, 0, !1); - a.appendChild(this.svgGroup); + b.getParams = function() { + var a = this; + return this.block.params.map(function(b) { + if (b instanceof Entry.Block) { + var d = new Entry.Scope(b, a.executor); + return Entry.block[b.type].func.call(d, a.entity, d); + } + return b; + }); }; - a._toGlobalCoordinate = function(a) { - a = this.getAbsoluteCoordinate(a); - this._moveTo(a.x, a.y, !1); - this.getBoard().svgBlockGroup.appendChild(this.svgGroup); + b.getValue = function(a, b) { + var d = this.block.params[this._getParamIndex(a, b)], e = new Entry.Scope(d, this.executor); + return Entry.block[d.type].func.call(e, this.entity, e); }; - a._moveTo = function(a, c, d) { - this.set({x:a, y:c}); - this._lazyUpdatePos(); - this.visible && this.display && this._setPosition(d); + b.getStringValue = function(a, b) { + return String(this.getValue(a, b)); }; - a._moveBy = function(a, c, d) { - return this._moveTo(this.x + a, this.y + c, d); + b.getNumberValue = function(a, b) { + return +this.getValue(a); }; - a._addControl = function() { - var a = this; - this._mouseEnable = !0; - $(this.svgGroup).bind("mousedown.blockViewMousedown touchstart.blockViewMousedown", a.mouseHandler); - var c = a.block.events; - c && c.dblclick && $(this.svgGroup).dblclick(function() { - c.dblclick.forEach(function(c) { - c && c(a); - }); - }); + b.getBooleanValue = function(a, b) { + return +this.getValue(a, b) ? !0 : !1; }; - a.removeControl = function() { - this._mouseEnable = !1; - $(this.svgGroup).unbind(".blockViewMousedown"); + b.getField = function(a, b) { + return this.block.params[this._getParamIndex(a)]; }; - a.onMouseDown = function(b) { - function c(b) { - b.stopPropagation(); - var c = e.workspace.getMode(), d; - c === Entry.Workspace.MODE_VIMBOARD && a.vimBoardEvent(b, "dragOver"); - d = b.originalEvent && b.originalEvent.touches ? b.originalEvent.touches[0] : b; - var f = m.mouseDownCoordinate, f = Math.sqrt(Math.pow(d.pageX - f.x, 2) + Math.pow(d.pageY - f.y, 2)); - (m.dragMode == Entry.DRAG_MODE_DRAG || f > Entry.BlockView.DRAG_RADIUS) && m.movable && (m.isInBlockMenu ? e.cloneToGlobal(b) : (b = !1, m.dragMode != Entry.DRAG_MODE_DRAG && (m._toGlobalCoordinate(), m.dragMode = Entry.DRAG_MODE_DRAG, m.block.getThread().changeEvent.notify(), Entry.GlobalSvg.setView(m, c), b = !0), this.animating && this.set({animating:!1}), 0 === m.dragInstance.height && m.dragInstance.set({height:-1 + m.height}), c = m.dragInstance, m._moveBy(d.pageX - c.offsetX, d.pageY - - c.offsetY, !1), c.set({offsetX:d.pageX, offsetY:d.pageY}), Entry.GlobalSvg.position(), m.originPos || (m.originPos = {x:m.x, y:m.y}), b && e.generateCodeMagnetMap(), m._updateCloseBlock())); - } - function d(a) { - $(document).unbind(".block"); - m.terminateDrag(a); - e && e.set({dragBlock:null}); - m._changeFill(!1); - Entry.GlobalSvg.remove(); - delete this.mouseDownCoordinate; - delete m.dragInstance; - } - b.stopPropagation && b.stopPropagation(); - b.preventDefault && b.preventDefault(); - this._changeFill(!1); - var e = this.getBoard(); - Entry.documentMousedown && Entry.documentMousedown.notify(b); - if (!this.readOnly && !e.viewOnly) { - e.setSelectedBlock(this); - this.dominate(); - if (0 === b.button || b.originalEvent && b.originalEvent.touches) { - var f; - f = b.originalEvent && b.originalEvent.touches ? b.originalEvent.touches[0] : b; - this.mouseDownCoordinate = {x:f.pageX, y:f.pageY}; - var g = $(document); - g.bind("mousemove.block touchmove.block", c); - g.bind("mouseup.block touchend.block", d); - this.dragInstance = new Entry.DragInstance({startX:f.pageX, startY:f.pageY, offsetX:f.pageX, offsetY:f.pageY, height:0, mode:!0}); - e.set({dragBlock:this}); - this.addDragging(); - this.dragMode = Entry.DRAG_MODE_MOUSEDOWN; - } else { - if (Entry.Utils.isRightButton(b)) { - var h = this, k = h.block; - if (this.isInBlockMenu) { - return; - } - f = []; - var g = {text:Lang.Blocks.Duplication_option, enable:this.copyable, callback:function() { - Entry.do("cloneBlock", k); - }}, l = {text:Lang.Blocks.CONTEXT_COPY_option, enable:this.copyable, callback:function() { - h.block.copyToClipboard(); - }}, n = {text:Lang.Blocks.Delete_Blocks, enable:k.isDeletable(), callback:function() { - Entry.do("destroyBlock", h.block); - }}; - f.push(g); - f.push(l); - f.push(n); - Entry.ContextMenu.show(f); - } - } - var m = this; - e.workspace.getMode() === Entry.Workspace.MODE_VIMBOARD && b && document.getElementsByClassName("CodeMirror")[0].dispatchEvent(Entry.Utils.createMouseEvent("dragStart", event)); - } + b.getStringField = function(a, b) { + return String(this.getField(a)); + }; + b.getNumberField = function(a) { + return +this.getField(a); + }; + b.getStatement = function(a, b) { + return this.executor.stepInto(this.block.statements[this._getStatementIndex(a, b)]); + }; + b._getParamIndex = function(a) { + this._schema || (this._schema = Entry.block[this.type]); + return this._schema.paramsKeyMap[a]; + }; + b._getStatementIndex = function(a) { + this._schema || (this._schema = Entry.block[this.type]); + return this._schema.statementsKeyMap[a]; + }; + b.die = function() { + this.block = null; + return Entry.STATIC.BREAK; + }; +})(Entry.Scope.prototype); +Entry.Field = function() { +}; +(function(b) { + b.TEXT_LIMIT_LENGTH = 20; + b.destroy = function() { + this.destroyOption(); + }; + b.command = function() { + this._startValue && (this._startValue === this.getValue() || this._blockView.isInBlockMenu || Entry.do("setFieldValue", this._block, this, this.pointer(), this._startValue, this.getValue())); + delete this._startValue; + }; + b.destroyOption = function() { + this.documentDownEvent && (Entry.documentMousedown.detach(this.documentDownEvent), delete this.documentDownEvent); + this.disposeEvent && (Entry.disposeEvent.detach(this.disposeEvent), delete this.documentDownEvent); + this.optionGroup && (this.optionGroup.remove(), delete this.optionGroup); + this.command(); + }; + b._attachDisposeEvent = function(a) { + var b = this; + b.disposeEvent = Entry.disposeEvent.attach(b, a || function() { + b.destroyOption(); + }); }; - a.vimBoardEvent = function(a, c, d) { - a && (a = Entry.Utils.createMouseEvent(c, a), d && (a.block = d), document.getElementsByClassName("CodeMirror")[0].dispatchEvent(a)); + b.align = function(a, b, d) { + var e = this.svgGroup; + this._position && (this._position.x && (a = this._position.x), this._position.y && (b = this._position.y)); + var f = "translate(" + a + "," + b + ")"; + void 0 === d || d ? e.animate({transform:f}, 300, mina.easeinout) : e.attr({transform:f}); + this.box.set({x:a, y:b}); }; - a.terminateDrag = function(a) { - var c = this.getBoard(), d = this.dragMode, e = this.block, f = c.workspace.getMode(); - this.removeDragging(); - this.set({visible:!0}); - this.dragMode = Entry.DRAG_MODE_NONE; - if (f === Entry.Workspace.MODE_VIMBOARD) { - c instanceof Entry.BlockMenu ? (c.terminateDrag(), this.vimBoardEvent(a, "dragEnd", e)) : c.clear(); - } else { - if (d === Entry.DRAG_MODE_DRAG) { - var f = this.dragInstance && this.dragInstance.isNew, g = Entry.GlobalSvg, h = this.block.getPrevBlock(this.block); - a = !1; - switch(Entry.GlobalSvg.terminateDrag(this)) { - case g.DONE: - g = c.magnetedBlockView; - g instanceof Entry.BlockView && (g = g.block); - h && !g ? Entry.do("separateBlock", e) : h || g || f ? g ? ("next" === g.view.magneting ? (h = e.getLastBlock(), this.dragMode = d, c.separate(e), this.dragMode = Entry.DRAG_MODE_NONE, Entry.do("insertBlock", g, h).isPass(f), Entry.ConnectionRipple.setView(g.view).dispose()) : (Entry.do("insertBlock", e, g).isPass(f), a = !0), createjs.Sound.play("entryMagneting")) : Entry.do("moveBlock", e).isPass(f) : e.getThread().view.isGlobal() ? Entry.do("moveBlock", e) : Entry.do("separateBlock", - e); - break; - case g.RETURN: - e = this.block; - d = this.originPos; - h ? (this.set({animating:!1}), createjs.Sound.play("entryMagneting"), this.bindPrev(h), e.insert(h)) : (f = e.getThread().view.getParent(), f instanceof Entry.Board ? this._moveTo(d.x, d.y, !1) : (createjs.Sound.play("entryMagneting"), Entry.do("insertBlock", e, f))); - break; - case g.REMOVE: - createjs.Sound.play("entryDelete"), f ? this.block.destroy(!1, !0) : this.block.doDestroyBelow(!1); - } - c.setMagnetedBlock(null); - a && Entry.ConnectionRipple.setView(e.view).dispose(); - } - } - this.destroyShadow(); - delete this.originPos; - this.dominate(); + b.getAbsolutePosFromBoard = function() { + var a = this._block.view, b = a.getContentPos(), a = a.getAbsoluteCoordinate(); + return {x:a.x + this.box.x + b.x, y:a.y + this.box.y + b.y}; }; - a._updateCloseBlock = function() { - var a = this.getBoard(), c; - if (this._skeleton.magnets) { - for (var d in this.magnet) { - if (c = "next" === d ? this.getBoard().getNearestMagnet(this.x, this.y + this.getBelowHeight(), d) : this.getBoard().getNearestMagnet(this.x, this.y, d)) { - return a.setMagnetedBlock(c.view, d); - } - } - a.setMagnetedBlock(null); - } + b.getAbsolutePosFromDocument = function() { + var a = this._block.view, b = a.getContentPos(), d = a.getAbsoluteCoordinate(), a = a.getBoard().svgDom.offset(); + return {x:d.x + this.box.x + b.x + a.left, y:d.y + this.box.y + b.y + a.top}; }; - a.dominate = function() { - this.block.getThread().view.dominate(); + b.getRelativePos = function() { + var a = this._block.view.getContentPos(), b = this.box; + return {x:b.x + a.x, y:b.y + a.y}; + }; + b.truncate = function() { + var a = String(this.getValue()), b = this.TEXT_LIMIT_LENGTH, d = a.substring(0, b); + a.length > b && (d += "..."); + return d; + }; + b.appendSvgOptionGroup = function() { + return this._block.view.getBoard().svgGroup.elem("g"); + }; + b.getValue = function() { + return this._block.params[this._index]; + }; + b.setValue = function(a, b) { + this.value != a && (this.value = a, this._block.params[this._index] = a, b && this._blockView.reDraw()); }; - a.getSvgRoot = function() { - for (var a = this.getBoard().svgBlockGroup, c = this.svgGroup;c.parentNode !== a;) { - c = c.parentNode; + b._isEditable = function() { + if (this._block.view.dragMode == Entry.DRAG_MODE_DRAG) { + return !1; } - return c; + var a = this._block.view, b = a.getBoard(); + if (!0 === b.disableMouseEvent) { + return !1; + } + var d = b.workspace.selectedBlockView; + if (!d || b != d.getBoard()) { + return !1; + } + b = a.getSvgRoot(); + return b == d.svgGroup || $(b).has($(a.svgGroup)); }; - a.getBoard = function() { - return this._board; + b._selectBlockView = function() { + var a = this._block.view; + a.getBoard().setSelectedBlock(a); }; - a._setBoard = function() { - this._board = this._board.code.board; + b._bindRenderOptions = function() { + var a = this; + $(this.svgGroup).bind("mouseup touchend", function(b) { + a._isEditable() && (a.destroyOption(), a._startValue = a.getValue(), a.renderOptions()); + }); }; - a.destroy = function(a) { - this._destroyObservers(); - var c = this.svgGroup; - a ? $(c).fadeOut(100, function() { - c.remove(); - }) : c.remove(); - this._contents.forEach(function(a) { - a.constructor !== Entry.Block && a.destroy(); + b.pointer = function(a) { + a = a || []; + a.unshift(this._index); + a.unshift(Entry.PARAM); + return this._block.pointer(a); + }; +})(Entry.Field.prototype); +Entry.FieldAngle = function(b, a, c) { + this._block = a.block; + this._blockView = a; + this.box = new Entry.BoxModel; + this.svgGroup = null; + this.position = b.position; + this._contents = b; + this._index = c; + b = this.getValue(); + this.setValue(this.modValue(void 0 !== b ? b : 90)); + this.renderStart(); +}; +Entry.Utils.inherit(Entry.Field, Entry.FieldAngle); +(function(b) { + b.renderStart = function() { + this.svgGroup && $(this.svgGroup).remove(); + this.svgGroup = this._blockView.contentSvgGroup.elem("g", {class:"entry-input-field"}); + this.textElement = this.svgGroup.elem("text", {x:4, y:4, "font-size":"9pt"}); + this.textElement.textContent = this.getText(); + var a = this.getTextWidth(), b = this.position && this.position.y ? this.position.y : 0; + this._header = this.svgGroup.elem("rect", {x:0, y:b - 8, rx:3, ry:3, width:a, height:16, rx:3, ry:3, fill:"#fff", "fill-opacity":.4}); + this.svgGroup.appendChild(this.textElement); + this._bindRenderOptions(); + this.box.set({x:0, y:0, width:a, height:16}); + }; + b.renderOptions = function() { + var a = this; + this._attachDisposeEvent(function() { + a.applyValue(); + a.destroyOption(); }); - var d = this.block; - (a = d.events.viewDestroy) && !this.isInBlockMenu && a.forEach(function(a) { - Entry.Utils.isFunction(a) && a(d); + this.optionGroup = Entry.Dom("input", {class:"entry-widget-input-field", parent:$("body")}); + this.optionGroup.val(this.value); + this.optionGroup.on("mousedown", function(a) { + a.stopPropagation(); }); - this._schemaChangeEvent && this._schemaChangeEvent.destroy(); + this.optionGroup.on("keyup", function(b) { + var c = b.keyCode || b.which; + a.applyValue(b); + -1 < [13, 27].indexOf(c) && a.destroyOption(); + }); + var b = this.getAbsolutePosFromDocument(); + b.y -= this.box.height / 2; + this.optionGroup.css({height:16, left:b.x, top:b.y, width:a.box.width}); + this.optionGroup.select(); + this.svgOptionGroup = this.appendSvgOptionGroup(); + this.svgOptionGroup.elem("circle", {x:0, y:0, r:49, class:"entry-field-angle-circle"}); + this._dividerGroup = this.svgOptionGroup.elem("g"); + for (b = 0;360 > b;b += 15) { + this._dividerGroup.elem("line", {x1:49, y1:0, x2:49 - (0 === b % 45 ? 10 : 5), y2:0, transform:"rotate(" + b + ", 0, 0)", class:"entry-angle-divider"}); + } + b = this.getAbsolutePosFromBoard(); + b.x += this.box.width / 2; + b.y = b.y + this.box.height / 2 + 49 + 1; + this.svgOptionGroup.attr({class:"entry-field-angle", transform:"translate(" + b.x + "," + b.y + ")"}); + var b = a.getAbsolutePosFromDocument(), d = [b.x + a.box.width / 2, b.y + a.box.height / 2 + 1]; + $(this.svgOptionGroup).mousemove(function(b) { + a.optionGroup.val(a.modValue(function(a, b) { + var c = b[0] - a[0], d = b[1] - a[1] - 49 - 1, e = Math.atan(-d / c), e = Entry.toDegrees(e), e = 90 - e; + 0 > c ? e += 180 : 0 < d && (e += 360); + return 15 * Math.round(e / 15); + }(d, [b.clientX, b.clientY]))); + a.applyValue(); + }); + this.updateGraph(); }; - a.getShadow = function() { - this._shadow || (this._shadow = Entry.SVG.createElement(this.svgGroup.cloneNode(!0), {opacity:.5}), this.getBoard().svgGroup.appendChild(this._shadow)); - return this._shadow; + b.updateGraph = function() { + this._fillPath && this._fillPath.remove(); + var a = Entry.toRadian(this.getValue()), b = 49 * Math.sin(a), d = -49 * Math.cos(a), a = a > Math.PI ? 1 : 0; + this._fillPath = this.svgOptionGroup.elem("path", {d:"M 0,0 v -49 A 49,49 0 %LARGE 1 %X,%Y z".replace("%X", b).replace("%Y", d).replace("%LARGE", a), class:"entry-angle-fill-area"}); + this.svgOptionGroup.appendChild(this._dividerGroup); + this._indicator && this._indicator.remove(); + this._indicator = this.svgOptionGroup.elem("line", {x1:0, y1:0, x2:b, y2:d}); + this._indicator.attr({class:"entry-angle-indicator"}); }; - a.destroyShadow = function() { - this._shadow && (this._shadow.remove(), delete this._shadow); + b.applyValue = function() { + var a = this.optionGroup.val(); + isNaN(a) || "" === a || (a = this.modValue(a), this.setValue(a), this.updateGraph(), this.textElement.textContent = this.getValue(), this.optionGroup && this.optionGroup.val(a), this.resize()); }; - a._updateMagnet = function() { - if (this._skeleton.magnets) { - var a = this._skeleton.magnets(this); - a.next && this._nextGroup.attr("transform", "translate(" + a.next.x + "," + a.next.y + ")"); - this.magnet = a; - this.block.getThread().changeEvent.notify(); - } + b.resize = function() { + var a = this.getTextWidth(); + this._header.attr({width:a}); + this.optionGroup && this.optionGroup.css({width:a}); + this.box.set({width:a}); + this._block.view.alignContent(); }; - a._updateBG = function() { - if (this._board.dragBlock && this._board.dragBlock.dragInstance) { - var a = this.svgGroup; - if (this.magnet.next) { - if (a = this.magneting) { - var c = this._board.dragBlock.getShadow(), d = this.getAbsoluteCoordinate(), e; - if ("previous" === a) { - e = this.magnet.next, e = "translate(" + (d.x + e.x) + "," + (d.y + e.y) + ")"; - } else { - if ("next" === a) { - e = this.magnet.previous; - var f = this._board.dragBlock.getBelowHeight(); - e = "translate(" + (d.x + e.x) + "," + (d.y + e.y - f) + ")"; - } - } - $(c).attr({transform:e, display:"block"}); - this._clonedShadow = c; - this.background && (this.background.remove(), this.nextBackground.remove(), delete this.background, delete this.nextBackground); - "previous" === a && (a = this._board.dragBlock.getBelowHeight() + this.offsetY, this.originalHeight = this.offsetY, this.set({offsetY:a})); - } else { - this._clonedShadow && (this._clonedShadow.attr({display:"none"}), delete this._clonedShadow), a = this.originalHeight, void 0 !== a && (this.background && (this.background.remove(), this.nextBackground.remove(), delete this.background, delete this.nextBackground), this.set({offsetY:a}), delete this.originalHeight); - } - (a = this.block.thread.changeEvent) && a.notify(); - } else { - this.magneting ? (a.attr({filter:"url(#entryBlockHighlightFilter_" + this.getBoard().suffix + ")"}), a.addClass("outputHighlight")) : (a.removeClass("outputHighlight"), a.removeAttr("filter")); + b.getTextWidth = function() { + return this.textElement ? this.textElement.getComputedTextLength() + 8 : 8; + }; + b.getText = function() { + return this.getValue() + "\u00b0"; + }; + b.modValue = function(a) { + return a % 360; + }; + b.destroyOption = function() { + this.disposeEvent && (Entry.disposeEvent.detach(this.disposeEvent), delete this.documentDownEvent); + this.optionGroup && (this.optionGroup.remove(), delete this.optionGroup); + this.svgOptionGroup && (this.svgOptionGroup.remove(), delete this.svgOptionGroup); + this.textElement.textContent = this.getText(); + this.command(); + }; +})(Entry.FieldAngle.prototype); +Entry.FieldBlock = function(b, a, c, d, e) { + Entry.Model(this, !1); + this._blockView = a; + this._block = a.block; + this._valueBlock = null; + this.box = new Entry.BoxModel; + this.changeEvent = new Entry.Event(this); + this._index = c; + this.contentIndex = e; + this._content = b; + this.acceptType = b.accept; + this._restoreCurrent = b.restore; + this.view = this; + this.svgGroup = null; + this._position = b.position; + this.box.observe(a, "alignContent", ["width", "height"]); + this.observe(this, "_updateBG", ["magneting"], !1); + this.renderStart(a.getBoard(), d); +}; +Entry.Utils.inherit(Entry.Field, Entry.FieldBlock); +(function(b) { + b.schema = {magneting:!1}; + b.renderStart = function(a, b) { + this.svgGroup = this._blockView.contentSvgGroup.elem("g"); + this.view = this; + this._nextGroup = this.svgGroup; + this.box.set({x:0, y:0, width:0, height:20}); + var d = this.getValue(); + d && !d.view && (d.setThread(this), d.createView(a, b), d.getThread().view.setParent(this)); + this.updateValueBlock(d); + this._blockView.getBoard().constructor !== Entry.Board && this._valueBlock.view.removeControl(); + }; + b.align = function(a, b, d) { + var e = this.svgGroup; + this._position && (this._position.x && (a = this._position.x), this._position.y && (b = this._position.y)); + var f = this._valueBlock; + f && (b = -.5 * f.view.height); + f = "translate(" + a + "," + b + ")"; + void 0 === d || d ? e.animate({transform:f}, 300, mina.easeinout) : e.attr({transform:f}); + this.box.set({x:a, y:b}); + }; + b.calcWH = function() { + var a = this._valueBlock; + a ? (a = a.view, this.box.set({width:a.width, height:a.height})) : this.box.set({width:15, height:20}); + }; + b.calcHeight = b.calcWH; + b.destroy = function() { + }; + b.inspectBlock = function() { + var a = null; + if (this._originBlock) { + a = this._originBlock.type, delete this._originBlock; + } else { + switch(this.acceptType) { + case "boolean": + a = "True"; + break; + case "string": + a = "text"; + break; + case "param": + a = "function_field_label"; } } + return this._createBlockByType(a); }; - a.addDragging = function() { - this.svgGroup.addClass("dragging"); + b._setValueBlock = function(a) { + this._restoreCurrent && (this._originBlock = this._valueBlock); + a || (a = this.inspectBlock()); + this._valueBlock = a; + this.setValue(a); + a.setThread(this); + a.getThread().view.setParent(this); + return this._valueBlock; }; - a.removeDragging = function() { - this.svgGroup.removeClass("dragging"); + b.getValueBlock = function() { + return this._valueBlock; }; - a.addSelected = function() { - this.svgGroup.addClass("selected"); + b.updateValueBlock = function(a) { + a instanceof Entry.Block || (a = void 0); + this._destroyObservers(); + a = this._setValueBlock(a).view; + a.bindPrev(this); + this._blockView.alignContent(); + this._posObserver = a.observe(this, "updateValueBlock", ["x", "y"], !1); + this._sizeObserver = a.observe(this, "calcWH", ["width", "height"]); + a = this._blockView.getBoard(); + a.constructor === Entry.Board && a.generateCodeMagnetMap(); }; - a.removeSelected = function() { - this.svgGroup.removeClass("selected"); + b._destroyObservers = function() { + this._sizeObserver && this._sizeObserver.destroy(); + this._posObserver && this._posObserver.destroy(); }; - a.getSkeleton = function() { - return this._skeleton; + b.getPrevBlock = function(a) { + return this._valueBlock === a ? this : null; }; - a.getContentPos = function() { - return this._skeleton.contentPos(this); + b.getNextBlock = function() { + return null; }; - a.renderText = function() { - this._startContentRender(Entry.Workspace.MODE_VIMBOARD); + b.requestAbsoluteCoordinate = function(a) { + a = this._blockView; + var b = a.contentPos; + a = a.getAbsoluteCoordinate(); + a.x += this.box.x + b.x; + a.y += this.box.y + b.y; + return a; }; - a.renderBlock = function() { - this._startContentRender(Entry.Workspace.MODE_BOARD); + b.dominate = function() { + this._blockView.dominate(); }; - a._updateOpacity = function() { - this.svgGroup.attr({opacity:!1 === this.visible ? 0 : 1}); - this.visible && this._setPosition(); + b.isGlobal = function() { + return !1; }; - a._updateShadow = function() { - this.shadow && Entry.Utils.colorDarken(this._schema.color, .7); + b.separate = function(a) { + this.getCode().createThread([a]); + this.calcWH(); + this.changeEvent.notify(); }; - a._setMovable = function() { - this.movable = null !== this.block.isMovable() ? this.block.isMovable() : void 0 !== this._skeleton.movable ? this._skeleton.movable : !0; + b.getCode = function() { + return this._block.thread.getCode(); }; - a._setReadOnly = function() { - this.readOnly = null !== this.block.isReadOnly() ? this.block.isReadOnly() : void 0 !== this._skeleton.readOnly ? this._skeleton.readOnly : !1; + b.cut = function(a) { + return this._valueBlock === a ? [a] : null; }; - a._setCopyable = function() { - this.copyable = null !== this.block.isCopyable() ? this.block.isCopyable() : void 0 !== this._skeleton.copyable ? this._skeleton.copyable : !0; + b.replace = function(a) { + "string" === typeof a && (a = this._createBlockByType(a)); + var b = this._valueBlock; + Entry.block[b.type].isPrimitive ? (b.doNotSplice = !0, b.destroy()) : "param" === this.acceptType ? (this._destroyObservers(), b.view._toGlobalCoordinate(), a.getTerminateOutputBlock().view._contents[1].replace(b)) : (this._destroyObservers(), b.view._toGlobalCoordinate(), this.separate(b), b.view.bumpAway(30, 150)); + this.updateValueBlock(a); + a.view._toLocalCoordinate(this.svgGroup); + this.calcWH(); + this.changeEvent.notify(); }; - a.bumpAway = function(a, c) { - var d = this; - a = a || 15; - c ? window.setTimeout(function() { - d._moveBy(a, a, !1); - }, c) : d._moveBy(a, a, !1); + b.setParent = function(a) { + this._parent = a; }; - a.bindPrev = function(a) { - if (a) { - if (this._toLocalCoordinate(a.view._nextGroup), (a = a.getNextBlock()) && a !== this.block) { - var c = this.block.getLastBlock(); - c.view.magnet.next ? a.view._toLocalCoordinate(c.view._nextGroup) : (a.view._toGlobalCoordinate(), a.separate(), a.view.bumpAway(null, 100)); - } - } else { - if (a = this.block.getPrevBlock()) { - this._toLocalCoordinate(a.view._nextGroup), (a = this.block.getNextBlock()) && a.view && a.view._toLocalCoordinate(this._nextGroup); - } - } + b.getParent = function() { + return this._parent; }; - a.getAbsoluteCoordinate = function(a) { - a = void 0 !== a ? a : this.dragMode; - if (a === Entry.DRAG_MODE_DRAG) { - return {x:this.x, y:this.y}; - } - a = this.block.getThread().view.requestAbsoluteCoordinate(this); - a.x += this.x; - a.y += this.y; + b._createBlockByType = function(a) { + this._block.getThread(); + var b = this._blockView.getBoard(); + a = new Entry.Block({type:a}, this); + var d = b.workspace, e; + d && (e = d.getMode()); + a.createView(b, e); return a; }; - a.getBelowHeight = function() { - return this.block.getThread().view.requestPartHeight(this); + b.spliceBlock = function() { + this.updateValueBlock(); }; - a._updateDisplay = function() { - this.svgGroup.attr({display:!1 === this.display ? "none" : "block"}); - this.display && this._setPosition(); + b._updateBG = function() { + this.magneting ? this._bg = this.svgGroup.elem("path", {d:"m 8,12 l -4,0 -2,-2 0,-3 3,0 1,-1 0,-12 -1,-1 -3,0 0,-3 2,-2 l 4,0 z", fill:"#fff", stroke:"#fff", "fill-opacity":.7, transform:"translate(0,12)"}) : this._bg && (this._bg.remove(), delete this._bg); }; - a._updateColor = function() { - var a = this._schema.color; - this.block.deletable === Entry.Block.DELETABLE_FALSE_LIGHTEN && (a = Entry.Utils.colorLighten(a)); - this._fillColor = a; - this._path.attr({fill:a}); - this._updateContents(); + b.getThread = function() { + return this; }; - a._updateContents = function() { - for (var a = 0;a < this._contents.length;a++) { - this._contents[a].renderStart(); - } - this.alignContent(!1); + b.pointer = function(a) { + a.unshift(this._index); + a.unshift(Entry.PARAM); + return this._block.pointer(a); }; - a._destroyObservers = function() { - for (var a = this._observers;a.length;) { - a.pop().destroy(); - } +})(Entry.FieldBlock.prototype); +Entry.FieldColor = function(b, a, c) { + this._block = a.block; + this._blockView = a; + this.box = new Entry.BoxModel; + this.svgGroup = null; + this._contents = b; + this._index = c; + this._position = b.position; + this.key = b.key; + this.setValue(this.getValue() || "#FF0000"); + this.renderStart(a); +}; +Entry.Utils.inherit(Entry.Field, Entry.FieldColor); +(function(b) { + b.renderStart = function() { + this.svgGroup && $(this.svgGroup).remove(); + this.svgGroup = this._blockView.contentSvgGroup.elem("g", {class:"entry-field-color"}); + var a = this._position, b; + a ? (b = a.x || 0, a = a.y || 0) : (b = 0, a = -8); + this._header = this.svgGroup.elem("rect", {x:b, y:a, width:14.5, height:16, fill:this.getValue()}); + this._bindRenderOptions(); + this.box.set({x:b, y:a, width:14.5, height:16}); }; - a._changeFill = function(a) { - var c = this.getBoard(); - if (c.patternRect && !c.dragBlock) { - var d = this._fillColor, e = this._path, c = this.getBoard(); - a ? (c.setPatternRectFill(d), d = "url(#blockHoverPattern_" + this.getBoard().suffix + ")") : c.disablePattern(); - e.attr({fill:d}); + b.renderOptions = function() { + var a = this; + this._attachDisposeEvent(); + var b = Entry.FieldColor.getWidgetColorList(); + this.optionGroup = Entry.Dom("table", {class:"entry-widget-color-table", parent:$("body")}); + for (var d = 0;d < b.length;d++) { + for (var e = Entry.Dom("tr", {class:"entry-widget-color-row", parent:this.optionGroup}), f = 0;f < b[d].length;f++) { + var g = Entry.Dom("td", {class:"entry-widget-color-cell", parent:e}), h = b[d][f]; + g.css({"background-color":h}); + g.attr({"data-color-value":h}); + (function(b, c) { + b.mousedown(function(a) { + a.stopPropagation(); + }); + b.mouseup(function(b) { + a.applyValue(c); + a.destroyOption(); + a._selectBlockView(); + }); + })(g, h); + } } + b = this.getAbsolutePosFromDocument(); + b.y += this.box.height / 2 + 1; + this.optionGroup.css({left:b.x, top:b.y}); }; - a.addActivated = function() { - this.svgGroup.addClass("activated"); + b.applyValue = function(a) { + this.value != a && (this.setValue(a), this._header.attr({fill:a})); }; - a.removeActivated = function() { - this.svgGroup.removeClass("activated"); +})(Entry.FieldColor.prototype); +Entry.FieldColor.getWidgetColorList = function() { + return ["#FFFFFF #CCCCCC #C0C0C0 #999999 #666666 #333333 #000000".split(" "), "#FFCCCC #FF6666 #FF0000 #CC0000 #990000 #660000 #330000".split(" "), "#FFCC99 #FF9966 #FF9900 #FF6600 #CC6600 #993300 #663300".split(" "), "#FFFF99 #FFFF66 #FFCC66 #FFCC33 #CC9933 #996633 #663333".split(" "), "#FFFFCC #FFFF33 #FFFF00 #FFCC00 #999900 #666600 #333300".split(" "), "#99FF99 #66FF99 #33FF33 #33CC00 #009900 #006600 #003300".split(" "), "#99FFFF #33FFFF #66CCCC #00CCCC #339999 #336666 #003333".split(" "), "#CCFFFF #66FFFF #33CCFF #3366FF #3333FF #000099 #000066".split(" "), + "#CCCCFF #9999FF #6666CC #6633FF #6609CC #333399 #330099".split(" "), "#FFCCFF #FF99FF #CC66CC #CC33CC #993399 #663366 #330033".split(" ")]; +}; +Entry.FieldDropdown = function(b, a, c) { + this._block = a.block; + this._blockView = a; + this.box = new Entry.BoxModel; + this.svgGroup = null; + this._contents = b; + this._noArrow = b.noArrow; + this._arrowColor = b.arrowColor; + this._index = c; + this.setValue(this.getValue()); + this._CONTENT_HEIGHT = b.dropdownHeight || a.getSkeleton().dropdownHeight || 16; + this._FONT_SIZE = b.fontSize || a.getSkeleton().fontSize || 12; + this._ROUND = b.roundValue || 3; + this.renderStart(); +}; +Entry.Utils.inherit(Entry.Field, Entry.FieldDropdown); +(function(b) { + b.renderStart = function() { + this.svgGroup && $(this.svgGroup).remove(); + this instanceof Entry.FieldDropdownDynamic && this._updateValue(); + var a = this._blockView; + this.svgGroup = a.contentSvgGroup.elem("g", {class:"entry-field-dropdown"}); + this.textElement = this.svgGroup.elem("text", {x:2}); + this.textElement.textContent = this.getTextByValue(this.getValue()); + var b = this.textElement.getBBox(); + this.textElement.attr({style:"white-space: pre; font-size:" + this._FONT_SIZE + "px", y:.25 * b.height}); + b = this.textElement.getComputedTextLength() + 16; + this._noArrow && (b -= 12); + var d = this._CONTENT_HEIGHT; + this._header = this.svgGroup.elem("rect", {width:b, height:d, y:-d / 2, rx:this._ROUND, ry:this._ROUND, fill:"#fff", "fill-opacity":.4}); + this.svgGroup.appendChild(this.textElement); + this._noArrow || (a = this._arrowColor || a._schema.color, this._arrow = this.svgGroup.elem("polygon", {points:"0,-2.1 6.4,-2.1 3.2,2.1", fill:a, stroke:a, transform:"translate(" + (b - 11) + ",0)"})); + this._bindRenderOptions(); + this.box.set({x:0, y:0, width:b, height:d}); }; - a.reDraw = function() { - if (this.visible) { - var a = this.block; - requestAnimationFrame(this._updateContents.bind(this)); - var c = a.params; - if (c) { - for (var d = 0;d < c.length;d++) { - var e = c[d]; - e instanceof Entry.Block && e.view.reDraw(); - } - } - if (a = a.statements) { - for (d = 0;d < a.length;d++) { - a[d].view.reDraw(); - } - } + b.resize = function() { + var a = this.textElement.getComputedTextLength() + 18; + this._noArrow ? a -= 14 : this._arrow.attr({transform:"translate(" + (a - 11) + ",0)"}); + this._header.attr({width:a}); + this.box.set({width:a}); + this._block.view.alignContent(); + }; + b.renderOptions = function() { + var a = this; + this._attachDisposeEvent(); + this.optionGroup = Entry.Dom("ul", {class:"entry-widget-dropdown", parent:$("body")}); + this.optionGroup.bind("mousedown touchstart", function(a) { + a.stopPropagation(); + }); + for (var b = this._contents.options, b = this._contents.options, d = 0, e = b.length;d < e;d++) { + var f = b[d], g = f[0], f = f[1], h = Entry.Dom("li", {class:"rect", parent:this.optionGroup}), k = Entry.Dom("span", {class:"left", parent:h}); + Entry.Dom("span", {class:"right", parent:h}).text(g); + this.getValue() == f && k.text("\u2713"); + (function(b, c) { + b.bind("mousedown touchstart", function(a) { + a.stopPropagation(); + }); + b.bind("mouseup touchend", function(b) { + b.stopPropagation(); + a.applyValue(c); + a.destroyOption(); + a._selectBlockView(); + }); + })(h, f); } + this._position(); }; - a.getParam = function(a) { - return this._paramMap[a]; + b._position = function() { + var a = this.getAbsolutePosFromDocument(); + a.y += this.box.height / 2; + var b = $(document).height(), d = this.optionGroup.height(), e = this.optionGroup.width() + 30; + if (b < a.y + d + 30) { + var b = this._blockView.getBoard().svgDom.height(), f = this.getAbsolutePosFromBoard(); + this._blockView.y < b / 2 ? (a.x += this.box.width / 2 - e / 2, b -= f.y + 30, this.optionGroup.height(b)) : (a.x += this.box.width + 1, b -= b - f.y, b - 30 < d && this.optionGroup.height(b - b % 30), a.y -= this.optionGroup.height()); + } else { + a.x += this.box.width / 2 - e / 2; + } + this.optionGroup.addClass("rendered"); + this.optionGroup.css({left:a.x, top:a.y, width:e}); + this.optionGroup.find(".right").width(e - 20); }; -})(Entry.BlockView.prototype); -Entry.Field = function() { -}; -(function(a) { - a.TEXT_LIMIT_LENGTH = 20; - a.destroy = function() { - this.destroyOption(); + b.applyValue = function(a) { + this.value != a && this.setValue(a); + this.textElement.textContent = this.getTextByValue(a); + this.resize(); }; - a.command = function() { - this._startValue && (this._startValue === this.getValue() || this._blockView.isInBlockMenu || Entry.do("setFieldValue", this._block, this, this.pointer(), this._startValue, this.getValue())); - delete this._startValue; + b.getTextByValue = function(a) { + if (!a || "null" === a) { + return Lang.Blocks.no_target; + } + for (var b = this._contents.options, d = 0, e = b.length;d < e;d++) { + var f = b[d]; + if (f[1] == a) { + return f[0]; + } + } + return Lang.Blocks.no_target; }; - a.destroyOption = function() { - this.documentDownEvent && (Entry.documentMousedown.detach(this.documentDownEvent), delete this.documentDownEvent); - this.disposeEvent && (Entry.disposeEvent.detach(this.disposeEvent), delete this.documentDownEvent); - this.optionGroup && (this.optionGroup.remove(), delete this.optionGroup); - this.command(); +})(Entry.FieldDropdown.prototype); +Entry.FieldDropdownDynamic = function(b, a, c) { + this._block = a.block; + this._blockView = a; + this.box = new Entry.BoxModel; + this.svgGroup = null; + this._contents = b; + this._index = c; + this._arrowColor = b.arrowColor; + c = this._contents.menuName; + Entry.Utils.isFunction(c) ? this._menuGenerator = c : this._menuName = c; + this._CONTENT_HEIGHT = b.dropdownHeight || a.getSkeleton().dropdownHeight || 16; + this._FONT_SIZE = b.fontSize || a.getSkeleton().fontSize || 12; + this._ROUND = b.roundValue || 3; + this.renderStart(a); +}; +Entry.Utils.inherit(Entry.FieldDropdown, Entry.FieldDropdownDynamic); +(function(b) { + b.constructor = Entry.FieldDropDownDynamic; + b._updateValue = function() { + var a = []; + Entry.container && (a = this._menuName ? Entry.container.getDropdownList(this._menuName) : this._menuGenerator()); + this._contents.options = a; + var a = this._contents.options, b = this.getValue(); + b && "null" != b || (b = 0 !== a.length ? a[0][1] : null); + this.setValue(b); }; - a._attachDisposeEvent = function(a) { - var c = this; - c.disposeEvent = Entry.disposeEvent.attach(c, a || function() { - c.destroyOption(); + b.renderOptions = function() { + var a = this; + this._attachDisposeEvent(); + this.optionGroup = Entry.Dom("ul", {class:"entry-widget-dropdown", parent:$("body")}); + this.optionGroup.bind("mousedown touchstart", function(a) { + a.stopPropagation(); }); + var b; + b = this._menuName ? Entry.container.getDropdownList(this._contents.menuName) : this._menuGenerator(); + this._contents.options = b; + for (var d = 0;d < b.length;d++) { + var e = b[d], f = e[0], e = e[1], g = Entry.Dom("li", {class:"rect", parent:this.optionGroup}), h = Entry.Dom("span", {class:"left", parent:g}); + Entry.Dom("span", {class:"right", parent:g}).text(f); + this.getValue() == e && h.text("\u2713"); + (function(b, c) { + b.mousedown(function(a) { + a.stopPropagation(); + }); + b.mouseup(function(b) { + b.stopPropagation(); + a.applyValue(c); + a.destroyOption(); + a._selectBlockView(); + }); + })(g, e); + } + this._position(); }; - a.align = function(a, c, d) { - var e = this.svgGroup; - this._position && (this._position.x && (a = this._position.x), this._position.y && (c = this._position.y)); - var f = "translate(" + a + "," + c + ")"; - void 0 === d || d ? e.animate({transform:f}, 300, mina.easeinout) : e.attr({transform:f}); - this.box.set({x:a, y:c}); +})(Entry.FieldDropdownDynamic.prototype); +Entry.FieldImage = function(b, a, c) { + this._block = a.block; + this._blockView = a; + this._content = b; + this.box = new Entry.BoxModel; + this._size = b.size; + this._highlightColor = b.highlightColor ? b.highlightColor : "#F59900"; + this._position = b.position; + this._imgElement = this._path = this.svgGroup = null; + this._index = c; + this.setValue(null); + this.renderStart(); +}; +Entry.Utils.inherit(Entry.Field, Entry.FieldImage); +(function(b) { + b.renderStart = function() { + this.svgGroup && this.svgGroup.remove(); + this._imgUrl = this._block.deletable === Entry.Block.DELETABLE_FALSE_LIGHTEN ? this._content.img.replace(".png", "_un.png") : this._content.img; + this.svgGroup = this._blockView.contentSvgGroup.elem("g"); + this._imgElement = this.svgGroup.elem("image", {href:this._imgUrl, x:0, y:-.5 * this._size, width:this._size, height:this._size}); + this.box.set({x:this._size, y:0, width:this._size, height:this._size}); }; - a.getAbsolutePosFromBoard = function() { - var a = this._block.view, c = a.getContentPos(), a = a.getAbsoluteCoordinate(); - return {x:a.x + this.box.x + c.x, y:a.y + this.box.y + c.y}; +})(Entry.FieldImage.prototype); +Entry.FieldIndicator = function(b, a, c) { + this._block = a.block; + this._blockView = a; + this.box = new Entry.BoxModel; + this._size = b.size; + this._imgUrl = this._block.deletable === Entry.Block.DELETABLE_FALSE_LIGHTEN ? b.img.replace(".png", "_un.png") : b.img; + this._boxMultiplier = b.boxMultiplier || 2; + this._highlightColor = b.highlightColor ? b.highlightColor : "#F59900"; + this._position = b.position; + this._index = c; + this._imgElement = this._path = this.svgGroup = null; + this.setValue(null); + this.renderStart(); +}; +Entry.Utils.inherit(Entry.Field, Entry.FieldIndicator); +(function(b) { + b.renderStart = function() { + this.svgGroup && this.svgGroup.remove(); + this.svgGroup = this._blockView.contentSvgGroup.elem("g"); + this._imgElement = this.svgGroup.elem("image", {href:Entry.mediaFilePath + this._imgUrl, x:this._position ? -1 * this._size : 0, y:-1 * this._size, width:2 * this._size, height:2 * this._size}); + var a = "m 0,-%s a %s,%s 0 1,1 -0.1,0 z".replace(/%s/gi, this._size); + this._path = this.svgGroup.elem("path", {d:a, stroke:"none", fill:"none"}); + this.box.set({width:this._size * this._boxMultiplier + (this._position ? -this._size : 0), height:this._size * this._boxMultiplier}); }; - a.getAbsolutePosFromDocument = function() { - var a = this._block.view, c = a.getContentPos(), d = a.getAbsoluteCoordinate(), a = a.getBoard().svgDom.offset(); - return {x:d.x + this.box.x + c.x + a.left, y:d.y + this.box.y + c.y + a.top}; + b.enableHighlight = function() { + var a = this._path.getTotalLength(), b = this._path; + this._path.attr({stroke:this._highlightColor, strokeWidth:2, "stroke-linecap":"round", "stroke-dasharray":a + " " + a, "stroke-dashoffset":a}); + setInterval(function() { + b.attr({"stroke-dashoffset":a}).animate({"stroke-dashoffset":0}, 300); + }, 1400, mina.easeout); + setTimeout(function() { + setInterval(function() { + b.animate({"stroke-dashoffset":-a}, 300); + }, 1400, mina.easeout); + }, 500); }; - a.getRelativePos = function() { - var a = this._block.view.getContentPos(), c = this.box; - return {x:c.x + a.x, y:c.y + a.y}; +})(Entry.FieldIndicator.prototype); +Entry.Keyboard = {}; +Entry.FieldKeyboard = function(b, a, c) { + this._block = a.block; + this._blockView = a; + this.box = new Entry.BoxModel; + this.svgGroup = null; + this.position = b.position; + this._contents = b; + this._index = c; + this.setValue(String(this.getValue())); + this._optionVisible = !1; + this.renderStart(a); +}; +Entry.Utils.inherit(Entry.Field, Entry.FieldKeyboard); +(function(b) { + b.renderStart = function() { + this.svgGroup && $(this.svgGroup).remove(); + this.svgGroup = this._blockView.contentSvgGroup.elem("g", {class:"entry-input-field"}); + this.textElement = this.svgGroup.elem("text").attr({x:4, y:4, "font-size":"9pt"}); + this.textElement.textContent = Entry.getKeyCodeMap()[this.getValue()]; + var a = this.getTextWidth(), b = this.position && this.position.y ? this.position.y : 0; + this._header = this.svgGroup.elem("rect", {x:0, y:b - 8, width:a, height:16, rx:3, ry:3, fill:"#fff", "fill-opacity":.4}); + this.svgGroup.appendChild(this.textElement); + this._bindRenderOptions(); + this.box.set({x:0, y:0, width:a, height:16}); }; - a.truncate = function() { - var a = String(this.getValue()), c = this.TEXT_LIMIT_LENGTH, d = a.substring(0, c); - a.length > c && (d += "..."); - return d; + b.renderOptions = function() { + Entry.keyPressed && (this.keyPressed = Entry.keyPressed.attach(this, this._keyboardControl)); + this._optionVisible = !0; + this._attachDisposeEvent(); + var a = this.getAbsolutePosFromDocument(); + a.x -= this.box.width / 2; + a.y += this.box.height / 2 + 1; + this.optionGroup = Entry.Dom("img", {class:"entry-widget-keyboard-input", src:Entry.mediaFilePath + "/media/keyboard_workspace.png", parent:$("body")}); + this.optionGroup.css({left:a.x, top:a.y}); }; - a.appendSvgOptionGroup = function() { - return this._block.view.getBoard().svgGroup.elem("g"); + b.destroyOption = function() { + this.disposeEvent && (Entry.disposeEvent.detach(this.disposeEvent), delete this.disposeEvent); + this.optionGroup && (this.optionGroup.remove(), delete this.optionGroup); + this._optionVisible = !1; + this.command(); + this.keyPressed && (Entry.keyPressed.detach(this.keyPressed), delete this.keyPressed); }; - a.getValue = function() { - return this._block.params[this._index]; + b._keyboardControl = function(a) { + a.stopPropagation(); + if (this._optionVisible) { + a = a.keyCode; + var b = Entry.getKeyCodeMap()[a]; + void 0 !== b && this.applyValue(b, a); + } }; - a.setValue = function(a, c) { - this.value != a && (this.value = a, this._block.params[this._index] = a, c && this._blockView.reDraw()); + b.applyValue = function(a, b) { + this.setValue(String(b)); + this.destroyOption(); + this.textElement.textContent = a; + this.resize(); }; - a._isEditable = function() { - if (this._block.view.dragMode == Entry.DRAG_MODE_DRAG) { - return !1; - } - var a = this._block.view, c = a.getBoard(); - if (!0 === c.disableMouseEvent) { - return !1; - } - var d = c.workspace.selectedBlockView; - if (!d || c != d.getBoard()) { - return !1; - } - c = a.getSvgRoot(); - return c == d.svgGroup || $(c).has($(a.svgGroup)); + b.resize = function() { + var a = this.getTextWidth(); + this._header.attr({width:a}); + this.box.set({width:a}); + this._blockView.alignContent(); }; - a._selectBlockView = function() { - var a = this._block.view; - a.getBoard().setSelectedBlock(a); + b.getTextWidth = function() { + return this.textElement.getComputedTextLength() + 8; }; - a._bindRenderOptions = function() { - var a = this; - $(this.svgGroup).bind("mouseup touchend", function(c) { - a._isEditable() && (a.destroyOption(), a._startValue = a.getValue(), a.renderOptions()); - }); + b.destroy = function() { + this.destroyOption(); + Entry.keyPressed && this.keyPressed && Entry.keyPressed.detach(this.keyPressed); }; - a.pointer = function(a) { - a = a || []; - a.unshift(this._index); - a.unshift(Entry.PARAM); - return this._block.pointer(a); +})(Entry.FieldKeyboard.prototype); +Entry.FieldLineBreak = function(b, a, c) { + this._block = a.block; + this._blockView = a; + this._index = c; + this.box = new Entry.BoxModel; + this.setValue(null); + this.renderStart(); +}; +Entry.Utils.inherit(Entry.Field, Entry.FieldLineBreak); +(function(b) { + b.renderStart = function() { }; -})(Entry.Field.prototype); -Entry.FieldBlock = function(a, b, c, d, e) { + b.align = function(a) { + var b = this._blockView; + 0 !== b._statements.length && this.box.set({y:(b._statements[a].height || 20) + Math.max(b.contentHeight % 1E3, 30)}); + }; +})(Entry.FieldLineBreak.prototype); +Entry.FieldOutput = function(b, a, c, d, e) { Entry.Model(this, !1); - this._blockView = b; - this._block = b.block; + this._blockView = a; + this._block = a.block; this._valueBlock = null; this.box = new Entry.BoxModel; this.changeEvent = new Entry.Event(this); this._index = c; this.contentIndex = e; - this._content = a; - this.acceptType = a.accept; - this._restoreCurrent = a.restore; + this._content = b; + this.acceptType = b.accept; this.view = this; this.svgGroup = null; - this._position = a.position; - this.box.observe(b, "alignContent", ["width", "height"]); + this._position = b.position; + this.box.observe(a, "alignContent", ["width", "height"]); this.observe(this, "_updateBG", ["magneting"], !1); - this.renderStart(b.getBoard(), d); + this.renderStart(a.getBoard(), d); }; -Entry.Utils.inherit(Entry.Field, Entry.FieldBlock); -(function(a) { - a.schema = {magneting:!1}; - a.renderStart = function(a, c) { +Entry.Utils.inherit(Entry.Field, Entry.FieldOutput); +(function(b) { + b.schema = {magneting:!1}; + b.renderStart = function(a, b) { this.svgGroup = this._blockView.contentSvgGroup.elem("g"); this.view = this; this._nextGroup = this.svgGroup; this.box.set({x:0, y:0, width:0, height:20}); var d = this.getValue(); - d && !d.view && (d.setThread(this), d.createView(a, c), d.getThread().view.setParent(this)); - this.updateValueBlock(d); - this._blockView.getBoard().constructor !== Entry.Board && this._valueBlock.view.removeControl(); + d && !d.view && (d.setThread(this), d.createView(a, b)); + this._updateValueBlock(d); + this._blockView.getBoard().constructor == Entry.BlockMenu && this._valueBlock && this._valueBlock.view.removeControl(); }; - a.align = function(a, c, d) { + b.align = function(a, b, d) { var e = this.svgGroup; - this._position && (this._position.x && (a = this._position.x), this._position.y && (c = this._position.y)); + this._position && (this._position.x && (a = this._position.x), this._position.y && (b = this._position.y)); var f = this._valueBlock; - f && (c = -.5 * f.view.height); - f = "translate(" + a + "," + c + ")"; + f && (b = -.5 * f.view.height); + f = "translate(" + a + "," + b + ")"; void 0 === d || d ? e.animate({transform:f}, 300, mina.easeinout) : e.attr({transform:f}); - this.box.set({x:a, y:c}); + this.box.set({x:a, y:b}); }; - a.calcWH = function() { + b.calcWH = function() { var a = this._valueBlock; - a ? (a = a.view, this.box.set({width:a.width, height:a.height})) : this.box.set({width:15, height:20}); - }; - a.calcHeight = a.calcWH; - a.destroy = function() { + a ? (a = a.view, this.box.set({width:a.width, height:a.height})) : this.box.set({width:0, height:20}); }; - a.inspectBlock = function() { - var a = null; - if (this._originBlock) { - a = this._originBlock.type, delete this._originBlock; - } else { - switch(this.acceptType) { - case "boolean": - a = "True"; - break; - case "string": - a = "text"; - break; - case "param": - a = "function_field_label"; - } - } - return this._createBlockByType(a); + b.calcHeight = b.calcWH; + b.destroy = function() { }; - a._setValueBlock = function(a) { - this._restoreCurrent && (this._originBlock = this._valueBlock); - a || (a = this.inspectBlock()); - this._valueBlock = a; - this.setValue(a); - a.setThread(this); - a.getThread().view.setParent(this); - return this._valueBlock; + b._inspectBlock = function() { }; - a.getValueBlock = function() { - return this._valueBlock; + b._setValueBlock = function(a) { + if (a != this._valueBlock || !this._valueBlock) { + return this._valueBlock = a, this.setValue(a), a && a.setThread(this), this._valueBlock; + } }; - a.updateValueBlock = function(a) { + b._updateValueBlock = function(a) { a instanceof Entry.Block || (a = void 0); - this._destroyObservers(); - a = this._setValueBlock(a).view; - a.bindPrev(this); + this._sizeObserver && this._sizeObserver.destroy(); + this._posObserver && this._posObserver.destroy(); + (a = this._setValueBlock(a)) ? (a = a.view, a.bindPrev(), this._posObserver = a.observe(this, "_updateValueBlock", ["x", "y"], !1), this._sizeObserver = a.observe(this, "calcWH", ["width", "height"])) : this.calcWH(); this._blockView.alignContent(); - this._posObserver = a.observe(this, "updateValueBlock", ["x", "y"], !1); - this._sizeObserver = a.observe(this, "calcWH", ["width", "height"]); a = this._blockView.getBoard(); a.constructor === Entry.Board && a.generateCodeMagnetMap(); }; - a._destroyObservers = function() { - this._sizeObserver && this._sizeObserver.destroy(); - this._posObserver && this._posObserver.destroy(); - }; - a.getPrevBlock = function(a) { + b.getPrevBlock = function(a) { return this._valueBlock === a ? this : null; }; - a.getNextBlock = function() { + b.getNextBlock = function() { return null; }; - a.requestAbsoluteCoordinate = function(a) { + b.requestAbsoluteCoordinate = function(a) { a = this._blockView; - var c = a.contentPos; + var b = a.contentPos; a = a.getAbsoluteCoordinate(); - a.x += this.box.x + c.x; - a.y += this.box.y + c.y; + a.x += this.box.x + b.x; + a.y += this.box.y + b.y; return a; }; - a.dominate = function() { + b.dominate = function() { this._blockView.dominate(); }; - a.isGlobal = function() { + b.isGlobal = function() { return !1; }; - a.separate = function(a) { + b.separate = function(a) { this.getCode().createThread([a]); - this.calcWH(); this.changeEvent.notify(); }; - a.getCode = function() { + b.getCode = function() { return this._block.thread.getCode(); }; - a.cut = function(a) { - return this._valueBlock === a ? [a] : null; + b.cut = function(a) { + return this._valueBlock === a ? (delete this._valueBlock, [a]) : null; + }; + b._updateBG = function() { + this.magneting ? this._bg = this.svgGroup.elem("path", {d:"m -4,-12 h 3 l 2,2 0,3 3,0 1,1 0,12 -1,1 -3,0 0,3 -2,2 h -3 ", fill:"#fff", stroke:"#fff", "fill-opacity":.7, transform:"translate(0," + (this._valueBlock ? 12 : 0) + ")"}) : this._bg && (this._bg.remove(), delete this._bg); + }; + b.replace = function(a) { + var b = this._valueBlock; + b && (b.view._toGlobalCoordinate(), a.getTerminateOutputBlock().view._contents[1].replace(b)); + this._updateValueBlock(a); + a.view._toLocalCoordinate(this.svgGroup); + this.calcWH(); + }; + b.setParent = function(a) { + this._parent = a; + }; + b.getParent = function() { + return this._parent; + }; + b.getThread = function() { + return this; + }; + b.getValueBlock = function() { + return this._valueBlock; + }; + b.pointer = function(a) { + a.unshift(this._index); + a.unshift(Entry.PARAM); + return this._block.pointer(a); + }; +})(Entry.FieldOutput.prototype); +Entry.FieldStatement = function(b, a, c) { + Entry.Model(this, !1); + this._blockView = a; + this.block = a.block; + this.view = this; + this._index = c; + this.acceptType = b.accept; + this._thread = this.statementSvgGroup = this.svgGroup = null; + this._position = b.position; + this.observe(a, "alignContent", ["height"], !1); + this.observe(this, "_updateBG", ["magneting"], !1); + this.renderStart(a.getBoard()); +}; +(function(b) { + b.schema = {x:0, y:0, width:100, height:20, magneting:!1}; + b.magnet = {next:{x:0, y:0}}; + b.renderStart = function(a) { + this.svgGroup = this._blockView.statementSvgGroup.elem("g"); + this._nextGroup = this.statementSvgGroup = this.svgGroup.elem("g"); + this._initThread(a); + this._board = a; + }; + b._initThread = function(a) { + var b = this.getValue(); + this._thread = b; + b.createView(a); + b.view.setParent(this); + if (a = b.getFirstBlock()) { + a.view._toLocalCoordinate(this.statementSvgGroup), this.firstBlock = a; + } + b.changeEvent.attach(this, this.calcHeight); + b.changeEvent.attach(this, this.checkTopBlock); + this.calcHeight(); + }; + b.align = function(a, b, d) { + d = void 0 === d ? !0 : d; + var e = this.svgGroup; + this._position && (this._position.x && (a = this._position.x), this._position.y && (b = this._position.y)); + var f = "translate(" + a + "," + b + ")"; + this.set({x:a, y:b}); + d ? e.animate({transform:f}, 300, mina.easeinout) : e.attr({transform:f}); + }; + b.calcHeight = function() { + var a = this._thread.view.requestPartHeight(null); + this.set({height:a}); + }; + b.getValue = function() { + return this.block.statements[this._index]; + }; + b.requestAbsoluteCoordinate = function() { + var a = this._blockView.getAbsoluteCoordinate(); + a.x += this.x; + a.y += this.y; + return a; + }; + b.dominate = function() { + this._blockView.dominate(); + }; + b.destroy = function() { + }; + b._updateBG = function() { + if (this._board.dragBlock && this._board.dragBlock.dragInstance) { + if (this.magneting) { + var a = this._board.dragBlock.getShadow(), b = this.requestAbsoluteCoordinate(), b = "translate(" + b.x + "," + b.y + ")"; + $(a).attr({transform:b, display:"block"}); + this._clonedShadow = a; + this.background && (this.background.remove(), this.nextBackground.remove(), delete this.background, delete this.nextBackground); + a = this._board.dragBlock.getBelowHeight(); + this.statementSvgGroup.attr({transform:"translate(0," + a + ")"}); + this.set({height:this.height + a}); + } else { + this._clonedShadow && (this._clonedShadow.attr({display:"none"}), delete this._clonedShadow), a = this.originalHeight, void 0 !== a && (this.background && (this.background.remove(), this.nextBackground.remove(), delete this.background, delete this.nextBackground), delete this.originalHeight), this.statementSvgGroup.attr({transform:"translate(0,0)"}), this.calcHeight(); + } + (a = this.block.thread.changeEvent) && a.notify(); + } + }; + b.insertTopBlock = function(a) { + this._posObserver && this._posObserver.destroy(); + var b = this.firstBlock; + (this.firstBlock = a) && a.doInsert(this._thread); + return b; + }; + b.getNextBlock = function() { + return this.firstBlock; + }; + b.checkTopBlock = function() { + var a = this._thread.getFirstBlock(); + a && this.firstBlock !== a ? (this.firstBlock = a, a.view.bindPrev(this), a._updatePos()) : a || (this.firstBlock = null); + }; +})(Entry.FieldStatement.prototype); +Entry.FieldText = function(b, a, c) { + this._block = a.block; + this._blockView = a; + this._index = c; + this.box = new Entry.BoxModel; + this._fontSize = b.fontSize || a.getSkeleton().fontSize || 12; + this._color = b.color || this._block.getSchema().fontColor || a.getSkeleton().color || "white"; + this._align = b.align || "left"; + this._text = this.getValue() || b.text; + this.setValue(null); + this.textElement = null; + this.renderStart(a); +}; +Entry.Utils.inherit(Entry.Field, Entry.FieldText); +(function(b) { + b.renderStart = function() { + this.svgGroup && $(this.svgGroup).remove(); + this.svgGroup = this._blockView.contentSvgGroup.elem("g"); + this._text = this._text.replace(/(\r\n|\n|\r)/gm, " "); + this.textElement = this.svgGroup.elem("text").attr({style:"white-space: pre; font-size:" + this._fontSize + "px", "class":"dragNone", fill:this._color}); + this.textElement.textContent = this._text; + var a = 0, b = this.textElement.getBoundingClientRect(); + "center" == this._align && (a = -b.width / 2); + this.textElement.attr({x:a, y:.25 * b.height}); + this.box.set({x:0, y:0, width:b.width, height:b.height}); + }; +})(Entry.FieldText.prototype); +Entry.FieldTextInput = function(b, a, c) { + this._blockView = a; + this._block = a.block; + this.box = new Entry.BoxModel; + this.svgGroup = null; + this.position = b.position; + this._contents = b; + this._index = c; + this.value = this.getValue() || ""; + this.renderStart(); +}; +Entry.Utils.inherit(Entry.Field, Entry.FieldTextInput); +(function(b) { + b.renderStart = function() { + this.svgGroup && $(this.svgGroup).remove(); + this.svgGroup = this._blockView.contentSvgGroup.elem("g"); + this.svgGroup.attr({class:"entry-input-field"}); + this.textElement = this.svgGroup.elem("text", {x:3, y:4, "font-size":"9pt"}); + this.textElement.textContent = this.truncate(); + var a = this.getTextWidth(), b = this.position && this.position.y ? this.position.y : 0; + this._header = this.svgGroup.elem("rect", {width:a, height:16, y:b - 8, rx:3, ry:3, fill:"transparent"}); + this.svgGroup.appendChild(this.textElement); + this._bindRenderOptions(); + this.box.set({x:0, y:0, width:a, height:16}); + }; + b.renderOptions = function() { + var a = this; + this._attachDisposeEvent(function() { + a.applyValue(); + a.destroyOption(); + }); + this.optionGroup = Entry.Dom("input", {class:"entry-widget-input-field", parent:$("body")}); + this.optionGroup.val(this.getValue()); + this.optionGroup.on("mousedown", function(a) { + a.stopPropagation(); + }); + this.optionGroup.on("keyup", function(b) { + var c = b.keyCode || b.which; + a.applyValue(b); + -1 < [13, 27].indexOf(c) && a.destroyOption(); + }); + var b = this.getAbsolutePosFromDocument(); + b.y -= this.box.height / 2; + this.optionGroup.css({height:16, left:b.x, top:b.y, width:a.box.width}); + this.optionGroup.focus(); + this.optionGroup.select(); + }; + b.applyValue = function(a) { + a = this.optionGroup.val(); + this.setValue(a); + this.textElement.textContent = this.truncate(); + this.resize(); + }; + b.resize = function() { + var a = this.getTextWidth(); + this._header.attr({width:a}); + this.optionGroup.css({width:a}); + this.box.set({width:a}); + this._blockView.alignContent(); + }; + b.getTextWidth = function() { + return this.textElement.getComputedTextLength() + 6 + 2; + }; +})(Entry.FieldTextInput.prototype); +Entry.GlobalSvg = {}; +(function(b) { + b.DONE = 0; + b._inited = !1; + b.REMOVE = 1; + b.RETURN = 2; + b.createDom = function() { + if (!this.inited) { + $("#globalSvgSurface").remove(); + $("#globalSvg").remove(); + var a = $("body"); + this._container = Entry.Dom("div", {classes:["globalSvgSurface", "entryRemove"], id:"globalSvgSurface", parent:a}); + this.svgDom = Entry.Dom($(''), {parent:this._container}); + this.svg = Entry.SVG("globalSvg"); + this.top = this.left = 0; + this._inited = !0; + } + }; + b.setView = function(a, b) { + if (a != this._view && !a.block.isReadOnly() && a.movable) { + return this._view = a, this._mode = b, b !== Entry.Workspace.MODE_VIMBOARD && a.set({visible:!1}), this.draw(), this.show(), this.align(), this.position(), !0; + } + }; + b.draw = function() { + var a = this._view; + this._svg && this.remove(); + var b = this._mode == Entry.Workspace.MODE_VIMBOARD; + this.svgGroup = Entry.SVG.createElement(a.svgGroup.cloneNode(!0), {opacity:1}); + this.svg.appendChild(this.svgGroup); + b && (a = $(this.svgGroup), a.find("g").css({filter:"none"}), a.find("path").velocity({opacity:0}, {duration:500}), a.find("text").velocity({fill:"#000000"}, {duration:530})); + }; + b.remove = function() { + this.svgGroup && (this.svgGroup.remove(), delete this.svgGroup, delete this._view, delete this._offsetX, delete this._offsetY, delete this._startX, delete this._startY, this.hide()); + }; + b.align = function() { + var a = this._view.getSkeleton().box(this._view).offsetX || 0, b = this._view.getSkeleton().box(this._view).offsetY || 0, a = -1 * a + 1, b = -1 * b + 1; + this._offsetX = a; + this._offsetY = b; + this.svgGroup.attr({transform:"translate(" + a + "," + b + ")"}); + }; + b.show = function() { + this._container.removeClass("entryRemove"); + }; + b.hide = function() { + this._container.addClass("entryRemove"); + }; + b.position = function() { + var a = this._view; + if (a) { + var b = a.getAbsoluteCoordinate(), a = a.getBoard().offset(); + this.left = b.x + a.left - this._offsetX; + this.top = b.y + a.top - this._offsetY; + this.svgDom.css({transform:"translate3d(" + this.left + "px," + this.top + "px, 0px)"}); + } + }; + b.terminateDrag = function(a) { + var b = Entry.mouseCoordinate, d = a.getBoard(), e = d.workspace.blockMenu, f = e.offset().left, g = e.offset().top, h = e.visible ? e.svgDom.width() : 0; + return b.y > d.offset().top - 20 && b.x > f + h ? this.DONE : b.y > g && b.x > f && e.visible ? a.block.isDeletable() ? this.REMOVE : this.RETURN : this.RETURN; + }; + b.addControl = function(a) { + this.onMouseDown.apply(this, arguments); + }; + b.onMouseDown = function(a) { + function b(a) { + var c = a.pageX; + a = a.pageY; + var d = e.left + (c - e._startX), f = e.top + (a - e._startY); + e.svgDom.css({left:d, top:f}); + e._startX = c; + e._startY = a; + e.left = d; + e.top = f; + } + function d(a) { + $(document).unbind(".block"); + } + this._startY = a.pageY; + var e = this; + a.stopPropagation(); + a.preventDefault(); + var f = $(document); + f.bind("mousemove.block", b); + f.bind("mouseup.block", d); + f.bind("touchmove.block", b); + f.bind("touchend.block", d); + this._startX = a.pageX; + this._startY = a.pageY; + }; +})(Entry.GlobalSvg); +Entry.Mutator = function() { +}; +(function(b) { + b.mutate = function(a, b) { + var d = Entry.block[a]; + void 0 === d.changeEvent && (d.changeEvent = new Entry.Event); + d.template = b.template; + d.params = b.params; + d.changeEvent.notify(1); }; - a.replace = function(a) { - "string" === typeof a && (a = this._createBlockByType(a)); - var c = this._valueBlock; - Entry.block[c.type].isPrimitive ? (c.doNotSplice = !0, c.destroy()) : "param" === this.acceptType ? (this._destroyObservers(), c.view._toGlobalCoordinate(), a.getTerminateOutputBlock().view._contents[1].replace(c)) : (this._destroyObservers(), c.view._toGlobalCoordinate(), this.separate(c), c.view.bumpAway(30, 150)); - this.updateValueBlock(a); - a.view._toLocalCoordinate(this.svgGroup); - this.calcWH(); - this.changeEvent.notify(); +})(Entry.Mutator); +(function(b) { +})(Entry.Mutator.prototype); +Entry.RenderView = function(b, a) { + this._align = a || "CENTER"; + b = "string" === typeof b ? $("#" + b) : $(b); + if ("DIV" !== b.prop("tagName")) { + return console.error("Dom is not div element"); + } + this.view = b; + this.viewOnly = !0; + this.suffix = "renderView"; + this.disableMouseEvent = this.visible = !0; + this._svgId = "renderView_" + (new Date).getTime(); + this._generateView(); + this.offset = this.svgDom.offset(); + this.setWidth(); + this.svg = Entry.SVG(this._svgId); + Entry.Utils.addFilters(this.svg, this.suffix); + this.svg && (this.svgGroup = this.svg.elem("g"), this.svgThreadGroup = this.svgGroup.elem("g"), this.svgThreadGroup.board = this, this.svgBlockGroup = this.svgGroup.elem("g"), this.svgBlockGroup.board = this); +}; +(function(b) { + b.schema = {code:null, dragBlock:null, closeBlock:null, selectedBlockView:null}; + b._generateView = function() { + this.renderViewContainer = Entry.Dom("div", {"class":"renderViewContainer", parent:this.view}); + this.svgDom = Entry.Dom($(''), {parent:this.renderViewContainer}); }; - a.setParent = function(a) { - this._parent = a; + b.changeCode = function(a) { + if (!(a instanceof Entry.Code)) { + return console.error("You must inject code instance"); + } + this.code = a; + this.svg || (this.svg = Entry.SVG(this._svgId), this.svgGroup = this.svg.elem("g"), this.svgThreadGroup = this.svgGroup.elem("g"), this.svgThreadGroup.board = this, this.svgBlockGroup = this.svgGroup.elem("g"), this.svgBlockGroup.board = this); + a.createView(this); + this.align(); + this.resize(); }; - a.getParent = function() { - return this._parent; + b.align = function() { + var a = this.code.getThreads(); + if (a && 0 !== a.length) { + for (var b = 0, d = "LEFT" == this._align ? 20 : this.svgDom.width() / 2, e = 0, f = a.length;e < f;e++) { + var g = a[e].getFirstBlock().view; + g._moveTo(d, b - g.offsetY, !1); + g = g.svgGroup.getBBox().height; + b += g + 15; + } + this._bBox = this.svgGroup.getBBox(); + this.height = this._bBox.height; + } }; - a._createBlockByType = function(a) { - this._block.getThread(); - var c = this._blockView.getBoard(); - a = new Entry.Block({type:a}, this); - var d = c.workspace, e; - d && (e = d.getMode()); - a.createView(c, e); - return a; + b.hide = function() { + this.view.addClass("entryRemove"); }; - a.spliceBlock = function() { - this.updateValueBlock(); + b.show = function() { + this.view.removeClass("entryRemove"); }; - a._updateBG = function() { - this.magneting ? this._bg = this.svgGroup.elem("path", {d:"m 8,12 l -4,0 -2,-2 0,-3 3,0 1,-1 0,-12 -1,-1 -3,0 0,-3 2,-2 l 4,0 z", fill:"#fff", stroke:"#fff", "fill-opacity":.7, transform:"translate(0,12)"}) : this._bg && (this._bg.remove(), delete this._bg); + b.setWidth = function() { + this._svgWidth = this.svgDom.width(); + this.offset = this.svgDom.offset(); }; - a.getThread = function() { - return this; + b.bindCodeView = function(a) { + this.svgBlockGroup.remove(); + this.svgThreadGroup.remove(); + this.svgBlockGroup = a.svgBlockGroup; + this.svgThreadGroup = a.svgThreadGroup; + this.svgGroup.appendChild(this.svgThreadGroup); + this.svgGroup.appendChild(this.svgBlockGroup); }; - a.pointer = function(a) { - a.unshift(this._index); - a.unshift(Entry.PARAM); - return this._block.pointer(a); + b.resize = function() { + this.svg && this._bBox && $(this.svg).css("height", this._bBox.height + 10); }; -})(Entry.FieldBlock.prototype); -Entry.Scroller = function(a, b, c) { - this._horizontal = void 0 === b ? !0 : b; +})(Entry.RenderView.prototype); +Entry.Scroller = function(b, a, c) { + this._horizontal = void 0 === a ? !0 : a; this._vertical = void 0 === c ? !0 : c; - this.board = a; + this.board = b; this.svgGroup = null; this.vRatio = this.vY = this.vWidth = this.hRatio = this.hX = this.hWidth = 0; this._visible = !0; @@ -18184,93 +17708,93 @@ Entry.Scroller = function(a, b, c) { this._scrollCommand = _.debounce(Entry.do, 200); }; Entry.Scroller.RADIUS = 7; -(function(a) { - a.createScrollBar = function() { - var a = Entry.Scroller.RADIUS, c = this; +(function(b) { + b.createScrollBar = function() { + var a = Entry.Scroller.RADIUS, b = this; this.svgGroup = this.board.svg.elem("g").attr({class:"boardScrollbar"}); this._horizontal && (this.hScrollbar = this.svgGroup.elem("rect", {height:2 * a, rx:a, ry:a}), this.hScrollbar.mousedown = function(a) { - function b(a) { + function e(a) { a.stopPropagation(); a.preventDefault(); a.originalEvent.touches && (a = a.originalEvent.touches[0]); - var d = c.dragInstance; - c.scroll((a.pageX - d.offsetX) / c.hRatio, 0); + var d = b.dragInstance; + b.scroll((a.pageX - d.offsetX) / b.hRatio, 0); d.set({offsetX:a.pageX, offsetY:a.pageY}); } function f(a) { $(document).unbind(".scroll"); - delete c.dragInstance; + delete b.dragInstance; } if (0 === a.button || a instanceof Touch) { Entry.documentMousedown && Entry.documentMousedown.notify(a); var g = $(document); - g.bind("mousemove.scroll", b); + g.bind("mousemove.scroll", e); g.bind("mouseup.scroll", f); - g.bind("touchmove.scroll", b); + g.bind("touchmove.scroll", e); g.bind("touchend.scroll", f); - c.dragInstance = new Entry.DragInstance({startX:a.pageX, startY:a.pageY, offsetX:a.pageX, offsetY:a.pageY}); + b.dragInstance = new Entry.DragInstance({startX:a.pageX, startY:a.pageY, offsetX:a.pageX, offsetY:a.pageY}); } a.stopPropagation(); }); this._vertical && (this.vScrollbar = this.svgGroup.elem("rect", {width:2 * a, rx:a, ry:a}), this.vScrollbar.mousedown = function(a) { - function b(a) { + function e(a) { a.stopPropagation(); a.preventDefault(); a.originalEvent.touches && (a = a.originalEvent.touches[0]); - var d = c.dragInstance; - c.scroll(0, (a.pageY - d.offsetY) / c.vRatio); + var d = b.dragInstance; + b.scroll(0, (a.pageY - d.offsetY) / b.vRatio); d.set({offsetX:a.pageX, offsetY:a.pageY}); } function f(a) { $(document).unbind(".scroll"); - delete c.dragInstance; + delete b.dragInstance; } if (0 === a.button || a instanceof Touch) { Entry.documentMousedown && Entry.documentMousedown.notify(a); var g = $(document); - g.bind("mousemove.scroll", b); + g.bind("mousemove.scroll", e); g.bind("mouseup.scroll", f); - g.bind("touchmove.scroll", b); + g.bind("touchmove.scroll", e); g.bind("touchend.scroll", f); - c.dragInstance = new Entry.DragInstance({startX:a.pageX, startY:a.pageY, offsetX:a.pageX, offsetY:a.pageY}); + b.dragInstance = new Entry.DragInstance({startX:a.pageX, startY:a.pageY, offsetX:a.pageX, offsetY:a.pageY}); } a.stopPropagation(); }); }; - a.updateScrollBar = function(a, c) { + b.updateScrollBar = function(a, b) { this._horizontal && (this.hX += a * this.hRatio, this.hScrollbar.attr({x:this.hX})); - this._vertical && (this.vY += c * this.vRatio, this.vScrollbar.attr({y:this.vY})); + this._vertical && (this.vY += b * this.vRatio, this.vScrollbar.attr({y:this.vY})); }; - a.scroll = function(a, c) { + b.scroll = function(a, b) { if (this.board.code) { var d = this.board.svgBlockGroup.getBoundingClientRect(), e = this.board.svgDom, f = d.left - this.board.offset().left, g = d.top - this.board.offset().top, h = d.height; a = Math.max(-d.width + Entry.BOARD_PADDING - f, a); - c = Math.max(-h + Entry.BOARD_PADDING - g, c); + b = Math.max(-h + Entry.BOARD_PADDING - g, b); a = Math.min(e.width() - Entry.BOARD_PADDING - f, a); - c = Math.min(e.height() - Entry.BOARD_PADDING - g, c); - this._scroll(a, c); + b = Math.min(e.height() - Entry.BOARD_PADDING - g, b); + this._scroll(a, b); this._diffs || (this._diffs = [0, 0]); this._diffs[0] += a; - this._diffs[1] += c; + this._diffs[1] += b; this._scrollCommand("scrollBoard", this._diffs[0], this._diffs[1], !0); } }; - a._scroll = function(a, c) { - this.board.code.moveBy(a, c); - this.updateScrollBar(a, c); + b._scroll = function(a, b) { + this.board.code.moveBy(a, b); + this.updateScrollBar(a, b); }; - a.setVisible = function(a) { + b.setVisible = function(a) { a != this.isVisible() && (this._visible = a, this.svgGroup.attr({display:!0 === a ? "block" : "none"})); }; - a.isVisible = function() { + b.isVisible = function() { return this._visible; }; - a.setOpacity = function(a) { + b.setOpacity = function(a) { this._opacity != a && (this.hScrollbar.attr({opacity:a}), this.vScrollbar.attr({opacity:a}), this._opacity = a); }; - a.resizeScrollBar = function() { + b.resizeScrollBar = function() { if (this._visible) { - var a = this.board, c = a.svgBlockGroup.getBoundingClientRect(), d = a.svgDom, e = d.width(), d = d.height(), f = c.left - a.offset().left, a = c.top - a.offset().top, g = c.width, c = c.height; + var a = this.board, b = a.svgBlockGroup.getBoundingClientRect(), d = a.svgDom, e = d.width(), d = d.height(), f = b.left - a.offset().left, a = b.top - a.offset().top, g = b.width, b = b.height; if (this._horizontal) { var h = -g + Entry.BOARD_PADDING, k = e - Entry.BOARD_PADDING, g = (e + 2 * Entry.Scroller.RADIUS) * g / (k - h + g); isNaN(g) && (g = 0); @@ -18278,19 +17802,19 @@ Entry.Scroller.RADIUS = 7; this.hScrollbar.attr({width:g, x:this.hX, y:d - 2 * Entry.Scroller.RADIUS}); this.hRatio = (e - g - 2 * Entry.Scroller.RADIUS) / (k - h); } - this._vertical && (f = -c + Entry.BOARD_PADDING, g = d - Entry.BOARD_PADDING, c = (d + 2 * Entry.Scroller.RADIUS) * c / (g - f + c), this.vY = (a - f) / (g - f) * (d - c - 2 * Entry.Scroller.RADIUS), this.vScrollbar.attr({height:c, y:this.vY, x:e - 2 * Entry.Scroller.RADIUS}), this.vRatio = (d - c - 2 * Entry.Scroller.RADIUS) / (g - f)); + this._vertical && (f = -b + Entry.BOARD_PADDING, g = d - Entry.BOARD_PADDING, b = (d + 2 * Entry.Scroller.RADIUS) * b / (g - f + b), this.vY = (a - f) / (g - f) * (d - b - 2 * Entry.Scroller.RADIUS), this.vScrollbar.attr({height:b, y:this.vY, x:e - 2 * Entry.Scroller.RADIUS}), this.vRatio = (d - b - 2 * Entry.Scroller.RADIUS) / (g - f)); } }; - a._bindEvent = function() { + b._bindEvent = function() { var a = _.debounce(this.resizeScrollBar, 200); this.board.changeEvent.attach(this, a); Entry.windowResized && Entry.windowResized.attach(this, a); }; })(Entry.Scroller.prototype); -Entry.Board = function(a) { +Entry.Board = function(b) { Entry.Model(this, !1); this.changeEvent = new Entry.Event(this); - this.createView(a); + this.createView(b); this.updateOffset(); this.scroller = new Entry.Scroller(this, !0, !0); this._magnetMap = {}; @@ -18304,18 +17828,18 @@ Entry.Board = function(a) { Entry.Board.OPTION_PASTE = 0; Entry.Board.OPTION_ALIGN = 1; Entry.Board.OPTION_CLEAR = 2; -(function(a) { - a.schema = {code:null, dragBlock:null, magnetedBlockView:null, selectedBlockView:null}; - a.createView = function(a) { - var c = a.dom, c = "string" === typeof c ? $("#" + c) : $(c); - if ("DIV" !== c.prop("tagName")) { +(function(b) { + b.schema = {code:null, dragBlock:null, magnetedBlockView:null, selectedBlockView:null}; + b.createView = function(a) { + var b = a.dom, b = "string" === typeof b ? $("#" + b) : $(b); + if ("DIV" !== b.prop("tagName")) { return console.error("Dom is not div element"); } - this.view = c; + this.view = b; this._svgId = "play" + (new Date).getTime(); this.workspace = a.workspace; this._activatedBlockView = null; - this.wrapper = Entry.Dom("div", {parent:c, class:"entryBoardWrapper"}); + this.wrapper = Entry.Dom("div", {parent:b, class:"entryBoardWrapper"}); this.svgDom = Entry.Dom($(''), {parent:this.wrapper}); this.visible = !0; var d = this; @@ -18334,16 +17858,16 @@ Entry.Board.OPTION_CLEAR = 2; this.patternRect = a.rect; this.pattern = a.pattern; }; - a.changeCode = function(a) { + b.changeCode = function(a) { this.code && this.codeListener && this.code.changeEvent.detach(this.codeListener); this.set({code:a}); - var c = this; + var b = this; a && (this.codeListener = this.code.changeEvent.attach(this, function() { - c.changeEvent.notify(); + b.changeEvent.notify(); }), a.createView(this)); this.scroller.resizeScrollBar(); }; - a.bindCodeView = function(a) { + b.bindCodeView = function(a) { this.svgBlockGroup.remove(); this.svgThreadGroup.remove(); this.svgBlockGroup = a.svgBlockGroup; @@ -18351,7 +17875,7 @@ Entry.Board.OPTION_CLEAR = 2; this.svgGroup.appendChild(this.svgThreadGroup); this.svgGroup.appendChild(this.svgBlockGroup); }; - a.setMagnetedBlock = function(a, c) { + b.setMagnetedBlock = function(a, b) { if (this.magnetedBlockView) { if (this.magnetedBlockView === a) { return; @@ -18359,40 +17883,40 @@ Entry.Board.OPTION_CLEAR = 2; this.magnetedBlockView.set({magneting:!1}); } this.set({magnetedBlockView:a}); - a && (a.set({magneting:c}), a.dominate()); + a && (a.set({magneting:b}), a.dominate()); }; - a.getCode = function() { + b.getCode = function() { return this.code; }; - a.findById = function(a) { + b.findById = function(a) { return this.code.findById(a); }; - a._addControl = function() { - var a = this.svgDom, c = this; + b._addControl = function() { + var a = this.svgDom, b = this; a.mousedown(function() { - c.onMouseDown.apply(c, arguments); + b.onMouseDown.apply(b, arguments); }); a.bind("touchstart", function() { - c.onMouseDown.apply(c, arguments); + b.onMouseDown.apply(b, arguments); }); a.on("wheel", function() { - c.mouseWheel.apply(c, arguments); + b.mouseWheel.apply(b, arguments); }); - var d = c.scroller; + var d = b.scroller; d && (a.mouseenter(function(a) { d.setOpacity(1); }), a.mouseleave(function(a) { d.setOpacity(0); })); }; - a.onMouseDown = function(a) { - function c(a) { + 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 b = f.dragInstance; - f.scroller.scroll(a.pageX - b.offsetX, a.pageY - b.offsetY); - b.set({offsetX:a.pageX, offsetY:a.pageY}); + var c = f.dragInstance; + f.scroller.scroll(a.pageX - c.offsetX, a.pageY - c.offsetY); + c.set({offsetX:a.pageX, offsetY:a.pageY}); } function d(a) { $(document).unbind(".entryBoard"); @@ -18405,9 +17929,9 @@ Entry.Board.OPTION_CLEAR = 2; a = a.originalEvent && a.originalEvent.touches ? a.originalEvent.touches[0] : a; Entry.documentMousedown && Entry.documentMousedown.notify(a); var e = $(document); - e.bind("mousemove.entryBoard", c); + e.bind("mousemove.entryBoard", b); e.bind("mouseup.entryBoard", d); - e.bind("touchmove.entryBoard", c); + e.bind("touchmove.entryBoard", b); e.bind("touchend.entryBoard", d); this.dragInstance = new Entry.DragInstance({startX:a.pageX, startY:a.pageY, offsetX:a.pageX, offsetY:a.pageY}); } else { @@ -18426,34 +17950,34 @@ Entry.Board.OPTION_CLEAR = 2; var f = this; } }; - a.mouseWheel = function(a) { + b.mouseWheel = function(a) { a = a.originalEvent; a.preventDefault(); - var c = Entry.disposeEvent; - c && c.notify(a); + var b = Entry.disposeEvent; + b && b.notify(a); this.scroller.scroll(a.wheelDeltaX || -a.deltaX, a.wheelDeltaY || -a.deltaY); }; - a.setSelectedBlock = function(a) { - var c = this.selectedBlockView; - c && c.removeSelected(); + b.setSelectedBlock = function(a) { + var b = this.selectedBlockView; + b && b.removeSelected(); a instanceof Entry.BlockView ? a.addSelected() : a = null; this.set({selectedBlockView:a}); }; - a._keyboardControl = function(a) { - var c = this.selectedBlockView; - c && 46 == a.keyCode && c.block && (Entry.do("destroyBlock", c.block), this.set({selectedBlockView:null})); + b._keyboardControl = function(a) { + var b = this.selectedBlockView; + b && 46 == a.keyCode && b.block && (Entry.do("destroyBlock", b.block), this.set({selectedBlockView:null})); }; - a.hide = function() { + b.hide = function() { this.wrapper.addClass("entryRemove"); this.visible = !1; }; - a.show = function() { + b.show = function() { this.wrapper.removeClass("entryRemove"); this.visible = !0; }; - a.alignThreads = function() { - for (var a = this.svgDom.height(), c = this.code.getThreads(), d = 15, e = 0, a = a - 30, f = 50, g = 0;g < c.length;g++) { - var h = c[g].getFirstBlock(); + b.alignThreads = function() { + for (var a = this.svgDom.height(), b = this.code.getThreads(), d = 15, e = 0, a = a - 30, f = 50, g = 0;g < b.length;g++) { + var h = b[g].getFirstBlock(); if (h) { var h = h.view, k = h.svgGroup.getBBox(), l = d + 15; l > a && (f = f + e + 10, e = 0, d = 15); @@ -18465,48 +17989,48 @@ Entry.Board.OPTION_CLEAR = 2; } this.scroller.resizeScrollBar(); }; - a.clear = function() { + b.clear = function() { this.svgBlockGroup.remove(); this.svgThreadGroup.remove(); }; - a.updateOffset = function() { + b.updateOffset = function() { this._offset = this.svg.getBoundingClientRect(); - var a = $(window), c = a.scrollTop(), a = a.scrollLeft(), d = this._offset; - this.relativeOffset = {top:d.top - c, left:d.left - a}; + var a = $(window), b = a.scrollTop(), a = a.scrollLeft(), d = this._offset; + this.relativeOffset = {top:d.top - b, left:d.left - a}; this.btnWrapper && this.btnWrapper.attr({transform:"translate(" + (d.width / 2 - 65) + "," + (d.height - 200) + ")"}); }; - a.generateButtons = function() { - var a = this, c = this.svgGroup.elem("g"); - this.btnWrapper = c; - var d = c.elem("text", {x:27, y:33, class:"entryFunctionButtonText"}); + b.generateButtons = function() { + var a = this, b = this.svgGroup.elem("g"); + this.btnWrapper = b; + var d = b.elem("text", {x:27, y:33, class:"entryFunctionButtonText"}); d.textContent = Lang.Buttons.save; - var e = c.elem("text", {x:102.5, y:33, class:"entryFunctionButtonText"}); + var e = b.elem("text", {x:102.5, y:33, class:"entryFunctionButtonText"}); e.textContent = Lang.Buttons.cancel; - var f = c.elem("circle", {cx:27.5, cy:27.5, r:27.5, class:"entryFunctionButton"}), c = c.elem("circle", {cx:102.5, cy:27.5, r:27.5, class:"entryFunctionButton"}); + var f = b.elem("circle", {cx:27.5, cy:27.5, r:27.5, class:"entryFunctionButton"}), b = b.elem("circle", {cx:102.5, cy:27.5, r:27.5, class:"entryFunctionButton"}); $(f).bind("mousedown touchstart", function() { a.save(); }); $(d).bind("mousedown touchstart", function() { a.save(); }); - $(c).bind("mousedown touchstart", function() { + $(b).bind("mousedown touchstart", function() { a.cancelEdit(); }); $(e).bind("mousedown touchstart", function() { a.cancelEdit(); }); }; - a.cancelEdit = function() { + b.cancelEdit = function() { this.workspace.setMode(Entry.Workspace.MODE_BOARD, "cancelEdit"); }; - a.save = function() { + b.save = function() { this.workspace.setMode(Entry.Workspace.MODE_BOARD, "save"); }; - a.generateCodeMagnetMap = function() { + b.generateCodeMagnetMap = function() { var a = this.code; if (a && this.dragBlock) { - for (var c in this.dragBlock.magnet) { - var d = this._getCodeBlocks(a, c); + for (var b in this.dragBlock.magnet) { + var d = this._getCodeBlocks(a, b); d.sort(function(a, b) { return a.point - b.point; }); @@ -18521,45 +18045,44 @@ Entry.Board.OPTION_CLEAR = 2; f.endPoint = Number.MAX_VALUE; d[e - 1].endPoint = f.point; } - this._magnetMap[c] = d; + this._magnetMap[b] = d; } } }; - a._getCodeBlocks = function(a, c) { - a = a.getThreads(); - var d = [], e; - switch(c) { + b._getCodeBlocks = function(a, b) { + var d = a.getThreads(), e = [], f; + switch(b) { case "previous": - e = this._getNextMagnets; + f = this._getNextMagnets; break; case "next": - e = this._getPreviousMagnets; + f = this._getPreviousMagnets; break; case "string": - e = this._getFieldMagnets; + f = this._getFieldMagnets; break; case "boolean": - e = this._getFieldMagnets; + f = this._getFieldMagnets; break; case "param": - e = this._getOutputMagnets; + f = this._getOutputMagnets; break; default: return []; } - for (var f = 0;f < a.length;f++) { - var g = a[f], d = d.concat(e.call(this, g, g.view.zIndex, null, c)) + for (var g = 0;g < d.length;g++) { + var h = d[g], e = e.concat(f.call(this, h, h.view.zIndex, null, b)) } - return d; + return e; }; - a._getNextMagnets = function(a, c, d, e) { + b._getNextMagnets = function(a, b, d, e) { var f = a.getBlocks(), g = [], h = []; d || (d = {x:0, y:0}); var k = d.x; d = d.y; for (var l = 0;l < f.length;l++) { var n = f[l], m = n.view; - m.zIndex = c; + m.zIndex = b; if (m.dragInstance) { break; } @@ -18567,37 +18090,37 @@ Entry.Board.OPTION_CLEAR = 2; k += m.x; a = d + 1; m.magnet.next && (a += m.height, h.push({point:d, endPoint:a, startBlock:n, blocks:[]}), h.push({point:a, blocks:[]}), m.absX = k); - n.statements && (c += .01); + n.statements && (b += .01); for (var q = 0;q < n.statements.length;q++) { a = n.statements[q]; var r = n.view._statements[q]; - r.zIndex = c; + r.zIndex = b; r.absX = k + r.x; h.push({point:r.y + d - 30, endPoint:r.y + d, startBlock:r, blocks:[]}); h.push({point:r.y + d + r.height, blocks:[]}); - c += .01; - g = g.concat(this._getNextMagnets(a, c, {x:r.x + k, y:r.y + d}, e)); + b += .01; + g = g.concat(this._getNextMagnets(a, b, {x:r.x + k, y:r.y + d}, e)); } m.magnet.next && (d += m.magnet.next.y, k += m.magnet.next.x); } return g.concat(h); }; - a._getPreviousMagnets = function(a, c, d, e) { + b._getPreviousMagnets = function(a, b, d, e) { var f = a.getBlocks(); a = []; d || (d = {x:0, y:0}); e = d.x; d = d.y; var f = f[0], g = f.view; - g.zIndex = c; + g.zIndex = b; if (g.dragInstance) { return []; } d += g.y - 15; e += g.x; - return g.magnet.previous ? (c = d + 1 + g.height, a.push({point:d, endPoint:c, startBlock:f, blocks:[]}), a.push({point:c, blocks:[]}), g.absX = e, a) : []; + return g.magnet.previous ? (b = d + 1 + g.height, a.push({point:d, endPoint:b, startBlock:f, blocks:[]}), a.push({point:b, blocks:[]}), g.absX = e, a) : []; }; - a._getFieldMagnets = function(a, c, d, e) { + b._getFieldMagnets = function(a, b, d, e) { var f = a.getBlocks(), g = [], h = []; d || (d = {x:0, y:0}); var k = d.x; @@ -18607,20 +18130,20 @@ Entry.Board.OPTION_CLEAR = 2; if (m.dragInstance) { break; } - m.zIndex = c; + m.zIndex = b; d += m.y; k += m.x; - h = h.concat(this._getFieldBlockMetaData(m, k, d, c, e)); - n.statements && (c += .01); + h = h.concat(this._getFieldBlockMetaData(m, k, d, b, e)); + n.statements && (b += .01); for (var q = 0;q < n.statements.length;q++) { a = n.statements[q]; - var r = n.view._statements[q], g = g.concat(this._getFieldMagnets(a, c, {x:r.x + k, y:r.y + d}, e)); + var r = n.view._statements[q], g = g.concat(this._getFieldMagnets(a, b, {x:r.x + k, y:r.y + d}, e)); } m.magnet.next && (d += m.magnet.next.y, k += m.magnet.next.x); } return g.concat(h); }; - a._getFieldBlockMetaData = function(a, c, d, e, f) { + b._getFieldBlockMetaData = function(a, b, d, e, f) { var g = a._contents, h = []; d += a.contentPos.y; for (var k = 0;k < g.length;k++) { @@ -18628,7 +18151,7 @@ Entry.Board.OPTION_CLEAR = 2; if (l instanceof Entry.FieldBlock) { var n = l._valueBlock; if (!n.view.dragInstance && (l.acceptType === f || "boolean" === l.acceptType)) { - var m = c + l.box.x, q = d + l.box.y + a.contentHeight % 1E3 * -.5, r = d + l.box.y + l.box.height; + var m = b + l.box.x, q = d + l.box.y + a.contentHeight % 1E3 * -.5, r = d + l.box.y + l.box.height; l.acceptType === f && (h.push({point:q, endPoint:r, startBlock:n, blocks:[]}), h.push({point:r, blocks:[]})); l = n.view; l.absX = m; @@ -18639,7 +18162,7 @@ Entry.Board.OPTION_CLEAR = 2; } return h; }; - a._getOutputMagnets = function(a, c, d, e) { + b._getOutputMagnets = function(a, b, d, e) { var f = a.getBlocks(), g = [], h = []; d || (d = {x:0, y:0}); var k = d.x; @@ -18649,35 +18172,35 @@ Entry.Board.OPTION_CLEAR = 2; if (m.dragInstance) { break; } - m.zIndex = c; + m.zIndex = b; d += m.y; k += m.x; - h = h.concat(this._getOutputMetaData(m, k, d, c, e)); - n.statements && (c += .01); + h = h.concat(this._getOutputMetaData(m, k, d, b, e)); + n.statements && (b += .01); for (var q = 0;q < n.statements.length;q++) { a = n.statements[q]; - var r = n.view._statements[q], g = g.concat(this._getOutputMagnets(a, c, {x:r.x + k, y:r.y + d}, e)); + var r = n.view._statements[q], g = g.concat(this._getOutputMagnets(a, b, {x:r.x + k, y:r.y + d}, e)); } m.magnet.next && (d += m.magnet.next.y, k += m.magnet.next.x); } return g.concat(h); }; - a._getOutputMetaData = function(a, c, d, e, f) { + b._getOutputMetaData = function(a, b, d, e, f) { var g = a._contents, h = []; - c += a.contentPos.x; + b += a.contentPos.x; d += a.contentPos.y; for (a = 0;a < g.length;a++) { - var k = g[a], l = c + k.box.x, n = d - 24, m = d; + var k = g[a], l = b + k.box.x, n = d - 24, m = d; k instanceof Entry.FieldBlock ? (k.acceptType === f && (h.push({point:n, endPoint:m, startBlock:k, blocks:[]}), h.push({point:m, blocks:[]}), k.absX = l, k.zIndex = e, k.width = 20), (n = k._valueBlock) && (h = h.concat(this._getOutputMetaData(n.view, l, d + k.box.y, e + .01, f)))) : k instanceof Entry.FieldOutput && k.acceptType === f && (h.push({point:n, endPoint:m, startBlock:k, blocks:[]}), h.push({point:m, blocks:[]}), k.absX = l, k.zIndex = e, k.width = 20, (n = k._valueBlock) && (n.view.dragInstance || - (h = h.concat(this._getOutputMetaData(n.view, c + k.box.x, d + k.box.y, e + .01, f))))); + (h = h.concat(this._getOutputMetaData(n.view, b + k.box.x, d + k.box.y, e + .01, f))))); } return h; }; - a.getNearestMagnet = function(a, c, d) { + b.getNearestMagnet = function(a, b, d) { var e = this._magnetMap[d]; if (e && 0 !== e.length) { - var f = 0, g = e.length - 1, h, k = null, l = "previous" === d ? c - 15 : c; - for (c = -1 < ["previous", "next"].indexOf(d) ? 20 : 0;f <= g;) { + var f = 0, g = e.length - 1, h, k = null, l = "previous" === d ? b - 15 : b; + for (b = -1 < ["previous", "next"].indexOf(d) ? 20 : 0;f <= g;) { if (h = (f + g) / 2 | 0, d = e[h], l < d.point) { g = h - 1; } else { @@ -18686,7 +18209,7 @@ Entry.Board.OPTION_CLEAR = 2; } else { e = d.blocks; for (f = 0;f < e.length;f++) { - if (g = e[f].view, g.absX - c < a && a < g.absX + g.width && (g = d.blocks[f], !k || k.view.zIndex < g.view.zIndex)) { + if (g = e[f].view, g.absX - b < a && a < g.absX + g.width && (g = d.blocks[f], !k || k.view.zIndex < g.view.zIndex)) { k = d.blocks[f]; } } @@ -18697,48 +18220,48 @@ Entry.Board.OPTION_CLEAR = 2; return null; } }; - a.dominate = function(a) { + b.dominate = function(a) { a && (a = a.getFirstBlock()) && (this.svgBlockGroup.appendChild(a.view.svgGroup), this.code.dominate(a.thread)); }; - a.setPatternRectFill = function(a) { + b.setPatternRectFill = function(a) { this.patternRect.attr({fill:a}); this.pattern.attr({style:""}); }; - a.disablePattern = function() { + b.disablePattern = function() { this.pattern.attr({style:"display: none"}); }; - a._removeActivated = function() { + b._removeActivated = function() { this._activatedBlockView && (this._activatedBlockView.removeActivated(), this._activatedBlockView = null); }; - a.activateBlock = function(a) { + b.activateBlock = function(a) { a = a.view; - var c = a.getAbsoluteCoordinate(), d = this.svgDom, e = c.x, c = c.y, e = d.width() / 2 - e, d = d.height() / 2 - c - 100; + var b = a.getAbsoluteCoordinate(), d = this.svgDom, e = b.x, b = b.y, e = d.width() / 2 - e, d = d.height() / 2 - b - 100; this.scroller.scroll(e, d); a.addActivated(); this._activatedBlockView = a; }; - a.reDraw = function() { + b.reDraw = function() { this.code.view.reDraw(); }; - a.separate = function(a, c) { + b.separate = function(a, b) { "string" === typeof a && (a = this.findById(a)); a.view && a.view._toGlobalCoordinate(); var d = a.getPrevBlock(); - a.separate(c); + a.separate(b); d && d.getNextBlock() && d.getNextBlock().view.bindPrev(); }; - a.insert = function(a, c, d) { + b.insert = function(a, b, d) { "string" === typeof a && (a = this.findById(a)); this.separate(a, d); - 3 === c.length ? a.moveTo(c[0], c[1]) : 4 === c.length && 0 === c[3] ? (c = this.code.getThreads()[c[2]], a.thread.cut(a), c.insertToTop(a), a.getNextBlock().view.bindPrev()) : (c = c instanceof Array ? this.code.getTargetByPointer(c) : c, c instanceof Entry.Block ? ("basic" === a.getBlockType() && a.view.bindPrev(c), a.doInsert(c)) : c instanceof Entry.FieldStatement ? (a.view.bindPrev(c), c.insertTopBlock(a)) : a.doInsert(c)); + 3 === b.length ? a.moveTo(b[0], b[1]) : 4 === b.length && 0 === b[3] ? (b = this.code.getThreads()[b[2]], a.thread.cut(a), b.insertToTop(a), a.getNextBlock().view.bindPrev()) : (b = b instanceof Array ? this.code.getTargetByPointer(b) : b, b instanceof Entry.Block ? ("basic" === a.getBlockType() && a.view.bindPrev(b), a.doInsert(b)) : b instanceof Entry.FieldStatement ? (a.view.bindPrev(b), b.insertTopBlock(a)) : a.doInsert(b)); }; - a.adjustThreadsPosition = function() { + b.adjustThreadsPosition = function() { var a = this.code; a && (a = a.getThreads()) && 0 !== a.length && (a = a.sort(function(a, b) { return a.getFirstBlock().view.x - b.getFirstBlock().view.x; }), a = a[0].getFirstBlock()) && (a = a.view, a = a.getAbsoluteCoordinate(), this.scroller.scroll(50 - a.x, 30 - a.y)); }; - a._initContextOptions = function() { + b._initContextOptions = function() { var a = this; this._contextOptions = [{activated:!0, option:{text:"\ubd99\uc5ec\ub123\uae30", enable:!!Entry.clipboard, callback:function() { Entry.do("addThread", Entry.clipboard).value.getFirstBlock().copyToClipboard(); @@ -18748,13 +18271,13 @@ Entry.Board.OPTION_CLEAR = 2; a.code.clear(); }}}]; }; - a.activateContextOption = function(a) { + b.activateContextOption = function(a) { this._contextOptions[a].activated = !0; }; - a.deActivateContextOption = function(a) { + b.deActivateContextOption = function(a) { this._contextOptions[a].activated = !1; }; - a._bindEvent = function() { + b._bindEvent = function() { Entry.documentMousedown && (Entry.documentMousedown.attach(this, this.setSelectedBlock), Entry.documentMousedown.attach(this, this._removeActivated)); Entry.keyPressed && Entry.keyPressed.attach(this, this._keyboardControl); if (Entry.windowResized) { @@ -18762,1606 +18285,2004 @@ Entry.Board.OPTION_CLEAR = 2; Entry.windowResized.attach(this, a); } }; - a.offset = function() { + b.offset = function() { (!this._offset || 0 === this._offset.top && 0 === this._offset.left) && this.updateOffset(); return this._offset; }; })(Entry.Board.prototype); -Entry.Code = function(a, b) { - Entry.Model(this, !1); - b && (this.object = b); +Entry.skeleton = function() { +}; +Entry.skeleton.basic = {path:function(b) { + var a = b.contentWidth; + b = b.contentHeight; + b = Math.max(30, b + 2); + a = Math.max(0, a + 9 - b / 2); + return "m -8,0 l 8,8 8,-8 h %w a %h,%h 0 0,1 0,%wh h -%w l -8,8 -8,-8 v -%wh z".replace(/%wh/gi, b).replace(/%w/gi, a).replace(/%h/gi, b / 2); +}, box:function(b) { + return {offsetX:-8, offsetY:0, width:(b ? b.contentWidth : 150) + 30, height:Math.max(30, (b ? b.contentHeight : 28) + 2), marginBottom:0}; +}, magnets:function(b) { + return {previous:{x:0, y:0}, next:{x:0, y:(b ? Math.max(b.height, 30) : 30) + 1 + b.offsetY}}; +}, contentPos:function(b) { + return {x:14, y:Math.max(b.contentHeight, 28) / 2 + 1}; +}}; +Entry.skeleton.basic_create = {path:function(b) { + var a = b.contentWidth; + b = b.contentHeight; + b = Math.max(30, b + 2); + a = Math.max(0, a + 9 - b / 2); + return "m -8,0 l 16,0 h %w a %h,%h 0 0,1 0,%wh h -%w l -8,8 -8,-8 v -%wh z".replace(/%wh/gi, b).replace(/%w/gi, a).replace(/%h/gi, b / 2); +}, box:function(b) { + return {offsetX:-8, offsetY:0, width:(b ? b.contentWidth : 150) + 30, height:Math.max(30, (b ? b.contentHeight : 28) + 2), marginBottom:0}; +}, magnets:function(b) { + return {next:{x:0, y:(b ? Math.max(b.height, 30) : 30) + 1 + b.offsetY}}; +}, contentPos:function(b) { + return {x:14, y:Math.max(b.contentHeight, 28) / 2 + 1}; +}}; +Entry.skeleton.basic_event = {path:function(b) { + b = b.contentWidth; + b = Math.max(0, b); + return "m -8,0 m 0,-5 a 19.5,19.5 0, 0,1 16,0 c 10,5 15,5 20,5 h %w a 15,15 0 0,1 0,30 H 8 l -8,8 -8,-8 l 0,0.5 a 19.5,19.5 0, 0,1 0,-35 z".replace(/%w/gi, b - 30); +}, box:function(b) { + return {offsetX:-19, offsetY:-7, width:b.contentWidth + 30, height:30, marginBottom:0}; +}, magnets:function(b) { + return {next:{x:0, y:(b ? Math.max(b.height + b.offsetY + 7, 30) : 30) + 1}}; +}, contentPos:function(b) { + return {x:1, y:15}; +}}; +Entry.skeleton.basic_loop = {path:function(b) { + var a = b.contentWidth, c = b.contentHeight, c = Math.max(30, c + 2), a = Math.max(0, a + 9 - c / 2); + b = b._statements[0] ? b._statements[0].height : 20; + b = Math.max(b, 20); + return "m -8,0 l 8,8 8,-8 h %w a %h,%h 0 0,1 0,%wh H 24 l -8,8 -8,-8 h -0.4 v %sh h 0.4 l 8,8 8,-8 h %bw a 8,8 0 0,1 0,16 H 8 l -8,8 -8,-8 z".replace(/%wh/gi, c).replace(/%w/gi, a).replace(/%bw/gi, a - 8).replace(/%h/gi, c / 2).replace(/%sh/gi, b + 1); +}, magnets:function(b) { + var a = Math.max(b.contentHeight + 2, 30), c = b._statements[0] ? b._statements[0].height : 20, c = Math.max(c, 20); + return {previous:{x:0, y:0}, next:{x:0, y:c + a + 18 + b.offsetY}}; +}, box:function(b) { + var a = b.contentWidth, c = Math.max(b.contentHeight + 2, 30); + b = b._statements[0] ? b._statements[0].height : 20; + b = Math.max(b, 20); + return {offsetX:-8, offsetY:0, width:a + 30, height:c + b + 17, marginBottom:0}; +}, statementPos:function(b) { + return [{x:16, y:Math.max(30, b.contentHeight + 2) + 1}]; +}, contentPos:function(b) { + return {x:14, y:Math.max(b.contentHeight, 28) / 2 + 1}; +}}; +Entry.skeleton.basic_define = {path:function(b) { + var a = b.contentWidth, c = b.contentHeight, c = Math.max(30, c + 2), a = Math.max(0, a + 9 - c / 2); + b = b._statements[0] ? b._statements[0].height : 30; + b = Math.max(b, 20); + return "m -8,0 l 16,0 h %w a %h,%h 0 0,1 0,%wh H 24 l -8,8 -8,-8 h -0.4 v %sh h 0.4 l 8,8 8,-8 h %bw a 8,8 0 0,1 0,16 H -8 z".replace(/%wh/gi, c).replace(/%w/gi, a).replace(/%h/gi, c / 2).replace(/%bw/gi, a - 8).replace(/%sh/gi, b + 1); +}, magnets:function() { + return {}; +}, box:function(b) { + return {offsetX:0, offsetY:0, width:b.contentWidth, height:Math.max(b.contentHeight, 25) + 46, marginBottom:0}; +}, statementPos:function(b) { + return [{x:16, y:Math.max(30, b.contentHeight + 2)}]; +}, contentPos:function() { + return {x:14, y:15}; +}}; +Entry.skeleton.pebble_event = {path:function(b) { + return "m 0,0 a 25,25 0 0,1 9,48.3 a 9,9 0 0,1 -18,0 a 25,25 0 0,1 9,-48.3 z"; +}, box:function(b) { + return {offsetX:-25, offsetY:0, width:50, height:48.3, marginBottom:0}; +}, magnets:function(b) { + return {next:{x:0, y:(b ? Math.max(b.height, 49.3) : 49.3) + b.offsetY}}; +}, contentPos:function() { + return {x:0, y:25}; +}}; +Entry.skeleton.pebble_loop = {fontSize:16, dropdownHeight:23, path:function(b) { + b = Math.max(b._statements[0] ? b._statements[0].height : 50, 50); + return "M 0,9 a 9,9 0 0,0 9,-9 h %cw q 25,0 25,25 v %ch q 0,25 -25,25 h -%cw a 9,9 0 0,1 -18,0 h -%cw q -25,0 -25,-25 v -%ch q 0,-25 25,-25 h %cw a 9,9 0 0,0 9,9 M 0,49 a 9,9 0 0,1 -9,-9 h -28 a 25,25 0 0,0 -25,25 v %cih a 25,25 0 0,0 25,25 h 28 a 9,9 0 0,0 18,0 h 28 a 25,25 0 0,0 25,-25 v -%cih a 25,25 0 0,0 -25,-25 h -28 a 9,9 0 0,1 -9,9 z".replace(/%cw/gi, 41).replace(/%ch/gi, b + 4).replace(/%cih/gi, b - 50); +}, magnets:function(b) { + var a = Math.max(b.contentHeight + 2, 41), c = b._statements[0] ? b._statements[0].height : 20, c = Math.max(c, 51); + return {previous:{x:0, y:0}, next:{x:0, y:c + a + 13 + b.offsetY}}; +}, box:function(b) { + var a = b.contentWidth, c = Math.max(b.contentHeight + 2, 41); + b = b._statements[0] ? b._statements[0].height : 20; + b = Math.max(b, 51); + return {offsetX:-(a / 2 + 13), offsetY:0, width:a + 30, height:c + b + 13, marginBottom:0}; +}, statementPos:function(b) { + return [{x:0, y:Math.max(39, b.contentHeight + 2) + 1.5}]; +}, contentPos:function() { + return {x:-46, y:25}; +}}; +Entry.skeleton.pebble_basic = {fontSize:15, morph:["prev", "next"], path:function(b) { + return "m 0,9 a 9,9 0 0,0 9,-9 h 28 q 25,0 25,25q 0,25 -25,25h -28 a 9,9 0 0,1 -18,0 h -28 q -25,0 -25,-25q 0,-25 25,-25h 28 a 9,9 0 0,0 9,9 z"; +}, magnets:function(b) { + return {previous:{x:0, y:0}, next:{x:0, y:(b ? Math.max(b.height, 51) : 51) + b.offsetY}}; +}, box:function() { + return {offsetX:-62, offsetY:0, width:124, height:50, marginBottom:0}; +}, contentPos:function() { + return {x:-46, y:25}; +}}; +Entry.skeleton.basic_string_field = {path:function(b) { + var a = b.contentWidth; + b = b.contentHeight; + b = Math.max(18, b + 2); + a = Math.max(0, a - b + 12); + return "m %h,0 h %w a %h,%h 0 1,1 0,%wh H %h A %h,%h 0 1,1 %h,0 z".replace(/%wh/gi, b).replace(/%w/gi, a).replace(/%h/gi, b / 2); +}, color:"#000", outerLine:"#768dce", box:function(b) { + return {offsetX:0, offsetY:0, width:(b ? b.contentWidth : 5) + 12, height:Math.max((b ? b.contentHeight : 18) + 2, 18), marginBottom:0}; +}, magnets:function() { + return {string:{}}; +}, contentPos:function(b) { + return {x:6, y:Math.max(b.contentHeight, 16) / 2 + 1}; +}}; +Entry.skeleton.basic_boolean_field = {path:function(b) { + var a = b.contentWidth; + b = b.contentHeight; + b = Math.max(18, b + 2); + a = Math.max(0, a - b + 19); + return "m %h,0 h %w l %h,%h -%h,%h H %h l -%h,-%h %h,-%h z".replace(/%wh/gi, b).replace(/%w/gi, a).replace(/%h/gi, b / 2); +}, color:"#000", outerLine:"#768dce", box:function(b) { + return {offsetX:0, offsetY:0, width:(b ? b.contentWidth : 5) + 19, height:Math.max((b ? b.contentHeight : 18) + 2, 18), marginBottom:0}; +}, magnets:function() { + return {boolean:{}}; +}, contentPos:function(b) { + return {x:10, y:Math.max(b.contentHeight, 16) / 2 + 1}; +}}; +Entry.skeleton.basic_param = {path:function(b) { + var a = b.contentWidth; + (b = b._contents[b._contents.length - 1]) && (a -= b.box.width + Entry.BlockView.PARAM_SPACE - 2); + a = Math.max(0, a); + return "m 4,0 h 10 h %w l 2,2 0,3 3,0 1,1 0,12 -1,1 -3,0 0,3 -2,2h -%w h -10 l -2,-2 0,-3 3,0 1,-1 0,-12 -1,-1 -3,0 0,-3 2,-2".replace(/%w/gi, a); +}, outerLine:"#768dce", box:function(b) { + return {offsetX:0, offsetY:0, width:(b ? b.contentWidth : 5) + 11, height:24, marginBottom:0}; +}, magnets:function() { + return {param:{}}; +}, contentPos:function(b) { + return {x:11, y:12}; +}}; +Entry.skeleton.basic_button = {path:function() { + return "m -64,0 h 128 a 6,6 0, 0,1 6,6 v 18 a 6,6 0, 0,1 -6,6 h -128 a 6,6 0, 0,1 -6,-6 v -18 a 6,6 0, 0,1 6,-6 z"; +}, box:function() { + return {offsetX:-80, offsetY:0, width:140, height:30}; +}, contentPos:function() { + return {x:0, y:15}; +}, movable:!1, readOnly:!0, nextShadow:!0, classes:["basicButtonView"]}; +Entry.skeleton.basic_without_next = {box:Entry.skeleton.basic.box, contentPos:Entry.skeleton.basic.contentPos, path:function(b) { + var a = b.contentWidth; + b = b.contentHeight; + b = Math.max(30, b + 2); + a = Math.max(0, a + 9 - b / 2); + return "m -8,0 l 8,8 8,-8 h %w a %h,%h 0 0,1 0, %wh H -8 z".replace(/%wh/gi, b).replace(/%w/gi, a).replace(/%h/gi, b / 2); +}, magnets:function(b) { + return {previous:{x:0, y:0}}; +}}; +Entry.skeleton.basic_double_loop = {path:function(b) { + var a = b.contentWidth, c = b.contentHeight % 1E3, d = Math.floor(b.contentHeight / 1E3), c = Math.max(30, c + 2), d = Math.max(30, d + 2), a = Math.max(0, a + 5 - c / 2), e = b._statements; + b = e[0] ? e[0].height : 20; + e = e[1] ? e[1].height : 20; + b = Math.max(b, 20); + e = Math.max(e, 20); + return "m -8,0 l 8,8 8,-8 h %w a %h1,%h1 0 0,1 0,%wh1 H 24 l -8,8 -8,-8 h -0.4 v %sh1 h 0.4 l 8,8 8,-8 h %bw a %h2,%h2 0 0,1 0,%wh2 H 24 l -8,8 -8,-8 h -0.4 v %sh2 h 0.4 l 8,8 8,-8 h %bw a 8,8 0 0,1 0,16 H 8 l -8,8 -8,-8 z".replace(/%wh1/gi, c).replace(/%wh2/gi, d).replace(/%w/gi, a).replace(/%bw/gi, a - 8).replace(/%h1/gi, c / 2).replace(/%h2/gi, d / 2).replace(/%sh1/gi, b + 1).replace(/%sh2/gi, e + 1); +}, magnets:function(b) { + var a = Math.max(b.contentHeight % 1E3 + 2, 30), c = Math.max(Math.floor(b.contentHeight / 1E3) + 2, 30), d = b._statements[0] ? b._statements[0].height : 20, e = b._statements[1] ? b._statements[1].height : 20, d = Math.max(d, 20), e = Math.max(e, 20); + return {previous:{x:0, y:0}, next:{x:0, y:d + e + a + c + 19 + b.offsetY}}; +}, box:function(b) { + var a = b.contentWidth, c = Math.max(Math.floor(b.contentHeight / 1E3) + 2, 30), d = Math.max(b.contentHeight % 1E3 + 2, 30), e = b._statements[0] ? b._statements[0].height % 1E3 : 20; + b = b._statements[1] ? b._statements[1].height : 20; + e = Math.max(e, 20); + b = Math.max(b, 20); + return {offsetX:-8, offsetY:0, width:a + 30, height:c + d + e + b + 17, marginBottom:0}; +}, statementPos:function(b) { + var a = Math.max(30, b.contentHeight % 1E3 + 2) + 1; + return [{x:16, y:a}, {x:16, y:a + Math.max(b._statements[0] ? b._statements[0].height % 1E3 : 20, 20) + Math.max(Math.floor(b.contentHeight / 1E3) + 2, 30) + 1}]; +}, contentPos:function(b) { + return {x:14, y:Math.max(b.contentHeight % 1E3, 28) / 2 + 1}; +}}; +Entry.Thread = function(b, a, c) { this._data = new Entry.Collection; - this._eventMap = {}; - this._blockMap = {}; - this.executors = []; - this.executeEndEvent = new Entry.Event(this); + this._code = a; this.changeEvent = new Entry.Event(this); - this.changeEvent.attach(this, this._handleChange); - this._maxZIndex = 0; - this.load(a); + this.changeEvent.attach(this, this.handleChange); + this._event = null; + this.parent = c ? c : a; + this.load(b); }; -Entry.STATEMENT = 0; -Entry.PARAM = -1; -(function(a) { - a.schema = {view:null, board:null}; - a.load = function(a) { - a instanceof Array || (a = JSON.parse(a)); - this.clear(); - for (var c = 0;c < a.length;c++) { - this._data.push(new Entry.Thread(a[c], this)); - } - return this; - }; - a.clear = function() { - for (var a = this._data.length - 1;0 <= a;a--) { - this._data[a].destroy(!1); - } - this.clearExecutors(); - this._eventMap = {}; - }; - a.createView = function(a) { - null === this.view ? this.set({view:new Entry.CodeView(this, a), board:a}) : (this.set({board:a}), a.bindCodeView(this.view)); - }; - a.registerEvent = function(a, c) { - this._eventMap[c] || (this._eventMap[c] = []); - this._eventMap[c].push(a); - }; - a.unregisterEvent = function(a, c) { - (c = this._eventMap[c]) && 0 !== c.length && (a = c.indexOf(a), 0 > a || c.splice(a, 1)); - }; - a.raiseEvent = function(a, c, d) { - a = this._eventMap[a]; - var e = []; - if (void 0 !== a) { - for (var f = 0;f < a.length;f++) { - var g = a[f]; - if (void 0 === d || -1 < g.params.indexOf(d)) { - g = new Entry.Executor(a[f], c), this.executors.push(g), e.push(g); - } - } - return e; - } - }; - a.getEventMap = function(a) { - return this._eventMap[a]; - }; - a.map = function(a) { - this._data.map(a); - }; - a.tick = function() { - for (var a = this.executors, c = 0;c < a.length;c++) { - var d = a[c]; - d.isEnd() ? (a.splice(c--, 1), 0 === a.length && this.executeEndEvent.notify()) : d.execute(); - } - }; - a.removeExecutor = function(a) { - a = this.executors.indexOf(a); - -1 < a && this.executors.splice(a, 1); - }; - a.clearExecutors = function() { - this.executors.forEach(function(a) { - a.end(); - }); - this.executors = []; - }; - a.clearExecutorsByEntity = function(a) { - for (var c = this.executors, d = 0;d < c.length;d++) { - var e = c[d]; - e.entity === a && e.end(); - } - }; - a.addExecutor = function(a) { - this.executors.push(a); - }; - a.createThread = function(a, c) { +(function(b) { + b.load = function(a, b) { + void 0 === a && (a = []); if (!(a instanceof Array)) { - return console.error("blocks must be array"); - } - a = new Entry.Thread(a, this); - void 0 === c ? this._data.push(a) : this._data.insert(a, c); - return a; - }; - a.cloneThread = function(a, c) { - a = a.clone(this, c); - this._data.push(a); - return a; - }; - a.destroyThread = function(a, c) { - c = this._data; - a = c.indexOf(a); - 0 > a || c.splice(a, 1); - }; - a.doDestroyThread = function(a, c) { - c = this._data; - a = c.indexOf(a); - 0 > a || c.splice(a, 1); - }; - a.getThreads = function() { - return this._data.map(function(a) { - return a; - }); - }; - a.toJSON = function() { - for (var a = this.getThreads(), c = [], d = 0, e = a.length;d < e;d++) { - c.push(a[d].toJSON()); - } - return c; - }; - a.countBlock = function() { - for (var a = this.getThreads(), c = 0, d = 0;d < a.length;d++) { - c += a[d].countBlock(); - } - return c; - }; - a.moveBy = function(a, c) { - for (var d = this.getThreads(), e = 0, f = d.length;e < f;e++) { - var g = d[e].getFirstBlock(); - g && g.view._moveBy(a, c, !1); - } - a = this.board; - a instanceof Entry.BlockMenu && a.updateSplitters(c); - }; - a.stringify = function() { - return JSON.stringify(this.toJSON()); - }; - a.dominate = function(a) { - a.view.setZIndex(this._maxZIndex++); - }; - a.indexOf = function(a) { - return this._data.indexOf(a); - }; - a._handleChange = function() { - Entry.creationChangedEvent && Entry.creationChangedEvent.notify(); - }; - a.hasBlockType = function(a) { - for (var c = this.getThreads(), d = 0;d < c.length;d++) { - if (c[d].hasBlockType(a)) { - return !0; - } - } - return !1; - }; - a.findById = function(a) { - return this._blockMap[a]; - }; - a.registerBlock = function(a) { - this._blockMap[a.id] = a; - }; - a.unregisterBlock = function(a) { - delete this._blockMap[a.id]; - }; - a.getByPointer = function(a) { - a = a.concat(); - a.shift(); - a.shift(); - for (var c = this._data[a.shift()].getBlock(a.shift());a.length;) { - c instanceof Entry.Block || (c = c.getValueBlock()); - var d = a.shift(), e = a.shift(); - -1 < d ? c = c.statements[d].getBlock(e) : -1 === d && (c = c.view.getParam(e)); - } - return c; - }; - a.getTargetByPointer = function(a) { - a = a.concat(); - a.shift(); - a.shift(); - var c = this._data[a.shift()], d; - if (1 === a.length) { - d = c.getBlock(a.shift() - 1); - } else { - for (d = c.getBlock(a.shift());a.length;) { - d instanceof Entry.Block || (d = d.getValueBlock()); - var e = a.shift(), c = a.shift(); - -1 < e ? (d = d.statements[e], d = a.length ? d.getBlock(c) : 0 === c ? d.view.getParent() : d.getBlock(c - 1)) : -1 === e && (d = d.view.getParam(c)); - } - } - return d; - }; - a.getBlockList = function(a) { - for (var c = this.getThreads(), d = [], e = 0;e < c.length;e++) { - d = d.concat(c[e].getBlockList(a)); + return console.error("thread must be array"); } - return d; - }; -})(Entry.Code.prototype); -Entry.CodeView = function(a, b) { - Entry.Model(this, !1); - this.code = a; - this.set({board:b}); - this.svgThreadGroup = b.svgGroup.elem("g"); - this.svgThreadGroup.attr({class:"svgThreadGroup"}); - this.svgThreadGroup.board = b; - this.svgBlockGroup = b.svgGroup.elem("g"); - this.svgBlockGroup.attr({class:"svgBlockGroup"}); - this.svgBlockGroup.board = b; - b.bindCodeView(this); - this.code.map(function(a) { - a.createView(b); - }); - a.observe(this, "_setBoard", ["board"]); -}; -(function(a) { - a.schema = {board:null, scrollX:0, scrollY:0}; - a._setBoard = function() { - this.set({board:this.code.board}); - }; - a.reDraw = function() { - this.code.map(function(a) { - a.view.reDraw(); - }); - }; -})(Entry.CodeView.prototype); -Entry.ConnectionRipple = {}; -(function(a) { - a.createDom = function(a) { - this.svgDom || (this._ripple = a.getBoard().svgGroup.elem("circle", {cx:0, cy:0, r:0, stroke:"#888", "stroke-width":10})); + for (var d = 0;d < a.length;d++) { + var e = a[d]; + e instanceof Entry.Block || e.isDummy ? (e.setThread(this), this._data.push(e)) : this._data.push(new Entry.Block(e, this)); + } + (d = this._code.view) && this.createView(d.board, b); }; - a.setView = function(a) { - this._ripple || this.createDom(a); - var c = this._ripple, d = a.getBoard().svgGroup; - c.remove(); - a = a.getAbsoluteCoordinate(); - c.attr({cx:a.x, cy:a.y}); - d.appendChild(c); - c._startTime = new Date; - return this; + b.registerEvent = function(a, b) { + this._event = b; + this._code.registerEvent(a, b); }; - a.dispose = function() { - var a = this, c = this._ripple, d = (new Date - c._startTime) / 150; - 1 < d ? c.remove() : (c.attr({r:25 * d, opacity:1 - d}), window.setTimeout(function() { - a.dispose(); - }, 10)); + b.unregisterEvent = function(a, b) { + this._code.unregisterEvent(a, b); }; -})(Entry.ConnectionRipple); -Entry.Executor = function(a, b) { - this.scope = new Entry.Scope(a, this); - this.entity = b; - this._callStack = []; - this.register = {}; -}; -(function(a) { - a.execute = function() { - if (!this.isEnd()) { - for (;;) { - try { - var a = this.scope.block.getSchema().func.call(this.scope, this.entity, this.scope); - } catch (d) { - Entry.Utils.stopProjectWithToast(this.scope.block, "\ub7f0\ud0c0\uc784 \uc5d0\ub7ec"); - } - if (this.isEnd()) { - break; - } - if (void 0 === a || null === a || a === Entry.STATIC.PASS) { - if (this.scope = new Entry.Scope(this.scope.block.getNextBlock(), this), null === this.scope.block) { - if (this._callStack.length) { - var c = this.scope; - this.scope = this._callStack.pop(); - if (this.scope.isLooped !== c.isLooped) { - break; - } - } else { - break; - } - } - } else { - if (a !== Entry.STATIC.CONTINUE && (a === Entry.STATIC.BREAK || this.scope === a)) { - break; - } - } - } + b.createView = function(a, b) { + this.view || (this.view = new Entry.ThreadView(this, a)); + this._data.map(function(d) { + d.createView(a, b); + }); + }; + b.separate = function(a, b) { + if (this._data.has(a.id)) { + var d = this._data.splice(this._data.indexOf(a), b); + this._code.createThread(d); + this.changeEvent.notify(); } }; - a.stepInto = function(a) { - a instanceof Entry.Thread || console.error("Must step in to thread"); - a = a.getFirstBlock(); - if (!a) { - return Entry.STATIC.BREAK; + b.cut = function(a) { + a = this._data.indexOf(a); + a = this._data.splice(a); + this.changeEvent.notify(); + return a; + }; + b.insertByBlock = function(a, b) { + for (var d = a ? this._data.indexOf(a) : -1, e = 0;e < b.length;e++) { + b[e].setThread(this); } - this._callStack.push(this.scope); - this.scope = new Entry.Scope(a, this); - return Entry.STATIC.CONTINUE; + this._data.splice.apply(this._data, [d + 1, 0].concat(b)); + this.changeEvent.notify(); }; - a.break = function() { - this._callStack.length && (this.scope = this._callStack.pop()); - return Entry.STATIC.PASS; + b.insertToTop = function(a) { + a.setThread(this); + this._data.unshift.apply(this._data, [a]); + this.changeEvent.notify(); }; - a.breakLoop = function() { - this._callStack.length && (this.scope = this._callStack.pop()); - for (;this._callStack.length && "repeat" !== Entry.block[this.scope.block.type].class;) { - this.scope = this._callStack.pop(); + b.clone = function(a, b) { + a = a || this._code; + for (var d = new Entry.Thread([], a), e = this._data, f = [], g = 0, h = e.length;g < h;g++) { + f.push(e[g].clone(d)); } - return Entry.STATIC.PASS; + d.load(f, b); + return d; }; - a.end = function() { - this.scope.block = null; + b.toJSON = function(a, b) { + for (var d = [], e = void 0 === b ? 0 : b;e < this._data.length;e++) { + this._data[e] instanceof Entry.Block && d.push(this._data[e].toJSON(a)); + } + return d; }; - a.isEnd = function() { - return null === this.scope.block; + b.destroy = function(a) { + this._code.destroyThread(this, !1); + this.view && this.view.destroy(a); + for (var b = this._data, d = b.length - 1;0 <= d;d--) { + b[d].destroy(a); + } }; -})(Entry.Executor.prototype); -Entry.Scope = function(a, b) { - this.type = (this.block = a) ? a.type : null; - this.executor = b; - this.entity = b.entity; -}; -(function(a) { - a.callReturn = function() { + b.getBlock = function(a) { + return this._data[a]; }; - a.getParam = function(a) { - a = this.block.params[a]; - var c = new Entry.Scope(a, this.executor); - return Entry.block[a.type].func.call(c, this.entity, c); + b.getBlocks = function() { + return this._data.map(function(a) { + return a; + }); }; - a.getParams = function() { - var a = this; - return this.block.params.map(function(c) { - if (c instanceof Entry.Block) { - var d = new Entry.Scope(c, a.executor); - return Entry.block[c.type].func.call(d, a.entity, d); + b.countBlock = function() { + for (var a = 0, b = 0;b < this._data.length;b++) { + var d = this._data[b]; + if (d.type && (a++, d = d.statements)) { + for (var e = 0;e < d.length;e++) { + a += d[e].countBlock(); + } } - return c; - }); + } + return a; }; - a.getValue = function(a, c) { - a = this.block.params[this._getParamIndex(a, c)]; - c = new Entry.Scope(a, this.executor); - return Entry.block[a.type].func.call(c, this.entity, c); + b.handleChange = function() { + 0 === this._data.length && this.destroy(); }; - a.getStringValue = function(a, c) { - return String(this.getValue(a, c)); + b.getCode = function() { + return this._code; }; - a.getNumberValue = function(a, c) { - return Number(this.getValue(a)); + b.setCode = function(a) { + this._code = a; }; - a.getBooleanValue = function(a, c) { - return Number(this.getValue(a, c)) ? !0 : !1; + b.spliceBlock = function(a) { + var b = this._data; + b.remove(a); + 0 === b.length && this.view.getParent().constructor !== Entry.FieldStatement && this.destroy(); + this.changeEvent.notify(); }; - a.getField = function(a, c) { - return this.block.params[this._getParamIndex(a)]; + b.getFirstBlock = function() { + return this._data[0]; }; - a.getStringField = function(a, c) { - return String(this.getField(a)); + b.getPrevBlock = function(a) { + a = this._data.indexOf(a); + return this._data.at(a - 1); }; - a.getNumberField = function(a) { - return Number(this.getField(a)); + b.getNextBlock = function(a) { + a = this._data.indexOf(a); + return this._data.at(a + 1); }; - a.getStatement = function(a, c) { - return this.executor.stepInto(this.block.statements[this._getStatementIndex(a, c)]); + b.getLastBlock = function() { + return this._data.at(this._data.length - 1); }; - a._getParamIndex = function(a) { - this._schema || (this._schema = Entry.block[this.type]); - return this._schema.paramsKeyMap[a]; + b.getRootBlock = function() { + return this._data.at(0); }; - a._getStatementIndex = function(a) { - this._schema || (this._schema = Entry.block[this.type]); - return this._schema.statementsKeyMap[a]; + b.hasBlockType = function(a) { + function b(d) { + if (a == d.type) { + return !0; + } + for (var f = d.params, g = 0;g < f.length;g++) { + var h = f[g]; + if (h && h.constructor == Entry.Block && b(h)) { + return !0; + } + } + if (d = d.statements) { + for (f = 0;f < d.length;f++) { + if (d[f].hasBlockType(a)) { + return !0; + } + } + } + return !1; + } + for (var d = 0;d < this._data.length;d++) { + if (b(this._data[d])) { + return !0; + } + } + return !1; }; - a.die = function() { - this.block = null; - return Entry.STATIC.BREAK; + b.getCount = function(a) { + var b = this._data.length; + a && (b -= this._data.indexOf(a)); + return b; }; -})(Entry.Scope.prototype); -Entry.FieldAngle = function(a, b, c) { - this._block = b.block; - this._blockView = b; - this.box = new Entry.BoxModel; - this.svgGroup = null; - this.position = a.position; - this._contents = a; - this._index = c; - a = this.getValue(); - this.setValue(this.modValue(void 0 !== a ? a : 90)); - this.renderStart(); -}; -Entry.Utils.inherit(Entry.Field, Entry.FieldAngle); -(function(a) { - a.renderStart = function() { - this.svgGroup && $(this.svgGroup).remove(); - this.svgGroup = this._blockView.contentSvgGroup.elem("g", {class:"entry-input-field"}); - this.textElement = this.svgGroup.elem("text", {x:4, y:4, "font-size":"9pt"}); - this.textElement.textContent = this.getText(); - var a = this.getTextWidth(), c = this.position && this.position.y ? this.position.y : 0; - this._header = this.svgGroup.elem("rect", {x:0, y:c - 8, rx:3, ry:3, width:a, height:16, rx:3, ry:3, fill:"#fff", "fill-opacity":.4}); - this.svgGroup.appendChild(this.textElement); - this._bindRenderOptions(); - this.box.set({x:0, y:0, width:a, height:16}); + b.indexOf = function(a) { + return this._data.indexOf(a); }; - a.renderOptions = function() { - var a = this; - this._attachDisposeEvent(function() { - a.applyValue(); - a.destroyOption(); - }); - this.optionGroup = Entry.Dom("input", {class:"entry-widget-input-field", parent:$("body")}); - this.optionGroup.val(this.value); - this.optionGroup.on("mousedown", function(a) { - a.stopPropagation(); - }); - this.optionGroup.on("keyup", function(c) { - var d = c.keyCode || c.which; - a.applyValue(c); - -1 < [13, 27].indexOf(d) && a.destroyOption(); - }); - var c = this.getAbsolutePosFromDocument(); - c.y -= this.box.height / 2; - this.optionGroup.css({height:16, left:c.x, top:c.y, width:a.box.width}); - this.optionGroup.select(); - this.svgOptionGroup = this.appendSvgOptionGroup(); - this.svgOptionGroup.elem("circle", {x:0, y:0, r:49, class:"entry-field-angle-circle"}); - this._dividerGroup = this.svgOptionGroup.elem("g"); - for (c = 0;360 > c;c += 15) { - this._dividerGroup.elem("line", {x1:49, y1:0, x2:49 - (0 === c % 45 ? 10 : 5), y2:0, transform:"rotate(" + c + ", 0, 0)", class:"entry-angle-divider"}); - } - c = this.getAbsolutePosFromBoard(); - c.x += this.box.width / 2; - c.y = c.y + this.box.height / 2 + 49 + 1; - this.svgOptionGroup.attr({class:"entry-field-angle", transform:"translate(" + c.x + "," + c.y + ")"}); - var c = a.getAbsolutePosFromDocument(), d = [c.x + a.box.width / 2, c.y + a.box.height / 2 + 1]; - $(this.svgOptionGroup).mousemove(function(c) { - a.optionGroup.val(a.modValue(function(a, b) { - var c = b[0] - a[0]; - a = b[1] - a[1] - 49 - 1; - b = Math.atan(-a / c); - b = Entry.toDegrees(b); - b = 90 - b; - 0 > c ? b += 180 : 0 < a && (b += 360); - return 15 * Math.round(b / 15); - }(d, [c.clientX, c.clientY]))); - a.applyValue(); - }); - this.updateGraph(); + b.pointer = function(a, b) { + var d = this.indexOf(b); + a.unshift(d); + this.parent instanceof Entry.Block && a.unshift(this.parent.indexOfStatements(this)); + return this._code === this.parent ? (a.unshift(this._code.indexOf(this)), d = this._data[0], a.unshift(d.y), a.unshift(d.x), a) : this.parent.pointer(a); }; - a.updateGraph = function() { - this._fillPath && this._fillPath.remove(); - var a = Entry.toRadian(this.getValue()), c = 49 * Math.sin(a), d = -49 * Math.cos(a), a = a > Math.PI ? 1 : 0; - this._fillPath = this.svgOptionGroup.elem("path", {d:"M 0,0 v -49 A 49,49 0 %LARGE 1 %X,%Y z".replace("%X", c).replace("%Y", d).replace("%LARGE", a), class:"entry-angle-fill-area"}); - this.svgOptionGroup.appendChild(this._dividerGroup); - this._indicator && this._indicator.remove(); - this._indicator = this.svgOptionGroup.elem("line", {x1:0, y1:0, x2:c, y2:d}); - this._indicator.attr({class:"entry-angle-indicator"}); + b.getBlockList = function(a) { + for (var b = [], d = 0;d < this._data.length;d++) { + b = b.concat(this._data[d].getBlockList(a)); + } + return b; }; - a.applyValue = function() { - var a = this.optionGroup.val(); - isNaN(a) || (a = this.modValue(a), this.setValue(a), this.updateGraph(), this.textElement.textContent = this.getValue(), this.optionGroup && this.optionGroup.val(a), this.resize()); + b.stringify = function() { + return JSON.stringify(this.toJSON()); }; - a.resize = function() { - var a = this.getTextWidth(); - this._header.attr({width:a}); - this.optionGroup && this.optionGroup.css({width:a}); - this.box.set({width:a}); - this._block.view.alignContent(); +})(Entry.Thread.prototype); +Entry.Block = function(b, a) { + var c = this; + Entry.Model(this, !1); + this._schema = null; + this.setThread(a); + this.load(b); + var d = this.getCode(); + d.registerBlock(this); + var e = this.events.dataAdd; + e && d.object && e.forEach(function(a) { + Entry.Utils.isFunction(a) && a(c); + }); +}; +Entry.Block.MAGNET_RANGE = 10; +Entry.Block.MAGNET_OFFSET = .4; +Entry.Block.DELETABLE_TRUE = 1; +Entry.Block.DELETABLE_FALSE = 2; +Entry.Block.DELETABLE_FALSE_LIGHTEN = 3; +(function(b) { + b.schema = {id:null, x:0, y:0, type:null, params:[], statements:[], view:null, thread:null, movable:null, deletable:Entry.Block.DELETABLE_TRUE, readOnly:null, copyable:!0, events:{}}; + b.load = function(a) { + a.id || (a.id = Entry.Utils.generateId()); + this.set(a); + this.loadSchema(); }; - a.getTextWidth = function() { - return this.textElement ? this.textElement.getComputedTextLength() + 8 : 8; + b.changeSchema = function(a) { + this.set({params:[]}); + this.loadSchema(); }; - a.getText = function() { - return this.getValue() + "\u00b0"; + b.getSchema = function() { + this._schema || this.loadSchema(); + return this._schema; }; - a.modValue = function(a) { - return a % 360; + b.loadSchema = function() { + if (this._schema = Entry.block[this.type]) { + !this._schemaChangeEvent && this._schema.changeEvent && (this._schemaChangeEvent = this._schema.changeEvent.attach(this, this.changeSchema)); + var a = this._schema.events; + if (a) { + for (var b in a) { + this.events[b] || (this.events[b] = []); + for (var d = a[b], e = 0;e < d.length;e++) { + var f = d[e]; + f && 0 > this.events[b].indexOf(f) && this.events[b].push(f); + } + } + } + this._schema.event && this.thread.registerEvent(this, this._schema.event); + a = this.params; + b = this._schema.params; + for (e = 0;b && e < b.length;e++) { + d = void 0 === a[e] || null === a[e] ? b[e].value : a[e], f = a[e] || e < a.length, !d || "Output" !== b[e].type && "Block" !== b[e].type || (d = new Entry.Block(d, this.thread)), f ? a.splice(e, 1, d) : a.push(d); + } + if (a = this._schema.statements) { + for (e = 0;e < a.length;e++) { + this.statements.splice(e, 1, new Entry.Thread(this.statements[e], this.getCode(), this)); + } + } + } }; - a.destroyOption = function() { - this.disposeEvent && (Entry.disposeEvent.detach(this.disposeEvent), delete this.documentDownEvent); - this.optionGroup && (this.optionGroup.remove(), delete this.optionGroup); - this.svgOptionGroup && (this.svgOptionGroup.remove(), delete this.svgOptionGroup); - this.textElement.textContent = this.getText(); - this.command(); + b.changeType = function(a) { + this._schemaChangeEvent && this._schemaChangeEvent.destroy(); + this.set({type:a}); + this.loadSchema(); + this.view && this.view.changeType(a); }; -})(Entry.FieldAngle.prototype); -Entry.FieldColor = function(a, b, c) { - this._block = b.block; - this._blockView = b; - this.box = new Entry.BoxModel; - this.svgGroup = null; - this._contents = a; - this._index = c; - this._position = a.position; - this.key = a.key; - this.setValue(this.getValue() || "#FF0000"); - this.renderStart(b); -}; -Entry.Utils.inherit(Entry.Field, Entry.FieldColor); -(function(a) { - a.renderStart = function() { - this.svgGroup && $(this.svgGroup).remove(); - this.svgGroup = this._blockView.contentSvgGroup.elem("g", {class:"entry-field-color"}); - var a = this._position, c; - a ? (c = a.x || 0, a = a.y || 0) : (c = 0, a = -8); - this._header = this.svgGroup.elem("rect", {x:c, y:a, width:14.5, height:16, fill:this.getValue()}); - this._bindRenderOptions(); - this.box.set({x:c, y:a, width:14.5, height:16}); + b.setThread = function(a) { + this.set({thread:a}); }; - a.renderOptions = function() { - var a = this; - this._attachDisposeEvent(); - var c = Entry.FieldColor.getWidgetColorList(); - this.optionGroup = Entry.Dom("table", {class:"entry-widget-color-table", parent:$("body")}); - for (var d = 0;d < c.length;d++) { - for (var e = Entry.Dom("tr", {class:"entry-widget-color-row", parent:this.optionGroup}), f = 0;f < c[d].length;f++) { - var g = Entry.Dom("td", {class:"entry-widget-color-cell", parent:e}), h = c[d][f]; - g.css({"background-color":h}); - g.attr({"data-color-value":h}); - (function(c, d) { - c.mousedown(function(a) { - a.stopPropagation(); - }); - c.mouseup(function(c) { - a.applyValue(d); - a.destroyOption(); - a._selectBlockView(); - }); - })(g, h); - } - } - c = this.getAbsolutePosFromDocument(); - c.y += this.box.height / 2 + 1; - this.optionGroup.css({left:c.x, top:c.y}); + b.getThread = function() { + return this.thread; }; - a.applyValue = function(a) { - this.value != a && (this.setValue(a), this._header.attr({fill:a})); + b.insertAfter = function(a) { + this.thread.insertByBlock(this, a); }; -})(Entry.FieldColor.prototype); -Entry.FieldColor.getWidgetColorList = function() { - return ["#FFFFFF #CCCCCC #C0C0C0 #999999 #666666 #333333 #000000".split(" "), "#FFCCCC #FF6666 #FF0000 #CC0000 #990000 #660000 #330000".split(" "), "#FFCC99 #FF9966 #FF9900 #FF6600 #CC6600 #993300 #663300".split(" "), "#FFFF99 #FFFF66 #FFCC66 #FFCC33 #CC9933 #996633 #663333".split(" "), "#FFFFCC #FFFF33 #FFFF00 #FFCC00 #999900 #666600 #333300".split(" "), "#99FF99 #66FF99 #33FF33 #33CC00 #009900 #006600 #003300".split(" "), "#99FFFF #33FFFF #66CCCC #00CCCC #339999 #336666 #003333".split(" "), "#CCFFFF #66FFFF #33CCFF #3366FF #3333FF #000099 #000066".split(" "), - "#CCCCFF #9999FF #6666CC #6633FF #6609CC #333399 #330099".split(" "), "#FFCCFF #FF99FF #CC66CC #CC33CC #993399 #663366 #330033".split(" ")]; -}; -Entry.FieldDropdown = function(a, b, c) { - this._block = b.block; - this._blockView = b; - this.box = new Entry.BoxModel; - this.svgGroup = null; - this._contents = a; - this._noArrow = a.noArrow; - this._arrowColor = a.arrowColor; - this._index = c; - this.setValue(this.getValue()); - this._CONTENT_HEIGHT = a.dropdownHeight || b.getSkeleton().dropdownHeight || 16; - this._FONT_SIZE = a.fontSize || b.getSkeleton().fontSize || 12; - this._ROUND = a.roundValue || 3; - this.renderStart(); -}; -Entry.Utils.inherit(Entry.Field, Entry.FieldDropdown); -(function(a) { - a.renderStart = function() { - this.svgGroup && $(this.svgGroup).remove(); - this instanceof Entry.FieldDropdownDynamic && this._updateValue(); - var a = this._blockView; - this.svgGroup = a.contentSvgGroup.elem("g", {class:"entry-field-dropdown"}); - this.textElement = this.svgGroup.elem("text", {x:2}); - this.textElement.textContent = this.getTextByValue(this.getValue()); - var c = this.textElement.getBBox(); - this.textElement.attr({style:"white-space: pre; font-size:" + this._FONT_SIZE + "px", y:.25 * c.height}); - c = this.textElement.getComputedTextLength() + 16; - this._noArrow && (c -= 12); - var d = this._CONTENT_HEIGHT; - this._header = this.svgGroup.elem("rect", {width:c, height:d, y:-d / 2, rx:this._ROUND, ry:this._ROUND, fill:"#fff", "fill-opacity":.4}); - this.svgGroup.appendChild(this.textElement); - this._noArrow || (a = this._arrowColor || a._schema.color, this._arrow = this.svgGroup.elem("polygon", {points:"0,-2.1 6.4,-2.1 3.2,2.1", fill:a, stroke:a, transform:"translate(" + (c - 11) + ",0)"})); - this._bindRenderOptions(); - this.box.set({x:0, y:0, width:c, height:d}); + b._updatePos = function() { + this.view && this.set({x:this.view.x, y:this.view.y}); }; - a.resize = function() { - var a = this.textElement.getComputedTextLength() + 18; - this._noArrow ? a -= 14 : this._arrow.attr({transform:"translate(" + (a - 11) + ",0)"}); - this._header.attr({width:a}); - this.box.set({width:a}); - this._block.view.alignContent(); + b.moveTo = function(a, b) { + this.view && this.view._moveTo(a, b); + this._updatePos(); + this.getCode().changeEvent.notify(); }; - a.renderOptions = function() { - var a = this; - this._attachDisposeEvent(); - this.optionGroup = Entry.Dom("ul", {class:"entry-widget-dropdown", parent:$("body")}); - this.optionGroup.bind("mousedown touchstart", function(a) { - a.stopPropagation(); - }); - for (var c = this._contents.options, c = this._contents.options, d = 0, e = c.length;d < e;d++) { - var f = c[d], g = f[0], f = f[1], h = Entry.Dom("li", {class:"rect", parent:this.optionGroup}), k = Entry.Dom("span", {class:"left", parent:h}); - Entry.Dom("span", {class:"right", parent:h}).text(g); - this.getValue() == f && k.text("\u2713"); - (function(c, d) { - c.bind("mousedown touchstart", function(a) { - a.stopPropagation(); - }); - c.bind("mouseup touchend", function(c) { - c.stopPropagation(); - a.applyValue(d); - a.destroyOption(); - a._selectBlockView(); - }); - })(h, f); - } - this._position(); + b.createView = function(a, b) { + this.view || (this.set({view:new Entry.BlockView(this, a, b)}), this._updatePos()); }; - a._position = function() { - var a = this.getAbsolutePosFromDocument(); - a.y += this.box.height / 2; - var c = $(document).height(), d = this.optionGroup.height(), e = this.optionGroup.width() + 30; - if (c < a.y + d + 30) { - var c = this._blockView.getBoard().svgDom.height(), f = this.getAbsolutePosFromBoard(); - this._blockView.y < c / 2 ? (a.x += this.box.width / 2 - e / 2, c -= f.y + 30, this.optionGroup.height(c)) : (a.x += this.box.width + 1, c -= c - f.y, c - 30 < d && this.optionGroup.height(c - c % 30), a.y -= this.optionGroup.height()); - } else { - a.x += this.box.width / 2 - e / 2; - } - this.optionGroup.addClass("rendered"); - this.optionGroup.css({left:a.x, top:a.y, width:e}); - this.optionGroup.find(".right").width(e - 20); + b.clone = function(a) { + return new Entry.Block(this.toJSON(!0), a); }; - a.applyValue = function(a) { - this.value != a && this.setValue(a); - this.textElement.textContent = this.getTextByValue(a); - this.resize(); + b.toJSON = function(a) { + var b = this._toJSON(); + delete b.view; + delete b.thread; + delete b.events; + a && delete b.id; + b.params = b.params.map(function(b) { + b instanceof Entry.Block && (b = b.toJSON(a)); + return b; + }); + b.statements = b.statements.map(function(b) { + return b.toJSON(a); + }); + b.x = this.x; + b.y = this.y; + b.movable = this.movable; + b.deletable = this.deletable; + b.readOnly = this.readOnly; + return b; }; - a.getTextByValue = function(a) { - if (!a || "null" === a) { - return Lang.Blocks.no_target; + b.destroy = function(a, b) { + var d = this, e = this.params; + if (e) { + for (var f = 0;f < e.length;f++) { + var g = e[f]; + g instanceof Entry.Block && (g.doNotSplice = !0, g.destroy(a)); + } } - for (var c = this._contents.options, d = 0, e = c.length;d < e;d++) { - var f = c[d]; - if (f[1] == a) { - return f[0]; + if (e = this.statements) { + for (f = 0;f < e.length;f++) { + e[f].destroy(a); } } - return Lang.Blocks.no_target; + g = this.getPrevBlock(); + f = this.getNextBlock(); + this.getCode().unregisterBlock(this); + e = this.getThread(); + this._schema.event && e.unregisterEvent(this, this._schema.event); + f && (b ? f.destroy(a, b) : g ? f.view.bindPrev(g) : (g = this.getThread().view.getParent(), g.constructor === Entry.FieldStatement ? (f.view.bindPrev(g), g.insertTopBlock(f)) : g.constructor === Entry.FieldStatement ? f.replace(g._valueBlock) : f.view._toGlobalCoordinate())); + this.doNotSplice ? delete this.doNotSplice : e.spliceBlock(this); + this.view && this.view.destroy(a); + this._schemaChangeEvent && this._schemaChangeEvent.destroy(); + (f = this.events.dataDestroy) && this.getCode().object && f.forEach(function(a) { + Entry.Utils.isFunction(a) && a(d); + }); }; -})(Entry.FieldDropdown.prototype); -Entry.FieldDropdownDynamic = function(a, b, c) { - this._block = b.block; - this._blockView = b; - this.box = new Entry.BoxModel; - this.svgGroup = null; - this._contents = a; - this._index = c; - this._arrowColor = a.arrowColor; - c = this._contents.menuName; - Entry.Utils.isFunction(c) ? this._menuGenerator = c : this._menuName = c; - this._CONTENT_HEIGHT = a.dropdownHeight || b.getSkeleton().dropdownHeight || 16; - this._FONT_SIZE = a.fontSize || b.getSkeleton().fontSize || 12; - this._ROUND = a.roundValue || 3; - this.renderStart(b); -}; -Entry.Utils.inherit(Entry.FieldDropdown, Entry.FieldDropdownDynamic); -(function(a) { - a.constructor = Entry.FieldDropDownDynamic; - a._updateValue = function() { - var a = []; - Entry.container && (a = this._menuName ? Entry.container.getDropdownList(this._menuName) : this._menuGenerator()); - this._contents.options = a; - var a = this._contents.options, c = this.getValue(); - c && "null" != c || (c = 0 !== a.length ? a[0][1] : null); - this.setValue(c); + b.getView = function() { + return this.view; }; - a.renderOptions = function() { - var a = this; - this._attachDisposeEvent(); - this.optionGroup = Entry.Dom("ul", {class:"entry-widget-dropdown", parent:$("body")}); - this.optionGroup.bind("mousedown touchstart", function(a) { - a.stopPropagation(); - }); - var c; - c = this._menuName ? Entry.container.getDropdownList(this._contents.menuName) : this._menuGenerator(); - this._contents.options = c; - for (var d = 0;d < c.length;d++) { - var e = c[d], f = e[0], e = e[1], g = Entry.Dom("li", {class:"rect", parent:this.optionGroup}), h = Entry.Dom("span", {class:"left", parent:g}); - Entry.Dom("span", {class:"right", parent:g}).text(f); - this.getValue() == e && h.text("\u2713"); - (function(c, d) { - c.mousedown(function(a) { - a.stopPropagation(); - }); - c.mouseup(function(c) { - c.stopPropagation(); - a.applyValue(d); - a.destroyOption(); - a._selectBlockView(); - }); - })(g, e); - } - this._position(); + b.setMovable = function(a) { + this.movable != a && this.set({movable:a}); }; -})(Entry.FieldDropdownDynamic.prototype); -Entry.FieldImage = function(a, b, c) { - this._block = b.block; - this._blockView = b; - this._content = a; - this.box = new Entry.BoxModel; - this._size = a.size; - this._highlightColor = a.highlightColor ? a.highlightColor : "#F59900"; - this._position = a.position; - this._imgElement = this._path = this.svgGroup = null; - this._index = c; - this.setValue(null); - this.renderStart(); -}; -Entry.Utils.inherit(Entry.Field, Entry.FieldImage); -(function(a) { - a.renderStart = function() { - this.svgGroup && this.svgGroup.remove(); - this._imgUrl = this._block.deletable === Entry.Block.DELETABLE_FALSE_LIGHTEN ? this._content.img.replace(".png", "_un.png") : this._content.img; - this.svgGroup = this._blockView.contentSvgGroup.elem("g"); - this._imgElement = this.svgGroup.elem("image", {href:this._imgUrl, x:0, y:-.5 * this._size, width:this._size, height:this._size}); - this.box.set({x:this._size, y:0, width:this._size, height:this._size}); + b.setCopyable = function(a) { + this.copyable != a && this.set({copyable:a}); }; -})(Entry.FieldImage.prototype); -Entry.FieldIndicator = function(a, b, c) { - this._block = b.block; - this._blockView = b; - this.box = new Entry.BoxModel; - this._size = a.size; - this._imgUrl = this._block.deletable === Entry.Block.DELETABLE_FALSE_LIGHTEN ? a.img.replace(".png", "_un.png") : a.img; - this._boxMultiplier = a.boxMultiplier || 2; - this._highlightColor = a.highlightColor ? a.highlightColor : "#F59900"; - this._position = a.position; - this._index = c; - this._imgElement = this._path = this.svgGroup = null; - this.setValue(null); - this.renderStart(); -}; -Entry.Utils.inherit(Entry.Field, Entry.FieldIndicator); -(function(a) { - a.renderStart = function() { - this.svgGroup && this.svgGroup.remove(); - this.svgGroup = this._blockView.contentSvgGroup.elem("g"); - this._imgElement = this.svgGroup.elem("image", {href:Entry.mediaFilePath + this._imgUrl, x:this._position ? -1 * this._size : 0, y:-1 * this._size, width:2 * this._size, height:2 * this._size}); - var a = "m 0,-%s a %s,%s 0 1,1 -0.1,0 z".replace(/%s/gi, this._size); - this._path = this.svgGroup.elem("path", {d:a, stroke:"none", fill:"none"}); - this.box.set({width:this._size * this._boxMultiplier + (this._position ? -this._size : 0), height:this._size * this._boxMultiplier}); + b.isMovable = function() { + return this.movable; }; - a.enableHighlight = function() { - var a = this._path.getTotalLength(), c = this._path; - this._path.attr({stroke:this._highlightColor, strokeWidth:2, "stroke-linecap":"round", "stroke-dasharray":a + " " + a, "stroke-dashoffset":a}); - setInterval(function() { - c.attr({"stroke-dashoffset":a}).animate({"stroke-dashoffset":0}, 300); - }, 1400, mina.easeout); - setTimeout(function() { - setInterval(function() { - c.animate({"stroke-dashoffset":-a}, 300); - }, 1400, mina.easeout); - }, 500); + b.isCopyable = function() { + return this.copyable; }; -})(Entry.FieldIndicator.prototype); -Entry.Keyboard = {}; -Entry.FieldKeyboard = function(a, b, c) { - this._block = b.block; - this._blockView = b; - this.box = new Entry.BoxModel; - this.svgGroup = null; - this.position = a.position; - this._contents = a; - this._index = c; - this.setValue(String(this.getValue())); - this._optionVisible = !1; - this.renderStart(b); -}; -Entry.Utils.inherit(Entry.Field, Entry.FieldKeyboard); -(function(a) { - a.renderStart = function() { - this.svgGroup && $(this.svgGroup).remove(); - this.svgGroup = this._blockView.contentSvgGroup.elem("g", {class:"entry-input-field"}); - this.textElement = this.svgGroup.elem("text").attr({x:4, y:4, "font-size":"9pt"}); - this.textElement.textContent = Entry.getKeyCodeMap()[this.getValue()]; - var a = this.getTextWidth(), c = this.position && this.position.y ? this.position.y : 0; - this._header = this.svgGroup.elem("rect", {x:0, y:c - 8, width:a, height:16, rx:3, ry:3, fill:"#fff", "fill-opacity":.4}); - this.svgGroup.appendChild(this.textElement); - this._bindRenderOptions(); - this.box.set({x:0, y:0, width:a, height:16}); + b.setDeletable = function(a) { + this.deletable != a && this.set({deletable:a}); }; - a.renderOptions = function() { - Entry.keyPressed && (this.keyPressed = Entry.keyPressed.attach(this, this._keyboardControl)); - this._optionVisible = !0; - this._attachDisposeEvent(); - var a = this.getAbsolutePosFromDocument(); - a.x -= this.box.width / 2; - a.y += this.box.height / 2 + 1; - this.optionGroup = Entry.Dom("img", {class:"entry-widget-keyboard-input", src:Entry.mediaFilePath + "/media/keyboard_workspace.png", parent:$("body")}); - this.optionGroup.css({left:a.x, top:a.y}); + b.isDeletable = function() { + return this.deletable === Entry.Block.DELETABLE_TRUE; }; - a.destroyOption = function() { - this.disposeEvent && (Entry.disposeEvent.detach(this.disposeEvent), delete this.disposeEvent); - this.optionGroup && (this.optionGroup.remove(), delete this.optionGroup); - this._optionVisible = !1; - this.command(); - this.keyPressed && (Entry.keyPressed.detach(this.keyPressed), delete this.keyPressed); + b.isReadOnly = function() { + return this.readOnly; }; - a._keyboardControl = function(a) { - a.stopPropagation(); - if (this._optionVisible) { - a = a.keyCode; - var c = Entry.getKeyCodeMap()[a]; - void 0 !== c && this.applyValue(c, a); - } + b.getCode = function() { + return this.thread.getCode(); }; - a.applyValue = function(a, c) { - this.setValue(String(c)); - this.destroyOption(); - this.textElement.textContent = a; - this.resize(); + b.doAdd = function() { + this.getCode().changeEvent.notify(); }; - a.resize = function() { - var a = this.getTextWidth(); - this._header.attr({width:a}); - this.box.set({width:a}); - this._blockView.alignContent(); + b.doMove = function() { + this._updatePos(); + this.getCode().changeEvent.notify(); }; - a.getTextWidth = function() { - return this.textElement.getComputedTextLength() + 8; + b.doSeparate = function() { + this.separate(); }; - a.destroy = function() { - this.destroyOption(); - Entry.keyPressed && this.keyPressed && Entry.keyPressed.detach(this.keyPressed); + b.doInsert = function(a) { + "basic" === this.getBlockType() ? this.insert(a) : this.replace(a); }; -})(Entry.FieldKeyboard.prototype); -Entry.FieldLineBreak = function(a, b, c) { - this._block = b.block; - this._blockView = b; - this._index = c; - this.box = new Entry.BoxModel; - this.setValue(null); - this.renderStart(); -}; -Entry.Utils.inherit(Entry.Field, Entry.FieldLineBreak); -(function(a) { - a.renderStart = function() { + b.doDestroy = function(a) { + this.destroy(a); + this.getCode().changeEvent.notify(); + return this; }; - a.align = function(a) { - var c = this._blockView; - 0 !== c._statements.length && this.box.set({y:(c._statements[a].height || 20) + Math.max(c.contentHeight % 1E3, 30)}); + b.doDestroyBelow = function(a) { + console.log("destroyBelow", this.id, this.x, this.y); + this.destroy(a, !0); + this.getCode().changeEvent.notify(); + return this; }; -})(Entry.FieldLineBreak.prototype); -Entry.FieldOutput = function(a, b, c, d, e) { - Entry.Model(this, !1); - this._blockView = b; - this._block = b.block; - this._valueBlock = null; - this.box = new Entry.BoxModel; - this.changeEvent = new Entry.Event(this); - this._index = c; - this.contentIndex = e; - this._content = a; - this.acceptType = a.accept; - this.view = this; - this.svgGroup = null; - this._position = a.position; - this.box.observe(b, "alignContent", ["width", "height"]); - this.observe(this, "_updateBG", ["magneting"], !1); - this.renderStart(b.getBoard(), d); -}; -Entry.Utils.inherit(Entry.Field, Entry.FieldOutput); -(function(a) { - a.schema = {magneting:!1}; - a.renderStart = function(a, c) { - this.svgGroup = this._blockView.contentSvgGroup.elem("g"); - this.view = this; - this._nextGroup = this.svgGroup; - this.box.set({x:0, y:0, width:0, height:20}); - var d = this.getValue(); - d && !d.view && (d.setThread(this), d.createView(a, c)); - this._updateValueBlock(d); - this._blockView.getBoard().constructor == Entry.BlockMenu && this._valueBlock && this._valueBlock.view.removeControl(); + b.copy = function() { + var a = this.getThread(), b = []; + if (a instanceof Entry.Thread) { + for (var d = a.getBlocks().indexOf(this), a = a.toJSON(!0, d), d = 0;d < a.length;d++) { + b.push(a[d]); + } + } else { + b.push(this.toJSON(!0)); + } + a = this.view.getAbsoluteCoordinate(); + d = b[0]; + d.x = a.x + 15; + d.y = a.y + 15; + d.id = Entry.Utils.generateId(); + return b; + }; + b.copyToClipboard = function() { + Entry.clipboard = this.copy(); + }; + b.separate = function(a) { + this.thread.separate(this, a); + this._updatePos(); + this.getCode().changeEvent.notify(); + }; + b.insert = function(a) { + var b = this.thread.cut(this); + a instanceof Entry.Thread ? a.insertByBlock(null, b) : a.insertAfter(b); + this._updatePos(); + this.getCode().changeEvent.notify(); }; - a.align = function(a, c, d) { - var e = this.svgGroup; - this._position && (this._position.x && (a = this._position.x), this._position.y && (c = this._position.y)); - var f = this._valueBlock; - f && (c = -.5 * f.view.height); - f = "translate(" + a + "," + c + ")"; - void 0 === d || d ? e.animate({transform:f}, 300, mina.easeinout) : e.attr({transform:f}); - this.box.set({x:a, y:c}); + b.replace = function(a) { + this.thread.cut(this); + a.getThread().replace(this); + this.getCode().changeEvent.notify(); }; - a.calcWH = function() { - var a = this._valueBlock; - a ? (a = a.view, this.box.set({width:a.width, height:a.height})) : this.box.set({width:0, height:20}); + b.getPrevBlock = function() { + return this.thread.getPrevBlock(this); }; - a.calcHeight = a.calcWH; - a.destroy = function() { + b.getNextBlock = function() { + return this.thread.getNextBlock(this) || null; }; - a._inspectBlock = function() { + b.getLastBlock = function() { + return this.thread.getLastBlock(); }; - a._setValueBlock = function(a) { - if (a != this._valueBlock || !this._valueBlock) { - return this._valueBlock = a, this.setValue(a), a && a.setThread(this), this._valueBlock; + b.getOutputBlock = function() { + for (var a = this._schema.params, b = 0;a && b < a.length;b++) { + if ("Output" === a[b].type) { + return this.params[b]; + } } + return null; }; - a._updateValueBlock = function(a) { - a instanceof Entry.Block || (a = void 0); - this._sizeObserver && this._sizeObserver.destroy(); - this._posObserver && this._posObserver.destroy(); - (a = this._setValueBlock(a)) ? (a = a.view, a.bindPrev(), this._posObserver = a.observe(this, "_updateValueBlock", ["x", "y"], !1), this._sizeObserver = a.observe(this, "calcWH", ["width", "height"])) : this.calcWH(); - this._blockView.alignContent(); - a = this._blockView.getBoard(); - a.constructor === Entry.Board && a.generateCodeMagnetMap(); + b.getTerminateOutputBlock = function() { + for (var a = this;;) { + var b = a.getOutputBlock(); + if (!b) { + return a; + } + a = b; + } }; - a.getPrevBlock = function(a) { - return this._valueBlock === a ? this : null; + b.getBlockType = function() { + if (!this.view) { + return null; + } + var a = Entry.skeleton[this._schema.skeleton].magnets(this.view); + return a.next || a.previous ? "basic" : a.boolean || a.string ? "field" : a.output ? "output" : null; }; - a.getNextBlock = function() { - return null; + b.indexOfStatements = function(a) { + return this.statements.indexOf(a); }; - a.requestAbsoluteCoordinate = function(a) { - a = this._blockView; - var c = a.contentPos; - a = a.getAbsoluteCoordinate(); - a.x += this.box.x + c.x; - a.y += this.box.y + c.y; + b.pointer = function(a) { + a || (a = []); + return this.thread.pointer(a, this); + }; + b.targetPointer = function() { + var a = this.thread.pointer([], this); + 4 === a.length && 0 === a[3] && a.pop(); return a; }; - a.dominate = function() { - this._blockView.dominate(); + b.getBlockList = function(a) { + var b = []; + if (!this._schema) { + return []; + } + if (a && this._schema.isPrimitive) { + return b; + } + b.push(this); + for (var d = this.params, e = 0;e < d.length;e++) { + var f = d[e]; + f && f.constructor == Entry.Block && (b = b.concat(f.getBlockList(a))); + } + if (d = this.statements) { + for (e = 0;e < d.length;e++) { + b = b.concat(d[e].getBlockList(a)); + } + } + return b; }; - a.isGlobal = function() { - return !1; + b.stringify = function() { + return JSON.stringify(this.toJSON()); }; - a.separate = function(a) { - this.getCode().createThread([a]); - this.changeEvent.notify(); +})(Entry.Block.prototype); +Entry.ThreadView = function(b, a) { + Entry.Model(this, !1); + this.thread = b; + this.svgGroup = a.svgThreadGroup.elem("g"); + this.parent = a; +}; +(function(b) { + b.schema = {height:0, zIndex:0}; + b.destroy = function() { + this.svgGroup.remove(); }; - a.getCode = function() { - return this._block.thread.getCode(); + b.setParent = function(a) { + this.parent = a; }; - a.cut = function(a) { - return this._valueBlock === a ? (delete this._valueBlock, [a]) : null; + b.getParent = function() { + return this.parent; }; - a._updateBG = function() { - this.magneting ? this._bg = this.svgGroup.elem("path", {d:"m -4,-12 h 3 l 2,2 0,3 3,0 1,1 0,12 -1,1 -3,0 0,3 -2,2 h -3 ", fill:"#fff", stroke:"#fff", "fill-opacity":.7, transform:"translate(0," + (this._valueBlock ? 12 : 0) + ")"}) : this._bg && (this._bg.remove(), delete this._bg); + b.renderText = function() { + for (var a = this.thread.getBlocks(), b = 0;b < a.length;b++) { + a[b].view.renderText(); + } }; - a.replace = function(a) { - var c = this._valueBlock; - c && (c.view._toGlobalCoordinate(), a.getTerminateOutputBlock().view._contents[1].replace(c)); - this._updateValueBlock(a); - a.view._toLocalCoordinate(this.svgGroup); - this.calcWH(); + b.renderBlock = function() { + for (var a = this.thread.getBlocks(), b = 0;b < a.length;b++) { + a[b].view.renderBlock(); + } }; - a.setParent = function(a) { - this._parent = a; + b.requestAbsoluteCoordinate = function(a) { + var b = this.thread.getBlocks(), d = b.shift(), e = {x:0, y:0}; + for (this.parent instanceof Entry.Board || this.parent instanceof Entry.BlockMenu || (e = this.parent.requestAbsoluteCoordinate());d && d.view !== a && d.view;) { + d = d.view, e.x += d.x + d.magnet.next.x, e.y += d.y + d.magnet.next.y, d = b.shift(); + } + return e; }; - a.getParent = function() { - return this._parent; + b.requestPartHeight = function(a, b) { + for (var d = this.thread.getBlocks(), e = d.pop(), f = a ? a.magnet.next ? a.magnet.next.y : a.height : 0;e && e.view !== a && e.view;) { + e = e.view, f = e.magnet.next ? f + e.magnet.next.y : f + e.height, e.dragMode === Entry.DRAG_MODE_DRAG && (f = 0), e = d.pop(); + } + return f; }; - a.getThread = function() { - return this; + b.dominate = function() { + this.parent.dominate(this.thread); }; - a.getValueBlock = function() { - return this._valueBlock; + b.isGlobal = function() { + return this.parent instanceof Entry.Board; }; - a.pointer = function(a) { - a.unshift(this._index); - a.unshift(Entry.PARAM); - return this._block.pointer(a); + b.reDraw = function() { + for (var a = this.thread._data, b = a.length - 1;0 <= b;b--) { + a[b].view.reDraw(); + } }; -})(Entry.FieldOutput.prototype); -Entry.FieldStatement = function(a, b, c) { - Entry.Model(this, !1); - this._blockView = b; - this.block = b.block; - this.view = this; - this._index = c; - this.acceptType = a.accept; - this._thread = this.statementSvgGroup = this.svgGroup = null; - this._position = a.position; - this.observe(b, "alignContent", ["height"], !1); - this.observe(this, "_updateBG", ["magneting"], !1); - this.renderStart(b.getBoard()); + b.setZIndex = function(a) { + this.set({zIndex:a}); + }; +})(Entry.ThreadView.prototype); +Entry.FieldTrashcan = function(b) { + b && this.setBoard(b); + this.dragBlockObserver = this.dragBlock = null; + this.isOver = !1; + Entry.windowResized && Entry.windowResized.attach(this, this.setPosition); }; -(function(a) { - a.schema = {x:0, y:0, width:100, height:20, magneting:!1}; - a.magnet = {next:{x:0, y:0}}; - a.renderStart = function(a) { - this.svgGroup = this._blockView.statementSvgGroup.elem("g"); - this._nextGroup = this.statementSvgGroup = this.svgGroup.elem("g"); - this._initThread(a); - this._board = a; +(function(b) { + b._generateView = function() { + this.svgGroup = this.board.svg.elem("g"); + this.renderStart(); + this._addControl(); }; - a._initThread = function(a) { - var c = this.getValue(); - this._thread = c; - c.createView(a); - c.view.setParent(this); - if (a = c.getFirstBlock()) { - a.view._toLocalCoordinate(this.statementSvgGroup), this.firstBlock = a; - } - c.changeEvent.attach(this, this.calcHeight); - c.changeEvent.attach(this, this.checkTopBlock); - this.calcHeight(); + b.renderStart = function() { + var a = Entry.mediaFilePath + "delete_"; + this.trashcanTop = this.svgGroup.elem("image", {href:a + "cover.png", width:60, height:20}); + this.svgGroup.elem("image", {href:a + "body.png", y:20, width:60, height:60}); }; - a.align = function(a, c, d) { - d = void 0 === d ? !0 : d; - var e = this.svgGroup; - this._position && (this._position.x && (a = this._position.x), this._position.y && (c = this._position.y)); - var f = "translate(" + a + "," + c + ")"; - this.set({x:a, y:c}); - d ? e.animate({transform:f}, 300, mina.easeinout) : e.attr({transform:f}); + b._addControl = function() { + $(this.svgGroup).bind("mousedown", function(a) { + Entry.Utils.isRightButton(a) && (a.stopPropagation(), $("#entryWorkspaceBoard").css("background", "white")); + }); }; - a.calcHeight = function() { - var a = this._thread.view.requestPartHeight(null); - this.set({height:a}); + b.updateDragBlock = function() { + var a = this.board.dragBlock, b = this.dragBlockObserver; + b && (b.destroy(), this.dragBlockObserver = null); + a ? this.dragBlockObserver = a.observe(this, "checkBlock", ["x", "y"]) : (this.isOver && this.dragBlock && !this.dragBlock.block.getPrevBlock() && (this.dragBlock.block.doDestroyBelow(!0), createjs.Sound.play("entryDelete")), this.tAnimation(!1)); + this.dragBlock = a; + }; + b.checkBlock = function() { + var a = this.dragBlock; + if (a && a.block.isDeletable()) { + var b = this.board.offset(), d = this.getPosition(), e = d.x + b.left, b = d.y + b.top, f, g; + if (a = a.dragInstance) { + f = a.offsetX, g = a.offsetY; + } + this.tAnimation(f >= e && g >= b); + } }; - a.getValue = function() { - return this.block.statements[this._index]; + b.align = function() { + var a = this.getPosition(); + this.svgGroup.attr({transform:"translate(" + a.x + "," + a.y + ")"}); }; - a.requestAbsoluteCoordinate = function() { - var a = this._blockView.getAbsoluteCoordinate(); - a.x += this.x; - a.y += this.y; - return a; + b.setPosition = function() { + if (this.board) { + var a = this.board.svgDom; + this._x = a.width() - 110; + this._y = a.height() - 110; + this.align(); + } }; - a.dominate = function() { - this._blockView.dominate(); + b.getPosition = function() { + return {x:this._x, y:this._y}; }; - a.destroy = function() { + b.tAnimation = function(a) { + if (a !== this.isOver) { + a = void 0 === a ? !0 : a; + var b, d = this.trashcanTop; + b = a ? {translateX:15, translateY:-25, rotateZ:30} : {translateX:0, translateY:0, rotateZ:0}; + $(d).velocity(b, {duration:50}); + this.isOver = a; + } }; - a._updateBG = function() { - if (this._board.dragBlock && this._board.dragBlock.dragInstance) { - if (this.magneting) { - var a = this._board.dragBlock.getShadow(), c = this.requestAbsoluteCoordinate(), c = "translate(" + c.x + "," + c.y + ")"; - $(a).attr({transform:c, display:"block"}); - this._clonedShadow = a; - this.background && (this.background.remove(), this.nextBackground.remove(), delete this.background, delete this.nextBackground); - a = this._board.dragBlock.getBelowHeight(); - this.statementSvgGroup.attr({transform:"translate(0," + a + ")"}); - this.set({height:this.height + a}); - } else { - this._clonedShadow && (this._clonedShadow.attr({display:"none"}), delete this._clonedShadow), a = this.originalHeight, void 0 !== a && (this.background && (this.background.remove(), this.nextBackground.remove(), delete this.background, delete this.nextBackground), delete this.originalHeight), this.statementSvgGroup.attr({transform:"translate(0,0)"}), this.calcHeight(); - } - (a = this.block.thread.changeEvent) && a.notify(); + b.setBoard = function(a) { + this._dragBlockObserver && this._dragBlockObserver.destroy(); + this.board = a; + this.svgGroup || this._generateView(); + var b = a.svg, d = b.firstChild; + d ? b.insertBefore(this.svgGroup, d) : b.appendChild(this.svgGroup); + this._dragBlockObserver = a.observe(this, "updateDragBlock", ["dragBlock"]); + this.svgGroup.attr({filter:"url(#entryTrashcanFilter_" + a.suffix + ")"}); + this.setPosition(); + }; +})(Entry.FieldTrashcan.prototype); +Entry.Vim = function(b) { + b = "string" === typeof b ? $("#" + b) : $(b); + if ("DIV" !== b.prop("tagName")) { + return console.error("Dom is not div element"); + } + this.createDom(b); + this._parser = new Entry.Parser("maze", "js", this.codeMirror); + this._blockParser = new Entry.Parser("maze", "block"); + Entry.Model(this, !1); + window.eventset = []; +}; +(function(b) { + b.createDom = function(a) { + function b(a) { + var c = e.getCodeToText(a.block); + e.codeMirror.display.dragFunctions.leave(a); + var d = Entry.Utils.createMouseEvent("mousedown", a); + e.codeMirror.display.scroller.dispatchEvent(d); + var c = c.split("\n"), k = c.length - 1, l = 0; + c.forEach(function(a, b) { + e.codeMirror.replaceSelection(a); + l = e.doc.getCursor().line; + e.codeMirror.indentLine(l); + 0 !== b && k === b || e.codeMirror.replaceSelection("\n"); + }); + a = Entry.Utils.createMouseEvent("mouseup", a); + e.codeMirror.display.scroller.dispatchEvent(a); + } + function d(a) { + e.codeMirror.display.dragFunctions.over(a); } + var e; + this.view = Entry.Dom("div", {parent:a, class:"entryVimBoard"}); + this.codeMirror = CodeMirror(this.view[0], {lineNumbers:!0, value:"", mode:{name:"javascript", globalVars:!0}, theme:"default", indentUnit:4, styleActiveLine:!0, extraKeys:{"Ctrl-Space":"javascriptComplete", Tab:function(a) { + var b = Array(a.getOption("indentUnit") + 1).join(" "); + a.replaceSelection(b); + }}, lint:!0, viewportMargin:10}); + this.doc = this.codeMirror.getDoc(); + e = this; + a = this.view[0]; + a.removeEventListener("dragEnd", b); + a.removeEventListener("dragOver", d); + a.addEventListener("dragEnd", b); + a.addEventListener("dragOver", d); }; - a.insertTopBlock = function(a) { - this._posObserver && this._posObserver.destroy(); - var c = this.firstBlock; - (this.firstBlock = a) && a.doInsert(this._thread); - return c; + b.hide = function() { + this.view.addClass("entryRemove"); }; - a.getNextBlock = function() { - return this.firstBlock; + b.show = function() { + this.view.removeClass("entryRemove"); }; - a.checkTopBlock = function() { - var a = this._thread.getFirstBlock(); - a && this.firstBlock !== a ? (this.firstBlock = a, a.view.bindPrev(this), a._updatePos()) : a || (this.firstBlock = null); + b.textToCode = function() { + var a = this.codeMirror.getValue(), a = this._parser.parse(a); + if (0 === a.length) { + throw "\ube14\ub85d \ud30c\uc2f1 \uc624\ub958"; + } + return a; }; -})(Entry.FieldStatement.prototype); -Entry.FieldText = function(a, b, c) { - this._block = b.block; - this._blockView = b; - this._index = c; - this.box = new Entry.BoxModel; - this._fontSize = a.fontSize || b.getSkeleton().fontSize || 12; - this._color = a.color || this._block.getSchema().fontColor || b.getSkeleton().color || "white"; - this._align = a.align || "left"; - this._text = this.getValue() || a.text; - this.setValue(null); - this.textElement = null; - this.renderStart(b); -}; -Entry.Utils.inherit(Entry.Field, Entry.FieldText); -(function(a) { - a.renderStart = function() { - this.svgGroup && $(this.svgGroup).remove(); - this.svgGroup = this._blockView.contentSvgGroup.elem("g"); - this._text = this._text.replace(/(\r\n|\n|\r)/gm, " "); - this.textElement = this.svgGroup.elem("text").attr({style:"white-space: pre; font-size:" + this._fontSize + "px", "class":"dragNone", fill:this._color}); - this.textElement.textContent = this._text; - var a = 0, c = this.textElement.getBoundingClientRect(); - "center" == this._align && (a = -c.width / 2); - this.textElement.attr({x:a, y:.25 * c.height}); - this.box.set({x:0, y:0, width:c.width, height:c.height}); + b.codeToText = function(a) { + a = this._blockParser.parse(a); + this.codeMirror.setValue(a); }; -})(Entry.FieldText.prototype); -Entry.FieldTextInput = function(a, b, c) { - this._blockView = b; - this._block = b.block; - this.box = new Entry.BoxModel; - this.svgGroup = null; - this.position = a.position; - this._contents = a; - this._index = c; - this.value = this.getValue() || ""; - this.renderStart(); + b.getCodeToText = function(a) { + return this._blockParser.parse(a); + }; +})(Entry.Vim.prototype); +Entry.Workspace = function(b) { + Entry.Model(this, !1); + this.observe(this, "_handleChangeBoard", ["selectedBoard"], !1); + this.trashcan = new Entry.FieldTrashcan; + var a = b.blockMenu; + a && (this.blockMenu = new Entry.BlockMenu(a.dom, a.align, a.categoryData, a.scroll), this.blockMenu.workspace = this, this.blockMenu.observe(this, "_setSelectedBlockView", ["selectedBlockView"], !1)); + if (a = b.board) { + a.workspace = this, this.board = new Entry.Board(a), this.board.observe(this, "_setSelectedBlockView", ["selectedBlockView"], !1), this.set({selectedBoard:this.board}); + } + if (a = b.vimBoard) { + this.vimBoard = new Entry.Vim(a.dom), this.vimBoard.workspace = this; + } + this.board && this.vimBoard && this.vimBoard.hide(); + Entry.GlobalSvg.createDom(); + this.mode = Entry.Workspace.MODE_BOARD; + Entry.keyPressed && Entry.keyPressed.attach(this, this._keyboardControl); + this.changeEvent = new Entry.Event(this); + Entry.commander.setCurrentEditor("board", this.board); }; -Entry.Utils.inherit(Entry.Field, Entry.FieldTextInput); -(function(a) { - a.renderStart = function() { - this.svgGroup && $(this.svgGroup).remove(); - this.svgGroup = this._blockView.contentSvgGroup.elem("g"); - this.svgGroup.attr({class:"entry-input-field"}); - this.textElement = this.svgGroup.elem("text", {x:3, y:4, "font-size":"9pt"}); - this.textElement.textContent = this.truncate(); - var a = this.getTextWidth(), c = this.position && this.position.y ? this.position.y : 0; - this._header = this.svgGroup.elem("rect", {width:a, height:16, y:c - 8, rx:3, ry:3, fill:"transparent"}); - this.svgGroup.appendChild(this.textElement); - this._bindRenderOptions(); - this.box.set({x:0, y:0, width:a, height:16}); +Entry.Workspace.MODE_BOARD = 0; +Entry.Workspace.MODE_VIMBOARD = 1; +Entry.Workspace.MODE_OVERLAYBOARD = 2; +(function(b) { + b.schema = {selectedBlockView:null, selectedBoard:null}; + b.getBoard = function() { + return this.board; }; - a.renderOptions = function() { - var a = this; - this._attachDisposeEvent(function() { - a.applyValue(); - a.destroyOption(); - }); - this.optionGroup = Entry.Dom("input", {class:"entry-widget-input-field", parent:$("body")}); - this.optionGroup.val(this.getValue()); - this.optionGroup.on("mousedown", function(a) { - a.stopPropagation(); - }); - this.optionGroup.on("keyup", function(c) { - var e = c.keyCode || c.which; - a.applyValue(c); - -1 < [13, 27].indexOf(e) && a.destroyOption(); - }); - var c = this.getAbsolutePosFromDocument(); - c.y -= this.box.height / 2; - this.optionGroup.css({height:16, left:c.x, top:c.y, width:a.box.width}); - this.optionGroup.focus(); - this.optionGroup.select(); + b.getSelectedBoard = function() { + return this.selectedBoard; + }; + b.getBlockMenu = function() { + return this.blockMenu; + }; + b.getVimBoard = function() { + return this.vimBoard; + }; + b.getMode = function() { + return this.mode; }; - a.applyValue = function(a) { - a = this.optionGroup.val(); - this.setValue(a); - this.textElement.textContent = this.truncate(); - this.resize(); + b.setMode = function(a, b) { + a = +a; + var d = this.mode; + this.mode = a; + switch(a) { + case d: + return; + case Entry.Workspace.MODE_VIMBOARD: + this.board && this.board.hide(); + this.overlayBoard && this.overlayBoard.hide(); + this.set({selectedBoard:this.vimBoard}); + this.vimBoard.show(); + this.vimBoard.codeToText(this.board.code); + this.blockMenu.renderText(); + this.board.clear(); + break; + case Entry.Workspace.MODE_BOARD: + try { + this.board.show(), this.set({selectedBoard:this.board}), this.textToCode(d), this.vimBoard && this.vimBoard.hide(), this.overlayBoard && this.overlayBoard.hide(), this.blockMenu.renderBlock(); + } catch (e) { + throw this.board && this.board.hide(), this.set({selectedBoard:this.vimBoard}), Entry.dispatchEvent("setProgrammingMode", Entry.Workspace.MODE_VIMBOARD), e; + } + Entry.commander.setCurrentEditor("board", this.board); + break; + case Entry.Workspace.MODE_OVERLAYBOARD: + this.overlayBoard || this.initOverlayBoard(), this.overlayBoard.show(), this.set({selectedBoard:this.overlayBoard}), Entry.commander.setCurrentEditor("board", this.overlayBoard); + } + this.changeEvent.notify(b); }; - a.resize = function() { - var a = this.getTextWidth(); - this._header.attr({width:a}); - this.optionGroup.css({width:a}); - this.box.set({width:a}); - this._blockView.alignContent(); + b.changeBoardCode = function(a) { + this.board.changeCode(a); }; - a.getTextWidth = function() { - return this.textElement.getComputedTextLength() + 6 + 2; + b.changeOverlayBoardCode = function(a) { + this.overlayBoard && this.overlayBoard.changeCode(a); }; -})(Entry.FieldTextInput.prototype); -Entry.GlobalSvg = {}; -(function(a) { - a.DONE = 0; - a._inited = !1; - a.REMOVE = 1; - a.RETURN = 2; - a.createDom = function() { - if (!this.inited) { - $("#globalSvgSurface").remove(); - $("#globalSvg").remove(); - var a = $("body"); - this._container = Entry.Dom("div", {classes:["globalSvgSurface", "entryRemove"], id:"globalSvgSurface", parent:a}); - this.svgDom = Entry.Dom($(''), {parent:this._container}); - this.svg = Entry.SVG("globalSvg"); - this.top = this.left = 0; - this._inited = !0; + b.changeBlockMenuCode = function(a) { + this.blockMenu.changeCode(a); + }; + b.textToCode = function(a) { + if (a == Entry.Workspace.MODE_VIMBOARD) { + a = this.vimBoard.textToCode(); + var b = this.board, d = b.code; + d.load(a); + d.createView(b); + b.reDraw(); + this.board.alignThreads(); } }; - a.setView = function(a, c) { - if (a != this._view && !a.block.isReadOnly() && a.movable) { - return this._view = a, this._mode = c, c !== Entry.Workspace.MODE_VIMBOARD && a.set({visible:!1}), this.draw(), this.show(), this.align(), this.position(), !0; + b.codeToText = function(a) { + return this.vimBoard.codeToText(a); + }; + b.getCodeToText = function(a) { + return this.vimBoard.getCodeToText(a); + }; + b._setSelectedBlockView = function() { + this.set({selectedBlockView:this.board.selectedBlockView || this.blockMenu.selectedBlockView || (this.overlayBoard ? this.overlayBoard.selectedBlockView : null)}); + }; + b.initOverlayBoard = function() { + this.overlayBoard = new Entry.Board({dom:this.board.view, workspace:this, isOverlay:!0}); + this.overlayBoard.changeCode(new Entry.Code([])); + this.overlayBoard.workspace = this; + this.overlayBoard.observe(this, "_setSelectedBlockView", ["selectedBlockView"], !1); + }; + b._keyboardControl = function(a) { + var b = a.keyCode || a.which, d = a.ctrlKey; + if (!Entry.Utils.isInInput(a)) { + var e = this.selectedBlockView; + e && !e.isInBlockMenu && e.block.isDeletable() && (8 == b || 46 == b ? (Entry.do("destroyBlock", e.block), a.preventDefault()) : d && (67 == b ? e.block.copyToClipboard() : 88 == b && (a = e.block, a.copyToClipboard(), a.destroy(!0, !0), e.getBoard().setSelectedBlock(null)))); + d && 86 == b && (b = this.selectedBoard) && b instanceof Entry.Board && Entry.clipboard && Entry.do("addThread", Entry.clipboard).value.getFirstBlock().copyToClipboard(); } }; - a.draw = function() { - var a = this._view; - this._svg && this.remove(); - var c = this._mode == Entry.Workspace.MODE_VIMBOARD; - this.svgGroup = Entry.SVG.createElement(a.svgGroup.cloneNode(!0), {opacity:1}); - this.svg.appendChild(this.svgGroup); - c && (a = $(this.svgGroup), a.find("g").css({filter:"none"}), a.find("path").velocity({opacity:0}, {duration:500}), a.find("text").velocity({fill:"#000000"}, {duration:530})); + b._handleChangeBoard = function() { + var a = this.selectedBoard; + a && a.constructor === Entry.Board && this.trashcan.setBoard(a); + }; +})(Entry.Workspace.prototype); +Entry.Playground = function() { + this.enableArduino = this.isTextBGMode_ = !1; + this.viewMode_ = "default"; + Entry.addEventListener("textEdited", this.injectText); + Entry.addEventListener("hwChanged", this.updateHW); +}; +Entry.Playground.prototype.generateView = function(b, a) { + this.view_ = b; + this.view_.addClass("entryPlayground"); + if (a && "workspace" != a) { + "phone" == a && (this.view_.addClass("entryPlaygroundPhone"), c = Entry.createElement("div", "entryCategoryTab"), c.addClass("entryPlaygroundTabPhone"), Entry.view_.insertBefore(c, this.view_), this.generateTabView(c), this.tabView_ = c, c = Entry.createElement("div", "entryCurtain"), c.addClass("entryPlaygroundCurtainPhone"), c.addClass("entryRemove"), c.innerHTML = Lang.Workspace.cannot_edit_click_to_stop, c.bindOnClick(function() { + Entry.engine.toggleStop(); + }), this.view_.appendChild(c), this.curtainView_ = c, Entry.pictureEditable && (c = Entry.createElement("div", "entryPicture"), c.addClass("entryPlaygroundPicturePhone"), c.addClass("entryRemove"), this.view_.appendChild(c), this.generatePictureView(c), this.pictureView_ = c), c = Entry.createElement("div", "entryText"), c.addClass("entryRemove"), this.view_.appendChild(c), this.generateTextView(c), this.textView_ = c, Entry.soundEditable && (c = Entry.createElement("div", "entrySound"), c.addClass("entryPlaygroundSoundWorkspacePhone"), + c.addClass("entryRemove"), this.view_.appendChild(c), this.generateSoundView(c), this.soundView_ = c), c = Entry.createElement("div", "entryDefault"), this.view_.appendChild(c), this.generateDefaultView(c), this.defaultView_ = c, c = Entry.createElement("div", "entryCode"), c.addClass("entryPlaygroundCodePhone"), this.view_.appendChild(c), this.generateCodeView(c), this.codeView_ = this.codeView_ = c, Entry.addEventListener("run", function(a) { + Entry.playground.curtainView_.removeClass("entryRemove"); + }), Entry.addEventListener("stop", function(a) { + Entry.playground.curtainView_.addClass("entryRemove"); + })); + } else { + this.view_.addClass("entryPlaygroundWorkspace"); + var c = Entry.createElement("div", "entryCategoryTab"); + c.addClass("entryPlaygroundTabWorkspace"); + this.view_.appendChild(c); + this.generateTabView(c); + this.tabView_ = c; + c = Entry.createElement("div", "entryCurtain"); + c.addClass("entryPlaygroundCurtainWorkspace"); + c.addClass("entryRemove"); + var d = Lang.Workspace.cannot_edit_click_to_stop.split("."); + c.innerHTML = d[0] + ".
" + d[1]; + c.addEventListener("click", function() { + Entry.engine.toggleStop(); + }); + this.view_.appendChild(c); + this.curtainView_ = c; + Entry.pictureEditable && (c = Entry.createElement("div", "entryPicture"), c.addClass("entryPlaygroundPictureWorkspace"), c.addClass("entryRemove"), this.view_.appendChild(c), this.generatePictureView(c), this.pictureView_ = c); + c = Entry.createElement("div", "entryText"); + c.addClass("entryPlaygroundTextWorkspace"); + c.addClass("entryRemove"); + this.view_.appendChild(c); + this.generateTextView(c); + this.textView_ = c; + Entry.soundEditable && (c = Entry.createElement("div", "entrySound"), c.addClass("entryPlaygroundSoundWorkspace"), c.addClass("entryRemove"), this.view_.appendChild(c), this.generateSoundView(c), this.soundView_ = c); + c = Entry.createElement("div", "entryDefault"); + c.addClass("entryPlaygroundDefaultWorkspace"); + this.view_.appendChild(c); + this.generateDefaultView(c); + this.defaultView_ = c; + c = Entry.createElement("div", "entryCode"); + c.addClass("entryPlaygroundCodeWorkspace"); + c.addClass("entryRemove"); + this.view_.appendChild(c); + this.generateCodeView(c); + this.codeView_ = c; + d = Entry.createElement("div"); + d.addClass("entryPlaygroundResizeWorkspace", "entryRemove"); + this.resizeHandle_ = d; + this.view_.appendChild(d); + this.initializeResizeHandle(d); + this.codeView_ = c; + Entry.addEventListener("run", function(a) { + Entry.playground.curtainView_.removeClass("entryRemove"); + }); + Entry.addEventListener("stop", function(a) { + Entry.playground.curtainView_.addClass("entryRemove"); + }); + } +}; +Entry.Playground.prototype.generateDefaultView = function(b) { + return b; +}; +Entry.Playground.prototype.generateTabView = function(b) { + var a = this, c = Entry.createElement("ul"); + c.addClass("entryTabListWorkspace"); + this.tabList_ = c; + b.appendChild(c); + this.tabViewElements = {}; + b = Entry.createElement("li", "entryCodeTab"); + b.innerHTML = Lang.Workspace.tab_code; + b.addClass("entryTabListItemWorkspace"); + b.addClass("entryTabSelected"); + c.appendChild(b); + b.bindOnClick(function(b) { + a.changeViewMode("code"); + a.blockMenu.reDraw(); + }); + this.tabViewElements.code = b; + Entry.pictureEditable && (b = Entry.createElement("li", "entryPictureTab"), b.innerHTML = Lang.Workspace.tab_picture, b.addClass("entryTabListItemWorkspace"), c.appendChild(b), b.bindOnClick(function(a) { + Entry.playground.changeViewMode("picture"); + }), this.tabViewElements.picture = b, b = Entry.createElement("li", "entryTextboxTab"), b.innerHTML = Lang.Workspace.tab_text, b.addClass("entryTabListItemWorkspace"), c.appendChild(b), b.bindOnClick(function(a) { + Entry.playground.changeViewMode("text"); + }), this.tabViewElements.text = b, b.addClass("entryRemove")); + Entry.soundEditable && (b = Entry.createElement("li", "entrySoundTab"), b.innerHTML = Lang.Workspace.tab_sound, b.addClass("entryTabListItemWorkspace"), c.appendChild(b), b.bindOnClick(function(a) { + Entry.playground.changeViewMode("sound"); + }), this.tabViewElements.sound = b); + Entry.hasVariableManager && (b = Entry.createElement("li", "entryVariableTab"), b.innerHTML = Lang.Workspace.tab_attribute, b.addClass("entryTabListItemWorkspace"), b.addClass("entryVariableTabWorkspace"), c.appendChild(b), b.bindOnClick(function(a) { + Entry.playground.toggleOnVariableView(); + Entry.playground.changeViewMode("variable"); + }), this.tabViewElements.variable = b); +}; +Entry.Playground.prototype.generateCodeView = function(b) { + var a = this.createVariableView(); + b.appendChild(a); + this.variableView_ = a; + b = Entry.Dom(b); + a = Entry.Dom("div", {parent:b, id:"entryWorkspaceBoard", class:"entryWorkspaceBoard"}); + b = Entry.Dom("div", {parent:b, id:"entryWorkspaceBlockMenu", class:"entryWorkspaceBlockMenu"}); + this.mainWorkspace = new Entry.Workspace({blockMenu:{dom:b, align:"LEFT", categoryData:EntryStatic.getAllBlocks(), scroll:!0}, board:{dom:a}}); + this.blockMenu = this.mainWorkspace.blockMenu; + this.board = this.mainWorkspace.board; + Entry.hw && this.updateHW(); +}; +Entry.Playground.prototype.generatePictureView = function(b) { + if ("workspace" == Entry.type) { + var a = Entry.createElement("div", "entryAddPicture"); + a.addClass("entryPlaygroundAddPicture"); + a.bindOnClick(function(a) { + Entry.dispatchEvent("openPictureManager"); + }); + var c = Entry.createElement("div", "entryAddPictureInner"); + c.addClass("entryPlaygroundAddPictureInner"); + c.innerHTML = Lang.Workspace.picture_add; + a.appendChild(c); + b.appendChild(a); + a = Entry.createElement("ul", "entryPictureList"); + a.addClass("entryPlaygroundPictureList"); + $ && $(a).sortable({start:function(a, b) { + b.item.data("start_pos", b.item.index()); + }, stop:function(a, b) { + var c = b.item.data("start_pos"), g = b.item.index(); + Entry.playground.movePicture(c, g); + }, axis:"y"}); + b.appendChild(a); + this.pictureListView_ = a; + a = Entry.createElement("div", "entryPainter"); + a.addClass("entryPlaygroundPainter"); + b.appendChild(a); + this.painter = new Entry.Painter; + this.painter.initialize(a); + } else { + "phone" == Entry.type && (a = Entry.createElement("div", "entryAddPicture"), a.addClass("entryPlaygroundAddPicturePhone"), a.bindOnClick(function(a) { + Entry.dispatchEvent("openPictureManager"); + }), c = Entry.createElement("div", "entryAddPictureInner"), c.addClass("entryPlaygroundAddPictureInnerPhone"), c.innerHTML = Lang.Workspace.picture_add, a.appendChild(c), b.appendChild(a), a = Entry.createElement("ul", "entryPictureList"), a.addClass("entryPlaygroundPictureListPhone"), $ && $(a).sortable({start:function(a, b) { + b.item.data("start_pos", b.item.index()); + }, stop:function(a, b) { + var c = b.item.data("start_pos"), g = b.item.index(); + Entry.playground.movePicture(c, g); + }, axis:"y"}), b.appendChild(a), this.pictureListView_ = a); + } +}; +Entry.Playground.prototype.generateTextView = function(b) { + var a = Entry.createElement("div"); + b.appendChild(a); + b = Entry.createElement("div"); + b.addClass("textProperties"); + a.appendChild(b); + var c = Entry.createElement("div"); + c.addClass("entryTextFontSelect"); + b.appendChild(c); + var d = Entry.createElement("select", "entryPainterAttrFontName"); + d.addClass("entryPlaygroundPainterAttrFontName", "entryTextFontSelecter"); + d.size = "1"; + d.onchange = function(a) { + Entry.playground.object.entity.setFontType(a.target.value); + }; + for (var e = 0;e < Entry.fonts.length;e++) { + var f = Entry.fonts[e], g = Entry.createElement("option"); + g.value = f.family; + g.innerHTML = f.name; + d.appendChild(g); + } + this.fontName_ = d; + c.appendChild(d); + e = Entry.createElement("ul"); + e.addClass("entryPlayground_text_buttons"); + b.appendChild(e); + c = Entry.createElement("li"); + c.addClass("entryPlaygroundTextAlignLeft"); + c.bindOnClick(function(a) { + Entry.playground.setFontAlign(Entry.TEXT_ALIGN_LEFT); + }); + e.appendChild(c); + this.alignLeftBtn = c; + c = Entry.createElement("li"); + c.addClass("entryPlaygroundTextAlignCenter"); + c.bindOnClick(function(a) { + Entry.playground.setFontAlign(Entry.TEXT_ALIGN_CENTER); + }); + e.appendChild(c); + this.alignCenterBtn = c; + c = Entry.createElement("li"); + c.addClass("entryPlaygroundTextAlignRight"); + c.bindOnClick(function(a) { + Entry.playground.setFontAlign(Entry.TEXT_ALIGN_RIGHT); + }); + e.appendChild(c); + this.alignRightBtn = c; + c = Entry.createElement("li"); + e.appendChild(c); + d = Entry.createElement("a"); + c.appendChild(d); + d.bindOnClick(function() { + Entry.playground.object.entity.toggleFontBold() ? h.src = Entry.mediaFilePath + "text_button_bold_true.png" : h.src = Entry.mediaFilePath + "text_button_bold_false.png"; + }); + var h = Entry.createElement("img", "entryPlaygroundText_boldImage"); + d.appendChild(h); + h.src = Entry.mediaFilePath + "text_button_bold_false.png"; + c = Entry.createElement("li"); + e.appendChild(c); + d = Entry.createElement("a"); + c.appendChild(d); + d.bindOnClick(function() { + var a = !Entry.playground.object.entity.getUnderLine() || !1; + k.src = Entry.mediaFilePath + "text_button_underline_" + a + ".png"; + Entry.playground.object.entity.setUnderLine(a); + }); + var k = Entry.createElement("img", "entryPlaygroundText_underlineImage"); + d.appendChild(k); + k.src = Entry.mediaFilePath + "text_button_underline_false.png"; + c = Entry.createElement("li"); + e.appendChild(c); + d = Entry.createElement("a"); + c.appendChild(d); + d.bindOnClick(function() { + Entry.playground.object.entity.toggleFontItalic() ? l.src = Entry.mediaFilePath + "text_button_italic_true.png" : l.src = Entry.mediaFilePath + "/text_button_italic_false.png"; + }); + var l = Entry.createElement("img", "entryPlaygroundText_italicImage"); + d.appendChild(l); + l.src = Entry.mediaFilePath + "text_button_italic_false.png"; + c = Entry.createElement("li"); + e.appendChild(c); + d = Entry.createElement("a"); + c.appendChild(d); + d.bindOnClick(function() { + var a = !Entry.playground.object.entity.getStrike() || !1; + Entry.playground.object.entity.setStrike(a); + n.src = Entry.mediaFilePath + "text_button_strike_" + a + ".png"; + }); + var n = Entry.createElement("img", "entryPlaygroundText_strikeImage"); + d.appendChild(n); + n.src = Entry.mediaFilePath + "text_button_strike_false.png"; + d = Entry.createElement("li"); + e.appendChild(d); + c = Entry.createElement("a"); + d.appendChild(c); + c.bindOnClick(function() { + Entry.playground.toggleColourChooser("foreground"); + }); + d = Entry.createElement("img"); + c.appendChild(d); + d.src = Entry.mediaFilePath + "text_button_color_false.png"; + c = Entry.createElement("li"); + e.appendChild(c); + e = Entry.createElement("a"); + c.appendChild(e); + e.bindOnClick(function() { + Entry.playground.toggleColourChooser("background"); + }); + c = Entry.createElement("img"); + e.appendChild(c); + c.src = Entry.mediaFilePath + "text_button_background_false.png"; + e = Entry.createElement("div"); + e.addClass("entryPlayground_fgColorDiv"); + c = Entry.createElement("div"); + c.addClass("entryPlayground_bgColorDiv"); + b.appendChild(e); + b.appendChild(c); + d = Entry.createElement("div"); + d.addClass("entryPlaygroundTextColoursWrapper"); + this.coloursWrapper = d; + a.appendChild(d); + b = Entry.getColourCodes(); + for (e = 0;e < b.length;e++) { + c = Entry.createElement("div"), c.addClass("modal_colour"), c.setAttribute("colour", b[e]), c.style.backgroundColor = b[e], 0 === e && c.addClass("modalColourTrans"), c.bindOnClick(function(a) { + Entry.playground.setTextColour(a.target.getAttribute("colour")); + }), d.appendChild(c); + } + d.style.display = "none"; + d = Entry.createElement("div"); + d.addClass("entryPlaygroundTextBackgroundsWrapper"); + this.backgroundsWrapper = d; + a.appendChild(d); + for (e = 0;e < b.length;e++) { + c = Entry.createElement("div"), c.addClass("modal_colour"), c.setAttribute("colour", b[e]), c.style.backgroundColor = b[e], 0 === e && c.addClass("modalColourTrans"), c.bindOnClick(function(a) { + Entry.playground.setBackgroundColour(a.target.getAttribute("colour")); + }), d.appendChild(c); + } + d.style.display = "none"; + b = Entry.createElement("input"); + b.addClass("entryPlayground_textBox"); + b.onkeyup = function() { + Entry.playground.object.setText(this.value); + Entry.playground.object.entity.setText(this.value); }; - a.remove = function() { - this.svgGroup && (this.svgGroup.remove(), delete this.svgGroup, delete this._view, delete this._offsetX, delete this._offsetY, delete this._startX, delete this._startY, this.hide()); + b.onblur = function() { + Entry.dispatchEvent("textEdited"); }; - a.align = function() { - var a = this._view.getSkeleton().box(this._view).offsetX || 0, c = this._view.getSkeleton().box(this._view).offsetY || 0, a = -1 * a + 1, c = -1 * c + 1; - this._offsetX = a; - this._offsetY = c; - this.svgGroup.attr({transform:"translate(" + a + "," + c + ")"}); + this.textEditInput = b; + a.appendChild(b); + b = Entry.createElement("textarea"); + b.addClass("entryPlayground_textArea"); + b.style.display = "none"; + b.onkeyup = function() { + Entry.playground.object.setText(this.value); + Entry.playground.object.entity.setText(this.value); }; - a.show = function() { - this._container.removeClass("entryRemove"); + b.onblur = function() { + Entry.dispatchEvent("textEdited"); }; - a.hide = function() { - this._container.addClass("entryRemove"); + this.textEditArea = b; + a.appendChild(b); + b = Entry.createElement("div"); + b.addClass("entryPlaygroundFontSizeWrapper"); + a.appendChild(b); + this.fontSizeWrapper = b; + var m = Entry.createElement("div"); + m.addClass("entryPlaygroundFontSizeSlider"); + b.appendChild(m); + var q = Entry.createElement("div"); + q.addClass("entryPlaygroundFontSizeIndicator"); + m.appendChild(q); + this.fontSizeIndiciator = q; + var r = Entry.createElement("div"); + r.addClass("entryPlaygroundFontSizeKnob"); + m.appendChild(r); + this.fontSizeKnob = r; + e = Entry.createElement("div"); + e.addClass("entryPlaygroundFontSizeLabel"); + e.innerHTML = "\uae00\uc790 \ud06c\uae30"; + b.appendChild(e); + var u = !1, t = 0; + r.onmousedown = function(a) { + u = !0; + t = $(m).offset().left; }; - a.position = function() { - var a = this._view; - if (a) { - var c = a.getAbsoluteCoordinate(), a = a.getBoard().offset(); - this.left = c.x + a.left - this._offsetX; - this.top = c.y + a.top - this._offsetY; - this.svgDom.css({transform:"translate3d(" + this.left + "px," + this.top + "px, 0px)"}); + document.addEventListener("mousemove", function(a) { + u && (a = a.pageX - t, a = Math.max(a, 5), a = Math.min(a, 88), r.style.left = a + "px", a /= .88, q.style.width = a + "%", Entry.playground.object.entity.setFontSize(a)); + }); + document.addEventListener("mouseup", function(a) { + u = !1; + }); + b = Entry.createElement("div"); + b.addClass("entryPlaygroundLinebreakWrapper"); + a.appendChild(b); + a = Entry.createElement("hr"); + a.addClass("entryPlaygroundLinebreakHorizontal"); + b.appendChild(a); + a = Entry.createElement("div"); + a.addClass("entryPlaygroundLinebreakButtons"); + b.appendChild(a); + e = Entry.createElement("img"); + e.bindOnClick(function() { + Entry.playground.toggleLineBreak(!1); + v.innerHTML = Lang.Menus.linebreak_off_desc_1; + x.innerHTML = Lang.Menus.linebreak_off_desc_2; + y.innerHTML = Lang.Menus.linebreak_off_desc_3; + }); + e.src = Entry.mediaFilePath + "text-linebreak-off-true.png"; + a.appendChild(e); + this.linebreakOffImage = e; + e = Entry.createElement("img"); + e.bindOnClick(function() { + Entry.playground.toggleLineBreak(!0); + v.innerHTML = Lang.Menus.linebreak_on_desc_1; + x.innerHTML = Lang.Menus.linebreak_on_desc_2; + y.innerHTML = Lang.Menus.linebreak_on_desc_3; + }); + e.src = Entry.mediaFilePath + "text-linebreak-on-false.png"; + a.appendChild(e); + this.linebreakOnImage = e; + a = Entry.createElement("div"); + a.addClass("entryPlaygroundLinebreakDescription"); + b.appendChild(a); + var v = Entry.createElement("p"); + v.innerHTML = Lang.Menus.linebreak_off_desc_1; + a.appendChild(v); + b = Entry.createElement("ul"); + a.appendChild(b); + var x = Entry.createElement("li"); + x.innerHTML = Lang.Menus.linebreak_off_desc_2; + b.appendChild(x); + var y = Entry.createElement("li"); + y.innerHTML = Lang.Menus.linebreak_off_desc_3; + b.appendChild(y); +}; +Entry.Playground.prototype.generateSoundView = function(b) { + if ("workspace" == Entry.type) { + var a = Entry.createElement("div", "entryAddSound"); + a.addClass("entryPlaygroundAddSound"); + a.bindOnClick(function(a) { + Entry.dispatchEvent("openSoundManager"); + }); + var c = Entry.createElement("div", "entryAddSoundInner"); + c.addClass("entryPlaygroundAddSoundInner"); + c.innerHTML = Lang.Workspace.sound_add; + a.appendChild(c); + b.appendChild(a); + a = Entry.createElement("ul", "entrySoundList"); + a.addClass("entryPlaygroundSoundList"); + $ && $(a).sortable({start:function(a, b) { + b.item.data("start_pos", b.item.index()); + }, stop:function(a, b) { + var c = b.item.data("start_pos"), g = b.item.index(); + Entry.playground.moveSound(c, g); + }, axis:"y"}); + b.appendChild(a); + this.soundListView_ = a; + } else { + "phone" == Entry.type && (a = Entry.createElement("div", "entryAddSound"), a.addClass("entryPlaygroundAddSoundPhone"), a.bindOnClick(function(a) { + Entry.dispatchEvent("openSoundManager"); + }), c = Entry.createElement("div", "entryAddSoundInner"), c.addClass("entryPlaygroundAddSoundInnerPhone"), c.innerHTML = Lang.Workspace.sound_add, a.appendChild(c), b.appendChild(a), a = Entry.createElement("ul", "entrySoundList"), a.addClass("entryPlaygroundSoundListPhone"), $ && $(a).sortable({start:function(a, b) { + b.item.data("start_pos", b.item.index()); + }, stop:function(a, b) { + var c = b.item.data("start_pos"), g = b.item.index(); + Entry.playground.moveSound(c, g); + }, axis:"y"}), b.appendChild(a), this.soundListView_ = a); + } +}; +Entry.Playground.prototype.injectObject = function(b) { + if (!b) { + this.changeViewMode("code"), this.object = null; + } else { + if (b !== this.object) { + this.object && this.object.toggleInformation(!1); + this.object = b; + this.setMenu(b.objectType); + this.injectCode(); + "sprite" == b.objectType && Entry.pictureEditable ? (this.tabViewElements.text && this.tabViewElements.text.addClass("entryRemove"), this.tabViewElements.picture && this.tabViewElements.picture.removeClass("entryRemove")) : "textBox" == b.objectType && (this.tabViewElements.picture && this.tabViewElements.picture.addClass("entryRemove"), this.tabViewElements.text && this.tabViewElements.text.removeClass("entryRemove")); + var a = this.viewMode_; + "default" == a ? this.changeViewMode("code") : "picture" != a && "text" != a || "textBox" != b.objectType ? "text" != a && "picture" != a || "sprite" != b.objectType ? "sound" == a && this.changeViewMode("sound") : this.changeViewMode("picture") : this.changeViewMode("text"); + this.reloadPlayground(); } - }; - a.terminateDrag = function(a) { - var c = Entry.mouseCoordinate, d = a.getBoard(), e = d.workspace.blockMenu, f = e.offset().left, g = e.offset().top, h = e.visible ? e.svgDom.width() : 0; - return c.y > d.offset().top - 20 && c.x > f + h ? this.DONE : c.y > g && c.x > f && e.visible ? a.block.isDeletable() ? this.REMOVE : this.RETURN : this.RETURN; - }; - a.addControl = function(a) { - this.onMouseDown.apply(this, arguments); - }; - a.onMouseDown = function(a) { - function c(a) { - var b = a.pageX; - a = a.pageY; - var c = e.left + (b - e._startX), d = e.top + (a - e._startY); - e.svgDom.css({left:c, top:d}); - e._startX = b; - e._startY = a; - e.left = c; - e.top = d; + } +}; +Entry.Playground.prototype.injectCode = function() { + var b = this.mainWorkspace; + b.changeBoardCode(this.object.script); + b.getBoard().adjustThreadsPosition(); +}; +Entry.Playground.prototype.injectPicture = function() { + var b = this.pictureListView_; + if (b) { + for (;b.hasChildNodes();) { + b.removeChild(b.lastChild); } - function d(a) { - $(document).unbind(".block"); + if (this.object) { + for (var a = this.object.pictures, c = 0, d = a.length;c < d;c++) { + var e = a[c].view; + e || console.log(e); + e.orderHolder.innerHTML = c + 1; + b.appendChild(e); + } + this.selectPicture(this.object.selectedPicture); + } else { + Entry.dispatchEvent("pictureClear"); } - this._startY = a.pageY; - var e = this; - a.stopPropagation(); - a.preventDefault(); - var f = $(document); - f.bind("mousemove.block", c); - f.bind("mouseup.block", d); - f.bind("touchmove.block", c); - f.bind("touchend.block", d); - this._startX = a.pageX; - this._startY = a.pageY; - }; -})(Entry.GlobalSvg); -Entry.Mutator = function() { + } }; -(function(a) { - a.mutate = function(a, c) { - a = Entry.block[a]; - void 0 === a.changeEvent && (a.changeEvent = new Entry.Event); - a.template = c.template; - a.params = c.params; - a.changeEvent.notify(1); - }; -})(Entry.Mutator); -(function(a) { -})(Entry.Mutator.prototype); -Entry.RenderView = function(a, b) { - this._align = b || "CENTER"; - a = "string" === typeof a ? $("#" + a) : $(a); - if ("DIV" !== a.prop("tagName")) { - return console.error("Dom is not div element"); +Entry.Playground.prototype.addPicture = function(b, a) { + var c = Entry.cloneSimpleObject(b); + delete c.id; + delete c.view; + b = JSON.parse(JSON.stringify(c)); + b.id = Entry.generateHash(); + b.name = Entry.getOrderedName(b.name, this.object.pictures); + this.generatePictureElement(b); + this.object.addPicture(b); + this.injectPicture(); + this.selectPicture(b); +}; +Entry.Playground.prototype.setPicture = function(b) { + var a = Entry.container.getPictureElement(b.id, b.objectId), c = $(a); + if (a) { + b.view = a; + a.picture = b; + a = c.find("#t_" + b.id)[0]; + if (b.fileurl) { + a.style.backgroundImage = 'url("' + b.fileurl + '")'; + } else { + var d = b.filename; + a.style.backgroundImage = 'url("' + Entry.defaultPath + "/uploads/" + d.substring(0, 2) + "/" + d.substring(2, 4) + "/thumb/" + d + '.png")'; + } + c.find("#s_" + b.id)[0].innerHTML = b.dimension.width + " X " + b.dimension.height; } - this.view = a; - this.viewOnly = !0; - this.suffix = "renderView"; - this.disableMouseEvent = this.visible = !0; - this._svgId = "renderView_" + (new Date).getTime(); - this._generateView(); - this.offset = this.svgDom.offset(); - this.setWidth(); - this.svg = Entry.SVG(this._svgId); - Entry.Utils.addFilters(this.svg, this.suffix); - this.svg && (this.svgGroup = this.svg.elem("g"), this.svgThreadGroup = this.svgGroup.elem("g"), this.svgThreadGroup.board = this, this.svgBlockGroup = this.svgGroup.elem("g"), this.svgBlockGroup.board = this); + Entry.container.setPicture(b); }; -(function(a) { - a.schema = {code:null, dragBlock:null, closeBlock:null, selectedBlockView:null}; - a._generateView = function() { - this.renderViewContainer = Entry.Dom("div", {"class":"renderViewContainer", parent:this.view}); - this.svgDom = Entry.Dom($(''), {parent:this.renderViewContainer}); - }; - a.changeCode = function(a) { - if (!(a instanceof Entry.Code)) { - return console.error("You must inject code instance"); +Entry.Playground.prototype.clonePicture = function(b) { + b = Entry.playground.object.getPicture(b); + this.addPicture(b, !0); +}; +Entry.Playground.prototype.selectPicture = function(b) { + for (var a = this.object.pictures, c = 0, d = a.length;c < d;c++) { + var e = a[c]; + e.id === b.id ? e.view.addClass("entryPictureSelected") : e.view.removeClass("entryPictureSelected"); + } + var f; + b && b.id && (f = Entry.container.selectPicture(b.id, b.objectId)); + this.object.id === f && Entry.dispatchEvent("pictureSelected", b); +}; +Entry.Playground.prototype.movePicture = function(b, a) { + this.object.pictures.splice(a, 0, this.object.pictures.splice(b, 1)[0]); + this.injectPicture(); + Entry.stage.sortZorder(); +}; +Entry.Playground.prototype.injectText = function() { + if (Entry.playground.object) { + Entry.playground.textEditInput.value = Entry.playground.object.entity.getText(); + Entry.playground.textEditArea.value = Entry.playground.object.entity.getText(); + Entry.playground.fontName_.value = Entry.playground.object.entity.getFontName(); + if (Entry.playground.object.entity.font) { + var b = -1 < Entry.playground.object.entity.font.indexOf("bold") || !1; + $("#entryPlaygroundText_boldImage").attr("src", Entry.mediaFilePath + "text_button_bold_" + b + ".png"); + b = -1 < Entry.playground.object.entity.font.indexOf("italic") || !1; + $("#entryPlaygroundText_italicImage").attr("src", Entry.mediaFilePath + "text_button_italic_" + b + ".png"); + } + b = Entry.playground.object.entity.getUnderLine() || !1; + $("#entryPlaygroundText_underlineImage").attr("src", Entry.mediaFilePath + "text_button_underline_" + b + ".png"); + b = Entry.playground.object.entity.getStrike() || !1; + $("#entryPlaygroundText_strikeImage").attr("src", Entry.mediaFilePath + "text_button_strike_" + b + ".png"); + $(".entryPlayground_fgColorDiv").css("backgroundColor", Entry.playground.object.entity.colour); + $(".entryPlayground_bgColorDiv").css("backgroundColor", Entry.playground.object.entity.bgColour); + Entry.playground.toggleLineBreak(Entry.playground.object.entity.getLineBreak()); + Entry.playground.object.entity.getLineBreak() && ($(".entryPlaygroundLinebreakDescription > p").html(Lang.Menus.linebreak_on_desc_1), $(".entryPlaygroundLinebreakDescription > ul > li").eq(0).html(Lang.Menus.linebreak_on_desc_2), $(".entryPlaygroundLinebreakDescription > ul > li").eq(1).html(Lang.Menus.linebreak_on_desc_3)); + Entry.playground.setFontAlign(Entry.playground.object.entity.getTextAlign()); + b = Entry.playground.object.entity.getFontSize(); + Entry.playground.fontSizeIndiciator.style.width = b + "%"; + Entry.playground.fontSizeKnob.style.left = .88 * b + "px"; + } +}; +Entry.Playground.prototype.injectSound = function() { + var b = this.soundListView_; + if (b) { + for (;b.hasChildNodes();) { + b.removeChild(b.lastChild); } - this.code = a; - this.svg || (this.svg = Entry.SVG(this._svgId), this.svgGroup = this.svg.elem("g"), this.svgThreadGroup = this.svgGroup.elem("g"), this.svgThreadGroup.board = this, this.svgBlockGroup = this.svgGroup.elem("g"), this.svgBlockGroup.board = this); - a.createView(this); - this.align(); - this.resize(); - }; - a.align = function() { - var a = this.code.getThreads(); - if (a && 0 !== a.length) { - for (var c = 0, d = "LEFT" == this._align ? 20 : this.svgDom.width() / 2, e = 0, f = a.length;e < f;e++) { - var g = a[e].getFirstBlock().view; - g._moveTo(d, c - g.offsetY, !1); - g = g.svgGroup.getBBox().height; - c += g + 15; + if (this.object) { + for (var a = this.object.sounds, c = 0, d = a.length;c < d;c++) { + var e = a[c].view; + e.orderHolder.innerHTML = c + 1; + b.appendChild(e); } - this._bBox = this.svgGroup.getBBox(); - this.height = this._bBox.height; } - }; - a.hide = function() { - this.view.addClass("entryRemove"); - }; - a.show = function() { - this.view.removeClass("entryRemove"); - }; - a.setWidth = function() { - this._svgWidth = this.svgDom.width(); - this.offset = this.svgDom.offset(); - }; - a.bindCodeView = function(a) { - this.svgBlockGroup.remove(); - this.svgThreadGroup.remove(); - this.svgBlockGroup = a.svgBlockGroup; - this.svgThreadGroup = a.svgThreadGroup; - this.svgGroup.appendChild(this.svgThreadGroup); - this.svgGroup.appendChild(this.svgBlockGroup); - }; - a.resize = function() { - this.svg && this._bBox && $(this.svg).css("height", this._bBox.height + 10); - }; -})(Entry.RenderView.prototype); -Entry.ThreadView = function(a, b) { - Entry.Model(this, !1); - this.thread = a; - this.svgGroup = b.svgThreadGroup.elem("g"); - this.parent = b; + } +}; +Entry.Playground.prototype.moveSound = function(b, a) { + this.object.sounds.splice(a, 0, this.object.sounds.splice(b, 1)[0]); + this.updateListViewOrder("sound"); + Entry.stage.sortZorder(); +}; +Entry.Playground.prototype.addSound = function(b, a) { + var c = Entry.cloneSimpleObject(b); + delete c.view; + delete c.id; + b = JSON.parse(JSON.stringify(c)); + b.id = Entry.generateHash(); + b.name = Entry.getOrderedName(b.name, this.object.sounds); + this.generateSoundElement(b); + this.object.addSound(b); + this.injectSound(); +}; +Entry.Playground.prototype.changeViewMode = function(b) { + for (var a in this.tabViewElements) { + this.tabViewElements[a].removeClass("entryTabSelected"); + } + "default" != b && this.tabViewElements[b].addClass("entryTabSelected"); + if ("variable" != b) { + var c = this.view_.children; + for (a = 0;a < c.length;a++) { + var d = c[a]; + -1 < d.id.toUpperCase().indexOf(b.toUpperCase()) ? d.removeClass("entryRemove") : d.addClass("entryRemove"); + } + if ("picture" == b && (!this.pictureView_.object || this.pictureView_.object != this.object)) { + this.pictureView_.object = this.object, this.injectPicture(); + } else { + if ("sound" == b && (!this.soundView_.object || this.soundView_.object != this.object)) { + this.soundView_.object = this.object, this.injectSound(); + } else { + if ("text" == b && "textBox" == this.object.objectType || this.textView_.object != this.object) { + this.textView_.object = this.object, this.injectText(); + } + } + } + "code" == b && this.resizeHandle_ && this.resizeHandle_.removeClass("entryRemove"); + Entry.engine.isState("run") && this.curtainView_.removeClass("entryRemove"); + this.viewMode_ = b; + this.toggleOffVariableView(); + } +}; +Entry.Playground.prototype.createVariableView = function() { + var b = Entry.createElement("div"); + Entry.type && "workspace" != Entry.type ? "phone" == Entry.type && b.addClass("entryVariablePanelPhone") : b.addClass("entryVariablePanelWorkspace"); + this.variableViewWrapper_ = b; + Entry.variableContainer.createDom(b); + return b; +}; +Entry.Playground.prototype.toggleOnVariableView = function() { + Entry.playground.changeViewMode("code"); + this.hideBlockMenu(); + Entry.variableContainer.updateList(); + this.variableView_.removeClass("entryRemove"); + this.resizeHandle_.removeClass("entryRemove"); +}; +Entry.Playground.prototype.toggleOffVariableView = function() { + this.showBlockMenu(); + this.variableView_.addClass("entryRemove"); +}; +Entry.Playground.prototype.editBlock = function() { + var b = Entry.playground; + Entry.stateManager && Entry.stateManager.addCommand("edit block", b, b.restoreBlock, b.object, b.object.getScriptText()); +}; +Entry.Playground.prototype.mouseupBlock = function() { + if (Entry.reporter) { + var b = Entry.playground, a = b.object; + Entry.reporter.report(new Entry.State("edit block mouseup", b, b.restoreBlock, a, a.getScriptText())); + } }; -(function(a) { - a.schema = {height:0, zIndex:0}; - a.destroy = function() { - this.svgGroup.remove(); - }; - a.setParent = function(a) { - this.parent = a; - }; - a.getParent = function() { - return this.parent; - }; - a.renderText = function() { - for (var a = this.thread.getBlocks(), c = 0;c < a.length;c++) { - a[c].view.renderText(); - } - }; - a.renderBlock = function() { - for (var a = this.thread.getBlocks(), c = 0;c < a.length;c++) { - a[c].view.renderBlock(); - } +Entry.Playground.prototype.restoreBlock = function(b, a) { + Entry.container.selectObject(b.id); + Entry.stateManager && Entry.stateManager.addCommand("restore block", this, this.restoreBlock, this.object, this.object.getScriptText()); + Blockly.Xml.textToDom(a); +}; +Entry.Playground.prototype.setMenu = function(b) { + if (this.currentObjectType != b) { + var a = this.blockMenu; + a.unbanClass(this.currentObjectType); + a.banClass(b); + a.setMenu(); + a.selectMenu(0, !0); + this.currentObjectType = b; + } +}; +Entry.Playground.prototype.hideTabs = function() { + var b = ["picture", "text", "sound", "variable"], a; + for (a in b) { + this.hideTab([b[a]]); + } +}; +Entry.Playground.prototype.hideTab = function(b) { + this.tabViewElements[b] && (this.tabViewElements[b].addClass("hideTab"), this.tabViewElements[b].removeClass("showTab")); +}; +Entry.Playground.prototype.showTabs = function() { + var b = ["picture", "text", "sound", "variable"], a; + for (a in b) { + this.showTab(b[a]); + } +}; +Entry.Playground.prototype.showTab = function(b) { + this.tabViewElements[b] && (this.tabViewElements[b].addClass("showTab"), this.tabViewElements[b].removeClass("hideTab")); +}; +Entry.Playground.prototype.initializeResizeHandle = function(b) { + b.onmousedown = function(a) { + Entry.playground.resizing = !0; + Entry.documentMousemove && (Entry.playground.resizeEvent = Entry.documentMousemove.attach(this, function(a) { + Entry.playground.resizing && Entry.resizeElement({menuWidth:a.clientX - Entry.interfaceState.canvasWidth}); + })); }; - a.requestAbsoluteCoordinate = function(a) { - var c = this.thread.getBlocks(), d = c.shift(), e = {x:0, y:0}; - for (this.parent instanceof Entry.Board || this.parent instanceof Entry.BlockMenu || (e = this.parent.requestAbsoluteCoordinate());d && d.view !== a && d.view;) { - d = d.view, e.x += d.x + d.magnet.next.x, e.y += d.y + d.magnet.next.y, d = c.shift(); + document.addEventListener("mouseup", function(a) { + if (a = Entry.playground.resizeEvent) { + Entry.playground.resizing = !1, Entry.documentMousemove.detach(a), delete Entry.playground.resizeEvent; } - return e; - }; - a.requestPartHeight = function(a, c) { - c = this.thread.getBlocks(); - for (var d = c.pop(), e = a ? a.magnet.next ? a.magnet.next.y : a.height : 0;d && d.view !== a && d.view;) { - d = d.view, e = d.magnet.next ? e + d.magnet.next.y : e + d.height, d.dragMode === Entry.DRAG_MODE_DRAG && (e = 0), d = c.pop(); + }); +}; +Entry.Playground.prototype.reloadPlayground = function() { + var b = this.mainWorkspace; + b && (b.getBlockMenu().reDraw(), this.object && this.object.script.view.reDraw()); +}; +Entry.Playground.prototype.flushPlayground = function() { + this.object = null; + if (Entry.playground && Entry.playground.view_) { + this.injectPicture(); + this.injectSound(); + var b = Entry.playground.mainWorkspace.getBoard(); + b.clear(); + b.changeCode(null); + } +}; +Entry.Playground.prototype.refreshPlayground = function() { + Entry.playground && Entry.playground.view_ && ("picture" === this.getViewMode() && this.injectPicture(), "sound" === this.getViewMode() && this.injectSound()); +}; +Entry.Playground.prototype.updateListViewOrder = function(b) { + b = "picture" == b ? this.pictureListView_.childNodes : this.soundListView_.childNodes; + for (var a = 0, c = b.length;a < c;a++) { + b[a].orderHolder.innerHTML = a + 1; + } +}; +Entry.Playground.prototype.generatePictureElement = function(b) { + function a() { + if ("" === this.value.trim()) { + Entry.deAttachEventListener(this, "blur", a), alert("\uc774\ub984\uc744 \uc785\ub825\ud558\uc5ec \uc8fc\uc138\uc694."), this.focus(), Entry.attachEventListener(this, "blur", a); + } else { + for (var b = $(".entryPlaygroundPictureName"), c = 0;c < b.length;c++) { + if (b.eq(c).val() == f.value && b[c] != this) { + Entry.deAttachEventListener(this, "blur", a); + alert("\uc774\ub984\uc774 \uc911\ubcf5 \ub418\uc5c8\uc2b5\ub2c8\ub2e4."); + this.focus(); + Entry.attachEventListener(this, "blur", a); + return; + } + } + this.picture.name = this.value; + Entry.playground.reloadPlayground(); + Entry.dispatchEvent("pictureNameChanged", this.picture); } - return e; - }; - a.dominate = function() { - this.parent.dominate(this.thread); - }; - a.isGlobal = function() { - return this.parent instanceof Entry.Board; + } + var c = Entry.createElement("li", b.id); + b.view = c; + c.addClass("entryPlaygroundPictureElement"); + c.picture = b; + c.bindOnClick(function(a) { + Entry.playground.selectPicture(this.picture); + }); + Entry.Utils.disableContextmenu(b.view); + $(b.view).on("contextmenu", function() { + Entry.ContextMenu.show([{text:Lang.Workspace.context_rename, callback:function() { + f.focus(); + }}, {text:Lang.Workspace.context_duplicate, callback:function() { + Entry.playground.clonePicture(b.id); + }}, {text:Lang.Workspace.context_remove, callback:function() { + Entry.playground.object.removePicture(b.id) ? (Entry.removeElement(c), Entry.toast.success(Lang.Workspace.shape_remove_ok, b.name + " " + Lang.Workspace.shape_remove_ok_msg)) : Entry.toast.alert(Lang.Workspace.shape_remove_fail, Lang.Workspace.shape_remove_fail_msg); + }}, {divider:!0}, {text:Lang.Workspace.context_download, callback:function() { + b.fileurl ? window.open(b.fileurl) : window.open("/api/sprite/download/image/" + encodeURIComponent(b.filename) + "/" + encodeURIComponent(b.name) + ".png"); + }}], "workspace-contextmenu"); + }); + var d = Entry.createElement("div"); + d.addClass("entryPlaygroundPictureOrder"); + c.orderHolder = d; + c.appendChild(d); + d = Entry.createElement("div", "t_" + b.id); + d.addClass("entryPlaygroundPictureThumbnail"); + if (b.fileurl) { + d.style.backgroundImage = 'url("' + b.fileurl + '")'; + } else { + var e = b.filename; + d.style.backgroundImage = 'url("' + Entry.defaultPath + "/uploads/" + e.substring(0, 2) + "/" + e.substring(2, 4) + "/thumb/" + e + '.png")'; + } + c.appendChild(d); + var f = Entry.createElement("input"); + f.addClass("entryPlaygroundPictureName"); + f.addClass("entryEllipsis"); + f.picture = b; + f.value = b.name; + Entry.attachEventListener(f, "blur", a); + f.onkeypress = function(a) { + 13 == a.keyCode && this.blur(); }; - a.reDraw = function() { - for (var a = this.thread._data, c = a.length - 1;0 <= c;c--) { - a[c].view.reDraw(); + c.appendChild(f); + d = Entry.createElement("div", "s_" + b.id); + d.addClass("entryPlaygroundPictureSize"); + d.innerHTML = b.dimension.width + " X " + b.dimension.height; + c.appendChild(d); +}; +Entry.Playground.prototype.generateSoundElement = function(b) { + var a = Entry.createElement("sound", b.id); + b.view = a; + a.addClass("entryPlaygroundSoundElement"); + a.sound = b; + Entry.Utils.disableContextmenu(b.view); + $(b.view).on("contextmenu", function() { + Entry.ContextMenu.show([{text:Lang.Workspace.context_rename, callback:function() { + g.focus(); + }}, {text:Lang.Workspace.context_duplicate, callback:function() { + Entry.playground.addSound(b, !0); + }}, {text:Lang.Workspace.context_remove, callback:function() { + Entry.playground.object.removeSound(b.id) ? (Entry.removeElement(a), Entry.toast.success(Lang.Workspace.sound_remove_ok, b.name + " " + Lang.Workspace.sound_remove_ok_msg)) : Entry.toast.alert(Lang.Workspace.sound_remove_fail, ""); + Entry.removeElement(a); + }}], "workspace-contextmenu"); + }); + var c = Entry.createElement("div"); + c.addClass("entryPlaygroundSoundOrder"); + a.orderHolder = c; + a.appendChild(c); + var d = Entry.createElement("div"); + d.addClass("entryPlaygroundSoundThumbnail"); + d.addClass("entryPlaygroundSoundPlay"); + var e = !1, f; + d.addEventListener("click", function() { + e ? (e = !1, d.removeClass("entryPlaygroundSoundStop"), d.addClass("entryPlaygroundSoundPlay"), f.stop()) : (e = !0, d.removeClass("entryPlaygroundSoundPlay"), d.addClass("entryPlaygroundSoundStop"), f = createjs.Sound.play(b.id), f.addEventListener("complete", function(a) { + d.removeClass("entryPlaygroundSoundStop"); + d.addClass("entryPlaygroundSoundPlay"); + e = !1; + }), f.addEventListener("loop", function(a) { + }), f.addEventListener("failed", function(a) { + })); + }); + a.appendChild(d); + var g = Entry.createElement("input"); + g.addClass("entryPlaygroundSoundName"); + g.sound = b; + g.value = b.name; + var h = document.getElementsByClassName("entryPlaygroundSoundName"); + g.onblur = function() { + if ("" === this.value) { + alert("\uc774\ub984\uc744 \uc785\ub825\ud558\uc5ec \uc8fc\uc138\uc694."), this.focus(); + } else { + for (var a = 0, b = 0;b < h.length;b++) { + if (h[b].value == g.value && (a += 1, 1 < a)) { + alert("\uc774\ub984\uc774 \uc911\ubcf5 \ub418\uc5c8\uc2b5\ub2c8\ub2e4."); + this.focus(); + return; + } + } + this.sound.name = this.value; + Entry.playground.reloadPlayground(); } }; - a.setZIndex = function(a) { - this.set({zIndex:a}); + g.onkeypress = function(a) { + 13 == a.keyCode && this.blur(); }; -})(Entry.ThreadView.prototype); -Entry.Vim = function(a) { - a = "string" === typeof a ? $("#" + a) : $(a); - if ("DIV" !== a.prop("tagName")) { - return console.error("Dom is not div element"); + a.appendChild(g); + c = Entry.createElement("div"); + c.addClass("entryPlaygroundSoundLength"); + c.innerHTML = b.duration + " \ucd08"; + a.appendChild(c); +}; +Entry.Playground.prototype.toggleColourChooser = function(b) { + "foreground" === b ? "none" === this.coloursWrapper.style.display ? (this.coloursWrapper.style.display = "block", this.backgroundsWrapper.style.display = "none") : this.coloursWrapper.style.display = "none" : "background" === b && ("none" === this.backgroundsWrapper.style.display ? (this.backgroundsWrapper.style.display = "block", this.coloursWrapper.style.display = "none") : this.backgroundsWrapper.style.display = "none"); +}; +Entry.Playground.prototype.setTextColour = function(b) { + Entry.playground.object.entity.setColour(b); + Entry.playground.toggleColourChooser("foreground"); + $(".entryPlayground_fgColorDiv").css("backgroundColor", b); +}; +Entry.Playground.prototype.setBackgroundColour = function(b) { + Entry.playground.object.entity.setBGColour(b); + Entry.playground.toggleColourChooser("background"); + $(".entryPlayground_bgColorDiv").css("backgroundColor", b); +}; +Entry.Playground.prototype.isTextBGMode = function() { + return this.isTextBGMode_; +}; +Entry.Playground.prototype.checkVariables = function() { + Entry.forEBS || (Entry.variableContainer.lists_.length ? this.blockMenu.unbanClass("listNotExist") : this.blockMenu.banClass("listNotExist"), Entry.variableContainer.variables_.length ? this.blockMenu.unbanClass("variableNotExist") : this.blockMenu.banClass("variableNotExist")); +}; +Entry.Playground.prototype.getViewMode = function() { + return this.viewMode_; +}; +Entry.Playground.prototype.updateHW = function() { + var b = Entry.playground.mainWorkspace.blockMenu; + if (b) { + var a = Entry.hw; + a && a.connected ? (b.unbanClass("arduinoConnected", !0), b.banClass("arduinoDisconnected", !0), a.banHW(), a.hwModule && b.unbanClass(a.hwModule.name)) : (b.banClass("arduinoConnected", !0), b.unbanClass("arduinoDisconnected", !0), Entry.hw.banHW()); + b.reDraw(); } - this.createDom(a); - this._parser = new Entry.Parser("maze", "js", this.codeMirror); - this._blockParser = new Entry.Parser("maze", "block"); - Entry.Model(this, !1); - window.eventset = []; }; -(function(a) { - a.createDom = function(a) { - function c(a) { - var b = e.getCodeToText(a.block); - e.codeMirror.display.dragFunctions.leave(a); - var c = Entry.Utils.createMouseEvent("mousedown", a); - e.codeMirror.display.scroller.dispatchEvent(c); - var b = b.split("\n"), d = b.length - 1, l = 0; - b.forEach(function(a, b) { - e.codeMirror.replaceSelection(a); - l = e.doc.getCursor().line; - e.codeMirror.indentLine(l); - 0 !== b && d === b || e.codeMirror.replaceSelection("\n"); - }); - a = Entry.Utils.createMouseEvent("mouseup", a); - e.codeMirror.display.scroller.dispatchEvent(a); - } - function d(a) { - e.codeMirror.display.dragFunctions.over(a); - } - var e; - this.view = Entry.Dom("div", {parent:a, class:"entryVimBoard"}); - this.codeMirror = CodeMirror(this.view[0], {lineNumbers:!0, value:"", mode:{name:"javascript", globalVars:!0}, theme:"default", indentUnit:4, styleActiveLine:!0, extraKeys:{"Ctrl-Space":"javascriptComplete", Tab:function(a) { - var b = Array(a.getOption("indentUnit") + 1).join(" "); - a.replaceSelection(b); - }}, lint:!0, viewportMargin:10}); - this.doc = this.codeMirror.getDoc(); - e = this; - a = this.view[0]; - a.removeEventListener("dragEnd", c); - a.removeEventListener("dragOver", d); - a.addEventListener("dragEnd", c); - a.addEventListener("dragOver", d); - }; - a.hide = function() { - this.view.addClass("entryRemove"); - }; - a.show = function() { - this.view.removeClass("entryRemove"); - }; - a.textToCode = function() { - var a = this.codeMirror.getValue(), a = this._parser.parse(a); - if (0 === a.length) { - throw "\ube14\ub85d \ud30c\uc2f1 \uc624\ub958"; +Entry.Playground.prototype.toggleLineBreak = function(b) { + this.object && "textBox" == this.object.objectType && (b ? (Entry.playground.object.entity.setLineBreak(!0), $(".entryPlayground_textArea").css("display", "block"), $(".entryPlayground_textBox").css("display", "none"), this.linebreakOffImage.src = Entry.mediaFilePath + "text-linebreak-off-false.png", this.linebreakOnImage.src = Entry.mediaFilePath + "text-linebreak-on-true.png", this.fontSizeWrapper.removeClass("entryHide")) : (Entry.playground.object.entity.setLineBreak(!1), $(".entryPlayground_textArea").css("display", + "none"), $(".entryPlayground_textBox").css("display", "block"), this.linebreakOffImage.src = Entry.mediaFilePath + "text-linebreak-off-true.png", this.linebreakOnImage.src = Entry.mediaFilePath + "text-linebreak-on-false.png", this.fontSizeWrapper.addClass("entryHide"))); +}; +Entry.Playground.prototype.setFontAlign = function(b) { + if ("textBox" == this.object.objectType) { + this.alignLeftBtn.removeClass("toggle"); + this.alignCenterBtn.removeClass("toggle"); + this.alignRightBtn.removeClass("toggle"); + switch(b) { + case Entry.TEXT_ALIGN_LEFT: + this.alignLeftBtn.addClass("toggle"); + break; + case Entry.TEXT_ALIGN_CENTER: + this.alignCenterBtn.addClass("toggle"); + break; + case Entry.TEXT_ALIGN_RIGHT: + this.alignRightBtn.addClass("toggle"); } - return a; - }; - a.codeToText = function(a) { - a = this._blockParser.parse(a); - this.codeMirror.setValue(a); - }; - a.getCodeToText = function(a) { - return this._blockParser.parse(a); - }; -})(Entry.Vim.prototype); + this.object.entity.setTextAlign(b); + } +}; +Entry.Playground.prototype.hideBlockMenu = function() { + this.mainWorkspace.getBlockMenu().hide(); +}; +Entry.Playground.prototype.showBlockMenu = function() { + this.mainWorkspace.getBlockMenu().show(); +}; Entry.Xml = {}; -Entry.Xml.isTypeOf = function(a, b) { - return b.getAttribute("type") == a; +Entry.Xml.isTypeOf = function(b, a) { + return a.getAttribute("type") == b; }; -Entry.Xml.getNextBlock = function(a) { - a = a.childNodes; - for (var b = 0;b < a.length;b++) { - if ("NEXT" == a[b].tagName.toUpperCase()) { - return a[b].children[0]; +Entry.Xml.getNextBlock = function(b) { + b = b.childNodes; + for (var a = 0;a < b.length;a++) { + if ("NEXT" == b[a].tagName.toUpperCase()) { + return b[a].children[0]; } } return null; }; -Entry.Xml.getStatementBlock = function(a, b) { - var c = b.getElementsByTagName("statement"); +Entry.Xml.getStatementBlock = function(b, a) { + var c = a.getElementsByTagName("statement"); if (!c.length) { - return b; + return a; } for (var d in c) { - if (c[d].getAttribute("name") == a) { + if (c[d].getAttribute("name") == b) { return c[d].children[0]; } } return null; }; -Entry.Xml.getParentLoop = function(a) { +Entry.Xml.getParentLoop = function(b) { for (;;) { - if (!a) { + if (!b) { return null; } - if ((a = a.parentNode) && "STATEMENT" == a.tagName.toUpperCase()) { - return a.parentNode; + if ((b = b.parentNode) && "STATEMENT" == b.tagName.toUpperCase()) { + return b.parentNode; } - if (a) { - a = a.parentNode; + if (b) { + b = b.parentNode; } else { return null; } } }; -Entry.Xml.getParentIterateLoop = function(a) { +Entry.Xml.getParentIterateLoop = function(b) { for (;;) { - if (!a) { + if (!b) { return null; } - if ((a = a.parentNode) && a.getAttribute("type") && "REPEAT" == a.getAttribute("type").toUpperCase().substr(0, 6)) { - return a; + if ((b = b.parentNode) && b.getAttribute("type") && "REPEAT" == b.getAttribute("type").toUpperCase().substr(0, 6)) { + return b; } - if (!a) { + if (!b) { return null; } } }; -Entry.Xml.getParentBlock = function(a) { - return (a = a.parentNode) ? a.parentNode : null; +Entry.Xml.getParentBlock = function(b) { + return (b = b.parentNode) ? b.parentNode : null; }; -Entry.Xml.callReturn = function(a) { - var b = Entry.Xml.getNextBlock(a); - return b ? b : Entry.Xml.getParentLoop(a); +Entry.Xml.callReturn = function(b) { + var a = Entry.Xml.getNextBlock(b); + return a ? a : Entry.Xml.getParentLoop(b); }; -Entry.Xml.isRootBlock = function(a) { +Entry.Xml.isRootBlock = function(b) { }; -Entry.Xml.getValue = function(a, b) { - b = b.childNodes; - if (!b.length) { +Entry.Xml.getValue = function(b, a) { + var c = a.childNodes; + if (!c.length) { return null; } - for (var c in b) { - if ("VALUE" == b[c].tagName.toUpperCase() && b[c].getAttribute("name") == a) { - return b[c].children[0]; + for (var d in c) { + if ("VALUE" == c[d].tagName.toUpperCase() && c[d].getAttribute("name") == b) { + return c[d].children[0]; } } return null; }; -Entry.Xml.getNumberValue = function(a, b, c) { +Entry.Xml.getNumberValue = function(b, a, c) { c = c.childNodes; if (!c.length) { return null; } for (var d in c) { - if (c[d].tagName && "VALUE" == c[d].tagName.toUpperCase() && c[d].getAttribute("name") == b) { - return Number(Entry.Xml.operate(a, c[d].children[0])); + if (c[d].tagName && "VALUE" == c[d].tagName.toUpperCase() && c[d].getAttribute("name") == a) { + return +Entry.Xml.operate(b, c[d].children[0]); } } return null; }; -Entry.Xml.getField = function(a, b) { - b = b.childNodes; - if (!b.length) { +Entry.Xml.getField = function(b, a) { + var c = a.childNodes; + if (!c.length) { return null; } - for (var c in b) { - if (b[c].tagName && "FIELD" == b[c].tagName.toUpperCase() && b[c].getAttribute("name") == a) { - return b[c].textContent; + for (var d in c) { + if (c[d].tagName && "FIELD" == c[d].tagName.toUpperCase() && c[d].getAttribute("name") == b) { + return c[d].textContent; } } }; -Entry.Xml.getNumberField = function(a, b) { - b = b.childNodes; - if (!b.length) { +Entry.Xml.getNumberField = function(b, a) { + var c = a.childNodes; + if (!c.length) { return null; } - for (var c in b) { - if ("FIELD" == b[c].tagName.toUpperCase() && b[c].getAttribute("name") == a) { - return Number(b[c].textContent); + for (var d in c) { + if ("FIELD" == c[d].tagName.toUpperCase() && c[d].getAttribute("name") == b) { + return +c[d].textContent; } } }; -Entry.Xml.getBooleanValue = function(a, b, c) { +Entry.Xml.getBooleanValue = function(b, a, c) { c = c.getElementsByTagName("value"); if (!c.length) { return null; } for (var d in c) { - if (c[d].getAttribute("name") == b) { - return Entry.Xml.operate(a, c[d].children[0]); + if (c[d].getAttribute("name") == a) { + return Entry.Xml.operate(b, c[d].children[0]); } } return null; }; -Entry.Xml.operate = function(a, b) { - return Entry.block[b.getAttribute("type")](a, b); +Entry.Xml.operate = function(b, a) { + return Entry.block[a.getAttribute("type")](b, a); }; -Entry.Xml.cloneBlock = function(a, b, c) { - var d = a.cloneNode(); - a.parentNode && "xml" != a.parentNode.tagName && Entry.Xml.cloneBlock(a.parentNode, d, "parent"); - for (var e = 0;e < a.childNodes.length;e++) { - var f = a.childNodes[e]; - f instanceof Text ? d.textContent = f.textContent : "parent" == c ? d.appendChild(b) : d.appendChild(Entry.Xml.cloneBlock(f, d, "child")); +Entry.Xml.cloneBlock = function(b, a, c) { + var d = b.cloneNode(); + b.parentNode && "xml" != b.parentNode.tagName && Entry.Xml.cloneBlock(b.parentNode, d, "parent"); + for (var e = 0;e < b.childNodes.length;e++) { + var f = b.childNodes[e]; + f instanceof Text ? d.textContent = f.textContent : "parent" == c ? d.appendChild(a) : d.appendChild(Entry.Xml.cloneBlock(f, d, "child")); } return d; }; -Entry.Youtube = function(a) { - this.generateView(a); +Entry.Youtube = function(b) { + this.generateView(b); }; p = Entry.Youtube.prototype; -p.init = function(a) { - this.youtubeHash = a; +p.init = function(b) { + this.youtubeHash = b; this.generateView(); }; -p.generateView = function(a) { - var b = Entry.createElement("div"); - b.addClass("entryContainerMovieWorkspace"); - b.addClass("entryRemove"); - this.movieContainer = b; - b = Entry.createElement("iframe"); - b.setAttribute("id", "youtubeIframe"); - b.setAttribute("allowfullscreen", ""); - b.setAttribute("frameborder", 0); - b.setAttribute("src", "https://www.youtube.com/embed/" + a); - this.movieFrame = b; - this.movieContainer.appendChild(b); +p.generateView = function(b) { + var a = Entry.createElement("div"); + a.addClass("entryContainerMovieWorkspace"); + a.addClass("entryRemove"); + this.movieContainer = a; + a = Entry.createElement("iframe"); + a.setAttribute("id", "youtubeIframe"); + a.setAttribute("allowfullscreen", ""); + a.setAttribute("frameborder", 0); + a.setAttribute("src", "https://www.youtube.com/embed/" + b); + this.movieFrame = a; + this.movieContainer.appendChild(a); }; p.getView = function() { return this.movieContainer; }; p.resize = function() { - var a = document.getElementsByClassName("propertyContent")[0], b = document.getElementById("youtubeIframe"); - w = a.offsetWidth; - b.width = w + "px"; - b.height = 9 * w / 16 + "px"; + var b = document.getElementsByClassName("propertyContent")[0], a = document.getElementById("youtubeIframe"); + w = b.offsetWidth; + a.width = w + "px"; + a.height = 9 * w / 16 + "px"; }; diff --git a/dist/entry.min.js b/dist/entry.min.js index 591d2a08dc..28e0f584e0 100644 --- a/dist/entry.min.js +++ b/dist/entry.min.js @@ -1,2201 +1,2203 @@ -Entry={block:{},TEXT_ALIGN_CENTER:0,TEXT_ALIGN_LEFT:1,TEXT_ALIGN_RIGHT:2,TEXT_ALIGNS:["center","left","right"],clipboard:null,loadProject:function(a){a||(a=Entry.getStartProject(Entry.mediaFilePath));"workspace"==this.type&&Entry.stateManager.startIgnore();Entry.projectId=a._id;Entry.variableContainer.setVariables(a.variables);Entry.variableContainer.setMessages(a.messages);Entry.scene.addScenes(a.scenes);Entry.stage.initObjectContainers();Entry.variableContainer.setFunctions(a.functions);Entry.container.setObjects(a.objects); -Entry.FPS=a.speed?a.speed:60;createjs.Ticker.setFPS(Entry.FPS);"workspace"==this.type&&setTimeout(function(){Entry.stateManager.endIgnore()},300);Entry.engine.projectTimer||Entry.variableContainer.generateTimer();0===Object.keys(Entry.container.inputValue).length&&Entry.variableContainer.generateAnswer();Entry.start();return a},exportProject:function(a){a||(a={});Entry.engine.isState("stop")||Entry.engine.toggleStop();Entry.Func&&Entry.Func.workspace&&Entry.Func.workspace.visible&&Entry.Func.cancelEdit(); -a.objects=Entry.container.toJSON();a.scenes=Entry.scene.toJSON();a.variables=Entry.variableContainer.getVariableJSON();a.messages=Entry.variableContainer.getMessageJSON();a.functions=Entry.variableContainer.getFunctionJSON();a.scenes=Entry.scene.toJSON();a.speed=Entry.FPS;return a},setBlockByText:function(a,b){a=[];b=jQuery.parseXML(b).getElementsByTagName("category");for(var c=0;cb?b=325:720b?b=244:400svg").css({width:b- -64+"px"});Entry.playground.mainWorkspace.blockMenu.setWidth();$(".entryWorkspaceBoard").css({left:b+"px"});Entry.playground.resizeHandle_.style.left=b+"px";Entry.playground.variableViewWrapper_.style.width=b+"px";this.interfaceState=a}Entry.windowResized.notify()},getUpTime:function(){return(new Date).getTime()-this.startTime},addActivity:function(a){Entry.stateManager&&Entry.stateManager.addActivity(a)},startActivityLogging:function(){Entry.reporter&&Entry.reporter.start(Entry.projectId,window.user? -window.user._id:null,Entry.startTime)},getActivityLog:function(){var a={};Entry.stateManager&&(a.activityLog=Entry.stateManager.activityLog_);return a},DRAG_MODE_NONE:0,DRAG_MODE_MOUSEDOWN:1,DRAG_MODE_DRAG:2,cancelObjectEdit:function(a){var b=Entry.playground.object;if(b){var c=a.target;a=0!==$(b.view_).find(c).length;c=c.tagName.toUpperCase();!b.isEditing||"INPUT"===c&&a||b.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 a=Entry.Albert.PORT_MAP,b=Entry.hw.sendQueue,c;for(c in a)b[c]=a[c];Entry.hw.update();a=Entry.Albert;a.tempo=60;a.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={block:{},TEXT_ALIGN_CENTER:0,TEXT_ALIGN_LEFT:1,TEXT_ALIGN_RIGHT:2,TEXT_ALIGNS:["center","left","right"],clipboard:null,loadProject:function(b){b||(b=Entry.getStartProject(Entry.mediaFilePath));"workspace"==this.type&&Entry.stateManager.startIgnore();Entry.projectId=b._id;Entry.variableContainer.setVariables(b.variables);Entry.variableContainer.setMessages(b.messages);Entry.scene.addScenes(b.scenes);Entry.stage.initObjectContainers();Entry.variableContainer.setFunctions(b.functions);Entry.container.setObjects(b.objects); +Entry.FPS=b.speed?b.speed:60;createjs.Ticker.setFPS(Entry.FPS);"workspace"==this.type&&setTimeout(function(){Entry.stateManager.endIgnore()},300);Entry.engine.projectTimer||Entry.variableContainer.generateTimer();0===Object.keys(Entry.container.inputValue).length&&Entry.variableContainer.generateAnswer();Entry.start();return b},exportProject:function(b){b||(b={});Entry.engine.isState("stop")||Entry.engine.toggleStop();Entry.Func&&Entry.Func.workspace&&Entry.Func.workspace.visible&&Entry.Func.cancelEdit(); +b.objects=Entry.container.toJSON();b.scenes=Entry.scene.toJSON();b.variables=Entry.variableContainer.getVariableJSON();b.messages=Entry.variableContainer.getMessageJSON();b.functions=Entry.variableContainer.getFunctionJSON();b.scenes=Entry.scene.toJSON();b.speed=Entry.FPS;return b},setBlockByText:function(b,a){for(var c=[],d=jQuery.parseXML(a).getElementsByTagName("category"),e=0;ea?a=325:720a?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", 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(a){clearTimeout(a);var b=this.timeouts;a=b.indexOf(a);0<=a&&b.splice(a,1)},removeAllTimeouts:function(){var a=this.timeouts,b;for(b in a)clearTimeout(a[b]);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(a,b){a=Entry.hw.portData;return 40Entry.Albert.tempo&&(Entry.Albert.tempo=1);return b.callReturn()}; +Entry.block.albert_change_tempo_by=function(b,a){Entry.Albert.tempo+=a.getNumberValue("VALUE");1>Entry.Albert.tempo&&(Entry.Albert.tempo=1);return a.callReturn()}; Blockly.Blocks.albert_set_tempo_to={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.ALBERT_set_tempo_to_1);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.ALBERT_set_tempo_to_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.albert_set_tempo_to=function(a,b){Entry.Albert.tempo=b.getNumberValue("VALUE");1>Entry.Albert.tempo&&(Entry.Albert.tempo=1);return b.callReturn()};Blockly.Blocks.albert_move_forward={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.HAMSTER_move_forward).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.albert_move_forward=function(a,b){a=Entry.hw.sendQueue;if(b.isStart){if(1==b.timeFlag)return b;delete b.timeFlag;delete b.isStart;Entry.engine.isContinue=!1;a.leftWheel=0;a.rightWheel=0;return b.callReturn()}b.isStart=!0;b.timeFlag=1;a.leftWheel=30;a.rightWheel=30;setTimeout(function(){b.timeFlag=0},1E3);return b}; +Entry.block.albert_set_tempo_to=function(b,a){Entry.Albert.tempo=a.getNumberValue("VALUE");1>Entry.Albert.tempo&&(Entry.Albert.tempo=1);return a.callReturn()};Blockly.Blocks.albert_move_forward={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.HAMSTER_move_forward).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; +Entry.block.albert_move_forward=function(b,a){var c=Entry.hw.sendQueue;if(a.isStart){if(1==a.timeFlag)return a;delete a.timeFlag;delete a.isStart;Entry.engine.isContinue=!1;c.leftWheel=0;c.rightWheel=0;return a.callReturn()}a.isStart=!0;a.timeFlag=1;c.leftWheel=30;c.rightWheel=30;setTimeout(function(){a.timeFlag=0},1E3);return a}; Blockly.Blocks.albert_move_backward={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.HAMSTER_move_backward).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.albert_move_backward=function(a,b){a=Entry.hw.sendQueue;if(b.isStart){if(1==b.timeFlag)return a.leftWheel=-30,a.rightWheel=-30,b;delete b.timeFlag;delete b.isStart;Entry.engine.isContinue=!1;a.leftWheel=0;a.rightWheel=0;return b.callReturn()}b.isStart=!0;b.timeFlag=1;setTimeout(function(){b.timeFlag=0},1E3);return b}; +Entry.block.albert_move_backward=function(b,a){var c=Entry.hw.sendQueue;if(a.isStart){if(1==a.timeFlag)return c.leftWheel=-30,c.rightWheel=-30,a;delete a.timeFlag;delete a.isStart;Entry.engine.isContinue=!1;c.leftWheel=0;c.rightWheel=0;return a.callReturn()}a.isStart=!0;a.timeFlag=1;setTimeout(function(){a.timeFlag=0},1E3);return a}; Blockly.Blocks.albert_turn_around={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.HAMSTER_turn_around_1).appendField(new Blockly.FieldDropdown([[Lang.General.left,"LEFT"],[Lang.General.right,"RIGHT"]]),"DIRECTION").appendField(Lang.Blocks.HAMSTER_turn_around_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.albert_turn_around=function(a,b){a=Entry.hw.sendQueue;if(b.isStart){if(1==b.timeFlag)return a.leftWheel=b.leftValue,a.rightWheel=b.rightValue,b;delete b.timeFlag;delete b.isStart;delete b.leftValue;delete b.rightValue;Entry.engine.isContinue=!1;a.leftWheel=0;a.rightWheel=0;return b.callReturn()}a="LEFT"==b.getField("DIRECTION",b);b.leftValue=a?-30:30;b.rightValue=a?30:-30;b.isStart=!0;b.timeFlag=1;setTimeout(function(){b.timeFlag=0},1E3);return b}; +Entry.block.albert_turn_around=function(b,a){var c=Entry.hw.sendQueue;if(a.isStart){if(1==a.timeFlag)return c.leftWheel=a.leftValue,c.rightWheel=a.rightValue,a;delete a.timeFlag;delete a.isStart;delete a.leftValue;delete a.rightValue;Entry.engine.isContinue=!1;c.leftWheel=0;c.rightWheel=0;return a.callReturn()}c="LEFT"==a.getField("DIRECTION",a);a.leftValue=c?-30:30;a.rightValue=c?30:-30;a.isStart=!0;a.timeFlag=1;setTimeout(function(){a.timeFlag=0},1E3);return a}; Blockly.Blocks.albert_set_led_to={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.HAMSTER_set_led_to_1).appendField(new Blockly.FieldDropdown([[Lang.General.left,"LEFT"],[Lang.General.right,"RIGHT"],[Lang.General.both,"FRONT"]]),"DIRECTION").appendField(Lang.Blocks.ALBERT_set_led_to_2).appendField(new Blockly.FieldDropdown([[Lang.General.red,"4"],[Lang.General.yellow,"6"],[Lang.General.green,"2"],[Lang.General.skyblue,"3"],[Lang.General.blue,"1"],[Lang.General.purple, -"5"],[Lang.General.white,"7"]]),"COLOR").appendField(Lang.Blocks.HAMSTER_set_led_to_3).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.albert_set_led_to=function(a,b){a=Entry.hw.sendQueue;var c=b.getField("DIRECTION",b),d=Number(b.getField("COLOR",b));"FRONT"==c?(a.leftEye=d,a.rightEye=d):"LEFT"==c?a.leftEye=d:a.rightEye=d;return b.callReturn()}; +"5"],[Lang.General.white,"7"]]),"COLOR").appendField(Lang.Blocks.HAMSTER_set_led_to_3).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.albert_set_led_to=function(b,a){var c=Entry.hw.sendQueue,d=a.getField("DIRECTION",a),e=+a.getField("COLOR",a);"FRONT"==d?(c.leftEye=e,c.rightEye=e):"LEFT"==d?c.leftEye=e:c.rightEye=e;return a.callReturn()}; Blockly.Blocks.albert_clear_led={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.HAMSTER_clear_led_1).appendField(new Blockly.FieldDropdown([[Lang.General.left,"LEFT"],[Lang.General.right,"RIGHT"],[Lang.General.both,"FRONT"]]),"DIRECTION").appendField(Lang.Blocks.ALBERT_clear_led_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.albert_clear_led=function(a,b){a=Entry.hw.sendQueue;var c=b.getField("DIRECTION",b);"FRONT"==c?(a.leftEye=0,a.rightEye=0):"LEFT"==c?a.leftEye=0:a.rightEye=0;return b.callReturn()}; +Entry.block.albert_clear_led=function(b,a){var c=Entry.hw.sendQueue,d=a.getField("DIRECTION",a);"FRONT"==d?(c.leftEye=0,c.rightEye=0):"LEFT"==d?c.leftEye=0:c.rightEye=0;return a.callReturn()}; Blockly.Blocks.albert_change_wheels_by={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.HAMSTER_change_wheels_by_1).appendField(new Blockly.FieldDropdown([[Lang.General.left,"LEFT"],[Lang.General.right,"RIGHT"],[Lang.General.both,"FRONT"]]),"DIRECTION").appendField(Lang.Blocks.HAMSTER_change_wheels_by_2);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.HAMSTER_change_wheels_by_3).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+ -"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.albert_change_wheels_by=function(a,b){a=Entry.hw.sendQueue;var c=Entry.hw.portData,d=b.getField("DIRECTION"),e=b.getNumberValue("VALUE");"LEFT"==d?a.leftWheel=void 0!=a.leftWheel?a.leftWheel+e:c.leftWheel+e:("RIGHT"!=d&&(a.leftWheel=void 0!=a.leftWheel?a.leftWheel+e:c.leftWheel+e),a.rightWheel=void 0!=a.rightWheel?a.rightWheel+e:c.rightWheel+e);return b.callReturn()}; +"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.albert_change_wheels_by=function(b,a){var c=Entry.hw.sendQueue,d=Entry.hw.portData,e=a.getField("DIRECTION"),f=a.getNumberValue("VALUE");"LEFT"==e?c.leftWheel=void 0!=c.leftWheel?c.leftWheel+f:d.leftWheel+f:("RIGHT"!=e&&(c.leftWheel=void 0!=c.leftWheel?c.leftWheel+f:d.leftWheel+f),c.rightWheel=void 0!=c.rightWheel?c.rightWheel+f:d.rightWheel+f);return a.callReturn()}; Blockly.Blocks.albert_set_wheels_to={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.HAMSTER_set_wheels_to_1).appendField(new Blockly.FieldDropdown([[Lang.General.left,"LEFT"],[Lang.General.right,"RIGHT"],[Lang.General.both,"FRONT"]]),"DIRECTION").appendField(Lang.Blocks.HAMSTER_set_wheels_to_2);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.HAMSTER_set_wheels_to_3).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+ -"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.albert_set_wheels_to=function(a,b){a=Entry.hw.sendQueue;var c=b.getField("DIRECTION"),d=b.getNumberValue("VALUE");"LEFT"==c?a.leftWheel=d:("RIGHT"!=c&&(a.leftWheel=d),a.rightWheel=d);return b.callReturn()};Entry.Arduino={name:"arduino",setZero:function(){Entry.hw.sendQueue.readablePorts=[];for(var a=0;20>a;a++)Entry.hw.sendQueue[a]=0,Entry.hw.sendQueue.readablePorts.push(a);Entry.hw.update()},monitorTemplate:{imgPath:"hw/arduino.png",width:605,height:434,listPorts:{2:{name:Lang.Hw.port_en+" 2 "+Lang.Hw.port_ko,type:"input",pos:{x:0,y:0}},3:{name:Lang.Hw.port_en+" 3 "+Lang.Hw.port_ko,type:"input",pos:{x:0,y:0}},4:{name:Lang.Hw.port_en+" 4 "+Lang.Hw.port_ko,type:"input",pos:{x:0,y:0}},5:{name:Lang.Hw.port_en+ +"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.albert_set_wheels_to=function(b,a){var c=Entry.hw.sendQueue,d=a.getField("DIRECTION"),e=a.getNumberValue("VALUE");"LEFT"==d?c.leftWheel=e:("RIGHT"!=d&&(c.leftWheel=e),c.rightWheel=e);return a.callReturn()};Entry.Arduino={name:"arduino",setZero:function(){Entry.hw.sendQueue.readablePorts=[];for(var b=0;20>b;b++)Entry.hw.sendQueue[b]=0,Entry.hw.sendQueue.readablePorts.push(b);Entry.hw.update()},monitorTemplate:{imgPath:"hw/arduino.png",width:605,height:434,listPorts:{2:{name:Lang.Hw.port_en+" 2 "+Lang.Hw.port_ko,type:"input",pos:{x:0,y:0}},3:{name:Lang.Hw.port_en+" 3 "+Lang.Hw.port_ko,type:"input",pos:{x:0,y:0}},4:{name:Lang.Hw.port_en+" 4 "+Lang.Hw.port_ko,type:"input",pos:{x:0,y:0}},5:{name:Lang.Hw.port_en+ " 5 "+Lang.Hw.port_ko,type:"input",pos:{x:0,y:0}},6:{name:Lang.Hw.port_en+" 6 "+Lang.Hw.port_ko,type:"input",pos:{x:0,y:0}},7:{name:Lang.Hw.port_en+" 7 "+Lang.Hw.port_ko,type:"input",pos:{x:0,y:0}},8:{name:Lang.Hw.port_en+" 8 "+Lang.Hw.port_ko,type:"input",pos:{x:0,y:0}},9:{name:Lang.Hw.port_en+" 9 "+Lang.Hw.port_ko,type:"input",pos:{x:0,y:0}},10:{name:Lang.Hw.port_en+" 10 "+Lang.Hw.port_ko,type:"input",pos:{x:0,y:0}},11:{name:Lang.Hw.port_en+" 11 "+Lang.Hw.port_ko,type:"input",pos:{x:0,y:0}},12:{name:Lang.Hw.port_en+ " 12 "+Lang.Hw.port_ko,type:"input",pos:{x:0,y:0}},13:{name:Lang.Hw.port_en+" 13 "+Lang.Hw.port_ko,type:"input",pos:{x:0,y:0}},a0:{name:Lang.Hw.port_en+" A0 "+Lang.Hw.port_ko,type:"input",pos:{x:0,y:0}},a1:{name:Lang.Hw.port_en+" A1 "+Lang.Hw.port_ko,type:"input",pos:{x:0,y:0}},a2:{name:Lang.Hw.port_en+" A2 "+Lang.Hw.port_ko,type:"input",pos:{x:0,y:0}},a3:{name:Lang.Hw.port_en+" A3 "+Lang.Hw.port_ko,type:"input",pos:{x:0,y:0}},a4:{name:Lang.Hw.port_en+" A4 "+Lang.Hw.port_ko,type:"input",pos:{x:0, y:0}},a5:{name:Lang.Hw.port_en+" A5 "+Lang.Hw.port_ko,type:"input",pos:{x:0,y:0}}},mode:"both"}};Entry.SensorBoard={name:"sensorBoard",setZero:Entry.Arduino.setZero};Entry.ardublock={name:"ardublock",setZero:Entry.Arduino.setZero}; -Entry.dplay={name:"dplay",vel_value:255,Left_value:255,Right_value:255,setZero:Entry.Arduino.setZero,timeouts:[],removeTimeout:function(a){clearTimeout(a);var b=this.timeouts;a=b.indexOf(a);0<=a&&b.splice(a,1)},removeAllTimeouts:function(){var a=this.timeouts,b;for(b in a)clearTimeout(a[b]);this.timeouts=[]}};Entry.nemoino={name:"nemoino",setZero:Entry.Arduino.setZero};Entry.joystick={name:"joystick",setZero:Entry.Arduino.setZero};Entry.CODEino={name:"CODEino",setZero:Entry.Arduino.setZero,monitorTemplate:Entry.Arduino.monitorTemplate}; -Blockly.Blocks.arduino_text={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(new Blockly.FieldTextInput("Arduino"),"NAME");this.setOutput(!0,"String");this.setInputsInline(!0)}};Entry.block.arduino_text=function(a,b){return b.getStringField("NAME")}; +Entry.dplay={name:"dplay",vel_value:255,Left_value:255,Right_value:255,setZero:Entry.Arduino.setZero,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=[]}};Entry.nemoino={name:"nemoino",setZero:Entry.Arduino.setZero};Entry.joystick={name:"joystick",setZero:Entry.Arduino.setZero};Entry.CODEino={name:"CODEino",setZero:Entry.Arduino.setZero,monitorTemplate:Entry.Arduino.monitorTemplate}; +Blockly.Blocks.arduino_text={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(new Blockly.FieldTextInput("Arduino"),"NAME");this.setOutput(!0,"String");this.setInputsInline(!0)}};Entry.block.arduino_text=function(b,a){return a.getStringField("NAME")}; Blockly.Blocks.arduino_send={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.ARDUINO_arduino_send_1);this.appendValueInput("VALUE").setCheck(["Number","String",null]);this.appendDummyInput().appendField(Lang.Blocks.ARDUINO_arduino_send_2);this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.arduino_send=function(a,b){a=b.getValue("VALUE",b);var c=new XMLHttpRequest;c.open("POST","http://localhost:23518/arduino/",!1);c.send(String(a));Entry.assert(200==c.status,"arduino is not connected");return b.callReturn()}; +Entry.block.arduino_send=function(b,a){var c=a.getValue("VALUE",a),d=new XMLHttpRequest;d.open("POST","http://localhost:23518/arduino/",!1);d.send(String(c));Entry.assert(200==d.status,"arduino is not connected");return a.callReturn()}; Blockly.Blocks.arduino_get_string={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.ARDUINO_arduino_get_string_1);this.appendValueInput("VALUE").setCheck(["Number","String",null]);this.appendDummyInput().appendField(Lang.Blocks.ARDUINO_arduino_get_string_2);this.setOutput(!0,"String");this.setInputsInline(!0)}}; -Entry.block.arduino_get_number=function(a,b){a=b.getValue("VALUE",b);b=new XMLHttpRequest;b.open("POST","http://localhost:23518/arduino/",!1);b.send(String(a));Entry.assert(200==b.status,"arduino is not connected");return Number(b.responseText)}; +Entry.block.arduino_get_number=function(b,a){var c=a.getValue("VALUE",a),d=new XMLHttpRequest;d.open("POST","http://localhost:23518/arduino/",!1);d.send(String(c));Entry.assert(200==d.status,"arduino is not connected");return+d.responseText}; Blockly.Blocks.arduino_get_number={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.ARDUINO_arduino_get_number_1);this.appendValueInput("VALUE").setCheck(["Number","String",null]);this.appendDummyInput().appendField(Lang.Blocks.ARDUINO_arduino_get_number_2);this.setOutput(!0,"Number");this.setInputsInline(!0)}}; -Entry.block.arduino_get_string=function(a,b){a=b.getValue("VALUE",b);b=new XMLHttpRequest;b.open("POST","http://localhost:23518/arduino/",!1);b.send(String(a));Entry.assert(200==b.status,"arduino is not connected");return b.responseText}; +Entry.block.arduino_get_string=function(b,a){var c=a.getValue("VALUE",a),d=new XMLHttpRequest;d.open("POST","http://localhost:23518/arduino/",!1);d.send(String(c));Entry.assert(200==d.status,"arduino is not connected");return d.responseText}; Blockly.Blocks.arduino_get_sensor_number={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(new Blockly.FieldDropdown([[Lang.Blocks.ARDUINO_arduino_get_sensor_number_0,"A0"],[Lang.Blocks.ARDUINO_arduino_get_sensor_number_1,"A1"],[Lang.Blocks.ARDUINO_arduino_get_sensor_number_2,"A2"],[Lang.Blocks.ARDUINO_arduino_get_sensor_number_3,"A3"],[Lang.Blocks.ARDUINO_arduino_get_sensor_number_4,"A4"],[Lang.Blocks.ARDUINO_arduino_get_sensor_number_5,"A5"]]),"PORT");this.appendDummyInput().appendField(" "); -this.setOutput(!0,"Number");this.setInputsInline(!0)}};Entry.block.arduino_get_sensor_number=function(a,b){return b.getStringField("PORT")}; -Blockly.Blocks.arduino_get_port_number={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(new Blockly.FieldDropdown([["0","0"],["1","1"],["2","2"],["3","3"],["4","4"],["5","5"],["6","6"],["7","7"],["8","8"],["9","9"],["10","10"],["11","11"],["12","12"],["13","13"]]),"PORT");this.appendDummyInput().appendField(" ");this.setOutput(!0,"Number");this.setInputsInline(!0)}};Entry.block.arduino_get_port_number=function(a,b){return b.getStringField("PORT")}; -Blockly.Blocks.arduino_get_pwm_port_number={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(new Blockly.FieldDropdown([["3","3"],["5","5"],["6","6"],["9","9"],["10","10"],["11","11"]]),"PORT");this.appendDummyInput().appendField(" ");this.setOutput(!0,"Number");this.setInputsInline(!0)}};Entry.block.arduino_get_pwm_port_number=function(a,b){return b.getStringField("PORT")}; -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(a,b){a=b.getValue("VALUE",b);return Entry.hw.getAnalogPortValue(a[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(a,b){a=b.getNumberValue("VALUE",b);return Entry.hw.getDigitalPortValue(a)}; +this.setOutput(!0,"Number");this.setInputsInline(!0)}};Entry.block.arduino_get_sensor_number=function(b,a){return a.getStringField("PORT")}; +Blockly.Blocks.arduino_get_port_number={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(new Blockly.FieldDropdown([["0","0"],["1","1"],["2","2"],["3","3"],["4","4"],["5","5"],["6","6"],["7","7"],["8","8"],["9","9"],["10","10"],["11","11"],["12","12"],["13","13"]]),"PORT");this.appendDummyInput().appendField(" ");this.setOutput(!0,"Number");this.setInputsInline(!0)}};Entry.block.arduino_get_port_number=function(b,a){return a.getStringField("PORT")}; +Blockly.Blocks.arduino_get_pwm_port_number={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(new Blockly.FieldDropdown([["3","3"],["5","5"],["6","6"],["9","9"],["10","10"],["11","11"]]),"PORT");this.appendDummyInput().appendField(" ");this.setOutput(!0,"Number");this.setInputsInline(!0)}};Entry.block.arduino_get_pwm_port_number=function(b,a){return a.getStringField("PORT")}; +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(a,b){a=b.getNumberValue("VALUE");var c=b.getField("OPERATOR");Entry.hw.setDigitalPortValue(a,"on"==c?255:0);return b.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(a,b){a=b.getNumberValue("PORT");var c=b.getNumberValue("VALUE"),c=Math.round(c),c=Math.max(c,0),c=Math.min(c,255);Entry.hw.setDigitalPortValue(a,c);return b.callReturn()}; +"*"));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); this.appendValueInput("VALUE4").setCheck(["Number","String",null]);this.appendDummyInput().appendField(Lang.Blocks.ARDUINO_convert_scale_5);this.appendValueInput("VALUE5").setCheck(["Number","String",null]);this.appendDummyInput().appendField(Lang.Blocks.ARDUINO_convert_scale_6);this.appendDummyInput().appendField(" ");this.setOutput(!0,"Number");this.setInputsInline(!0)}}; -Entry.block.arduino_convert_scale=function(a,b){var c=b.getNumberValue("VALUE1",b),d=b.getNumberValue("VALUE2",b),e=b.getNumberValue("VALUE3",b);a=b.getNumberValue("VALUE4",b);b=b.getNumberValue("VALUE5",b);if(d>e)var f=d,d=e,e=f;a>b&&(f=a,a=b,b=f);c=(b-a)/(e-d)*(c-d);c+=a;c=Math.min(b,c);c=Math.max(a,c);return Math.round(c)}; -Blockly.Blocks.sensorBoard_get_named_sensor_value={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("").appendField(new Blockly.FieldDropdown([["\uc18c\ub9ac","0"],["\ube5b \uac10\uc9c0","1"],["\uc2ac\ub77c\uc774\ub354","2"],["\uc628\ub3c4","3"]]),"PORT").appendField(" \uc13c\uc11c\uac12");this.setOutput(!0,"Number");this.setInputsInline(!0)}};Entry.block.sensorBoard_get_named_sensor_value=function(a,b){return Entry.hw.getAnalogPortValue(b.getField("PORT",b))}; +Entry.block.arduino_convert_scale=function(b,a){var c=a.getNumberValue("VALUE1",a),d=a.getNumberValue("VALUE2",a),e=a.getNumberValue("VALUE3",a),f=a.getNumberValue("VALUE4",a),g=a.getNumberValue("VALUE5",a);if(d>e)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)}; +Blockly.Blocks.sensorBoard_get_named_sensor_value={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("").appendField(new Blockly.FieldDropdown([["\uc18c\ub9ac","0"],["\ube5b \uac10\uc9c0","1"],["\uc2ac\ub77c\uc774\ub354","2"],["\uc628\ub3c4","3"]]),"PORT").appendField(" \uc13c\uc11c\uac12");this.setOutput(!0,"Number");this.setInputsInline(!0)}};Entry.block.sensorBoard_get_named_sensor_value=function(b,a){return Entry.hw.getAnalogPortValue(a.getField("PORT",a))}; Blockly.Blocks.sensorBoard_is_button_pressed={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("").appendField(new Blockly.FieldDropdown([["\ube68\uac04","8"],["\ud30c\ub780","9"],["\ub178\ub780","10"],["\ucd08\ub85d","11"]]),"PORT");this.appendDummyInput().appendField(" \ubc84\ud2bc\uc744 \ub20c\ub800\ub294\uac00?");this.setInputsInline(!0);this.setOutput(!0,"Boolean")}}; -Entry.block.sensorBoard_is_button_pressed=function(a,b){return Entry.hw.getDigitalPortValue(b.getNumberField("PORT",b))}; +Entry.block.sensorBoard_is_button_pressed=function(b,a){return Entry.hw.getDigitalPortValue(a.getNumberField("PORT",a))}; Blockly.Blocks.sensorBoard_led={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("").appendField(new Blockly.FieldDropdown([["\ube68\uac04","2"],["\ucd08\ub85d","3"],["\ud30c\ub780","4"],["\ud770\uc0c9","5"]]),"PORT").appendField(" LED").appendField(new Blockly.FieldDropdown([["\ucf1c\uae30","255"],["\ub044\uae30","0"]]),"OPERATOR").appendField(" ").appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0); -this.setNextStatement(!0)}};Entry.block.sensorBoard_led=function(a,b){Entry.hw.setDigitalPortValue(b.getField("PORT"),b.getNumberField("OPERATOR"));return b.callReturn()};Entry.block.arduino_download_connector={skeleton:"basic_button",color:"#eee",template:"%1",params:[{type:"Text",text:"\uc5f0\uacb0 \ud504\ub85c\uadf8\ub7a8 \ub2e4\uc6b4\ub85c\ub4dc",color:"#333",align:"center"}],func:function(){},events:{mousedown:[function(){console.log("download connector")}]}}; +this.setNextStatement(!0)}};Entry.block.sensorBoard_led=function(b,a){Entry.hw.setDigitalPortValue(a.getField("PORT"),a.getNumberField("OPERATOR"));return a.callReturn()};Entry.block.arduino_download_connector={skeleton:"basic_button",color:"#eee",template:"%1",params:[{type:"Text",text:"\uc5f0\uacb0 \ud504\ub85c\uadf8\ub7a8 \ub2e4\uc6b4\ub85c\ub4dc",color:"#333",align:"center"}],func:function(){},events:{mousedown:[function(){console.log("download connector")}]}}; Entry.block.arduino_download_source={skeleton:"basic_button",color:"#eee",template:"%1",params:[{type:"Text",text:"\uc5d4\ud2b8\ub9ac \uc544\ub450\uc774\ub178 \uc18c\uc2a4",color:"#333",align:"center"}],func:function(){},events:{mousedown:[function(){console.log("download source")}]}};Entry.block.arduino_connected={skeleton:"basic_button",color:"#eee",template:"%1",params:[{type:"Text",text:"\uc5f0\uacb0 \ub428",color:"#333",align:"center"}],func:function(){},events:{mousedown:[function(){console.log("download source")}]}}; Entry.block.arduino_reconnect={skeleton:"basic_button",color:"#eee",template:"%1",params:[{type:"Text",text:"\ub2e4\uc2dc \uc5f0\uacb0\ud558\uae30",color:"#333",align:"center"}],func:function(){},events:{mousedown:[function(){console.log("download source")}]}}; Blockly.Blocks.CODEino_get_sensor_number={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(new Blockly.FieldDropdown([[Lang.Blocks.CODEino_get_sensor_number_0,"A0"],[Lang.Blocks.CODEino_get_sensor_number_1,"A1"],[Lang.Blocks.CODEino_get_sensor_number_2,"A2"],[Lang.Blocks.CODEino_get_sensor_number_3,"A3"],[Lang.Blocks.CODEino_get_sensor_number_4,"A4"],[Lang.Blocks.CODEino_get_sensor_number_5,"A5"],[Lang.Blocks.CODEino_get_sensor_number_6,"A6"]]),"PORT");this.appendDummyInput().appendField(" "); -this.setOutput(!0,"Number");this.setInputsInline(!0)}};Entry.block.CODEino_get_sensor_number=function(a,b){return b.getStringField("PORT")}; +this.setOutput(!0,"Number");this.setInputsInline(!0)}};Entry.block.CODEino_get_sensor_number=function(b,a){return a.getStringField("PORT")}; Blockly.Blocks.CODEino_get_named_sensor_value={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(" ").appendField(new Blockly.FieldDropdown([[Lang.Blocks.CODEino_sensor_name_0,"0"],[Lang.Blocks.CODEino_sensor_name_1,"1"],[Lang.Blocks.CODEino_sensor_name_2,"2"],[Lang.Blocks.CODEino_sensor_name_3,"3"],[Lang.Blocks.CODEino_sensor_name_4,"4"],[Lang.Blocks.CODEino_sensor_name_5,"5"],[Lang.Blocks.CODEino_sensor_name_6,"6"]]),"PORT").appendField(Lang.Blocks.CODEino_string_1); -this.setOutput(!0,"Number");this.setInputsInline(!0)}};Entry.block.CODEino_get_named_sensor_value=function(a,b){return Entry.hw.getAnalogPortValue(b.getField("PORT",b))}; +this.setOutput(!0,"Number");this.setInputsInline(!0)}};Entry.block.CODEino_get_named_sensor_value=function(b,a){return Entry.hw.getAnalogPortValue(a.getField("PORT",a))}; Blockly.Blocks.CODEino_get_sound_status={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.CODEino_string_10).appendField(new Blockly.FieldDropdown([[Lang.Blocks.CODEino_string_11,"GREAT"],[Lang.Blocks.CODEino_string_12,"SMALL"]]),"STATUS").appendField(" ");this.setInputsInline(!0);this.setOutput(!0,"Boolean")}}; -Entry.block.CODEino_get_sound_status=function(a,b){return"GREAT"==b.getField("STATUS",b)?600Entry.hw.getAnalogPortValue(0)?1:0}; +Entry.block.CODEino_get_sound_status=function(b,a){return"GREAT"==a.getField("STATUS",a)?600Entry.hw.getAnalogPortValue(0)?1:0}; Blockly.Blocks.CODEino_get_light_status={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.CODEino_string_13).appendField(new Blockly.FieldDropdown([[Lang.Blocks.CODEino_string_14,"BRIGHT"],[Lang.Blocks.CODEino_string_15,"DARK"]]),"STATUS").appendField(" ");this.setInputsInline(!0);this.setOutput(!0,"Boolean")}}; -Entry.block.CODEino_get_light_status=function(a,b){return"DARK"==b.getField("STATUS",b)?800Entry.hw.getAnalogPortValue(1)?1:0}; +Entry.block.CODEino_get_light_status=function(b,a){return"DARK"==a.getField("STATUS",a)?800Entry.hw.getAnalogPortValue(1)?1:0}; Blockly.Blocks.CODEino_is_button_pressed={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.CODEino_string_2).appendField(new Blockly.FieldDropdown([[Lang.Blocks.CODEino_string_3,"4"],[Lang.Blocks.CODEino_string_4,"17"],[Lang.Blocks.CODEino_string_5,"18"],[Lang.Blocks.CODEino_string_6,"19"],[Lang.Blocks.CODEino_string_7,"20"]]),"PORT").appendField(" ");this.setInputsInline(!0);this.setOutput(!0,"Boolean")}}; -Entry.block.CODEino_is_button_pressed=function(a,b){a=b.getNumberField("PORT",b);return 14b?1:0;if("RIGHT"==a||"FRONT"==a)return 30b?1:0}; +Entry.block.CODEino_get_accelerometer_direction=function(b,a){var c=a.getField("DIRECTION",a),d=0;"LEFT"==c||"RIGHT"==c?d=3:"FRONT"==c||"REAR"==c?d=4:"REVERSE"==c&&(d=5);d=Entry.hw.getAnalogPortValue(d);d=180/137*(d-265);d+=-90;d=Math.min(90,d);d=Math.max(-90,d);d=Math.round(d);if("LEFT"==c||"REAR"==c)return-30>d?1:0;if("RIGHT"==c||"FRONT"==c)return 30d?1:0}; 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(a,b){var c=Entry.hw.getAnalogPortValue(b.getField("PORT",b)),d=265,e=402;a=-90;b=90;if(d>e)var f=d,d=e,e=f;a>b&&(f=a,a=b,b=f);c=(b-a)/(e-d)*(c-d);c+=a;c=Math.min(b,c);c=Math.max(a,c);return Math.round(c)}; +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(a,b){var c=b.getField("PORT");a=7;"7"==c?a=7:"8"==c?a=8:"9"==c?a=9:"10"==c&&(a=10);c=b.getField("OPERATOR");Entry.hw.setDigitalPortValue(a,"on"==c?255:0);return b.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(a,b){a=b.getField("PORT");var c=2;"2"==a?c=2:"4"==a&&(c=4);return"OFF"==b.getField("STATUS")?1==Entry.hw.getDigitalPortValue(c)?1:0:0==Entry.hw.getDigitalPortValue(c)?1:0}; +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")}}; -Entry.block.dplay_get_light_status=function(a,b){return"DARK"==b.getField("STATUS",b)?800Entry.hw.getAnalogPortValue(1)?1:0}; +Entry.block.dplay_get_light_status=function(b,a){return"DARK"==a.getField("STATUS",a)?800Entry.hw.getAnalogPortValue(1)?1:0}; Blockly.Blocks.dplay_get_value={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.dplay_num_pin_3);this.appendValueInput("VALUE").setCheck(["Number","String",null]);this.appendDummyInput().appendField("\ubc88 ");this.appendDummyInput().appendField(new Blockly.FieldDropdown([["\uac00\ubcc0\uc800\ud56d","ADJU"],["\ube5b\uc13c\uc11c","LIGHT"],["\uc628\ub3c4\uc13c\uc11c","TEMP"],["\uc870\uc774\uc2a4\ud2f1 X","JOYS"],["\uc870\uc774\uc2a4\ud2f1 Y","JOYS"],["\uc801\uc678\uc120", -"INFR"]]),"OPERATOR");this.appendDummyInput().appendField(Lang.Blocks.dplay_num_pin_5);this.setInputsInline(!0);this.setOutput(!0,"Number")}};Entry.block.dplay_get_value=function(a,b){a=b.getValue("VALUE",b);return Entry.hw.getAnalogPortValue(a[1])}; +"INFR"]]),"OPERATOR");this.appendDummyInput().appendField(Lang.Blocks.dplay_num_pin_5);this.setInputsInline(!0);this.setOutput(!0,"Number")}};Entry.block.dplay_get_value=function(b,a){var c=a.getValue("VALUE",a);return Entry.hw.getAnalogPortValue(c[1])}; Blockly.Blocks.dplay_get_tilt={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.dplay_tilt).appendField(new Blockly.FieldDropdown([["\uc67c\ucabd \uae30\uc6b8\uc784","LEFT"],["\uc624\ub978\ucabd \uae30\uc6b8\uc784","LIGHT"]]),"STATUS").appendField(" ");this.setInputsInline(!0);this.setOutput(!0,"Boolean")}}; -Entry.block.dplay_get_tilt=function(a,b){return"LIGHT"==b.getField("STATUS",b)?1==Entry.hw.getDigitalPortValue(12)?1:0:0==Entry.hw.getDigitalPortValue(12)?1:0}; +Entry.block.dplay_get_tilt=function(b,a){return"LIGHT"==a.getField("STATUS",a)?1==Entry.hw.getDigitalPortValue(12)?1:0:0==Entry.hw.getDigitalPortValue(12)?1:0}; Blockly.Blocks.dplay_DCmotor={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(new Blockly.FieldDropdown([["\uc67c\ucabd","3"],["\uc624\ub978\ucabd","6"]]),"PORT");this.appendDummyInput().appendField(" DC\ubaa8\ud130 \uc0c1\ud0dc\ub97c");this.appendDummyInput().appendField(new Blockly.FieldDropdown([["\uc815\ubc29\ud5a5","FRONT"],["\uc5ed\ubc29\ud5a5","REAR"],["\uc815\uc9c0","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_DCmotor=function(a,b){a=b.getField("PORT");var c=0;"3"==a?c=5:"6"==a&&(c=11);var d=b.getField("OPERATOR"),e=0,f=0;"FRONT"==d?(e=255,f=0):"REAR"==d?(e=0,f=255):"OFF"==d&&(f=e=0);Entry.hw.setDigitalPortValue(a,e);Entry.hw.setDigitalPortValue(c,f);return b.callReturn()}; +"*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.dplay_DCmotor=function(b,a){var c=a.getField("PORT"),d=0;"3"==c?d=5:"6"==c&&(d=11);var e=a.getField("OPERATOR"),f=0,g=0;"FRONT"==e?(f=255,g=0):"REAR"==e?(f=0,g=255):"OFF"==e&&(g=f=0);Entry.hw.setDigitalPortValue(c,f);Entry.hw.setDigitalPortValue(d,g);return a.callReturn()}; Blockly.Blocks.dplay_buzzer={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("\ubd80\uc800\ub97c ");this.appendDummyInput().appendField(new Blockly.FieldDropdown([["\ub3c4","1"],["\ub808","2"],["\ubbf8","3"]]),"PORT");this.appendDummyInput().appendField("\ub85c");this.appendValueInput("VALUE").setCheck(["Number","String",null]);this.appendDummyInput().appendField("\ubc15\uc790\ub85c \uc5f0\uc8fc\ud558\uae30");this.appendDummyInput().appendField(new Blockly.FieldIcon(Entry.mediaFilePath+ -"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.dplay_buzzer=function(a,b){var c=b.getField("PORT");a=2;"1"==c?a=2:"2"==c?a=4:"3"==c&&(a=7);c=b.getNumberValue("VALUE");c=Math.round(c);c=Math.max(c,0);c=Math.min(c,100);Entry.hw.setDigitalPortValue(a,c);return b.callReturn()}; +"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.dplay_buzzer=function(b,a){var c=a.getField("PORT"),d=2;"1"==c?d=2:"2"==c?d=4:"3"==c&&(d=7);c=a.getNumberValue("VALUE");c=Math.round(c);c=Math.max(c,0);c=Math.min(c,100);Entry.hw.setDigitalPortValue(d,c);return a.callReturn()}; Blockly.Blocks.dplay_servo={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("\uc11c\ubcf4\ubaa8\ud130 \uac01\ub3c4\ub97c");this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField("\ub85c \uc774\ub3d9");this.appendDummyInput().appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.dplay_servo=function(a,b){a=b.getNumberValue("VALUE");a=Math.round(a);a=Math.max(a,0);a=Math.min(a,180);Entry.hw.setDigitalPortValue(9,a);return b.callReturn()};Entry.Bitbrick={SENSOR_MAP:{1:"light",2:"IR",3:"touch",4:"potentiometer",5:"MIC",21:"UserSensor",11:"UserInput",20:"LED",19:"SERVO",18:"DC"},PORT_MAP:{buzzer:2,5:4,6:6,7:8,8:10,LEDR:12,LEDG:14,LEDB:16},sensorList:function(){for(var a=[],b=Entry.hw.portData,c=1;5>c;c++){var d=b[c];d&&(d.value||0===d.value)&&a.push([c+" - "+Lang.Blocks["BITBRICK_"+d.type],c.toString()])}return 0==a.length?[[Lang.Blocks.no_target,"null"]]:a},touchList:function(){for(var a=[],b=Entry.hw.portData,c=1;5>c;c++){var d=b[c]; -d&&"touch"===d.type&&a.push([c.toString(),c.toString()])}return 0==a.length?[[Lang.Blocks.no_target,"null"]]:a},servoList:function(){for(var a=[],b=Entry.hw.portData,c=5;9>c;c++){var d=b[c];d&&"SERVO"===d.type&&a.push(["ABCD"[c-5],c.toString()])}return 0==a.length?[[Lang.Blocks.no_target,"null"]]:a},dcList:function(){for(var a=[],b=Entry.hw.portData,c=5;9>c;c++){var d=b[c];d&&"DC"===d.type&&a.push(["ABCD"[c-5],c.toString()])}return 0==a.length?[[Lang.Blocks.no_target,"null"]]:a},setZero:function(){var a= -Entry.hw.sendQueue,b;for(b in Entry.Bitbrick.PORT_MAP)a[b]=0;Entry.hw.update()},name:"bitbrick",servoMaxValue:181,servoMinValue:1,dcMaxValue:100,dcMinValue:-100,monitorTemplate:{keys:["value"],imgPath:"hw/bitbrick.png",width:400,height:400,listPorts:{1:{name:Lang.Hw.port_en+" 1 "+Lang.Hw.port_ko,type:"input",pos:{x:0,y:0}},2:{name:Lang.Hw.port_en+" 2 "+Lang.Hw.port_ko,type:"input",pos:{x:0,y:0}},3:{name:Lang.Hw.port_en+" 3 "+Lang.Hw.port_ko,type:"input",pos:{x:0,y:0}},4:{name:Lang.Hw.port_en+" 4 "+ +Entry.block.dplay_servo=function(b,a){var c=a.getNumberValue("VALUE"),c=Math.round(c),c=Math.max(c,0),c=Math.min(c,180);Entry.hw.setDigitalPortValue(9,c);return a.callReturn()};Entry.Bitbrick={SENSOR_MAP:{1:"light",2:"IR",3:"touch",4:"potentiometer",5:"MIC",21:"UserSensor",11:"UserInput",20:"LED",19:"SERVO",18:"DC"},PORT_MAP:{buzzer:2,5:4,6:6,7:8,8:10,LEDR:12,LEDG:14,LEDB:16},sensorList:function(){for(var b=[],a=Entry.hw.portData,c=1;5>c;c++){var d=a[c];d&&(d.value||0===d.value)&&b.push([c+" - "+Lang.Blocks["BITBRICK_"+d.type],c.toString()])}return 0==b.length?[[Lang.Blocks.no_target,"null"]]:b},touchList:function(){for(var b=[],a=Entry.hw.portData,c=1;5>c;c++){var d=a[c]; +d&&"touch"===d.type&&b.push([c.toString(),c.toString()])}return 0==b.length?[[Lang.Blocks.no_target,"null"]]:b},servoList:function(){for(var b=[],a=Entry.hw.portData,c=5;9>c;c++){var d=a[c];d&&"SERVO"===d.type&&b.push(["ABCD"[c-5],c.toString()])}return 0==b.length?[[Lang.Blocks.no_target,"null"]]:b},dcList:function(){for(var b=[],a=Entry.hw.portData,c=5;9>c;c++){var d=a[c];d&&"DC"===d.type&&b.push(["ABCD"[c-5],c.toString()])}return 0==b.length?[[Lang.Blocks.no_target,"null"]]:b},setZero:function(){var b= +Entry.hw.sendQueue,a;for(a in Entry.Bitbrick.PORT_MAP)b[a]=0;Entry.hw.update()},name:"bitbrick",servoMaxValue:181,servoMinValue:1,dcMaxValue:100,dcMinValue:-100,monitorTemplate:{keys:["value"],imgPath:"hw/bitbrick.png",width:400,height:400,listPorts:{1:{name:Lang.Hw.port_en+" 1 "+Lang.Hw.port_ko,type:"input",pos:{x:0,y:0}},2:{name:Lang.Hw.port_en+" 2 "+Lang.Hw.port_ko,type:"input",pos:{x:0,y:0}},3:{name:Lang.Hw.port_en+" 3 "+Lang.Hw.port_ko,type:"input",pos:{x:0,y:0}},4:{name:Lang.Hw.port_en+" 4 "+ Lang.Hw.port_ko,type:"input",pos:{x:0,y:0}},A:{name:Lang.Hw.port_en+" A "+Lang.Hw.port_ko,type:"input",pos:{x:0,y:0}},B:{name:Lang.Hw.port_en+" B "+Lang.Hw.port_ko,type:"input",pos:{x:0,y:0}},C:{name:Lang.Hw.port_en+" C "+Lang.Hw.port_ko,type:"input",pos:{x:0,y:0}},D:{name:Lang.Hw.port_en+" D "+Lang.Hw.port_ko,type:"input",pos:{x:0,y:0}}},mode:"both"}}; -Blockly.Blocks.bitbrick_sensor_value={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("").appendField(new Blockly.FieldDropdownDynamic(Entry.Bitbrick.sensorList),"PORT").appendField(" \uac12");this.setOutput(!0,"String");this.setInputsInline(!0)}};Entry.block.bitbrick_sensor_value=function(a,b){a=b.getStringField("PORT");return Entry.hw.portData[a].value}; -Blockly.Blocks.bitbrick_is_touch_pressed={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.BITBRICK_touch).appendField(new Blockly.FieldDropdownDynamic(Entry.Bitbrick.touchList),"PORT").appendField("\uc774(\uac00) \ub20c\ub838\ub294\uac00?");this.setOutput(!0,"Boolean");this.setInputsInline(!0)}};Entry.block.bitbrick_is_touch_pressed=function(a,b){return 0===Entry.hw.portData[b.getStringField("PORT")].value}; -Blockly.Blocks.bitbrick_turn_off_color_led={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("\uceec\ub7ec LED \ub044\uae30").appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.bitbrick_turn_off_color_led=function(a,b){Entry.hw.sendQueue.LEDR=0;Entry.hw.sendQueue.LEDG=0;Entry.hw.sendQueue.LEDB=0;return b.callReturn()}; +Blockly.Blocks.bitbrick_sensor_value={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("").appendField(new Blockly.FieldDropdownDynamic(Entry.Bitbrick.sensorList),"PORT").appendField(" \uac12");this.setOutput(!0,"String");this.setInputsInline(!0)}};Entry.block.bitbrick_sensor_value=function(b,a){var c=a.getStringField("PORT");return Entry.hw.portData[c].value}; +Blockly.Blocks.bitbrick_is_touch_pressed={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.BITBRICK_touch).appendField(new Blockly.FieldDropdownDynamic(Entry.Bitbrick.touchList),"PORT").appendField("\uc774(\uac00) \ub20c\ub838\ub294\uac00?");this.setOutput(!0,"Boolean");this.setInputsInline(!0)}};Entry.block.bitbrick_is_touch_pressed=function(b,a){return 0===Entry.hw.portData[a.getStringField("PORT")].value}; +Blockly.Blocks.bitbrick_turn_off_color_led={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("\uceec\ub7ec LED \ub044\uae30").appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.bitbrick_turn_off_color_led=function(b,a){Entry.hw.sendQueue.LEDR=0;Entry.hw.sendQueue.LEDG=0;Entry.hw.sendQueue.LEDB=0;return a.callReturn()}; Blockly.Blocks.bitbrick_turn_on_color_led_by_rgb={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("\uceec\ub7ec LED \ucf1c\uae30 R");this.appendValueInput("rValue").setCheck(["Number","String"]);this.appendDummyInput().appendField("G");this.appendValueInput("gValue").setCheck(["Number","String"]);this.appendDummyInput().appendField("B");this.appendValueInput("bValue").setCheck(["Number","String"]);this.appendDummyInput().appendField(new Blockly.FieldIcon(Entry.mediaFilePath+ -"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.bitbrick_turn_on_color_led_by_rgb=function(a,b){a=b.getNumberValue("rValue");var c=b.getNumberValue("gValue"),d=b.getNumberValue("bValue"),e=Entry.adjustValueWithMaxMin,f=Entry.hw.sendQueue;f.LEDR=e(a,0,255);f.LEDG=e(c,0,255);f.LEDB=e(d,0,255);return b.callReturn()}; +"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.bitbrick_turn_on_color_led_by_rgb=function(b,a){var c=a.getNumberValue("rValue"),d=a.getNumberValue("gValue"),e=a.getNumberValue("bValue"),f=Entry.adjustValueWithMaxMin,g=Entry.hw.sendQueue;g.LEDR=f(c,0,255);g.LEDG=f(d,0,255);g.LEDB=f(e,0,255);return a.callReturn()}; Blockly.Blocks.bitbrick_turn_on_color_led_by_picker={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("\uceec\ub7ec LED \uc0c9 ").appendField(new Blockly.FieldColour("#ff0000"),"VALUE").appendField("\ub85c \uc815\ud558\uae30").appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.bitbrick_turn_on_color_led_by_picker=function(a,b){a=b.getStringField("VALUE");Entry.hw.sendQueue.LEDR=parseInt(a.substr(1,2),16);Entry.hw.sendQueue.LEDG=parseInt(a.substr(3,2),16);Entry.hw.sendQueue.LEDB=parseInt(a.substr(5,2),16);return b.callReturn()}; +Entry.block.bitbrick_turn_on_color_led_by_picker=function(b,a){var c=a.getStringField("VALUE");Entry.hw.sendQueue.LEDR=parseInt(c.substr(1,2),16);Entry.hw.sendQueue.LEDG=parseInt(c.substr(3,2),16);Entry.hw.sendQueue.LEDB=parseInt(c.substr(5,2),16);return a.callReturn()}; Blockly.Blocks.bitbrick_turn_on_color_led_by_value={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("\uceec\ub7ec LED \ucf1c\uae30 \uc0c9");this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField("\ub85c \uc815\ud558\uae30").appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.bitbrick_turn_on_color_led_by_value=function(a,b){a=b.getNumberValue("VALUE");var c,d,e;a%=200;67>a?(c=200-3*a,d=3*a,e=0):134>a?(a-=67,c=0,d=200-3*a,e=3*a):201>a&&(a-=134,c=3*a,d=0,e=200-3*a);Entry.hw.sendQueue.LEDR=c;Entry.hw.sendQueue.LEDG=d;Entry.hw.sendQueue.LEDB=e;return b.callReturn()}; +Entry.block.bitbrick_turn_on_color_led_by_value=function(b,a){var c=a.getNumberValue("VALUE"),d,e,f,c=c%200;67>c?(d=200-3*c,e=3*c,f=0):134>c?(c-=67,d=0,e=200-3*c,f=3*c):201>c&&(c-=134,d=3*c,e=0,f=200-3*c);Entry.hw.sendQueue.LEDR=d;Entry.hw.sendQueue.LEDG=e;Entry.hw.sendQueue.LEDB=f;return a.callReturn()}; Blockly.Blocks.bitbrick_buzzer={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("\ubc84\uc800\uc74c ");this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField("\ub0b4\uae30").appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.bitbrick_buzzer=function(a,b){if(b.isStart)return Entry.hw.sendQueue.buzzer=0,delete b.isStart,b.callReturn();a=b.getNumberValue("VALUE");Entry.hw.sendQueue.buzzer=a;b.isStart=!0;return b}; +Entry.block.bitbrick_buzzer=function(b,a){if(a.isStart)return Entry.hw.sendQueue.buzzer=0,delete a.isStart,a.callReturn();var c=a.getNumberValue("VALUE");Entry.hw.sendQueue.buzzer=c;a.isStart=!0;return a}; Blockly.Blocks.bitbrick_turn_off_all_motors={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("\ubaa8\ub4e0 \ubaa8\ud130 \ub044\uae30").appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.bitbrick_turn_off_all_motors=function(a,b){var c=Entry.hw.sendQueue;a=Entry.Bitbrick;a.servoList().map(function(b){c[b[1]]=0});a.dcList().map(function(b){c[b[1]]=128});return b.callReturn()}; +Entry.block.bitbrick_turn_off_all_motors=function(b,a){var c=Entry.hw.sendQueue,d=Entry.Bitbrick;d.servoList().map(function(a){c[a[1]]=0});d.dcList().map(function(a){c[a[1]]=128});return a.callReturn()}; Blockly.Blocks.bitbrick_dc_speed={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("DC \ubaa8\ud130").appendField(new Blockly.FieldDropdownDynamic(Entry.Bitbrick.dcList),"PORT").appendField(" \uc18d\ub3c4");this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField("").appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setPreviousStatement(!0);this.setNextStatement(!0);this.setInputsInline(!0)}}; -Entry.block.bitbrick_dc_speed=function(a,b){a=b.getNumberValue("VALUE");a=Math.min(a,Entry.Bitbrick.dcMaxValue);a=Math.max(a,Entry.Bitbrick.dcMinValue);Entry.hw.sendQueue[b.getStringField("PORT")]=a+128;return b.callReturn()}; +Entry.block.bitbrick_dc_speed=function(b,a){var c=a.getNumberValue("VALUE"),c=Math.min(c,Entry.Bitbrick.dcMaxValue),c=Math.max(c,Entry.Bitbrick.dcMinValue);Entry.hw.sendQueue[a.getStringField("PORT")]=c+128;return a.callReturn()}; Blockly.Blocks.bitbrick_dc_direction_speed={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("DC \ubaa8\ud130").appendField(new Blockly.FieldDropdownDynamic(Entry.Bitbrick.dcList),"PORT").appendField(" ").appendField(new Blockly.FieldDropdown([[Lang.Blocks.BITBRICK_dc_direction_cw,"CW"],[Lang.Blocks.BITBRICK_dc_direction_ccw,"CCW"]]),"DIRECTION").appendField(" \ubc29\ud5a5").appendField(" \uc18d\ub825");this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField("").appendField(new Blockly.FieldIcon(Entry.mediaFilePath+ -"block_icon/hardware_03.png","*"));this.setPreviousStatement(!0);this.setNextStatement(!0);this.setInputsInline(!0)}};Entry.block.bitbrick_dc_direction_speed=function(a,b){a="CW"===b.getStringField("DIRECTION");var c=b.getNumberValue("VALUE"),c=Math.min(c,Entry.Bitbrick.dcMaxValue),c=Math.max(c,0);Entry.hw.sendQueue[b.getStringField("PORT")]=a?c+128:128-c;return b.callReturn()}; +"block_icon/hardware_03.png","*"));this.setPreviousStatement(!0);this.setNextStatement(!0);this.setInputsInline(!0)}};Entry.block.bitbrick_dc_direction_speed=function(b,a){var c="CW"===a.getStringField("DIRECTION"),d=a.getNumberValue("VALUE"),d=Math.min(d,Entry.Bitbrick.dcMaxValue),d=Math.max(d,0);Entry.hw.sendQueue[a.getStringField("PORT")]=c?d+128:128-d;return a.callReturn()}; Blockly.Blocks.bitbrick_servomotor_angle={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("\uc11c\ubcf4 \ubaa8\ud130").appendField(new Blockly.FieldDropdownDynamic(Entry.Bitbrick.servoList),"PORT").appendField(" \uac01\ub3c4");this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField("").appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setPreviousStatement(!0);this.setNextStatement(!0); -this.setInputsInline(!0)}};Entry.block.bitbrick_servomotor_angle=function(a,b){a=b.getNumberValue("VALUE")+1;a=Math.min(a,Entry.Bitbrick.servoMaxValue);a=Math.max(a,Entry.Bitbrick.servoMinValue);Entry.hw.sendQueue[b.getStringField("PORT")]=a;return b.callReturn()}; +this.setInputsInline(!0)}};Entry.block.bitbrick_servomotor_angle=function(b,a){var c=a.getNumberValue("VALUE")+1,c=Math.min(c,Entry.Bitbrick.servoMaxValue),c=Math.max(c,Entry.Bitbrick.servoMinValue);Entry.hw.sendQueue[a.getStringField("PORT")]=c;return a.callReturn()}; Blockly.Blocks.bitbrick_convert_scale={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("\ubcc0\ud658");this.appendDummyInput().appendField("").appendField(new Blockly.FieldDropdownDynamic(Entry.Bitbrick.sensorList),"PORT");this.appendDummyInput().appendField("\uac12");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("\uc5d0\uc11c");this.appendValueInput("VALUE4").setCheck(["Number","String",null]);this.appendDummyInput().appendField(Lang.Blocks.ARDUINO_convert_scale_5);this.appendValueInput("VALUE5").setCheck(["Number","String",null]);this.setOutput(!0,"Number");this.setInputsInline(!0)}}; -Entry.block.bitbrick_convert_scale=function(a,b){a=b.getNumberField("PORT");var c=Entry.hw.portData[a].value,d=b.getNumberValue("VALUE2",b),e=b.getNumberValue("VALUE3",b);a=b.getNumberValue("VALUE4",b);b=b.getNumberValue("VALUE5",b);if(a>b){var f=a;a=b;b=f}c=(b-a)/(e-d)*(c-d);c+=a;c=Math.min(b,c);c=Math.max(a,c);return Math.round(c)};var categoryColor="#FF9E20";Blockly.Blocks.start_drawing={init:function(){this.setColour(categoryColor);this.appendDummyInput().appendField(Lang.Blocks.BRUSH_start_drawing).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/brush_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.start_drawing=function(a,b){a.brush?a.brush.stop=!1:Entry.setBasicBrush(a);Entry.stage.sortZorder();a.brush.moveTo(a.getX(),-1*a.getY());return b.callReturn()}; -Blockly.Blocks.stop_drawing={init:function(){this.setColour(categoryColor);this.appendDummyInput().appendField(Lang.Blocks.BRUSH_stop_drawing).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/brush_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.stop_drawing=function(a,b){a.brush&&a.shape&&(a.brush.stop=!0);return b.callReturn()}; +Entry.block.bitbrick_convert_scale=function(b,a){var c=a.getNumberField("PORT"),d=Entry.hw.portData[c].value,c=a.getNumberValue("VALUE2",a),e=a.getNumberValue("VALUE3",a),f=a.getNumberValue("VALUE4",a),g=a.getNumberValue("VALUE5",a);if(f>g)var h=f,f=g,g=h;d-=c;d*=(g-f)/(e-c);d+=f;d=Math.min(g,d);d=Math.max(f,d);return Math.round(d)};var categoryColor="#FF9E20";Blockly.Blocks.start_drawing={init:function(){this.setColour(categoryColor);this.appendDummyInput().appendField(Lang.Blocks.BRUSH_start_drawing).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/brush_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.start_drawing=function(b,a){b.brush?b.brush.stop=!1:Entry.setBasicBrush(b);Entry.stage.sortZorder();b.brush.moveTo(b.getX(),-1*b.getY());return a.callReturn()}; +Blockly.Blocks.stop_drawing={init:function(){this.setColour(categoryColor);this.appendDummyInput().appendField(Lang.Blocks.BRUSH_stop_drawing).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/brush_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.stop_drawing=function(b,a){b.brush&&b.shape&&(b.brush.stop=!0);return a.callReturn()}; Blockly.Blocks.set_color={init:function(){this.setColour(categoryColor);this.appendDummyInput().appendField(Lang.Blocks.BRUSH_set_color_1);this.appendDummyInput().appendField(new Blockly.FieldColour("#ff0000"),"VALUE");this.appendDummyInput().appendField(Lang.Blocks.BRUSH_set_color_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/brush_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.set_color=function(a,b){var c=b.getField("VALUE",b);a.brush||(Entry.setBasicBrush(a),a.brush.stop=!0);a.brush&&(c=Entry.hex2rgb(c),a.brush.rgb=c,a.brush.endStroke(),a.brush.beginStroke("rgba("+c.r+","+c.g+","+c.b+","+a.brush.opacity/100+")"),a.brush.moveTo(a.getX(),-1*a.getY()));return b.callReturn()}; +Entry.block.set_color=function(b,a){var c=a.getField("VALUE",a);b.brush||(Entry.setBasicBrush(b),b.brush.stop=!0);b.brush&&(c=Entry.hex2rgb(c),b.brush.rgb=c,b.brush.endStroke(),b.brush.beginStroke("rgba("+c.r+","+c.g+","+c.b+","+b.brush.opacity/100+")"),b.brush.moveTo(b.getX(),-1*b.getY()));return a.callReturn()}; Blockly.Blocks.set_random_color={init:function(){this.setColour(categoryColor);this.appendDummyInput().appendField(Lang.Blocks.BRUSH_set_random_color).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/brush_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.set_random_color=function(a,b){a.brush||(Entry.setBasicBrush(a),a.brush.stop=!0);if(a.brush){var c=Entry.generateRgb();a.brush.rgb=c;a.brush.endStroke();a.brush.beginStroke("rgba("+c.r+","+c.g+","+c.b+","+a.brush.opacity/100+")");a.brush.moveTo(a.getX(),-1*a.getY())}return b.callReturn()}; +Entry.block.set_random_color=function(b,a){b.brush||(Entry.setBasicBrush(b),b.brush.stop=!0);if(b.brush){var c=Entry.generateRgb();b.brush.rgb=c;b.brush.endStroke();b.brush.beginStroke("rgba("+c.r+","+c.g+","+c.b+","+b.brush.opacity/100+")");b.brush.moveTo(b.getX(),-1*b.getY())}return a.callReturn()}; Blockly.Blocks.change_thickness={init:function(){this.setColour(categoryColor);this.appendDummyInput().appendField(Lang.Blocks.BRUSH_change_thickness_1);this.appendValueInput("VALUE").setCheck(["Number","Boolean"]);this.appendDummyInput().appendField(Lang.Blocks.BRUSH_change_thickness_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/brush_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.change_thickness=function(a,b){var c=b.getNumberValue("VALUE",b);a.brush||(Entry.setBasicBrush(a),a.brush.stop=!0);a.brush&&(a.brush.thickness+=c,1>a.brush.thickness&&(a.brush.thickness=1),a.brush.setStrokeStyle(a.brush.thickness),a.brush.moveTo(a.getX(),-1*a.getY()));return b.callReturn()}; +Entry.block.change_thickness=function(b,a){var c=a.getNumberValue("VALUE",a);b.brush||(Entry.setBasicBrush(b),b.brush.stop=!0);b.brush&&(b.brush.thickness+=c,1>b.brush.thickness&&(b.brush.thickness=1),b.brush.setStrokeStyle(b.brush.thickness),b.brush.moveTo(b.getX(),-1*b.getY()));return a.callReturn()}; Blockly.Blocks.set_thickness={init:function(){this.setColour(categoryColor);this.appendDummyInput().appendField(Lang.Blocks.BRUSH_set_thickness_1);this.appendValueInput("VALUE").setCheck(["Number","Boolean"]);this.appendDummyInput().appendField(Lang.Blocks.BRUSH_set_thickness_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/brush_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.set_thickness=function(a,b){var c=b.getNumberValue("VALUE",b);a.brush||(Entry.setBasicBrush(a),a.brush.stop=!0);a.brush&&(a.brush.thickness=c,a.brush.setStrokeStyle(a.brush.thickness),a.brush.moveTo(a.getX(),-1*a.getY()));return b.callReturn()}; +Entry.block.set_thickness=function(b,a){var c=a.getNumberValue("VALUE",a);b.brush||(Entry.setBasicBrush(b),b.brush.stop=!0);b.brush&&(b.brush.thickness=c,b.brush.setStrokeStyle(b.brush.thickness),b.brush.moveTo(b.getX(),-1*b.getY()));return a.callReturn()}; Blockly.Blocks.change_opacity={init:function(){this.setColour(categoryColor);this.appendDummyInput().appendField(Lang.Blocks.BRUSH_change_opacity_1);this.appendValueInput("VALUE").setCheck(["Number","Boolean"]);this.appendDummyInput().appendField(Lang.Blocks.BRUSH_change_opacity_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/brush_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.change_opacity=function(a,b){var c=b.getNumberValue("VALUE",b);a.brush||(Entry.setBasicBrush(a),a.brush.stop=!0);c=Entry.adjustValueWithMaxMin(a.brush.opacity+c,0,100);a.brush&&(a.brush.opacity=c,a.brush.endStroke(),c=a.brush.rgb,a.brush.beginStroke("rgba("+c.r+","+c.g+","+c.b+","+a.brush.opacity/100+")"),a.brush.moveTo(a.getX(),-1*a.getY()));return b.callReturn()}; +Entry.block.change_opacity=function(b,a){var c=a.getNumberValue("VALUE",a);b.brush||(Entry.setBasicBrush(b),b.brush.stop=!0);c=Entry.adjustValueWithMaxMin(b.brush.opacity+c,0,100);b.brush&&(b.brush.opacity=c,b.brush.endStroke(),c=b.brush.rgb,b.brush.beginStroke("rgba("+c.r+","+c.g+","+c.b+","+b.brush.opacity/100+")"),b.brush.moveTo(b.getX(),-1*b.getY()));return a.callReturn()}; Blockly.Blocks.set_opacity={init:function(){this.setColour(categoryColor);this.appendDummyInput().appendField(Lang.Blocks.BRUSH_set_opacity_1);this.appendValueInput("VALUE").setCheck(["Number","Boolean"]);this.appendDummyInput().appendField(Lang.Blocks.BRUSH_set_opacity_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/brush_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.set_opacity=function(a,b){var c=b.getNumberValue("VALUE",b);a.brush||(Entry.setBasicBrush(a),a.brush.stop=!0);a.brush&&(a.brush.opacity=Entry.adjustValueWithMaxMin(c,0,100),a.brush.endStroke(),c=a.brush.rgb,a.brush.beginStroke("rgba("+c.r+","+c.g+","+c.b+","+a.brush.opacity/100+")"),a.brush.moveTo(a.getX(),-1*a.getY()));return b.callReturn()}; +Entry.block.set_opacity=function(b,a){var c=a.getNumberValue("VALUE",a);b.brush||(Entry.setBasicBrush(b),b.brush.stop=!0);b.brush&&(b.brush.opacity=Entry.adjustValueWithMaxMin(c,0,100),b.brush.endStroke(),c=b.brush.rgb,b.brush.beginStroke("rgba("+c.r+","+c.g+","+c.b+","+b.brush.opacity/100+")"),b.brush.moveTo(b.getX(),-1*b.getY()));return a.callReturn()}; Blockly.Blocks.brush_erase_all={init:function(){this.setColour(categoryColor);this.appendDummyInput().appendField(Lang.Blocks.BRUSH_brush_erase_all).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/brush_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.brush_erase_all=function(a,b){var c=a.brush;if(c){var d=c._stroke.style,e=c._strokeStyle.width;c.clear().setStrokeStyle(e).beginStroke(d);c.moveTo(a.getX(),-1*a.getY())}a=a.parent.getStampEntities();a.map(function(b){b.removeClone()});a=null;return b.callReturn()}; -Blockly.Blocks.brush_stamp={init:function(){this.setColour(categoryColor);this.appendDummyInput().appendField(Lang.Blocks.BRUSH_stamp).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/brush_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.brush_stamp=function(a,b){a.parent.addStampEntity(a);return b.callReturn()}; +Entry.block.brush_erase_all=function(b,a){var c=b.brush;if(c){var d=c._stroke.style,e=c._strokeStyle.width;c.clear().setStrokeStyle(e).beginStroke(d);c.moveTo(b.getX(),-1*b.getY())}c=b.parent.getStampEntities();c.map(function(a){a.removeClone()});c=null;return a.callReturn()}; +Blockly.Blocks.brush_stamp={init:function(){this.setColour(categoryColor);this.appendDummyInput().appendField(Lang.Blocks.BRUSH_stamp).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/brush_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.brush_stamp=function(b,a){b.parent.addStampEntity(b);return a.callReturn()}; Blockly.Blocks.change_brush_transparency={init:function(){this.setColour(categoryColor);this.appendDummyInput().appendField(Lang.Blocks.BRUSH_change_brush_transparency_1);this.appendValueInput("VALUE").setCheck(["Number","Boolean"]);this.appendDummyInput().appendField(Lang.Blocks.BRUSH_change_brush_transparency_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/brush_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.change_brush_transparency=function(a,b){var c=b.getNumberValue("VALUE",b);a.brush||(Entry.setBasicBrush(a),a.brush.stop=!0);c=Entry.adjustValueWithMaxMin(a.brush.opacity-c,0,100);a.brush&&(a.brush.opacity=c,a.brush.endStroke(),c=a.brush.rgb,a.brush.beginStroke("rgba("+c.r+","+c.g+","+c.b+","+a.brush.opacity/100+")"),a.brush.moveTo(a.getX(),-1*a.getY()));return b.callReturn()}; +Entry.block.change_brush_transparency=function(b,a){var c=a.getNumberValue("VALUE",a);b.brush||(Entry.setBasicBrush(b),b.brush.stop=!0);c=Entry.adjustValueWithMaxMin(b.brush.opacity-c,0,100);b.brush&&(b.brush.opacity=c,b.brush.endStroke(),c=b.brush.rgb,b.brush.beginStroke("rgba("+c.r+","+c.g+","+c.b+","+b.brush.opacity/100+")"),b.brush.moveTo(b.getX(),-1*b.getY()));return a.callReturn()}; Blockly.Blocks.set_brush_tranparency={init:function(){this.setColour(categoryColor);this.appendDummyInput().appendField(Lang.Blocks.BRUSH_set_brush_transparency_1);this.appendValueInput("VALUE").setCheck(["Number","Boolean"]);this.appendDummyInput().appendField(Lang.Blocks.BRUSH_set_brush_transparency_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/brush_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.set_brush_tranparency=function(a,b){var c=b.getNumberValue("VALUE",b);a.brush||(Entry.setBasicBrush(a),a.brush.stop=!0);a.brush&&(a.brush.opacity=Entry.adjustValueWithMaxMin(c,0,100),a.brush.endStroke(),c=a.brush.rgb,a.brush.beginStroke("rgba("+c.r+","+c.g+","+c.b+","+(1-a.brush.opacity/100)+")"),a.brush.moveTo(a.getX(),-1*a.getY()));return b.callReturn()};var calcArrowColor="#e8b349",calcBlockColor="#FFD974",calcFontColor="#3D3D3D";Blockly.Blocks.number={init:function(){this.setColour(calcBlockColor);this.appendDummyInput().appendField(new Blockly.FieldTextInput(""),"NUM");this.setOutput(!0,"Number");this.setInputsInline(!0)}};Entry.block.number=function(a,b){return b.getField("NUM",b)}; -Blockly.Blocks.angle={init:function(){this.setColour(calcBlockColor);this.appendDummyInput().appendField(new Blockly.FieldAngle("90"),"ANGLE");this.setOutput(!0,"Number");this.setInputsInline(!0)}};Entry.block.angle=function(a,b){return b.getNumberField("ANGLE")};Blockly.Blocks.get_x_coordinate={init:function(){this.setColour(calcBlockColor);this.appendDummyInput().appendField(Lang.Blocks.CALC_get_x_coordinate,calcFontColor);this.setOutput(!0,"Number");this.setInputsInline(!0)}}; -Entry.block.get_x_coordinate=function(a,b){return a.getX()};Blockly.Blocks.get_y_coordinate={init:function(){this.setColour(calcBlockColor);this.appendDummyInput().appendField(Lang.Blocks.CALC_get_y_coordinate,calcFontColor);this.setOutput(!0,"Number");this.setInputsInline(!0)}};Entry.block.get_y_coordinate=function(a,b){return a.getY()}; -Blockly.Blocks.get_angle={init:function(){this.setColour(calcBlockColor);this.appendDummyInput().appendField(Lang.Blocks.CALC_get_angle,calcFontColor);this.setOutput(!0,"Number");this.setInputsInline(!0)}};Entry.block.get_angle=function(a,b){return parseFloat(a.getRotation().toFixed(1))}; +Entry.block.set_brush_tranparency=function(b,a){var c=a.getNumberValue("VALUE",a);b.brush||(Entry.setBasicBrush(b),b.brush.stop=!0);b.brush&&(b.brush.opacity=Entry.adjustValueWithMaxMin(c,0,100),b.brush.endStroke(),c=b.brush.rgb,b.brush.beginStroke("rgba("+c.r+","+c.g+","+c.b+","+(1-b.brush.opacity/100)+")"),b.brush.moveTo(b.getX(),-1*b.getY()));return a.callReturn()};var calcArrowColor="#e8b349",calcBlockColor="#FFD974",calcFontColor="#3D3D3D";Blockly.Blocks.number={init:function(){this.setColour(calcBlockColor);this.appendDummyInput().appendField(new Blockly.FieldTextInput(""),"NUM");this.setOutput(!0,"Number");this.setInputsInline(!0)}};Entry.block.number=function(b,a){return a.getField("NUM",a)}; +Blockly.Blocks.angle={init:function(){this.setColour(calcBlockColor);this.appendDummyInput().appendField(new Blockly.FieldAngle("90"),"ANGLE");this.setOutput(!0,"Number");this.setInputsInline(!0)}};Entry.block.angle=function(b,a){return a.getNumberField("ANGLE")};Blockly.Blocks.get_x_coordinate={init:function(){this.setColour(calcBlockColor);this.appendDummyInput().appendField(Lang.Blocks.CALC_get_x_coordinate,calcFontColor);this.setOutput(!0,"Number");this.setInputsInline(!0)}}; +Entry.block.get_x_coordinate=function(b,a){return b.getX()};Blockly.Blocks.get_y_coordinate={init:function(){this.setColour(calcBlockColor);this.appendDummyInput().appendField(Lang.Blocks.CALC_get_y_coordinate,calcFontColor);this.setOutput(!0,"Number");this.setInputsInline(!0)}};Entry.block.get_y_coordinate=function(b,a){return b.getY()}; +Blockly.Blocks.get_angle={init:function(){this.setColour(calcBlockColor);this.appendDummyInput().appendField(Lang.Blocks.CALC_get_angle,calcFontColor);this.setOutput(!0,"Number");this.setInputsInline(!0)}};Entry.block.get_angle=function(b,a){return parseFloat(b.getRotation().toFixed(1))}; Blockly.Blocks.get_rotation_direction={init:function(){this.setColour(calcBlockColor);this.appendDummyInput().appendField(new Blockly.FieldDropdown([[Lang.Blocks.CALC_rotation_value,"ROTATION"],[Lang.Blocks.CALC_direction_value,"DIRECTION"]],null,!0,calcArrowColor),"OPERATOR");this.appendDummyInput().appendField(" ");this.setOutput(!0,"Number");this.setInputsInline(!0)}}; -Entry.block.get_rotation_direction=function(a,b){return"DIRECTION"==b.getField("OPERATOR",b).toUpperCase()?parseFloat(a.getDirection().toFixed(1)):parseFloat(a.getRotation().toFixed(1))}; +Entry.block.get_rotation_direction=function(b,a){return"DIRECTION"==a.getField("OPERATOR",a).toUpperCase()?parseFloat(b.getDirection().toFixed(1)):parseFloat(b.getRotation().toFixed(1))}; Blockly.Blocks.distance_something={init:function(){this.setColour(calcBlockColor);this.appendDummyInput().appendField(Lang.Blocks.CALC_distance_something_1,calcFontColor).appendField(new Blockly.FieldDropdownDynamic("spritesWithMouse",null,!0,calcArrowColor),"VALUE").appendField(Lang.Blocks.CALC_distance_something_2,calcFontColor);this.setOutput(!0,"Number");this.setInputsInline(!0)}}; -Entry.block.distance_something=function(a,b){b=b.getField("VALUE",b);if("mouse"==b)return b=Entry.stage.mouseCoordinate,Math.sqrt(Math.pow(a.getX()-b.x,2)+Math.pow(a.getY()-b.y,2));b=Entry.container.getEntity(b);return Math.sqrt(Math.pow(a.getX()-b.getX(),2)+Math.pow(a.getY()-b.getY(),2))}; -Blockly.Blocks.coordinate_mouse={init:function(){this.setColour(calcBlockColor);this.appendDummyInput().appendField(Lang.Blocks.CALC_coordinate_mouse_1,calcFontColor).appendField(new Blockly.FieldDropdown([["x","x"],["y","y"]],null,!0,calcArrowColor),"VALUE").appendField(Lang.Blocks.CALC_coordinate_mouse_2,calcFontColor);this.setOutput(!0,"Number");this.setInputsInline(!0)}};Entry.block.coordinate_mouse=function(a,b){return"x"===b.getField("VALUE",b)?Number(Entry.stage.mouseCoordinate.x):Number(Entry.stage.mouseCoordinate.y)}; +Entry.block.distance_something=function(b,a){var c=a.getField("VALUE",a);if("mouse"==c)return c=Entry.stage.mouseCoordinate,Math.sqrt(Math.pow(b.getX()-c.x,2)+Math.pow(b.getY()-c.y,2));c=Entry.container.getEntity(c);return Math.sqrt(Math.pow(b.getX()-c.getX(),2)+Math.pow(b.getY()-c.getY(),2))}; +Blockly.Blocks.coordinate_mouse={init:function(){this.setColour(calcBlockColor);this.appendDummyInput().appendField(Lang.Blocks.CALC_coordinate_mouse_1,calcFontColor).appendField(new Blockly.FieldDropdown([["x","x"],["y","y"]],null,!0,calcArrowColor),"VALUE").appendField(Lang.Blocks.CALC_coordinate_mouse_2,calcFontColor);this.setOutput(!0,"Number");this.setInputsInline(!0)}};Entry.block.coordinate_mouse=function(b,a){return"x"===a.getField("VALUE",a)?+Entry.stage.mouseCoordinate.x:+Entry.stage.mouseCoordinate.y}; Blockly.Blocks.coordinate_object={init:function(){this.setColour(calcBlockColor);this.appendDummyInput().appendField(Lang.Blocks.CALC_coordinate_object_1,calcFontColor).appendField(new Blockly.FieldDropdownDynamic("spritesWithSelf",null,!0,calcArrowColor),"VALUE").appendField(Lang.Blocks.CALC_coordinate_object_2,calcFontColor).appendField(new Blockly.FieldDropdown([[Lang.Blocks.CALC_coordinate_x_value,"x"],[Lang.Blocks.CALC_coordinate_y_value,"y"],[Lang.Blocks.CALC_coordinate_rotation_value,"rotation"], [Lang.Blocks.CALC_coordinate_direction_value,"direction"],[Lang.Blocks.CALC_coordinate_size_value,"size"],[Lang.Blocks.CALC_picture_index,"picture_index"],[Lang.Blocks.CALC_picture_name,"picture_name"]],null,!0,calcArrowColor),"COORDINATE").appendField(Lang.Blocks.CALC_coordinate_object_3,calcFontColor);this.setOutput(!0,"Number");this.setInputsInline(!0)}}; -Entry.block.coordinate_object=function(a,b){var c=b.getField("VALUE",b);a="self"==c?a:Entry.container.getEntity(c);switch(b.getField("COORDINATE",b)){case "x":return a.getX();case "y":return a.getY();case "rotation":return a.getRotation();case "direction":return a.getDirection();case "picture_index":return b=a.parent,b=b.pictures,b.indexOf(a.picture)+1;case "size":return Number(a.getSize().toFixed(1));case "picture_name":return b=a.parent,b=b.pictures,b[b.indexOf(a.picture)].name}}; +Entry.block.coordinate_object=function(b,a){var c=a.getField("VALUE",a),c="self"==c?b:Entry.container.getEntity(c);switch(a.getField("COORDINATE",a)){case "x":return c.getX();case "y":return c.getY();case "rotation":return c.getRotation();case "direction":return c.getDirection();case "picture_index":var d=c.parent,d=d.pictures;return d.indexOf(c.picture)+1;case "size":return+c.getSize().toFixed(1);case "picture_name":return d=c.parent,d=d.pictures,d[d.indexOf(c.picture)].name}}; Blockly.Blocks.calc_basic={init:function(){this.setColour(calcBlockColor);this.appendValueInput("LEFTHAND").setCheck(["String","Number"]);this.appendDummyInput("VALUE").appendField(new Blockly.FieldDropdown([["+","PLUS"],["-","MINUS"],["x","MULTI"],["/","DIVIDE"]],null,!1),"OPERATOR");this.appendValueInput("RIGHTHAND").setCheck(["Number","String"]);this.setOutput(!0,"Number");this.setInputsInline(!0)}}; -Entry.block.calc_basic=function(a,b){a=b.getField("OPERATOR",b);var c=b.getNumberValue("LEFTHAND",b);b=b.getNumberValue("RIGHTHAND",b);return"PLUS"==a?c+b:"MINUS"==a?c-b:"MULTI"==a?c*b:c/b};Blockly.Blocks.calc_plus={init:function(){this.setColour(calcBlockColor);this.appendValueInput("LEFTHAND").setCheck(["Number","String"]);this.appendDummyInput().appendField("+",calcFontColor);this.appendValueInput("RIGHTHAND").setCheck(["Number","String"]);this.setOutput(!0,"Number");this.setInputsInline(!0)}}; -Entry.block.calc_plus=function(a,b){a=b.getNumberValue("LEFTHAND",b);b=b.getNumberValue("RIGHTHAND",b);return a+b};Blockly.Blocks.calc_minus={init:function(){this.setColour(calcBlockColor);this.appendValueInput("LEFTHAND").setCheck(["Number","String"]);this.appendDummyInput().appendField("-",calcFontColor);this.appendValueInput("RIGHTHAND").setCheck(["Number","String"]);this.setOutput(!0,"Number");this.setInputsInline(!0)}}; -Entry.block.calc_minus=function(a,b){a=b.getNumberValue("LEFTHAND",b);b=b.getNumberValue("RIGHTHAND",b);return a-b};Blockly.Blocks.calc_times={init:function(){this.setColour(calcBlockColor);this.appendValueInput("LEFTHAND").setCheck(["Number","String"]);this.appendDummyInput().appendField("x",calcFontColor);this.appendValueInput("RIGHTHAND").setCheck(["Number","String"]);this.setOutput(!0,"Number");this.setInputsInline(!0)}}; -Entry.block.calc_times=function(a,b){a=b.getNumberValue("LEFTHAND",b);b=b.getNumberValue("RIGHTHAND",b);return a*b};Blockly.Blocks.calc_divide={init:function(){this.setColour(calcBlockColor);this.appendValueInput("LEFTHAND").setCheck(["Number","String"]);this.appendDummyInput().appendField("/",calcFontColor);this.appendValueInput("RIGHTHAND").setCheck(["Number","String"]);this.setOutput(!0,"Number");this.setInputsInline(!0)}}; -Entry.block.calc_divide=function(a,b){a=b.getNumberValue("LEFTHAND",b);b=b.getNumberValue("RIGHTHAND",b);return a/b}; +Entry.block.calc_basic=function(b,a){var c=a.getField("OPERATOR",a),d=a.getNumberValue("LEFTHAND",a),e=a.getNumberValue("RIGHTHAND",a);return"PLUS"==c?d+e:"MINUS"==c?d-e:"MULTI"==c?d*e:d/e};Blockly.Blocks.calc_plus={init:function(){this.setColour(calcBlockColor);this.appendValueInput("LEFTHAND").setCheck(["Number","String"]);this.appendDummyInput().appendField("+",calcFontColor);this.appendValueInput("RIGHTHAND").setCheck(["Number","String"]);this.setOutput(!0,"Number");this.setInputsInline(!0)}}; +Entry.block.calc_plus=function(b,a){var c=a.getNumberValue("LEFTHAND",a),d=a.getNumberValue("RIGHTHAND",a);return c+d};Blockly.Blocks.calc_minus={init:function(){this.setColour(calcBlockColor);this.appendValueInput("LEFTHAND").setCheck(["Number","String"]);this.appendDummyInput().appendField("-",calcFontColor);this.appendValueInput("RIGHTHAND").setCheck(["Number","String"]);this.setOutput(!0,"Number");this.setInputsInline(!0)}}; +Entry.block.calc_minus=function(b,a){var c=a.getNumberValue("LEFTHAND",a),d=a.getNumberValue("RIGHTHAND",a);return c-d};Blockly.Blocks.calc_times={init:function(){this.setColour(calcBlockColor);this.appendValueInput("LEFTHAND").setCheck(["Number","String"]);this.appendDummyInput().appendField("x",calcFontColor);this.appendValueInput("RIGHTHAND").setCheck(["Number","String"]);this.setOutput(!0,"Number");this.setInputsInline(!0)}}; +Entry.block.calc_times=function(b,a){var c=a.getNumberValue("LEFTHAND",a),d=a.getNumberValue("RIGHTHAND",a);return c*d};Blockly.Blocks.calc_divide={init:function(){this.setColour(calcBlockColor);this.appendValueInput("LEFTHAND").setCheck(["Number","String"]);this.appendDummyInput().appendField("/",calcFontColor);this.appendValueInput("RIGHTHAND").setCheck(["Number","String"]);this.setOutput(!0,"Number");this.setInputsInline(!0)}}; +Entry.block.calc_divide=function(b,a){var c=a.getNumberValue("LEFTHAND",a),d=a.getNumberValue("RIGHTHAND",a);return c/d}; Blockly.Blocks.calc_mod={init:function(){this.setColour(calcBlockColor);this.appendDummyInput().appendField(Lang.Blocks.CALC_calc_mod_1,calcFontColor);this.appendValueInput("LEFTHAND").setCheck(["Number","String"]);this.appendDummyInput("VALUE").appendField(Lang.Blocks.CALC_calc_mod_2,calcFontColor);this.appendValueInput("RIGHTHAND").setCheck(["Number","String"]);this.setOutput(!0,"Number");this.appendDummyInput("VALUE").appendField(Lang.Blocks.CALC_calc_mod_3,calcFontColor);this.setInputsInline(!0)}}; -Entry.block.calc_mod=function(a,b){a=b.getNumberValue("LEFTHAND",b);b=b.getNumberValue("RIGHTHAND",b);return a%b}; +Entry.block.calc_mod=function(b,a){var c=a.getNumberValue("LEFTHAND",a),d=a.getNumberValue("RIGHTHAND",a);return c%d}; Blockly.Blocks.calc_share={init:function(){this.setColour(calcBlockColor);this.appendDummyInput().appendField(Lang.Blocks.CALC_calc_share_1,calcFontColor);this.appendValueInput("LEFTHAND").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.CALC_calc_share_2,calcFontColor);this.appendValueInput("RIGHTHAND").setCheck(["Number","String"]);this.setOutput(!0,"Number");this.appendDummyInput("VALUE").appendField(Lang.Blocks.CALC_calc_share_3,calcFontColor);this.setInputsInline(!0)}}; -Entry.block.calc_share=function(a,b){a=b.getNumberValue("LEFTHAND",b);b=b.getNumberValue("RIGHTHAND",b);return Math.floor(a/b)}; +Entry.block.calc_share=function(b,a){var c=a.getNumberValue("LEFTHAND",a),d=a.getNumberValue("RIGHTHAND",a);return Math.floor(c/d)}; Blockly.Blocks.calc_operation={init:function(){this.setColour(calcBlockColor);this.appendDummyInput("VALUE").appendField(Lang.Blocks.CALC_calc_operation_of_1,calcFontColor);this.appendValueInput("LEFTHAND").setCheck(["Number","String"]);this.appendDummyInput("VALUE").appendField(Lang.Blocks.CALC_calc_operation_of_2,calcFontColor);this.appendDummyInput("VALUE").appendField(new Blockly.FieldDropdown([[Lang.Blocks.CALC_calc_operation_square,"square"],[Lang.Blocks.CALC_calc_operation_root,"root"],[Lang.Blocks.CALC_calc_operation_sin, "sin"],[Lang.Blocks.CALC_calc_operation_cos,"cos"],[Lang.Blocks.CALC_calc_operation_tan,"tan"],[Lang.Blocks.CALC_calc_operation_asin,"asin_radian"],[Lang.Blocks.CALC_calc_operation_acos,"acos_radian"],[Lang.Blocks.CALC_calc_operation_atan,"atan_radian"],[Lang.Blocks.CALC_calc_operation_log,"log"],[Lang.Blocks.CALC_calc_operation_ln,"ln"],[Lang.Blocks.CALC_calc_operation_unnatural,"unnatural"],[Lang.Blocks.CALC_calc_operation_floor,"floor"],[Lang.Blocks.CALC_calc_operation_ceil,"ceil"],[Lang.Blocks.CALC_calc_operation_round, "round"],[Lang.Blocks.CALC_calc_operation_factorial,"factorial"],[Lang.Blocks.CALC_calc_operation_abs,"abs"]],null,!0,calcArrowColor),"VALUE");this.setOutput(!0,"Number");this.appendDummyInput().appendField(" ");this.setInputsInline(!0)}}; -Entry.block.calc_operation=function(a,b){a=b.getNumberValue("LEFTHAND",b);b=b.getField("VALUE",b);if(-1<["asin_radian","acos_radian"].indexOf(b)&&(1a))throw Error("x range exceeded");b.indexOf("_")&&(b=b.split("_")[0]);-1<["sin","cos","tan"].indexOf(b)&&(a=Entry.toRadian(a));switch(b){case "square":b=a*a;break;case "factorial":b=Entry.factorial(a);break;case "root":b=Math.sqrt(a);break;case "log":b=Math.log(a)/Math.LN10;break;case "ln":b=Math.log(a);break;case "asin":case "acos":case "atan":b= -Entry.toDegrees(Math[b](a));break;case "unnatural":b=a-Math.floor(a);0>a&&(b=1-b);break;default:b=Math[b](a)}return Math.round(1E3*b)/1E3}; +Entry.block.calc_operation=function(b,a){var c=a.getNumberValue("LEFTHAND",a),d=a.getField("VALUE",a);if(-1<["asin_radian","acos_radian"].indexOf(d)&&(1c))throw Error("x range exceeded");d.indexOf("_")&&(d=d.split("_")[0]);-1<["sin","cos","tan"].indexOf(d)&&(c=Entry.toRadian(c));var e=0;switch(d){case "square":e=c*c;break;case "factorial":e=Entry.factorial(c);break;case "root":e=Math.sqrt(c);break;case "log":e=Math.log(c)/Math.LN10;break;case "ln":e=Math.log(c);break;case "asin":case "acos":case "atan":e= +Entry.toDegrees(Math[d](c));break;case "unnatural":e=c-Math.floor(c);0>c&&(e=1-e);break;default:e=Math[d](c)}return Math.round(1E3*e)/1E3}; Blockly.Blocks.calc_rand={init:function(){this.setColour(calcBlockColor);this.appendDummyInput().appendField(Lang.Blocks.CALC_calc_rand_1,calcFontColor);this.appendValueInput("LEFTHAND").setCheck(["Number","String"]);this.appendDummyInput("VALUE").appendField(Lang.Blocks.CALC_calc_rand_2,calcFontColor);this.appendValueInput("RIGHTHAND").setCheck(["Number","String"]);this.setOutput(!0,"Number");this.appendDummyInput("VALUE").appendField(Lang.Blocks.CALC_calc_rand_3,calcFontColor);this.setInputsInline(!0)}}; -Entry.block.calc_rand=function(a,b){a=b.getStringValue("LEFTHAND",b);b=b.getStringValue("RIGHTHAND",b);var c=Math.min(a,b),d=Math.max(a,b);a=Entry.isFloat(a);return Entry.isFloat(b)||a?(Math.random()*(d-c)+c).toFixed(2):Math.floor(Math.random()*(d-c+1)+c)}; +Entry.block.calc_rand=function(b,a){var c=a.getStringValue("LEFTHAND",a),d=a.getStringValue("RIGHTHAND",a),e=Math.min(c,d),f=Math.max(c,d),c=Entry.isFloat(c);return Entry.isFloat(d)||c?(Math.random()*(f-e)+e).toFixed(2):Math.floor(Math.random()*(f-e+1)+e)}; Blockly.Blocks.get_date={init:function(){this.setColour(calcBlockColor);this.appendDummyInput().appendField(Lang.Blocks.CALC_get_date_1,calcFontColor).appendField(new Blockly.FieldDropdown([[Lang.Blocks.CALC_get_date_year,"YEAR"],[Lang.Blocks.CALC_get_date_month,"MONTH"],[Lang.Blocks.CALC_get_date_day,"DAY"],[Lang.Blocks.CALC_get_date_hour,"HOUR"],[Lang.Blocks.CALC_get_date_minute,"MINUTE"],[Lang.Blocks.CALC_get_date_second,"SECOND"]],null,!0,calcArrowColor),"VALUE");this.appendDummyInput().appendField(" ").appendField(Lang.Blocks.CALC_get_date_2, -calcFontColor);this.setOutput(!0,"Number");this.setInputsInline(!0)}};Entry.block.get_date=function(a,b){a=b.getField("VALUE",b);b=new Date;return"YEAR"==a?b.getFullYear():"MONTH"==a?b.getMonth()+1:"DAY"==a?b.getDate():"HOUR"==a?b.getHours():"MINUTE"==a?b.getMinutes():b.getSeconds()}; +calcFontColor);this.setOutput(!0,"Number");this.setInputsInline(!0)}};Entry.block.get_date=function(b,a){var c=a.getField("VALUE",a),d=new Date;return"YEAR"==c?d.getFullYear():"MONTH"==c?d.getMonth()+1:"DAY"==c?d.getDate():"HOUR"==c?d.getHours():"MINUTE"==c?d.getMinutes():d.getSeconds()}; Blockly.Blocks.get_sound_duration={init:function(){this.setColour(calcBlockColor);this.appendDummyInput().appendField(Lang.Blocks.CALC_get_sound_duration_1,calcFontColor);this.appendDummyInput().appendField(new Blockly.FieldDropdownDynamic("sounds",null,!0,calcArrowColor),"VALUE");this.appendDummyInput().appendField(Lang.Blocks.CALC_get_sound_duration_2,calcFontColor);this.setOutput(!0,"Number");this.setInputsInline(!0)}}; -Entry.block.get_sound_duration=function(a,b){b=b.getField("VALUE",b);a=a.parent.sounds;for(var c=0;cb||b>a.length-1)throw Error();return a[b]}; -Blockly.Blocks.length_of_string={init:function(){this.setColour(calcBlockColor);this.appendDummyInput().appendField(Lang.Blocks.CALC_length_of_string_1,calcFontColor);this.appendValueInput("STRING").setCheck(["Number","String"]);this.appendDummyInput("VALUE").appendField(Lang.Blocks.CALC_length_of_string_2,calcFontColor);this.setOutput(!0,"Number");this.setInputsInline(!0)}};Entry.block.length_of_string=function(a,b){return b.getStringValue("STRING",b).length}; +Entry.block.char_at=function(b,a){var c=a.getStringValue("LEFTHAND",a),d=a.getNumberValue("RIGHTHAND",a)-1;if(0>d||d>c.length-1)throw Error();return c[d]}; +Blockly.Blocks.length_of_string={init:function(){this.setColour(calcBlockColor);this.appendDummyInput().appendField(Lang.Blocks.CALC_length_of_string_1,calcFontColor);this.appendValueInput("STRING").setCheck(["Number","String"]);this.appendDummyInput("VALUE").appendField(Lang.Blocks.CALC_length_of_string_2,calcFontColor);this.setOutput(!0,"Number");this.setInputsInline(!0)}};Entry.block.length_of_string=function(b,a){return a.getStringValue("STRING",a).length}; Blockly.Blocks.substring={init:function(){this.setColour(calcBlockColor);this.appendDummyInput().appendField(Lang.Blocks.CALC_substring_1,calcFontColor);this.appendValueInput("STRING").setCheck(["Number","String"]);this.appendDummyInput("VALUE").appendField(Lang.Blocks.CALC_substring_2,calcFontColor);this.appendValueInput("START").setCheck(["Number","String"]);this.appendDummyInput("VALUE").appendField(Lang.Blocks.CALC_substring_3,calcFontColor);this.appendValueInput("END").setCheck(["Number","String"]); -this.appendDummyInput("VALUE").appendField(Lang.Blocks.CALC_substring_4,calcFontColor);this.setOutput(!0,"String");this.setInputsInline(!0)}};Entry.block.substring=function(a,b){a=b.getStringValue("STRING",b);var c=b.getNumberValue("START",b)-1;b=b.getNumberValue("END",b)-1;var d=a.length-1;if(0>c||0>b||c>d||b>d)throw Error();return a.substring(Math.min(c,b),Math.max(c,b)+1)}; +this.appendDummyInput("VALUE").appendField(Lang.Blocks.CALC_substring_4,calcFontColor);this.setOutput(!0,"String");this.setInputsInline(!0)}};Entry.block.substring=function(b,a){var c=a.getStringValue("STRING",a),d=a.getNumberValue("START",a)-1,e=a.getNumberValue("END",a)-1,f=c.length-1;if(0>d||0>e||d>f||e>f)throw Error();return c.substring(Math.min(d,e),Math.max(d,e)+1)}; Blockly.Blocks.replace_string={init:function(){this.setColour(calcBlockColor);this.appendDummyInput().appendField(Lang.Blocks.CALC_replace_string_1,calcFontColor);this.appendValueInput("STRING").setCheck(["Number","String"]);this.appendDummyInput("VALUE").appendField(Lang.Blocks.CALC_replace_string_2,calcFontColor);this.appendValueInput("OLD_WORD").setCheck(["Number","String"]);this.appendDummyInput("VALUE").appendField(Lang.Blocks.CALC_replace_string_3,calcFontColor);this.appendValueInput("NEW_WORD").setCheck(["Number", -"String"]);this.appendDummyInput("VALUE").appendField(Lang.Blocks.CALC_replace_string_4,calcFontColor);this.setOutput(!0,"String");this.setInputsInline(!0)}};Entry.block.replace_string=function(a,b){return b.getStringValue("STRING",b).replace(new RegExp(b.getStringValue("OLD_WORD",b),"gm"),b.getStringValue("NEW_WORD",b))}; +"String"]);this.appendDummyInput("VALUE").appendField(Lang.Blocks.CALC_replace_string_4,calcFontColor);this.setOutput(!0,"String");this.setInputsInline(!0)}};Entry.block.replace_string=function(b,a){return a.getStringValue("STRING",a).replace(new RegExp(a.getStringValue("OLD_WORD",a),"gm"),a.getStringValue("NEW_WORD",a))}; Blockly.Blocks.change_string_case={init:function(){this.setColour(calcBlockColor);this.appendDummyInput().appendField(Lang.Blocks.CALC_change_string_case_1,calcFontColor);this.appendValueInput("STRING").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.CALC_change_string_case_2,calcFontColor);this.appendDummyInput().appendField(new Blockly.FieldDropdown([[Lang.Blocks.CALC_change_string_case_sub_1,"toUpperCase"],[Lang.Blocks.CALC_change_string_case_sub_2,"toLowerCase"]], -null,!0,calcArrowColor),"CASE");this.appendDummyInput().appendField(Lang.Blocks.CALC_change_string_case_3,calcFontColor);this.setOutput(!0,"String");this.setInputsInline(!0)}};Entry.block.change_string_case=function(a,b){return b.getStringValue("STRING",b)[b.getField("CASE",b)]()}; +null,!0,calcArrowColor),"CASE");this.appendDummyInput().appendField(Lang.Blocks.CALC_change_string_case_3,calcFontColor);this.setOutput(!0,"String");this.setInputsInline(!0)}};Entry.block.change_string_case=function(b,a){return a.getStringValue("STRING",a)[a.getField("CASE",a)]()}; Blockly.Blocks.index_of_string={init:function(){this.setColour(calcBlockColor);this.appendDummyInput().appendField(Lang.Blocks.CALC_index_of_string_1,calcFontColor);this.appendValueInput("LEFTHAND").setCheck(["Number","String"]);this.appendDummyInput("VALUE").appendField(Lang.Blocks.CALC_index_of_string_2,calcFontColor);this.appendValueInput("RIGHTHAND").setCheck(["Number","String"]);this.setOutput(!0,"Number");this.appendDummyInput("VALUE").appendField(Lang.Blocks.CALC_index_of_string_3,calcFontColor); -this.setInputsInline(!0)}};Entry.block.index_of_string=function(a,b){a=b.getStringValue("LEFTHAND",b);b=b.getStringValue("RIGHTHAND",b);b=a.indexOf(b);return-1a)throw Error(Lang.Blocks.FLOW_repeat_basic_errorMsg);b.iterCount=Math.floor(a)}if(0==b.iterCount||0>b.iterCount)return delete b.isLooped,delete b.iterCount,b.callReturn();b.iterCount--;return b.getStatement("DO",b)}; -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(a,b){b.isLooped=!0;return b.getStatement("DO")}; -Blockly.Blocks.stop_repeat={init:function(){this.setColour("#498deb");this.appendDummyInput().appendField(Lang.Blocks.FLOW_stop_repeat).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/flow_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.stop_repeat=function(a,b){return this.executor.break()}; +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")}; +Blockly.Blocks.stop_repeat={init:function(){this.setColour("#498deb");this.appendDummyInput().appendField(Lang.Blocks.FLOW_stop_repeat).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/flow_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.stop_repeat=function(b,a){return this.executor.break()}; Blockly.Blocks.wait_until_true={init:function(){this.setColour("#498deb");this.appendDummyInput().appendField(Lang.Blocks.FLOW_wait_until_true_1);this.appendValueInput("BOOL").setCheck("Boolean");this.appendDummyInput().appendField(Lang.Blocks.FLOW_wait_until_true_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/flow_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.wait_until_true=function(a,b){return b.getBooleanValue("BOOL",b)?b.callReturn():b}; +Entry.block.wait_until_true=function(b,a){return a.getBooleanValue("BOOL",a)?a.callReturn():a}; Blockly.Blocks._if={init:function(){this.setColour("#498deb");this.appendDummyInput().appendField(Lang.Blocks.FLOW__if_1);this.appendValueInput("BOOL").setCheck("Boolean");this.appendDummyInput().appendField(Lang.Blocks.FLOW__if_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/flow_03.png","*"));this.appendStatementInput("STACK");this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block._if=function(a,b){return b.isLooped?(delete b.isLooped,b.callReturn()):b.getBooleanValue("BOOL",b)?(b.isLooped=!0,b.getStatement("STACK",b)):b.callReturn()}; +Entry.block._if=function(b,a){return a.isLooped?(delete a.isLooped,a.callReturn()):a.getBooleanValue("BOOL",a)?(a.isLooped=!0,a.getStatement("STACK",a)):a.callReturn()}; Blockly.Blocks.if_else={init:function(){this.setColour("#498deb");this.appendDummyInput().appendField(Lang.Blocks.FLOW_if_else_1);this.appendValueInput("BOOL").setCheck("Boolean");this.appendDummyInput().appendField(Lang.Blocks.FLOW_if_else_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/flow_03.png","*"));this.appendStatementInput("STACK_IF");this.appendDummyInput().appendField(Lang.Blocks.FLOW_if_else_3);this.appendStatementInput("STACK_ELSE");this.setInputsInline(!0);this.setPreviousStatement(!0); -this.setNextStatement(!0)}};Entry.block.if_else=function(a,b){if(b.isLooped)return delete b.isLooped,b.callReturn();a=b.getBooleanValue("BOOL",b);b.isLooped=!0;return a?b.getStatement("STACK_IF",b):b.getStatement("STACK_ELSE",b)}; +this.setNextStatement(!0)}};Entry.block.if_else=function(b,a){if(a.isLooped)return delete a.isLooped,a.callReturn();var c=a.getBooleanValue("BOOL",a);a.isLooped=!0;return c?a.getStatement("STACK_IF",a):a.getStatement("STACK_ELSE",a)}; Blockly.Blocks.create_clone={init:function(){this.setColour("#498deb");this.appendDummyInput().appendField(Lang.Blocks.FLOW_create_clone_1);this.appendDummyInput().appendField(new Blockly.FieldDropdownDynamic("clone"),"VALUE");this.appendDummyInput().appendField(Lang.Blocks.FLOW_create_clone_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/flow_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.create_clone=function(a,b){var c=b.getField("VALUE",b);b=b.callReturn();"self"==c?a.parent.addCloneEntity(a.parent,a,null):Entry.container.getObject(c).addCloneEntity(a.parent,null,null);return b};Blockly.Blocks.delete_clone={init:function(){this.setColour("#498deb");this.appendDummyInput().appendField(Lang.Blocks.FLOW_delete_clone).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/flow_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0)}}; -Entry.block.delete_clone=function(a,b){if(!a.isClone)return b.callReturn();a.removeClone()};Blockly.Blocks.when_clone_start={init:function(){this.setColour("#498deb");this.appendDummyInput().appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/start_icon_clone.png","*","start")).appendField(Lang.Blocks.FLOW_when_clone_start);this.setInputsInline(!0);this.setNextStatement(!0)}};Entry.block.when_clone_start=function(a,b){return b.callReturn()}; -Blockly.Blocks.stop_run={init:function(){this.setColour("#498deb");this.appendDummyInput().appendField(Lang.Blocks.FLOW_stop_run).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/flow_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.stop_run=function(a,b){return Entry.engine.toggleStop()}; +Entry.block.create_clone=function(b,a){var c=a.getField("VALUE",a),d=a.callReturn();"self"==c?b.parent.addCloneEntity(b.parent,b,null):Entry.container.getObject(c).addCloneEntity(b.parent,null,null);return d};Blockly.Blocks.delete_clone={init:function(){this.setColour("#498deb");this.appendDummyInput().appendField(Lang.Blocks.FLOW_delete_clone).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/flow_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0)}}; +Entry.block.delete_clone=function(b,a){if(!b.isClone)return a.callReturn();b.removeClone()};Blockly.Blocks.when_clone_start={init:function(){this.setColour("#498deb");this.appendDummyInput().appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/start_icon_clone.png","*","start")).appendField(Lang.Blocks.FLOW_when_clone_start);this.setInputsInline(!0);this.setNextStatement(!0)}};Entry.block.when_clone_start=function(b,a){return a.callReturn()}; +Blockly.Blocks.stop_run={init:function(){this.setColour("#498deb");this.appendDummyInput().appendField(Lang.Blocks.FLOW_stop_run).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/flow_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.stop_run=function(b,a){return Entry.engine.toggleStop()}; Blockly.Blocks.repeat_while_true={init:function(){this.setColour("#498deb");"ko"==Lang.type?(this.appendDummyInput().appendField(Lang.Blocks.FLOW_repeat_while_true_1),this.appendValueInput("BOOL").setCheck("Boolean"),this.appendDummyInput().appendField(new Blockly.FieldDropdown([[Lang.Blocks.FLOW_repeat_while_true_until,"until"],[Lang.Blocks.FLOW_repeat_while_true_while,"while"]]),"OPTION").appendField(Lang.Blocks.FLOW_repeat_while_true_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/flow_03.png", "*"))):(this.appendDummyInput().appendField(Lang.Blocks.FLOW_repeat_while_true_1),this.appendDummyInput().appendField(new Blockly.FieldDropdown([[Lang.Blocks.FLOW_repeat_while_true_until,"until"],[Lang.Blocks.FLOW_repeat_while_true_while,"while"]]),"OPTION"),this.appendValueInput("BOOL").setCheck("Boolean"),this.appendDummyInput().appendField(Lang.Blocks.FLOW_repeat_while_true_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_while_true=function(a,b){a=b.getBooleanValue("BOOL",b);"until"==b.getField("OPTION",b)&&(a=!a);return(b.isLooped=a)?b.getStatement("DO",b):b.callReturn()}; +this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.repeat_while_true=function(b,a){var c=a.getBooleanValue("BOOL",a);"until"==a.getField("OPTION",a)&&(c=!c);return(a.isLooped=c)?a.getStatement("DO",a):a.callReturn()}; Blockly.Blocks.stop_object={init:function(){this.setColour("#498deb");this.appendDummyInput().appendField(Lang.Blocks.FLOW_stop_object_1);this.appendDummyInput().appendField(new Blockly.FieldDropdown([[Lang.Blocks.FLOW_stop_object_all,"all"],[Lang.Blocks.FLOW_stop_object_this_object,"thisOnly"],[Lang.Blocks.FLOW_stop_object_this_thread,"thisThread"],[Lang.Blocks.FLOW_stop_object_other_thread,"otherThread"]]),"TARGET");this.appendDummyInput().appendField(Lang.Blocks.FLOW_stop_object_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+ -"block_icon/flow_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.stop_object=function(a,b){b=b.getField("TARGET",b);var c=Entry.container;switch(b){case "all":return c.clearRunningState(),this.die();case "thisOnly":return a.parent.script.clearExecutorsByEntity(a),this.die();case "thisThread":return this.die();case "otherThread":a.parent.script.clearExecutors(),a.parent.script.addExecutor(this.executor)}}; -Blockly.Blocks.restart_project={init:function(){this.setColour("#498deb");this.appendDummyInput().appendField(Lang.Blocks.FLOW_restart).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/flow_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0)}};Entry.block.restart_project=function(a,b){Entry.engine.toggleStop();Entry.engine.toggleRun()}; -Blockly.Blocks.remove_all_clones={init:function(){this.setColour("#498deb");this.appendDummyInput().appendField(Lang.Blocks.FLOW_delete_clone_all).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/flow_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.remove_all_clones=function(a,b){a=a.parent.getClonedEntities();a.map(function(b){b.removeClone()});a=null;return b.callReturn()};Entry.block.functionAddButton={skeleton:"basic_button",color:"#eee",isNotFor:["functionInit"],template:"%1",params:[{type:"Text",text:"\ud568\uc218 \ucd94\uac00",color:"#333",align:"center"}],events:{mousedown:[function(){Entry.variableContainer.createFunction()}]}}; +"block_icon/flow_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.stop_object=function(b,a){var c=a.getField("TARGET",a),d=Entry.container;switch(c){case "all":return d.clearRunningState(),this.die();case "thisOnly":return b.parent.script.clearExecutorsByEntity(b),this.die();case "thisThread":return this.die();case "otherThread":b.parent.script.clearExecutors(),b.parent.script.addExecutor(this.executor)}}; +Blockly.Blocks.restart_project={init:function(){this.setColour("#498deb");this.appendDummyInput().appendField(Lang.Blocks.FLOW_restart).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/flow_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0)}};Entry.block.restart_project=function(b,a){Entry.engine.toggleStop();Entry.engine.toggleRun()}; +Blockly.Blocks.remove_all_clones={init:function(){this.setColour("#498deb");this.appendDummyInput().appendField(Lang.Blocks.FLOW_delete_clone_all).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/flow_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.remove_all_clones=function(b,a){var c=b.parent.getClonedEntities();c.map(function(a){a.removeClone()});c=null;return a.callReturn()};Entry.block.functionAddButton={skeleton:"basic_button",color:"#eee",isNotFor:["functionInit"],template:"%1",params:[{type:"Text",text:"\ud568\uc218 \ucd94\uac00",color:"#333",align:"center"}],events:{mousedown:[function(){Entry.variableContainer.createFunction()}]}}; Blockly.Blocks.function_field_label={init:function(){this.setColour("#f9c535");this.appendDummyInput().appendField(new Blockly.FieldTextInput(Lang.Blocks.FUNCTION_explanation_1),"NAME");this.appendValueInput("NEXT").setCheck(["Param"]);this.setOutput(!0,"Param");this.setInputsInline(!0)}};Entry.block.function_field_label={skeleton:"basic_param",isNotFor:["functionEdit"],color:"#f9c535",template:"%1%2",params:[{type:"TextInput",value:"\ud568\uc218"},{type:"Output",accept:"paramMagnet"}]}; Blockly.Blocks.function_field_string={init:function(){this.setColour("#FFD974");this.appendValueInput("PARAM").setCheck(["String"]);this.appendValueInput("NEXT").setCheck(["Param"]);this.setOutput(!0,"Param");this.setInputsInline(!0)}};Entry.block.function_field_string={skeleton:"basic_param",isNotFor:["functionEdit"],color:"#ffd974",template:"%1%2",params:[{type:"Block",accept:"stringMagnet",restore:!0},{type:"Output",accept:"paramMagnet"}]}; Blockly.Blocks.function_field_boolean={init:function(){this.setColour("#AEB8FF");this.appendValueInput("PARAM").setCheck(["Boolean"]);this.appendValueInput("NEXT").setCheck(["Param"]);this.setOutput(!0,"Param");this.setInputsInline(!0)}};Entry.block.function_field_boolean={skeleton:"basic_param",isNotFor:["functionEdit"],color:"#aeb8ff",template:"%1%2",params:[{type:"Block",accept:"booleanMagnet",restore:!0},{type:"Output",accept:"paramMagnet"}]}; -Blockly.Blocks.function_param_string={init:function(){this.setEditable(!1);this.setColour("#FFD974");this.setOutput(!0,["String","Number"]);this.setInputsInline(!0)},domToMutation:function(a){a.getElementsByTagName("field");this.hashId=a.getAttribute("hashid");(a=Entry.Func.targetFunc.stringHash[this.hashId])||(a="");this.appendDummyInput().appendField(new Blockly.FieldTextInput(Lang.Blocks.FUNCTION_character_variable+a),"")},mutationToDom:function(){var a=document.createElement("mutation");a.setAttribute("hashid", -this.hashId);return a}};Entry.block.function_param_string=function(a,b,c){return b.register[b.hashId].run()};Entry.block.function_param_string={skeleton:"basic_string_field",color:"#ffd974",template:"\ubb38\uc790/\uc22b\uc790\uac12",func:function(){return this.executor.register.params[this.executor.register.paramMap[this.block.type]]}}; -Blockly.Blocks.function_param_boolean={init:function(){this.setEditable(!1);this.setColour("#AEB8FF");this.setOutput(!0,"Boolean");this.setInputsInline(!0)},domToMutation:function(a){a.getElementsByTagName("field");this.hashId=a.getAttribute("hashid");(a=Entry.Func.targetFunc.booleanHash[this.hashId])||(a="");this.appendDummyInput().appendField(new Blockly.FieldTextInput(Lang.Blocks.FUNCTION_logical_variable+a),"")},mutationToDom:function(){var a=document.createElement("mutation");a.setAttribute("hashid", -this.hashId);return a}};Entry.block.function_param_boolean=function(a,b,c){return b.register[b.hashId].run()};Entry.block.function_param_boolean={skeleton:"basic_boolean_field",color:"#aeb8ff",template:"\ud310\ub2e8\uac12",func:function(){return this.executor.register.params[this.executor.register.paramMap[this.block.type]]}}; -Blockly.Blocks.function_create={init:function(){this.appendDummyInput().appendField(Lang.Blocks.FUNCTION_define);this.setColour("#cc7337");this.appendValueInput("FIELD").setCheck(["Param"]);this.appendDummyInput().appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/function_03.png","*"));this.setInputsInline(!0);this.setNextStatement(!0)}};Entry.block.function_create=function(a,b){return b.callReturn()}; +Blockly.Blocks.function_param_string={init:function(){this.setEditable(!1);this.setColour("#FFD974");this.setOutput(!0,["String","Number"]);this.setInputsInline(!0)},domToMutation:function(b){b.getElementsByTagName("field");this.hashId=b.getAttribute("hashid");(b=Entry.Func.targetFunc.stringHash[this.hashId])||(b="");this.appendDummyInput().appendField(new Blockly.FieldTextInput(Lang.Blocks.FUNCTION_character_variable+b),"")},mutationToDom:function(){var b=document.createElement("mutation");b.setAttribute("hashid", +this.hashId);return b}};Entry.block.function_param_string=function(b,a,c){return a.register[a.hashId].run()};Entry.block.function_param_string={skeleton:"basic_string_field",color:"#ffd974",template:"\ubb38\uc790/\uc22b\uc790\uac12",func:function(){return this.executor.register.params[this.executor.register.paramMap[this.block.type]]}}; +Blockly.Blocks.function_param_boolean={init:function(){this.setEditable(!1);this.setColour("#AEB8FF");this.setOutput(!0,"Boolean");this.setInputsInline(!0)},domToMutation:function(b){b.getElementsByTagName("field");this.hashId=b.getAttribute("hashid");(b=Entry.Func.targetFunc.booleanHash[this.hashId])||(b="");this.appendDummyInput().appendField(new Blockly.FieldTextInput(Lang.Blocks.FUNCTION_logical_variable+b),"")},mutationToDom:function(){var b=document.createElement("mutation");b.setAttribute("hashid", +this.hashId);return b}};Entry.block.function_param_boolean=function(b,a,c){return a.register[a.hashId].run()};Entry.block.function_param_boolean={skeleton:"basic_boolean_field",color:"#aeb8ff",template:"\ud310\ub2e8\uac12",func:function(){return this.executor.register.params[this.executor.register.paramMap[this.block.type]]}}; +Blockly.Blocks.function_create={init:function(){this.appendDummyInput().appendField(Lang.Blocks.FUNCTION_define);this.setColour("#cc7337");this.appendValueInput("FIELD").setCheck(["Param"]);this.appendDummyInput().appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/function_03.png","*"));this.setInputsInline(!0);this.setNextStatement(!0)}};Entry.block.function_create=function(b,a){return a.callReturn()}; Entry.block.function_create={skeleton:"basic",color:"#cc7337",event:"funcDef",template:"\ud568\uc218 \uc815\uc758\ud558\uae30 %1 %2",params:[{type:"Block",accept:"paramMagnet",value:{type:"function_field_label"}},{type:"Indicator",img:"/lib/entryjs/images/block_icon/function_03.png",size:12}],func:function(){}}; -Blockly.Blocks.function_general={init:function(){this.setColour("#cc7337");this.setInputsInline(!0);this.setNextStatement(!0);this.setPreviousStatement(!0)},domToMutation:function(a){var b=a.getElementsByTagName("field");this.appendDummyInput().appendField("");b.length||this.appendDummyInput().appendField(Lang.Blocks.FUNCTION_function);for(var c=0;cb.count?(50>c.leftFloor&&50>c.rightFloor?b.count++:b.count=0,c=c.leftFloor-c.rightFloor,a.leftWheel=45+.25*c,a.rightWheel=45-.25*c):(b.count=0,b.boardState=2);break;case 2:c=c.leftFloor-c.rightFloor;a.leftWheel=45+.25*c;a.rightWheel=45-.25*c;b.boardState=3;var d=setTimeout(function(){b.boardState=4;Entry.Hamster.removeTimeout(d)},250);Entry.Hamster.timeouts.push(d); -break;case 3:c=c.leftFloor-c.rightFloor;a.leftWheel=45+.25*c;a.rightWheel=45-.25*c;break;case 4:a.leftWheel=0,a.rightWheel=0,b.boardState=0,b.isMoving=!1}return b}delete b.isStart;delete b.isMoving;delete b.count;delete b.boardState;Entry.engine.isContinue=!1;a.leftWheel=0;a.rightWheel=0;return b.callReturn()}b.isStart=!0;b.isMoving=!0;b.count=0;b.boardState=1;a.leftWheel=45;a.rightWheel=45;Entry.Hamster.setLineTracerMode(a,0);return b}; +Entry.block.hamster_move_forward_once=function(b,a){var c=Entry.hw.sendQueue,d=Entry.hw.portData;if(a.isStart){if(a.isMoving){switch(a.boardState){case 1:2>a.count?(50>d.leftFloor&&50>d.rightFloor?a.count++:a.count=0,d=d.leftFloor-d.rightFloor,c.leftWheel=45+.25*d,c.rightWheel=45-.25*d):(a.count=0,a.boardState=2);break;case 2:d=d.leftFloor-d.rightFloor;c.leftWheel=45+.25*d;c.rightWheel=45-.25*d;a.boardState=3;var e=setTimeout(function(){a.boardState=4;Entry.Hamster.removeTimeout(e)},250);Entry.Hamster.timeouts.push(e); +break;case 3:d=d.leftFloor-d.rightFloor;c.leftWheel=45+.25*d;c.rightWheel=45-.25*d;break;case 4:c.leftWheel=0,c.rightWheel=0,a.boardState=0,a.isMoving=!1}return a}delete a.isStart;delete a.isMoving;delete a.count;delete a.boardState;Entry.engine.isContinue=!1;c.leftWheel=0;c.rightWheel=0;return a.callReturn()}a.isStart=!0;a.isMoving=!0;a.count=0;a.boardState=1;c.leftWheel=45;c.rightWheel=45;Entry.Hamster.setLineTracerMode(c,0);return a}; Blockly.Blocks.hamster_turn_once={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.HAMSTER_turn_once_1).appendField(new Blockly.FieldDropdown([[Lang.General.left,"LEFT"],[Lang.General.right,"RIGHT"]]),"DIRECTION").appendField(Lang.Blocks.HAMSTER_turn_once_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.hamster_turn_once=function(a,b){a=Entry.hw.sendQueue;var c=Entry.hw.portData;if(b.isStart){if(b.isMoving){if(b.isLeft)switch(b.boardState){case 1:2>b.count?50c.leftFloor&&(b.boardState=3);break;case 3:2>b.count?20>c.leftFloor&&b.count++:(b.count=0,b.boardState=4);break;case 4:50b.count?50c.rightFloor&&(b.boardState=3);break;case 3:2>b.count?20>c.rightFloor&&b.count++:(b.count=0,b.boardState=4);break;case 4:50a.count?50d.leftFloor&&(a.boardState=3);break;case 3:2>a.count?20>d.leftFloor&&a.count++:(a.count=0,a.boardState=4);break;case 4:50a.count?50d.rightFloor&&(a.boardState=3);break;case 3:2>a.count?20>d.rightFloor&&a.count++:(a.count=0,a.boardState=4);break;case 4:50Entry.Hamster.tempo&&(Entry.Hamster.tempo=1);return b.callReturn()}; +Entry.block.hamster_change_tempo_by=function(b,a){Entry.Hamster.tempo+=a.getNumberValue("VALUE");1>Entry.Hamster.tempo&&(Entry.Hamster.tempo=1);return a.callReturn()}; Blockly.Blocks.hamster_set_tempo_to={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.HAMSTER_set_tempo_to_1);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.HAMSTER_set_tempo_to_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.hamster_set_tempo_to=function(a,b){Entry.Hamster.tempo=b.getNumberValue("VALUE");1>Entry.Hamster.tempo&&(Entry.Hamster.tempo=1);return b.callReturn()}; +Entry.block.hamster_set_tempo_to=function(b,a){Entry.Hamster.tempo=a.getNumberValue("VALUE");1>Entry.Hamster.tempo&&(Entry.Hamster.tempo=1);return a.callReturn()}; Blockly.Blocks.hamster_set_port_to={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.HAMSTER_set_port_to_1).appendField(new Blockly.FieldDropdown([[Lang.Blocks.HAMSTER_port_a,"A"],[Lang.Blocks.HAMSTER_port_b,"B"],[Lang.Blocks.HAMSTER_port_ab,"AB"]]),"PORT").appendField(Lang.Blocks.HAMSTER_set_port_to_2).appendField(new Blockly.FieldDropdown([[Lang.Blocks.HAMSTER_analog_input,"0"],[Lang.Blocks.HAMSTER_digital_input,"1"],[Lang.Blocks.HAMSTER_servo_output,"8"], -[Lang.Blocks.HAMSTER_pwm_output,"9"],[Lang.Blocks.HAMSTER_digital_output,"10"]]),"MODE").appendField(Lang.Blocks.HAMSTER_set_port_to_3).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.hamster_set_port_to=function(a,b){a=Entry.hw.sendQueue;var c=b.getField("PORT",b),d=Number(b.getField("MODE",b));"A"==c?a.ioModeA=d:("B"!=c&&(a.ioModeA=d),a.ioModeB=d);return b.callReturn()}; +[Lang.Blocks.HAMSTER_pwm_output,"9"],[Lang.Blocks.HAMSTER_digital_output,"10"]]),"MODE").appendField(Lang.Blocks.HAMSTER_set_port_to_3).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.hamster_set_port_to=function(b,a){var c=Entry.hw.sendQueue,d=a.getField("PORT",a),e=+a.getField("MODE",a);"A"==d?c.ioModeA=e:("B"!=d&&(c.ioModeA=e),c.ioModeB=e);return a.callReturn()}; Blockly.Blocks.hamster_change_output_by={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.HAMSTER_change_output_by_1).appendField(new Blockly.FieldDropdown([[Lang.Blocks.HAMSTER_port_a,"A"],[Lang.Blocks.HAMSTER_port_b,"B"],[Lang.Blocks.HAMSTER_port_ab,"AB"]]),"PORT").appendField(Lang.Blocks.HAMSTER_change_output_by_2);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.HAMSTER_change_output_by_3).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+ -"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.hamster_change_output_by=function(a,b){a=Entry.hw.sendQueue;var c=b.getField("PORT"),d=b.getNumberValue("VALUE");"A"==c?a.outputA=void 0!=a.outputA?a.outputA+d:d:("B"!=c&&(a.outputA=void 0!=a.outputA?a.outputA+d:d),a.outputB=void 0!=a.outputB?a.outputB+d:d);return b.callReturn()}; +"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.hamster_change_output_by=function(b,a){var c=Entry.hw.sendQueue,d=a.getField("PORT"),e=a.getNumberValue("VALUE");"A"==d?c.outputA=void 0!=c.outputA?c.outputA+e:e:("B"!=d&&(c.outputA=void 0!=c.outputA?c.outputA+e:e),c.outputB=void 0!=c.outputB?c.outputB+e:e);return a.callReturn()}; Blockly.Blocks.hamster_set_output_to={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.HAMSTER_set_output_to_1).appendField(new Blockly.FieldDropdown([[Lang.Blocks.HAMSTER_port_a,"A"],[Lang.Blocks.HAMSTER_port_b,"B"],[Lang.Blocks.HAMSTER_port_ab,"AB"]]),"PORT").appendField(Lang.Blocks.HAMSTER_set_output_to_2);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.HAMSTER_set_output_to_3).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+ -"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.hamster_set_output_to=function(a,b){a=Entry.hw.sendQueue;var c=b.getField("PORT"),d=b.getNumberValue("VALUE");"A"==c?a.outputA=d:("B"!=c&&(a.outputA=d),a.outputB=d);return b.callReturn()};Blockly.Blocks.is_clicked={init:function(){this.setColour("#AEB8FF");this.appendDummyInput().appendField(Lang.Blocks.JUDGEMENT_is_clicked,"#3D3D3D");this.setOutput(!0,"Boolean");this.setInputsInline(!0)}};Entry.block.is_clicked=function(a,b){return Entry.stage.isClick}; -Blockly.Blocks.is_press_some_key={init:function(){this.setColour("#AEB8FF");this.appendDummyInput().appendField(Lang.Blocks.JUDGEMENT_is_press_some_key_1,"#3D3D3D");this.appendDummyInput().appendField(new Blockly.FieldKeydownInput("81"),"VALUE").appendField(Lang.Blocks.JUDGEMENT_is_press_some_key_2,"#3D3D3D");this.setOutput(!0,"Boolean");this.setInputsInline(!0)}};Entry.block.is_press_some_key=function(a,b){a=Number(b.getField("VALUE",b));return 0<=Entry.pressedKeys.indexOf(a)}; +"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.hamster_set_output_to=function(b,a){var c=Entry.hw.sendQueue,d=a.getField("PORT"),e=a.getNumberValue("VALUE");"A"==d?c.outputA=e:("B"!=d&&(c.outputA=e),c.outputB=e);return a.callReturn()};Blockly.Blocks.is_clicked={init:function(){this.setColour("#AEB8FF");this.appendDummyInput().appendField(Lang.Blocks.JUDGEMENT_is_clicked,"#3D3D3D");this.setOutput(!0,"Boolean");this.setInputsInline(!0)}};Entry.block.is_clicked=function(b,a){return Entry.stage.isClick}; +Blockly.Blocks.is_press_some_key={init:function(){this.setColour("#AEB8FF");this.appendDummyInput().appendField(Lang.Blocks.JUDGEMENT_is_press_some_key_1,"#3D3D3D");this.appendDummyInput().appendField(new Blockly.FieldKeydownInput("81"),"VALUE").appendField(Lang.Blocks.JUDGEMENT_is_press_some_key_2,"#3D3D3D");this.setOutput(!0,"Boolean");this.setInputsInline(!0)}};Entry.block.is_press_some_key=function(b,a){var c=+a.getField("VALUE",a);return 0<=Entry.pressedKeys.indexOf(c)}; Blockly.Blocks.reach_something={init:function(){this.setColour("#AEB8FF");this.appendDummyInput().appendField(Lang.Blocks.JUDGEMENT_reach_something_1,"#3D3D3D");this.appendDummyInput().appendField(new Blockly.FieldDropdownDynamic("collision"),"VALUE");this.appendDummyInput().appendField(Lang.Blocks.JUDGEMENT_reach_something_2,"#3D3D3D");this.setOutput(!0,"Boolean");this.setInputsInline(!0)}}; -Entry.block.reach_something=function(a,b){if(!a.getVisible())return!1;var c=b.getField("VALUE",b);b=a.object;var d=/wall/.test(c),e=ndgmr.checkPixelCollision;if(d)switch(a=Entry.stage.wall,c){case "wall":if(e(b,a.up,.2,!0)||e(b,a.down,.2,!0)||e(b,a.left,.2,!0)||e(b,a.right,.2,!0))return!0;break;case "wall_up":if(e(b,a.up,.2,!0))return!0;break;case "wall_down":if(e(b,a.down,.2,!0))return!0;break;case "wall_right":if(e(b,a.right,.2,!0))return!0;break;case "wall_left":if(e(b,a.left,.2,!0))return!0}else{if("mouse"== -c)return e=Entry.stage.canvas,e=b.globalToLocal(e.mouseX,e.mouseY),b.hitTest(e.x,e.y);c=Entry.container.getEntity(c);if("textBox"==c.type||"textBox"==a.type){e=c.object.getTransformedBounds();b=b.getTransformedBounds();if(Entry.checkCollisionRect(b,e))return!0;a=c.parent.clonedEntities;c=0;for(d=a.length;c","BIGGER"]]),"OPERATOR");this.appendValueInput("RIGHTHAND").setCheck(["String","Number"]);this.setOutput(!0,"Boolean");this.setInputsInline(!0)}}; -Entry.block.boolean_comparison=function(a,b){a=b.getField("OPERATOR",b);var c=b.getNumberValue("LEFTHAND",b);b=b.getNumberValue("RIGHTHAND",b);return"EQUAL"==a?c==b:"BIGGER"==a?c>b:c","#3D3D3D");this.appendValueInput("RIGHTHAND").setCheck(["Number","String"]);this.setOutput(!0,"Boolean");this.setInputsInline(!0)}}; -Entry.block.boolean_bigger=function(a,b){a=b.getNumberValue("LEFTHAND",b);b=b.getNumberValue("RIGHTHAND",b);return a>b};Blockly.Blocks.boolean_smaller={init:function(){this.setColour("#AEB8FF");this.appendValueInput("LEFTHAND").setCheck(["Number","String"]);this.appendDummyInput().appendField("<","#3D3D3D");this.appendValueInput("RIGHTHAND").setCheck(["Number","String"]);this.setOutput(!0,"Boolean");this.setInputsInline(!0)}}; -Entry.block.boolean_smaller=function(a,b){a=b.getNumberValue("LEFTHAND",b);b=b.getNumberValue("RIGHTHAND",b);return a","BIGGER"]]),"OPERATOR");this.appendValueInput("RIGHTHAND").setCheck(["String","Number"]);this.setOutput(!0,"Boolean");this.setInputsInline(!0)}}; +Entry.block.boolean_comparison=function(b,a){var c=a.getField("OPERATOR",a),d=a.getNumberValue("LEFTHAND",a),e=a.getNumberValue("RIGHTHAND",a);return"EQUAL"==c?d==e:"BIGGER"==c?d>e:d","#3D3D3D");this.appendValueInput("RIGHTHAND").setCheck(["Number","String"]);this.setOutput(!0,"Boolean");this.setInputsInline(!0)}}; +Entry.block.boolean_bigger=function(b,a){var c=a.getNumberValue("LEFTHAND",a),d=a.getNumberValue("RIGHTHAND",a);return c>d};Blockly.Blocks.boolean_smaller={init:function(){this.setColour("#AEB8FF");this.appendValueInput("LEFTHAND").setCheck(["Number","String"]);this.appendDummyInput().appendField("<","#3D3D3D");this.appendValueInput("RIGHTHAND").setCheck(["Number","String"]);this.setOutput(!0,"Boolean");this.setInputsInline(!0)}}; +Entry.block.boolean_smaller=function(b,a){var c=a.getNumberValue("LEFTHAND",a),d=a.getNumberValue("RIGHTHAND",a);return c","GREATER"],["<","LESS"],["\u2265","GREATER_OR_EQUAL"],["\u2264","LESS_OR_EQUAL"]],null,!1),"OPERATOR");this.appendValueInput("RIGHTHAND").setCheck(["Number","String"]);this.setOutput(!0,"Boolean");this.setInputsInline(!0)}}; -Entry.block.boolean_basic_operator=function(a,b){a=b.getField("OPERATOR",b);var c=b.getStringValue("LEFTHAND",b);b=b.getStringValue("RIGHTHAND",b);switch(a){case "EQUAL":return c==b;case "GREATER":return Number(c)>Number(b);case "LESS":return Number(c)=Number(b);case "LESS_OR_EQUAL":return Number(c)<=Number(b)}};Blockly.Blocks.show={init:function(){this.setColour("#EC4466");this.appendDummyInput().appendField(Lang.Blocks.LOOKS_show).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/looks_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.show=function(a,b){a.setVisible(!0);return b.callReturn()}; -Blockly.Blocks.hide={init:function(){this.setColour("#EC4466");this.appendDummyInput().appendField(Lang.Blocks.LOOKS_hide).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/looks_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.hide=function(a,b){a.setVisible(!1);return b.callReturn()}; +Entry.block.boolean_basic_operator=function(b,a){var c=a.getField("OPERATOR",a),d=a.getStringValue("LEFTHAND",a),e=a.getStringValue("RIGHTHAND",a);switch(c){case "EQUAL":return d==e;case "GREATER":return+d>+e;case "LESS":return+d<+e;case "GREATER_OR_EQUAL":return+d>=+e;case "LESS_OR_EQUAL":return+d<=+e}};Blockly.Blocks.show={init:function(){this.setColour("#EC4466");this.appendDummyInput().appendField(Lang.Blocks.LOOKS_show).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/looks_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.show=function(b,a){b.setVisible(!0);return a.callReturn()}; +Blockly.Blocks.hide={init:function(){this.setColour("#EC4466");this.appendDummyInput().appendField(Lang.Blocks.LOOKS_hide).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/looks_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.hide=function(b,a){b.setVisible(!1);return a.callReturn()}; Blockly.Blocks.dialog_time={init:function(){this.setColour("#EC4466");this.appendDummyInput().appendField(Lang.Blocks.LOOKS_dialog_time_1);this.appendValueInput("VALUE").setCheck(["String","Number",null]);this.appendDummyInput().appendField(Lang.Blocks.LOOKS_dialog_time_2);this.appendValueInput("SECOND").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.LOOKS_dialog_time_3);this.appendDummyInput().appendField(new Blockly.FieldDropdown([[Lang.Blocks.speak,"speak"]]),"OPTION"); this.appendDummyInput().appendField(Lang.Blocks.LOOKS_dialog_time_4).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/looks_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.dialog_time=function(a,b){if(!b.isStart){var c=b.getNumberValue("SECOND",b),d=b.getStringValue("VALUE",b),e=b.getField("OPTION",b);b.isStart=!0;b.timeFlag=1;d||"number"==typeof d||(d=" ");d=Entry.convertToRoundedDecimals(d,3);new Entry.Dialog(a,d,e);a.syncDialogVisible(a.getVisible());setTimeout(function(){b.timeFlag=0},1E3*c)}return 0==b.timeFlag?(delete b.timeFlag,delete b.isStart,a.dialog&&a.dialog.remove(),b.callReturn()):b}; +Entry.block.dialog_time=function(b,a){if(!a.isStart){var c=a.getNumberValue("SECOND",a),d=a.getStringValue("VALUE",a),e=a.getField("OPTION",a);a.isStart=!0;a.timeFlag=1;d||"number"==typeof d||(d=" ");d=Entry.convertToRoundedDecimals(d,3);new Entry.Dialog(b,d,e);b.syncDialogVisible(b.getVisible());setTimeout(function(){a.timeFlag=0},1E3*c)}return 0==a.timeFlag?(delete a.timeFlag,delete a.isStart,b.dialog&&b.dialog.remove(),a.callReturn()):a}; Blockly.Blocks.dialog={init:function(){this.setColour("#EC4466");this.appendDummyInput().appendField(Lang.Blocks.LOOKS_dialog_1);this.appendValueInput("VALUE").setCheck(["String","Number",null]);this.appendDummyInput().appendField(Lang.Blocks.LOOKS_dialog_2);this.appendDummyInput().appendField(new Blockly.FieldDropdown([[Lang.Blocks.speak,"speak"]]),"OPTION");this.appendDummyInput().appendField(Lang.Blocks.LOOKS_dialog_3).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/looks_03.png", -"*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.dialog=function(a,b){var c=b.getStringValue("VALUE",b);c||"number"==typeof c||(c=" ");var d=b.getField("OPTION",b),c=Entry.convertToRoundedDecimals(c,3);new Entry.Dialog(a,c,d);a.syncDialogVisible(a.getVisible());return b.callReturn()}; -Blockly.Blocks.remove_dialog={init:function(){this.setColour("#EC4466");this.appendDummyInput().appendField(Lang.Blocks.LOOKS_remove_dialog).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/looks_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.remove_dialog=function(a,b){a.dialog&&a.dialog.remove();return b.callReturn()}; +"*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.dialog=function(b,a){var c=a.getStringValue("VALUE",a);c||"number"==typeof c||(c=" ");var d=a.getField("OPTION",a),c=Entry.convertToRoundedDecimals(c,3);new Entry.Dialog(b,c,d);b.syncDialogVisible(b.getVisible());return a.callReturn()}; +Blockly.Blocks.remove_dialog={init:function(){this.setColour("#EC4466");this.appendDummyInput().appendField(Lang.Blocks.LOOKS_remove_dialog).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/looks_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.remove_dialog=function(b,a){b.dialog&&b.dialog.remove();return a.callReturn()}; Blockly.Blocks.change_to_nth_shape={init:function(){this.setColour("#EC4466");this.appendDummyInput().appendField(Lang.Blocks.LOOKS_change_to_nth_shape_1);this.appendDummyInput().appendField(new Blockly.FieldDropdownDynamic("pictures"),"VALUE");this.appendDummyInput().appendField(Lang.Blocks.LOOKS_change_to_nth_shape_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/looks_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.change_to_nth_shape=function(a,b){var c=b.getField("VALUE",b),c=a.parent.getPicture(c);a.setImage(c);return b.callReturn()}; +Entry.block.change_to_nth_shape=function(b,a){var c=a.getField("VALUE",a),c=b.parent.getPicture(c);b.setImage(c);return a.callReturn()}; Blockly.Blocks.change_to_next_shape={init:function(){this.setColour("#EC4466");this.appendDummyInput().appendField(Lang.Blocks.LOOKS_change_to_near_shape_1).appendField(new Blockly.FieldDropdown([[Lang.Blocks.LOOKS_change_shape_next,"next"],[Lang.Blocks.LOOKS_change_shape_prev,"prev"]]),"DRIECTION").appendField(Lang.Blocks.LOOKS_change_to_near_shape_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/looks_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.change_to_next_shape=function(a,b){var c;c=b.fields&&"prev"===b.getStringField("DRIECTION")?a.parent.getPrevPicture(a.picture.id):a.parent.getNextPicture(a.picture.id);a.setImage(c);return b.callReturn()}; +Entry.block.change_to_next_shape=function(b,a){var c;c=a.fields&&"prev"===a.getStringField("DRIECTION")?b.parent.getPrevPicture(b.picture.id):b.parent.getNextPicture(b.picture.id);b.setImage(c);return a.callReturn()}; Blockly.Blocks.set_effect_volume={init:function(){this.setColour("#EC4466");this.appendDummyInput().appendField(Lang.Blocks.LOOKS_set_effect_volume_1);this.appendDummyInput().appendField(new Blockly.FieldDropdown([[Lang.Blocks.color,"color"],[Lang.Blocks.brightness,"brightness"],[Lang.Blocks.opacity,"opacity"]]),"EFFECT");this.appendDummyInput().appendField(Lang.Blocks.LOOKS_set_effect_volume_2);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.LOOKS_set_effect_volume_3).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+ -"block_icon/looks_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.set_effect_volume=function(a,b){var c=b.getField("EFFECT",b),d=b.getNumberValue("VALUE",b);"color"==c?a.effect.hue=d+a.effect.hue:"lens"!=c&&"swriling"!=c&&"pixel"!=c&&"mosaic"!=c&&("brightness"==c?a.effect.brightness=d+a.effect.brightness:"blur"!=c&&"opacity"==c&&(a.effect.alpha+=d/100));a.applyFilter();return b.callReturn()}; +"block_icon/looks_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.set_effect_volume=function(b,a){var c=a.getField("EFFECT",a),d=a.getNumberValue("VALUE",a);"color"==c?b.effect.hue=d+b.effect.hue:"lens"!=c&&"swriling"!=c&&"pixel"!=c&&"mosaic"!=c&&("brightness"==c?b.effect.brightness=d+b.effect.brightness:"blur"!=c&&"opacity"==c&&(b.effect.alpha+=d/100));b.applyFilter();return a.callReturn()}; Blockly.Blocks.set_effect={init:function(){this.setColour("#EC4466");this.appendDummyInput().appendField(Lang.Blocks.LOOKS_set_effect_1);this.appendDummyInput().appendField(new Blockly.FieldDropdown([[Lang.Blocks.color,"color"],[Lang.Blocks.brightness,"brightness"],[Lang.Blocks.opacity,"opacity"]]),"EFFECT");this.appendDummyInput().appendField(Lang.Blocks.LOOKS_set_effect_2);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.LOOKS_set_effect_3).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+ -"block_icon/looks_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.set_effect=function(a,b){var c=b.getField("EFFECT",b),d=b.getNumberValue("VALUE",b);"color"==c?a.effect.hue=d:"lens"!=c&&"swriling"!=c&&"pixel"!=c&&"mosaic"!=c&&("brightness"==c?a.effect.brightness=d:"blur"!=c&&"opacity"==c&&(a.effect.alpha=d/100));a.applyFilter();return b.callReturn()}; -Blockly.Blocks.erase_all_effects={init:function(){this.setColour("#EC4466");this.appendDummyInput().appendField(Lang.Blocks.LOOKS_erase_all_effects).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/looks_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.erase_all_effects=function(a,b){a.resetFilter();return b.callReturn()}; +"block_icon/looks_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.set_effect=function(b,a){var c=a.getField("EFFECT",a),d=a.getNumberValue("VALUE",a);"color"==c?b.effect.hue=d:"lens"!=c&&"swriling"!=c&&"pixel"!=c&&"mosaic"!=c&&("brightness"==c?b.effect.brightness=d:"blur"!=c&&"opacity"==c&&(b.effect.alpha=d/100));b.applyFilter();return a.callReturn()}; +Blockly.Blocks.erase_all_effects={init:function(){this.setColour("#EC4466");this.appendDummyInput().appendField(Lang.Blocks.LOOKS_erase_all_effects).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/looks_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.erase_all_effects=function(b,a){b.resetFilter();return a.callReturn()}; Blockly.Blocks.change_scale_percent={init:function(){this.setColour("#EC4466");this.appendDummyInput().appendField(Lang.Blocks.LOOKS_change_scale_percent_1);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.LOOKS_change_scale_percent_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/looks_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.change_scale_percent=function(a,b){var c=(b.getNumberValue("VALUE",b)+100)/100;a.setScaleX(a.getScaleX()*c);a.setScaleY(a.getScaleY()*c);return b.callReturn()}; +Entry.block.change_scale_percent=function(b,a){var c=(a.getNumberValue("VALUE",a)+100)/100;b.setScaleX(b.getScaleX()*c);b.setScaleY(b.getScaleY()*c);return a.callReturn()}; Blockly.Blocks.set_scale_percent={init:function(){this.setColour("#EC4466");this.appendDummyInput().appendField(Lang.Blocks.LOOKS_set_scale_percent_1);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.LOOKS_set_scale_percent_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/looks_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.set_scale_percent=function(a,b){var c=b.getNumberValue("VALUE",b)/100,d=a.snapshot_;a.setScaleX(c*d.scaleX);a.setScaleY(c*d.scaleY);return b.callReturn()}; +Entry.block.set_scale_percent=function(b,a){var c=a.getNumberValue("VALUE",a)/100,d=b.snapshot_;b.setScaleX(c*d.scaleX);b.setScaleY(c*d.scaleY);return a.callReturn()}; Blockly.Blocks.change_scale_size={init:function(){this.setColour("#EC4466");this.appendDummyInput().appendField(Lang.Blocks.LOOKS_change_scale_percent_1);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.LOOKS_change_scale_percent_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/looks_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.change_scale_size=function(a,b){var c=b.getNumberValue("VALUE",b);a.setSize(a.getSize()+c);return b.callReturn()}; +Entry.block.change_scale_size=function(b,a){var c=a.getNumberValue("VALUE",a);b.setSize(b.getSize()+c);return a.callReturn()}; Blockly.Blocks.set_scale_size={init:function(){this.setColour("#EC4466");this.appendDummyInput().appendField(Lang.Blocks.LOOKS_set_scale_percent_1);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.LOOKS_set_scale_percent_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/looks_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.set_scale_size=function(a,b){var c=b.getNumberValue("VALUE",b);a.setSize(c);return b.callReturn()};Blockly.Blocks.flip_y={init:function(){this.setColour("#EC4466");this.appendDummyInput().appendField(Lang.Blocks.LOOKS_flip_y).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/looks_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.flip_y=function(a,b){a.setScaleX(-1*a.getScaleX());return b.callReturn()}; -Blockly.Blocks.flip_x={init:function(){this.setColour("#EC4466");this.appendDummyInput().appendField(Lang.Blocks.LOOKS_flip_x).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/looks_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.flip_x=function(a,b){a.setScaleY(-1*a.getScaleY());return b.callReturn()}; +Entry.block.set_scale_size=function(b,a){var c=a.getNumberValue("VALUE",a);b.setSize(c);return a.callReturn()};Blockly.Blocks.flip_y={init:function(){this.setColour("#EC4466");this.appendDummyInput().appendField(Lang.Blocks.LOOKS_flip_y).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/looks_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.flip_y=function(b,a){b.setScaleX(-1*b.getScaleX());return a.callReturn()}; +Blockly.Blocks.flip_x={init:function(){this.setColour("#EC4466");this.appendDummyInput().appendField(Lang.Blocks.LOOKS_flip_x).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/looks_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.flip_x=function(b,a){b.setScaleY(-1*b.getScaleY());return a.callReturn()}; Blockly.Blocks.set_object_order={init:function(){this.setColour("#EC4466");this.appendDummyInput().appendField(Lang.Blocks.LOOKS_set_object_order_1);this.appendDummyInput().appendField(new Blockly.FieldDropdownDynamic("objectSequence"),"VALUE");this.appendDummyInput().appendField(Lang.Blocks.LOOKS_set_object_order_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/looks_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.set_object_order=function(a,b){var c=b.getField("VALUE",b);a=Entry.container.getCurrentObjects().indexOf(a.parent);if(-1a)throw Error("object is not available for current scene");switch(d){case "FRONT":c=0;break;case "FORWARD":c=Math.max(0,a-1);break;case "BACKWARD":c=Math.min(e,a+1);break;case "BACK":c=e}Entry.container.moveElementByBlock(a,c);return b.callReturn()};Blockly.Blocks.move_direction={init:function(){this.setColour("#A751E3");this.appendDummyInput().appendField(Lang.Blocks.MOVING_move_direction_1);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.MOVING_move_direction_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/moving_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.move_direction=function(a,b){var c=b.getNumberValue("VALUE",b);a.setX(a.getX()+c*Math.cos((a.getRotation()+a.getDirection()-90)/180*Math.PI));a.setY(a.getY()-c*Math.sin((a.getRotation()+a.getDirection()-90)/180*Math.PI));a.brush&&!a.brush.stop&&a.brush.lineTo(a.getX(),-1*a.getY());return b.callReturn()}; +"block_icon/looks_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.change_object_index=function(b,a){var c,d=a.getField("LOCATION",a),e=Entry.container.getCurrentObjects(),f=e.indexOf(b.parent),e=e.length-1;if(0>f)throw Error("object is not available for current scene");switch(d){case "FRONT":c=0;break;case "FORWARD":c=Math.max(0,f-1);break;case "BACKWARD":c=Math.min(e,f+1);break;case "BACK":c=e}Entry.container.moveElementByBlock(f,c);return a.callReturn()};Blockly.Blocks.move_direction={init:function(){this.setColour("#A751E3");this.appendDummyInput().appendField(Lang.Blocks.MOVING_move_direction_1);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.MOVING_move_direction_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/moving_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; +Entry.block.move_direction=function(b,a){var c=a.getNumberValue("VALUE",a);b.setX(b.getX()+c*Math.cos((b.getRotation()+b.getDirection()-90)/180*Math.PI));b.setY(b.getY()-c*Math.sin((b.getRotation()+b.getDirection()-90)/180*Math.PI));b.brush&&!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY());return a.callReturn()}; Blockly.Blocks.move_x={init:function(){this.setColour("#A751E3");this.appendDummyInput().appendField(Lang.Blocks.MOVING_move_x_1);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.MOVING_move_x_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/moving_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.move_x=function(a,b){var c=b.getNumberValue("VALUE",b);a.setX(a.getX()+c);a.brush&&!a.brush.stop&&a.brush.lineTo(a.getX(),-1*a.getY());return b.callReturn()}; +Entry.block.move_x=function(b,a){var c=a.getNumberValue("VALUE",a);b.setX(b.getX()+c);b.brush&&!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY());return a.callReturn()}; Blockly.Blocks.move_y={init:function(){this.setColour("#A751E3");this.appendDummyInput().appendField(Lang.Blocks.MOVING_move_y_1);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.MOVING_move_y_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/moving_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.move_y=function(a,b){var c=b.getNumberValue("VALUE",b);a.setY(a.getY()+c);a.brush&&!a.brush.stop&&a.brush.lineTo(a.getX(),-1*a.getY());return b.callReturn()}; +Entry.block.move_y=function(b,a){var c=a.getNumberValue("VALUE",a);b.setY(b.getY()+c);b.brush&&!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY());return a.callReturn()}; Blockly.Blocks.locate_xy_time={init:function(){this.setColour("#A751E3");this.appendDummyInput().appendField(Lang.Blocks.MOVING_locate_xy_time_1);this.appendValueInput("VALUE1").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.MOVING_locate_xy_time_2);this.appendValueInput("VALUE2").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.MOVING_locate_xy_time_3);this.appendValueInput("VALUE3").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.MOVING_locate_xy_time_4).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+ "block_icon/moving_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.locate_xy_time=function(a,b){if(!b.isStart){var c;c=b.getNumberValue("VALUE1",b);b.isStart=!0;b.frameCount=Math.floor(c*Entry.FPS);b.x=b.getNumberValue("VALUE2",b);b.y=b.getNumberValue("VALUE3",b)}if(0!=b.frameCount){c=b.x-a.getX();var d=b.y-a.getY();c/=b.frameCount;d/=b.frameCount;a.setX(a.getX()+c);a.setY(a.getY()+d);b.frameCount--;a.brush&&!a.brush.stop&&a.brush.lineTo(a.getX(),-1*a.getY());return b}delete b.isStart;delete b.frameCount;return b.callReturn()}; +Entry.block.locate_xy_time=function(b,a){if(!a.isStart){var c;c=a.getNumberValue("VALUE1",a);a.isStart=!0;a.frameCount=Math.floor(c*Entry.FPS);a.x=a.getNumberValue("VALUE2",a);a.y=a.getNumberValue("VALUE3",a)}if(0!=a.frameCount){c=a.x-b.getX();var d=a.y-b.getY();c/=a.frameCount;d/=a.frameCount;b.setX(b.getX()+c);b.setY(b.getY()+d);a.frameCount--;b.brush&&!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY());return a}delete a.isStart;delete a.frameCount;return a.callReturn()}; Blockly.Blocks.rotate_by_angle={init:function(){this.setColour("#A751E3");this.appendDummyInput().appendField(Lang.Blocks.MOVING_rotate_by_angle_1);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.MOVING_rotate_by_angle_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/moving_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.rotate_by_angle=function(a,b){var c=b.getNumberValue("VALUE",b);a.setRotation(a.getRotation()+c);return b.callReturn()}; +Entry.block.rotate_by_angle=function(b,a){var c=a.getNumberValue("VALUE",a);b.setRotation(b.getRotation()+c);return a.callReturn()}; Blockly.Blocks.rotate_by_angle_dropdown={init:function(){this.setColour("#A751E3");this.appendDummyInput().appendField(Lang.Blocks.MOVING_rotate_by_angle_dropdown_1);this.appendDummyInput().appendField(new Blockly.FieldDropdown([["45","45"],["90","90"],["135","135"],["180","180"]]),"VALUE").appendField(Lang.Blocks.MOVING_rotate_by_angle_dropdown_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/moving_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.rotate_by_angle_dropdown=function(a,b){var c=b.getField("VALUE",b);a.setRotation(a.getRotation()+Number(c));return b.callReturn()}; +Entry.block.rotate_by_angle_dropdown=function(b,a){var c=a.getField("VALUE",a);b.setRotation(b.getRotation()+ +c);return a.callReturn()}; Blockly.Blocks.see_angle={init:function(){this.setColour("#A751E3");this.appendDummyInput().appendField(Lang.Blocks.MOVING_see_angle_1);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.MOVING_see_angle_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/moving_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.see_angle=function(a,b){var c=b.getNumberValue("VALUE",b);a.setDirection(c);return b.callReturn()}; +Entry.block.see_angle=function(b,a){var c=a.getNumberValue("VALUE",a);b.setDirection(c);return a.callReturn()}; Blockly.Blocks.see_direction={init:function(){this.setColour("#A751E3");this.appendDummyInput().appendField(Lang.Blocks.MOVING_see_direction_1);this.appendDummyInput().appendField(new Blockly.FieldDropdownDynamic("sprites"),"VALUE");this.appendDummyInput().appendField(Lang.Blocks.MOVING_see_direction_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/moving_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.see_direction=function(a,b){var c=b.getField("VALUE",b),d=Entry.container.getEntity(c),c=d.getX()-a.getX(),d=d.getY()-a.getY();0<=c?a.setRotation(Math.atan(d/c)/Math.PI*180+90):a.setRotation(Math.atan(d/c)/Math.PI*180+270);return b.callReturn()}; +Entry.block.see_direction=function(b,a){var c=a.getField("VALUE",a),d=Entry.container.getEntity(c),c=d.getX()-b.getX(),d=d.getY()-b.getY();0<=c?b.setRotation(Math.atan(d/c)/Math.PI*180+90):b.setRotation(Math.atan(d/c)/Math.PI*180+270);return a.callReturn()}; Blockly.Blocks.locate_xy={init:function(){this.setColour("#A751E3");this.appendDummyInput().appendField(Lang.Blocks.MOVING_locate_xy_1);this.appendValueInput("VALUE1").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.MOVING_locate_xy_2);this.appendValueInput("VALUE2").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.MOVING_locate_xy_3).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/moving_03.png","*"));this.setInputsInline(!0); -this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.locate_xy=function(a,b){var c=b.getNumberValue("VALUE1",b);a.setX(c);c=b.getNumberValue("VALUE2",b);a.setY(c);a.brush&&!a.brush.stop&&a.brush.lineTo(a.getX(),-1*a.getY());return b.callReturn()}; +this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.locate_xy=function(b,a){var c=a.getNumberValue("VALUE1",a);b.setX(c);c=a.getNumberValue("VALUE2",a);b.setY(c);b.brush&&!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY());return a.callReturn()}; Blockly.Blocks.locate_x={init:function(){this.setColour("#A751E3");this.appendDummyInput().appendField(Lang.Blocks.MOVING_locate_x_1);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.MOVING_locate_x_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/moving_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.locate_x=function(a,b){var c=b.getNumberValue("VALUE",b);a.setX(c);a.brush&&!a.brush.stop&&a.brush.lineTo(a.getX(),-1*a.getY());return b.callReturn()}; +Entry.block.locate_x=function(b,a){var c=a.getNumberValue("VALUE",a);b.setX(c);b.brush&&!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY());return a.callReturn()}; Blockly.Blocks.locate_y={init:function(){this.setColour("#A751E3");this.appendDummyInput().appendField(Lang.Blocks.MOVING_locate_y_1);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.MOVING_locate_y_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/moving_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.locate_y=function(a,b){var c=b.getNumberValue("VALUE",b);a.setY(c);a.brush&&!a.brush.stop&&a.brush.lineTo(a.getX(),-1*a.getY());return b.callReturn()}; +Entry.block.locate_y=function(b,a){var c=a.getNumberValue("VALUE",a);b.setY(c);b.brush&&!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY());return a.callReturn()}; Blockly.Blocks.locate={init:function(){this.setColour("#A751E3");this.appendDummyInput().appendField(Lang.Blocks.MOVING_locate_1);this.appendDummyInput().appendField(new Blockly.FieldDropdownDynamic("spritesWithMouse"),"VALUE");this.appendDummyInput().appendField(Lang.Blocks.MOVING_locate_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/moving_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.locate=function(a,b){var c=b.getField("VALUE",b),d;"mouse"==c?(c=Entry.stage.mouseCoordinate.x,d=Entry.stage.mouseCoordinate.y):(d=Entry.container.getEntity(c),c=d.getX(),d=d.getY());a.setX(Number(c));a.setY(Number(d));a.brush&&!a.brush.stop&&a.brush.lineTo(c,-1*d);return b.callReturn()}; +Entry.block.locate=function(b,a){var c=a.getField("VALUE",a),d;"mouse"==c?(c=Entry.stage.mouseCoordinate.x,d=Entry.stage.mouseCoordinate.y):(d=Entry.container.getEntity(c),c=d.getX(),d=d.getY());b.setX(+c);b.setY(+d);b.brush&&!b.brush.stop&&b.brush.lineTo(c,-1*d);return a.callReturn()}; Blockly.Blocks.move_xy_time={init:function(){this.setColour("#A751E3");this.appendDummyInput().appendField(Lang.Blocks.MOVING_move_xy_time_1);this.appendValueInput("VALUE1").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.MOVING_move_xy_time_2);this.appendValueInput("VALUE2").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.MOVING_move_xy_time_3);this.appendValueInput("VALUE3").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.MOVING_move_xy_time_4).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+ "block_icon/moving_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.move_xy_time=function(a,b){if(!b.isStart){var c;c=b.getNumberValue("VALUE1",b);var d=b.getNumberValue("VALUE2",b),e=b.getNumberValue("VALUE3",b);b.isStart=!0;b.frameCount=Math.floor(c*Entry.FPS);b.dX=d/b.frameCount;b.dY=e/b.frameCount}if(0!=b.frameCount)return a.setX(a.getX()+b.dX),a.setY(a.getY()+b.dY),b.frameCount--,a.brush&&!a.brush.stop&&a.brush.lineTo(a.getX(),-1*a.getY()),b;delete b.isStart;delete b.frameCount;return b.callReturn()}; +Entry.block.move_xy_time=function(b,a){if(!a.isStart){var c;c=a.getNumberValue("VALUE1",a);var d=a.getNumberValue("VALUE2",a),e=a.getNumberValue("VALUE3",a);a.isStart=!0;a.frameCount=Math.floor(c*Entry.FPS);a.dX=d/a.frameCount;a.dY=e/a.frameCount}if(0!=a.frameCount)return b.setX(b.getX()+a.dX),b.setY(b.getY()+a.dY),a.frameCount--,b.brush&&!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY()),a;delete a.isStart;delete a.frameCount;return a.callReturn()}; Blockly.Blocks.locate_time={init:function(){this.setColour("#A751E3");this.appendDummyInput().appendField(Lang.Blocks.MOVING_locate_time_1);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.MOVING_locate_time_2);this.appendDummyInput().appendField(new Blockly.FieldDropdownDynamic("sprites"),"VALUE");this.appendDummyInput().appendField(Lang.Blocks.MOVING_locate_time_3).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/moving_03.png", "*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; Blockly.Blocks.rotate_by_angle_time={init:function(){this.setColour("#A751E3");this.appendDummyInput().appendField(Lang.Blocks.MOVING_rotate_by_angle_time_1);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.MOVING_rotate_by_angle_time_2);this.appendDummyInput().appendField(new Blockly.FieldAngle("90"),"VALUE");this.appendDummyInput().appendField(Lang.Blocks.MOVING_rotate_by_angle_time_3).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/moving_03.png", -"*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.rotate_by_angle_time=function(a,b){if(!b.isStart){var c;c=b.getNumberValue("VALUE",b);var d=b.getNumberField("VALUE",b);b.isStart=!0;b.frameCount=Math.floor(c*Entry.FPS);b.dAngle=d/b.frameCount}if(0!=b.frameCount)return a.setRotation(a.getRotation()+b.dAngle),b.frameCount--,b;delete b.isStart;delete b.frameCount;return b.callReturn()}; +"*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.rotate_by_angle_time=function(b,a){if(!a.isStart){var c;c=a.getNumberValue("VALUE",a);var d=a.getNumberField("VALUE",a);a.isStart=!0;a.frameCount=Math.floor(c*Entry.FPS);a.dAngle=d/a.frameCount}if(0!=a.frameCount)return b.setRotation(b.getRotation()+a.dAngle),a.frameCount--,a;delete a.isStart;delete a.frameCount;return a.callReturn()}; Blockly.Blocks.bounce_when={init:function(){this.setColour("#A751E3");this.appendDummyInput().appendField(Lang.Blocks.MOVING_bounce_when_1);this.appendDummyInput().appendField(new Blockly.FieldDropdownDynamic("bounce"),"VALUE");this.appendDummyInput().appendField(Lang.Blocks.MOVING_bounce_when_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/moving_03.png","*"));this.setPreviousStatement(!0);this.setInputsInline(!0);this.setNextStatement(!0)}}; Blockly.Blocks.bounce_wall={init:function(){this.setColour("#A751E3");this.appendDummyInput().appendField(Lang.Blocks.MOVING_bounce_wall).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/moving_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.bounce_wall=function(a,b){var c=a.parent.getRotateMethod(),d="free"==c?(a.getRotation()+a.getDirection()).mod(360):a.getDirection(),e;if(90>d&&0<=d||360>d&&270<=d){e=a.collision==Entry.Utils.COLLISION.UP;var f=ndgmr.checkPixelCollision(Entry.stage.wall.up,a.object,0,!1);!f&&e&&(a.collision=Entry.Utils.COLLISION.NONE);f&&e&&(f=!1);f?("free"==c?a.setRotation(-a.getRotation()-2*a.getDirection()+180):a.setDirection(-a.getDirection()+180),a.collision=Entry.Utils.COLLISION.UP):(e=a.collision== -Entry.Utils.COLLISION.DOWN,f=ndgmr.checkPixelCollision(Entry.stage.wall.down,a.object,0,!1),!f&&e&&(a.collision=Entry.Utils.COLLISION.NONE),f&&e&&(f=!1),f&&("free"==c?a.setRotation(-a.getRotation()-2*a.getDirection()+180):a.setDirection(-a.getDirection()+180),a.collision=Entry.Utils.COLLISION.DOWN))}else 270>d&&90<=d&&(e=a.collision==Entry.Utils.COLLISION.DOWN,f=ndgmr.checkPixelCollision(Entry.stage.wall.down,a.object,0,!1),!f&&e&&(a.collision=Entry.Utils.COLLISION.NONE),f&&e&&(f=!1),f?("free"==c? -a.setRotation(-a.getRotation()-2*a.getDirection()+180):a.setDirection(-a.getDirection()+180),a.collision=Entry.Utils.COLLISION.DOWN):(e=a.collision==Entry.Utils.COLLISION.UP,f=ndgmr.checkPixelCollision(Entry.stage.wall.up,a.object,0,!1),!f&&e&&(a.collision=Entry.Utils.COLLISION.NONE),f&&e&&(f=!1),f&&("free"==c?a.setRotation(-a.getRotation()-2*a.getDirection()+180):a.setDirection(-a.getDirection()+180),a.collision=Entry.Utils.COLLISION.UP)));360>d&&180<=d?(e=a.collision==Entry.Utils.COLLISION.LEFT, -d=ndgmr.checkPixelCollision(Entry.stage.wall.left,a.object,0,!1),!d&&e&&(a.collision=Entry.Utils.COLLISION.NONE),d&&e&&(d=!1),d?("free"==c?a.setRotation(-a.getRotation()-2*a.getDirection()):a.setDirection(-a.getDirection()+360),a.collision=Entry.Utils.COLLISION.LEFT):(e=a.collision==Entry.Utils.COLLISION.RIGHT,d=ndgmr.checkPixelCollision(Entry.stage.wall.right,a.object,0,!1),!d&&e&&(a.collision=Entry.Utils.COLLISION.NONE),d&&e&&(d=!1),d&&("free"==c?a.setRotation(-a.getRotation()-2*a.getDirection()): -a.setDirection(-a.getDirection()+360),a.collision=Entry.Utils.COLLISION.RIGHT))):180>d&&0<=d&&(e=a.collision==Entry.Utils.COLLISION.RIGHT,d=ndgmr.checkPixelCollision(Entry.stage.wall.right,a.object,0,!1),!d&&e&&(a.collision=Entry.Utils.COLLISION.NONE),d&&e&&(d=!1),d?("free"==c?a.setRotation(-a.getRotation()-2*a.getDirection()):a.setDirection(-a.getDirection()+360),a.collision=Entry.Utils.COLLISION.RIGHT):(e=a.collision==Entry.Utils.COLLISION.LEFT,d=ndgmr.checkPixelCollision(Entry.stage.wall.left, -a.object,0,!1),!d&&e&&(a.collision=Entry.Utils.COLLISION.NONE),d&&e&&(d=!1),d&&("free"==c?a.setRotation(-a.getRotation()-2*a.getDirection()):a.setDirection(-a.getDirection()+360),a.collision=Entry.Utils.COLLISION.LEFT)));return b.callReturn()}; -Blockly.Blocks.flip_arrow_horizontal={init:function(){this.setColour("#A751E3");this.appendDummyInput().appendField(Lang.Blocks.MOVING_flip_arrow_horizontal).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/moving_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.flip_arrow_horizontal=function(a,b){a.setDirection(a.getDirection()+180);return b.callReturn()}; -Blockly.Blocks.flip_arrow_vertical={init:function(){this.setColour("#A751E3");this.appendDummyInput().appendField(Lang.Blocks.MOVING_flip_arrow_vertical).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/moving_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.flip_arrow_vertical=function(a,b){a.setDirection(a.getDirection()+180);return b.callReturn()}; +Entry.block.bounce_wall=function(b,a){var c=b.parent.getRotateMethod(),d="free"==c?(b.getRotation()+b.getDirection()).mod(360):b.getDirection(),e=Entry.Utils.COLLISION.NONE;if(90>d&&0<=d||360>d&&270<=d){var e=b.collision==Entry.Utils.COLLISION.UP,f=ndgmr.checkPixelCollision(Entry.stage.wall.up,b.object,0,!1);!f&&e&&(b.collision=Entry.Utils.COLLISION.NONE);f&&e&&(f=!1);f?("free"==c?b.setRotation(-b.getRotation()-2*b.getDirection()+180):b.setDirection(-b.getDirection()+180),b.collision=Entry.Utils.COLLISION.UP): +(e=b.collision==Entry.Utils.COLLISION.DOWN,f=ndgmr.checkPixelCollision(Entry.stage.wall.down,b.object,0,!1),!f&&e&&(b.collision=Entry.Utils.COLLISION.NONE),f&&e&&(f=!1),f&&("free"==c?b.setRotation(-b.getRotation()-2*b.getDirection()+180):b.setDirection(-b.getDirection()+180),b.collision=Entry.Utils.COLLISION.DOWN))}else 270>d&&90<=d&&(e=b.collision==Entry.Utils.COLLISION.DOWN,f=ndgmr.checkPixelCollision(Entry.stage.wall.down,b.object,0,!1),!f&&e&&(b.collision=Entry.Utils.COLLISION.NONE),f&&e&&(f= +!1),f?("free"==c?b.setRotation(-b.getRotation()-2*b.getDirection()+180):b.setDirection(-b.getDirection()+180),b.collision=Entry.Utils.COLLISION.DOWN):(e=b.collision==Entry.Utils.COLLISION.UP,f=ndgmr.checkPixelCollision(Entry.stage.wall.up,b.object,0,!1),!f&&e&&(b.collision=Entry.Utils.COLLISION.NONE),f&&e&&(f=!1),f&&("free"==c?b.setRotation(-b.getRotation()-2*b.getDirection()+180):b.setDirection(-b.getDirection()+180),b.collision=Entry.Utils.COLLISION.UP)));360>d&&180<=d?(e=b.collision==Entry.Utils.COLLISION.LEFT, +d=ndgmr.checkPixelCollision(Entry.stage.wall.left,b.object,0,!1),!d&&e&&(b.collision=Entry.Utils.COLLISION.NONE),d&&e&&(d=!1),d?("free"==c?b.setRotation(-b.getRotation()-2*b.getDirection()):b.setDirection(-b.getDirection()+360),b.collision=Entry.Utils.COLLISION.LEFT):(e=b.collision==Entry.Utils.COLLISION.RIGHT,d=ndgmr.checkPixelCollision(Entry.stage.wall.right,b.object,0,!1),!d&&e&&(b.collision=Entry.Utils.COLLISION.NONE),d&&e&&(d=!1),d&&("free"==c?b.setRotation(-b.getRotation()-2*b.getDirection()): +b.setDirection(-b.getDirection()+360),b.collision=Entry.Utils.COLLISION.RIGHT))):180>d&&0<=d&&(e=b.collision==Entry.Utils.COLLISION.RIGHT,d=ndgmr.checkPixelCollision(Entry.stage.wall.right,b.object,0,!1),!d&&e&&(b.collision=Entry.Utils.COLLISION.NONE),d&&e&&(d=!1),d?("free"==c?b.setRotation(-b.getRotation()-2*b.getDirection()):b.setDirection(-b.getDirection()+360),b.collision=Entry.Utils.COLLISION.RIGHT):(e=b.collision==Entry.Utils.COLLISION.LEFT,d=ndgmr.checkPixelCollision(Entry.stage.wall.left, +b.object,0,!1),!d&&e&&(b.collision=Entry.Utils.COLLISION.NONE),d&&e&&(d=!1),d&&("free"==c?b.setRotation(-b.getRotation()-2*b.getDirection()):b.setDirection(-b.getDirection()+360),b.collision=Entry.Utils.COLLISION.LEFT)));return a.callReturn()}; +Blockly.Blocks.flip_arrow_horizontal={init:function(){this.setColour("#A751E3");this.appendDummyInput().appendField(Lang.Blocks.MOVING_flip_arrow_horizontal).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/moving_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.flip_arrow_horizontal=function(b,a){b.setDirection(b.getDirection()+180);return a.callReturn()}; +Blockly.Blocks.flip_arrow_vertical={init:function(){this.setColour("#A751E3");this.appendDummyInput().appendField(Lang.Blocks.MOVING_flip_arrow_vertical).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/moving_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.flip_arrow_vertical=function(b,a){b.setDirection(b.getDirection()+180);return a.callReturn()}; Blockly.Blocks.see_angle_object={init:function(){this.setColour("#A751E3");this.appendDummyInput().appendField(Lang.Blocks.MOVING_see_angle_object_1);this.appendDummyInput().appendField(new Blockly.FieldDropdownDynamic("spritesWithMouse"),"VALUE");this.appendDummyInput().appendField(Lang.Blocks.MOVING_see_angle_object_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/moving_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.see_angle_object=function(a,b){var c=b.getField("VALUE",b),d=a.getX(),e=a.getY();if(a.parent.id==c)return b.callReturn();"mouse"==c?(c=Entry.stage.mouseCoordinate.y,d=Entry.stage.mouseCoordinate.x-d,e=c-e):(c=Entry.container.getEntity(c),d=c.getX()-d,e=c.getY()-e);e=0===d&&0===e?a.getDirection()+a.getRotation():0<=d?-Math.atan(e/d)/Math.PI*180+90:-Math.atan(e/d)/Math.PI*180+270;d=a.getDirection()+a.getRotation();a.setRotation(a.getRotation()+e-d);return b.callReturn()}; +Entry.block.see_angle_object=function(b,a){var c=a.getField("VALUE",a),d=b.getX(),e=b.getY();if(b.parent.id==c)return a.callReturn();"mouse"==c?(c=Entry.stage.mouseCoordinate.y,d=Entry.stage.mouseCoordinate.x-d,e=c-e):(c=Entry.container.getEntity(c),d=c.getX()-d,e=c.getY()-e);e=0===d&&0===e?b.getDirection()+b.getRotation():0<=d?-Math.atan(e/d)/Math.PI*180+90:-Math.atan(e/d)/Math.PI*180+270;d=b.getDirection()+b.getRotation();b.setRotation(b.getRotation()+e-d);return a.callReturn()}; Blockly.Blocks.see_angle_direction={init:function(){this.setColour("#A751E3");this.appendDummyInput().appendField(Lang.Blocks.MOVING_see_angle_direction_1);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.MOVING_see_angle_direction_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/moving_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.see_angle_direction=function(a,b){var c=b.getNumberValue("VALUE",b),d=a.getDirection()+a.getRotation();a.setRotation(a.getRotation()+c-d);return b.callReturn()}; +Entry.block.see_angle_direction=function(b,a){var c=a.getNumberValue("VALUE",a),d=b.getDirection()+b.getRotation();b.setRotation(b.getRotation()+c-d);return a.callReturn()}; Blockly.Blocks.rotate_direction={init:function(){this.setColour("#A751E3");this.appendDummyInput().appendField(Lang.Blocks.MOVING_rotate_direction_1);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.MOVING_rotate_direction_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/moving_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.rotate_direction=function(a,b){var c=b.getNumberValue("VALUE",b);a.setDirection(c+a.getDirection());return b.callReturn()}; +Entry.block.rotate_direction=function(b,a){var c=a.getNumberValue("VALUE",a);b.setDirection(c+b.getDirection());return a.callReturn()}; Blockly.Blocks.locate_object_time={init:function(){this.setColour("#A751E3");this.appendDummyInput().appendField(Lang.Blocks.MOVING_locate_object_time_1);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.MOVING_locate_object_time_2);this.appendDummyInput().appendField(new Blockly.FieldDropdownDynamic("spritesWithMouse"),"TARGET");this.appendDummyInput().appendField(Lang.Blocks.MOVING_locate_object_time_3).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+ "block_icon/moving_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.locate_object_time=function(a,b){if(!b.isStart){var c,d,e;d=b.getField("TARGET",b);c=b.getNumberValue("VALUE",b);c=Math.floor(c*Entry.FPS);e=Entry.stage.mouseCoordinate;if(0!=c)"mouse"==d?(d=e.x-a.getX(),e=e.y-a.getY()):(e=Entry.container.getEntity(d),d=e.getX()-a.getX(),e=e.getY()-a.getY()),b.isStart=!0,b.frameCount=c,b.dX=d/b.frameCount,b.dY=e/b.frameCount;else return"mouse"==d?(d=Number(e.x),e=Number(e.y)):(e=Entry.container.getEntity(d),d=e.getX(),e=e.getY()),a.setX(d),a.setY(e),a.brush&& -!a.brush.stop&&a.brush.lineTo(a.getX(),-1*a.getY()),b.callReturn()}if(0!=b.frameCount)return a.setX(a.getX()+b.dX),a.setY(a.getY()+b.dY),b.frameCount--,a.brush&&!a.brush.stop&&a.brush.lineTo(a.getX(),-1*a.getY()),b;delete b.isStart;delete b.frameCount;return b.callReturn()}; +Entry.block.locate_object_time=function(b,a){if(!a.isStart){var c,d,e;d=a.getField("TARGET",a);c=a.getNumberValue("VALUE",a);c=Math.floor(c*Entry.FPS);e=Entry.stage.mouseCoordinate;if(0!=c)"mouse"==d?(d=e.x-b.getX(),e=e.y-b.getY()):(e=Entry.container.getEntity(d),d=e.getX()-b.getX(),e=e.getY()-b.getY()),a.isStart=!0,a.frameCount=c,a.dX=d/a.frameCount,a.dY=e/a.frameCount;else return"mouse"==d?(d=+e.x,e=+e.y):(e=Entry.container.getEntity(d),d=e.getX(),e=e.getY()),b.setX(d),b.setY(e),b.brush&&!b.brush.stop&& +b.brush.lineTo(b.getX(),-1*b.getY()),a.callReturn()}if(0!=a.frameCount)return b.setX(b.getX()+a.dX),b.setY(b.getY()+a.dY),a.frameCount--,b.brush&&!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY()),a;delete a.isStart;delete a.frameCount;return a.callReturn()}; Blockly.Blocks.rotate_absolute={init:function(){this.setColour("#A751E3");this.appendDummyInput().appendField(Lang.Blocks.MOVING_set_direction_by_angle_1);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.MOVING_set_direction_by_angle_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/moving_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.rotate_absolute=function(a,b){var c=b.getNumberValue("VALUE",b);a.setRotation(c);return b.callReturn()}; +Entry.block.rotate_absolute=function(b,a){var c=a.getNumberValue("VALUE",a);b.setRotation(c);return a.callReturn()}; Blockly.Blocks.rotate_relative={init:function(){this.setColour("#A751E3");this.appendDummyInput().appendField(Lang.Blocks.MOVING_add_direction_by_angle_1);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.MOVING_add_direction_by_angle_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/moving_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.rotate_relative=function(a,b){var c=b.getNumberValue("VALUE",b);a.setRotation(c+a.getRotation());return b.callReturn()}; +Entry.block.rotate_relative=function(b,a){var c=a.getNumberValue("VALUE",a);b.setRotation(c+b.getRotation());return a.callReturn()}; Blockly.Blocks.direction_absolute={init:function(){this.setColour("#A751E3");this.appendDummyInput().appendField(Lang.Blocks.MOVING_see_angle_1);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.MOVING_see_angle_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/moving_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.direction_absolute=function(a,b){var c=b.getNumberValue("VALUE",b);a.setDirection(c);return b.callReturn()}; +Entry.block.direction_absolute=function(b,a){var c=a.getNumberValue("VALUE",a);b.setDirection(c);return a.callReturn()}; Blockly.Blocks.direction_relative={init:function(){this.setColour("#A751E3");this.appendDummyInput().appendField(Lang.Blocks.MOVING_rotate_direction_1);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.MOVING_rotate_direction_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/moving_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.direction_relative=function(a,b){var c=b.getNumberValue("VALUE",b);a.setDirection(c+a.getDirection());return b.callReturn()}; +Entry.block.direction_relative=function(b,a){var c=a.getNumberValue("VALUE",a);b.setDirection(c+b.getDirection());return a.callReturn()}; Blockly.Blocks.move_to_angle={init:function(){this.setColour("#A751E3");this.appendDummyInput().appendField(Lang.Blocks.MOVING_move_direction_angle_1);this.appendValueInput("ANGLE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.MOVING_move_direction_angle_2);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.MOVING_move_direction_angle_3).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/moving_03.png", -"*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.move_to_angle=function(a,b){var c=b.getNumberValue("VALUE",b),d=b.getNumberValue("ANGLE",b);a.setX(a.getX()+c*Math.cos((d-90)/180*Math.PI));a.setY(a.getY()-c*Math.sin((d-90)/180*Math.PI));a.brush&&!a.brush.stop&&a.brush.lineTo(a.getX(),-1*a.getY());return b.callReturn()}; +"*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.move_to_angle=function(b,a){var c=a.getNumberValue("VALUE",a),d=a.getNumberValue("ANGLE",a);b.setX(b.getX()+c*Math.cos((d-90)/180*Math.PI));b.setY(b.getY()-c*Math.sin((d-90)/180*Math.PI));b.brush&&!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY());return a.callReturn()}; Blockly.Blocks.rotate_by_time={init:function(){this.setColour("#A751E3");this.appendDummyInput().appendField(Lang.Blocks.MOVING_add_direction_by_angle_time_explain_1);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.MOVING_add_direction_by_angle_time_2);this.appendDummyInput().appendField(Lang.Blocks.MOVING_add_direction_by_angle_time_1);this.appendValueInput("ANGLE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.MOVING_add_direction_by_angle_time_3).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+ -"block_icon/moving_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.rotate_by_time=function(a,b){if(!b.isStart){var c;c=b.getNumberValue("VALUE",b);var d=b.getNumberValue("ANGLE",b);b.isStart=!0;b.frameCount=Math.floor(c*Entry.FPS);b.dAngle=d/b.frameCount}if(0!=b.frameCount)return a.setRotation(a.getRotation()+b.dAngle),b.frameCount--,b;delete b.isStart;delete b.frameCount;return b.callReturn()}; +"block_icon/moving_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.rotate_by_time=function(b,a){if(!a.isStart){var c;c=a.getNumberValue("VALUE",a);var d=a.getNumberValue("ANGLE",a);a.isStart=!0;a.frameCount=Math.floor(c*Entry.FPS);a.dAngle=d/a.frameCount}if(0!=a.frameCount)return b.setRotation(b.getRotation()+a.dAngle),a.frameCount--,a;delete a.isStart;delete a.frameCount;return a.callReturn()}; Blockly.Blocks.direction_relative_duration={init:function(){this.setColour("#A751E3");this.appendDummyInput().appendField(Lang.Blocks.MOVING_direction_relative_duration_1);this.appendValueInput("DURATION").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.MOVING_direction_relative_duration_2);this.appendValueInput("AMOUNT").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.MOVING_direction_relative_duration_3).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+ -"block_icon/moving_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.direction_relative_duration=function(a,b){if(!b.isStart){var c;c=b.getNumberValue("DURATION",b);var d=b.getNumberValue("AMOUNT",b);b.isStart=!0;b.frameCount=Math.floor(c*Entry.FPS);b.dDirection=d/b.frameCount}if(0!=b.frameCount)return a.setDirection(a.getDirection()+b.dDirection),b.frameCount--,b;delete b.isStart;delete b.frameCount;delete b.dDirection;return b.callReturn()};Entry.Neobot={name:"neobot",LOCAL_MAP:["IN1","IN2","IN3","IR","BAT"],REMOTE_MAP:"OUT1 OUT2 OUT3 DCR DCL SND FND OPT".split(" "),setZero:function(){for(var a in Entry.Neobot.REMOTE_MAP)Entry.hw.sendQueue[Entry.Neobot.REMOTE_MAP[a]]=0;Entry.hw.update()},name:"neobot",monitorTemplate:{imgPath:"hw/neobot.png",width:700,height:700,listPorts:{IR:{name:"\ub9ac\ubaa8\ucee8",type:"input",pos:{x:0,y:0}},BAT:{name:"\ubca0\ud130\ub9ac",type:"input",pos:{x:0,y:0}},SND:{name:Lang.Hw.buzzer,type:"output",pos:{x:0, +"block_icon/moving_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.direction_relative_duration=function(b,a){if(!a.isStart){var c;c=a.getNumberValue("DURATION",a);var d=a.getNumberValue("AMOUNT",a);a.isStart=!0;a.frameCount=Math.floor(c*Entry.FPS);a.dDirection=d/a.frameCount}if(0!=a.frameCount)return b.setDirection(b.getDirection()+a.dDirection),a.frameCount--,a;delete a.isStart;delete a.frameCount;delete a.dDirection;return a.callReturn()};Entry.Neobot={name:"neobot",LOCAL_MAP:["IN1","IN2","IN3","IR","BAT"],REMOTE_MAP:"OUT1 OUT2 OUT3 DCR DCL SND FND OPT".split(" "),setZero:function(){for(var b in Entry.Neobot.REMOTE_MAP)Entry.hw.sendQueue[Entry.Neobot.REMOTE_MAP[b]]=0;Entry.hw.update()},name:"neobot",monitorTemplate:{imgPath:"hw/neobot.png",width:700,height:700,listPorts:{IR:{name:"\ub9ac\ubaa8\ucee8",type:"input",pos:{x:0,y:0}},BAT:{name:"\ubca0\ud130\ub9ac",type:"input",pos:{x:0,y:0}},SND:{name:Lang.Hw.buzzer,type:"output",pos:{x:0, y:0}},FND:{name:"FND",type:"output",pos:{x:0,y:0}}},ports:{IN1:{name:"IN1",type:"input",pos:{x:270,y:200}},IN2:{name:"IN2",type:"input",pos:{x:325,y:200}},IN3:{name:"IN3",type:"input",pos:{x:325,y:500}},DCL:{name:"L-Motor",type:"output",pos:{x:270,y:500}},DCR:{name:"R-Motor",type:"output",pos:{x:435,y:500}},OUT1:{name:"OUT1",type:"output",pos:{x:380,y:200}},OUT2:{name:"OUT2",type:"output",pos:{x:435,y:200}},OUT3:{name:"OUT3",type:"output",pos:{x:380,y:500}}},mode:"both"}}; -Blockly.Blocks.neobot_sensor_value={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("").appendField(new Blockly.FieldDropdown([["1\ubc88 \ud3ec\ud2b8","IN1"],["2\ubc88 \ud3ec\ud2b8","IN2"],["3\ubc88 \ud3ec\ud2b8","IN3"],["\ub9ac\ubaa8\ucee8","IR"],["\ubc30\ud130\ub9ac","BAT"]]),"PORT").appendField(" \uac12");this.setOutput(!0,"Number");this.setInputsInline(!0)}};Entry.block.neobot_sensor_value=function(a,b){a=b.getStringField("PORT");return Entry.hw.portData[a]}; +Blockly.Blocks.neobot_sensor_value={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("").appendField(new Blockly.FieldDropdown([["1\ubc88 \ud3ec\ud2b8","IN1"],["2\ubc88 \ud3ec\ud2b8","IN2"],["3\ubc88 \ud3ec\ud2b8","IN3"],["\ub9ac\ubaa8\ucee8","IR"],["\ubc30\ud130\ub9ac","BAT"]]),"PORT").appendField(" \uac12");this.setOutput(!0,"Number");this.setInputsInline(!0)}};Entry.block.neobot_sensor_value=function(b,a){var c=a.getStringField("PORT");return Entry.hw.portData[c]}; Blockly.Blocks.neobot_left_motor={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("\uc67c\ucabd\ubaa8\ud130\ub97c").appendField(new Blockly.FieldDropdown([["\uc55e\uc73c\ub85c","16"],["\ub4a4\ub85c","32"]]),"DIRECTION").appendField(new Blockly.FieldDropdown([["0","0"],["1","1"],["2","2"],["3","3"],["4","4"],["5","5"],["6","6"],["7","7"],["8","8"],["9","9"],["10","10"],["11","11"],["12","12"],["13","13"],["14","14"],["15","15"]]),"SPEED").appendField("\uc758 \uc18d\ub3c4\ub85c \ud68c\uc804").appendField(new Blockly.FieldIcon(Entry.mediaFilePath+ -"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.neobot_left_motor=function(a,b){a=b.getNumberField("SPEED");var c=b.getNumberField("DIRECTION");Entry.hw.sendQueue.DCL=a+c;return b.callReturn()}; -Blockly.Blocks.neobot_stop_left_motor={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("\uc67c\ucabd\ubaa8\ud130 \uc815\uc9c0").appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.neobot_stop_left_motor=function(a,b){Entry.hw.sendQueue.DCL=0;return b.callReturn()}; +"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.neobot_left_motor=function(b,a){var c=a.getNumberField("SPEED"),d=a.getNumberField("DIRECTION");Entry.hw.sendQueue.DCL=c+d;return a.callReturn()}; +Blockly.Blocks.neobot_stop_left_motor={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("\uc67c\ucabd\ubaa8\ud130 \uc815\uc9c0").appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.neobot_stop_left_motor=function(b,a){Entry.hw.sendQueue.DCL=0;return a.callReturn()}; Blockly.Blocks.neobot_right_motor={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("\uc624\ub978\ucabd\ubaa8\ud130\ub97c").appendField(new Blockly.FieldDropdown([["\uc55e\uc73c\ub85c","16"],["\ub4a4\ub85c","32"]]),"DIRECTION").appendField(new Blockly.FieldDropdown([["0","0"],["1","1"],["2","2"],["3","3"],["4","4"],["5","5"],["6","6"],["7","7"],["8","8"],["9","9"],["10","10"],["11","11"],["12","12"],["13","13"],["14","14"],["15","15"]]),"SPEED").appendField("\uc758 \uc18d\ub3c4\ub85c \ud68c\uc804").appendField(new Blockly.FieldIcon(Entry.mediaFilePath+ -"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.neobot_right_motor=function(a,b){a=b.getNumberField("SPEED");var c=b.getNumberField("DIRECTION");Entry.hw.sendQueue.DCR=a+c;return b.callReturn()}; -Blockly.Blocks.neobot_stop_right_motor={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("\uc624\ub978\ucabd\ubaa8\ud130 \uc815\uc9c0").appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.neobot_stop_right_motor=function(a,b){Entry.hw.sendQueue.DCR=0;return b.callReturn()}; +"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.neobot_right_motor=function(b,a){var c=a.getNumberField("SPEED"),d=a.getNumberField("DIRECTION");Entry.hw.sendQueue.DCR=c+d;return a.callReturn()}; +Blockly.Blocks.neobot_stop_right_motor={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("\uc624\ub978\ucabd\ubaa8\ud130 \uc815\uc9c0").appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.neobot_stop_right_motor=function(b,a){Entry.hw.sendQueue.DCR=0;return a.callReturn()}; Blockly.Blocks.neobot_all_motor={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("\uc591\ucabd \ubaa8\ud130\ub97c ");this.appendDummyInput().appendField(new Blockly.FieldDropdown([["0","0"],["1","1"],["2","2"],["3","3"],["4","4"],["5","5"],["6","6"],["7","7"],["8","8"],["9","9"],["10","10"],["11","11"],["12","12"],["13","13"],["14","14"],["15","15"]]),"SPEED").appendField(" \uc758 \uc18d\ub3c4\ub85c ").appendField(new Blockly.FieldDropdown([["\uc804\uc9c4","1"],["\ud6c4\uc9c4", "2"],["\uc81c\uc790\ub9ac \uc88c\ud68c\uc804","3"],["\uc81c\uc790\ub9ac \uc6b0\ud68c\uc804","4"],["\uc88c\ud68c\uc804","5"],["\uc6b0\ud68c\uc804","6"]]),"DIRECTION").appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.neobot_all_motor=function(a,b){b.getNumberField("TYPE");a=b.getNumberField("SPEED");switch(b.getNumberField("DIRECTION")){case 1:Entry.hw.sendQueue.DCL=16+a;Entry.hw.sendQueue.DCR=16+a;break;case 2:Entry.hw.sendQueue.DCL=32+a;Entry.hw.sendQueue.DCR=32+a;break;case 3:Entry.hw.sendQueue.DCL=32+a;Entry.hw.sendQueue.DCR=16+a;break;case 4:Entry.hw.sendQueue.DCL=16+a;Entry.hw.sendQueue.DCR=32+a;break;case 5:Entry.hw.sendQueue.DCL=0;Entry.hw.sendQueue.DCR=16+a;break;case 6:Entry.hw.sendQueue.DCL= -16+a,Entry.hw.sendQueue.DCR=0}return b.callReturn()}; +Entry.block.neobot_all_motor=function(b,a){a.getNumberField("TYPE");var c=a.getNumberField("SPEED");switch(a.getNumberField("DIRECTION")){case 1:Entry.hw.sendQueue.DCL=16+c;Entry.hw.sendQueue.DCR=16+c;break;case 2:Entry.hw.sendQueue.DCL=32+c;Entry.hw.sendQueue.DCR=32+c;break;case 3:Entry.hw.sendQueue.DCL=32+c;Entry.hw.sendQueue.DCR=16+c;break;case 4:Entry.hw.sendQueue.DCL=16+c;Entry.hw.sendQueue.DCR=32+c;break;case 5:Entry.hw.sendQueue.DCL=0;Entry.hw.sendQueue.DCR=16+c;break;case 6:Entry.hw.sendQueue.DCL= +16+c,Entry.hw.sendQueue.DCR=0}return a.callReturn()}; Blockly.Blocks.neobot_set_servo={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(new Blockly.FieldDropdown([["OUT1","1"],["OUT2","2"],["OUT3","3"]]),"PORT").appendField("\ud3ec\ud2b8\uc758 \uc11c\ubcf4\ubaa8\ud130\ub97c").appendField(new Blockly.FieldDropdown([["0\ub3c4","0"],["10\ub3c4","10"],["20\ub3c4","20"],["30\ub3c4","30"],["40\ub3c4","40"],["50\ub3c4","50"],["60\ub3c4","60"],["70\ub3c4","70"],["80\ub3c4","80"],["90\ub3c4","90"],["100\ub3c4","100"],["110\ub3c4", "110"],["120\ub3c4","120"],["130\ub3c4","130"],["140\ub3c4","140"],["150\ub3c4","150"],["160\ub3c4","160"],["170\ub3c4","170"],["180\ub3c4","180"]]),"DEGREE").appendField(" \uc774\ub3d9").appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.neobot_set_servo=function(a,b){a=b.getNumberField("PORT");var c=b.getNumberField("DEGREE");Entry.hw.sendQueue["OUT"+a]=c;3===a&&(a=4);Entry.hw.sendQueue.OPT|=a;return b.callReturn()}; +Entry.block.neobot_set_servo=function(b,a){var c=a.getNumberField("PORT"),d=a.getNumberField("DEGREE");Entry.hw.sendQueue["OUT"+c]=d;3===c&&(c=4);Entry.hw.sendQueue.OPT|=c;return a.callReturn()}; Blockly.Blocks.neobot_set_output={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(new Blockly.FieldDropdown([["OUT1","1"],["OUT2","2"],["OUT3","3"]]),"PORT").appendField("\ubc88 \ud3ec\ud2b8\uc758 \uac12\uc744");this.appendValueInput("VALUE").setCheck(["Number"]);this.appendDummyInput().appendField("\ub9cc\ud07c \ucd9c\ub825").appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0); -this.setNextStatement(!0)}};Entry.block.neobot_set_output=function(a,b){a=b.getStringField("PORT",b);var c=b.getNumberValue("VALUE",b),d=a;0>c?c=0:255d?d=0:255a&&(a=0);Entry.hw.sendQueue.FND=a;return b.callReturn()}; +Entry.block.neobot_set_fnd=function(b,a){var c=a.getNumberValue("VALUE",a);255c&&(c=0);Entry.hw.sendQueue.FND=c;return a.callReturn()}; Blockly.Blocks.neobot_play_note_for={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("\uba5c\ub85c\ub514").appendField(new Blockly.FieldDropdown([["\ubb34\uc74c","0"],[Lang.General.note_c,"1"],[Lang.General.note_c+"#","2"],[Lang.General.note_d,"3"],[Lang.General.note_d+"#","4"],[Lang.General.note_e,"5"],[Lang.General.note_f,"6"],[Lang.General.note_f+"#","7"],[Lang.General.note_g,"8"],[Lang.General.note_g+"#","9"],[Lang.General.note_a,"10"],[Lang.General.note_a+"#","11"], [Lang.General.note_b,"12"]]),"NOTE").appendField("\uc744(\ub97c)").appendField(new Blockly.FieldDropdown([["1","0"],["2","1"],["3","2"],["4","3"],["5","4"],["6","5"]]),"OCTAVE").appendField("\uc625\ud0c0\ube0c\ub85c").appendField(new Blockly.FieldDropdown([["2\ubd84\uc74c\ud45c","2"],["4\ubd84\uc74c\ud45c","4"],["8\ubd84\uc74c\ud45c","8"],["16\ubd84\uc74c\ud45c","16"]]),"DURATION");this.appendDummyInput().appendField("\uae38\uc774\ub9cc\ud07c \uc18c\ub9ac\ub0b4\uae30").appendField(new Blockly.FieldIcon(Entry.mediaFilePath+ "block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.neobot_play_note_for=function(a,b){a=Entry.hw.sendQueue;if(b.isStart){if(1==b.timeFlag)return b;delete b.timeFlag;delete b.isStart;Entry.hw.sendQueue.SND=0;Entry.engine.isContinue=!1;return b.callReturn()}var c=b.getNumberField("NOTE",b),d=b.getNumberField("OCTAVE",b),e=b.getNumberField("DURATION",b),c=c+12*d;b.isStart=!0;b.timeFlag=1;65=c)return this.setRobotisData(b),this.update(),a.callReturn();if(a.isStart){if(1==a.timeFlag)return this.setRobotisData(null),a;delete a.timeFlag;delete a.isStart;Entry.engine.isContinue=!1;this.update();return a.callReturn()}a.isStart=!0;a.timeFlag=1;this.setRobotisData(b);setTimeout(function(){a.timeFlag= -0},c);return a},wait:function(a,b){Entry.hw.socket.send(JSON.stringify(a));for(var c=a=(new Date).getTime();c=c)return this.setRobotisData(a),this.update(),b.callReturn();if(b.isStart){if(1==b.timeFlag)return this.setRobotisData(null),b;delete b.timeFlag;delete b.isStart;Entry.engine.isContinue=!1;this.update();return b.callReturn()}b.isStart=!0;b.timeFlag=1;this.setRobotisData(a);setTimeout(function(){b.timeFlag= +0},c);return b},wait:function(b,a){Entry.hw.socket.send(JSON.stringify(b));for(var c=(new Date).getTime(),d=c;dc&&(c=0);return Entry.Robotis_carCont.postCallReturn(b,[[d,e+(a-1)*f,f,c]],Entry.Robotis_openCM70.delay)}; +"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.robotis_openCM70_aux_servo_position=function(b,a){var c=a.getField("PORT",a),d=a.getNumberValue("VALUE"),e=Entry.Robotis_openCM70.INSTRUCTION.WRITE,f=0,g=0,f=Entry.Robotis_openCM70.CONTROL_TABLE.AUX_SERVO_POSITION[0],g=Entry.Robotis_openCM70.CONTROL_TABLE.AUX_SERVO_POSITION[1];1023d&&(d=0);return Entry.Robotis_carCont.postCallReturn(a,[[e,f+(c-1)*g,g,d]],Entry.Robotis_openCM70.delay)}; Blockly.Blocks.robotis_openCM70_aux_led_module={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(new Blockly.FieldDropdown([[Lang.Blocks.robotis_common_port_3,"3"],[Lang.Blocks.robotis_common_port_4,"4"],[Lang.Blocks.robotis_common_port_5,"5"],[Lang.Blocks.robotis_common_port_6,"6"]]),"PORT").appendField(Lang.Blocks.robotis_openCM70_aux_led_module_1).appendField(new Blockly.FieldDropdown([[Lang.Blocks.robotis_cm_led_both+Lang.Blocks.robotis_common_off,"0"],[Lang.Blocks.robotis_cm_led_right+ Lang.Blocks.robotis_common_on,"1"],[Lang.Blocks.robotis_cm_led_left+Lang.Blocks.robotis_common_on,"2"],[Lang.Blocks.robotis_cm_led_both+Lang.Blocks.robotis_common_on,"3"]]),"LED_MODULE");this.appendDummyInput().appendField(Lang.Blocks.robotis_common_set).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.robotis_openCM70_aux_led_module=function(a,b){a=b.getField("PORT",b);var c=b.getField("LED_MODULE",b),d=Entry.Robotis_openCM70.INSTRUCTION.WRITE,e,f;e=Entry.Robotis_openCM70.CONTROL_TABLE.AUX_LED_MODULE[0];f=Entry.Robotis_openCM70.CONTROL_TABLE.AUX_LED_MODULE[1];return Entry.Robotis_carCont.postCallReturn(b,[[d,e+(a-1)*f,f,c]],Entry.Robotis_openCM70.delay)}; +Entry.block.robotis_openCM70_aux_led_module=function(b,a){var c=a.getField("PORT",a),d=a.getField("LED_MODULE",a),e=Entry.Robotis_openCM70.INSTRUCTION.WRITE,f=0,g=0,f=Entry.Robotis_openCM70.CONTROL_TABLE.AUX_LED_MODULE[0],g=Entry.Robotis_openCM70.CONTROL_TABLE.AUX_LED_MODULE[1];return Entry.Robotis_carCont.postCallReturn(a,[[e,f+(c-1)*g,g,d]],Entry.Robotis_openCM70.delay)}; Blockly.Blocks.robotis_openCM70_aux_custom={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(new Blockly.FieldDropdown([[Lang.Blocks.robotis_common_port_3,"3"],[Lang.Blocks.robotis_common_port_4,"4"],[Lang.Blocks.robotis_common_port_5,"5"],[Lang.Blocks.robotis_common_port_6,"6"]]),"PORT").appendField(Lang.Blocks.robotis_openCM70_aux_custom_1);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.robotis_common_set).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+ -"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.robotis_openCM70_aux_custom=function(a,b){a=b.getField("PORT",b);var c=b.getNumberValue("VALUE"),d=Entry.Robotis_openCM70.INSTRUCTION.WRITE,e,f;e=Entry.Robotis_openCM70.CONTROL_TABLE.AUX_CUSTOM[0];f=Entry.Robotis_openCM70.CONTROL_TABLE.AUX_CUSTOM[1];return Entry.Robotis_carCont.postCallReturn(b,[[d,e+(a-1)*f,f,c]],Entry.Robotis_openCM70.delay)}; +"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.robotis_openCM70_aux_custom=function(b,a){var c=a.getField("PORT",a),d=a.getNumberValue("VALUE"),e=Entry.Robotis_openCM70.INSTRUCTION.WRITE,f=0,g=0,f=Entry.Robotis_openCM70.CONTROL_TABLE.AUX_CUSTOM[0],g=Entry.Robotis_openCM70.CONTROL_TABLE.AUX_CUSTOM[1];return Entry.Robotis_carCont.postCallReturn(a,[[e,f+(c-1)*g,g,d]],Entry.Robotis_openCM70.delay)}; Blockly.Blocks.robotis_openCM70_cm_custom={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.robotis_cm_custom);this.appendDummyInput().appendField("(");this.appendValueInput("ADDRESS").setCheck(["Number","String"]);this.appendDummyInput().appendField(")");this.appendDummyInput().appendField(Lang.Blocks.robotis_common_case_01);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.robotis_common_set).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+ -"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.robotis_openCM70_cm_custom=function(a,b){a=Entry.Robotis_openCM70.INSTRUCTION.WRITE;var c,d;c=b.getNumberValue("ADDRESS");d=b.getNumberValue("VALUE");return Entry.Robotis_carCont.postCallReturn(b,[[a,c,65535a&&(a=0);createjs.Sound.setVolume(a);return b.callReturn()}; +Entry.block.sound_volume_change=function(b,a){var c=a.getNumberValue("VALUE",a)/100,c=c+createjs.Sound.getVolume();1c&&(c=0);createjs.Sound.setVolume(c);return a.callReturn()}; Blockly.Blocks.sound_volume_set={init:function(){this.setColour("#A4D01D");this.appendDummyInput().appendField(Lang.Blocks.SOUND_sound_volume_set_1);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.SOUND_sound_volume_set_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/sound_03.png","*"));this.setInputsInline(!0);this.setNextStatement(!0);this.setPreviousStatement(!0)}}; -Entry.block.sound_volume_set=function(a,b){a=b.getNumberValue("VALUE",b)/100;1a&&(a=0);createjs.Sound.setVolume(a);return b.callReturn()};Blockly.Blocks.sound_silent_all={init:function(){this.setColour("#A4D01D");this.appendDummyInput().appendField(Lang.Blocks.SOUND_sound_silent_all).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/sound_03.png","*"));this.setInputsInline(!0);this.setNextStatement(!0);this.setPreviousStatement(!0)}}; -Entry.block.sound_silent_all=function(a,b){createjs.Sound.stop();return b.callReturn()};Blockly.Blocks.get_sounds={init:function(){this.setColour("#A4D01D");this.appendDummyInput().appendField("");this.appendDummyInput().appendField(new Blockly.FieldDropdownDynamic("sounds"),"VALUE");this.appendDummyInput().appendField(" ");this.setOutput(!0,"String");this.setInputsInline(!0)}};Entry.block.get_sounds=function(a,b){return b.getStringField("VALUE")}; +Entry.block.sound_volume_set=function(b,a){var c=a.getNumberValue("VALUE",a)/100;1c&&(c=0);createjs.Sound.setVolume(c);return a.callReturn()};Blockly.Blocks.sound_silent_all={init:function(){this.setColour("#A4D01D");this.appendDummyInput().appendField(Lang.Blocks.SOUND_sound_silent_all).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/sound_03.png","*"));this.setInputsInline(!0);this.setNextStatement(!0);this.setPreviousStatement(!0)}}; +Entry.block.sound_silent_all=function(b,a){createjs.Sound.stop();return a.callReturn()};Blockly.Blocks.get_sounds={init:function(){this.setColour("#A4D01D");this.appendDummyInput().appendField("");this.appendDummyInput().appendField(new Blockly.FieldDropdownDynamic("sounds"),"VALUE");this.appendDummyInput().appendField(" ");this.setOutput(!0,"String");this.setInputsInline(!0)}};Entry.block.get_sounds=function(b,a){return a.getStringField("VALUE")}; Blockly.Blocks.sound_something_with_block={init:function(){this.setColour("#A4D01D");this.appendDummyInput().appendField(Lang.Blocks.SOUND_sound_something_1);this.appendValueInput("VALUE").setCheck(["String","Number"]);this.appendDummyInput().appendField(Lang.Blocks.SOUND_sound_something_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/sound_03.png","*"));this.setInputsInline(!0);this.setNextStatement(!0);this.setPreviousStatement(!0)}}; -Entry.block.sound_something_with_block=function(a,b){var c=b.getStringValue("VALUE",b);(a=a.parent.getSound(c))&&createjs.Sound.play(a.id);return b.callReturn()}; +Entry.block.sound_something_with_block=function(b,a){var c=a.getStringValue("VALUE",a);(c=b.parent.getSound(c))&&createjs.Sound.play(c.id);return a.callReturn()}; Blockly.Blocks.sound_something_second_with_block={init:function(){this.setColour("#A4D01D");this.appendDummyInput().appendField(Lang.Blocks.SOUND_sound_something_second_1);this.appendValueInput("VALUE").setCheck(["String","Number"]);this.appendDummyInput().appendField(" ").appendField(Lang.Blocks.SOUND_sound_something_second_2);this.appendValueInput("SECOND").setCheck(["String","Number"]);this.appendDummyInput().appendField(Lang.Blocks.SOUND_sound_something_second_3).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+ -"block_icon/sound_03.png","*"));this.setInputsInline(!0);this.setNextStatement(!0);this.setPreviousStatement(!0)}};Entry.block.sound_something_second_with_block=function(a,b){var c=b.getStringValue("VALUE",b),d=b.getNumberValue("SECOND",b);(a=a.parent.getSound(c))&&createjs.Sound.play(a.id,{startTime:0,duration:1E3*d});return b.callReturn()}; +"block_icon/sound_03.png","*"));this.setInputsInline(!0);this.setNextStatement(!0);this.setPreviousStatement(!0)}};Entry.block.sound_something_second_with_block=function(b,a){var c=a.getStringValue("VALUE",a),d=a.getNumberValue("SECOND",a);(c=b.parent.getSound(c))&&createjs.Sound.play(c.id,{startTime:0,duration:1E3*d});return a.callReturn()}; Blockly.Blocks.sound_something_wait_with_block={init:function(){this.setColour("#A4D01D");this.appendDummyInput().appendField(Lang.Blocks.SOUND_sound_something_wait_1);this.appendValueInput("VALUE").setCheck(["String","Number"]);this.appendDummyInput().appendField(Lang.Blocks.SOUND_sound_something_wait_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/sound_03.png","*"));this.setInputsInline(!0);this.setNextStatement(!0);this.setPreviousStatement(!0)}}; -Entry.block.sound_something_wait_with_block=function(a,b){if(b.isPlay){if(1==b.playState)return b;delete b.playState;delete b.isPlay;return b.callReturn()}b.isPlay=!0;b.playState=1;var c=b.getStringValue("VALUE",b);if(a=a.parent.getSound(c))createjs.Sound.play(a.id),setTimeout(function(){b.playState=0},1E3*a.duration);return b}; +Entry.block.sound_something_wait_with_block=function(b,a){if(a.isPlay){if(1==a.playState)return a;delete a.playState;delete a.isPlay;return a.callReturn()}a.isPlay=!0;a.playState=1;var c=a.getStringValue("VALUE",a);if(c=b.parent.getSound(c))createjs.Sound.play(c.id),setTimeout(function(){a.playState=0},1E3*c.duration);return a}; Blockly.Blocks.sound_something_second_wait_with_block={init:function(){this.setColour("#A4D01D");this.appendDummyInput().appendField(Lang.Blocks.SOUND_sound_something_second_wait_1);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.SOUND_sound_something_second_wait_2).appendField(" ");this.appendValueInput("SECOND").setCheck(["String","Number"]);this.appendDummyInput().appendField(Lang.Blocks.SOUND_sound_something_second_wait_3).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+ "block_icon/sound_03.png","*"));this.setInputsInline(!0);this.setNextStatement(!0);this.setPreviousStatement(!0)}}; -Entry.block.sound_something_second_wait_with_block=function(a,b){if(b.isPlay){if(1==b.playState)return b;delete b.isPlay;delete b.playState;return b.callReturn()}b.isPlay=!0;b.playState=1;var c=b.getStringValue("VALUE",b);if(a=a.parent.getSound(c)){var d=createjs.Sound.play(a.id);a=b.getNumberValue("SECOND",b);setTimeout(function(){d.stop();b.playState=0},1E3*a);d.addEventListener("complete",function(b){})}return b}; +Entry.block.sound_something_second_wait_with_block=function(b,a){if(a.isPlay){if(1==a.playState)return a;delete a.isPlay;delete a.playState;return a.callReturn()}a.isPlay=!0;a.playState=1;var c=a.getStringValue("VALUE",a);if(c=b.parent.getSound(c)){var d=createjs.Sound.play(c.id),c=a.getNumberValue("SECOND",a);setTimeout(function(){d.stop();a.playState=0},1E3*c);d.addEventListener("complete",function(a){})}return a}; Blockly.Blocks.sound_from_to={init:function(){this.setColour("#A4D01D");this.appendDummyInput().appendField(Lang.Blocks.SOUND_sound_from_to_1);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.SOUND_sound_from_to_2);this.appendValueInput("START").setCheck(["String","Number"]);this.appendDummyInput().appendField(Lang.Blocks.SOUND_sound_from_to_3);this.appendValueInput("END").setCheck(["String","Number"]);this.appendDummyInput().appendField(Lang.Blocks.SOUND_sound_from_to_4).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+ -"block_icon/sound_03.png","*"));this.setInputsInline(!0);this.setNextStatement(!0);this.setPreviousStatement(!0)}};Entry.block.sound_from_to=function(a,b){var c=b.getStringValue("VALUE",b);if(a=a.parent.getSound(c)){var c=1E3*b.getNumberValue("START",b),d=1E3*b.getNumberValue("END",b);createjs.Sound.play(a.id,{startTime:Math.min(c,d),duration:Math.max(c,d)-Math.min(c,d)})}return b.callReturn()}; +"block_icon/sound_03.png","*"));this.setInputsInline(!0);this.setNextStatement(!0);this.setPreviousStatement(!0)}};Entry.block.sound_from_to=function(b,a){var c=a.getStringValue("VALUE",a);if(c=b.parent.getSound(c)){var d=1E3*a.getNumberValue("START",a),e=1E3*a.getNumberValue("END",a);createjs.Sound.play(c.id,{startTime:Math.min(d,e),duration:Math.max(d,e)-Math.min(d,e)})}return a.callReturn()}; Blockly.Blocks.sound_from_to_and_wait={init:function(){this.setColour("#A4D01D");this.appendDummyInput().appendField(Lang.Blocks.SOUND_sound_from_to_and_wait_1);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.SOUND_sound_from_to_and_wait_2);this.appendValueInput("START").setCheck(["String","Number"]);this.appendDummyInput().appendField(Lang.Blocks.SOUND_sound_from_to_and_wait_3);this.appendValueInput("END").setCheck(["String","Number"]); this.appendDummyInput().appendField(Lang.Blocks.SOUND_sound_from_to_and_wait_4).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/sound_03.png","*"));this.setInputsInline(!0);this.setNextStatement(!0);this.setPreviousStatement(!0)}}; -Entry.block.sound_from_to_and_wait=function(a,b){if(b.isPlay){if(1==b.playState)return b;delete b.isPlay;delete b.playState;return b.callReturn()}b.isPlay=!0;b.playState=1;var c=b.getStringValue("VALUE",b);if(a=a.parent.getSound(c)){var d=1E3*b.getNumberValue("START",b),e=1E3*b.getNumberValue("END",b),c=Math.min(d,e),d=Math.max(d,e)-c;createjs.Sound.play(a.id,{startTime:c,duration:d});setTimeout(function(){b.playState=0},d)}return b};Blockly.Blocks.when_run_button_click={init:function(){this.setColour("#3BBD70");this.appendDummyInput().appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/start_icon_play.png","*","start")).appendField(Lang.Blocks.START_when_run_button_click);this.setInputsInline(!0);this.setNextStatement(!0)}};Entry.block.when_run_button_click=function(a,b){return b.callReturn()}; +Entry.block.sound_from_to_and_wait=function(b,a){if(a.isPlay){if(1==a.playState)return a;delete a.isPlay;delete a.playState;return a.callReturn()}a.isPlay=!0;a.playState=1;var c=a.getStringValue("VALUE",a);if(c=b.parent.getSound(c)){var d=1E3*a.getNumberValue("START",a),e=1E3*a.getNumberValue("END",a),f=Math.min(d,e),d=Math.max(d,e)-f;createjs.Sound.play(c.id,{startTime:f,duration:d});setTimeout(function(){a.playState=0},d)}return a};Blockly.Blocks.when_run_button_click={init:function(){this.setColour("#3BBD70");this.appendDummyInput().appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/start_icon_play.png","*","start")).appendField(Lang.Blocks.START_when_run_button_click);this.setInputsInline(!0);this.setNextStatement(!0)}};Entry.block.when_run_button_click=function(b,a){return a.callReturn()}; Blockly.Blocks.press_some_key={init:function(){this.setColour("#3BBD70");this.appendDummyInput().appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/start_icon_keyboard.png","*","start")).appendField(Lang.Blocks.START_press_some_key_1).appendField(new Blockly.FieldDropdown([["q","81"],["w","87"],["e","69"],["r","82"],["a","65"],["s","83"],["d","68"],[Lang.Blocks.START_press_some_key_up,"38"],[Lang.Blocks.START_press_some_key_down,"40"],[Lang.Blocks.START_press_some_key_left,"37"],[Lang.Blocks.START_press_some_key_right, -"39"],[Lang.Blocks.START_press_some_key_enter,"13"],[Lang.Blocks.START_press_some_key_space,"32"]]),"VALUE").appendField(Lang.Blocks.START_press_some_key_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/start_03.png","*"));this.setInputsInline(!0);this.setNextStatement(!0)}};Entry.block.press_some_key=function(a,b){return b.callReturn()}; -Blockly.Blocks.when_some_key_pressed={init:function(){this.setColour("#3BBD70");this.appendDummyInput().appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/start_icon_keyboard.png","*","start")).appendField(Lang.Blocks.START_press_some_key_1).appendField(new Blockly.FieldKeydownInput("81"),"VALUE").appendField(Lang.Blocks.START_press_some_key_2);this.setInputsInline(!0);this.setNextStatement(!0)}};Entry.block.when_some_key_pressed=function(a,b){return b.callReturn()}; -Blockly.Blocks.mouse_clicked={init:function(){this.setColour("#3BBD70");this.appendDummyInput().appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/start_icon_mouse.png","*","start")).appendField(Lang.Blocks.START_mouse_clicked);this.setInputsInline(!0);this.setNextStatement(!0)}};Entry.block.mouse_clicked=function(a,b){return b.callReturn()}; -Blockly.Blocks.mouse_click_cancled={init:function(){this.setColour("#3BBD70");this.appendDummyInput().appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/start_icon_mouse.png","*","start")).appendField(Lang.Blocks.START_mouse_click_cancled);this.setInputsInline(!0);this.setNextStatement(!0)}};Entry.block.mouse_click_cancled=function(a,b){return b.callReturn()}; -Blockly.Blocks.when_object_click={init:function(){this.setColour("#3BBD70");this.appendDummyInput().appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/start_icon_mouse.png","*","start")).appendField(Lang.Blocks.START_when_object_click);this.setInputsInline(!0);this.setNextStatement(!0)}};Entry.block.when_object_click=function(a,b){return b.callReturn()}; -Blockly.Blocks.when_object_click_canceled={init:function(){this.setColour("#3BBD70");this.appendDummyInput().appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/start_icon_mouse.png","*","start")).appendField(Lang.Blocks.START_when_object_click_canceled);this.setInputsInline(!0);this.setNextStatement(!0)}};Entry.block.when_object_click_canceled=function(a,b){return b.callReturn()}; -Blockly.Blocks.when_some_key_click={init:function(){this.setColour("#3BBD70");this.appendDummyInput().appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/start_icon_keyboard.png","*","start")).appendField(Lang.Blocks.START_when_some_key_click);this.setInputsInline(!0);this.setNextStatement(!0)}};Entry.block.when_some_key_click=function(a,b){return b.callReturn()}; -Blockly.Blocks.when_message_cast={init:function(){this.setColour("#3BBD70");this.appendDummyInput().appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/start_icon_signal.png","*","start")).appendField(Lang.Blocks.START_when_message_cast_1).appendField(new Blockly.FieldDropdownDynamic("messages"),"VALUE").appendField(Lang.Blocks.START_when_message_cast_2);this.setInputsInline(!0);this.setNextStatement(!0)},whenAdd:function(a){var b=Entry.variableContainer;b&&b.addRef("_messageRefs",a)}, -whenRemove:function(a){var b=Entry.variableContainer;b&&b.removeRef("_messageRefs",a)}};Entry.block.when_message_cast=function(a,b){return b.callReturn()}; -Blockly.Blocks.message_cast={init:function(){this.setColour("#3BBD70");this.appendDummyInput().appendField(Lang.Blocks.START_message_cast_1).appendField(new Blockly.FieldDropdownDynamic("messages"),"VALUE").appendField(Lang.Blocks.START_message_cast_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/start_03.png","*"));this.setInputsInline(!0);this.setInputsInline(!0);this.setNextStatement(!0);this.setPreviousStatement(!0)},whenAdd:function(a){var b=Entry.variableContainer;b&&b.addRef("_messageRefs", -a)},whenRemove:function(a){var b=Entry.variableContainer;b&&b.removeRef("_messageRefs",a)}};Entry.block.message_cast=function(a,b){a=b.getField("VALUE",b);var c=Entry.isExist(a,"id",Entry.variableContainer.messages_);if("null"==a||!c)throw Error("value can not be null or undefined");Entry.container.mapEntityIncludeCloneOnScene(Entry.engine.raiseKeyEvent,["when_message_cast",a]);return b.callReturn()}; -Blockly.Blocks.message_cast_wait={init:function(){this.setColour("#3BBD70");this.appendDummyInput().appendField(Lang.Blocks.START_message_send_wait_1).appendField(new Blockly.FieldDropdownDynamic("messages"),"VALUE").appendField(Lang.Blocks.START_message_send_wait_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/start_03.png","*"));this.setInputsInline(!0);this.setNextStatement(!0);this.setPreviousStatement(!0)},whenAdd:function(a){var b=Entry.variableContainer;b&&b.addRef("_messageRefs", -a)},whenRemove:function(a){var b=Entry.variableContainer;b&&b.removeRef("_messageRefs",a)}}; -Entry.block.message_cast_wait=function(a,b){if(b.runningScript){a=b.runningScript;for(var c=a.length,d=0;da.array_.length)throw Error("can not remove value from array");a.array_.splice(d-1,1);a.updateView();return b.callReturn()}; +"block_icon/variable_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.remove_value_from_list=function(b,a){var c=a.getField("LIST",a),d=a.getValue("VALUE",a),c=Entry.variableContainer.getList(c,b);if(!c.array_||isNaN(d)||d>c.array_.length)throw Error("can not remove value from array");c.array_.splice(d-1,1);c.updateView();return a.callReturn()}; Blockly.Blocks.insert_value_to_list={init:function(){this.setColour("#E457DC");this.appendDummyInput().appendField(Lang.Blocks.VARIABLE_insert_value_to_list_1);this.appendValueInput("DATA").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.VARIABLE_insert_value_to_list_2);this.appendDummyInput().appendField(new Blockly.FieldDropdownDynamic("lists"),"LIST");this.appendDummyInput().appendField(Lang.Blocks.VARIABLE_insert_value_to_list_3);this.appendValueInput("INDEX").setCheck(["Number", "String"]);this.appendDummyInput().appendField(Lang.Blocks.VARIABLE_insert_value_to_list_4).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/variable_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.insert_value_to_list=function(a,b){var c=b.getField("LIST",b),d=b.getValue("DATA",b),e=b.getValue("INDEX",b);a=Entry.variableContainer.getList(c,a);if(!a.array_||isNaN(e)||0==e||e>a.array_.length+1)throw Error("can not insert value to array");a.array_.splice(e-1,0,{data:d});a.updateView();return b.callReturn()}; +Entry.block.insert_value_to_list=function(b,a){var c=a.getField("LIST",a),d=a.getValue("DATA",a),e=a.getValue("INDEX",a),c=Entry.variableContainer.getList(c,b);if(!c.array_||isNaN(e)||0==e||e>c.array_.length+1)throw Error("can not insert value to array");c.array_.splice(e-1,0,{data:d});c.updateView();return a.callReturn()}; Blockly.Blocks.change_value_list_index={init:function(){this.setColour("#E457DC");this.appendDummyInput().appendField(Lang.Blocks.VARIABLE_change_value_list_index_1);this.appendDummyInput().appendField(new Blockly.FieldDropdownDynamic("lists"),"LIST");this.appendDummyInput().appendField(Lang.Blocks.VARIABLE_change_value_list_index_2);this.appendValueInput("INDEX").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.VARIABLE_change_value_list_index_3);this.appendValueInput("DATA").setCheck(["Number", "String"]);this.appendDummyInput().appendField(Lang.Blocks.VARIABLE_change_value_list_index_4).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/variable_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.change_value_list_index=function(a,b){var c=b.getField("LIST",b),d=b.getValue("DATA",b),e=b.getValue("INDEX",b);a=Entry.variableContainer.getList(c,a);if(!a.array_||isNaN(e)||e>a.array_.length)throw Error("can not insert value to array");a.array_[e-1].data=d;a.updateView();return b.callReturn()}; +Entry.block.change_value_list_index=function(b,a){var c=a.getField("LIST",a),d=a.getValue("DATA",a),e=a.getValue("INDEX",a),c=Entry.variableContainer.getList(c,b);if(!c.array_||isNaN(e)||e>c.array_.length)throw Error("can not insert value to array");c.array_[e-1].data=d;c.updateView();return a.callReturn()}; Blockly.Blocks.value_of_index_from_list={init:function(){this.setColour("#E457DC");this.appendDummyInput().appendField(Lang.Blocks.VARIABLE_value_of_index_from_list_1);this.appendDummyInput().appendField(new Blockly.FieldDropdownDynamic("lists"),"LIST");this.appendDummyInput().appendField(Lang.Blocks.VARIABLE_value_of_index_from_list_2);this.appendValueInput("INDEX").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.VARIABLE_value_of_index_from_list_3);this.setOutput(!0, -"String");this.setInputsInline(!0)}};Entry.block.value_of_index_from_list=function(a,b){var c=b.getField("LIST",b);b=b.getValue("INDEX",b);a=Entry.variableContainer.getList(c,a);b=Entry.getListRealIndex(b,a);if(!a.array_||isNaN(b)||b>a.array_.length)throw Error("can not insert value to array");return a.array_[b-1].data}; -Blockly.Blocks.length_of_list={init:function(){this.setColour("#E457DC");this.appendDummyInput().appendField(Lang.Blocks.VARIABLE_length_of_list_1);this.appendDummyInput().appendField(new Blockly.FieldDropdownDynamic("lists"),"LIST");this.appendDummyInput().appendField(Lang.Blocks.VARIABLE_length_of_list_2);this.setOutput(!0,"Number");this.setInputsInline(!0)}};Entry.block.length_of_list=function(a,b){a=b.getField("LIST",b);return Entry.variableContainer.getList(a).array_.length}; +"String");this.setInputsInline(!0)}};Entry.block.value_of_index_from_list=function(b,a){var c=a.getField("LIST",a),d=a.getValue("INDEX",a),c=Entry.variableContainer.getList(c,b),d=Entry.getListRealIndex(d,c);if(!c.array_||isNaN(d)||d>c.array_.length)throw Error("can not insert value to array");return c.array_[d-1].data}; +Blockly.Blocks.length_of_list={init:function(){this.setColour("#E457DC");this.appendDummyInput().appendField(Lang.Blocks.VARIABLE_length_of_list_1);this.appendDummyInput().appendField(new Blockly.FieldDropdownDynamic("lists"),"LIST");this.appendDummyInput().appendField(Lang.Blocks.VARIABLE_length_of_list_2);this.setOutput(!0,"Number");this.setInputsInline(!0)}};Entry.block.length_of_list=function(b,a){var c=a.getField("LIST",a);return Entry.variableContainer.getList(c).array_.length}; Blockly.Blocks.show_list={init:function(){this.setColour("#E457DC");this.appendDummyInput().appendField(Lang.Blocks.VARIABLE_show_list_1);this.appendDummyInput().appendField(new Blockly.FieldDropdownDynamic("lists"),"LIST").appendField(Lang.Blocks.VARIABLE_show_list_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/variable_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.show_list=function(a,b){a=b.getField("LIST",b);Entry.variableContainer.getList(a).setVisible(!0);return b.callReturn()}; +Entry.block.show_list=function(b,a){var c=a.getField("LIST",a);Entry.variableContainer.getList(c).setVisible(!0);return a.callReturn()}; Blockly.Blocks.hide_list={init:function(){this.setColour("#E457DC");this.appendDummyInput().appendField(Lang.Blocks.VARIABLE_hide_list_1);this.appendDummyInput().appendField(new Blockly.FieldDropdownDynamic("lists"),"LIST").appendField(Lang.Blocks.VARIABLE_hide_list_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/variable_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.hide_list=function(a,b){a=b.getField("LIST",b);Entry.variableContainer.getList(a).setVisible(!1);return b.callReturn()}; +Entry.block.hide_list=function(b,a){var c=a.getField("LIST",a);Entry.variableContainer.getList(c).setVisible(!1);return a.callReturn()}; Blockly.Blocks.options_for_list={init:function(){this.setColour("#E457DC");this.appendDummyInput().appendField("");this.appendDummyInput("VALUE").appendField(new Blockly.FieldDropdown([[Lang.Blocks.VARIABLE_list_option_first,"FIRST"],[Lang.Blocks.VARIABLE_list_option_last,"LAST"],[Lang.Blocks.VARIABLE_list_option_random,"RANDOM"]]),"OPERATOR");this.appendDummyInput().appendField(" ");this.setOutput(!0,"Number");this.setInputsInline(!0)}}; -Entry.block.options_for_list=function(a,b){return b.getField("OPERATOR",b)}; +Entry.block.options_for_list=function(b,a){return a.getField("OPERATOR",a)}; Blockly.Blocks.set_visible_answer={init:function(){this.setColour("#E457DC");this.appendDummyInput().appendField(Lang.Blocks.VARIABLE_get_canvas_input_value);this.appendDummyInput().appendField(new Blockly.FieldDropdown([[Lang.Blocks.CALC_timer_visible_show,"SHOW"],[Lang.Blocks.CALC_timer_visible_hide,"HIDE"]]),"BOOL");this.appendDummyInput().appendField("").appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/variable_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0); -this.setNextStatement(!0)},whenAdd:function(){Entry.container&&Entry.container.showProjectAnswer()},whenRemove:function(a){Entry.container&&Entry.container.hideProjectAnswer(a)}};Entry.block.set_visible_answer=function(a,b){"HIDE"==b.getField("BOOL",b)?Entry.container.inputValue.setVisible(!1):Entry.container.inputValue.setVisible(!0);return b.callReturn()}; +this.setNextStatement(!0)},whenAdd:function(){Entry.container&&Entry.container.showProjectAnswer()},whenRemove:function(b){Entry.container&&Entry.container.hideProjectAnswer(b)}};Entry.block.set_visible_answer=function(b,a){"HIDE"==a.getField("BOOL",a)?Entry.container.inputValue.setVisible(!1):Entry.container.inputValue.setVisible(!0);return a.callReturn()}; Blockly.Blocks.is_included_in_list={init:function(){this.setColour("#E457DC");this.appendDummyInput().appendField(Lang.Blocks.VARIABLE_is_included_in_list_1);this.appendDummyInput().appendField(new Blockly.FieldDropdownDynamic("lists"),"LIST");this.appendDummyInput().appendField(Lang.Blocks.VARIABLE_is_included_in_list_2);this.appendValueInput("DATA").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.VARIABLE_is_included_in_list_3);this.setOutput(!0,"Boolean");this.setInputsInline(!0)}}; -Entry.block.is_included_in_list=function(a,b){a=b.getField("LIST",b);b=b.getStringValue("DATA",b);a=Entry.variableContainer.getList(a);if(!a)return!1;a=a.array_;for(var c=0,d=a.length;ca||0>d||a>e||d>e||b.splice.call(this,d,0,b.splice.call(this,a,1)[0])};a.sort=function(){};a.fromJSON=function(){};a.toJSON=function(){for(var b=[],a=0,e=this.length;a=b.x&&e-c<=b.y&&e+a.height+c>=b.y}; -Entry.Utils.colorDarken=function(a,b){function c(b){2!=b.length&&(b="0"+b);return b}var d,e;7===a.length?(d=parseInt(a.substr(1,2),16),e=parseInt(a.substr(3,2),16),a=parseInt(a.substr(5,2),16)):(d=parseInt(a.substr(1,2),16),e=parseInt(a.substr(2,2),16),a=parseInt(a.substr(3,2),16));b=void 0===b?.7:b;d=c(Math.floor(d*b).toString(16));e=c(Math.floor(e*b).toString(16));a=c(Math.floor(a*b).toString(16));return"#"+d+e+a}; -Entry.Utils.colorLighten=function(a,b){b=0===b?0:b||20;a=Entry.Utils.hexToHsl(a);a.l+=b/100;a.l=Math.min(1,Math.max(0,a.l));return Entry.Utils.hslToHex(a)};Entry.Utils.bound01=function(a,b){var c=a;"string"==typeof c&&-1!=c.indexOf(".")&&1===parseFloat(c)&&(a="100%");c="string"===typeof a&&-1!=a.indexOf("%");a=Math.min(b,Math.max(0,parseFloat(a)));c&&(a=parseInt(a*b,10)/100);return 1E-6>Math.abs(a-b)?1:a%b/parseFloat(b)}; -Entry.Utils.hexToHsl=function(a){var b,c;7===a.length?(b=parseInt(a.substr(1,2),16),c=parseInt(a.substr(3,2),16),a=parseInt(a.substr(5,2),16)):(b=parseInt(a.substr(1,2),16),c=parseInt(a.substr(2,2),16),a=parseInt(a.substr(3,2),16));b=Entry.Utils.bound01(b,255);c=Entry.Utils.bound01(c,255);a=Entry.Utils.bound01(a,255);var d=Math.max(b,c,a),e=Math.min(b,c,a),f,g=(d+e)/2;if(d==e)f=e=0;else{var h=d-e,e=.5c&&(c+=1);1c?a:c<2/3?b+(a-b)*(2/3-c)*6:b}function c(b){return 1==b.length?"0"+b:""+b}var d,e;e=Entry.Utils.bound01(a.h,360);d=Entry.Utils.bound01(a.s,1);a=Entry.Utils.bound01(a.l,1);if(0===d)d=a=e=a;else{var f=.5>a?a*(1+d):a+d-a*d,g=2*a-f;d=b(g,f,e+1/3);a=b(g,f,e);e=b(g,f,e-1/3)}a*=255;e*=255;return"#"+[c(Math.round(255*d).toString(16)),c(Math.round(a).toString(16)),c(Math.round(e).toString(16))].join("")}; -Entry.Utils.bindGlobalEvent=function(a){var b=$(document);void 0===a&&(a="resize mousedown mousemove keydown keyup dispose".split(" "));-1Entry.pressedKeys.indexOf(a)&&Entry.pressedKeys.push(a);Entry.keyPressed.notify(b)}));-1$1://$2").replace(/([xA1-xFEa-z0-9_-]+@[xA1-xFEa-z0-9-]+.[a-z0-9-]+)/gi,"$1"):""};Entry.generateHash=function(){return("0000"+(Math.random()*Math.pow(36,4)<<0).toString(36)).substr(-4)}; -Entry.addEventListener=function(a,b){this.events_||(this.events_={});this.events_[a]||(this.events_[a]=[]);b instanceof Function&&this.events_[a].push(b);return!0};Entry.dispatchEvent=function(a,b){this.events_||(this.events_={});if(this.events_[a])for(var c=0,d=this.events_[a].length;c=f?(parseFloat(a)+parseFloat(b)).toFixed(e):(parseFloat(a)+parseFloat(b)).toFixed(f):parseInt(a)+parseInt(b)}; -Entry.hex2rgb=function(a){return(a=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a))?{r:parseInt(a[1],16),g:parseInt(a[2],16),b:parseInt(a[3],16)}:null};Entry.rgb2hex=function(a,b,c){return"#"+(16777216+(a<<16)+(b<<8)+c).toString(16).slice(1)};Entry.generateRgb=function(){return{r:Math.floor(256*Math.random()),g:Math.floor(256*Math.random()),b:Math.floor(256*Math.random())}};Entry.adjustValueWithMaxMin=function(a,b,c){return a>c?c:ab.y+b.height||a.x+a.widthb.x+b.width)};Entry.bindAnimationCallback=function(a,b){a.addEventListener("webkitAnimationEnd",b,!1);a.addEventListener("animationend",b,!1);a.addEventListener("oanimationend",b,!1)};Entry.cloneSimpleObject=function(a){var b={},c;for(c in a)b[c]=a[c];return b};Entry.nodeListToArray=function(a){for(var b=Array(a.length),c=-1,d=a.length;++c!==d;b[c]=a[c]);return b}; -Entry.computeInputWidth=function(a){var b=document.createElement("span");b.className="tmp-element";b.innerHTML=a.replace(/&/g,"&").replace(//g,">");document.body.appendChild(b);a=b.offsetWidth;document.body.removeChild(b);return Number(a+10)+"px"};Entry.isArrowOrBackspace=function(a){return-1<[37,38,39,40,8].indexOf(a)};Entry.hexStringToBin=function(a){for(var b=[],c=0;cd&&(d=h.index)}return 0b&&(b=e))}return Math.min(b,20)};Entry.convertToRoundedDecimals=function(a,b){return isNaN(a)||!this.isFloat(a)?a:Number(Math.round(a+"e"+b)+"e-"+b)};Entry.attachEventListener=function(a,b,c){setTimeout(function(){a.addEventListener(b,c)},0)};Entry.deAttachEventListener=function(a,b,c){a.removeEventListener(b,c)}; -Entry.isEmpty=function(a){if(!a)return!0;for(var b in a)if(a.hasOwnProperty(b))return!1;return!0};Entry.Utils.disableContextmenu=function(a){if(a)$(a).on("contextmenu",function(b){b.stopPropagation();b.preventDefault();return!1})};Entry.Utils.isRightButton=function(a){return 2==a.button||a.ctrlKey};Entry.Utils.isTouchEvent=function(a){return"mousedown"!==a.type.toLowerCase()};Entry.Utils.inherit=function(a,b){function c(){}c.prototype=a.prototype;b.prototype=new c;return b}; -Entry.bindAnimationCallbackOnce=function(a,b){a.one("webkitAnimationEnd animationendo animationend",b)};Entry.Utils.isInInput=function(a){return"textarea"==a.target.type||"text"==a.target.type};Entry.Utils.isFunction=function(a){return"function"===typeof a}; -Entry.Utils.addFilters=function(a,b){a=a.elem("defs");var c=a.elem("filter",{id:"entryTrashcanFilter_"+b});c.elem("feGaussianBlur",{"in":"SourceAlpha",stdDeviation:2,result:"blur"});c.elem("feOffset",{"in":"blur",dx:1,dy:1,result:"offsetBlur"});c=c.elem("feMerge");c.elem("feMergeNode",{"in":"offsetBlur"});c.elem("feMergeNode",{"in":"SourceGraphic"},c);c=a.elem("filter",{id:"entryBlockShadowFilter_"+b,height:"200%"});c.elem("feOffset",{result:"offOut",in:"SourceGraphic",dx:0,dy:1});c.elem("feColorMatrix", -{result:"matrixOut",in:"offOut",type:"matrix",values:"0.7 0 0 0 0 0 0.7 0 0 0 0 0 0.7 0 0 0 0 0 1 0"});c.elem("feBlend",{in:"SourceGraphic",in1:"offOut",mode:"normal"});b=a.elem("filter",{id:"entryBlockHighlightFilter_"+b});b.elem("feOffset",{result:"offOut",in:"SourceGraphic",dx:0,dy:0});b.elem("feColorMatrix",{result:"matrixOut",in:"offOut",type:"matrix",values:"1.3 0 0 0 0 0 1.3 0 0 0 0 0 1.3 0 0 0 0 0 1 0"})}; -Entry.Utils.addBlockPattern=function(a,b){a=a.elem("pattern",{id:"blockHoverPattern_"+b,class:"blockHoverPattern",patternUnits:"userSpaceOnUse",patternTransform:"translate(12, 0)",x:0,y:0,width:125,height:33,style:"display: none"});b=a.elem("g");for(var c=b.elem("rect",{x:0,y:0,width:125,height:33}),d=Entry.mediaFilePath+"block_pattern_(order).png",e=1;5>e;e++)b.elem("image",{class:"pattern"+e,href:d.replace("(order)",e),x:0,y:0,width:125,height:33});return{pattern:a,rect:c}}; -Entry.Utils.COLLISION={NONE:0,UP:1,RIGHT:2,LEFT:3,DOWN:4};Entry.Utils.createMouseEvent=function(a,b){var c=document.createEvent("MouseEvent");c.initMouseEvent(a,!0,!0,window,0,0,0,b.clientX,b.clientY,!1,!1,!1,!1,0,null);return c};Entry.Utils.xmlToJsonData=function(a){a=$.parseXML(a);var b=[];a=a.childNodes[0].childNodes;for(var c in a){var d=a[c];if(d.tagName){var e={category:d.getAttribute("id"),blocks:[]},d=d.childNodes;for(c in d){var f=d[c];f.tagName&&(f=f.getAttribute("type"))&&e.blocks.push(f)}b.push(e)}}return b}; -Entry.Utils.stopProjectWithToast=function(a,b){b=b||"\ub7f0\ud0c0\uc784 \uc5d0\ub7ec \ubc1c\uc0dd";Entry.toast&&Entry.toast.alert(Lang.Msgs.warn,Lang.Workspace.check_runtime_error,!0);Entry.engine&&Entry.engine.toggleStop();"workspace"===Entry.type&&(Entry.container.selectObject(a.getCode().object.id,!0),a.view.getBoard().activateBlock(a));throw Error(b);}; -window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(a){window.setTimeout(a,1E3/60)}}();Entry.Model=function(a,b){var c=Entry.Model;c.generateSchema(a);c.generateSetter(a);c.generateObserve(a);(void 0===b||b)&&Object.seal(a);return a}; -(function(a){a.generateSchema=function(b){var a=b.schema;if(void 0!==a){a=JSON.parse(JSON.stringify(a));b.data={};for(var d in a)(function(d){b.data[d]=a[d];Object.defineProperty(b,d,{get:function(){return b.data[d]}})})(d);b._toJSON=this._toJSON}};a.generateSetter=function(b){b.set=this.set};a.set=function(b,a){var d={},e;for(e in this.data)void 0!==b[e]&&(b[e]===this.data[e]?delete b[e]:(d[e]=this.data[e],this.data[e]=b[e]instanceof Array?b[e].concat():b[e]));a||this.notify(Object.keys(b),d)};a.generateObserve= -function(b){b.observers=[];b.observe=this.observe;b.unobserve=this.unobserve;b.notify=this.notify};a.observe=function(b,a,d,e){d=new Entry.Observer(this.observers,b,a,d);if(!1!==e)b[a]([]);return d};a.unobserve=function(b){b.destroy()};a.notify=function(b,a){"string"===typeof b&&(b=[b]);var d=this;d.observers.map(function(e){var f=b;void 0!==e.attrs&&(f=Entry.Utils.intersectArray(e.attrs,b));if(f.length)e.object[e.funcName](f.map(function(b){return{name:b,object:d,oldValue:a[b]}}))})};a._toJSON=function(){var b= -{},a;for(a in this.data)b[a]=this.data[a];return b}})(Entry.Model);Entry.Observer=function(a,b,c,d){this.parent=a;this.object=b;this.funcName=c;this.attrs=d;a.push(this)};(function(a){a.destroy=function(){var b=this.parent,a=b.indexOf(this);-1/,d;d=a instanceof HTMLElement?$(a):a instanceof jQuery?a:c.test(a)?$(a):$("<"+a+">");if(void 0===b)return d;b.id&&d.attr("id",b.id);b.class&&d.addClass(b.class);b.classes&&b.classes.map(function(b){d.addClass(b)});b.src&&d.attr("src",b.src);b.parent&&b.parent.append(d);d.bindOnClick=function(){var b,a,c=function(b){b.stopImmediatePropagation();b.handled||(b.handled=!0,a.call(this,b))};1a.x+a.width+this.width?(this.object.x=a.x+a.width+this.width/2,b+="e"):(this.object.x=a.x-this.width/2,b+="w");this.notch.type!=b&&(this.object.removeChild(this.notch),this.notch=this.createSpeakNotch(b),this.object.addChild(this.notch));Entry.requestUpdate= +this.setNextStatement(!0)}};Entry.block.xbot_lcd=function(b,a){var c=Entry.hw.sendQueue,d=a.getNumberField("LINE",a),e=a.getStringValue("VALUE",a);0==d?(c.lcdNum=0,c.lcdTxt=e):1==d&&(c.lcdNum=1,c.lcdTxt=e);return a.callReturn()};Entry.Collection=function(b){this.length=0;this._hashMap={};this._observers=[];this.set(b)}; +(function(b,a){b.set=function(b){for(;this.length;)a.pop.call(this);var d=this._hashMap,e;for(e in d)delete d[e];if(void 0!==b){e=0;for(var f=b.length;eb||0>d||b>e||d>e||a.splice.call(this,d,0,a.splice.call(this,b,1)[0])};b.sort=function(){};b.fromJSON=function(){};b.toJSON=function(){for(var a=[],b=0,e=this.length;b/,d;d=b instanceof HTMLElement?$(b):b instanceof jQuery?b:c.test(b)?$(b):$("<"+b+">");if(void 0===a)return d;a.id&&d.attr("id",a.id);a.class&&d.addClass(a.class);a.classes&&a.classes.map(function(a){d.addClass(a)});a.src&&d.attr("src",a.src);a.parent&&a.parent.append(d);d.bindOnClick=function(){var a,b,c=function(a){a.stopImmediatePropagation();a.handled||(a.handled=!0,b.call(this,a))};1b.x+b.width+this.width?(this.object.x=b.x+b.width+this.width/2,a+="e"):(this.object.x=b.x-this.width/2,a+="w");this.notch.type!=a&&(this.object.removeChild(this.notch),this.notch=this.createSpeakNotch(a),this.object.addChild(this.notch));Entry.requestUpdate= !0}; -Entry.Dialog.prototype.createSpeakNotch=function(a){var b=new createjs.Shape;b.type=a;"ne"==a?b.graphics.f("#f5f5f5").ss(2,"round").s("#6FC0DD").mt(0,this.height+this.padding-1.5).lt(-10,this.height+this.padding+20).lt(20,this.height+this.padding-1.5):"nw"==a?b.graphics.f("#f5f5f5").ss(2,"round").s("#6FC0DD").mt(this.width,this.height+this.padding-1.5).lt(this.width+10,this.height+this.padding+20).lt(this.width-20,this.height+this.padding-1.5):"se"==a?b.graphics.f("#f5f5f5").ss(2,"round").s("#6FC0DD").mt(0,-this.padding+ -1.5).lt(-10,-this.padding-20).lt(20,-this.padding+1.5):"sw"==a&&b.graphics.f("#f5f5f5").ss(2,"round").s("#6FC0DD").mt(this.width,-this.padding+1.5).lt(this.width+10,-this.padding-20).lt(this.width-20,-this.padding+1.5);return b};Entry.Dialog.prototype.remove=function(){Entry.stage.unloadDialog(this);this.parent.dialog=null};Entry.DoneProject=function(a){this.generateView(a)};var p=Entry.DoneProject.prototype;p.init=function(a){this.projectId=a};p.generateView=function(a){var b=Entry.createElement("div");b.addClass("entryContainerDoneWorkspace");this.doneContainer=b;var c=Entry.createElement("iframe");c.setAttribute("id","doneProjectframe");c.setAttribute("frameborder",0);c.setAttribute("src","/api/iframe/project/"+a);this.doneProjectFrame=c;this.doneContainer.appendChild(c);b.addClass("entryRemove")};p.getView=function(){return this.doneContainer}; -p.resize=function(){document.getElementById("entryContainerWorkspaceId");var a=document.getElementById("doneProjectframe"),b=this.doneContainer.offsetWidth;a.width=b+"px";a.height=9*b/16+"px"};Entry.Engine=function(){function a(b){var a=[37,38,39,40,32],d=b.keyCode||b.which,e=Entry.stage.inputField;32==d&&e&&e.hasFocus()||-1c;c++)(function(c){var e=Entry.createElement("td","progressCell"+c);e.bindOnClick(function(){Entry.engine.setSpeedMeter(b[c])});a.appendChild(e)})(c);this.view_.insertBefore(this.speedProgress_,this.maximizeButton);this.speedProgress_.appendChild(a);this.speedHandle_=Entry.createElement("div","entrySpeedHandleWorkspace");c=(Entry.interfaceState.canvasWidth-84)/5;$(this.speedHandle_).draggable({axis:"x",grid:[c,c],containment:[80,0,4*c+80,0],drag:function(b,a){b=(a.position.left-80)/(Entry.interfaceState.canvasWidth- -84)*5;b=Math.floor(b);0>b||Entry.engine.setSpeedMeter(Entry.engine.speeds[b])}});this.view_.insertBefore(this.speedHandle_,this.maximizeButton);this.setSpeedMeter(Entry.FPS)}}; -Entry.Engine.prototype.setSpeedMeter=function(a){var b=this.speeds.indexOf(a);0>b||(b=Math.min(4,b),b=Math.max(0,b),this.speedPanelOn&&(this.speedHandle_.style.left=(Entry.interfaceState.canvasWidth-80)/10*(2*b+1)+80-9+"px"),Entry.FPS!=a&&(clearInterval(this.ticker),this.ticker=setInterval(this.update,Math.floor(1E3/a)),Entry.FPS=a))};Entry.Engine.prototype.start=function(a){createjs.Ticker.setFPS(Entry.FPS);this.ticker=setInterval(this.update,Math.floor(1E3/Entry.FPS))}; -Entry.Engine.prototype.stop=function(){clearInterval(this.ticker);this.ticker=null};Entry.Engine.prototype.update=function(){Entry.engine.isState("run")&&(Entry.engine.computeObjects(),Entry.hw.update())};Entry.Engine.prototype.computeObjects=function(){Entry.container.mapObjectOnScene(this.computeFunction)};Entry.Engine.prototype.computeFunction=function(a){a.script.tick()}; -Entry.Engine.computeThread=function(a,b){Entry.engine.isContinue=!0;for(a=!1;b&&Entry.engine.isContinue&&!a;){Entry.engine.isContinue=!b.isRepeat;var c=b.run();a=c&&c===b;b=c}return b};Entry.Engine.prototype.isState=function(a){return-1c;c++)(function(c){var e=Entry.createElement("td","progressCell"+c);e.bindOnClick(function(){Entry.engine.setSpeedMeter(a[c])});b.appendChild(e)})(c);this.view_.insertBefore(this.speedProgress_,this.maximizeButton);this.speedProgress_.appendChild(b);this.speedHandle_=Entry.createElement("div","entrySpeedHandleWorkspace");c=(Entry.interfaceState.canvasWidth-84)/5;$(this.speedHandle_).draggable({axis:"x",grid:[c,c],containment:[80,0,4*c+80,0],drag:function(a,b){var c=(b.position.left-80)/(Entry.interfaceState.canvasWidth- +84)*5,c=Math.floor(c);0>c||Entry.engine.setSpeedMeter(Entry.engine.speeds[c])}});this.view_.insertBefore(this.speedHandle_,this.maximizeButton);this.setSpeedMeter(Entry.FPS)}}; +Entry.Engine.prototype.setSpeedMeter=function(b){var a=this.speeds.indexOf(b);0>a||(a=Math.min(4,a),a=Math.max(0,a),this.speedPanelOn&&(this.speedHandle_.style.left=(Entry.interfaceState.canvasWidth-80)/10*(2*a+1)+80-9+"px"),Entry.FPS!=b&&(clearInterval(this.ticker),this.ticker=setInterval(this.update,Math.floor(1E3/b)),Entry.FPS=b))};Entry.Engine.prototype.start=function(b){createjs.Ticker.setFPS(Entry.FPS);this.ticker=setInterval(this.update,Math.floor(1E3/Entry.FPS))}; +Entry.Engine.prototype.stop=function(){clearInterval(this.ticker);this.ticker=null};Entry.Engine.prototype.update=function(){Entry.engine.isState("run")&&(Entry.engine.computeObjects(),Entry.hw.update())};Entry.Engine.prototype.computeObjects=function(){Entry.container.mapObjectOnScene(this.computeFunction)};Entry.Engine.prototype.computeFunction=function(b){b.script.tick()}; +Entry.Engine.computeThread=function(b,a){Entry.engine.isContinue=!0;for(var c=!1;a&&Entry.engine.isContinue&&!c;){Entry.engine.isContinue=!a.isRepeat;var d=a.run(),c=d&&d===a;a=d}return a};Entry.Engine.prototype.isState=function(b){return-1=b&&Entry.stage.moveSprite(a)}; -Entry.Engine.prototype.raiseKeyEvent=function(a,b){return a.parent.script.raiseEvent(b[0],a,String(b[1]))};Entry.Engine.prototype.updateMouseView=function(){var a=Entry.stage.mouseCoordinate;this.mouseView.textContent="X : "+a.x+", Y : "+a.y;this.mouseView.removeClass("entryRemove")};Entry.Engine.prototype.hideMouseView=function(){this.mouseView.addClass("entryRemove")}; -Entry.Engine.prototype.toggleFullscreen=function(){if(this.popup)this.popup.remove(),this.popup=null;else{this.popup=new Entry.Popup;if("workspace"!=Entry.type){var a=$(document);$(this.popup.body_).css("top",a.scrollTop());$("body").css("overflow","hidden");popup.window_.appendChild(Entry.stage.canvas.canvas)}popup.window_.appendChild(Entry.engine.view_)}Entry.windowResized.notify()}; +Entry.Engine.prototype.togglePause=function(){var b=Entry.engine.projectTimer;"pause"==this.state?(b.pausedTime+=(new Date).getTime()-b.pauseStart,b.isPaused?b.pauseStart=(new Date).getTime():delete b.pauseStart,this.state="run",this.pauseButton.innerHTML=Lang.Workspace.pause,this.runButton.addClass("entryRemove"),this.runButton2&&this.runButton2.addClass("entryRemove")):(this.state="pause",b.isPaused&&(b.pausedTime+=(new Date).getTime()-b.pauseStart),b.pauseStart=(new Date).getTime(),this.pauseButton.innerHTML= +Lang.Workspace.restart,this.runButton.removeClass("entryRemove"),this.stopButton.removeClass("entryRemove"),this.runButton2&&this.runButton2.removeClass("entryRemove"))};Entry.Engine.prototype.fireEvent=function(b){"run"==this.state&&Entry.container.mapEntityIncludeCloneOnScene(this.raiseEvent,b)};Entry.Engine.prototype.raiseEvent=function(b,a){b.parent.script.raiseEvent(a,b)}; +Entry.Engine.prototype.fireEventOnEntity=function(b,a){"run"==this.state&&Entry.container.mapEntityIncludeCloneOnScene(this.raiseEventOnEntity,[a,b])};Entry.Engine.prototype.raiseEventOnEntity=function(b,a){b===a[0]&&b.parent.script.raiseEvent(a[1],b)}; +Entry.Engine.prototype.captureKeyEvent=function(b){var a=b.keyCode,c=Entry.type;b.ctrlKey&&"workspace"==c?83==a?(b.preventDefault(),Entry.dispatchEvent("saveWorkspace")):82==a?(b.preventDefault(),Entry.engine.run()):90==a&&(b.preventDefault(),console.log("engine"),Entry.dispatchEvent(b.shiftKey?"redo":"undo")):Entry.engine.isState("run")&&Entry.container.mapEntityIncludeCloneOnScene(Entry.engine.raiseKeyEvent,["keyPress",a]);Entry.engine.isState("stop")&&"workspace"===c&&37<=a&&40>=a&&Entry.stage.moveSprite(b)}; +Entry.Engine.prototype.raiseKeyEvent=function(b,a){return b.parent.script.raiseEvent(a[0],b,String(a[1]))};Entry.Engine.prototype.updateMouseView=function(){var b=Entry.stage.mouseCoordinate;this.mouseView.textContent="X : "+b.x+", Y : "+b.y;this.mouseView.removeClass("entryRemove")};Entry.Engine.prototype.hideMouseView=function(){this.mouseView.addClass("entryRemove")}; +Entry.Engine.prototype.toggleFullscreen=function(){if(this.popup)this.popup.remove(),this.popup=null;else{this.popup=new Entry.Popup;if("workspace"!=Entry.type){var b=$(document);$(this.popup.body_).css("top",b.scrollTop());$("body").css("overflow","hidden");popup.window_.appendChild(Entry.stage.canvas.canvas)}popup.window_.appendChild(Entry.engine.view_)}Entry.windowResized.notify()}; Entry.Engine.prototype.exitFullScreen=function(){document.webkitIsFullScreen||document.mozIsFullScreen||document.isFullScreen||(Entry.engine.footerView_.removeClass("entryRemove"),Entry.engine.headerView_.removeClass("entryRemove"));Entry.windowResized.notify()};Entry.Engine.prototype.showProjectTimer=function(){Entry.engine.projectTimer&&this.projectTimer.setVisible(!0)}; -Entry.Engine.prototype.hideProjectTimer=function(){var a=this.projectTimer;if(a&&a.isVisible()&&!this.isState("run")){for(var b=Entry.container.getAllObjects(),c=["get_project_timer_value","reset_project_timer","set_visible_project_timer","choose_project_timer_action"],d=0,e=b.length;dthis.direction)==(0<=a&&180>a)||(this.setScaleX(-this.getScaleX()),Entry.stage.updateObject(),this.flip=!this.flip);this.direction=a.mod(360);this.object.direction=this.direction;this.isClone||this.parent.updateRotationView();Entry.dispatchEvent("updateObject");Entry.requestUpdate=!0}; -Entry.EntityObject.prototype.setRotation=function(a){"free"!=this.parent.getRotateMethod()&&(a=0);this.rotation=a.mod(360);this.object.rotation=this.rotation;this.updateDialog();this.isClone||this.parent.updateRotationView();Entry.dispatchEvent("updateObject");Entry.requestUpdate=!0};Entry.EntityObject.prototype.getRotation=function(){return this.rotation};Entry.EntityObject.prototype.setRegX=function(a){"textBox"==this.type&&(a=0);this.regX=a;this.object.regX=this.regX;Entry.requestUpdate=!0}; -Entry.EntityObject.prototype.getRegX=function(){return this.regX};Entry.EntityObject.prototype.setRegY=function(a){"textBox"==this.type&&(a=0);this.regY=a;this.object.regY=this.regY;Entry.requestUpdate=!0};Entry.EntityObject.prototype.getRegY=function(){return this.regY};Entry.EntityObject.prototype.setScaleX=function(a){this.scaleX=a;this.object.scaleX=this.scaleX;this.parent.updateCoordinateView();this.updateDialog();Entry.requestUpdate=!0};Entry.EntityObject.prototype.getScaleX=function(){return this.scaleX}; -Entry.EntityObject.prototype.setScaleY=function(a){this.scaleY=a;this.object.scaleY=this.scaleY;this.parent.updateCoordinateView();this.updateDialog();Entry.requestUpdate=!0};Entry.EntityObject.prototype.getScaleY=function(){return this.scaleY};Entry.EntityObject.prototype.setSize=function(a){1>a&&(a=1);a/=this.getSize();this.setScaleX(this.getScaleX()*a);this.setScaleY(this.getScaleY()*a);this.isClone||this.parent.updateCoordinateView();Entry.requestUpdate=!0}; -Entry.EntityObject.prototype.getSize=function(){return(this.getWidth()*Math.abs(this.getScaleX())+this.getHeight()*Math.abs(this.getScaleY()))/2};Entry.EntityObject.prototype.setWidth=function(a){this.width=a;this.object.width=this.width;this.textObject&&this.getLineBreak()&&(this.textObject.lineWidth=this.width);this.updateDialog();this.updateBG();Entry.requestUpdate=!0};Entry.EntityObject.prototype.getWidth=function(){return this.width}; -Entry.EntityObject.prototype.setHeight=function(a){this.height=a;this.textObject&&(this.object.height=this.height,this.alignTextBox());this.updateDialog();this.updateBG();Entry.requestUpdate=!0};Entry.EntityObject.prototype.getHeight=function(){return this.height};Entry.EntityObject.prototype.setColour=function(a){a||(a="#000000");this.colour=a;this.textObject&&(this.textObject.color=this.colour);Entry.requestUpdate=!0};Entry.EntityObject.prototype.getColour=function(){return this.colour}; -Entry.EntityObject.prototype.setBGColour=function(a){a||(a="transparent");this.bgColor=a;this.updateBG();Entry.requestUpdate=!0};Entry.EntityObject.prototype.getBGColour=function(){return this.bgColor};Entry.EntityObject.prototype.setUnderLine=function(a){void 0===a&&(a=!1);this.underLine=a;this.textObject.underLine=a;Entry.requestUpdate=!0};Entry.EntityObject.prototype.getUnderLine=function(){return this.underLine}; -Entry.EntityObject.prototype.setStrike=function(a){void 0===a&&(a=!1);this.strike=a;this.textObject.strike=a;Entry.requestUpdate=!0};Entry.EntityObject.prototype.getStrike=function(){return this.strike};Entry.EntityObject.prototype.getFont=function(){var a=[];this.fontBold&&a.push("bold");this.fontItalic&&a.push("italic");a.push(this.getFontSize()+"px");a.push(this.fontType);return a.join(" ")}; -Entry.EntityObject.prototype.setFont=function(a){if("textBox"==this.parent.objectType&&this.font!==a){a||(a="20px Nanum Gothic");var b=a.split(" "),c;if(c=-1=l?g=[1,0,0,0,0,0,k,h,0,0,0,-1*h,k,0,0,0,0,0,1,0,0,0,0,0,1]:.66>=l?g=[k,0,h,0,0,0,1,0,0,0,h,0,k,0,0,0,0,0,1,0,0,0,0,0,1]:.99>=l&&(g=[k,h,0,0,0,-1*h,k,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1]);g=(new createjs.ColorMatrix).concat(g);g=new createjs.ColorMatrixFilter(g);e.push(g);a.alpha=b.alpha=f(b.alpha,0,1);a.filters=e}(a,b),b.cache(0,0,this.getWidth(), +Entry.EntityObject.prototype.restoreEntity=function(b){var a=this.toJSON();this.syncModel_(b);Entry.dispatchEvent("updateObject");Entry.stateManager&&Entry.stateManager.addCommand("restore object",this,this.restoreEntity,a)};Entry.EntityObject.prototype.setX=function(b){"number"==typeof b&&(this.x=b,this.object.x=this.x,this.isClone||this.parent.updateCoordinateView(),this.updateDialog(),Entry.requestUpdate=!0)};Entry.EntityObject.prototype.getX=function(){return this.x}; +Entry.EntityObject.prototype.setY=function(b){"number"==typeof b&&(this.y=b,this.object.y=-this.y,this.isClone||this.parent.updateCoordinateView(),this.updateDialog(),Entry.requestUpdate=!0)};Entry.EntityObject.prototype.getY=function(){return this.y};Entry.EntityObject.prototype.getDirection=function(){return this.direction}; +Entry.EntityObject.prototype.setDirection=function(b,a){b||(b=0);"vertical"!=this.parent.getRotateMethod()||a||(0<=this.direction&&180>this.direction)==(0<=b&&180>b)||(this.setScaleX(-this.getScaleX()),Entry.stage.updateObject(),this.flip=!this.flip);this.direction=b.mod(360);this.object.direction=this.direction;this.isClone||this.parent.updateRotationView();Entry.dispatchEvent("updateObject");Entry.requestUpdate=!0}; +Entry.EntityObject.prototype.setRotation=function(b){"free"!=this.parent.getRotateMethod()&&(b=0);this.rotation=b.mod(360);this.object.rotation=this.rotation;this.updateDialog();this.isClone||this.parent.updateRotationView();Entry.dispatchEvent("updateObject");Entry.requestUpdate=!0};Entry.EntityObject.prototype.getRotation=function(){return this.rotation};Entry.EntityObject.prototype.setRegX=function(b){"textBox"==this.type&&(b=0);this.regX=b;this.object.regX=this.regX;Entry.requestUpdate=!0}; +Entry.EntityObject.prototype.getRegX=function(){return this.regX};Entry.EntityObject.prototype.setRegY=function(b){"textBox"==this.type&&(b=0);this.regY=b;this.object.regY=this.regY;Entry.requestUpdate=!0};Entry.EntityObject.prototype.getRegY=function(){return this.regY};Entry.EntityObject.prototype.setScaleX=function(b){this.scaleX=b;this.object.scaleX=this.scaleX;this.parent.updateCoordinateView();this.updateDialog();Entry.requestUpdate=!0};Entry.EntityObject.prototype.getScaleX=function(){return this.scaleX}; +Entry.EntityObject.prototype.setScaleY=function(b){this.scaleY=b;this.object.scaleY=this.scaleY;this.parent.updateCoordinateView();this.updateDialog();Entry.requestUpdate=!0};Entry.EntityObject.prototype.getScaleY=function(){return this.scaleY};Entry.EntityObject.prototype.setSize=function(b){1>b&&(b=1);b/=this.getSize();this.setScaleX(this.getScaleX()*b);this.setScaleY(this.getScaleY()*b);this.isClone||this.parent.updateCoordinateView();Entry.requestUpdate=!0}; +Entry.EntityObject.prototype.getSize=function(){return(this.getWidth()*Math.abs(this.getScaleX())+this.getHeight()*Math.abs(this.getScaleY()))/2};Entry.EntityObject.prototype.setWidth=function(b){this.width=b;this.object.width=this.width;this.textObject&&this.getLineBreak()&&(this.textObject.lineWidth=this.width);this.updateDialog();this.updateBG();Entry.requestUpdate=!0};Entry.EntityObject.prototype.getWidth=function(){return this.width}; +Entry.EntityObject.prototype.setHeight=function(b){this.height=b;this.textObject&&(this.object.height=this.height,this.alignTextBox());this.updateDialog();this.updateBG();Entry.requestUpdate=!0};Entry.EntityObject.prototype.getHeight=function(){return this.height};Entry.EntityObject.prototype.setColour=function(b){b||(b="#000000");this.colour=b;this.textObject&&(this.textObject.color=this.colour);Entry.requestUpdate=!0};Entry.EntityObject.prototype.getColour=function(){return this.colour}; +Entry.EntityObject.prototype.setBGColour=function(b){b||(b="transparent");this.bgColor=b;this.updateBG();Entry.requestUpdate=!0};Entry.EntityObject.prototype.getBGColour=function(){return this.bgColor};Entry.EntityObject.prototype.setUnderLine=function(b){void 0===b&&(b=!1);this.underLine=b;this.textObject.underLine=b;Entry.requestUpdate=!0};Entry.EntityObject.prototype.getUnderLine=function(){return this.underLine}; +Entry.EntityObject.prototype.setStrike=function(b){void 0===b&&(b=!1);this.strike=b;this.textObject.strike=b;Entry.requestUpdate=!0};Entry.EntityObject.prototype.getStrike=function(){return this.strike};Entry.EntityObject.prototype.getFont=function(){var b=[];this.fontBold&&b.push("bold");this.fontItalic&&b.push("italic");b.push(this.getFontSize()+"px");b.push(this.fontType);return b.join(" ")}; +Entry.EntityObject.prototype.setFont=function(b){if("textBox"==this.parent.objectType&&this.font!==b){b||(b="20px Nanum Gothic");var a=b.split(" "),c=0;if(c=-1=l?g=[1,0,0,0,0,0,k,h,0,0,0,-1*h,k,0,0,0,0,0,1,0,0,0,0,0,1]:.66>=l?g=[k,0,h,0,0,0,1,0,0,0,h,0,k,0,0,0,0,0,1,0,0,0,0,0,1]:.99>=l&&(g=[k,h,0,0,0,-1*h,k,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1]);g=(new createjs.ColorMatrix).concat(g);g=new createjs.ColorMatrixFilter(g);e.push(g);b.alpha=a.alpha=f(a.alpha,0,1);b.filters=e}(b,a),a.cache(0,0,this.getWidth(), this.getHeight()),Entry.requestUpdate=!0)};Entry.EntityObject.prototype.resetFilter=function(){"sprite"==this.parent.objectType&&(this.object.filters=[],this.setInitialEffectValue(),this.object.alpha=this.effect.alpha,this.object.cache(0,0,this.getWidth(),this.getHeight()),Entry.requestUpdate=!0)};Entry.EntityObject.prototype.updateDialog=function(){this.dialog&&this.dialog.update();Entry.requestUpdate=!0}; Entry.EntityObject.prototype.takeSnapshot=function(){this.snapshot_=this.toJSON();this.collision=Entry.Utils.COLLISION.NONE};Entry.EntityObject.prototype.loadSnapshot=function(){this.snapshot_&&this.syncModel_(this.snapshot_);"sprite"==this.parent.objectType&&this.setImage(this.parent.getPicture());Entry.requestUpdate=!0}; -Entry.EntityObject.prototype.removeClone=function(){if(this.isClone){this.dialog&&this.dialog.remove();this.brush&&this.removeBrush();Entry.stage.unloadEntity(this);var a=this.parent.clonedEntities.indexOf(this);this.parent.clonedEntities.splice(a,1);Entry.Utils.isFunction(this.clearExecutor)&&this.clearExecutor()}};Entry.EntityObject.prototype.clearExecutor=function(){this.parent.script.clearExecutorsByEntity(this)}; -Entry.EntityObject.prototype.toJSON=function(){var a={};a.x=Entry.cutDecimal(this.getX());a.y=Entry.cutDecimal(this.getY());a.regX=Entry.cutDecimal(this.getRegX());a.regY=Entry.cutDecimal(this.getRegY());a.scaleX=this.getScaleX();a.scaleY=this.getScaleY();a.rotation=Entry.cutDecimal(this.getRotation());a.direction=Entry.cutDecimal(this.getDirection());a.width=Entry.cutDecimal(this.getWidth());a.height=Entry.cutDecimal(this.getHeight());a.font=this.getFont();a.visible=this.getVisible();"textBox"== -this.parent.objectType&&(a.colour=this.getColour(),a.text=this.getText(),a.textAlign=this.getTextAlign(),a.lineBreak=this.getLineBreak(),a.bgColor=this.getBGColour(),a.underLine=this.getUnderLine(),a.strike=this.getStrike(),a.fontSize=this.getFontSize());return a};Entry.EntityObject.prototype.setInitialEffectValue=function(){this.effect=this.getInitialEffectValue();Entry.requestUpdate=!0}; +Entry.EntityObject.prototype.removeClone=function(){if(this.isClone){this.dialog&&this.dialog.remove();this.brush&&this.removeBrush();Entry.stage.unloadEntity(this);var b=this.parent.clonedEntities.indexOf(this);this.parent.clonedEntities.splice(b,1);Entry.Utils.isFunction(this.clearExecutor)&&this.clearExecutor()}};Entry.EntityObject.prototype.clearExecutor=function(){this.parent.script.clearExecutorsByEntity(this)}; +Entry.EntityObject.prototype.toJSON=function(){var b={};b.x=Entry.cutDecimal(this.getX());b.y=Entry.cutDecimal(this.getY());b.regX=Entry.cutDecimal(this.getRegX());b.regY=Entry.cutDecimal(this.getRegY());b.scaleX=this.getScaleX();b.scaleY=this.getScaleY();b.rotation=Entry.cutDecimal(this.getRotation());b.direction=Entry.cutDecimal(this.getDirection());b.width=Entry.cutDecimal(this.getWidth());b.height=Entry.cutDecimal(this.getHeight());b.font=this.getFont();b.visible=this.getVisible();"textBox"== +this.parent.objectType&&(b.colour=this.getColour(),b.text=this.getText(),b.textAlign=this.getTextAlign(),b.lineBreak=this.getLineBreak(),b.bgColor=this.getBGColour(),b.underLine=this.getUnderLine(),b.strike=this.getStrike(),b.fontSize=this.getFontSize());return b};Entry.EntityObject.prototype.setInitialEffectValue=function(){this.effect=this.getInitialEffectValue();Entry.requestUpdate=!0}; Entry.EntityObject.prototype.getInitialEffectValue=function(){return{blur:0,hue:0,hsv:0,brightness:0,contrast:0,saturation:0,alpha:1}};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 a=this.getWidth(),b=this.getHeight();this.bgObject.graphics.setStrokeStyle(1).beginStroke().beginFill(this.getBGColour()).drawRect(-a/2,-b/2,a,b);if(this.getLineBreak())this.bgObject.x=0;else switch(this.getTextAlign()){case Entry.TEXT_ALIGN_LEFT:this.bgObject.x=a/2;break;case Entry.TEXT_ALIGN_CENTER:this.bgObject.x=0;break;case Entry.TEXT_ALIGN_RIGHT:this.bgObject.x=-a/2}}}; -Entry.EntityObject.prototype.alignTextBox=function(){if("textBox"==this.type){var a=this.textObject;if(this.lineBreak){var b=a.getMeasuredLineHeight();a.y=b/2-this.getHeight()/2;switch(this.textAlign){case Entry.TEXT_ALIGN_CENTER:a.x=0;break;case Entry.TEXT_ALIGN_LEFT:a.x=-this.getWidth()/2;break;case Entry.TEXT_ALIGN_RIGHT:a.x=this.getWidth()/2}a.maxHeight=this.getHeight()}else a.x=0,a.y=0}};Entry.EntityObject.prototype.syncDialogVisible=function(){this.dialog&&(this.dialog.object.visible=this.visible)};Entry.Func=function(a){this.id=a?a.id:Entry.generateHash();this.content=a?new Entry.Code(a.content):new Entry.Code([[{type:"function_create",copyable:!1,deletable:!1,x:40,y:40}]]);this.blockMenuBlock=this.block=null;this.hashMap={};this.paramMap={};var b=function(){};b.prototype=Entry.block.function_general;b=new b;b.changeEvent=new Entry.Event;b.template=Lang.template.function_general;Entry.block["func_"+this.id]=b;if(a){a=this.content._blockMap;for(var c in a)Entry.Func.registerParamBlock(a[c].type); -Entry.Func.generateWsBlock(this)}Entry.Func.registerFunction(this);Entry.Func.updateMenu()};Entry.Func.threads={};Entry.Func.registerFunction=function(a){var b=Entry.playground.mainWorkspace;b&&(this._targetFuncBlock=b.getBlockMenu().getCategoryCodes("func").createThread([{type:"func_"+a.id}]),a.blockMenuBlock=this._targetFuncBlock)};Entry.Func.executeFunction=function(a){var b=this.threads[a];if(b=Entry.Engine.computeThread(b.entity,b))return this.threads[a]=b,!0;delete this.threads[a];return!1}; -Entry.Func.clearThreads=function(){this.threads={}};Entry.Func.prototype.init=function(a){this.id=a.id;this.content=Blockly.Xml.textToDom(a.content);this.block=Blockly.Xml.textToDom(""+a.block+"").childNodes[0]};Entry.Func.prototype.destroy=function(){this.blockMenuBlock.destroy()};Entry.Func.edit=function(a){this.cancelEdit();this.targetFunc=a;this.initEditView(a.content);this.bindFuncChangeEvent();this.updateMenu()}; -Entry.Func.initEditView=function(a){this.menuCode||this.setupMenuCode();var b=Entry.playground.mainWorkspace;b.setMode(Entry.Workspace.MODE_OVERLAYBOARD);b.changeOverlayBoardCode(a);this._workspaceStateEvent=b.changeEvent.attach(this,this.endEdit)};Entry.Func.endEdit=function(a){this.unbindFuncChangeEvent();this._workspaceStateEvent.destroy();delete this._workspaceStateEvent;switch(a){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(a){var b=0;a=a.split(" ");var c="",d;d=Blockly.mainWorkspace.getAllBlocks();for(var e=0;eBlockly.Block.dragMode_&&(a.updateMenu(),a.fieldText=b,a.workspaceLength=c)}}; -Entry.Func.setupMenuCode=function(){var a=Entry.playground.mainWorkspace;a&&(a=a.getBlockMenu().getCategoryCodes("func"),this._fieldLabel=a.createThread([{type:"function_field_label"}]).getFirstBlock(),this._fieldString=a.createThread([{type:"function_field_string",params:[{type:this.requestParamBlock("string")}]}]).getFirstBlock(),this._fieldBoolean=a.createThread([{type:"function_field_boolean",params:[{type:this.requestParamBlock("boolean")}]}]).getFirstBlock(),this.menuCode=a)}; -Entry.Func.refreshMenuCode=function(){if(Entry.playground.mainWorkspace){this.menuCode||this.setupMenuCode();var a=Entry.block[this._fieldString.params[0].type].changeEvent._listeners.length;2'));this._hwModule=a;var b=this;Entry.addEventListener("windowResized",function(){var a=b._hwModule.monitorTemplate.mode;"both"==a&&(b.resize(),b.resizeList());"list"==a?b.resizeList():b.resize()});Entry.addEventListener("hwModeChange",function(){b.changeMode()});this.changeOffset=0;this.scale=.5;this._listPortViews={}}; -(function(a){a.initView=function(){this.svgDom=Entry.Dom($(''))};a.generateView=function(){this.snap=Entry.SVG("hwMonitor");this._svgGroup=this.snap.elem("g");this._portMap={n:[],e:[],s:[],w:[]};var b=this._hwModule.monitorTemplate,a={href:Entry.mediaFilePath+b.imgPath,x:-b.width/2,y:-b.height/2,width:b.width,height:b.height};this._portViews={};this.hwView=this._svgGroup.elem("image");this.hwView= -this.hwView.attr(a);this._template=b;b=b.ports;this.pathGroup=null;this.pathGroup=this._svgGroup.elem("g");var a=[],d;for(d in b){var e=this.generatePortView(b[d],"_svgGroup");this._portViews[d]=e;a.push(e)}a.sort(function(b,a){return b.box.x-a.box.x});var f=this._portMap;a.map(function(b){(1>(Math.atan2(-b.box.y,b.box.x)/Math.PI+2)%2?f.n:f.s).push(b)});this.resize()};a.toggleMode=function(b){var a=this._hwModule.monitorTemplate;"list"==b?(a.TempPort=null,this._hwModule.monitorTemplate.ports&&(this._hwModule.monitorTemplate.TempPort= -this._hwModule.monitorTemplate.ports,this._hwModule.monitorTemplate.listPorts=this.addPortEle(this._hwModule.monitorTemplate.listPorts,this._hwModule.monitorTemplate.ports)),$(this._svglistGroup).remove(),this._svgGroup&&$(this._svgGroup).remove(),$(this._pathGroup).remove(),this._hwModule.monitorTemplate.mode="list",this.generateListView()):(this._hwModule.monitorTemplate.TempPort&&(this._hwModule.monitorTemplate.ports=this._hwModule.monitorTemplate.TempPort,this._hwModule.monitorTemplate.listPorts= -this.removePortEle(this._hwModule.monitorTemplate.listPorts,this._hwModule.monitorTemplate.ports)),$(this._svglistGroup).remove(),this._hwModule.monitorTemplate.mode="both",this.generateListView(),this.generateView())};a.setHwmonitor=function(b){this._hwmodule=b};a.changeMode=function(b){"both"==this._hwModule.monitorTemplate.mode?this.toggleMode("list"):"list"==this._hwModule.monitorTemplate.mode&&this.toggleMode("both")};a.addPortEle=function(b,a){if("object"!=typeof a)return b;for(var d in a)b[d]= -a[d];return b};a.removePortEle=function(b,a){if("object"!=typeof a)return b;for(var d in a)delete b[d];return b};a.generateListView=function(){this._portMapList={n:[]};this._svglistGroup=null;this.listsnap=Entry.SVG("hwMonitor");this._svglistGroup=this.listsnap.elem("g");var b=this._hwModule.monitorTemplate;this._template=b;b=b.listPorts;this.pathGroup=this._svglistGroup.elem("g");var a=[],d;for(d in b){var e=this.generatePortView(b[d],"_svglistGroup");this._listPortViews[d]=e;a.push(e)}var f=this._portMapList; -a.map(function(b){f.n.push(b)});this.resizeList()};a.generatePortView=function(b,a){a=this[a].elem("g");a.addClass("hwComponent");var d;d=this.pathGroup.elem("path").attr({d:"m0,0",fill:"none",stroke:"input"===b.type?"#00979d":"#A751E3","stroke-width":3});var e=a.elem("rect").attr({x:0,y:0,width:150,height:22,rx:4,ry:4,fill:"#fff",stroke:"#a0a1a1"}),f=a.elem("text").attr({x:4,y:12,fill:"#000","class":"hwComponentName","alignment-baseline":"central"});f.textContent=b.name;f=f.getComputedTextLength(); -a.elem("rect").attr({x:f+8,y:2,width:30,height:18,rx:9,ry:9,fill:"input"===b.type?"#00979d":"#A751E3"});var g=a.elem("text").attr({x:f+13,y:12,fill:"#fff","class":"hwComponentValue","alignment-baseline":"central"});g.textContent=0;f+=40;e.attr({width:f});return{group:a,value:g,type:b.type,path:d,box:{x:b.pos.x-this._template.width/2,y:b.pos.y-this._template.height/2,width:f},width:f}};a.getView=function(){return this.svgDom};a.update=function(){var b=Entry.hw.portData,a=Entry.hw.sendQueue,d=this._hwModule.monitorTemplate.mode, -e=this._hwModule.monitorTemplate.keys||[],f=[];if("list"==d)f=this._listPortViews;else if("both"==d){if(f=this._listPortViews,this._portViews)for(var g in this._portViews)f[g]=this._portViews[g]}else f=this._portViews;if(a)for(g in a)0!=a[g]&&f[g]&&(f[g].type="output");for(var h in f)if(d=f[h],"input"==d.type){var k=b[h];0=this._template.height||0>=b.height||(this.scale=b.height/this._template.height* -this._template.height/1E3,this.align())};a.resizeList=function(){var b=this.svgDom.get(0).getBoundingClientRect();this._svglistGroup.attr({transform:"translate("+b.width/2+","+b.height/2+")"});this._rect=b;this.alignList()};a.align=function(){var b;b=this._portMap.s.concat();this._alignNS(b,this.scale/3*this._template.height+5,27);b=this._portMap.n.concat();this._alignNS(b,-this._template.height*this.scale/3-32,-27);b=this._portMap.e.concat();this._alignEW(b,-this._template.width*this.scale/3-5,-27); -b=this._portMap.w.concat();this._alignEW(b,this._template.width*this.scale/3-32,-27)};a.alignList=function(){var b;b=this._hwModule.monitorTemplate.listPorts;for(var a=b.length,d=0;da-(k.width+l.width/2.2)&&(e+=1,initX=g,f=0)};a._movePort=function(b,a,d,e){var f=a,g=b.box.x*this.scale,h=b.box.y*this.scale; -a>e?(f=a-b.width,a=a>g&&g>e?"M"+g+","+d+"L"+g+","+h:"M"+(a+e)/2+","+d+"l0,"+(h>d?28:-3)+"H"+g+"L"+g+","+h):a=ad?28:-3)+"H"+g+"L"+g+","+h;b.group.attr({transform:"translate("+f+","+d+")"});b.path.attr({d:a})}})(Entry.HWMonitor.prototype);Entry.HW=function(){this.connectTrial=0;this.isFirstConnect=!0;this.initSocket();this.connected=!1;this.portData={};this.sendQueue={};this.outputQueue={};this.settingQueue={};this.socketType=this.hwModule=this.selectedDevice=null;Entry.addEventListener("stop",this.setZero);this.hwInfo={11:Entry.Arduino,12:Entry.SensorBoard,13:Entry.CODEino,14:Entry.joystick,15:Entry.dplay,16:Entry.nemoino,17:Entry.Xbot,18:Entry.ardublock,24:Entry.Hamster,25:Entry.Albert,31:Entry.Bitbrick,42:Entry.Arduino,51:Entry.Neobot, -71:Entry.Robotis_carCont,72:Entry.Robotis_openCM70,81:Entry.Arduino}};Entry.HW.TRIAL_LIMIT=1;p=Entry.HW.prototype; -p.initSocket=function(){try{if(this.connectTrial>=Entry.HW.TRIAL_LIMIT)this.isFirstConnect||Entry.toast.alert(Lang.Menus.connect_hw,Lang.Menus.connect_fail,!1),this.isFirstConnect=!1;else{var a=this,b,c;this.connected=!1;this.connectTrial++;if(-1"+Lang.Menus[b]+"",{classes:["propertyTabElement","propertyTab"+b],parent:this._tabView}),f=this;e.bind("click",function(){f.select(b)});this.modes[b]&&(this.modes[b].tabDom.remove(),this.modes[b].contentDom.remove(),"hw"==b&&($(this.modes).removeClass(".propertyTabhw"),$(".propertyTabhw").unbind("dblclick")));this.modes[b]={obj:a,tabDom:e,contentDom:d};"hw"==b&&$(".propertyTabhw").bind("dblclick",function(){Entry.dispatchEvent("hwModeChange")})}; -a.resize=function(b){this._view.css({width:b+"px",top:9*b/16+123-22+"px"});430<=b?this._view.removeClass("collapsed"):this._view.addClass("collapsed");Entry.dispatchEvent("windowResized");b=this.selected;"hw"==b?this.modes.hw.obj.listPorts?this.modes[b].obj.resizeList():this.modes[b].obj.resize():this.modes[b].obj.resize()};a.select=function(b){for(var a in this.modes){var d=this.modes[a];d.tabDom.removeClass("selected");d.contentDom.addClass("entryRemove");d.obj.visible=!1}a=this.modes[b];a.tabDom.addClass("selected"); -a.contentDom.removeClass("entryRemove");a.obj.resize&&a.obj.resize();a.obj.visible=!0;this.selected=b};a.initializeSplitter=function(b){var a=this;b.bind("mousedown touchstart",function(b){a._cover.removeClass("entryRemove");Entry.container.disableSort();Entry.container.splitterEnable=!0;Entry.documentMousemove&&(Entry.container.resizeEvent=Entry.documentMousemove.attach(this,function(b){Entry.container.splitterEnable&&Entry.resizeElement({canvasWidth:b.clientX||b.x})}))});$(document).bind("mouseup touchend", -function(b){if(b=Entry.container.resizeEvent)Entry.container.splitterEnable=!1,Entry.documentMousemove.detach(b),a._cover.addClass("entryRemove"),delete Entry.container.resizeEvent;Entry.container.enableSort()})}})(Entry.PropertyPanel.prototype);Entry.init=function(a,b){Entry.assert("object"===typeof b,"Init option is not object");this.events_={};this.interfaceState={menuWidth:264};Entry.Utils.bindGlobalEvent("resize mousedown mousemove keydown keyup dispose".split(" "));this.options=b;this.parseOptions(b);this.mediaFilePath=(b.libDir?b.libDir:"/lib")+"/entryjs/images/";this.defaultPath=b.defaultDir||"";this.blockInjectPath=b.blockInjectDir||"";"workspace"==this.type&&this.isPhone()&&(this.type="phone");this.initialize_();this.view_=a;this.view_.setAttribute("class", -"entry");Entry.initFonts(b.fonts);this.createDom(a,this.type);this.loadInterfaceState();this.overridePrototype();this.maxCloneLimit=302;this.cloudSavable=!0;this.startTime=(new Date).getTime();document.onkeydown=function(b){Entry.dispatchEvent("keyPressed",b)};document.onkeyup=function(b){Entry.dispatchEvent("keyUpped",b)};window.onresize=function(b){Entry.dispatchEvent("windowResized",b)};window.onbeforeunload=this.beforeUnload;Entry.addEventListener("saveWorkspace",function(b){Entry.addActivity("save")}); -"IE"!=Entry.getBrowserType().substr(0,2)||window.flashaudio?createjs.Sound.registerPlugins([createjs.WebAudioPlugin]):(createjs.FlashAudioPlugin.swfPath=this.mediaFilePath+"media/",createjs.Sound.registerPlugins([createjs.FlashAudioPlugin]),window.flashaudio=!0);Entry.soundQueue=new createjs.LoadQueue;Entry.soundQueue.installPlugin(createjs.Sound);Entry.loadAudio_([Entry.mediaFilePath+"sounds/click.mp3",Entry.mediaFilePath+"sounds/click.wav",Entry.mediaFilePath+"sounds/click.ogg"],"entryMagneting"); -Entry.loadAudio_([Entry.mediaFilePath+"sounds/delete.mp3",Entry.mediaFilePath+"sounds/delete.ogg",Entry.mediaFilePath+"sounds/delete.wav"],"entryDelete");createjs.Sound.stop()};Entry.loadAudio_=function(a,b){if(window.Audio&&a.length)for(;0this.pictures.length)return!1;a=this.getPicture(a);var b=this.pictures.indexOf(a);Entry.stateManager&&Entry.stateManager.addCommand("remove sprite",this,this.addPicture,a,b);this.pictures.splice(b,1);a===this.selectedPicture&&Entry.playground.selectPicture(this.pictures[0]);Entry.playground.injectPicture(this);Entry.playground.reloadPlayground();return new Entry.State(this,this.addPicture,a,b)}; -Entry.EntryObject.prototype.getPicture=function(a){if(!a)return this.selectedPicture;a=a.trim();for(var b=this.pictures,c=b.length,d=0;d=a&&0Entry.maxCloneLimit||(a=new Entry.EntityObject(this),b?(a.injectModel(b.picture?b.picture:null,b.toJSON()),a.snapshot_=b.snapshot_,b.effect&&(a.effect=Entry.cloneSimpleObject(b.effect),a.applyFilter()),b.brush&&Entry.setCloneBrush(a,b.brush)):(a.injectModel(this.entity.picture?this.entity.picture:null,this.entity.toJSON(a)),a.snapshot_=this.entity.snapshot_,this.entity.effect&&(a.effect=Entry.cloneSimpleObject(this.entity.effect), -a.applyFilter()),this.entity.brush&&Entry.setCloneBrush(a,this.entity.brush)),Entry.engine.raiseEventOnEntity(a,[a,"when_clone_start"]),a.isClone=!0,a.isStarted=!0,this.addCloneVariables(this,a,b?b.variables:null,b?b.lists:null),this.clonedEntities.push(a),Entry.stage.loadEntity(a))}; -Entry.EntryObject.prototype.initializeSplitter=function(a){a.onmousedown=function(b){Entry.container.disableSort();Entry.container.splitterEnable=!0};document.addEventListener("mousemove",function(b){Entry.container.splitterEnable&&Entry.resizeElement({canvasWidth:b.x||b.clientX})});document.addEventListener("mouseup",function(b){Entry.container.splitterEnable=!1;Entry.container.enableSort()})};Entry.EntryObject.prototype.isSelected=function(){return this.isSelected_}; -Entry.EntryObject.prototype.toJSON=function(){var a={};a.id=this.id;a.name=this.name;"textBox"==this.objectType&&(a.text=this.text);a.script=this.getScriptText();"sprite"==this.objectType&&(a.selectedPictureId=this.selectedPicture.id);a.objectType=this.objectType;a.rotateMethod=this.getRotateMethod();a.scene=this.scene.id;a.sprite={pictures:Entry.getPicturesJSON(this.pictures),sounds:Entry.getSoundsJSON(this.sounds)};a.lock=this.lock;a.entity=this.entity.toJSON();return a}; -Entry.EntryObject.prototype.destroy=function(){Entry.stage.unloadEntity(this.entity);this.view_&&Entry.removeElement(this.view_)};Entry.EntryObject.prototype.getSound=function(a){a=a.trim();for(var b=this.sounds,c=b.length,d=0;d=a&&0this.pictures.length)return!1;b=this.getPicture(b);var a=this.pictures.indexOf(b);Entry.stateManager&&Entry.stateManager.addCommand("remove sprite",this,this.addPicture,b,a);this.pictures.splice(a,1);b===this.selectedPicture&&Entry.playground.selectPicture(this.pictures[0]);Entry.playground.injectPicture(this);Entry.playground.reloadPlayground();return new Entry.State(this,this.addPicture,b,a)}; +Entry.EntryObject.prototype.getPicture=function(b){if(!b)return this.selectedPicture;b=b.trim();for(var a=this.pictures,c=a.length,d=0;d=b&&0Entry.maxCloneLimit||(b=new Entry.EntityObject(this),a?(b.injectModel(a.picture?a.picture:null,a.toJSON()),b.snapshot_=a.snapshot_,a.effect&&(b.effect=Entry.cloneSimpleObject(a.effect),b.applyFilter()),a.brush&&Entry.setCloneBrush(b,a.brush)):(b.injectModel(this.entity.picture?this.entity.picture:null,this.entity.toJSON(b)),b.snapshot_=this.entity.snapshot_,this.entity.effect&&(b.effect=Entry.cloneSimpleObject(this.entity.effect), +b.applyFilter()),this.entity.brush&&Entry.setCloneBrush(b,this.entity.brush)),Entry.engine.raiseEventOnEntity(b,[b,"when_clone_start"]),b.isClone=!0,b.isStarted=!0,this.addCloneVariables(this,b,a?a.variables:null,a?a.lists:null),this.clonedEntities.push(b),Entry.stage.loadEntity(b))}; +Entry.EntryObject.prototype.initializeSplitter=function(b){b.onmousedown=function(a){Entry.container.disableSort();Entry.container.splitterEnable=!0};document.addEventListener("mousemove",function(a){Entry.container.splitterEnable&&Entry.resizeElement({canvasWidth:a.x||a.clientX})});document.addEventListener("mouseup",function(a){Entry.container.splitterEnable=!1;Entry.container.enableSort()})};Entry.EntryObject.prototype.isSelected=function(){return this.isSelected_}; +Entry.EntryObject.prototype.toJSON=function(){var b={};b.id=this.id;b.name=this.name;"textBox"==this.objectType&&(b.text=this.text);b.script=this.getScriptText();"sprite"==this.objectType&&(b.selectedPictureId=this.selectedPicture.id);b.objectType=this.objectType;b.rotateMethod=this.getRotateMethod();b.scene=this.scene.id;b.sprite={pictures:Entry.getPicturesJSON(this.pictures),sounds:Entry.getSoundsJSON(this.sounds)};b.lock=this.lock;b.entity=this.entity.toJSON();return b}; +Entry.EntryObject.prototype.destroy=function(){Entry.stage.unloadEntity(this.entity);this.view_&&Entry.removeElement(this.view_)};Entry.EntryObject.prototype.getSound=function(b){b=b.trim();for(var a=this.sounds,c=a.length,d=0;d=b&&0=b-e/100*b&&f<=b+e/100*b&&g>=c-e/100*c&&g<=c+e/100*c&&a>=d-e/100*d&&a<=d+e/100*d};Entry.Painter.prototype.matchColorOnly=function(a,b,c,d){return b===this.colorLayerData.data[a]&&c===this.colorLayerData.data[a+1]&&d===this.colorLayerData.data[a+2]?!0:!1}; -Entry.Painter.prototype.matchColor=function(a,b,c,d,e){return b===this.colorLayerData.data[a]&&c===this.colorLayerData.data[a+1]&&d===this.colorLayerData.data[a+2]&&e===this.colorLayerData.data[a+3]?!0:!1};Entry.Painter.prototype.colorPixel=function(a,b,c,d,e){e||(e=255);this.stroke.transparent&&(e=d=c=b=0);this.colorLayerData.data[a]=b;this.colorLayerData.data[a+1]=c;this.colorLayerData.data[a+2]=d;this.colorLayerData.data[a+3]=e}; -Entry.Painter.prototype.pickStrokeColor=function(a){a=4*(Math.round(a.stageY)*this.canvas.width+Math.round(a.stageX));this.stroke.lineColor=Entry.rgb2hex(this.colorLayerData.data[a],this.colorLayerData.data[a+1],this.colorLayerData.data[a+2]);document.getElementById("entryPainterAttrCircle").style.backgroundColor=this.stroke.lineColor;document.getElementById("entryPainterAttrCircleInput").value=this.stroke.lineColor}; -Entry.Painter.prototype.drawText=function(a){var b=document.getElementById("entryPainterAttrFontStyle").value,c=document.getElementById("entryPainterAttrFontName").value,d=document.getElementById("entryPainterAttrFontSize").value;a=new createjs.Text(a,b+" "+d+'px "'+c+'"',this.stroke.lineColor);a.textBaseline="top";a.x=this.oldPt.x;a.y=this.oldPt.y;this.objectContainer.addChild(a);this.selectTextObject(a);this.file.modified=!0}; -Entry.Painter.prototype.addImage=function(a){var b=new createjs.Bitmap(a);this.objectContainer.addChild(b);b.x=this.stage.canvas.width/2;b.y=this.stage.canvas.height/2;b.regX=b.image.width/2|0;b.regY=b.image.height/2|0;if(540=a-e/100*a&&f<=a+e/100*a&&g>=c-e/100*c&&g<=c+e/100*c&&b>=d-e/100*d&&b<=d+e/100*d};Entry.Painter.prototype.matchColorOnly=function(b,a,c,d){return a===this.colorLayerData.data[b]&&c===this.colorLayerData.data[b+1]&&d===this.colorLayerData.data[b+2]?!0:!1}; +Entry.Painter.prototype.matchColor=function(b,a,c,d,e){return a===this.colorLayerData.data[b]&&c===this.colorLayerData.data[b+1]&&d===this.colorLayerData.data[b+2]&&e===this.colorLayerData.data[b+3]?!0:!1};Entry.Painter.prototype.colorPixel=function(b,a,c,d,e){e||(e=255);this.stroke.transparent&&(e=d=c=a=0);this.colorLayerData.data[b]=a;this.colorLayerData.data[b+1]=c;this.colorLayerData.data[b+2]=d;this.colorLayerData.data[b+3]=e}; +Entry.Painter.prototype.pickStrokeColor=function(b){b=4*(Math.round(b.stageY)*this.canvas.width+Math.round(b.stageX));this.stroke.lineColor=Entry.rgb2hex(this.colorLayerData.data[b],this.colorLayerData.data[b+1],this.colorLayerData.data[b+2]);document.getElementById("entryPainterAttrCircle").style.backgroundColor=this.stroke.lineColor;document.getElementById("entryPainterAttrCircleInput").value=this.stroke.lineColor}; +Entry.Painter.prototype.drawText=function(b){var a=document.getElementById("entryPainterAttrFontStyle").value,c=document.getElementById("entryPainterAttrFontName").value,d=document.getElementById("entryPainterAttrFontSize").value;b=new createjs.Text(b,a+" "+d+'px "'+c+'"',this.stroke.lineColor);b.textBaseline="top";b.x=this.oldPt.x;b.y=this.oldPt.y;this.objectContainer.addChild(b);this.selectTextObject(b);this.file.modified=!0}; +Entry.Painter.prototype.addImage=function(b){var a=new createjs.Bitmap(b);this.objectContainer.addChild(a);a.x=this.stage.canvas.width/2;a.y=this.stage.canvas.height/2;a.regX=a.image.width/2|0;a.regY=a.image.height/2|0;if(540>1,this.oldPt.y+this.stage.mouseY>>1);this.brush.graphics.setStrokeStyle(this.stroke.thickness,"round").beginStroke(this.stroke.lineColor).moveTo(a.x,a.y).curveTo(this.oldPt.x,this.oldPt.y,this.oldMidPt.x,this.oldMidPt.y);this.oldPt.x=this.stage.mouseX;this.oldPt.y=this.stage.mouseY;this.oldMidPt.x=a.x;this.oldMidPt.y=a.y;this.file.modified=!0;this.stage.update()}; +Entry.Painter.prototype.fill=function(){if(!this.stroke.locked){this.stroke.locked=!0;this.initCommand();this.doCommand();this.clearHandle();var b=this.canvas.width,a=this.canvas.height;this.colorLayerData=this.ctx.getImageData(0,0,b,a);var c=new createjs.Point(this.stage.mouseX,this.stage.mouseY);c.x=Math.round(c.x);c.y=Math.round(c.y);for(var d=4*(c.y*b+c.x),e=this.colorLayerData.data[d],f=this.colorLayerData.data[d+1],g=this.colorLayerData.data[d+2],h=this.colorLayerData.data[d+3],k,l,c=[[c.x, +c.y]],n=Entry.hex2rgb(this.stroke.lineColor);c.length;){for(var d=c.pop(),m=d[0],q=d[1],d=4*(q*b+m);0<=q&&this.matchColor(d,e,f,g,h);)--q,d-=4*b;d+=4*b;q+=1;for(l=k=!1;q>1,this.oldPt.y+this.stage.mouseY>>1);this.brush.graphics.setStrokeStyle(this.stroke.thickness,"round").beginStroke(this.stroke.lineColor).moveTo(b.x,b.y).curveTo(this.oldPt.x,this.oldPt.y,this.oldMidPt.x,this.oldMidPt.y);this.oldPt.x=this.stage.mouseX;this.oldPt.y=this.stage.mouseY;this.oldMidPt.x=b.x;this.oldMidPt.y=b.y;this.file.modified=!0;this.stage.update()}; Entry.Painter.prototype.move_line=function(){this.brush.graphics.clear().beginStroke(this.stroke.lineColor).setStrokeStyle(this.stroke.thickness,"round").moveTo(this.oldPt.x,this.oldPt.y).lineTo(this.stage.mouseX,this.stage.mouseY);this.file.modified=!0;this.stage.update()}; -Entry.Painter.prototype.move_rect=function(){var a=this.stage.mouseX-this.oldPt.x,b=this.stage.mouseY-this.oldPt.y;event.shiftKey&&(b=a);this.stroke.fill?0===this.stroke.thickness?this.brush.graphics.clear().setStrokeStyle(this.stroke.thickness,"round").beginFill(this.stroke.fillColor).drawRect(this.oldPt.x,this.oldPt.y,a,b):this.brush.graphics.clear().beginStroke(this.stroke.lineColor).setStrokeStyle(this.stroke.thickness,"round").beginFill(this.stroke.fillColor).drawRect(this.oldPt.x,this.oldPt.y, -a,b):0===this.stroke.thickness?this.brush.graphics.clear().setStrokeStyle(this.stroke.thickness,"round").drawRect(this.oldPt.x,this.oldPt.y,a,b):this.brush.graphics.clear().beginStroke(this.stroke.lineColor).setStrokeStyle(this.stroke.thickness,"round").drawRect(this.oldPt.x,this.oldPt.y,a,b);this.file.modified=!0;this.stage.update()}; -Entry.Painter.prototype.move_circle=function(){var a=this.stage.mouseX-this.oldPt.x,b=this.stage.mouseY-this.oldPt.y;event.shiftKey&&(b=a);this.stroke.fill?0===this.stroke.thickness?this.brush.graphics.clear().beginStroke(this.stroke.fillColor).setStrokeStyle(this.stroke.thickness,"round").beginFill(this.stroke.fillColor).drawEllipse(this.oldPt.x,this.oldPt.y,a,b):this.brush.graphics.clear().beginStroke(this.stroke.lineColor).setStrokeStyle(this.stroke.thickness,"round").beginFill(this.stroke.fillColor).drawEllipse(this.oldPt.x, -this.oldPt.y,a,b):this.stroke.fill||(0===this.stroke.thickness?this.brush.graphics.clear().drawEllipse(this.oldPt.x,this.oldPt.y,a,b):this.brush.graphics.clear().beginStroke(this.stroke.lineColor).setStrokeStyle(this.stroke.thickness,"round").drawEllipse(this.oldPt.x,this.oldPt.y,a,b));this.file.modified=!0;this.stage.update()}; +Entry.Painter.prototype.move_rect=function(){var b=this.stage.mouseX-this.oldPt.x,a=this.stage.mouseY-this.oldPt.y;event.shiftKey&&(a=b);this.stroke.fill?0===this.stroke.thickness?this.brush.graphics.clear().setStrokeStyle(this.stroke.thickness,"round").beginFill(this.stroke.fillColor).drawRect(this.oldPt.x,this.oldPt.y,b,a):this.brush.graphics.clear().beginStroke(this.stroke.lineColor).setStrokeStyle(this.stroke.thickness,"round").beginFill(this.stroke.fillColor).drawRect(this.oldPt.x,this.oldPt.y, +b,a):0===this.stroke.thickness?this.brush.graphics.clear().setStrokeStyle(this.stroke.thickness,"round").drawRect(this.oldPt.x,this.oldPt.y,b,a):this.brush.graphics.clear().beginStroke(this.stroke.lineColor).setStrokeStyle(this.stroke.thickness,"round").drawRect(this.oldPt.x,this.oldPt.y,b,a);this.file.modified=!0;this.stage.update()}; +Entry.Painter.prototype.move_circle=function(){var b=this.stage.mouseX-this.oldPt.x,a=this.stage.mouseY-this.oldPt.y;event.shiftKey&&(a=b);this.stroke.fill?0===this.stroke.thickness?this.brush.graphics.clear().beginStroke(this.stroke.fillColor).setStrokeStyle(this.stroke.thickness,"round").beginFill(this.stroke.fillColor).drawEllipse(this.oldPt.x,this.oldPt.y,b,a):this.brush.graphics.clear().beginStroke(this.stroke.lineColor).setStrokeStyle(this.stroke.thickness,"round").beginFill(this.stroke.fillColor).drawEllipse(this.oldPt.x, +this.oldPt.y,b,a):this.stroke.fill||(0===this.stroke.thickness?this.brush.graphics.clear().drawEllipse(this.oldPt.x,this.oldPt.y,b,a):this.brush.graphics.clear().beginStroke(this.stroke.lineColor).setStrokeStyle(this.stroke.thickness,"round").drawEllipse(this.oldPt.x,this.oldPt.y,b,a));this.file.modified=!0;this.stage.update()}; Entry.Painter.prototype.edit_copy=function(){this.selectArea?(this.clearHandle(),this.selectedObject&&delete this.selectedObject,this.copyLayerData=this.ctx.getImageData(this.selectArea.x1,this.selectArea.y1,this.selectArea.x2,this.selectArea.y2),this.copy={},this.copy.width=this.selectArea.x2,this.copy.height=this.selectArea.y2,this.canvas_.width=this.copy.width,this.canvas_.height=this.copy.height,this.ctx_.clearRect(0,0,this.canvas_.width,this.canvas_.height),this.ctx_.putImageData(this.copyLayerData, 0,0)):alert("\ubcf5\uc0ac\ud560 \uc601\uc5ed\uc744 \uc120\ud0dd\ud558\uc138\uc694.")}; Entry.Painter.prototype.edit_cut=function(){this.selectArea?(this.clearHandle(),this.selectedObject&&delete this.selectedObject,this.copyLayerData=this.ctx.getImageData(this.selectArea.x1,this.selectArea.y1,this.selectArea.x2,this.selectArea.y2),this.copy={},this.copy.width=this.selectArea.x2,this.copy.height=this.selectArea.y2,this.canvas_.width=this.copy.width,this.canvas_.height=this.copy.height,this.ctx_.clearRect(0,0,this.canvas_.width,this.canvas_.height),this.ctx_.putImageData(this.copyLayerData, 0,0),this.ctx.clearRect(this.selectArea.x1,this.selectArea.y1,this.selectArea.x2,this.selectArea.y2),this.colorLayerData=this.ctx.getImageData(0,0,this.canvas.width,this.canvas.height),this.reloadContext(),this.file.modified=!0):alert("\uc790\ub97c \uc601\uc5ed\uc744 \uc120\ud0dd\ud558\uc138\uc694.")}; -Entry.Painter.prototype.edit_paste=function(){var a=new Image;a.src=this.canvas_.toDataURL();var b=this;a.onload=function(a){a=new createjs.Bitmap(a.target);a.x=b.canvas.width/2;a.y=b.canvas.height/2;a.regX=b.copy.width/2|0;a.regY=b.copy.height/2|0;a.id=Entry.generateHash();b.objectContainer.addChild(a);b.selectObject(a,!0)};this.file.modified=!0}; +Entry.Painter.prototype.edit_paste=function(){var b=new Image;b.src=this.canvas_.toDataURL();var a=this;b.onload=function(b){b=new createjs.Bitmap(b.target);b.x=a.canvas.width/2;b.y=a.canvas.height/2;b.regX=a.copy.width/2|0;b.regY=a.copy.height/2|0;b.id=Entry.generateHash();a.objectContainer.addChild(b);a.selectObject(b,!0)};this.file.modified=!0}; Entry.Painter.prototype.edit_select=function(){this.clearHandle();this.selectedObject&&delete this.selectedObject;this.copyLayerData=this.ctx.getImageData(this.selectArea.x1,this.selectArea.y1,this.selectArea.x2,this.selectArea.y2);this.copy={};this.copy.width=this.selectArea.x2;this.copy.height=this.selectArea.y2;this.canvas_.width=this.copy.width;this.canvas_.height=this.copy.height;this.ctx_.clearRect(0,0,this.canvas_.width,this.canvas_.height);this.ctx_.putImageData(this.copyLayerData,0,0);this.ctx.clearRect(this.selectArea.x1, -this.selectArea.y1,this.selectArea.x2,this.selectArea.y2);this.colorLayerData=this.ctx.getImageData(0,0,this.canvas.width,this.canvas.height);this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);this.ctx.putImageData(this.colorLayerData,0,0);var a=new Image;a.src=this.canvas.toDataURL();var b=this;a.onload=function(a){a=new createjs.Bitmap(a.target);b.objectContainer.removeAllChildren();b.objectContainer.addChild(a);a=new Image;a.src=b.canvas_.toDataURL();a.onload=function(a){a=new createjs.Bitmap(a.target); -a.x=b.selectArea.x1+b.copy.width/2;a.y=b.selectArea.y1+b.copy.height/2;a.regX=b.copy.width/2|0;a.regY=b.copy.height/2|0;a.id=Entry.generateHash();a.name=a.id;b.objectContainer.addChild(a);b.selectObject(a,!0)}}}; -Entry.Painter.prototype.move_erase=function(a){a=new createjs.Point(this.oldPt.x+this.stage.mouseX>>1,this.oldPt.y+this.stage.mouseY>>1);this.eraser.graphics.setStrokeStyle(this.stroke.thickness,"round").beginStroke("#ffffff").moveTo(a.x,a.y).curveTo(this.oldPt.x,this.oldPt.y,this.oldMidPt.x,this.oldMidPt.y);this.oldPt.x=this.stage.mouseX;this.oldPt.y=this.stage.mouseY;this.oldMidPt.x=a.x;this.oldMidPt.y=a.y;this.file.modified=!0;this.stage.update()}; +this.selectArea.y1,this.selectArea.x2,this.selectArea.y2);this.colorLayerData=this.ctx.getImageData(0,0,this.canvas.width,this.canvas.height);this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);this.ctx.putImageData(this.colorLayerData,0,0);var b=new Image;b.src=this.canvas.toDataURL();var a=this;b.onload=function(b){b=new createjs.Bitmap(b.target);a.objectContainer.removeAllChildren();a.objectContainer.addChild(b);b=new Image;b.src=a.canvas_.toDataURL();b.onload=function(b){b=new createjs.Bitmap(b.target); +b.x=a.selectArea.x1+a.copy.width/2;b.y=a.selectArea.y1+a.copy.height/2;b.regX=a.copy.width/2|0;b.regY=a.copy.height/2|0;b.id=Entry.generateHash();b.name=b.id;a.objectContainer.addChild(b);a.selectObject(b,!0)}}}; +Entry.Painter.prototype.move_erase=function(b){b=new createjs.Point(this.oldPt.x+this.stage.mouseX>>1,this.oldPt.y+this.stage.mouseY>>1);this.eraser.graphics.setStrokeStyle(this.stroke.thickness,"round").beginStroke("#ffffff").moveTo(b.x,b.y).curveTo(this.oldPt.x,this.oldPt.y,this.oldMidPt.x,this.oldMidPt.y);this.oldPt.x=this.stage.mouseX;this.oldPt.y=this.stage.mouseY;this.oldMidPt.x=b.x;this.oldMidPt.y=b.y;this.file.modified=!0;this.stage.update()}; Entry.Painter.prototype.settingShapeBlur=function(){this.objectWidthInput.blur();this.objectHeightInput.blur();this.objectRotateInput.blur()}; -Entry.Painter.prototype.stagemousedown=function(a){"picture"==Entry.playground.getViewMode()&&(this.settingShapeBlur(),this.oldPt=new createjs.Point(a.stageX,a.stageY),this.oldMidPt=this.oldPt.clone(),"select"===this.toolbox.selected?this.stage.addChild(this._handle):"spoid"===this.toolbox.selected?this.pickStrokeColor(a):"text"===this.toolbox.selected?(this.showInputField(a),this.stage.update()):"erase"===this.toolbox.selected?(this.createEraser(),this.stroke.enabled=!0):"fill"===this.toolbox.selected? +Entry.Painter.prototype.stagemousedown=function(b){"picture"==Entry.playground.getViewMode()&&(this.settingShapeBlur(),this.oldPt=new createjs.Point(b.stageX,b.stageY),this.oldMidPt=this.oldPt.clone(),"select"===this.toolbox.selected?this.stage.addChild(this._handle):"spoid"===this.toolbox.selected?this.pickStrokeColor(b):"text"===this.toolbox.selected?(this.showInputField(b),this.stage.update()):"erase"===this.toolbox.selected?(this.createEraser(),this.stroke.enabled=!0):"fill"===this.toolbox.selected? this.fill():"cursor"!==this.toolbox.selected&&(this.createBrush(),this.stroke.enabled=!0))}; -Entry.Painter.prototype.stagemousemove=function(a){"picture"==Entry.playground.getViewMode()&&("select"===this.toolbox.selected&&-1this.value&&(this.value=360+this.value%360);b.handle.rotation=this.value;b.updateImageHandle()};this.objectRotateInput.addClass("entryPlaygroundPainterNumberInput"); +this.attrRotateArea.appendChild(d);c=Entry.createElement("div");c.addClass("painterAttrRotateTop");c.innerHTML="\u03bf";d.appendChild(c);this.objectRotateInput=Entry.createElement("input","entryPainterAttrDegree");this.objectRotateInput.onblur=function(){if(isNaN(this.value))return alert("\uc22b\uc790\ub9cc \uc785\ub825 \uac00\ub2a5\ud569\ub2c8\ub2e4."),!1;360<=this.value?this.value%=360:0>this.value&&(this.value=360+this.value%360);a.handle.rotation=this.value;a.updateImageHandle()};this.objectRotateInput.addClass("entryPlaygroundPainterNumberInput"); this.objectRotateInput.defaultValue="0";d.appendChild(this.objectRotateInput);this.attrColorArea=Entry.createElement("fieldset","entryPainterAttrColor");this.attrColorArea.addClass("entryPlaygroundPainterAttrColor");g.appendChild(this.attrColorArea);var n=Entry.createElement("div");n.addClass("entryPlaygroundPainterAttrColorContainer");this.attrColorArea.appendChild(n);this.attrCircleArea=Entry.createElement("div");this.attrCircleArea.addClass("painterAttrCircleArea");g.appendChild(this.attrCircleArea); -d=Entry.createElement("div","entryPainterAttrCircle");d.addClass("painterAttrCircle");this.attrCircleArea.appendChild(d);this.attrCircleArea.painterAttrCircle=d;d=Entry.createElement("input","entryPainterAttrCircleInput");d.value="#000000";d.addClass("painterAttrCircleInput");this.attrCircleArea.appendChild(d);this.attrColorSpoid=Entry.createElement("div");this.attrColorSpoid.bindOnClick(function(){b.selectToolbox("spoid")});this.attrColorSpoid.addClass("painterAttrColorSpoid");g.appendChild(this.attrColorSpoid); -Entry.getColourCodes().forEach(function(a){var c=Entry.createElement("div");c.addClass("entryPlaygroundPainterAttrColorElement");"transparent"===a?c.style.backgroundImage="url("+(Entry.mediaFilePath+"/transparent.png")+")":c.style.backgroundColor=a;c.bindOnClick(function(c){"transparent"===a?(b.stroke.transparent=!0,b.stroke.lineColor="#ffffff"):(b.stroke.transparent=!1,r&&(document.getElementById("entryPainterShapeBackgroundColor").style.backgroundColor=a,b.stroke.fillColor=a),r||(document.getElementById("entryPainterShapeLineColor").style.backgroundColor= -a,b.stroke.lineColor=a));document.getElementById("entryPainterAttrCircle").style.backgroundColor=b.stroke.lineColor;document.getElementById("entryPainterAttrCircleInput").value=a});n.appendChild(c)});this.attrThickArea=Entry.createElement("div","painterAttrThickArea");this.attrThickArea.addClass("entryPlaygroundentryPlaygroundPainterAttrThickArea");g.appendChild(this.attrThickArea);d=Entry.createElement("legend");d.addClass("painterAttrThickName");d.innerHTML=Lang.Workspace.thickness;this.attrThickArea.appendChild(d); -var m=Entry.createElement("fieldset","entryPainterAttrThick");m.addClass("entryPlaygroundPainterAttrThick");this.attrThickArea.appendChild(m);d=Entry.createElement("div");d.addClass("paintAttrThickTop");m.appendChild(d);e=Entry.createElement("select","entryPainterAttrThick");e.addClass("entryPlaygroundPainterAttrThickInput");e.size="1";e.onchange=function(a){b.stroke.thickness=a.target.value};for(d=1;10>=d;d++)c=Entry.createElement("option"),c.value=d,c.innerHTML=d,e.appendChild(c);m.appendChild(e); +d=Entry.createElement("div","entryPainterAttrCircle");d.addClass("painterAttrCircle");this.attrCircleArea.appendChild(d);this.attrCircleArea.painterAttrCircle=d;d=Entry.createElement("input","entryPainterAttrCircleInput");d.value="#000000";d.addClass("painterAttrCircleInput");this.attrCircleArea.appendChild(d);this.attrColorSpoid=Entry.createElement("div");this.attrColorSpoid.bindOnClick(function(){a.selectToolbox("spoid")});this.attrColorSpoid.addClass("painterAttrColorSpoid");g.appendChild(this.attrColorSpoid); +Entry.getColourCodes().forEach(function(b){var c=Entry.createElement("div");c.addClass("entryPlaygroundPainterAttrColorElement");"transparent"===b?c.style.backgroundImage="url("+(Entry.mediaFilePath+"/transparent.png")+")":c.style.backgroundColor=b;c.bindOnClick(function(c){"transparent"===b?(a.stroke.transparent=!0,a.stroke.lineColor="#ffffff"):(a.stroke.transparent=!1,r&&(document.getElementById("entryPainterShapeBackgroundColor").style.backgroundColor=b,a.stroke.fillColor=b),r||(document.getElementById("entryPainterShapeLineColor").style.backgroundColor= +b,a.stroke.lineColor=b));document.getElementById("entryPainterAttrCircle").style.backgroundColor=a.stroke.lineColor;document.getElementById("entryPainterAttrCircleInput").value=b});n.appendChild(c)});this.attrThickArea=Entry.createElement("div","painterAttrThickArea");this.attrThickArea.addClass("entryPlaygroundentryPlaygroundPainterAttrThickArea");g.appendChild(this.attrThickArea);d=Entry.createElement("legend");d.addClass("painterAttrThickName");d.innerHTML=Lang.Workspace.thickness;this.attrThickArea.appendChild(d); +var m=Entry.createElement("fieldset","entryPainterAttrThick");m.addClass("entryPlaygroundPainterAttrThick");this.attrThickArea.appendChild(m);d=Entry.createElement("div");d.addClass("paintAttrThickTop");m.appendChild(d);e=Entry.createElement("select","entryPainterAttrThick");e.addClass("entryPlaygroundPainterAttrThickInput");e.size="1";e.onchange=function(b){a.stroke.thickness=b.target.value};for(d=1;10>=d;d++)c=Entry.createElement("option"),c.value=d,c.innerHTML=d,e.appendChild(c);m.appendChild(e); d=Entry.createElement("div","entryPainterShapeLineColor");d.addClass("painterAttrShapeLineColor");c=Entry.createElement("div","entryPainterShapeInnerBackground");c.addClass("painterAttrShapeInnerBackground");d.appendChild(c);m.appendChild(d);this.attrThickArea.painterAttrShapeLineColor=d;m.bindOnClick(function(){q.style.zIndex="1";this.style.zIndex="10";r=!1});this.attrBackgroundArea=Entry.createElement("div","painterAttrBackgroundArea");this.attrBackgroundArea.addClass("entryPlaygroundPainterBackgroundArea"); -g.appendChild(this.attrBackgroundArea);d=Entry.createElement("fieldset","entryPainterAttrbackground");d.addClass("entryPlaygroundPainterAttrBackground");this.attrBackgroundArea.appendChild(d);c=Entry.createElement("div");c.addClass("paintAttrBackgroundTop");d.appendChild(c);var q=Entry.createElement("div","entryPainterShapeBackgroundColor");q.addClass("painterAttrShapeBackgroundColor");this.attrBackgroundArea.painterAttrShapeBackgroundColor=q;c.appendChild(q);var r=!1;q.bindOnClick(function(b){m.style.zIndex= +g.appendChild(this.attrBackgroundArea);d=Entry.createElement("fieldset","entryPainterAttrbackground");d.addClass("entryPlaygroundPainterAttrBackground");this.attrBackgroundArea.appendChild(d);c=Entry.createElement("div");c.addClass("paintAttrBackgroundTop");d.appendChild(c);var q=Entry.createElement("div","entryPainterShapeBackgroundColor");q.addClass("painterAttrShapeBackgroundColor");this.attrBackgroundArea.painterAttrShapeBackgroundColor=q;c.appendChild(q);var r=!1;q.bindOnClick(function(a){m.style.zIndex= "1";this.style.zIndex="10";r=!0});this.attrFontArea=Entry.createElement("div","painterAttrFont");this.attrFontArea.addClass("entryPlaygroundPainterAttrFont");g.appendChild(this.attrFontArea);e=Entry.createElement("div");e.addClass("entryPlaygroundPainterAttrTop");this.attrFontArea.appendChild(e);d=Entry.createElement("div");d.addClass("entryPlaygroundPaintAttrTop_");e.appendChild(d);d=Entry.createElement("legend");d.addClass("panterAttrFontTitle");d.innerHTML=Lang.Workspace.textStyle;k=Entry.createElement("select", -"entryPainterAttrFontName");k.addClass("entryPlaygroundPainterAttrFontName");k.size="1";k.onchange=function(a){b.font.name=a.target.value};for(d=0;d=d;d++)c=Entry.createElement("option"),c.value=d,c.innerHTML=d,k.appendChild(c);e.appendChild(k);e=Entry.createElement("div");e.addClass("entryPlaygroundPainterAttrFontStyleArea");this.attrFontArea.appendChild(e);d=Entry.createElement("div");d.addClass("entryPlaygroundPainterAttrFontTop");e.appendChild(d);k=Entry.createElement("select","entryPainterAttrFontStyle"); -k.addClass("entryPlaygroundPainterAttrFontStyle");k.size="1";k.onchange=function(a){b.font.style=a.target.value};h=[{label:"\ubcf4\ud1b5",value:"normal"},{label:"\uad75\uac8c",value:"bold"},{label:"\uae30\uc6b8\uc784",value:"italic"}];for(d=0;d=d;d++)c=Entry.createElement("option"),c.value=d,c.innerHTML=d,k.appendChild(c);e.appendChild(k);e=Entry.createElement("div");e.addClass("entryPlaygroundPainterAttrFontStyleArea");this.attrFontArea.appendChild(e);d=Entry.createElement("div");d.addClass("entryPlaygroundPainterAttrFontTop");e.appendChild(d);k=Entry.createElement("select","entryPainterAttrFontStyle"); +k.addClass("entryPlaygroundPainterAttrFontStyle");k.size="1";k.onchange=function(b){a.font.style=b.target.value};h=[{label:"\ubcf4\ud1b5",value:"normal"},{label:"\uad75\uac8c",value:"bold"},{label:"\uae30\uc6b8\uc784",value:"italic"}];for(d=0;d":h=a-d;break;case ">=":h=a+1-d}return this.BasicIteration(b,h,f)};a.BlockStatement=function(b){var a=[];b=b.body;for(var d=0;d >= << >> >>> + - * / % , ^ & in instanceof".split(" ")}; -a.AssignmentExpression=function(b){throw{message:b.operator+"\uc740(\ub294) \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \uba85\ub839\uc5b4 \uc785\ub2c8\ub2e4.",node:b};};a.AssignmentOperator=function(){return"= += -= *= /= %= <<= >>= >>>= ,= ^= &=".split(" ")};a.LogicalExpression=function(b){throw{message:b.operator+"\uc740(\ub294) \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \uba85\ub839\uc5b4 \uc785\ub2c8\ub2e4.",node:b};};a.LogicalOperator=function(){return["||","&&"]};a.MemberExpression=function(b){var a= -b.object,d=b.property;console.log(a.type);a=this[a.type](a);console.log(a);d=this[d.type](d,a);if(Object(a)!==a||Object.getPrototypeOf(a)!==Object.prototype)throw{message:a+"\uc740(\ub294) \uc798\ubabb\ub41c \uba64\ubc84 \ubcc0\uc218\uc785\ub2c8\ub2e4.",node:b};a=d;if(!a)throw{message:d+"\uc774(\uac00) \uc874\uc7ac\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.",node:b};return a};a.ConditionalExpression=function(b){throw{message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", -node:b};};a.UpdateExpression=function(b){throw{message:b.operator+"\uc740(\ub294) \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \uba85\ub801\uc5b4 \uc785\ub2c8\ub2e4.",node:b};};a.CallExpression=function(b){b=b.callee;return{type:this[b.type](b)}};a.NewExpression=function(b){throw{message:"new\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.",node:b};};a.SequenceExpression=function(b){throw{message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", -node:b};};a.initScope=function(b){if(null===this.scope){var a=function(){};a.prototype=this.syntax.Scope}else a=function(){},a.prototype=this.scope;this.scope=new a;this.scopeChain.push(this.scope);return this.scanDefinition(b)};a.unloadScope=function(){this.scopeChain.pop();this.scope=this.scopeChain.length?this.scopeChain[this.scopeChain.length-1]:null};a.scanDefinition=function(b){b=b.body;for(var a=[],d=0;d=a.keyCode&&CodeMirror.showHint(b,null,{completeSingle:!1,globalScope:d})});break;case "block":this._parser=new Entry.BlockParser(this.syntax)}}; -(function(a){a.parse=function(b){var a=null;switch(this._lang){case "js":try{var d=acorn.parse(b),a=this._parser.Program(d)}catch(e){this.codeMirror&&(e instanceof SyntaxError?(b={from:{line:e.loc.line-1,ch:e.loc.column-2},to:{line:e.loc.line-1,ch:e.loc.column+1}},e.message="\ubb38\ubc95 \uc624\ub958\uc785\ub2c8\ub2e4."):(b=this.getLineNumber(e.node.start,e.node.end),b.message=e.message,b.severity="error",this.codeMirror.markText(b.from,b.to,{className:"CodeMirror-lint-mark-error",__annotation:b, -clearOnEnter:!0})),Entry.toast.alert("Error",e.message)),a=[]}break;case "block":b=this._parser.Code(b).match(/(.*{.*[\S|\s]+?}|.+)/g),a=Array.isArray(b)?b.reduce(function(b,a,c){1===c&&(b+="\n");return(-1=e&&g>=a)}};a.align=function(){var b=this.getPosition();this.svgGroup.attr({transform:"translate("+b.x+","+b.y+")"})};a.setPosition=function(){if(this.board){var b=this.board.svgDom;this._x=b.width()-110;this._y=b.height()-110;this.align()}};a.getPosition=function(){return{x:this._x,y:this._y}};a.tAnimation=function(b){if(b!==this.isOver){b=void 0===b?!0:b;var a,d=this.trashcanTop;a=b?{translateX:15,translateY:-25, -rotateZ:30}:{translateX:0,translateY:0,rotateZ:0};$(d).velocity(a,{duration:50});this.isOver=b}};a.setBoard=function(b){this._dragBlockObserver&&this._dragBlockObserver.destroy();this.board=b;this.svgGroup||this._generateView();var a=b.svg,d=a.firstChild;d?a.insertBefore(this.svgGroup,d):a.appendChild(this.svgGroup);this._dragBlockObserver=b.observe(this,"updateDragBlock",["dragBlock"]);this.svgGroup.attr({filter:"url(#entryTrashcanFilter_"+b.suffix+")"});this.setPosition()}})(Entry.FieldTrashcan.prototype);Entry.Workspace=function(a){Entry.Model(this,!1);this.observe(this,"_handleChangeBoard",["selectedBoard"],!1);this.trashcan=new Entry.FieldTrashcan;var b=a.blockMenu;b&&(this.blockMenu=new Entry.BlockMenu(b.dom,b.align,b.categoryData,b.scroll),this.blockMenu.workspace=this,this.blockMenu.observe(this,"_setSelectedBlockView",["selectedBlockView"],!1));if(b=a.board)b.workspace=this,this.board=new Entry.Board(b),this.board.observe(this,"_setSelectedBlockView",["selectedBlockView"],!1),this.set({selectedBoard:this.board}); -if(b=a.vimBoard)this.vimBoard=new Entry.Vim(b.dom),this.vimBoard.workspace=this;this.board&&this.vimBoard&&this.vimBoard.hide();Entry.GlobalSvg.createDom();this.mode=Entry.Workspace.MODE_BOARD;Entry.keyPressed&&Entry.keyPressed.attach(this,this._keyboardControl);this.changeEvent=new Entry.Event(this);Entry.commander.setCurrentEditor("board",this.board)};Entry.Workspace.MODE_BOARD=0;Entry.Workspace.MODE_VIMBOARD=1;Entry.Workspace.MODE_OVERLAYBOARD=2; -(function(a){a.schema={selectedBlockView:null,selectedBoard:null};a.getBoard=function(){return this.board};a.getSelectedBoard=function(){return this.selectedBoard};a.getBlockMenu=function(){return this.blockMenu};a.getVimBoard=function(){return this.vimBoard};a.getMode=function(){return this.mode};a.setMode=function(b,a){b=Number(b);var d=this.mode;this.mode=b;switch(b){case d:return;case Entry.Workspace.MODE_VIMBOARD:this.board&&this.board.hide();this.overlayBoard&&this.overlayBoard.hide();this.set({selectedBoard:this.vimBoard}); -this.vimBoard.show();this.vimBoard.codeToText(this.board.code);this.blockMenu.renderText();this.board.clear();break;case Entry.Workspace.MODE_BOARD:try{this.board.show(),this.set({selectedBoard:this.board}),this.textToCode(d),this.vimBoard&&this.vimBoard.hide(),this.overlayBoard&&this.overlayBoard.hide(),this.blockMenu.renderBlock()}catch(e){throw this.board&&this.board.hide(),this.set({selectedBoard:this.vimBoard}),Entry.dispatchEvent("setProgrammingMode",Entry.Workspace.MODE_VIMBOARD),e;}Entry.commander.setCurrentEditor("board", -this.board);break;case Entry.Workspace.MODE_OVERLAYBOARD:this.overlayBoard||this.initOverlayBoard(),this.overlayBoard.show(),this.set({selectedBoard:this.overlayBoard}),Entry.commander.setCurrentEditor("board",this.overlayBoard)}this.changeEvent.notify(a)};a.changeBoardCode=function(b){this.board.changeCode(b)};a.changeOverlayBoardCode=function(b){this.overlayBoard&&this.overlayBoard.changeCode(b)};a.changeBlockMenuCode=function(b){this.blockMenu.changeCode(b)};a.textToCode=function(b){if(b==Entry.Workspace.MODE_VIMBOARD){b= -this.vimBoard.textToCode();var a=this.board,d=a.code;d.load(b);d.createView(a);a.reDraw();this.board.alignThreads()}};a.codeToText=function(b){return this.vimBoard.codeToText(b)};a.getCodeToText=function(b){return this.vimBoard.getCodeToText(b)};a._setSelectedBlockView=function(){this.set({selectedBlockView:this.board.selectedBlockView||this.blockMenu.selectedBlockView||(this.overlayBoard?this.overlayBoard.selectedBlockView:null)})};a.initOverlayBoard=function(){this.overlayBoard=new Entry.Board({dom:this.board.view, -workspace:this,isOverlay:!0});this.overlayBoard.changeCode(new Entry.Code([]));this.overlayBoard.workspace=this;this.overlayBoard.observe(this,"_setSelectedBlockView",["selectedBlockView"],!1)};a._keyboardControl=function(b){var a=b.keyCode||b.which,d=b.ctrlKey;if(!Entry.Utils.isInInput(b)){var e=this.selectedBlockView;e&&!e.isInBlockMenu&&e.block.isDeletable()&&(8==a||46==a?(Entry.do("destroyBlock",e.block),b.preventDefault()):d&&(67==a?e.block.copyToClipboard():88==a&&(b=e.block,b.copyToClipboard(), -b.destroy(!0,!0),e.getBoard().setSelectedBlock(null))));d&&86==a&&(a=this.selectedBoard)&&a instanceof Entry.Board&&Entry.clipboard&&Entry.do("addThread",Entry.clipboard).value.getFirstBlock().copyToClipboard()}};a._handleChangeBoard=function(){var b=this.selectedBoard;b&&b.constructor===Entry.Board&&this.trashcan.setBoard(b)}})(Entry.Workspace.prototype);Entry.BlockDriver=function(){}; -(function(a){a.convert=function(){var b=new Date,a;for(a in Entry.block)"function"===typeof Entry.block[a]&&this._convertBlock(a);console.log((new Date).getTime()-b.getTime())};a._convertBlock=function(b){function a(b){var d={type:b.getAttribute("type"),index:{}};b=$(b).children();if(!b)return d;for(var e=0;e"+b[1], -a.addEventListener("click",function(){Entry.engine.toggleStop()}),this.view_.appendChild(a),this.curtainView_=a,Entry.pictureEditable&&(a=Entry.createElement("div","entryPicture"),a.addClass("entryPlaygroundPictureWorkspace"),a.addClass("entryRemove"),this.view_.appendChild(a),this.generatePictureView(a),this.pictureView_=a),a=Entry.createElement("div","entryText"),a.addClass("entryPlaygroundTextWorkspace"),a.addClass("entryRemove"),this.view_.appendChild(a),this.generateTextView(a),this.textView_= -a,Entry.soundEditable&&(a=Entry.createElement("div","entrySound"),a.addClass("entryPlaygroundSoundWorkspace"),a.addClass("entryRemove"),this.view_.appendChild(a),this.generateSoundView(a),this.soundView_=a),a=Entry.createElement("div","entryDefault"),a.addClass("entryPlaygroundDefaultWorkspace"),this.view_.appendChild(a),this.generateDefaultView(a),this.defaultView_=a,a=Entry.createElement("div","entryCode"),a.addClass("entryPlaygroundCodeWorkspace"),a.addClass("entryRemove"),this.view_.appendChild(a), -this.generateCodeView(a),this.codeView_=a,b=Entry.createElement("div"),b.addClass("entryPlaygroundResizeWorkspace","entryRemove"),this.resizeHandle_=b,this.view_.appendChild(b),this.initializeResizeHandle(b),this.codeView_=a,Entry.addEventListener("run",function(b){Entry.playground.curtainView_.removeClass("entryRemove")}),Entry.addEventListener("stop",function(b){Entry.playground.curtainView_.addClass("entryRemove")}))};Entry.Playground.prototype.generateDefaultView=function(a){return a}; -Entry.Playground.prototype.generateTabView=function(a){var b=this,c=Entry.createElement("ul");c.addClass("entryTabListWorkspace");this.tabList_=c;a.appendChild(c);this.tabViewElements={};a=Entry.createElement("li","entryCodeTab");a.innerHTML=Lang.Workspace.tab_code;a.addClass("entryTabListItemWorkspace");a.addClass("entryTabSelected");c.appendChild(a);a.bindOnClick(function(a){b.changeViewMode("code");b.blockMenu.reDraw()});this.tabViewElements.code=a;Entry.pictureEditable&&(a=Entry.createElement("li", -"entryPictureTab"),a.innerHTML=Lang.Workspace.tab_picture,a.addClass("entryTabListItemWorkspace"),c.appendChild(a),a.bindOnClick(function(b){Entry.playground.changeViewMode("picture")}),this.tabViewElements.picture=a,a=Entry.createElement("li","entryTextboxTab"),a.innerHTML=Lang.Workspace.tab_text,a.addClass("entryTabListItemWorkspace"),c.appendChild(a),a.bindOnClick(function(b){Entry.playground.changeViewMode("text")}),this.tabViewElements.text=a,a.addClass("entryRemove"));Entry.soundEditable&&(a= -Entry.createElement("li","entrySoundTab"),a.innerHTML=Lang.Workspace.tab_sound,a.addClass("entryTabListItemWorkspace"),c.appendChild(a),a.bindOnClick(function(b){Entry.playground.changeViewMode("sound")}),this.tabViewElements.sound=a);Entry.hasVariableManager&&(a=Entry.createElement("li","entryVariableTab"),a.innerHTML=Lang.Workspace.tab_attribute,a.addClass("entryTabListItemWorkspace"),a.addClass("entryVariableTabWorkspace"),c.appendChild(a),a.bindOnClick(function(b){Entry.playground.toggleOnVariableView(); -Entry.playground.changeViewMode("variable")}),this.tabViewElements.variable=a)}; -Entry.Playground.prototype.generateCodeView=function(a){var b=this.createVariableView();a.appendChild(b);this.variableView_=b;a=Entry.Dom(a);b=Entry.Dom("div",{parent:a,id:"entryWorkspaceBoard",class:"entryWorkspaceBoard"});a=Entry.Dom("div",{parent:a,id:"entryWorkspaceBlockMenu",class:"entryWorkspaceBlockMenu"});this.mainWorkspace=new Entry.Workspace({blockMenu:{dom:a,align:"LEFT",categoryData:EntryStatic.getAllBlocks(),scroll:!0},board:{dom:b}});this.blockMenu=this.mainWorkspace.blockMenu;this.board= -this.mainWorkspace.board;Entry.hw&&this.updateHW()}; -Entry.Playground.prototype.generatePictureView=function(a){if("workspace"==Entry.type){var b=Entry.createElement("div","entryAddPicture");b.addClass("entryPlaygroundAddPicture");b.bindOnClick(function(b){Entry.dispatchEvent("openPictureManager")});var c=Entry.createElement("div","entryAddPictureInner");c.addClass("entryPlaygroundAddPictureInner");c.innerHTML=Lang.Workspace.picture_add;b.appendChild(c);a.appendChild(b);b=Entry.createElement("ul","entryPictureList");b.addClass("entryPlaygroundPictureList"); -$&&$(b).sortable({start:function(b,a){a.item.data("start_pos",a.item.index())},stop:function(b,a){b=a.item.data("start_pos");a=a.item.index();Entry.playground.movePicture(b,a)},axis:"y"});a.appendChild(b);this.pictureListView_=b;b=Entry.createElement("div","entryPainter");b.addClass("entryPlaygroundPainter");a.appendChild(b);this.painter=new Entry.Painter;this.painter.initialize(b)}else"phone"==Entry.type&&(b=Entry.createElement("div","entryAddPicture"),b.addClass("entryPlaygroundAddPicturePhone"), -b.bindOnClick(function(b){Entry.dispatchEvent("openPictureManager")}),c=Entry.createElement("div","entryAddPictureInner"),c.addClass("entryPlaygroundAddPictureInnerPhone"),c.innerHTML=Lang.Workspace.picture_add,b.appendChild(c),a.appendChild(b),b=Entry.createElement("ul","entryPictureList"),b.addClass("entryPlaygroundPictureListPhone"),$&&$(b).sortable({start:function(b,a){a.item.data("start_pos",a.item.index())},stop:function(b,a){b=a.item.data("start_pos");a=a.item.index();Entry.playground.movePicture(b, -a)},axis:"y"}),a.appendChild(b),this.pictureListView_=b)}; -Entry.Playground.prototype.generateTextView=function(a){var b=Entry.createElement("div");a.appendChild(b);a=Entry.createElement("div");a.addClass("textProperties");b.appendChild(a);var c=Entry.createElement("div");c.addClass("entryTextFontSelect");a.appendChild(c);var d=Entry.createElement("select","entryPainterAttrFontName");d.addClass("entryPlaygroundPainterAttrFontName","entryTextFontSelecter");d.size="1";d.onchange=function(b){Entry.playground.object.entity.setFontType(b.target.value)};for(var e= -0;e p").html(Lang.Menus.linebreak_on_desc_1),$(".entryPlaygroundLinebreakDescription > ul > li").eq(0).html(Lang.Menus.linebreak_on_desc_2),$(".entryPlaygroundLinebreakDescription > ul > li").eq(1).html(Lang.Menus.linebreak_on_desc_3)); -Entry.playground.setFontAlign(Entry.playground.object.entity.getTextAlign());a=Entry.playground.object.entity.getFontSize();Entry.playground.fontSizeIndiciator.style.width=a+"%";Entry.playground.fontSizeKnob.style.left=.88*a+"px"}};Entry.Playground.prototype.injectSound=function(){var a=this.soundListView_;if(a){for(;a.hasChildNodes();)a.removeChild(a.lastChild);if(this.object)for(var b=this.object.sounds,c=0,d=b.length;c":h=b-d;break;case ">=":h=b+1-d}return this.BasicIteration(a,h,f)};b.BlockStatement=function(a){var b=[];a=a.body;for(var d=0;d >= << >> >>> + - * / % , ^ & in instanceof".split(" ")}; +b.AssignmentExpression=function(a){throw{message:a.operator+"\uc740(\ub294) \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \uba85\ub839\uc5b4 \uc785\ub2c8\ub2e4.",node:a};};b.AssignmentOperator=function(){return"= += -= *= /= %= <<= >>= >>>= ,= ^= &=".split(" ")};b.LogicalExpression=function(a){throw{message:a.operator+"\uc740(\ub294) \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \uba85\ub839\uc5b4 \uc785\ub2c8\ub2e4.",node:a};};b.LogicalOperator=function(){return["||","&&"]};b.MemberExpression=function(a){var b= +a.object,d=a.property;console.log(b.type);b=this[b.type](b);console.log(b);d=this[d.type](d,b);if(Object(b)!==b||Object.getPrototypeOf(b)!==Object.prototype)throw{message:b+"\uc740(\ub294) \uc798\ubabb\ub41c \uba64\ubc84 \ubcc0\uc218\uc785\ub2c8\ub2e4.",node:a};b=d;if(!b)throw{message:d+"\uc774(\uac00) \uc874\uc7ac\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.",node:a};return b};b.ConditionalExpression=function(a){throw{message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", +node:a};};b.UpdateExpression=function(a){throw{message:a.operator+"\uc740(\ub294) \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \uba85\ub801\uc5b4 \uc785\ub2c8\ub2e4.",node:a};};b.CallExpression=function(a){a=a.callee;return{type:this[a.type](a)}};b.NewExpression=function(a){throw{message:"new\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.",node:a};};b.SequenceExpression=function(a){throw{message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", +node:a};};b.initScope=function(a){if(null===this.scope){var b=function(){};b.prototype=this.syntax.Scope}else b=function(){},b.prototype=this.scope;this.scope=new b;this.scopeChain.push(this.scope);return this.scanDefinition(a)};b.unloadScope=function(){this.scopeChain.pop();this.scope=this.scopeChain.length?this.scopeChain[this.scopeChain.length-1]:null};b.scanDefinition=function(a){a=a.body;for(var b=[],d=0;d=b.keyCode&&CodeMirror.showHint(a,null,{completeSingle:!1,globalScope:d})});break;case "block":this._parser=new Entry.BlockParser(this.syntax)}}; +(function(b){b.parse=function(a){var b=null;switch(this._lang){case "js":try{var d=acorn.parse(a),b=this._parser.Program(d)}catch(e){this.codeMirror&&(e instanceof SyntaxError?(a={from:{line:e.loc.line-1,ch:e.loc.column-2},to:{line:e.loc.line-1,ch:e.loc.column+1}},e.message="\ubb38\ubc95 \uc624\ub958\uc785\ub2c8\ub2e4."):(a=this.getLineNumber(e.node.start,e.node.end),a.message=e.message,a.severity="error",this.codeMirror.markText(a.from,a.to,{className:"CodeMirror-lint-mark-error",__annotation:a, +clearOnEnter:!0})),Entry.toast.alert("Error",e.message)),b=[]}break;case "block":a=this._parser.Code(a).match(/(.*{.*[\S|\s]+?}|.+)/g),b=Array.isArray(a)?a.reduce(function(a,b,c){var d="";1===c&&(a+="\n");d=-1f+55)&&b>40+a*(g-f)&&(g=c.getNextScene())&&(g=$(g.view),$(document).trigger("mouseup"), -g.trigger("mousedown"))}),a=Entry.createElement("ul"),a.addClass("entrySceneListWorkspace"),Entry.sceneEditable&&$&&$(a).sortable({start:function(b,a){a.item.data("start_pos",a.item.index());$(a.item[0]).clone(!0)},stop:function(b,a){b=a.item.data("start_pos");a=a.item.index();Entry.scene.moveScene(b,a)},axis:"x",tolerance:"pointer"}),this.view_.appendChild(a),this.listView_=a,Entry.sceneEditable&&(a=Entry.createElement("span"),a.addClass("entrySceneElementWorkspace"),a.addClass("entrySceneAddButtonWorkspace"), -a.bindOnClick(function(b){Entry.engine.isState("run")||Entry.scene.addScene()}),this.view_.appendChild(a),this.addButton_=a))}; -Entry.Scene.prototype.generateElement=function(a){var b=this,c=Entry.createElement("li",a.id);c.addClass("entrySceneElementWorkspace");c.addClass("entrySceneButtonWorkspace");c.addClass("minValue");$(c).on("mousedown",function(b){Entry.engine.isState("run")?b.preventDefault():Entry.scene.selectScene(a)});var d=Entry.createElement("input");d.addClass("entrySceneFieldWorkspace");d.value=a.name;Entry.sceneEditable||(d.disabled="disabled");var e=Entry.createElement("span");e.addClass("entrySceneLeftWorkspace"); -c.appendChild(e);var f=Entry.createElement("span");f.addClass("entrySceneInputCover");f.style.width=Entry.computeInputWidth(a.name);c.appendChild(f);a.inputWrapper=f;d.onkeyup=function(c){c=c.keyCode;Entry.isArrowOrBackspace(c)||(a.name=this.value,f.style.width=Entry.computeInputWidth(a.name),b.resize(),13==c&&this.blur(),9=this.getScenes().length)Entry.toast.alert(Lang.Msgs.runtime_error,Lang.Workspace.Scene_delete_error,!1);else{var b=this.getScenes().indexOf(this.getSceneById(a.id));this.getScenes().splice(b,1);for(var b=Entry.container.getSceneObjects(a),c=0;c=this.maxCount)Entry.toast.alert(Lang.Msgs.runtime_error,Lang.Workspace.Scene_add_error,!1);else{var b={name:a.name+Lang.Workspace.replica_of_object,id:Entry.generateHash()};this.generateElement(b);this.addScene(b);a=Entry.container.getSceneObjects(a);for(var c=a.length-1;0<=c;c--)Entry.container.addCloneObject(a[c],b.id)}}; -Entry.Scene.prototype.resize=function(){var a=this.getScenes(),b=this.selectedScene,c=a[0];if(0!==a.length&&c){var d=$(c.view).offset().left,c=parseFloat($(b.view).css("margin-left")),e=$(this.view_).width()-d,f=0,g;for(g in a){var d=a[g],h=d.view;h.addClass("minValue");$(d.inputWrapper).width(Entry.computeInputWidth(d.name));h=$(h);f=f+h.width()+c}if(f>e)for(g in e-=$(b.view).width(),c=e/(a.length-1)-(Entry.Scene.viewBasicWidth+c),a)d=a[g],b.id!=d.id?(d.view.removeClass("minValue"),$(d.inputWrapper).width(c)): -d.view.addClass("minValue")}};Entry.Scene.prototype.getNextScene=function(){var a=this.getScenes();return a[a.indexOf(this.selectedScene)+1]};Entry.Script=function(a){this.entity=a};p=Entry.Script.prototype; -p.init=function(a,b,c){Entry.assert("BLOCK"==a.tagName.toUpperCase(),a.tagName);this.type=a.getAttribute("type");this.id=Number(a.getAttribute("id"));a.getElementsByTagName("mutation").length&&a.getElementsByTagName("mutation")[0].hasAttribute("hashid")&&(this.hashId=a.childNodes[0].getAttribute("hashid"));"REPEAT"==this.type.substr(0,6).toUpperCase()&&(this.isRepeat=!0);b instanceof Entry.Script&&(this.previousScript=b,b.parentScript&&(this.parentScript=b.parentScript));c instanceof Entry.Script&& -(this.parentScript=c);a=a.childNodes;for(b=0;b"+Lang.Menus[a]+"",{classes:["propertyTabElement","propertyTab"+a],parent:this._tabView}),f=this;e.bind("click",function(){f.select(a)});this.modes[a]&&(this.modes[a].tabDom.remove(),this.modes[a].contentDom.remove(),"hw"==a&&($(this.modes).removeClass(".propertyTabhw"),$(".propertyTabhw").unbind("dblclick")));this.modes[a]={obj:b,tabDom:e,contentDom:d};"hw"==a&&$(".propertyTabhw").bind("dblclick",function(){Entry.dispatchEvent("hwModeChange")})}; +b.resize=function(a){this._view.css({width:a+"px",top:9*a/16+123-22+"px"});430<=a?this._view.removeClass("collapsed"):this._view.addClass("collapsed");Entry.dispatchEvent("windowResized");a=this.selected;"hw"==a?this.modes.hw.obj.listPorts?this.modes[a].obj.resizeList():this.modes[a].obj.resize():this.modes[a].obj.resize()};b.select=function(a){for(var b in this.modes){var d=this.modes[b];d.tabDom.removeClass("selected");d.contentDom.addClass("entryRemove");d.obj.visible=!1}b=this.modes[a];b.tabDom.addClass("selected"); +b.contentDom.removeClass("entryRemove");b.obj.resize&&b.obj.resize();b.obj.visible=!0;this.selected=a};b.initializeSplitter=function(a){var b=this;a.bind("mousedown touchstart",function(a){b._cover.removeClass("entryRemove");Entry.container.disableSort();Entry.container.splitterEnable=!0;Entry.documentMousemove&&(Entry.container.resizeEvent=Entry.documentMousemove.attach(this,function(a){Entry.container.splitterEnable&&Entry.resizeElement({canvasWidth:a.clientX||a.x})}))});$(document).bind("mouseup touchend", +function(a){if(a=Entry.container.resizeEvent)Entry.container.splitterEnable=!1,Entry.documentMousemove.detach(a),b._cover.addClass("entryRemove"),delete Entry.container.resizeEvent;Entry.container.enableSort()})}})(Entry.PropertyPanel.prototype);Entry.init=function(b,a){Entry.assert("object"===typeof a,"Init option is not object");this.events_={};this.interfaceState={menuWidth:264};Entry.Utils.bindGlobalEvent("resize mousedown mousemove keydown keyup dispose".split(" "));this.options=a;this.parseOptions(a);this.mediaFilePath=(a.libDir?a.libDir:"/lib")+"/entryjs/images/";this.defaultPath=a.defaultDir||"";this.blockInjectPath=a.blockInjectDir||"";"workspace"==this.type&&this.isPhone()&&(this.type="phone");this.initialize_();this.view_=b;this.view_.setAttribute("class", +"entry");Entry.initFonts(a.fonts);this.createDom(b,this.type);this.loadInterfaceState();this.overridePrototype();this.maxCloneLimit=302;this.cloudSavable=!0;this.startTime=(new Date).getTime();document.onkeydown=function(a){Entry.dispatchEvent("keyPressed",a)};document.onkeyup=function(a){Entry.dispatchEvent("keyUpped",a)};window.onresize=function(a){Entry.dispatchEvent("windowResized",a)};window.onbeforeunload=this.beforeUnload;Entry.addEventListener("saveWorkspace",function(a){Entry.addActivity("save")}); +"IE"!=Entry.getBrowserType().substr(0,2)||window.flashaudio?createjs.Sound.registerPlugins([createjs.WebAudioPlugin]):(createjs.FlashAudioPlugin.swfPath=this.mediaFilePath+"media/",createjs.Sound.registerPlugins([createjs.FlashAudioPlugin]),window.flashaudio=!0);Entry.soundQueue=new createjs.LoadQueue;Entry.soundQueue.installPlugin(createjs.Sound);Entry.loadAudio_([Entry.mediaFilePath+"sounds/click.mp3",Entry.mediaFilePath+"sounds/click.wav",Entry.mediaFilePath+"sounds/click.ogg"],"entryMagneting"); +Entry.loadAudio_([Entry.mediaFilePath+"sounds/delete.mp3",Entry.mediaFilePath+"sounds/delete.ogg",Entry.mediaFilePath+"sounds/delete.wav"],"entryDelete");createjs.Sound.stop()};Entry.loadAudio_=function(b,a){if(window.Audio&&b.length)for(;0d+55)&&a>40+b*(h-d)&&(h=c.getNextScene())&&(h=$(h.view),$(document).trigger("mouseup"), +h.trigger("mousedown"))});var d=Entry.createElement("ul");d.addClass("entrySceneListWorkspace");Entry.sceneEditable&&$&&$(d).sortable({start:function(a,b){b.item.data("start_pos",b.item.index());$(b.item[0]).clone(!0)},stop:function(a,b){var c=b.item.data("start_pos"),d=b.item.index();Entry.scene.moveScene(c,d)},axis:"x",tolerance:"pointer"});this.view_.appendChild(d);this.listView_=d;Entry.sceneEditable&&(d=Entry.createElement("span"),d.addClass("entrySceneElementWorkspace"),d.addClass("entrySceneAddButtonWorkspace"), +d.bindOnClick(function(a){Entry.engine.isState("run")||Entry.scene.addScene()}),this.view_.appendChild(d),this.addButton_=d)}}; +Entry.Scene.prototype.generateElement=function(b){var a=this,c=Entry.createElement("li",b.id);c.addClass("entrySceneElementWorkspace");c.addClass("entrySceneButtonWorkspace");c.addClass("minValue");$(c).on("mousedown",function(a){Entry.engine.isState("run")?a.preventDefault():Entry.scene.selectScene(b)});var d=Entry.createElement("input");d.addClass("entrySceneFieldWorkspace");d.value=b.name;Entry.sceneEditable||(d.disabled="disabled");var e=Entry.createElement("span");e.addClass("entrySceneLeftWorkspace"); +c.appendChild(e);var f=Entry.createElement("span");f.addClass("entrySceneInputCover");f.style.width=Entry.computeInputWidth(b.name);c.appendChild(f);b.inputWrapper=f;d.onkeyup=function(c){c=c.keyCode;Entry.isArrowOrBackspace(c)||(b.name=this.value,f.style.width=Entry.computeInputWidth(b.name),a.resize(),13==c&&this.blur(),9=this.getScenes().length)Entry.toast.alert(Lang.Msgs.runtime_error,Lang.Workspace.Scene_delete_error,!1);else{var a=this.getScenes().indexOf(this.getSceneById(b.id));this.getScenes().splice(a,1);for(var a=Entry.container.getSceneObjects(b),c=0;c=this.maxCount)Entry.toast.alert(Lang.Msgs.runtime_error,Lang.Workspace.Scene_add_error,!1);else{var a={name:b.name+Lang.Workspace.replica_of_object,id:Entry.generateHash()};this.generateElement(a);this.addScene(a);b=Entry.container.getSceneObjects(b);for(var c=b.length-1;0<=c;c--)Entry.container.addCloneObject(b[c],a.id)}}; +Entry.Scene.prototype.resize=function(){var b=this.getScenes(),a=this.selectedScene,c=b[0];if(0!==b.length&&c){var d=$(c.view).offset().left,c=parseFloat($(a.view).css("margin-left")),e=$(this.view_).width()-d,f=0,g;for(g in b){var d=b[g],h=d.view;h.addClass("minValue");$(d.inputWrapper).width(Entry.computeInputWidth(d.name));h=$(h);f=f+h.width()+c}if(f>e)for(g in e-=$(a.view).width(),c=e/(b.length-1)-(Entry.Scene.viewBasicWidth+c),b)d=b[g],a.id!=d.id?(d.view.removeClass("minValue"),$(d.inputWrapper).width(c)): +d.view.addClass("minValue")}};Entry.Scene.prototype.getNextScene=function(){var b=this.getScenes();return b[b.indexOf(this.selectedScene)+1]};Entry.Script=function(b){this.entity=b};p=Entry.Script.prototype; +p.init=function(b,a,c){Entry.assert("BLOCK"==b.tagName.toUpperCase(),b.tagName);this.type=b.getAttribute("type");this.id=+b.getAttribute("id");b.getElementsByTagName("mutation").length&&b.getElementsByTagName("mutation")[0].hasAttribute("hashid")&&(this.hashId=b.childNodes[0].getAttribute("hashid"));"REPEAT"==this.type.substr(0,6).toUpperCase()&&(this.isRepeat=!0);a instanceof Entry.Script&&(this.previousScript=a,a.parentScript&&(this.parentScript=a.parentScript));c instanceof Entry.Script&&(this.parentScript= +c);b=b.childNodes;for(a=0;ad.style.opacity&&(clearInterval(a),d.style.display="none",Entry.removeElement(d));d.style.opacity*=.9},20)},1E3)}; +Entry.Toast.prototype.success=function(b,a,c){var d=Entry.createElement("div","entryToast");d.addClass("entryToast");d.addClass("entryToastSuccess");d.bindOnClick(function(){Entry.toast.body_.removeChild(this)});var e=Entry.createElement("div","entryToast");e.addClass("entryToastTitle");e.innerHTML=b;d.appendChild(e);b=Entry.createElement("p","entryToast");b.addClass("entryToastMessage");b.innerHTML=a;d.appendChild(b);this.toasts_.push(d);this.body_.appendChild(d);c||window.setTimeout(function(){d.style.opacity= +1;var a=setInterval(function(){.05>d.style.opacity&&(clearInterval(a),d.style.display="none",Entry.removeElement(d));d.style.opacity*=.9},20)},1E3)}; +Entry.Toast.prototype.alert=function(b,a,c){var d=Entry.createElement("div","entryToast");d.addClass("entryToast");d.addClass("entryToastAlert");d.bindOnClick(function(){Entry.toast.body_.removeChild(this)});var e=Entry.createElement("div","entryToast");e.addClass("entryToastTitle");e.innerHTML=b;d.appendChild(e);b=Entry.createElement("p","entryToast");b.addClass("entryToastMessage");b.innerHTML=a;d.appendChild(b);this.toasts_.push(d);this.body_.appendChild(d);c||window.setTimeout(function(){d.style.opacity= +1;var a=setInterval(function(){.05>d.style.opacity&&(clearInterval(a),d.style.display="none",Entry.toast.body_.removeChild(d));d.style.opacity*=.9},20)},5E3)};Entry.TvCast=function(b){this.generateView(b)};p=Entry.TvCast.prototype;p.init=function(b){this.tvCastHash=b};p.generateView=function(b){var a=Entry.createElement("div");a.addClass("entryContainerMovieWorkspace");a.addClass("entryRemove");this.movieContainer=a;a=Entry.createElement("iframe");a.setAttribute("id","tvCastIframe");a.setAttribute("allowfullscreen","");a.setAttribute("frameborder",0);a.setAttribute("src",b);this.movieFrame=a;this.movieContainer.appendChild(this.movieFrame)};p.getView=function(){return this.movieContainer}; +p.resize=function(){document.getElementById("entryContainerWorkspaceId");var b=document.getElementById("tvCastIframe");w=this.movieContainer.offsetWidth;b.width=w+"px";b.height=9*w/16+"px"};Entry.BlockDriver=function(){}; +(function(b){b.convert=function(){var a=new Date,b;for(b in Entry.block)"function"===typeof Entry.block[b]&&this._convertBlock(b);console.log((new Date).getTime()-a.getTime())};b._convertBlock=function(a){function b(a){var d={type:a.getAttribute("type"),index:{}};a=$(a).children();if(!a)return d;for(var e=0;eg&&(a.x-=d+3);a.y+e>f&&(a.y-=e);b.css({left:a.x,top:a.y})};b.hide=function(){this.dom.empty();this.dom.addClass("entryRemove");this._className&&(this.dom.removeClass(this._className),delete this._className)}})(Entry.ContextMenu);Entry.Loader={queueCount:0};Entry.Loader.addQueue=function(b){this.queueCount||Entry.dispatchEvent("loadStart");this.queueCount++};Entry.Loader.removeQueue=function(b){this.queueCount--;this.queueCount||Entry.dispatchEvent("loadComplete")};Entry.STATIC={OBJECT:0,ENTITY:1,SPRITE:2,SOUND:3,VARIABLE:4,FUNCTION:5,SCENE:6,MESSAGE:7,BLOCK_MODEL:8,BLOCK_RENDER_MODEL:9,BOX_MODEL:10,THREAD_MODEL:11,DRAG_INSTANCE:12,BLOCK_STATIC:0,BLOCK_MOVE:1,BLOCK_FOLLOW:2,RETURN:0,CONTINUE:1,BREAK:2,PASS:3};Entry.Utils={};Entry.overridePrototype=function(){Number.prototype.mod=function(b){return(this%b+b)%b}};Entry.Utils.generateId=function(){return("0000"+(Math.random()*Math.pow(36,4)<<0).toString(36)).substr(-4)};Entry.Utils.intersectArray=function(b,a){for(var c=[],d=0;d=a.x&&e-c<=a.y&&e+b.height+c>=a.y}; +Entry.Utils.colorDarken=function(b,a){function c(a){2!=a.length&&(a="0"+a);return a}var d,e,f;7===b.length?(d=parseInt(b.substr(1,2),16),e=parseInt(b.substr(3,2),16),f=parseInt(b.substr(5,2),16)):(d=parseInt(b.substr(1,2),16),e=parseInt(b.substr(2,2),16),f=parseInt(b.substr(3,2),16));a=void 0===a?.7:a;d=c(Math.floor(d*a).toString(16));e=c(Math.floor(e*a).toString(16));f=c(Math.floor(f*a).toString(16));return"#"+d+e+f}; +Entry.Utils.colorLighten=function(b,a){a=0===a?0:a||20;var c=Entry.Utils.hexToHsl(b);c.l+=a/100;c.l=Math.min(1,Math.max(0,c.l));return Entry.Utils.hslToHex(c)};Entry.Utils.bound01=function(b,a){var c=b;"string"==typeof c&&-1!=c.indexOf(".")&&1===parseFloat(c)&&(b="100%");c="string"===typeof b&&-1!=b.indexOf("%");b=Math.min(a,Math.max(0,parseFloat(b)));c&&(b=parseInt(b*a,10)/100);return 1E-6>Math.abs(b-a)?1:b%a/parseFloat(a)}; +Entry.Utils.hexToHsl=function(b){var a,c;7===b.length?(a=parseInt(b.substr(1,2),16),c=parseInt(b.substr(3,2),16),b=parseInt(b.substr(5,2),16)):(a=parseInt(b.substr(1,2),16),c=parseInt(b.substr(2,2),16),b=parseInt(b.substr(3,2),16));a=Entry.Utils.bound01(a,255);c=Entry.Utils.bound01(c,255);b=Entry.Utils.bound01(b,255);var d=Math.max(a,c,b),e=Math.min(a,c,b),f,g=(d+e)/2;if(d==e)f=e=0;else{var h=d-e,e=.5c&&(c+=1);1c?b:c<2/3?a+(b-a)*(2/3-c)*6:a}function c(a){return 1==a.length?"0"+a:""+a}var d,e;e=Entry.Utils.bound01(b.h,360);d=Entry.Utils.bound01(b.s,1);b=Entry.Utils.bound01(b.l,1);if(0===d)d=b=e=b;else{var f=.5>b?b*(1+d):b+d-b*d,g=2*b-f;d=a(g,f,e+1/3);b=a(g,f,e);e=a(g,f,e-1/3)}b*=255;e*=255;return"#"+[c(Math.round(255*d).toString(16)),c(Math.round(b).toString(16)),c(Math.round(e).toString(16))].join("")}; +Entry.Utils.bindGlobalEvent=function(b){var a=$(document);void 0===b&&(b="resize mousedown mousemove keydown keyup dispose".split(" "));-1Entry.pressedKeys.indexOf(b)&&Entry.pressedKeys.push(b);Entry.keyPressed.notify(a)}));-1$1://$2").replace(/([xA1-xFEa-z0-9_-]+@[xA1-xFEa-z0-9-]+.[a-z0-9-]+)/gi,"$1"):""};Entry.generateHash=function(){return("0000"+(Math.random()*Math.pow(36,4)<<0).toString(36)).substr(-4)}; +Entry.addEventListener=function(b,a){this.events_||(this.events_={});this.events_[b]||(this.events_[b]=[]);a instanceof Function&&this.events_[b].push(a);return!0};Entry.dispatchEvent=function(b,a){this.events_||(this.events_={});if(this.events_[b])for(var c=0,d=this.events_[b].length;c=f?(parseFloat(b)+parseFloat(a)).toFixed(e):(parseFloat(b)+parseFloat(a)).toFixed(f):parseInt(b)+parseInt(a)}; +Entry.hex2rgb=function(b){return(b=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(b))?{r:parseInt(b[1],16),g:parseInt(b[2],16),b:parseInt(b[3],16)}:null};Entry.rgb2hex=function(b,a,c){return"#"+(16777216+(b<<16)+(a<<8)+c).toString(16).slice(1)};Entry.generateRgb=function(){return{r:Math.floor(256*Math.random()),g:Math.floor(256*Math.random()),b:Math.floor(256*Math.random())}};Entry.adjustValueWithMaxMin=function(b,a,c){return b>c?c:ba.y+a.height||b.x+b.widtha.x+a.width)};Entry.bindAnimationCallback=function(b,a){b.addEventListener("webkitAnimationEnd",a,!1);b.addEventListener("animationend",a,!1);b.addEventListener("oanimationend",a,!1)};Entry.cloneSimpleObject=function(b){var a={},c;for(c in b)a[c]=b[c];return a};Entry.nodeListToArray=function(b){for(var a=Array(b.length),c=-1,d=b.length;++c!==d;a[c]=b[c]);return a}; +Entry.computeInputWidth=function(b){var a=document.createElement("span");a.className="tmp-element";a.innerHTML=b.replace(/&/g,"&").replace(//g,">");document.body.appendChild(a);b=a.offsetWidth;document.body.removeChild(a);return+(b+10)+"px"};Entry.isArrowOrBackspace=function(b){return-1<[37,38,39,40,8].indexOf(b)};Entry.hexStringToBin=function(b){for(var a=[],c=0;cd&&(d=h.index)}return 0a&&(a=e))}return Math.min(a,20)};Entry.convertToRoundedDecimals=function(b,a){return isNaN(b)||!this.isFloat(b)?b:+(Math.round(b+"e"+a)+"e-"+a)};Entry.attachEventListener=function(b,a,c){setTimeout(function(){b.addEventListener(a,c)},0)};Entry.deAttachEventListener=function(b,a,c){b.removeEventListener(a,c)}; +Entry.isEmpty=function(b){if(!b)return!0;for(var a in b)if(b.hasOwnProperty(a))return!1;return!0};Entry.Utils.disableContextmenu=function(b){if(b)$(b).on("contextmenu",function(a){a.stopPropagation();a.preventDefault();return!1})};Entry.Utils.isRightButton=function(b){return 2==b.button||b.ctrlKey};Entry.Utils.isTouchEvent=function(b){return"mousedown"!==b.type.toLowerCase()};Entry.Utils.inherit=function(b,a){function c(){}c.prototype=b.prototype;a.prototype=new c;return a}; +Entry.bindAnimationCallbackOnce=function(b,a){b.one("webkitAnimationEnd animationendo animationend",a)};Entry.Utils.isInInput=function(b){return"textarea"==b.target.type||"text"==b.target.type};Entry.Utils.isFunction=function(b){return"function"===typeof b}; +Entry.Utils.addFilters=function(b,a){var c=b.elem("defs"),d=c.elem("filter",{id:"entryTrashcanFilter_"+a});d.elem("feGaussianBlur",{"in":"SourceAlpha",stdDeviation:2,result:"blur"});d.elem("feOffset",{"in":"blur",dx:1,dy:1,result:"offsetBlur"});d=d.elem("feMerge");d.elem("feMergeNode",{"in":"offsetBlur"});d.elem("feMergeNode",{"in":"SourceGraphic"},d);d=c.elem("filter",{id:"entryBlockShadowFilter_"+a,height:"200%"});d.elem("feOffset",{result:"offOut",in:"SourceGraphic",dx:0,dy:1});d.elem("feColorMatrix", +{result:"matrixOut",in:"offOut",type:"matrix",values:"0.7 0 0 0 0 0 0.7 0 0 0 0 0 0.7 0 0 0 0 0 1 0"});d.elem("feBlend",{in:"SourceGraphic",in1:"offOut",mode:"normal"});c=c.elem("filter",{id:"entryBlockHighlightFilter_"+a});c.elem("feOffset",{result:"offOut",in:"SourceGraphic",dx:0,dy:0});c.elem("feColorMatrix",{result:"matrixOut",in:"offOut",type:"matrix",values:"1.3 0 0 0 0 0 1.3 0 0 0 0 0 1.3 0 0 0 0 0 1 0"})}; +Entry.Utils.addBlockPattern=function(b,a){for(var c=b.elem("pattern",{id:"blockHoverPattern_"+a,class:"blockHoverPattern",patternUnits:"userSpaceOnUse",patternTransform:"translate(12, 0)",x:0,y:0,width:125,height:33,style:"display: none"}),d=c.elem("g"),e=d.elem("rect",{x:0,y:0,width:125,height:33}),f=Entry.mediaFilePath+"block_pattern_(order).png",g=1;5>g;g++)d.elem("image",{class:"pattern"+g,href:f.replace("(order)",g),x:0,y:0,width:125,height:33});return{pattern:c,rect:e}}; +Entry.Utils.COLLISION={NONE:0,UP:1,RIGHT:2,LEFT:3,DOWN:4};Entry.Utils.createMouseEvent=function(b,a){var c=document.createEvent("MouseEvent");c.initMouseEvent(b,!0,!0,window,0,0,0,a.clientX,a.clientY,!1,!1,!1,!1,0,null);return c};Entry.Utils.xmlToJsonData=function(b){b=$.parseXML(b);var a=[];b=b.childNodes[0].childNodes;for(var c in b){var d=b[c];if(d.tagName){var e={category:d.getAttribute("id"),blocks:[]},d=d.childNodes;for(c in d){var f=d[c];f.tagName&&(f=f.getAttribute("type"))&&e.blocks.push(f)}a.push(e)}}return a}; +Entry.Utils.stopProjectWithToast=function(b,a){a=a||"\ub7f0\ud0c0\uc784 \uc5d0\ub7ec \ubc1c\uc0dd";Entry.toast&&Entry.toast.alert(Lang.Msgs.warn,Lang.Workspace.check_runtime_error,!0);Entry.engine&&Entry.engine.toggleStop();"workspace"===Entry.type&&(Entry.container.selectObject(b.getCode().object.id,!0),b.view.getBoard().activateBlock(b));throw Error(a);}; +window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(b){window.setTimeout(b,1E3/60)}}();Entry.Model=function(b,a){var c=Entry.Model;c.generateSchema(b);c.generateSetter(b);c.generateObserve(b);(void 0===a||a)&&Object.seal(b);return b}; +(function(b){b.generateSchema=function(a){var b=a.schema;if(void 0!==b){b=JSON.parse(JSON.stringify(b));a.data={};for(var d in b)(function(d){a.data[d]=b[d];Object.defineProperty(a,d,{get:function(){return a.data[d]}})})(d);a._toJSON=this._toJSON}};b.generateSetter=function(a){a.set=this.set};b.set=function(a,b){var d={},e;for(e in this.data)void 0!==a[e]&&(a[e]===this.data[e]?delete a[e]:(d[e]=this.data[e],this.data[e]=a[e]instanceof Array?a[e].concat():a[e]));b||this.notify(Object.keys(a),d)};b.generateObserve= +function(a){a.observers=[];a.observe=this.observe;a.unobserve=this.unobserve;a.notify=this.notify};b.observe=function(a,b,d,e){d=new Entry.Observer(this.observers,a,b,d);if(!1!==e)a[b]([]);return d};b.unobserve=function(a){a.destroy()};b.notify=function(a,b){"string"===typeof a&&(a=[a]);var d=this;d.observers.map(function(e){var f=a;void 0!==e.attrs&&(f=Entry.Utils.intersectArray(e.attrs,a));if(f.length)e.object[e.funcName](f.map(function(a){return{name:a,object:d,oldValue:b[a]}}))})};b._toJSON=function(){var a= +{},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={};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;if(b){b=this.content._blockMap;for(var c in b)Entry.Func.registerParamBlock(b[c].type); +Entry.Func.generateWsBlock(this)}Entry.Func.registerFunction(this);Entry.Func.updateMenu()};Entry.Func.threads={};Entry.Func.registerFunction=function(b){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;eBlockly.Block.dragMode_&&(b.updateMenu(),b.fieldText=a,b.workspaceLength=c)}}; +Entry.Func.setupMenuCode=function(){var b=Entry.playground.mainWorkspace;b&&(b=b.getBlockMenu().getCategoryCodes("func"),this._fieldLabel=b.createThread([{type:"function_field_label"}]).getFirstBlock(),this._fieldString=b.createThread([{type:"function_field_string",params:[{type:this.requestParamBlock("string")}]}]).getFirstBlock(),this._fieldBoolean=b.createThread([{type:"function_field_boolean",params:[{type:this.requestParamBlock("boolean")}]}]).getFirstBlock(),this.menuCode=b)}; +Entry.Func.refreshMenuCode=function(){if(Entry.playground.mainWorkspace){this.menuCode||this.setupMenuCode();var b=Entry.block[this._fieldString.params[0].type].changeEvent._listeners.length;2'));this._hwModule=b;var a=this;Entry.addEventListener("windowResized",function(){var b=a._hwModule.monitorTemplate.mode;"both"==b&&(a.resize(),a.resizeList());"list"==b?a.resizeList():a.resize()});Entry.addEventListener("hwModeChange",function(){a.changeMode()});this.changeOffset=0;this.scale=.5;this._listPortViews={}}; +(function(b){b.initView=function(){this.svgDom=Entry.Dom($(''))};b.generateView=function(){this.snap=Entry.SVG("hwMonitor");this._svgGroup=this.snap.elem("g");this._portMap={n:[],e:[],s:[],w:[]};var a=this._hwModule.monitorTemplate,b={href:Entry.mediaFilePath+a.imgPath,x:-a.width/2,y:-a.height/2,width:a.width,height:a.height};this._portViews={};this.hwView=this._svgGroup.elem("image");this.hwView= +this.hwView.attr(b);this._template=a;a=a.ports;this.pathGroup=null;this.pathGroup=this._svgGroup.elem("g");var b=[],d;for(d in a){var e=this.generatePortView(a[d],"_svgGroup");this._portViews[d]=e;b.push(e)}b.sort(function(a,b){return a.box.x-b.box.x});var f=this._portMap;b.map(function(a){(1>(Math.atan2(-a.box.y,a.box.x)/Math.PI+2)%2?f.n:f.s).push(a)});this.resize()};b.toggleMode=function(a){var b=this._hwModule.monitorTemplate;"list"==a?(b.TempPort=null,this._hwModule.monitorTemplate.ports&&(this._hwModule.monitorTemplate.TempPort= +this._hwModule.monitorTemplate.ports,this._hwModule.monitorTemplate.listPorts=this.addPortEle(this._hwModule.monitorTemplate.listPorts,this._hwModule.monitorTemplate.ports)),$(this._svglistGroup).remove(),this._svgGroup&&$(this._svgGroup).remove(),$(this._pathGroup).remove(),this._hwModule.monitorTemplate.mode="list",this.generateListView()):(this._hwModule.monitorTemplate.TempPort&&(this._hwModule.monitorTemplate.ports=this._hwModule.monitorTemplate.TempPort,this._hwModule.monitorTemplate.listPorts= +this.removePortEle(this._hwModule.monitorTemplate.listPorts,this._hwModule.monitorTemplate.ports)),$(this._svglistGroup).remove(),this._hwModule.monitorTemplate.mode="both",this.generateListView(),this.generateView())};b.setHwmonitor=function(a){this._hwmodule=a};b.changeMode=function(a){"both"==this._hwModule.monitorTemplate.mode?this.toggleMode("list"):"list"==this._hwModule.monitorTemplate.mode&&this.toggleMode("both")};b.addPortEle=function(a,b){if("object"!=typeof b)return a;for(var d in b)a[d]= +b[d];return a};b.removePortEle=function(a,b){if("object"!=typeof b)return a;for(var d in b)delete a[d];return a};b.generateListView=function(){this._portMapList={n:[]};this._svglistGroup=null;this.listsnap=Entry.SVG("hwMonitor");this._svglistGroup=this.listsnap.elem("g");var a=this._hwModule.monitorTemplate;this._template=a;a=a.listPorts;this.pathGroup=this._svglistGroup.elem("g");var b=[],d;for(d in a){var e=this.generatePortView(a[d],"_svglistGroup");this._listPortViews[d]=e;b.push(e)}var f=this._portMapList; +b.map(function(a){f.n.push(a)});this.resizeList()};b.generatePortView=function(a,b){var d=this[b].elem("g");d.addClass("hwComponent");var e=null,e=this.pathGroup.elem("path").attr({d:"m0,0",fill:"none",stroke:"input"===a.type?"#00979d":"#A751E3","stroke-width":3}),f=d.elem("rect").attr({x:0,y:0,width:150,height:22,rx:4,ry:4,fill:"#fff",stroke:"#a0a1a1"}),g=d.elem("text").attr({x:4,y:12,fill:"#000","class":"hwComponentName","alignment-baseline":"central"});g.textContent=a.name;g=g.getComputedTextLength(); +d.elem("rect").attr({x:g+8,y:2,width:30,height:18,rx:9,ry:9,fill:"input"===a.type?"#00979d":"#A751E3"});var h=d.elem("text").attr({x:g+13,y:12,fill:"#fff","class":"hwComponentValue","alignment-baseline":"central"});h.textContent=0;g+=40;f.attr({width:g});return{group:d,value:h,type:a.type,path:e,box:{x:a.pos.x-this._template.width/2,y:a.pos.y-this._template.height/2,width:g},width:g}};b.getView=function(){return this.svgDom};b.update=function(){var a=Entry.hw.portData,b=Entry.hw.sendQueue,d=this._hwModule.monitorTemplate.mode, +e=this._hwModule.monitorTemplate.keys||[],f=[];if("list"==d)f=this._listPortViews;else if("both"==d){if(f=this._listPortViews,this._portViews)for(var g in this._portViews)f[g]=this._portViews[g]}else f=this._portViews;if(b)for(g in b)0!=b[g]&&f[g]&&(f[g].type="output");for(var h in f)if(d=f[h],"input"==d.type){var k=a[h];0=this._template.height||0>=a.height||(this.scale=a.height/this._template.height* +this._template.height/1E3,this.align())};b.resizeList=function(){var a=this.svgDom.get(0).getBoundingClientRect();this._svglistGroup.attr({transform:"translate("+a.width/2+","+a.height/2+")"});this._rect=a;this.alignList()};b.align=function(){var a=[],a=this._portMap.s.concat();this._alignNS(a,this.scale/3*this._template.height+5,27);a=this._portMap.n.concat();this._alignNS(a,-this._template.height*this.scale/3-32,-27);a=this._portMap.e.concat();this._alignEW(a,-this._template.width*this.scale/3- +5,-27);a=this._portMap.w.concat();this._alignEW(a,this._template.width*this.scale/3-32,-27)};b.alignList=function(){for(var a={},a=this._hwModule.monitorTemplate.listPorts,b=a.length,d=0;dd-(l.width+n.width/2.2)&&(f+=1,initX=h,g=0)};b._movePort=function(a,b,d,e){var f=b,g=a.box.x*this.scale,h=a.box.y*this.scale; +b>e?(f=b-a.width,b=b>g&&g>e?"M"+g+","+d+"L"+g+","+h:"M"+(b+e)/2+","+d+"l0,"+(h>d?28:-3)+"H"+g+"L"+g+","+h):b=bd?28:-3)+"H"+g+"L"+g+","+h;a.group.attr({transform:"translate("+f+","+d+")"});a.path.attr({d:b})}})(Entry.HWMonitor.prototype);Entry.HW=function(){this.connectTrial=0;this.isFirstConnect=!0;this.initSocket();this.connected=!1;this.portData={};this.sendQueue={};this.outputQueue={};this.settingQueue={};this.socketType=this.hwModule=this.selectedDevice=null;Entry.addEventListener("stop",this.setZero);this.hwInfo={11:Entry.Arduino,12:Entry.SensorBoard,13:Entry.CODEino,14:Entry.joystick,15:Entry.dplay,16:Entry.nemoino,17:Entry.Xbot,18:Entry.ardublock,24:Entry.Hamster,25:Entry.Albert,31:Entry.Bitbrick,42:Entry.Arduino,51:Entry.Neobot, +71:Entry.Robotis_carCont,72:Entry.Robotis_openCM70,81:Entry.Arduino}};Entry.HW.TRIAL_LIMIT=1;p=Entry.HW.prototype; +p.initSocket=function(){try{if(this.connectTrial>=Entry.HW.TRIAL_LIMIT)this.isFirstConnect||Entry.toast.alert(Lang.Menus.connect_hw,Lang.Menus.connect_fail,!1),this.isFirstConnect=!1;else{var b=this,a,c;this.connected=!1;this.connectTrial++;if(-1d.style.opacity&&(clearInterval(b),d.style.display="none",Entry.removeElement(d));d.style.opacity*=.9},20)},1E3)}; -Entry.Toast.prototype.success=function(a,b,c){var d=Entry.createElement("div","entryToast");d.addClass("entryToast");d.addClass("entryToastSuccess");d.bindOnClick(function(){Entry.toast.body_.removeChild(this)});var e=Entry.createElement("div","entryToast");e.addClass("entryToastTitle");e.innerHTML=a;d.appendChild(e);a=Entry.createElement("p","entryToast");a.addClass("entryToastMessage");a.innerHTML=b;d.appendChild(a);this.toasts_.push(d);this.body_.appendChild(d);c||window.setTimeout(function(){d.style.opacity= -1;var b=setInterval(function(){.05>d.style.opacity&&(clearInterval(b),d.style.display="none",Entry.removeElement(d));d.style.opacity*=.9},20)},1E3)}; -Entry.Toast.prototype.alert=function(a,b,c){var d=Entry.createElement("div","entryToast");d.addClass("entryToast");d.addClass("entryToastAlert");d.bindOnClick(function(){Entry.toast.body_.removeChild(this)});var e=Entry.createElement("div","entryToast");e.addClass("entryToastTitle");e.innerHTML=a;d.appendChild(e);a=Entry.createElement("p","entryToast");a.addClass("entryToastMessage");a.innerHTML=b;d.appendChild(a);this.toasts_.push(d);this.body_.appendChild(d);c||window.setTimeout(function(){d.style.opacity= -1;var b=setInterval(function(){.05>d.style.opacity&&(clearInterval(b),d.style.display="none",Entry.toast.body_.removeChild(d));d.style.opacity*=.9},20)},5E3)};Entry.TvCast=function(a){this.generateView(a)};p=Entry.TvCast.prototype;p.init=function(a){this.tvCastHash=a};p.generateView=function(a){var b=Entry.createElement("div");b.addClass("entryContainerMovieWorkspace");b.addClass("entryRemove");this.movieContainer=b;b=Entry.createElement("iframe");b.setAttribute("id","tvCastIframe");b.setAttribute("allowfullscreen","");b.setAttribute("frameborder",0);b.setAttribute("src",a);this.movieFrame=b;this.movieContainer.appendChild(this.movieFrame)};p.getView=function(){return this.movieContainer}; -p.resize=function(){document.getElementById("entryContainerWorkspaceId");var a=document.getElementById("tvCastIframe");w=this.movieContainer.offsetWidth;a.width=w+"px";a.height=9*w/16+"px"};Entry.ContextMenu={}; -(function(a){a.createDom=function(){this.dom=Entry.Dom("ul",{id:"entry-contextmenu",parent:$("body")});Entry.Utils.disableContextmenu(this.dom);Entry.documentMousedown.attach(this,function(){this.hide()})};a.show=function(b,a){this.dom||this.createDom();if(0!==b.length){var d=this;void 0!==a&&(this._className=a,this.dom.addClass(a));a=this.dom;a.empty();for(var e=0,f=b.length;eg&&(b.x-=d+3);b.y+e>f&&(b.y-=e);a.css({left:b.x,top:b.y})};a.hide=function(){this.dom.empty();this.dom.addClass("entryRemove");this._className&&(this.dom.removeClass(this._className),delete this._className)}})(Entry.ContextMenu);Entry.Loader={queueCount:0};Entry.Loader.addQueue=function(a){this.queueCount||Entry.dispatchEvent("loadStart");this.queueCount++};Entry.Loader.removeQueue=function(a){this.queueCount--;this.queueCount||Entry.dispatchEvent("loadComplete")};Entry.Variable=function(a){Entry.assert("string"==typeof a.name,"Variable name must be given");this.name_=a.name;this.id_=a.id?a.id:Entry.generateHash();this.type=a.variableType?a.variableType:"variable";this.object_=a.object||null;this.isCloud_=a.isCloud||!1;this._valueWidth=this._nameWidth=null;var b=Entry.parseNumber(a.value);this.value_="number"==typeof b?b:a.value?a.value:0;"slide"==this.type?(this.minValue_=Number(a.minValue?a.minValue:0),this.maxValue_=Number(a.maxValue?a.maxValue:100)):"list"== -this.type&&(this.array_=a.array?a.array:[]);a.isClone||(this.visible_=a.visible||"boolean"==typeof a.visible?a.visible:!0,this.x_=a.x?a.x:null,this.y_=a.y?a.y:null,"list"==this.type&&(this.width_=a.width?a.width:100,this.height_=a.height?a.height:120,this.scrollPosition=0),this.BORDER=6,this.FONT="10pt NanumGothic")}; -Entry.Variable.prototype.generateView=function(a){var b=this.type;if("variable"==b||"timer"==b||"answer"==b)this.view_=new createjs.Container,this.rect_=new createjs.Shape,this.view_.addChild(this.rect_),this.view_.variable=this,this.wrapper_=new createjs.Shape,this.view_.addChild(this.wrapper_),this.textView_=new createjs.Text("asdf",this.FONT,"#000000"),this.textView_.textBaseline="alphabetic",this.textView_.x=4,this.textView_.y=1,this.view_.addChild(this.textView_),this.valueView_=new createjs.Text("asdf", -"10pt NanumGothic","#ffffff"),this.valueView_.textBaseline="alphabetic",b=Entry.variableContainer.variables_.length,this.getX()&&this.getY()?(this.setX(this.getX()),this.setY(this.getY())):(this.setX(-230+80*Math.floor(b/11)),this.setY(24*a+20-135-264*Math.floor(b/11))),this.view_.visible=this.visible_,this.view_.addChild(this.valueView_),this.view_.on("mousedown",function(b){"workspace"==Entry.type&&(this.offset={x:this.x-(.75*b.stageX-240),y:this.y-(.75*b.stageY-135)},this.cursor="move")}),this.view_.on("pressmove", -function(b){"workspace"==Entry.type&&(this.variable.setX(.75*b.stageX-240+this.offset.x),this.variable.setY(.75*b.stageY-135+this.offset.y),this.variable.updateView())});else if("slide"==b){var c=this;this.view_=new createjs.Container;this.rect_=new createjs.Shape;this.view_.addChild(this.rect_);this.view_.variable=this;this.wrapper_=new createjs.Shape;this.view_.addChild(this.wrapper_);this.textView_=new createjs.Text("name",this.FONT,"#000000");this.textView_.textBaseline="alphabetic";this.textView_.x= -4;this.textView_.y=1;this.view_.addChild(this.textView_);this.valueView_=new createjs.Text("value","10pt NanumGothic","#ffffff");this.valueView_.textBaseline="alphabetic";this.view_.on("mousedown",function(b){"workspace"==Entry.type&&(this.offset={x:this.x-(.75*b.stageX-240),y:this.y-(.75*b.stageY-135)})});this.view_.on("pressmove",function(b){"workspace"!=Entry.type||c.isAdjusting||(this.variable.setX(.75*b.stageX-240+this.offset.x),this.variable.setY(.75*b.stageY-135+this.offset.y),this.variable.updateView())}); -this.view_.visible=this.visible_;this.view_.addChild(this.valueView_);b=this.textView_.getMeasuredWidth()+this.valueView_.getMeasuredWidth()+26;b=Math.max(b,90);this.maxWidth=b-20;this.slideBar_=new createjs.Shape;this.slideBar_.graphics.beginFill("#A0A1A1").s("#A0A1A1").ss(1).dr(10,10,this.maxWidth,1.5);this.view_.addChild(this.slideBar_);b=this.getSlidePosition(this.maxWidth);this.valueSetter_=new createjs.Shape;this.valueSetter_.graphics.beginFill("#1bafea").s("#A0A1A1").ss(1).dc(b,10.5,3);this.valueSetter_.cursor= -"pointer";this.valueSetter_.on("mousedown",function(b){Entry.engine.isState("run")&&(c.isAdjusting=!0,this.offsetX=-(this.x-.75*b.stageX+240))});this.valueSetter_.on("pressmove",function(b){if(Entry.engine.isState("run")){var a=this.offsetX;this.offsetX=-(this.x-.75*b.stageX+240);a!==this.offsetX&&(b=c.getX(),c.setSlideCommandX(b+10>this.offsetX?0:b+c.maxWidth+10>this.offsetX?this.offsetX-b:c.maxWidth+10))}});this.valueSetter_.on("pressup",function(b){c.isAdjusting=!1});this.view_.addChild(this.valueSetter_); -b=Entry.variableContainer.variables_.length;this.getX()&&this.getY()?(this.setX(this.getX()),this.setY(this.getY())):(this.setX(-230+80*Math.floor(b/11)),this.setY(24*a+20-135-264*Math.floor(b/11)))}else this.view_=new createjs.Container,this.rect_=new createjs.Shape,this.view_.addChild(this.rect_),this.view_.variable=this,this.titleView_=new createjs.Text("asdf",this.FONT,"#000"),this.titleView_.textBaseline="alphabetic",this.titleView_.textAlign="center",this.titleView_.width=this.width_-2*this.BORDER, -this.titleView_.y=this.BORDER+10,this.titleView_.x=this.width_/2,this.view_.addChild(this.titleView_),this.resizeHandle_=new createjs.Shape,this.resizeHandle_.graphics.f("#1bafea").ss(1,0,0).s("#1bafea").lt(0,-9).lt(-9,0).lt(0,0),this.view_.addChild(this.resizeHandle_),this.resizeHandle_.list=this,this.resizeHandle_.on("mouseover",function(b){this.cursor="nwse-resize"}),this.resizeHandle_.on("mousedown",function(b){this.list.isResizing=!0;this.offset={x:.75*b.stageX-this.list.getWidth(),y:.75*b.stageY- -this.list.getHeight()};this.parent.cursor="nwse-resize"}),this.resizeHandle_.on("pressmove",function(b){this.list.setWidth(.75*b.stageX-this.offset.x);this.list.setHeight(.75*b.stageY-this.offset.y);this.list.updateView()}),this.view_.on("mouseover",function(b){this.cursor="move"}),this.view_.on("mousedown",function(b){"workspace"!=Entry.type||this.variable.isResizing||(this.offset={x:this.x-(.75*b.stageX-240),y:this.y-(.75*b.stageY-135)},this.cursor="move")}),this.view_.on("pressup",function(b){this.cursor= -"initial";this.variable.isResizing=!1}),this.view_.on("pressmove",function(b){"workspace"!=Entry.type||this.variable.isResizing||(this.variable.setX(.75*b.stageX-240+this.offset.x),this.variable.setY(.75*b.stageY-135+this.offset.y),this.variable.updateView())}),this.elementView=new createjs.Container,b=new createjs.Text("asdf",this.FONT,"#000"),b.textBaseline="middle",b.y=5,this.elementView.addChild(b),this.elementView.indexView=b,b=new createjs.Shape,this.elementView.addChild(b),this.elementView.valueWrapper= -b,b=new createjs.Text("fdsa",this.FONT,"#eee"),b.x=24,b.y=6,b.textBaseline="middle",this.elementView.addChild(b),this.elementView.valueView=b,this.elementView.x=this.BORDER,this.scrollButton_=new createjs.Shape,this.scrollButton_.graphics.f("#aaa").rr(0,0,7,30,3.5),this.view_.addChild(this.scrollButton_),this.scrollButton_.y=23,this.scrollButton_.list=this,this.scrollButton_.on("mousedown",function(b){this.list.isResizing=!0;this.cursor="pointer";this.offsetY=isNaN(this.offsetY)||0>this.offsetY?b.rawY/ -2:this.offsetY}),this.scrollButton_.on("pressmove",function(b){void 0===this.moveAmount?(this.y=b.target.y,this.moveAmount=!0):this.y=b.rawY/2-this.offsetY+this.list.height_/100*23;23>this.y&&(this.y=23);this.y>this.list.getHeight()-40&&(this.y=this.list.getHeight()-40);this.list.updateView()}),this.scrollButton_.on("pressup",function(b){this.moveAmount=void 0}),this.getX()&&this.getY()?(this.setX(this.getX()),this.setY(this.getY())):(b=Entry.variableContainer.lists_.length,this.setX(110*-Math.floor(b/ -6)+120),this.setY(24*a+20-135-145*Math.floor(b/6)));this.setVisible(this.isVisible());this.updateView();Entry.stage.loadVariable(this)}; -Entry.Variable.prototype.updateView=function(){if(this.view_){if(this.isVisible())if("variable"==this.type){this.view_.x=this.getX();this.view_.y=this.getY();if(this.object_){var a=Entry.container.getObject(this.object_);this.textView_.text=a?a.name+":"+this.getName():this.getName()}else this.textView_.text=this.getName();null===this._nameWidth&&(this._nameWidth=this.textView_.getMeasuredWidth());this.valueView_.x=this._nameWidth+14;this.valueView_.y=1;this.isNumber()?this.valueView_.text=this.getValue().toFixed(2).replace(".00", -""):this.valueView_.text=this.getValue();null===this._valueWidth&&(this._valueWidth=this.valueView_.getMeasuredWidth());this.rect_.graphics.clear().f("#ffffff").ss(1,2,0).s("#A0A1A1").rc(0,-14,this._nameWidth+this._valueWidth+26,20,4,4,4,4);this.wrapper_.graphics.clear().f("#1bafea").ss(1,2,0).s("#1bafea").rc(this._nameWidth+7,-11,this._valueWidth+15,14,7,7,7,7)}else if("slide"==this.type)this.view_.x=this.getX(),this.view_.y=this.getY(),this.object_?(a=Entry.container.getObject(this.object_),this.textView_.text= -a?a.name+":"+this.getName():this.getName()):this.textView_.text=this.getName(),null===this._nameWidth&&(this._nameWidth=this.textView_.getMeasuredWidth()),this.valueView_.x=this._nameWidth+14,this.valueView_.y=1,this.isNumber()?this.valueView_.text=this.getValue().toFixed(2).replace(".00",""):this.valueView_.text=this.getValue(),null===this._valueWidth&&(this._valueWidth=this.valueView_.getMeasuredWidth()),a=this._nameWidth+this._valueWidth+26,a=Math.max(a,90),this.rect_.graphics.clear().f("#ffffff").ss(1, -2,0).s("#A0A1A1").rc(0,-14,a,33,4,4,4,4),this.wrapper_.graphics.clear().f("#1bafea").ss(1,2,0).s("#1bafea").rc(this._nameWidth+7,-11,this._valueWidth+15,14,7,7,7,7),a=this._nameWidth+this._valueWidth+26,a=Math.max(a,90),this.maxWidth=a-20,this.slideBar_.graphics.clear().beginFill("#A0A1A1").s("#A0A1A1").ss(1).dr(10,10,this.maxWidth,1.5),a=this.getSlidePosition(this.maxWidth),this.valueSetter_.graphics.clear().beginFill("#1bafea").s("#A0A1A1").ss(1).dc(a,10.5,3);else if("list"==this.type){this.view_.x= -this.getX();this.view_.y=this.getY();this.resizeHandle_.x=this.width_-2;this.resizeHandle_.y=this.height_-2;var b=this.getName();this.object_&&(a=Entry.container.getObject(this.object_))&&(b=a.name+":"+b);b=7this.getHeight()-40&&(this.scrollButton_.y=this.getHeight()-40),this.elementView.valueWrapper.graphics.clear().f("#1bafea").rr(20,-2,this.getWidth()-20-10-2*this.BORDER,17,2),this.scrollButton_.visible=!0,this.scrollButton_.x=this.getWidth()-12,this.scrollPosition=Math.floor((this.scrollButton_.y-23)/(this.getHeight()-23-40)*(this.array_.length-a))):(this.elementView.valueWrapper.graphics.clear().f("#1bafea").rr(20,-2,this.getWidth()-20-2*this.BORDER, -17,2),this.scrollButton_.visible=!1,this.scrollPosition=0);for(b=this.scrollPosition;bc.length?c+"..":c;this.elementView.valueView.text=c;c=this.elementView.clone(!0);c.y=20*(b-this.scrollPosition)+23;this.view_.addChild(c)}}else"answer"==this.type?(this.view_.x=this.getX(),this.view_.y= +Entry.Stage.prototype.initObjectContainers=function(){var b=Entry.scene.scenes_;if(b&&0!==b.length){for(var a=0;athis.offsetX?0:a+c.maxWidth+10>this.offsetX?this.offsetX-a:c.maxWidth+10))}});this.valueSetter_.on("pressup",function(a){c.isAdjusting=!1});this.view_.addChild(this.valueSetter_); +a=Entry.variableContainer.variables_.length;this.getX()&&this.getY()?(this.setX(this.getX()),this.setY(this.getY())):(this.setX(-230+80*Math.floor(a/11)),this.setY(24*b+20-135-264*Math.floor(a/11)))}else this.view_=new createjs.Container,this.rect_=new createjs.Shape,this.view_.addChild(this.rect_),this.view_.variable=this,this.titleView_=new createjs.Text("asdf",this.FONT,"#000"),this.titleView_.textBaseline="alphabetic",this.titleView_.textAlign="center",this.titleView_.width=this.width_-2*this.BORDER, +this.titleView_.y=this.BORDER+10,this.titleView_.x=this.width_/2,this.view_.addChild(this.titleView_),this.resizeHandle_=new createjs.Shape,this.resizeHandle_.graphics.f("#1bafea").ss(1,0,0).s("#1bafea").lt(0,-9).lt(-9,0).lt(0,0),this.view_.addChild(this.resizeHandle_),this.resizeHandle_.list=this,this.resizeHandle_.on("mouseover",function(a){this.cursor="nwse-resize"}),this.resizeHandle_.on("mousedown",function(a){this.list.isResizing=!0;this.offset={x:.75*a.stageX-this.list.getWidth(),y:.75*a.stageY- +this.list.getHeight()};this.parent.cursor="nwse-resize"}),this.resizeHandle_.on("pressmove",function(a){this.list.setWidth(.75*a.stageX-this.offset.x);this.list.setHeight(.75*a.stageY-this.offset.y);this.list.updateView()}),this.view_.on("mouseover",function(a){this.cursor="move"}),this.view_.on("mousedown",function(a){"workspace"!=Entry.type||this.variable.isResizing||(this.offset={x:this.x-(.75*a.stageX-240),y:this.y-(.75*a.stageY-135)},this.cursor="move")}),this.view_.on("pressup",function(a){this.cursor= +"initial";this.variable.isResizing=!1}),this.view_.on("pressmove",function(a){"workspace"!=Entry.type||this.variable.isResizing||(this.variable.setX(.75*a.stageX-240+this.offset.x),this.variable.setY(.75*a.stageY-135+this.offset.y),this.variable.updateView())}),this.elementView=new createjs.Container,a=new createjs.Text("asdf",this.FONT,"#000"),a.textBaseline="middle",a.y=5,this.elementView.addChild(a),this.elementView.indexView=a,a=new createjs.Shape,this.elementView.addChild(a),this.elementView.valueWrapper= +a,a=new createjs.Text("fdsa",this.FONT,"#eee"),a.x=24,a.y=6,a.textBaseline="middle",this.elementView.addChild(a),this.elementView.valueView=a,this.elementView.x=this.BORDER,this.scrollButton_=new createjs.Shape,this.scrollButton_.graphics.f("#aaa").rr(0,0,7,30,3.5),this.view_.addChild(this.scrollButton_),this.scrollButton_.y=23,this.scrollButton_.list=this,this.scrollButton_.on("mousedown",function(a){this.list.isResizing=!0;this.cursor="pointer";this.offsetY=isNaN(this.offsetY)||0>this.offsetY?a.rawY/ +2:this.offsetY}),this.scrollButton_.on("pressmove",function(a){void 0===this.moveAmount?(this.y=a.target.y,this.moveAmount=!0):this.y=a.rawY/2-this.offsetY+this.list.height_/100*23;23>this.y&&(this.y=23);this.y>this.list.getHeight()-40&&(this.y=this.list.getHeight()-40);this.list.updateView()}),this.scrollButton_.on("pressup",function(a){this.moveAmount=void 0}),this.getX()&&this.getY()?(this.setX(this.getX()),this.setY(this.getY())):(a=Entry.variableContainer.lists_.length,this.setX(110*-Math.floor(a/ +6)+120),this.setY(24*b+20-135-145*Math.floor(a/6)));this.setVisible(this.isVisible());this.updateView();Entry.stage.loadVariable(this)}; +Entry.Variable.prototype.updateView=function(){if(this.view_){if(this.isVisible())if("variable"==this.type){this.view_.x=this.getX();this.view_.y=this.getY();if(this.object_){var b=Entry.container.getObject(this.object_);this.textView_.text=b?b.name+":"+this.getName():this.getName()}else this.textView_.text=this.getName();null===this._nameWidth&&(this._nameWidth=this.textView_.getMeasuredWidth());this.valueView_.x=this._nameWidth+14;this.valueView_.y=1;this.isNumber()?this.valueView_.text=this.getValue().toFixed(2).replace(".00", +""):this.valueView_.text=this.getValue();null===this._valueWidth&&(this._valueWidth=this.valueView_.getMeasuredWidth());this.rect_.graphics.clear().f("#ffffff").ss(1,2,0).s("#A0A1A1").rc(0,-14,this._nameWidth+this._valueWidth+26,20,4,4,4,4);this.wrapper_.graphics.clear().f("#1bafea").ss(1,2,0).s("#1bafea").rc(this._nameWidth+7,-11,this._valueWidth+15,14,7,7,7,7)}else if("slide"==this.type)this.view_.x=this.getX(),this.view_.y=this.getY(),this.object_?(b=Entry.container.getObject(this.object_),this.textView_.text= +b?b.name+":"+this.getName():this.getName()):this.textView_.text=this.getName(),null===this._nameWidth&&(this._nameWidth=this.textView_.getMeasuredWidth()),this.valueView_.x=this._nameWidth+14,this.valueView_.y=1,this.isNumber()?this.valueView_.text=this.getValue().toFixed(2).replace(".00",""):this.valueView_.text=this.getValue(),null===this._valueWidth&&(this._valueWidth=this.valueView_.getMeasuredWidth()),b=this._nameWidth+this._valueWidth+26,b=Math.max(b,90),this.rect_.graphics.clear().f("#ffffff").ss(1, +2,0).s("#A0A1A1").rc(0,-14,b,33,4,4,4,4),this.wrapper_.graphics.clear().f("#1bafea").ss(1,2,0).s("#1bafea").rc(this._nameWidth+7,-11,this._valueWidth+15,14,7,7,7,7),b=this._nameWidth+this._valueWidth+26,b=Math.max(b,90),this.maxWidth=b-20,this.slideBar_.graphics.clear().beginFill("#A0A1A1").s("#A0A1A1").ss(1).dr(10,10,this.maxWidth,1.5),b=this.getSlidePosition(this.maxWidth),this.valueSetter_.graphics.clear().beginFill("#1bafea").s("#A0A1A1").ss(1).dc(b,10.5,3);else if("list"==this.type){this.view_.x= +this.getX();this.view_.y=this.getY();this.resizeHandle_.x=this.width_-2;this.resizeHandle_.y=this.height_-2;var a=this.getName();this.object_&&(b=Entry.container.getObject(this.object_))&&(a=b.name+":"+a);a=7this.getHeight()-40&&(this.scrollButton_.y=this.getHeight()-40),this.elementView.valueWrapper.graphics.clear().f("#1bafea").rr(20,-2,this.getWidth()-20-10-2*this.BORDER,17,2),this.scrollButton_.visible=!0,this.scrollButton_.x=this.getWidth()-12,this.scrollPosition=Math.floor((this.scrollButton_.y-23)/(this.getHeight()-23-40)*(this.array_.length-b))):(this.elementView.valueWrapper.graphics.clear().f("#1bafea").rr(20,-2,this.getWidth()-20-2*this.BORDER, +17,2),this.scrollButton_.visible=!1,this.scrollPosition=0);for(a=this.scrollPosition;ac.length?c+"..":c;this.elementView.valueView.text=c;c=this.elementView.clone(!0);c.y=20*(a-this.scrollPosition)+23;this.view_.addChild(c)}}else"answer"==this.type?(this.view_.x=this.getX(),this.view_.y= this.getY(),this.textView_.text=this.getName(),this.valueView_.y=1,this.isNumber()?parseInt(this.getValue(),10)==this.getValue()?this.valueView_.text=this.getValue():this.valueView_.text=this.getValue().toFixed(1).replace(".00",""):this.valueView_.text=this.getValue(),null===this._nameWidth&&(this._nameWidth=this.textView_.getMeasuredWidth()),null===this._valueWidth&&(this._valueWidth=this.valueView_.getMeasuredWidth()),this.valueView_.x=this._nameWidth+14,this.rect_.graphics.clear().f("#ffffff").ss(1, 2,0).s("#A0A1A1").rc(0,-14,this._nameWidth+this._valueWidth+26,20,4,4,4,4),this.wrapper_.graphics.clear().f("#E457DC").ss(1,2,0).s("#E457DC").rc(this._nameWidth+7,-11,this._valueWidth+15,14,7,7,7,7)):(this.view_.x=this.getX(),this.view_.y=this.getY(),this.textView_.text=this.getName(),null===this._nameWidth&&(this._nameWidth=this.textView_.getMeasuredWidth()),this.valueView_.x=this._nameWidth+14,this.valueView_.y=1,this.isNumber()?this.valueView_.text=this.getValue().toFixed(1).replace(".00",""): this.valueView_.text=this.getValue(),null===this._valueWidth&&(this._valueWidth=this.valueView_.getMeasuredWidth()),this.rect_.graphics.clear().f("#ffffff").ss(1,2,0).s("#A0A1A1").rc(0,-14,this._nameWidth+this._valueWidth+26,20,4,4,4,4),this.wrapper_.graphics.clear().f("#ffbb14").ss(1,2,0).s("orange").rc(this._nameWidth+7,-11,this._valueWidth+15,14,7,7,7,7));Entry.requestUpdate=!0}};Entry.Variable.prototype.getName=function(){return this.name_}; -Entry.Variable.prototype.setName=function(a){Entry.assert("string"==typeof a,"Variable name must be string");this.name_=a;this._nameWidth=null;this.updateView()};Entry.Variable.prototype.getId=function(){return this.id_};Entry.Variable.prototype.getValue=function(){return this.isNumber()?Number(this.value_):this.value_};Entry.Variable.prototype.isNumber=function(){return isNaN(this.value_)?!1:!0}; -Entry.Variable.prototype.setValue=function(a){"slide"!=this.type?this.value_=a:(a=Number(a),this.value_=athis.maxValue_?this.maxValue_:a);this.isCloud_&&Entry.variableContainer.updateCloudVariables();this._valueWidth=null;this.updateView()};Entry.Variable.prototype.isVisible=function(){return this.visible_}; -Entry.Variable.prototype.setVisible=function(a){Entry.assert("boolean"==typeof a,"Variable visible state must be boolean");(this.visible_=this.view_.visible=a)&&this.updateView()};Entry.Variable.prototype.setX=function(a){this.x_=a;this.updateView()};Entry.Variable.prototype.getX=function(){return this.x_};Entry.Variable.prototype.setY=function(a){this.y_=a;this.updateView()};Entry.Variable.prototype.getY=function(){return this.y_}; -Entry.Variable.prototype.setWidth=function(a){this.width_=100>a?100:a;this.updateView()};Entry.Variable.prototype.getWidth=function(){return this.width_};Entry.Variable.prototype.isInList=function(a,b){this.getX();this.getY()};Entry.Variable.prototype.setHeight=function(a){this.height_=100>a?100:a;this.updateView()};Entry.Variable.prototype.getHeight=function(){return this.height_};Entry.Variable.prototype.takeSnapshot=function(){this.snapshot_=this.toJSON()}; -Entry.Variable.prototype.loadSnapshot=function(){this.snapshot_&&!this.isCloud_&&this.syncModel_(this.snapshot_)};Entry.Variable.prototype.syncModel_=function(a){this.setX(a.x);this.setY(a.y);this.id_=a.id;this.setVisible(a.visible);this.setValue(a.value);this.setName(a.name);this.isCloud_=a.isCloud;"list"==this.type&&(this.setWidth(a.width),this.setHeight(a.height),this.array_=a.array)}; -Entry.Variable.prototype.toJSON=function(){var a={};a.name=this.name_;a.id=this.id_;a.visible=this.visible_;a.value=this.value_;a.variableType=this.type;"list"==this.type?(a.width=this.getWidth(),a.height=this.getHeight(),a.array=JSON.parse(JSON.stringify(this.array_))):"slide"==this.type&&(a.minValue=this.minValue_,a.maxValue=this.maxValue_);a.isCloud=this.isCloud_;a.object=this.object_;a.x=this.x_;a.y=this.y_;return a};Entry.Variable.prototype.remove=function(){Entry.stage.removeVariable(this)}; -Entry.Variable.prototype.clone=function(){var a=this.toJSON();a.isClone=!0;return a=new Entry.Variable(a)};Entry.Variable.prototype.getType=function(){return this.type};Entry.Variable.prototype.setType=function(a){this.type=a};Entry.Variable.prototype.getSlidePosition=function(a){var b=this.minValue_;return Math.abs(this.value_-b)/Math.abs(this.maxValue_-b)*a+10}; -Entry.Variable.prototype.setSlideCommandX=function(a){var b=this.valueSetter_.graphics.command;a=Math.max("undefined"==typeof a?10:a,10);a=Math.min(this.maxWidth+10,a);b.x=a;this.updateSlideValueByView()}; -Entry.Variable.prototype.updateSlideValueByView=function(){var a=Math.max(this.valueSetter_.graphics.command.x-10,0)/this.maxWidth;0>a&&(a=0);1c&&(a=this.maxValue_);this.isFloatPoint()||(a=Math.round(a));this.setValue(a)};Entry.Variable.prototype.getMinValue=function(){return this.minValue_}; -Entry.Variable.prototype.setMinValue=function(a){this.minValue_=a;this.value_a&&(this.value_=a);this.updateView();this.isMaxFloat=Entry.isFloat(this.maxValue_)};Entry.Variable.prototype.isFloatPoint=function(){return this.isMaxFloat||this.isMinFloat};Entry.VariableContainer=function(){this.variables_=[];this.messages_=[];this.lists_=[];this.functions_={};this.viewMode_="all";this.selected=null;this.variableAddPanel={isOpen:!1,info:{object:null,isCloud:!1}};this.listAddPanel={isOpen:!1,info:{object:null,isCloud:!1}};this.selectedVariable=null;this._variableRefs=[];this._messageRefs=[];this._functionRefs=[]}; -Entry.VariableContainer.prototype.createDom=function(a){var b=this;this.view_=a;var c=Entry.createElement("table");c.addClass("entryVariableSelectorWorkspace");this.view_.appendChild(c);var d=Entry.createElement("tr");c.appendChild(d);var e=this.createSelectButton("all");e.setAttribute("rowspan","2");e.addClass("selected","allButton");d.appendChild(e);d.appendChild(this.createSelectButton("variable",Entry.variableEnable));d.appendChild(this.createSelectButton("message",Entry.messageEnable));d=Entry.createElement("tr"); -d.appendChild(this.createSelectButton("list",Entry.listEnable));d.appendChild(this.createSelectButton("func",Entry.functionEnable));c.appendChild(d);c=Entry.createElement("ul");c.addClass("entryVariableListWorkspace");this.view_.appendChild(c);this.listView_=c;c=Entry.createElement("li");c.addClass("entryVariableAddWorkspace");c.addClass("entryVariableListElementWorkspace");c.innerHTML="+ "+Lang.Workspace.variable_add;var f=this;this.variableAddButton_=c;c.bindOnClick(function(a){a=f.variableAddPanel; -var c=a.view.name.value.trim();a.isOpen?c&&0!==c.length?b.addVariable():(a.view.addClass("entryRemove"),a.isOpen=!1):(a.view.removeClass("entryRemove"),a.view.name.focus(),a.isOpen=!0)});this.generateVariableAddView();this.generateListAddView();this.generateVariableSplitterView();this.generateVariableSettingView();this.generateListSettingView();c=Entry.createElement("li");c.addClass("entryVariableAddWorkspace");c.addClass("entryVariableListElementWorkspace");c.innerHTML="+ "+Lang.Workspace.message_create; -this.messageAddButton_=c;c.bindOnClick(function(a){b.addMessage({name:Lang.Workspace.message+" "+(b.messages_.length+1)})});c=Entry.createElement("li");c.addClass("entryVariableAddWorkspace");c.addClass("entryVariableListElementWorkspace");c.innerHTML="+ "+Lang.Workspace.list_create;this.listAddButton_=c;c.bindOnClick(function(a){a=f.listAddPanel;var c=a.view.name.value.trim();a.isOpen?c&&0!==c.length?b.addList():(a.view.addClass("entryRemove"),a.isOpen=!1):(a.view.removeClass("entryRemove"),a.view.name.focus(), -a.isOpen=!0)});c=Entry.createElement("li");c.addClass("entryVariableAddWorkspace");c.addClass("entryVariableListElementWorkspace");c.innerHTML="+ "+Lang.Workspace.function_add;this.functionAddButton_=c;c.bindOnClick(function(a){a=b._getBlockMenu();Entry.playground.changeViewMode("code");"func"!=a.lastSelector&&a.selectMenu("func");b.createFunction()});return a}; -Entry.VariableContainer.prototype.createSelectButton=function(a,b){var c=this;void 0===b&&(b=!0);var d=Entry.createElement("td");d.addClass("entryVariableSelectButtonWorkspace",a);d.innerHTML=Lang.Workspace[a];b?d.bindOnClick(function(b){c.selectFilter(a);this.addClass("selected")}):d.addClass("disable");return d}; -Entry.VariableContainer.prototype.selectFilter=function(a){for(var b=this.view_.getElementsByTagName("td"),c=0;ca.x_&&b.xe?!0:!1}; -Entry.VariableContainer.prototype.getListById=function(a){var b=this.lists_,c=[];if(0this._maxNameLength&&(a=this._truncName(a,"variable"));a=this.checkAllVariableName(a,"variables_")?Entry.getOrderedName(a,this.variables_,"name_"):a;var c=b.info;a={name:a,isCloud:c.isCloud,object:c.object,variableType:"variable"};b.view.addClass("entryRemove");this.resetVariableAddPanel("variable")}a=new Entry.Variable(a);Entry.stateManager&& -Entry.stateManager.addCommand("add variable",this,this.removeVariable,a);a.generateView(this.variables_.length);this.createVariableView(a);this.variables_.unshift(a);Entry.playground.reloadPlayground();this.updateList();return new Entry.State(this,this.removeVariable,a)}; -Entry.VariableContainer.prototype.removeVariable=function(a){var b=this.variables_.indexOf(a),c=a.toJSON();this.selected==a&&this.select(null);a.remove();this.variables_.splice(b,1);Entry.stateManager&&Entry.stateManager.addCommand("remove variable",this,this.addVariable,c);Entry.playground.reloadPlayground();this.updateList();return new Entry.State(this,this.addVariable,c)}; -Entry.VariableContainer.prototype.changeVariableName=function(a,b){a.name_!=b&&(Entry.isExist(b,"name_",this.variables_)?(a.listElement.nameField.value=a.name_,Entry.toast.alert(Lang.Workspace.variable_rename_failed,Lang.Workspace.variable_dup)):10this.maxValue_?this.maxValue_:b);this.isCloud_&&Entry.variableContainer.updateCloudVariables();this._valueWidth=null;this.updateView()};Entry.Variable.prototype.isVisible=function(){return this.visible_};Entry.Variable.prototype.setVisible=function(b){Entry.assert("boolean"==typeof b,"Variable visible state must be boolean");(this.visible_=this.view_.visible=b)&&this.updateView()}; +Entry.Variable.prototype.setX=function(b){this.x_=b;this.updateView()};Entry.Variable.prototype.getX=function(){return this.x_};Entry.Variable.prototype.setY=function(b){this.y_=b;this.updateView()};Entry.Variable.prototype.getY=function(){return this.y_};Entry.Variable.prototype.setWidth=function(b){this.width_=100>b?100:b;this.updateView()};Entry.Variable.prototype.getWidth=function(){return this.width_};Entry.Variable.prototype.isInList=function(b,a){this.getX();this.getY()}; +Entry.Variable.prototype.setHeight=function(b){this.height_=100>b?100:b;this.updateView()};Entry.Variable.prototype.getHeight=function(){return this.height_};Entry.Variable.prototype.takeSnapshot=function(){this.snapshot_=this.toJSON()};Entry.Variable.prototype.loadSnapshot=function(){this.snapshot_&&!this.isCloud_&&this.syncModel_(this.snapshot_)}; +Entry.Variable.prototype.syncModel_=function(b){this.setX(b.x);this.setY(b.y);this.id_=b.id;this.setVisible(b.visible);this.setValue(b.value);this.setName(b.name);this.isCloud_=b.isCloud;"list"==this.type&&(this.setWidth(b.width),this.setHeight(b.height),this.array_=b.array)}; +Entry.Variable.prototype.toJSON=function(){var b={};b.name=this.name_;b.id=this.id_;b.visible=this.visible_;b.value=this.value_;b.variableType=this.type;"list"==this.type?(b.width=this.getWidth(),b.height=this.getHeight(),b.array=JSON.parse(JSON.stringify(this.array_))):"slide"==this.type&&(b.minValue=this.minValue_,b.maxValue=this.maxValue_);b.isCloud=this.isCloud_;b.object=this.object_;b.x=this.x_;b.y=this.y_;return b};Entry.Variable.prototype.remove=function(){Entry.stage.removeVariable(this)}; +Entry.Variable.prototype.clone=function(){var b=this.toJSON();b.isClone=!0;return b=new Entry.Variable(b)};Entry.Variable.prototype.getType=function(){return this.type};Entry.Variable.prototype.setType=function(b){this.type=b};Entry.Variable.prototype.getSlidePosition=function(b){var a=this.minValue_;return Math.abs(this.value_-a)/Math.abs(this.maxValue_-a)*b+10}; +Entry.Variable.prototype.setSlideCommandX=function(b){var a=this.valueSetter_.graphics.command;b=Math.max("undefined"==typeof b?10:b,10);b=Math.min(this.maxWidth+10,b);a.x=b;this.updateSlideValueByView()}; +Entry.Variable.prototype.updateSlideValueByView=function(){var b=Math.max(this.valueSetter_.graphics.command.x-10,0)/this.maxWidth;0>b&&(b=0);1c&&(b=this.maxValue_);this.isFloatPoint()||(b=Math.round(b));this.setValue(b)};Entry.Variable.prototype.getMinValue=function(){return this.minValue_}; +Entry.Variable.prototype.setMinValue=function(b){this.minValue_=b;this.value_b&&(this.value_=b);this.updateView();this.isMaxFloat=Entry.isFloat(this.maxValue_)};Entry.Variable.prototype.isFloatPoint=function(){return this.isMaxFloat||this.isMinFloat};Entry.VariableContainer=function(){this.variables_=[];this.messages_=[];this.lists_=[];this.functions_={};this.viewMode_="all";this.selected=null;this.variableAddPanel={isOpen:!1,info:{object:null,isCloud:!1}};this.listAddPanel={isOpen:!1,info:{object:null,isCloud:!1}};this.selectedVariable=null;this._variableRefs=[];this._messageRefs=[];this._functionRefs=[]}; +Entry.VariableContainer.prototype.createDom=function(b){var a=this;this.view_=b;var c=Entry.createElement("table");c.addClass("entryVariableSelectorWorkspace");this.view_.appendChild(c);var d=Entry.createElement("tr");c.appendChild(d);var e=this.createSelectButton("all");e.setAttribute("rowspan","2");e.addClass("selected","allButton");d.appendChild(e);d.appendChild(this.createSelectButton("variable",Entry.variableEnable));d.appendChild(this.createSelectButton("message",Entry.messageEnable));d=Entry.createElement("tr"); +d.appendChild(this.createSelectButton("list",Entry.listEnable));d.appendChild(this.createSelectButton("func",Entry.functionEnable));c.appendChild(d);c=Entry.createElement("ul");c.addClass("entryVariableListWorkspace");this.view_.appendChild(c);this.listView_=c;c=Entry.createElement("li");c.addClass("entryVariableAddWorkspace");c.addClass("entryVariableListElementWorkspace");c.innerHTML="+ "+Lang.Workspace.variable_add;var f=this;this.variableAddButton_=c;c.bindOnClick(function(b){b=f.variableAddPanel; +var c=b.view.name.value.trim();b.isOpen?c&&0!==c.length?a.addVariable():(b.view.addClass("entryRemove"),b.isOpen=!1):(b.view.removeClass("entryRemove"),b.view.name.focus(),b.isOpen=!0)});this.generateVariableAddView();this.generateListAddView();this.generateVariableSplitterView();this.generateVariableSettingView();this.generateListSettingView();c=Entry.createElement("li");c.addClass("entryVariableAddWorkspace");c.addClass("entryVariableListElementWorkspace");c.innerHTML="+ "+Lang.Workspace.message_create; +this.messageAddButton_=c;c.bindOnClick(function(b){a.addMessage({name:Lang.Workspace.message+" "+(a.messages_.length+1)})});c=Entry.createElement("li");c.addClass("entryVariableAddWorkspace");c.addClass("entryVariableListElementWorkspace");c.innerHTML="+ "+Lang.Workspace.list_create;this.listAddButton_=c;c.bindOnClick(function(b){b=f.listAddPanel;var c=b.view.name.value.trim();b.isOpen?c&&0!==c.length?a.addList():(b.view.addClass("entryRemove"),b.isOpen=!1):(b.view.removeClass("entryRemove"),b.view.name.focus(), +b.isOpen=!0)});c=Entry.createElement("li");c.addClass("entryVariableAddWorkspace");c.addClass("entryVariableListElementWorkspace");c.innerHTML="+ "+Lang.Workspace.function_add;this.functionAddButton_=c;c.bindOnClick(function(b){b=a._getBlockMenu();Entry.playground.changeViewMode("code");"func"!=b.lastSelector&&b.selectMenu("func");a.createFunction()});return b}; +Entry.VariableContainer.prototype.createSelectButton=function(b,a){var c=this;void 0===a&&(a=!0);var d=Entry.createElement("td");d.addClass("entryVariableSelectButtonWorkspace",b);d.innerHTML=Lang.Workspace[b];a?d.bindOnClick(function(a){c.selectFilter(b);this.addClass("selected")}):d.addClass("disable");return d}; +Entry.VariableContainer.prototype.selectFilter=function(b){for(var a=this.view_.getElementsByTagName("td"),c=0;cb.x_&&a.xe?!0:!1}; +Entry.VariableContainer.prototype.getListById=function(b){var a=this.lists_,c=[];if(0this._maxNameLength&&(b=this._truncName(b,"variable"));b=this.checkAllVariableName(b,"variables_")?Entry.getOrderedName(b,this.variables_,"name_"):b;var c=a.info;b={name:b,isCloud:c.isCloud,object:c.object,variableType:"variable"};a.view.addClass("entryRemove");this.resetVariableAddPanel("variable")}b=new Entry.Variable(b);Entry.stateManager&& +Entry.stateManager.addCommand("add variable",this,this.removeVariable,b);b.generateView(this.variables_.length);this.createVariableView(b);this.variables_.unshift(b);Entry.playground.reloadPlayground();this.updateList();return new Entry.State(this,this.removeVariable,b)}; +Entry.VariableContainer.prototype.removeVariable=function(b){var a=this.variables_.indexOf(b),c=b.toJSON();this.selected==b&&this.select(null);b.remove();this.variables_.splice(a,1);Entry.stateManager&&Entry.stateManager.addCommand("remove variable",this,this.addVariable,c);Entry.playground.reloadPlayground();this.updateList();return new Entry.State(this,this.addVariable,c)}; +Entry.VariableContainer.prototype.changeVariableName=function(b,a){b.name_!=a&&(Entry.isExist(a,"name_",this.variables_)?(b.listElement.nameField.value=b.name_,Entry.toast.alert(Lang.Workspace.variable_rename_failed,Lang.Workspace.variable_dup)):10this._maxNameLength&&(a=this._truncName(a,"list"));a=this.checkAllVariableName(a,"lists_")?Entry.getOrderedName(a,this.lists_,"name_"):a;a={name:a,isCloud:c.isCloud,object:c.object,variableType:"list"};b.view.addClass("entryRemove");this.resetVariableAddPanel("list")}a=new Entry.Variable(a);Entry.stateManager&&Entry.stateManager.addCommand("add list", -this,this.removeList,a);a.generateView(this.lists_.length);this.createListView(a);this.lists_.unshift(a);Entry.playground.reloadPlayground();this.updateList();return new Entry.State(this,this.removelist,a)}; -Entry.VariableContainer.prototype.createListView=function(a){var b=this,c=Entry.createElement("li"),d=Entry.createElement("div");d.addClass("entryVariableListElementWrapperWorkspace");c.appendChild(d);c.addClass("entryVariableListElementWorkspace");a.object_?c.addClass("entryListLocalElementWorkspace"):a.isCloud_?c.addClass("entryListCloudElementWorkspace"):c.addClass("entryListGlobalElementWorkspace");c.bindOnClick(function(c){b.select(a)});var e=Entry.createElement("button");e.addClass("entryVariableListElementDeleteWorkspace"); -e.bindOnClick(function(c){c.stopPropagation();b.removeList(a);b.selectedList=null;b.listSettingView.addClass("entryRemove")});var f=Entry.createElement("button");f.addClass("entryVariableListElementEditWorkspace");f.bindOnClick(function(c){c.stopPropagation();h.removeAttribute("disabled");g.removeClass("entryRemove");this.addClass("entryRemove");b.updateSelectedVariable(a);h.focus()});c.editButton=f;var g=Entry.createElement("button");g.addClass("entryVariableListElementEditWorkspace");g.addClass("entryRemove"); -g.bindOnClick(function(c){c.stopPropagation();h.blur();h.setAttribute("disabled","disabled");f.removeClass("entryRemove");this.addClass("entryRemove");b.select(a);b.updateSelectedVariable(null,"list")});c.editSaveButton=g;var h=Entry.createElement("input");h.setAttribute("disabled","disabled");h.addClass("entryVariableListElementNameWorkspace");h.value=a.name_;h.bindOnClick(function(b){b.stopPropagation()});h.onblur=function(c){(c=this.value.trim())&&0!==c.length?b.changeListName(a,this.value):(Entry.toast.alert(Lang.Msgs.warn, -Lang.Msgs.list_can_not_space),this.value=a.getName())};h.onkeydown=function(b){13==b.keyCode&&this.blur()};c.nameField=h;d.appendChild(h);d.appendChild(f);d.appendChild(g);d.appendChild(e);a.listElement=c};Entry.VariableContainer.prototype.mapVariable=function(a,b){for(var c=this.variables_.length,d=0;dc.getValue()&&c.setValue(0),100a&&(b.length=a)}this.updateListSettingView()};Entry.VariableContainer.prototype.updateViews=function(){var a=this.lists_;this.variables_.map(function(b){b.updateView()});a.map(function(b){b.updateView()})}; -Entry.VariableContainer.prototype.updateSelectedVariable=function(a,b){a?"variable"==a.type?(this.selectedVariable=a,this.updateVariableSettingView(a)):"slide"==a.type?(this.selectedVariable=a,this.updateVariableSettingView(a)):"list"==a.type&&(this.selectedList=a,this.updateListSettingView(a)):(this.selectedVariable=null,"variable"==(b||"variable")?this.variableSettingView.addClass("entryRemove"):this.listSettingView.addClass("entryRemove"))}; -Entry.VariableContainer.prototype.removeLocalVariables=function(a){var b=[],c=this;this.mapVariable(function(a,c){a.object_&&a.object_==c&&b.push(a)},a);b.map(function(b){c.removeVariable(b)})}; -Entry.VariableContainer.prototype.updateCloudVariables=function(){var a=Entry.projectId;if(Entry.cloudSavable&&a){var b=Entry.variableContainer,a=b.variables_.filter(function(b){return b.isCloud_}),a=a.map(function(b){return b.toJSON()}),b=b.lists_.filter(function(b){return b.isCloud_}),b=b.map(function(b){return b.toJSON()});$.ajax({url:"/api/project/variable/"+Entry.projectId,type:"PUT",data:{variables:a,lists:b}}).done(function(){})}}; -Entry.VariableContainer.prototype.addRef=function(a,b){if(this.view_&&Entry.playground.mainWorkspace.getMode()===Entry.Workspace.MODE_BOARD){var c={object:b.getCode().object,block:b};b.funcBlock&&(c.funcBlock=b.funcBlock,delete b.funcBlock);this[a].push(c);if("_functionRefs"==a){a=b.type.substr(5);for(var d=Entry.variableContainer.functions_[a].content.getBlockList(),e=0;ethis._maxNameLength&&(b=this._truncName(b,"list"));b=this.checkAllVariableName(b,"lists_")?Entry.getOrderedName(b,this.lists_,"name_"):b;b={name:b,isCloud:c.isCloud,object:c.object,variableType:"list"};a.view.addClass("entryRemove");this.resetVariableAddPanel("list")}b=new Entry.Variable(b);Entry.stateManager&&Entry.stateManager.addCommand("add list", +this,this.removeList,b);b.generateView(this.lists_.length);this.createListView(b);this.lists_.unshift(b);Entry.playground.reloadPlayground();this.updateList();return new Entry.State(this,this.removelist,b)}; +Entry.VariableContainer.prototype.createListView=function(b){var a=this,c=Entry.createElement("li"),d=Entry.createElement("div");d.addClass("entryVariableListElementWrapperWorkspace");c.appendChild(d);c.addClass("entryVariableListElementWorkspace");b.object_?c.addClass("entryListLocalElementWorkspace"):b.isCloud_?c.addClass("entryListCloudElementWorkspace"):c.addClass("entryListGlobalElementWorkspace");c.bindOnClick(function(c){a.select(b)});var e=Entry.createElement("button");e.addClass("entryVariableListElementDeleteWorkspace"); +e.bindOnClick(function(c){c.stopPropagation();a.removeList(b);a.selectedList=null;a.listSettingView.addClass("entryRemove")});var f=Entry.createElement("button");f.addClass("entryVariableListElementEditWorkspace");f.bindOnClick(function(c){c.stopPropagation();h.removeAttribute("disabled");g.removeClass("entryRemove");this.addClass("entryRemove");a.updateSelectedVariable(b);h.focus()});c.editButton=f;var g=Entry.createElement("button");g.addClass("entryVariableListElementEditWorkspace");g.addClass("entryRemove"); +g.bindOnClick(function(c){c.stopPropagation();h.blur();h.setAttribute("disabled","disabled");f.removeClass("entryRemove");this.addClass("entryRemove");a.select(b);a.updateSelectedVariable(null,"list")});c.editSaveButton=g;var h=Entry.createElement("input");h.setAttribute("disabled","disabled");h.addClass("entryVariableListElementNameWorkspace");h.value=b.name_;h.bindOnClick(function(a){a.stopPropagation()});h.onblur=function(c){(c=this.value.trim())&&0!==c.length?a.changeListName(b,this.value):(Entry.toast.alert(Lang.Msgs.warn, +Lang.Msgs.list_can_not_space),this.value=b.getName())};h.onkeydown=function(a){13==a.keyCode&&this.blur()};c.nameField=h;d.appendChild(h);d.appendChild(f);d.appendChild(g);d.appendChild(e);b.listElement=c};Entry.VariableContainer.prototype.mapVariable=function(b,a){for(var c=this.variables_.length,d=0;dc.getValue()&&c.setValue(0),100b&&(a.length=b)}this.updateListSettingView()};Entry.VariableContainer.prototype.updateViews=function(){var b=this.lists_;this.variables_.map(function(a){a.updateView()});b.map(function(a){a.updateView()})}; +Entry.VariableContainer.prototype.updateSelectedVariable=function(b,a){b?"variable"==b.type?(this.selectedVariable=b,this.updateVariableSettingView(b)):"slide"==b.type?(this.selectedVariable=b,this.updateVariableSettingView(b)):"list"==b.type&&(this.selectedList=b,this.updateListSettingView(b)):(this.selectedVariable=null,"variable"==(a||"variable")?this.variableSettingView.addClass("entryRemove"):this.listSettingView.addClass("entryRemove"))}; +Entry.VariableContainer.prototype.removeLocalVariables=function(b){var a=[],c=this;this.mapVariable(function(b,c){b.object_&&b.object_==c&&a.push(b)},b);a.map(function(a){c.removeVariable(a)})}; +Entry.VariableContainer.prototype.updateCloudVariables=function(){var b=Entry.projectId;if(Entry.cloudSavable&&b){var a=Entry.variableContainer,b=a.variables_.filter(function(a){return a.isCloud_}),b=b.map(function(a){return a.toJSON()}),a=a.lists_.filter(function(a){return a.isCloud_}),a=a.map(function(a){return a.toJSON()});$.ajax({url:"/api/project/variable/"+Entry.projectId,type:"PUT",data:{variables:b,lists:a}}).done(function(){})}}; +Entry.VariableContainer.prototype.addRef=function(b,a){if(this.view_&&Entry.playground.mainWorkspace.getMode()===Entry.Workspace.MODE_BOARD){var c={object:a.getCode().object,block:a};a.funcBlock&&(c.funcBlock=a.funcBlock,delete a.funcBlock);this[b].push(c);if("_functionRefs"==b)for(var d=a.type.substr(5),e=Entry.variableContainer.functions_[d].content.getBlockList(),f=0;fthis.events[a].indexOf(f)&&this.events[a].push(f)}}this._schema.event&&this.thread.registerEvent(this,this._schema.event);b=this.params;a=this._schema.params;for(e=0;a&&eEntry.Albert.tempo&&(Entry.Albert.tempo=1);return b.callReturn()}},albert_set_tempo_to:{color:"#00979D", -skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[{type:"text",params:["60"]},null],type:"albert_set_tempo_to"},paramsKeyMap:{VALUE:0},"class":"albert_buzzer",isNotFor:["albert"],func:function(a,b){Entry.Albert.tempo=b.getNumberValue("VALUE");1>Entry.Albert.tempo&&(Entry.Albert.tempo=1);return b.callReturn()}},albert_move_forward:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Indicator", -img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null]},func:function(a,b){a=Entry.hw.sendQueue;if(b.isStart){if(1==b.timeFlag)return b;delete b.timeFlag;delete b.isStart;Entry.engine.isContinue=!1;a.leftWheel=0;a.rightWheel=0;return b.callReturn()}b.isStart=!0;b.timeFlag=1;a.leftWheel=30;a.rightWheel=30;setTimeout(function(){b.timeFlag=0},1E3);return b}},albert_move_backward:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/hardware_03.png", -size:12}],events:{},def:{params:[null]},func:function(a,b){a=Entry.hw.sendQueue;if(b.isStart){if(1==b.timeFlag)return a.leftWheel=-30,a.rightWheel=-30,b;delete b.timeFlag;delete b.isStart;Entry.engine.isContinue=!1;a.leftWheel=0;a.rightWheel=0;return b.callReturn()}b.isStart=!0;b.timeFlag=1;setTimeout(function(){b.timeFlag=0},1E3);return b}},albert_turn_around:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[["\uc67c\ucabd","LEFT"],["\uc624\ub978\ucabd","RIGHT"]], -value:"LEFT",fontSize:11},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,null]},paramsKeyMap:{DIRECTION:0},func:function(a,b){a=Entry.hw.sendQueue;if(b.isStart){if(1==b.timeFlag)return a.leftWheel=b.leftValue,a.rightWheel=b.rightValue,b;delete b.timeFlag;delete b.isStart;delete b.leftValue;delete b.rightValue;Entry.engine.isContinue=!1;a.leftWheel=0;a.rightWheel=0;return b.callReturn()}a="LEFT"==b.getField("DIRECTION",b);b.leftValue=a?-30:30;b.rightValue= -a?30:-30;b.isStart=!0;b.timeFlag=1;setTimeout(function(){b.timeFlag=0},1E3);return b}},albert_set_led_to:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[["\uc67c\ucabd","LEFT"],["\uc624\ub978\ucabd","RIGHT"],["\uc591\ucabd","FRONT"]],value:"LEFT",fontSize:11},{type:"Dropdown",options:[["\ube68\uac04\uc0c9","4"],["\ub178\ub780\uc0c9","6"],["\ucd08\ub85d\uc0c9","2"],["\ud558\ub298\uc0c9","3"],["\ud30c\ub780\uc0c9","1"],["\ubcf4\ub77c\uc0c9","5"],["\ud558\uc580\uc0c9", -"7"]],value:"4",fontSize:11},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,null,null]},paramsKeyMap:{DIRECTION:0,COLOR:1},func:function(a,b){a=Entry.hw.sendQueue;var c=b.getField("DIRECTION",b),d=Number(b.getField("COLOR",b));"FRONT"==c?(a.leftEye=d,a.rightEye=d):"LEFT"==c?a.leftEye=d:a.rightEye=d;return b.callReturn()}},albert_clear_led:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[["\uc67c\ucabd","LEFT"],["\uc624\ub978\ucabd", -"RIGHT"],["\uc591\ucabd","FRONT"]],value:"LEFT",fontSize:11},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,null]},paramsKeyMap:{DIRECTION:0},func:function(a,b){a=Entry.hw.sendQueue;var c=b.getField("DIRECTION",b);"FRONT"==c?(a.leftEye=0,a.rightEye=0):"LEFT"==c?a.leftEye=0:a.rightEye=0;return b.callReturn()}},albert_change_wheels_by:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[["\uc67c\ucabd","LEFT"],["\uc624\ub978\ucabd", -"RIGHT"],["\uc591\ucabd","FRONT"]],value:"LEFT",fontSize:11},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,null]},paramsKeyMap:{DIRECTION:0,VALUE:1},func:function(a,b){a=Entry.hw.sendQueue;var c=Entry.hw.portData,d=b.getField("DIRECTION"),e=b.getNumberValue("VALUE");"LEFT"==d?a.leftWheel=void 0!=a.leftWheel?a.leftWheel+e:c.leftWheel+e:("RIGHT"!=d&&(a.leftWheel=void 0!=a.leftWheel?a.leftWheel+e:c.leftWheel+e),a.rightWheel=void 0!= -a.rightWheel?a.rightWheel+e:c.rightWheel+e);return b.callReturn()}},albert_set_wheels_to:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[["\uc67c\ucabd","LEFT"],["\uc624\ub978\ucabd","RIGHT"],["\uc591\ucabd","FRONT"]],value:"LEFT",fontSize:11},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,null]},paramsKeyMap:{DIRECTION:0,VALUE:1},func:function(a,b){a=Entry.hw.sendQueue;var c=b.getField("DIRECTION"), -d=b.getNumberValue("VALUE");"LEFT"==c?a.leftWheel=d:("RIGHT"!=c&&(a.leftWheel=d),a.rightWheel=d);return b.callReturn()}},arduino_text:{color:"#00979D",skeleton:"basic_string_field",statements:[],params:[{type:"TextInput",value:10}],events:{},def:{params:[]},paramsKeyMap:{NAME:0},func:function(a,b){return b.getStringField("NAME")}},arduino_send:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"}],events:{},def:{params:[]},paramsKeyMap:{VALUE:0},func:function(a,b){a= -b.getValue("VALUE",b);var c=new XMLHttpRequest;c.open("POST","http://localhost:23518/arduino/",!1);c.send(String(a));Entry.assert(200==c.status,"arduino is not connected");return b.callReturn()}},arduino_get_number:{color:"#00979D",skeleton:"basic_string_field",statements:[],params:[{type:"Block",accept:"string"}],events:{},def:{params:[]},paramsKeyMap:{VALUE:0},func:function(a,b){a=b.getValue("VALUE",b);b=new XMLHttpRequest;b.open("POST","http://localhost:23518/arduino/",!1);b.send(String(a));Entry.assert(200== -b.status,"arduino is not connected");return Number(b.responseText)}},arduino_get_string:{color:"#00979D",skeleton:"basic_string_field",statements:[],params:[{type:"Block",accept:"string"}],events:{},def:{params:[]},paramsKeyMap:{VALUE:0},func:function(a,b){a=b.getValue("VALUE",b);b=new XMLHttpRequest;b.open("POST","http://localhost:23518/arduino/",!1);b.send(String(a));Entry.assert(200==b.status,"arduino is not connected");return b.responseText}},arduino_get_sensor_number:{color:"#00979D",skeleton:"basic_string_field", -statements:[],params:[{type:"Dropdown",options:[["0","A0"],["1","A1"],["2","A2"],["3","A3"],["4","A4"],["5","A5"]],value:"A0",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW}],events:{},def:{params:[null]},paramsKeyMap:{PORT:0},func:function(a,b){return b.getStringField("PORT")}},arduino_get_port_number:{color:"#00979D",skeleton:"basic_string_field",statements:[],params:[{type:"Dropdown",options:[["0","0"],["1","1"],["2","2"],["3","3"],["4","4"],["5","5"],["6","6"],["7","7"],["8","8"],["9","9"], -["10","10"],["11","11"],["12","12"],["13","13"]],value:"0",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW}],events:{},def:{params:[null]},paramsKeyMap:{PORT:0},func:function(a,b){return b.getStringField("PORT")}},arduino_get_pwm_port_number:{color:"#00979D",skeleton:"basic_string_field",statements:[],params:[{type:"Dropdown",options:[["3","3"],["5","5"],["6","6"],["9","9"],["10","10"],["11","11"]],value:"3",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW}],events:{},def:{params:[null]},paramsKeyMap:{PORT:0}, -func:function(a,b){return b.getStringField("PORT")}},arduino_get_number_sensor_value:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],params:[{type:"Block",accept:"string"}],events:{},def:{params:[{type:"arduino_get_sensor_number"}],type:"arduino_get_number_sensor_value"},paramsKeyMap:{VALUE:0},"class":"arduino_value",isNotFor:["arduino"],func:function(a,b){a=b.getValue("VALUE",b);return Entry.hw.getAnalogPortValue(a[1])}},arduino_get_digital_value:{color:"#00979D",fontColor:"#fff", -skeleton:"basic_boolean_field",statements:[],params:[{type:"Block",accept:"string"}],events:{},def:{params:[{type:"arduino_get_port_number"}],type:"arduino_get_digital_value"},paramsKeyMap:{VALUE:0},"class":"arduino_value",isNotFor:["arduino"],func:function(a,b){a=b.getNumberValue("VALUE",b);return Entry.hw.getDigitalPortValue(a)}},arduino_toggle_led:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Dropdown",options:[[Lang.Blocks.ARDUINO_on,"on"],[Lang.Blocks.ARDUINO_off, -"off"]],value:"on",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[{type:"arduino_get_port_number"},null,null],type:"arduino_toggle_led"},paramsKeyMap:{VALUE:0,OPERATOR:1},"class":"arduino_set",isNotFor:["arduino"],func:function(a,b){a=b.getNumberValue("VALUE");var c=b.getField("OPERATOR");Entry.hw.setDigitalPortValue(a,"on"==c?255:0);return b.callReturn()}},arduino_toggle_pwm:{color:"#00979D",skeleton:"basic", -statements:[],params:[{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[{type:"arduino_get_pwm_port_number"},{type:"arduino_text",params:["255"]},null],type:"arduino_toggle_pwm"},paramsKeyMap:{PORT:0,VALUE:1},"class":"arduino_set",isNotFor:["arduino"],func:function(a,b){a=b.getNumberValue("PORT");var c=b.getNumberValue("VALUE"),c=Math.round(c),c=Math.max(c,0),c=Math.min(c,255);Entry.hw.setDigitalPortValue(a, -c);return b.callReturn()}},arduino_convert_scale:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],params:[{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Block",accept:"string"}],events:{},def:{params:[{type:"arduino_get_number_sensor_value",params:[{type:"arduino_get_sensor_number",id:"bl5e"}]},{type:"number",params:["0"]},{type:"number",params:["1023"]},{type:"number",params:["0"]},{type:"number", -params:["100"]}],type:"arduino_convert_scale"},paramsKeyMap:{VALUE1:0,VALUE2:1,VALUE3:2,VALUE4:3,VALUE5:4},"class":"arduino",isNotFor:["arduino"],func:function(a,b){var c=b.getNumberValue("VALUE1",b),d=b.getNumberValue("VALUE2",b),e=b.getNumberValue("VALUE3",b);a=b.getNumberValue("VALUE4",b);b=b.getNumberValue("VALUE5",b);if(d>e)var f=d,d=e,e=f;a>b&&(f=a,a=b,b=f);c=(b-a)/(e-d)*(c-d);c+=a;c=Math.min(b,c);c=Math.max(a,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(a,b){return Entry.hw.getAnalogPortValue(b.getField("PORT",b))}},sensorBoard_is_button_pressed:{color:"#00979D",fontColor:"#fff",skeleton:"basic_boolean_field", -statements:[],params:[{type:"Dropdown",options:[["\ube68\uac04","8"],["\ud30c\ub780","9"],["\ub178\ub791","10"],["\ucd08\ub85d","11"]],value:"8",fontSize:11}],events:{},def:{params:[null],type:"sensorBoard_is_button_pressed"},paramsKeyMap:{PORT:0},"class":"sensorBoard",isNotFor:["sensorBoard"],func:function(a,b){return Entry.hw.getDigitalPortValue(b.getNumberField("PORT",b))}},sensorBoard_led:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[["\ube68\uac04","2"],["\ucd08\ub85d", -"3"],["\ud30c\ub780","4"],["\ub178\ub791","5"]],value:"2",fontSize:11},{type:"Dropdown",options:[["\ucf1c\uae30","255"],["\ub044\uae30","0"]],value:"255",fontSize:11},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,null,null],type:"sensorBoard_led"},paramsKeyMap:{PORT:0,OPERATOR:1},"class":"sensorBoard",isNotFor:["sensorBoard"],func:function(a,b){Entry.hw.setDigitalPortValue(b.getField("PORT"),b.getNumberField("OPERATOR"));return b.callReturn()}},arduino_download_connector:{skeleton:"basic_button", -isNotFor:["arduinoDisconnected"],color:"#eee",params:[{type:"Text",text:Entry.isOffline?Lang.Blocks.ARDUINO_open_connector:Lang.Blocks.ARDUINO_download_connector,color:"#333",align:"center"}],events:{mousedown:[function(){Entry.hw.downloadConnector()}]}},arduino_download_source:{skeleton:"basic_button",isNotFor:["arduinoDisconnected"],color:"#eee",params:[{type:"Text",text:Lang.Blocks.ARDUINO_download_source,color:"#333",align:"center"}],events:{mousedown:[function(){Entry.hw.downloadSource()}]}}, -arduino_connected:{skeleton:"basic_button",color:"#eee",isNotFor:["arduinoConnected"],params:[{type:"Text",text:Lang.Blocks.ARDUINO_connected,color:"#333",align:"center"}],events:{}},arduino_reconnect:{skeleton:"basic_button",color:"#eee",isNotFor:["arduinoDisconnected"],params:[{type:"Text",text:Lang.Blocks.ARDUINO_reconnect,color:"#333",align:"center"}],events:{mousedown:[function(){Entry.hw.retryConnect()}]}},CODEino_get_sensor_number:{color:"#00979D",skeleton:"basic_string_field",statements:[], -params:[{type:"Dropdown",options:[["0","A0"],["1","A1"],["2","A2"],["3","A3"],["4","A4"],["5","A5"],["6","A6"]],value:"A0",fontSize:11}],events:{},def:{params:[null]},paramsKeyMap:{PORT:0},func:function(a,b){return b.getStringField("PORT")}},CODEino_get_named_sensor_value:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.CODEino_sensor_name_0,"0"],[Lang.Blocks.CODEino_sensor_name_1,"1"],[Lang.Blocks.CODEino_sensor_name_2,"2"], -[Lang.Blocks.CODEino_sensor_name_3,"3"],[Lang.Blocks.CODEino_sensor_name_4,"4"],[Lang.Blocks.CODEino_sensor_name_5,"5"],[Lang.Blocks.CODEino_sensor_name_6,"6"]],value:"0",fontSize:11}],events:{},def:{params:[null],type:"CODEino_get_named_sensor_value"},paramsKeyMap:{PORT:0},"class":"CODEino",isNotFor:["CODEino"],func:function(a,b){return Entry.hw.getAnalogPortValue(b.getField("PORT",b))}},CODEino_get_sound_status:{color:"#00979D",fontColor:"#fff",skeleton:"basic_boolean_field",statements:[],params:[{type:"Dropdown", -options:[[Lang.Blocks.CODEino_string_11,"GREAT"],[Lang.Blocks.CODEino_string_12,"SMALL"]],value:"GREAT",fontSize:11}],events:{},def:{params:[null],type:"CODEino_get_sound_status"},paramsKeyMap:{STATUS:0},"class":"CODEino",isNotFor:["CODEino"],func:function(a,b){return"GREAT"==b.getField("STATUS",b)?600Entry.hw.getAnalogPortValue(0)?1:0}},CODEino_get_light_status:{color:"#00979D",fontColor:"#fff",skeleton:"basic_boolean_field",statements:[],params:[{type:"Dropdown", -options:[[Lang.Blocks.CODEino_string_14,"BRIGHT"],[Lang.Blocks.CODEino_string_15,"DARK"]],value:"BRIGHT",fontSize:11}],events:{},def:{params:[null],type:"CODEino_get_light_status"},paramsKeyMap:{STATUS:0},"class":"CODEino",isNotFor:["CODEino"],func:function(a,b){return"DARK"==b.getField("STATUS",b)?800Entry.hw.getAnalogPortValue(1)?1:0}},CODEino_is_button_pressed:{color:"#00979D",fontColor:"#fff",skeleton:"basic_boolean_field",statements:[],params:[{type:"Dropdown", -options:[[Lang.Blocks.CODEino_string_3,"4"],[Lang.Blocks.CODEino_string_4,"17"],[Lang.Blocks.CODEino_string_5,"18"],[Lang.Blocks.CODEino_string_6,"19"],[Lang.Blocks.CODEino_string_7,"20"]],value:"4",fontSize:11}],events:{},def:{params:[null],type:"CODEino_is_button_pressed"},paramsKeyMap:{PORT:0},"class":"CODEino",isNotFor:["CODEino"],func:function(a,b){a=b.getNumberField("PORT",b);return 14b?1:0;if("RIGHT"==a||"FRONT"==a)return 30b?1:0}},CODEino_get_accelerometer_value:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],params:[{type:"Dropdown",options:[["X","3"],["Y","4"],["Z","5"]],value:"3",fontSize:11}],events:{}, -def:{params:[null],type:"CODEino_get_accelerometer_value"},paramsKeyMap:{PORT:0},"class":"CODEino",isNotFor:["CODEino"],func:function(a,b){var c=Entry.hw.getAnalogPortValue(b.getField("PORT",b)),d=265,e=402;a=-90;b=90;if(d>e)var f=d,d=e,e=f;a>b&&(f=a,a=b,b=f);c=(b-a)/(e-d)*(c-d);c+=a;c=Math.min(b,c);c=Math.max(a,c);return Math.round(c)}},nemoino_get_named_sensor_value:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],template:"%1 \uc13c\uc11c\uac12",params:[{type:"Dropdown", -options:[["\uc18c\ub9ac","0"],["\ube5b","1"],["\uc2ac\ub77c\uc774\ub354","2"],["\uc800\ud56d-A","3"],["\uc800\ud56d-B","4"],["\uc800\ud56d-C","5"],["\uc800\ud56d-D","6"]],value:"0",fontSize:11}],events:{},def:{params:[null],type:"nemoino_get_named_sensor_value"},paramsKeyMap:{PORT:0},"class":"nemoino",isNotFor:["nemoino"],func:function(a,b){return Entry.hw.getAnalogPortValue(b.getField("PORT",b))}},nemoino_get_sound_status:{color:"#00979D",fontColor:"#fff",skeleton:"basic_boolean_field",statements:[], -template:"\uc18c\ub9ac\uc13c\uc11c %1",params:[{type:"Dropdown",options:[["\uc18c\ub9ac\ud07c","GREAT"],["\uc18c\ub9ac\uc791\uc74c","SMALL"]],value:"GREAT",fontSize:11}],events:{},def:{params:[null],type:"nemoino_get_sound_status"},paramsKeyMap:{STATUS:0},"class":"nemoino",isNotFor:["nemoino"],func:function(a,b){return"GREAT"==b.getField("STATUS",b)?600Entry.hw.getAnalogPortValue(0)?1:0}},nemoino_is_button_pressed:{color:"#00979D",fontColor:"#fff",skeleton:"basic_boolean_field", -statements:[],template:"\ubcf4\ub4dc\uc758 %1",params:[{type:"Dropdown",options:[["\ubc84\ud2bc\ub204\ub984","4"],["A\uc5f0\uacb0\ub428","17"],["B\uc5f0\uacb0\ub428","18"],["C\uc5f0\uacb0\ub428","19"],["D\uc5f0\uacb0\ub428","20"]],value:"4",fontSize:11}],events:{},def:{params:[null],type:"nemoino_is_button_pressed"},paramsKeyMap:{PORT:0},"class":"nemoino",isNotFor:["nemoino"],func:function(a,b){a=b.getNumberField("PORT",b);return 14b?1:0;if("RIGHT"==a||"FRONT"==a)return 30b?1:0}},nemoino_get_accelerometer_value:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field", -statements:[],template:"3\ucd95 \uac00\uc18d\ub3c4\uc13c\uc11c %1 \ucd95\uc758 \uc13c\uc11c\uac12",params:[{type:"Dropdown",options:[["X","3"],["Y","4"],["Z","5"]],value:"3",fontSize:11}],events:{},def:{params:[null],type:"nemoino_get_accelerometer_value"},paramsKeyMap:{PORT:0},"class":"nemoino",isNotFor:["nemoino"],func:function(a,b){var c=Entry.hw.getAnalogPortValue(b.getField("PORT",b)),d=265,e=402;a=-90;b=90;if(d>e)var f=d,d=e,e=f;a>b&&(f=a,a=b,b=f);c=(b-a)/(e-d)*(c-d);c+=a;c=Math.min(b,c);c= -Math.max(a,c);return Math.round(c)}},bitbrick_sensor_value:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],params:[{type:"DropdownDynamic",value:null,fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW,menuName:Entry.Bitbrick.sensorList}],events:{},def:{params:[null],type:"bitbrick_sensor_value"},paramsKeyMap:{PORT:0},"class":"condition",isNotFor:["bitbrick"],func:function(a,b){a=b.getStringField("PORT");return Entry.hw.portData[a].value}},bitbrick_is_touch_pressed:{color:"#00979D", -fontColor:"#fff",skeleton:"basic_boolean_field",statements:[],params:[{type:"DropdownDynamic",value:null,fontSize:11,menuName:Entry.Bitbrick.touchList}],events:{},def:{params:[null],type:"bitbrick_is_touch_pressed"},paramsKeyMap:{PORT:0},"class":"condition",isNotFor:["bitbrick"],func:function(a,b){return 0===Entry.hw.portData[b.getStringField("PORT")].value}},bitbrick_turn_off_color_led:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/hardware_03.png",size:12}], -events:{},def:{params:[null],type:"bitbrick_turn_off_color_led",id:"i3je"},"class":"condition",isNotFor:["bitbrick"],func:function(a,b){Entry.hw.sendQueue.LEDR=0;Entry.hw.sendQueue.LEDG=0;Entry.hw.sendQueue.LEDB=0;return b.callReturn()}},bitbrick_turn_on_color_led_by_rgb:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[{type:"text", -params:["255"]},{type:"text",params:["255"]},{type:"text",params:["255"]},null],type:"bitbrick_turn_on_color_led_by_rgb"},paramsKeyMap:{rValue:0,gValue:1,bValue:2},"class":"condition",isNotFor:["bitbrick"],func:function(a,b){a=b.getNumberValue("rValue");var c=b.getNumberValue("gValue"),d=b.getNumberValue("bValue"),e=Entry.adjustValueWithMaxMin,f=Entry.hw.sendQueue;f.LEDR=e(a,0,255);f.LEDG=e(c,0,255);f.LEDB=e(d,0,255);return b.callReturn()}},bitbrick_turn_on_color_led_by_picker:{color:"#00979D",skeleton:"basic", -statements:[],params:[{type:"Color"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null],type:"bitbrick_turn_on_color_led_by_picker"},paramsKeyMap:{VALUE:0},"class":"condition",isNotFor:["bitbrick"],func:function(a,b){a=b.getStringField("VALUE");Entry.hw.sendQueue.LEDR=parseInt(a.substr(1,2),16);Entry.hw.sendQueue.LEDG=parseInt(a.substr(3,2),16);Entry.hw.sendQueue.LEDB=parseInt(a.substr(5,2),16);return b.callReturn()}},bitbrick_turn_on_color_led_by_value:{color:"#00979D", -skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[{type:"text",params:["0"]},null],type:"bitbrick_turn_on_color_led_by_value"},paramsKeyMap:{VALUE:0},"class":"condition",isNotFor:["bitbrick"],func:function(a,b){a=b.getNumberValue("VALUE");var c,d,e;a%=200;67>a?(c=200-3*a,d=3*a,e=0):134>a?(a-=67,c=0,d=200-3*a,e=3*a):201>a&&(a-=134,c=3*a,d=0,e=200-3*a);Entry.hw.sendQueue.LEDR=c;Entry.hw.sendQueue.LEDG= -d;Entry.hw.sendQueue.LEDB=e;return b.callReturn()}},bitbrick_buzzer:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[{type:"text",params:["60"]},null],type:"bitbrick_buzzer"},paramsKeyMap:{VALUE:0},"class":"condition",isNotFor:["bitbrick"],func:function(a,b){if(b.isStart)return Entry.hw.sendQueue.buzzer=0,delete b.isStart,b.callReturn();a=b.getNumberValue("VALUE");Entry.hw.sendQueue.buzzer= -a;b.isStart=!0;return b}},bitbrick_turn_off_all_motors:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null],type:"bitbrick_turn_off_all_motors"},"class":"condition",isNotFor:["bitbrick"],func:function(a,b){var c=Entry.hw.sendQueue;a=Entry.Bitbrick;a.servoList().map(function(b){c[b[1]]=0});a.dcList().map(function(b){c[b[1]]=128});return b.callReturn()}},bitbrick_dc_speed:{color:"#00979D",skeleton:"basic",statements:[], -params:[{type:"DropdownDynamic",value:null,fontSize:11,menuName:Entry.Bitbrick.dcList},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,{type:"text",params:["60"]},null],type:"bitbrick_dc_speed"},paramsKeyMap:{PORT:0,VALUE:1},"class":"condition",isNotFor:["bitbrick"],func:function(a,b){a=b.getNumberValue("VALUE");a=Math.min(a,Entry.Bitbrick.dcMaxValue);a=Math.max(a,Entry.Bitbrick.dcMinValue);Entry.hw.sendQueue[b.getStringField("PORT")]= -a+128;return b.callReturn()}},bitbrick_dc_direction_speed:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"DropdownDynamic",value:null,fontSize:11,menuName:Entry.Bitbrick.dcList},{type:"Dropdown",options:[[Lang.Blocks.BITBRICK_dc_direction_cw,"CW"],[Lang.Blocks.BITBRICK_dc_direction_ccw,"CCW"]],value:"CW",fontSize:11},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,null,{type:"text",params:["100"]},null],type:"bitbrick_dc_direction_speed"}, -paramsKeyMap:{PORT:0,DIRECTION:1,VALUE:2},"class":"condition",isNotFor:["bitbrick"],func:function(a,b){a="CW"===b.getStringField("DIRECTION");var c=b.getNumberValue("VALUE"),c=Math.min(c,Entry.Bitbrick.dcMaxValue),c=Math.max(c,0);Entry.hw.sendQueue[b.getStringField("PORT")]=a?c+128:128-c;return b.callReturn()}},bitbrick_servomotor_angle:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"DropdownDynamic",value:null,fontSize:11,menuName:Entry.Bitbrick.servoList},{type:"Block",accept:"string"}, -{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,{type:"text",params:["100"]},null],type:"bitbrick_servomotor_angle"},paramsKeyMap:{PORT:0,VALUE:1},"class":"condition",isNotFor:["bitbrick"],func:function(a,b){a=Entry.Bitbrick.servoMaxValue-(b.getNumberValue("VALUE")+1);a=Math.min(a,Entry.Bitbrick.servoMaxValue);a=Math.max(a,Entry.Bitbrick.servoMinValue);Entry.hw.sendQueue[b.getStringField("PORT")]=a;return b.callReturn()}},bitbrick_convert_scale:{color:"#00979D", -fontColor:"#fff",skeleton:"basic_string_field",statements:[],params:[{type:"DropdownDynamic",value:null,fontSize:11,menuName:Entry.Bitbrick.sensorList},{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Block",accept:"string"}],events:{},def:{params:[null,{type:"number",params:["0"]},{type:"number",params:["1023"]},{type:"number",params:["-100"]},{type:"number",params:["100"]}],type:"bitbrick_convert_scale"},paramsKeyMap:{PORT:0,VALUE2:1,VALUE3:2,VALUE4:3, -VALUE5:4},"class":"condition",isNotFor:["bitbrick"],func:function(a,b){a=b.getNumberField("PORT");var c=Entry.hw.portData[a].value,d=b.getNumberValue("VALUE2",b),e=b.getNumberValue("VALUE3",b);a=b.getNumberValue("VALUE4",b);b=b.getNumberValue("VALUE5",b);if(a>b){var f=a;a=b;b=f}c=(b-a)/(e-d)*(c-d);c+=a;c=Math.min(b,c);c=Math.max(a,c);return Math.round(c)}},start_drawing:{color:"#FF9E20",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/brush_03.png",size:12}],events:{},def:{params:[null], -type:"start_drawing"},"class":"brush_control",isNotFor:["textBox"],func:function(a,b){a.brush?a.brush.stop=!1:Entry.setBasicBrush(a);Entry.stage.sortZorder();a.brush.moveTo(a.getX(),-1*a.getY());return b.callReturn()}},stop_drawing:{color:"#FF9E20",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/brush_03.png",size:12}],events:{},def:{params:[null],type:"stop_drawing"},"class":"brush_control",isNotFor:["textBox"],func:function(a,b){a.brush&&a.shape&&(a.brush.stop=!0);return b.callReturn()}}, -set_color:{color:"#FF9E20",skeleton:"basic",statements:[],params:[{type:"Color"},{type:"Indicator",img:"block_icon/brush_03.png",size:12}],events:{},def:{params:[null],type:"set_color"},paramsKeyMap:{VALUE:0},"class":"brush_color",isNotFor:["textBox"],func:function(a,b){var c=b.getField("VALUE",b);a.brush||(Entry.setBasicBrush(a),a.brush.stop=!0);a.brush&&(c=Entry.hex2rgb(c),a.brush.rgb=c,a.brush.endStroke(),a.brush.beginStroke("rgba("+c.r+","+c.g+","+c.b+","+a.brush.opacity/100+")"),a.brush.moveTo(a.getX(), --1*a.getY()));return b.callReturn()}},set_random_color:{color:"#FF9E20",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/brush_03.png",size:12}],events:{},def:{params:[null],type:"set_random_color"},"class":"brush_color",isNotFor:["textBox"],func:function(a,b){a.brush||(Entry.setBasicBrush(a),a.brush.stop=!0);if(a.brush){var c=Entry.generateRgb();a.brush.rgb=c;a.brush.endStroke();a.brush.beginStroke("rgba("+c.r+","+c.g+","+c.b+","+a.brush.opacity/100+")");a.brush.moveTo(a.getX(), --1*a.getY())}return b.callReturn()}},change_thickness:{color:"#FF9E20",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/brush_03.png",size:12}],events:{},def:{params:[{type:"number",params:["1"]},null],type:"change_thickness"},paramsKeyMap:{VALUE:0},"class":"brush_thickness",isNotFor:["textBox"],func:function(a,b){var c=b.getNumberValue("VALUE",b);a.brush||(Entry.setBasicBrush(a),a.brush.stop=!0);a.brush&&(a.brush.thickness+=c,1>a.brush.thickness&& -(a.brush.thickness=1),a.brush.setStrokeStyle(a.brush.thickness),a.brush.moveTo(a.getX(),-1*a.getY()));return b.callReturn()}},set_thickness:{color:"#FF9E20",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/brush_03.png",size:12}],events:{},def:{params:[{type:"number",params:["1"]},null],type:"set_thickness"},paramsKeyMap:{VALUE:0},"class":"brush_thickness",isNotFor:["textBox"],func:function(a,b){var c=b.getNumberValue("VALUE",b);a.brush||(Entry.setBasicBrush(a), -a.brush.stop=!0);a.brush&&(a.brush.thickness=c,a.brush.setStrokeStyle(a.brush.thickness),a.brush.moveTo(a.getX(),-1*a.getY()));return b.callReturn()}},change_opacity:{color:"#FF9E20",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/brush_03.png",size:12}],events:{},def:{params:[{type:"number",params:["10"]},null],type:"change_opacity"},paramsKeyMap:{VALUE:0},"class":"brush_opacity",isNotFor:["textBox"],func:function(a,b){var c=b.getNumberValue("VALUE", -b);a.brush||(Entry.setBasicBrush(a),a.brush.stop=!0);c=Entry.adjustValueWithMaxMin(a.brush.opacity+c,0,100);a.brush&&(a.brush.opacity=c,a.brush.endStroke(),c=a.brush.rgb,a.brush.beginStroke("rgba("+c.r+","+c.g+","+c.b+","+a.brush.opacity/100+")"),a.brush.moveTo(a.getX(),-1*a.getY()));return b.callReturn()}},set_opacity:{color:"#FF9E20",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/brush_03.png",size:12}],events:{},def:{params:[{type:"number", -params:["50"]},null],type:"set_opacity"},paramsKeyMap:{VALUE:0},"class":"brush_opacity",isNotFor:["textBox"],func:function(a,b){var c=b.getNumberValue("VALUE",b);a.brush||(Entry.setBasicBrush(a),a.brush.stop=!0);a.brush&&(a.brush.opacity=Entry.adjustValueWithMaxMin(c,0,100),a.brush.endStroke(),c=a.brush.rgb,a.brush.beginStroke("rgba("+c.r+","+c.g+","+c.b+","+a.brush.opacity/100+")"),a.brush.moveTo(a.getX(),-1*a.getY()));return b.callReturn()}},brush_erase_all:{color:"#FF9E20",skeleton:"basic",statements:[], -params:[{type:"Indicator",img:"block_icon/brush_03.png",size:12}],events:{},def:{params:[null],type:"brush_erase_all"},"class":"brush_clear",isNotFor:["textBox"],func:function(a,b){var c=a.brush;if(c){var d=c._stroke.style,e=c._strokeStyle.width;c.clear().setStrokeStyle(e).beginStroke(d);c.moveTo(a.getX(),-1*a.getY())}a=a.parent.getStampEntities();a.map(function(b){b.removeClone()});a=null;return b.callReturn()}},brush_stamp:{color:"#FF9E20",skeleton:"basic",statements:[],params:[{type:"Indicator", -img:"block_icon/brush_03.png",size:12}],events:{},def:{params:[null],type:"brush_stamp"},"class":"stamp",isNotFor:["textBox"],func:function(a,b){a.parent.addStampEntity(a);return b.callReturn()}},change_brush_transparency:{color:"#FF9E20",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/brush_03.png",size:12}],events:{},def:{params:[{type:"number",params:["10"]},null],type:"change_brush_transparency"},paramsKeyMap:{VALUE:0},"class":"brush_opacity", -isNotFor:["textBox"],func:function(a,b){var c=b.getNumberValue("VALUE",b);a.brush||(Entry.setBasicBrush(a),a.brush.stop=!0);c=Entry.adjustValueWithMaxMin(a.brush.opacity-c,0,100);a.brush&&(a.brush.opacity=c,a.brush.endStroke(),c=a.brush.rgb,a.brush.beginStroke("rgba("+c.r+","+c.g+","+c.b+","+a.brush.opacity/100+")"),a.brush.moveTo(a.getX(),-1*a.getY()));return b.callReturn()}},set_brush_tranparency:{color:"#FF9E20",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator", -img:"block_icon/brush_03.png",size:12}],events:{},def:{params:[{type:"number",params:["50"]},null],type:"set_brush_tranparency"},paramsKeyMap:{VALUE:0},"class":"brush_opacity",isNotFor:["textBox"],func:function(a,b){var c=b.getNumberValue("VALUE",b);a.brush||(Entry.setBasicBrush(a),a.brush.stop=!0);a.brush&&(a.brush.opacity=Entry.adjustValueWithMaxMin(c,0,100),a.brush.endStroke(),c=a.brush.rgb,a.brush.beginStroke("rgba("+c.r+","+c.g+","+c.b+","+(1-a.brush.opacity/100)+")"),a.brush.moveTo(a.getX(), --1*a.getY()));return b.callReturn()}},number:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"TextInput",value:10}],events:{},def:{params:[]},paramsKeyMap:{NUM:0},func:function(a,b){return b.getField("NUM",b)},isPrimitive:!0},angle:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Angle"}],events:{},def:{params:[null],type:"angle"},paramsKeyMap:{ANGLE:0},func:function(a,b){return b.getNumberField("ANGLE")}},get_x_coordinate:{color:"#FFD974",skeleton:"basic_string_field", -statements:[],params:[{type:"Text",text:Lang.Blocks.CALC_get_x_coordinate,color:"#3D3D3D"}],events:{},def:{params:[null],type:"get_x_coordinate"},"class":"calc",isNotFor:[],func:function(a,b){return a.getX()}},get_y_coordinate:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Text",text:Lang.Blocks.CALC_get_y_coordinate,color:"#3D3D3D"}],events:{},def:{params:[null],type:"get_y_coordinate"},"class":"calc",isNotFor:[],func:function(a,b){return a.getY()}},get_angle:{color:"#FFD974", -skeleton:"basic_string_field",statements:[],params:[{type:"Text",text:Lang.Blocks.CALC_get_angle,color:"#3D3D3D"}],events:{},def:{params:[null]},func:function(a,b){return parseFloat(a.getRotation().toFixed(1))}},get_rotation_direction:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.CALC_rotation_value,"ROTATION"],[Lang.Blocks.CALC_direction_value,"DIRECTION"]],value:"ROTATION",fontSize:11}],events:{},def:{params:[null],type:"get_rotation_direction"}, -paramsKeyMap:{OPERATOR:0},"class":"calc",isNotFor:[],func:function(a,b){return"DIRECTION"==b.getField("OPERATOR",b).toUpperCase()?parseFloat(a.getDirection().toFixed(1)):parseFloat(a.getRotation().toFixed(1))}},distance_something:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Text",text:Lang.Blocks.CALC_distance_something_1,color:"#3D3D3D"},{type:"DropdownDynamic",value:null,menuName:"spritesWithMouse",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_CALC},{type:"Text", -text:Lang.Blocks.CALC_distance_something_2,color:"#3D3D3D"}],events:{},def:{params:[null,null,null],type:"distance_something"},paramsKeyMap:{VALUE:1},"class":"calc_distance",isNotFor:[],func:function(a,b){b=b.getField("VALUE",b);if("mouse"==b)return b=Entry.stage.mouseCoordinate,Math.sqrt(Math.pow(a.getX()-b.x,2)+Math.pow(a.getY()-b.y,2));b=Entry.container.getEntity(b);return Math.sqrt(Math.pow(a.getX()-b.getX(),2)+Math.pow(a.getY()-b.getY(),2))}},coordinate_mouse:{color:"#FFD974",skeleton:"basic_string_field", -statements:[],params:[{type:"Text",text:Lang.Blocks.CALC_coordinate_mouse_1,color:"#3D3D3D"},{type:"Dropdown",options:[["x","x"],["y","y"]],value:"x",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_CALC},{type:"Text",text:Lang.Blocks.CALC_coordinate_mouse_2,color:"#3D3D3D"}],events:{},def:{params:[null,null,null],type:"coordinate_mouse"},paramsKeyMap:{VALUE:1},"class":"calc",isNotFor:[],func:function(a,b){return"x"===b.getField("VALUE",b)?Number(Entry.stage.mouseCoordinate.x):Number(Entry.stage.mouseCoordinate.y)}}, -coordinate_object:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Text",text:Lang.Blocks.CALC_coordinate_object_1,color:"#3D3D3D"},{type:"DropdownDynamic",value:null,menuName:"spritesWithSelf",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_CALC},{type:"Text",text:Lang.Blocks.CALC_coordinate_object_2,color:"#3D3D3D"},{type:"Dropdown",options:[[Lang.Blocks.CALC_coordinate_x_value,"x"],[Lang.Blocks.CALC_coordinate_y_value,"y"],[Lang.Blocks.CALC_coordinate_rotation_value,"rotation"], -[Lang.Blocks.CALC_coordinate_direction_value,"direction"],[Lang.Blocks.CALC_coordinate_size_value,"size"],[Lang.Blocks.CALC_picture_index,"picture_index"],[Lang.Blocks.CALC_picture_name,"picture_name"]],value:"x",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_CALC}],events:{},def:{params:[null,null,null,null],type:"coordinate_object"},paramsKeyMap:{VALUE:1,COORDINATE:3},"class":"calc",isNotFor:[],func:function(a,b){var c=b.getField("VALUE",b);a="self"==c?a:Entry.container.getEntity(c);switch(b.getField("COORDINATE", -b)){case "x":return a.getX();case "y":return a.getY();case "rotation":return a.getRotation();case "direction":return a.getDirection();case "picture_index":return b=a.parent,b=b.pictures,b.indexOf(a.picture)+1;case "size":return Number(a.getSize().toFixed(1));case "picture_name":return b=a.parent,b=b.pictures,b[b.indexOf(a.picture)].name}}},calc_basic:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Block",accept:"string"},{type:"Dropdown",options:[["+","PLUS"],["-","MINUS"], -["x","MULTI"],["/","DIVIDE"]],value:"PLUS",fontSize:11,noArrow:!0},{type:"Block",accept:"string"}],events:{},def:{params:[{type:"number",params:["10"]},"PLUS",{type:"number",params:["10"]}],type:"calc_basic"},defs:[{params:[{type:"number",params:["10"]},"PLUS",{type:"number",params:["10"]}],type:"calc_basic"},{params:[{type:"number",params:["10"]},"MINUS",{type:"number",params:["10"]}],type:"calc_basic"},{params:[{type:"number",params:["10"]},"MULTI",{type:"number",params:["10"]}],type:"calc_basic"}, -{params:[{type:"number",params:["10"]},"DIVIDE",{type:"number",params:["10"]}],type:"calc_basic"}],paramsKeyMap:{LEFTHAND:0,OPERATOR:1,RIGHTHAND:2},"class":"calc",isNotFor:[],func:function(a,b){a=b.getField("OPERATOR",b);var c=b.getNumberValue("LEFTHAND",b);b=b.getNumberValue("RIGHTHAND",b);return"PLUS"==a?c+b:"MINUS"==a?c-b:"MULTI"==a?c*b:c/b}},calc_plus:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Block",accept:"string"},{type:"Text",text:"+",color:"#3D3D3D"},{type:"Block", -accept:"string"}],events:{},def:{params:[null]},paramsKeyMap:{LEFTHAND:0,RIGHTHAND:2},func:function(a,b){a=b.getNumberValue("LEFTHAND",b);b=b.getNumberValue("RIGHTHAND",b);return a+b}},calc_minus:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Block",accept:"string"},{type:"Text",text:"-",color:"#3D3D3D"},{type:"Block",accept:"string"}],events:{},def:{params:[null]},paramsKeyMap:{LEFTHAND:0,RIGHTHAND:2},func:function(a,b){a=b.getNumberValue("LEFTHAND",b);b=b.getNumberValue("RIGHTHAND", -b);return a-b}},calc_times:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Block",accept:"string"},{type:"Text",text:"x",color:"#3D3D3D"},{type:"Block",accept:"string"}],events:{},def:{params:[null]},paramsKeyMap:{LEFTHAND:0,RIGHTHAND:2},func:function(a,b){a=b.getNumberValue("LEFTHAND",b);b=b.getNumberValue("RIGHTHAND",b);return a*b}},calc_divide:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Block",accept:"string"},{type:"Text",text:"/",color:"#3D3D3D"}, -{type:"Block",accept:"string"}],events:{},def:{params:[null]},paramsKeyMap:{LEFTHAND:0,RIGHTHAND:2},func:function(a,b){a=b.getNumberValue("LEFTHAND",b);b=b.getNumberValue("RIGHTHAND",b);return a/b}},calc_mod:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Block",accept:"string"},{type:"Text",text:"/",color:"#3D3D3D"},{type:"Block",accept:"string"},{type:"Text",text:Lang.Blocks.CALC_calc_mod_3,color:"#3D3D3D"}],events:{},def:{params:[{type:"number",params:["10"]},null,{type:"number", -params:["10"]},null],type:"calc_mod"},paramsKeyMap:{LEFTHAND:0,RIGHTHAND:2},"class":"calc",isNotFor:[],func:function(a,b){a=b.getNumberValue("LEFTHAND",b);b=b.getNumberValue("RIGHTHAND",b);return a%b}},calc_share:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Block",accept:"string"},{type:"Text",text:"/",color:"#3D3D3D"},{type:"Block",accept:"string"},{type:"Text",text:"\uc758 \ubaab",color:"#3D3D3D"}],events:{},def:{params:[{type:"number",params:["10"]},null,{type:"number", -params:["10"]},null],type:"calc_share"},paramsKeyMap:{LEFTHAND:0,RIGHTHAND:2},"class":"calc",isNotFor:[],func:function(a,b){a=b.getNumberValue("LEFTHAND",b);b=b.getNumberValue("RIGHTHAND",b);return Math.floor(a/b)}},calc_operation:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Text",text:Lang.Blocks.CALC_calc_operation_of_1,color:"#3D3D3D"},{type:"Block",accept:"string"},{type:"Text",text:Lang.Blocks.CALC_calc_operation_of_2,color:"#3D3D3D"},{type:"Dropdown",options:[[Lang.Blocks.CALC_calc_operation_square, -"square"],[Lang.Blocks.CALC_calc_operation_root,"root"],[Lang.Blocks.CALC_calc_operation_sin,"sin"],[Lang.Blocks.CALC_calc_operation_cos,"cos"],[Lang.Blocks.CALC_calc_operation_tan,"tan"],[Lang.Blocks.CALC_calc_operation_asin,"asin_radian"],[Lang.Blocks.CALC_calc_operation_acos,"acos_radian"],[Lang.Blocks.CALC_calc_operation_atan,"atan_radian"],[Lang.Blocks.CALC_calc_operation_log,"log"],[Lang.Blocks.CALC_calc_operation_ln,"ln"],[Lang.Blocks.CALC_calc_operation_unnatural,"unnatural"],[Lang.Blocks.CALC_calc_operation_floor, -"floor"],[Lang.Blocks.CALC_calc_operation_ceil,"ceil"],[Lang.Blocks.CALC_calc_operation_round,"round"],[Lang.Blocks.CALC_calc_operation_factorial,"factorial"],[Lang.Blocks.CALC_calc_operation_abs,"abs"]],value:"square",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_CALC}],events:{},def:{params:[null,{type:"number",params:["10"]},null,null],type:"calc_operation"},paramsKeyMap:{LEFTHAND:1,VALUE:3},"class":"calc",isNotFor:[],func:function(a,b){a=b.getNumberValue("LEFTHAND",b);b=b.getField("VALUE",b); -if(-1<["asin_radian","acos_radian"].indexOf(b)&&(1a))throw Error("x range exceeded");b.indexOf("_")&&(b=b.split("_")[0]);-1<["sin","cos","tan"].indexOf(b)&&(a=Entry.toRadian(a));switch(b){case "square":b=a*a;break;case "factorial":b=Entry.factorial(a);break;case "root":b=Math.sqrt(a);break;case "log":b=Math.log(a)/Math.LN10;break;case "ln":b=Math.log(a);break;case "asin":case "acos":case "atan":b=Entry.toDegrees(Math[b](a));break;case "unnatural":b=a-Math.floor(a);0>a&&(b=1-b);break;default:b= -Math[b](a)}return Math.round(1E3*b)/1E3}},calc_rand:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Text",text:Lang.Blocks.CALC_calc_rand_1,color:"#3D3D3D"},{type:"Block",accept:"string"},{type:"Text",text:Lang.Blocks.CALC_calc_rand_2,color:"#3D3D3D"},{type:"Block",accept:"string"},{type:"Text",text:Lang.Blocks.CALC_calc_rand_3,color:"#3D3D3D"}],events:{},def:{params:[null,{type:"number",params:["0"]},null,{type:"number",params:["10"]},null],type:"calc_rand"},paramsKeyMap:{LEFTHAND:1, -RIGHTHAND:3},"class":"calc",isNotFor:[],func:function(a,b){a=b.getStringValue("LEFTHAND",b);b=b.getStringValue("RIGHTHAND",b);var c=Math.min(a,b),d=Math.max(a,b);a=Entry.isFloat(a);return Entry.isFloat(b)||a?(Math.random()*(d-c)+c).toFixed(2):Math.floor(Math.random()*(d-c+1)+c)}},get_date:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Text",text:Lang.Blocks.CALC_get_date_1,color:"#3D3D3D"},{type:"Dropdown",options:[[Lang.Blocks.CALC_get_date_year,"YEAR"],[Lang.Blocks.CALC_get_date_month, -"MONTH"],[Lang.Blocks.CALC_get_date_day,"DAY"],[Lang.Blocks.CALC_get_date_hour,"HOUR"],[Lang.Blocks.CALC_get_date_minute,"MINUTE"],[Lang.Blocks.CALC_get_date_second,"SECOND"]],value:"YEAR",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_CALC},{type:"Text",text:Lang.Blocks.CALC_get_date_2,color:"#3D3D3D"}],events:{},def:{params:[null,"YEAR",null],type:"get_date"},paramsKeyMap:{VALUE:1},"class":"calc_date",isNotFor:[],func:function(a,b){a=b.getField("VALUE",b);b=new Date;return"YEAR"==a?b.getFullYear(): -"MONTH"==a?b.getMonth()+1:"DAY"==a?b.getDate():"HOUR"==a?b.getHours():"MINUTE"==a?b.getMinutes():b.getSeconds()}},get_sound_duration:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Text",text:Lang.Blocks.CALC_get_sound_duration_1,color:"#3D3D3D"},{type:"DropdownDynamic",value:null,menuName:"sounds",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_CALC},{type:"Text",text:Lang.Blocks.CALC_get_sound_duration_2,color:"#3D3D3D"}],events:{},def:{params:[null,null,null],type:"get_sound_duration"}, -paramsKeyMap:{VALUE:1},"class":"calc_duration",isNotFor:[],func:function(a,b){b=b.getField("VALUE",b);a=a.parent.sounds;for(var c=0;cb||b>a.length-1)throw Error();return a[b]}},length_of_string:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Text",text:Lang.Blocks.CALC_length_of_string_1, -color:"#3D3D3D"},{type:"Block",accept:"string"},{type:"Text",text:Lang.Blocks.CALC_length_of_string_2,color:"#3D3D3D"}],events:{},def:{params:[null,{type:"text",params:[Lang.Blocks.entry]},null],type:"length_of_string"},paramsKeyMap:{STRING:1},"class":"calc_string",isNotFor:[],func:function(a,b){return b.getStringValue("STRING",b).length}},substring:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Text",text:Lang.Blocks.CALC_substring_1,color:"#3D3D3D"},{type:"Block",accept:"string"}, -{type:"Text",text:Lang.Blocks.CALC_substring_2,color:"#3D3D3D"},{type:"Block",accept:"string"},{type:"Text",text:Lang.Blocks.CALC_substring_3,color:"#3D3D3D"},{type:"Block",accept:"string"},{type:"Text",text:Lang.Blocks.CALC_substring_4,color:"#3D3D3D"}],events:{},def:{params:[null,{type:"text",params:[Lang.Blocks.hi_entry]},null,{type:"number",params:["2"]},null,{type:"number",params:["5"]},null],type:"substring"},paramsKeyMap:{STRING:1,START:3,END:5},"class":"calc_string",isNotFor:[],func:function(a, -b){a=b.getStringValue("STRING",b);var c=b.getNumberValue("START",b)-1;b=b.getNumberValue("END",b)-1;var d=a.length-1;if(0>c||0>b||c>d||b>d)throw Error();return a.substring(Math.min(c,b),Math.max(c,b)+1)}},replace_string:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Text",text:Lang.Blocks.CALC_replace_string_1,color:"#3D3D3D"},{type:"Block",accept:"string"},{type:"Text",text:Lang.Blocks.CALC_replace_string_2,color:"#3D3D3D"},{type:"Block",accept:"string"},{type:"Text", -text:Lang.Blocks.CALC_replace_string_3,color:"#3D3D3D"},{type:"Block",accept:"string"},{type:"Text",text:Lang.Blocks.CALC_replace_string_4,color:"#3D3D3D"}],events:{},def:{params:[null,{type:"text",params:[Lang.Blocks.hi_entry]},null,{type:"text",params:[Lang.Blocks.hello]},null,{type:"text",params:[Lang.Blocks.nice]},null],type:"replace_string"},paramsKeyMap:{STRING:1,OLD_WORD:3,NEW_WORD:5},"class":"calc_string",isNotFor:[],func:function(a,b){return b.getStringValue("STRING",b).replace(new RegExp(b.getStringValue("OLD_WORD", -b),"gm"),b.getStringValue("NEW_WORD",b))}},change_string_case:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Text",text:Lang.Blocks.CALC_change_string_case_1,color:"#3D3D3D"},{type:"Block",accept:"string"},{type:"Text",text:Lang.Blocks.CALC_change_string_case_2,color:"#3D3D3D"},{type:"Dropdown",options:[[Lang.Blocks.CALC_change_string_case_sub_1,"toUpperCase"],[Lang.Blocks.CALC_change_string_case_sub_2,"toLowerCase"]],value:"toUpperCase",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_CALC}, -{type:"Text",text:Lang.Blocks.CALC_change_string_case_3,color:"#3D3D3D"}],events:{},def:{params:[null,{type:"text",params:["Hello Entry!"]},null,null,null],type:"change_string_case"},paramsKeyMap:{STRING:1,CASE:3},"class":"calc_string",isNotFor:[],func:function(a,b){return b.getStringValue("STRING",b)[b.getField("CASE",b)]()}},index_of_string:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Text",text:Lang.Blocks.CALC_index_of_string_1,color:"#3D3D3D"},{type:"Block",accept:"string"}, -{type:"Text",text:Lang.Blocks.CALC_index_of_string_2,color:"#3D3D3D"},{type:"Block",accept:"string"},{type:"Text",text:Lang.Blocks.CALC_index_of_string_3,color:"#3D3D3D"}],events:{},def:{params:[null,{type:"text",params:[Lang.Blocks.hi_entry]},null,{type:"text",params:[Lang.Blocks.entry]},null],type:"index_of_string"},paramsKeyMap:{LEFTHAND:1,RIGHTHAND:3},"class":"calc_string",isNotFor:[],func:function(a,b){a=b.getStringValue("LEFTHAND",b);b=b.getStringValue("RIGHTHAND",b);b=a.indexOf(b);return-1< -b?b+1:0}},combine_something:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Text",text:Lang.Blocks.VARIABLE_combine_something_1,color:"#3D3D3D"},{type:"Block",accept:"string"},{type:"Text",text:Lang.Blocks.VARIABLE_combine_something_2,color:"#3D3D3D"},{type:"Block",accept:"string"},{type:"Text",text:Lang.Blocks.VARIABLE_combine_something_3,color:"#3D3D3D"}],events:{},def:{params:[null,{type:"text",params:[Lang.Blocks.block_hi]},null,{type:"text",params:[Lang.Blocks.entry]}, -null],type:"combine_something"},paramsKeyMap:{VALUE1:1,VALUE2:3},"class":"calc_string",isNotFor:[],func:function(a,b){a=b.getStringValue("VALUE1",b);b=b.getStringValue("VALUE2",b);return a+b}},get_sound_volume:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Text",text:Lang.Blocks.CALC_get_sound_volume,color:"#3D3D3D"},{type:"Text",text:"",color:"#3D3D3D"}],events:{},def:{params:[null,null],type:"get_sound_volume"},"class":"calc",isNotFor:[""],func:function(a,b){return 100* -createjs.Sound.getVolume()}},quotient_and_mod:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Text",text:Lang.Blocks.CALC_quotient_and_mod_1,color:"#3D3D3D"},{type:"Block",accept:"string"},{type:"Text",text:Lang.Blocks.CALC_quotient_and_mod_2,color:"#3D3D3D"},{type:"Block",accept:"string"},{type:"Text",text:Lang.Blocks.CALC_quotient_and_mod_3,color:"#3D3D3D"},{type:"Dropdown",options:[[Lang.Blocks.CALC_quotient_and_mod_sub_1,"QUOTIENT"],[Lang.Blocks.CALC_quotient_and_mod_sub_2, -"MOD"]],value:"QUOTIENT",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_CALC}],events:{},def:{params:[null,{type:"text",params:["10"]},null,{type:"text",params:["10"]},null,null],type:"quotient_and_mod"},paramsKeyMap:{LEFTHAND:1,RIGHTHAND:3,OPERATOR:5},"class":"calc",isNotFor:[],func:function(a,b){a=b.getNumberValue("LEFTHAND",b);var c=b.getNumberValue("RIGHTHAND",b);if(isNaN(a)||isNaN(c))throw Error();return"QUOTIENT"==b.getField("OPERATOR",b)?Math.floor(a/c):a%c}},choose_project_timer_action:{color:"#FFD974", -skeleton:"basic",statements:[],params:[{type:"Text",text:Lang.Blocks.CALC_choose_project_timer_action_1,color:"#3D3D3D"},{type:"Dropdown",options:[[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"]],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(a){Entry.engine&&Entry.engine.hideProjectTimer(a)}]},def:{params:[null,"START",null,null],type:"choose_project_timer_action"},paramsKeyMap:{ACTION:1},"class":"calc_timer",isNotFor:[],func:function(a,b){a=b.getField("ACTION");var c=Entry.engine,d=c.projectTimer;"START"==a?d.isInit?d.isInit&&d.isPaused&&(d.pauseStart&&(d.pausedTime+=(new Date).getTime()-d.pauseStart),delete d.pauseStart,d.isPaused= -!1):c.startProjectTimer():"STOP"==a?d.isInit&&!d.isPaused&&(d.isPaused=!0,d.pauseStart=(new Date).getTime()):"RESET"==a&&d.isInit&&(d.setValue(0),d.start=(new Date).getTime(),d.pausedTime=0,delete d.pauseStart);return b.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(a,b){if(b.isStart){if(1==b.timeFlag)return b;delete b.timeFlag;delete b.isStart;Entry.engine.isContinue=!1;return b.callReturn()}b.isStart=!0;b.timeFlag=1;a=b.getNumberValue("SECOND",b);setTimeout(function(){b.timeFlag=0},60/(Entry.FPS||60)*a*1E3);return b}},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(a,b){if(!b.isLooped){b.isLooped=!0;a=b.getNumberValue("VALUE",b);if(0>a)throw Error(Lang.Blocks.FLOW_repeat_basic_errorMsg);b.iterCount=Math.floor(a)}if(0==b.iterCount||0>b.iterCount)return delete b.isLooped,delete b.iterCount,b.callReturn();b.iterCount--;return b.getStatement("DO",b)}},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(a,b){b.isLooped=!0;return b.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(a,b){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(a,b){return b.getBooleanValue("BOOL",b)?b.callReturn():b}},_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(a,b){return b.isCondition?(delete b.isCondition,b.callReturn()):b.getBooleanValue("BOOL",b)?(b.isCondition=!0,b.getStatement("STACK",b)):b.callReturn()}},if_else:{color:"#498deb",skeleton:"basic_double_loop",statements:[{accept:"basic"},{accept:"basic"}],params:[{type:"Block",accept:"boolean"},{type:"Indicator",img:"block_icon/flow_03.png",size:12},{type:"LineBreak"}],events:{},def:{params:[{type:"True"}, -null],type:"if_else"},paramsKeyMap:{BOOL:0},statementsKeyMap:{STACK_IF:0,STACK_ELSE:1},"class":"condition",isNotFor:[],func:function(a,b){if(b.isCondition)return delete b.isCondition,b.callReturn();a=b.getBooleanValue("BOOL",b);b.isCondition=!0;return a?b.getStatement("STACK_IF",b):b.getStatement("STACK_ELSE",b)}},create_clone:{color:"#498deb",skeleton:"basic",statements:[],params:[{type:"DropdownDynamic",value:null,menuName:"clone",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_FLOW},{type:"Indicator", -img:"block_icon/flow_03.png",size:12}],events:{},def:{params:[null,null],type:"create_clone"},paramsKeyMap:{VALUE:0},"class":"clone",isNotFor:[],func:function(a,b){var c=b.getField("VALUE",b);b=b.callReturn();"self"==c?a.parent.addCloneEntity(a.parent,a,null):Entry.container.getObject(c).addCloneEntity(a.parent,null,null);return b}},delete_clone:{color:"#498deb",skeleton:"basic_without_next",statements:[],params:[{type:"Indicator",img:"block_icon/flow_03.png",size:12}],events:{},def:{params:[null], -type:"delete_clone"},"class":"clone",isNotFor:[],func:function(a,b){if(!a.isClone)return b.callReturn();a.removeClone();return this.die()}},when_clone_start:{color:"#498deb",skeleton:"basic_event",statements:[],params:[{type:"Indicator",img:"block_icon/start_icon_clone.png",size:17,position:{x:0,y:-2}}],events:{},def:{params:[null],type:"when_clone_start"},"class":"clone",isNotFor:[],func:function(a,b){return b.callReturn()},event:"when_clone_start"},stop_run:{color:"#498deb",skeleton:"basic",statements:[], -params:[{type:"Indicator",img:"block_icon/flow_03.png",size:12}],events:{},def:{params:[null]},func:function(a,b){return Entry.engine.toggleStop()}},repeat_while_true:{color:"#498deb",skeleton:"basic_loop",statements:[{accept:"basic"}],params:[{type:"Block",accept:"boolean"},{type:"Dropdown",options:[[Lang.Blocks.FLOW_repeat_while_true_until,"until"],[Lang.Blocks.FLOW_repeat_while_true_while,"while"]],value:"until",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_FLOW},{type:"Indicator",img:"block_icon/flow_03.png", -size:12}],events:{},def:{params:[{type:"True"},null,null],type:"repeat_while_true"},paramsKeyMap:{BOOL:0,OPTION:1},statementsKeyMap:{DO:0},"class":"repeat",isNotFor:[],func:function(a,b){a=b.getBooleanValue("BOOL",b);"until"==b.getField("OPTION",b)&&(a=!a);return(b.isLooped=a)?b.getStatement("DO",b):b.callReturn()}},stop_object:{color:"#498deb",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.FLOW_stop_object_all,"all"],[Lang.Blocks.FLOW_stop_object_this_object,"thisOnly"], -[Lang.Blocks.FLOW_stop_object_this_thread,"thisThread"],[Lang.Blocks.FLOW_stop_object_other_thread,"otherThread"]],value:"all",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_FLOW},{type:"Indicator",img:"block_icon/flow_03.png",size:12}],events:{},def:{params:[null,null],type:"stop_object"},paramsKeyMap:{TARGET:0},"class":"terminate",isNotFor:[],func:function(a,b){var c=b.getField("TARGET",b),d=Entry.container;switch(c){case "all":return d.clearRunningState(),this.die();case "thisOnly":return a.parent.script.clearExecutorsByEntity(a), -this.die();case "thisObject":return a.parent.script.clearExecutors(),this.die();case "thisThread":return this.die();case "otherThread":c=this.executor;a=a.parent.script;for(var d=a.executors,e=0;eb.count?(50>c.leftFloor&&50>c.rightFloor?b.count++:b.count=0,c=c.leftFloor-c.rightFloor,a.leftWheel=45+.25*c,a.rightWheel=45-.25*c):(b.count=0,b.boardState=2);break;case 2:c=c.leftFloor-c.rightFloor;a.leftWheel=45+.25*c;a.rightWheel=45-.25*c;b.boardState=3;var d= -setTimeout(function(){b.boardState=4;Entry.Hamster.removeTimeout(d)},250);Entry.Hamster.timeouts.push(d);break;case 3:c=c.leftFloor-c.rightFloor;a.leftWheel=45+.25*c;a.rightWheel=45-.25*c;break;case 4:a.leftWheel=0,a.rightWheel=0,b.boardState=0,b.isMoving=!1}return b}delete b.isStart;delete b.isMoving;delete b.count;delete b.boardState;Entry.engine.isContinue=!1;a.leftWheel=0;a.rightWheel=0;return b.callReturn()}b.isStart=!0;b.isMoving=!0;b.count=0;b.boardState=1;a.leftWheel=45;a.rightWheel=45;Entry.Hamster.setLineTracerMode(a, -0);return b}},hamster_turn_once:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.General.left,"LEFT"],[Lang.General.right,"RIGHT"]],value:"LEFT",fontSize:11},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,null],type:"hamster_turn_once"},paramsKeyMap:{DIRECTION:0},"class":"hamster_board",isNotFor:["hamster"],func:function(a,b){a=Entry.hw.sendQueue;var c=Entry.hw.portData;if(b.isStart){if(b.isMoving){if(b.isLeft)switch(b.boardState){case 1:2> -b.count?50c.leftFloor&&(b.boardState=3);break;case 3:2>b.count?20>c.leftFloor&&b.count++:(b.count=0,b.boardState=4);break;case 4:50b.count?50c.rightFloor&&(b.boardState= -3);break;case 3:2>b.count?20>c.rightFloor&&b.count++:(b.count=0,b.boardState=4);break;case 4:50Entry.Hamster.tempo&&(Entry.Hamster.tempo=1);return b.callReturn()}},hamster_set_tempo_to:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[{type:"text",params:["60"]},null],type:"hamster_set_tempo_to"}, -paramsKeyMap:{VALUE:0},"class":"hamster_buzzer",isNotFor:["hamster"],func:function(a,b){Entry.Hamster.tempo=b.getNumberValue("VALUE");1>Entry.Hamster.tempo&&(Entry.Hamster.tempo=1);return b.callReturn()}},hamster_set_port_to:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.HAMSTER_port_a,"A"],[Lang.Blocks.HAMSTER_port_b,"B"],[Lang.Blocks.HAMSTER_port_ab,"AB"]],value:"A",fontSize:11},{type:"Dropdown",options:[[Lang.Blocks.HAMSTER_analog_input,"0"],[Lang.Blocks.HAMSTER_digital_input, -"1"],[Lang.Blocks.HAMSTER_servo_output,"8"],[Lang.Blocks.HAMSTER_pwm_output,"9"],[Lang.Blocks.HAMSTER_digital_output,"10"]],value:"0",fontSize:11},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,null,null],type:"hamster_set_port_to"},paramsKeyMap:{PORT:0,MODE:1},"class":"hamster_port",isNotFor:["hamster"],func:function(a,b){a=Entry.hw.sendQueue;var c=b.getField("PORT",b),d=Number(b.getField("MODE",b));"A"==c?a.ioModeA=d:("B"!=c&&(a.ioModeA=d),a.ioModeB=d); -return b.callReturn()}},hamster_change_output_by:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.HAMSTER_port_a,"A"],[Lang.Blocks.HAMSTER_port_b,"B"],[Lang.Blocks.HAMSTER_port_ab,"AB"]],value:"A",fontSize:11},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,{type:"text",params:["10"]},null],type:"hamster_change_output_by"},paramsKeyMap:{PORT:0,VALUE:1},"class":"hamster_port",isNotFor:["hamster"], -func:function(a,b){a=Entry.hw.sendQueue;var c=b.getField("PORT"),d=b.getNumberValue("VALUE");"A"==c?a.outputA=void 0!=a.outputA?a.outputA+d:d:("B"!=c&&(a.outputA=void 0!=a.outputA?a.outputA+d:d),a.outputB=void 0!=a.outputB?a.outputB+d:d);return b.callReturn()}},hamster_set_output_to:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.HAMSTER_port_a,"A"],[Lang.Blocks.HAMSTER_port_b,"B"],[Lang.Blocks.HAMSTER_port_ab,"AB"]],value:"A",fontSize:11},{type:"Block", -accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,{type:"text",params:["100"]},null],type:"hamster_set_output_to"},paramsKeyMap:{PORT:0,VALUE:1},"class":"hamster_port",isNotFor:["hamster"],func:function(a,b){a=Entry.hw.sendQueue;var c=b.getField("PORT"),d=b.getNumberValue("VALUE");"A"==c?a.outputA=d:("B"!=c&&(a.outputA=d),a.outputB=d);return b.callReturn()}},is_clicked:{color:"#AEB8FF",skeleton:"basic_boolean_field",statements:[],params:[{type:"Text", -text:Lang.Blocks.JUDGEMENT_is_clicked,color:"#3D3D3D"}],events:{},def:{params:[null],type:"is_clicked"},"class":"boolean_input",isNotFor:[],func:function(a,b){return Entry.stage.isClick}},is_press_some_key:{color:"#AEB8FF",skeleton:"basic_boolean_field",statements:[],params:[{type:"Keyboard",value:81},{type:"Text",text:Lang.Blocks.JUDGEMENT_is_press_some_key_2,color:"#3D3D3D"}],events:{},def:{params:[null,null],type:"is_press_some_key"},paramsKeyMap:{VALUE:0},"class":"boolean_input",isNotFor:[],func:function(a, -b){a=Number(b.getField("VALUE",b));return 0<=Entry.pressedKeys.indexOf(a)}},reach_something:{color:"#AEB8FF",skeleton:"basic_boolean_field",statements:[],params:[{type:"Text",text:Lang.Blocks.JUDGEMENT_reach_something_1,color:"#3D3D3D"},{type:"DropdownDynamic",value:null,menuName:"collision",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_JUDGE},{type:"Text",text:Lang.Blocks.JUDGEMENT_reach_something_2,color:"#3D3D3D"}],events:{},def:{params:[null,null,null],type:"reach_something"},paramsKeyMap:{VALUE:1}, -"class":"boolean_collision",isNotFor:[],func:function(a,b){if(!a.getVisible())return!1;var c=b.getField("VALUE",b);b=a.object;var d=/wall/.test(c),e=ndgmr.checkPixelCollision;if(d)switch(a=Entry.stage.wall,c){case "wall":if(e(b,a.up,.2,!0)||e(b,a.down,.2,!0)||e(b,a.left,.2,!0)||e(b,a.right,.2,!0))return!0;break;case "wall_up":if(e(b,a.up,.2,!0))return!0;break;case "wall_down":if(e(b,a.down,.2,!0))return!0;break;case "wall_right":if(e(b,a.right,.2,!0))return!0;break;case "wall_left":if(e(b,a.left, -.2,!0))return!0}else{if("mouse"==c)return e=Entry.stage.canvas,e=b.globalToLocal(e.mouseX,e.mouseY),b.hitTest(e.x,e.y);c=Entry.container.getEntity(c);if("textBox"==c.type||"textBox"==a.type){e=c.object.getTransformedBounds();b=b.getTransformedBounds();if(Entry.checkCollisionRect(b,e))return!0;a=c.parent.clonedEntities;c=0;for(d=a.length;c","BIGGER"]],value:"EQUAL",fontSize:11},{type:"Block",accept:"string"}],events:{},def:{params:[null],type:"boolean_comparison"},paramsKeyMap:{LEFTHAND:0,OPERATOR:1,RIGHTHAND:2},func:function(a, -b){a=b.getField("OPERATOR",b);var c=b.getNumberValue("LEFTHAND",b);b=b.getNumberValue("RIGHTHAND",b);return"EQUAL"==a?c==b:"BIGGER"==a?c>b:c",color:"#3D3D3D"},{type:"Block",accept:"string"}],events:{},def:{params:[{type:"number",params:["10"]},null,{type:"number",params:["10"]}],type:"boolean_bigger"},paramsKeyMap:{LEFTHAND:0,RIGHTHAND:2},"class":"boolean_compare",isNotFor:[],func:function(a, -b){a=b.getNumberValue("LEFTHAND",b);b=b.getNumberValue("RIGHTHAND",b);return a>b}},boolean_smaller:{color:"#AEB8FF",skeleton:"basic_boolean_field",statements:[],params:[{type:"Block",accept:"string"},{type:"Text",text:"<",color:"#3D3D3D"},{type:"Block",accept:"string"}],events:{},def:{params:[{type:"number",params:["10"]},null,{type:"number",params:["10"]}],type:"boolean_smaller"},paramsKeyMap:{LEFTHAND:0,RIGHTHAND:2},"class":"boolean_compare",isNotFor:[],func:function(a,b){a=b.getNumberValue("LEFTHAND", -b);b=b.getNumberValue("RIGHTHAND",b);return a","GREATER"],["<","LESS"],["\u2265","GREATER_OR_EQUAL"],["\u2264","LESS_OR_EQUAL"]],value:"EQUAL",fontSize:11,noArrow:!0},{type:"Block",accept:"string"}],events:{},def:{params:[{type:"text",params:["10"]},"EQUAL",{type:"text",params:["10"]}], -type:"boolean_basic_operator"},defs:[{params:[{type:"text",params:["10"]},"EQUAL",{type:"text",params:["10"]}],type:"boolean_basic_operator"},{params:[{type:"text",params:["10"]},"GREATER",{type:"text",params:["10"]}],type:"boolean_basic_operator"},{params:[{type:"text",params:["10"]},"LESS",{type:"text",params:["10"]}],type:"boolean_basic_operator"},{params:[{type:"text",params:["10"]},"GREATER_OR_EQUAL",{type:"text",params:["10"]}],type:"boolean_basic_operator"},{params:[{type:"text",params:["10"]}, -"LESS_OR_EQUAL",{type:"text",params:["10"]}],type:"boolean_basic_operator"}],paramsKeyMap:{LEFTHAND:0,OPERATOR:1,RIGHTHAND:2},"class":"boolean_compare",isNotFor:[],func:function(a,b){a=b.getField("OPERATOR",b);var c=b.getStringValue("LEFTHAND",b);b=b.getStringValue("RIGHTHAND",b);switch(a){case "EQUAL":return c==b;case "GREATER":return Number(c)>Number(b);case "LESS":return Number(c)=Number(b);case "LESS_OR_EQUAL":return Number(c)<=Number(b)}}}, -show:{color:"#EC4466",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/looks_03.png",size:12}],events:{},def:{params:[null],type:"show"},"class":"visibility",isNotFor:[],func:function(a,b){a.setVisible(!0);return b.callReturn()}},hide:{color:"#EC4466",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/looks_03.png",size:12}],events:{},def:{params:[null],type:"hide"},"class":"visibility",isNotFor:[],func:function(a,b){a.setVisible(!1);return b.callReturn()}}, -dialog_time:{color:"#EC4466",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Dropdown",options:[[Lang.Blocks.speak,"speak"]],value:"speak",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_LOOKS},{type:"Indicator",img:"block_icon/looks_03.png",size:12}],events:{},def:{params:[{type:"text",params:[Lang.Blocks.block_hi]},{type:"number",params:["4"]},null,null],type:"dialog_time"},paramsKeyMap:{VALUE:0,SECOND:1,OPTION:2},"class":"say",isNotFor:["textBox"], -func:function(a,b){if(!b.isStart){var c=b.getNumberValue("SECOND",b),d=b.getStringValue("VALUE",b),e=b.getField("OPTION",b);b.isStart=!0;b.timeFlag=1;d||"number"==typeof d||(d=" ");d=Entry.convertToRoundedDecimals(d,3);new Entry.Dialog(a,d,e);a.syncDialogVisible(a.getVisible());setTimeout(function(){b.timeFlag=0},1E3*c)}if(0==b.timeFlag)return delete b.timeFlag,delete b.isStart,a.dialog&&a.dialog.remove(),b.callReturn();a.dialog||(d=b.getStringValue("VALUE",b),e=b.getField("OPTION",b),d||"number"== -typeof d||(d=" "),d=Entry.convertToRoundedDecimals(d,3),new Entry.Dialog(a,d,e),a.syncDialogVisible(a.getVisible()));return b}},dialog:{color:"#EC4466",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Dropdown",options:[[Lang.Blocks.speak,"speak"]],value:"speak",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_LOOKS},{type:"Indicator",img:"block_icon/looks_03.png",size:12}],events:{},def:{params:[{type:"text",params:[Lang.Blocks.block_hi]},null,null],type:"dialog"},paramsKeyMap:{VALUE:0, -OPTION:1},"class":"say",isNotFor:["textBox"],func:function(a,b){var c=b.getStringValue("VALUE",b);c||"number"==typeof c||(c=" ");var d=b.getField("OPTION",b),c=Entry.convertToRoundedDecimals(c,3);new Entry.Dialog(a,c,d);a.syncDialogVisible(a.getVisible());return b.callReturn()}},remove_dialog:{color:"#EC4466",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/looks_03.png",size:12}],events:{},def:{params:[null],type:"remove_dialog"},"class":"say",isNotFor:["textBox"],func:function(a, -b){a.dialog&&a.dialog.remove();return b.callReturn()}},change_to_nth_shape:{color:"#EC4466",skeleton:"basic",statements:[],params:[{type:"DropdownDynamic",value:null,menuName:"pictures",fontSize:11},{type:"Indicator",img:"block_icon/looks_03.png",size:12}],events:{},def:{params:[null,null],type:"change_to_nth_shape"},paramsKeyMap:{VALUE:0},"class":"shape",isNotFor:[],func:function(a,b){var c=b.getField("VALUE",b),c=a.parent.getPicture(c);a.setImage(c);return b.callReturn()}},change_to_next_shape:{color:"#EC4466", -skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.LOOKS_change_shape_next,"next"],[Lang.Blocks.LOOKS_change_shape_prev,"prev"]],value:"next",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_LOOKS},{type:"Indicator",img:"block_icon/looks_03.png",size:12}],events:{},def:{params:[null,null],type:"change_to_next_shape"},paramsKeyMap:{DRIECTION:0},"class":"shape",isNotFor:["textBox"],func:function(a,b){var c;c="prev"!==b.getStringField("DRIECTION")?a.parent.getNextPicture(a.picture.id): -a.parent.getPrevPicture(a.picture.id);a.setImage(c);return b.callReturn()}},set_effect_volume:{color:"#EC4466",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.color,"color"],[Lang.Blocks.brightness,"brightness"],[Lang.Blocks.opacity,"opacity"]],value:"color",fontSize:11},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/looks_03.png",size:12}],events:{},def:{params:[null,{type:"number",params:["10"]},null],type:"set_effect_volume"},paramsKeyMap:{EFFECT:0, -VALUE:1},"class":"effect",isNotFor:["textBox"],func:function(a,b){var c=b.getField("EFFECT",b),d=b.getNumberValue("VALUE",b);"color"==c?a.effect.hue=d+a.effect.hue:"lens"!=c&&"swriling"!=c&&"pixel"!=c&&"mosaic"!=c&&("brightness"==c?a.effect.brightness=d+a.effect.brightness:"blur"!=c&&"opacity"==c&&(a.effect.alpha+=d/100));a.applyFilter();return b.callReturn()}},set_effect:{color:"#EC4466",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.color,"color"],[Lang.Blocks.brightness, -"brightness"],[Lang.Blocks.opacity,"opacity"]],value:"color",fontSize:11},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/looks_03.png",size:12}],events:{},def:{params:[null,{type:"number",params:["100"]},null],type:"set_effect"},paramsKeyMap:{EFFECT:0,VALUE:1},"class":"effect",isNotFor:["textBox"],func:function(a,b){var c=b.getField("EFFECT",b),d=b.getNumberValue("VALUE",b);"color"==c?a.effect.hue=d:"lens"!=c&&"swriling"!=c&&"pixel"!=c&&"mosaic"!=c&&("brightness"==c?a.effect.brightness= -d:"blur"!=c&&"opacity"==c&&(a.effect.alpha=d/100));a.applyFilter();return b.callReturn()}},erase_all_effects:{color:"#EC4466",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/looks_03.png",size:12}],events:{},def:{params:[null],type:"erase_all_effects"},"class":"effect",isNotFor:["textBox"],func:function(a,b){a.resetFilter();return b.callReturn()}},change_scale_percent:{color:"#EC4466",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator", -img:"block_icon/looks_03.png",size:12}],events:{},def:{params:[{type:"number",params:["10"]},null],type:"change_scale_percent"},paramsKeyMap:{VALUE:0},"class":"scale",isNotFor:[],func:function(a,b){var c=(b.getNumberValue("VALUE",b)+100)/100;a.setScaleX(a.getScaleX()*c);a.setScaleY(a.getScaleY()*c);return b.callReturn()}},set_scale_percent:{color:"#EC4466",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/looks_03.png",size:12}],events:{},def:{params:[{type:"number", -params:["100"]},null],type:"set_scale_percent"},paramsKeyMap:{VALUE:0},"class":"scale",isNotFor:[],func:function(a,b){var c=b.getNumberValue("VALUE",b)/100,d=a.snapshot_;a.setScaleX(c*d.scaleX);a.setScaleY(c*d.scaleY);return b.callReturn()}},change_scale_size:{color:"#EC4466",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/looks_03.png",size:12}],events:{},def:{params:[{type:"number",params:["10"]},null],type:"change_scale_size"},paramsKeyMap:{VALUE:0}, -"class":"scale",isNotFor:[],func:function(a,b){var c=b.getNumberValue("VALUE",b);a.setSize(a.getSize()+c);return b.callReturn()}},set_scale_size:{color:"#EC4466",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/looks_03.png",size:12}],events:{},def:{params:[{type:"number",params:["100"]},null],type:"set_scale_size"},paramsKeyMap:{VALUE:0},"class":"scale",isNotFor:[],func:function(a,b){var c=b.getNumberValue("VALUE",b);a.setSize(c);return b.callReturn()}}, -flip_y:{color:"#EC4466",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/looks_03.png",size:12}],events:{},def:{params:[null],type:"flip_y"},"class":"flip",isNotFor:[],func:function(a,b){a.setScaleX(-1*a.getScaleX());return b.callReturn()}},flip_x:{color:"#EC4466",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/looks_03.png",size:12}],events:{},def:{params:[null],type:"flip_x"},"class":"flip",isNotFor:[],func:function(a,b){a.setScaleY(-1*a.getScaleY()); -return b.callReturn()}},set_object_order:{color:"#EC4466",skeleton:"basic",statements:[],params:[{type:"DropdownDynamic",value:null,menuName:"objectSequence",fontSize:11},{type:"Indicator",img:"block_icon/looks_03.png",size:12}],events:{},def:{params:[null,null],type:"set_object_order"},paramsKeyMap:{VALUE:0},"class":"z-index",isNotFor:[],func:function(a,b){var c=b.getField("VALUE",b);a=Entry.container.getCurrentObjects().indexOf(a.parent);if(-1a)throw Error("object is not available for current scene");switch(d){case "FRONT":c=0;break;case "FORWARD":c=Math.max(0, -a-1);break;case "BACKWARD":c=Math.min(e,a+1);break;case "BACK":c=e}Entry.container.moveElementByBlock(a,c);return b.callReturn()}},move_direction:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"number",params:["10"]},null],type:"move_direction"},paramsKeyMap:{VALUE:0},"class":"walk",isNotFor:[],func:function(a,b){var c=b.getNumberValue("VALUE",b);a.setX(a.getX()+c*Math.cos((a.getRotation()+ -a.getDirection()-90)/180*Math.PI));a.setY(a.getY()-c*Math.sin((a.getRotation()+a.getDirection()-90)/180*Math.PI));a.brush&&!a.brush.stop&&a.brush.lineTo(a.getX(),-1*a.getY());return b.callReturn()}},move_x:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"number",params:["10"]},null],type:"move_x"},paramsKeyMap:{VALUE:0},"class":"move_relative",isNotFor:[],func:function(a, -b){var c=b.getNumberValue("VALUE",b);a.setX(a.getX()+c);a.brush&&!a.brush.stop&&a.brush.lineTo(a.getX(),-1*a.getY());return b.callReturn()}},move_y:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"number",params:["10"]},null],type:"move_y"},paramsKeyMap:{VALUE:0},"class":"move_relative",isNotFor:[],func:function(a,b){var c=b.getNumberValue("VALUE",b);a.setY(a.getY()+c);a.brush&& -!a.brush.stop&&a.brush.lineTo(a.getX(),-1*a.getY());return b.callReturn()}},locate_xy_time:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"number",params:["2"]},{type:"number",params:["10"]},{type:"number",params:["10"]},null],type:"locate_xy_time"},paramsKeyMap:{VALUE1:0,VALUE2:1,VALUE3:2},"class":"move_absolute", -isNotFor:[],func:function(a,b){function c(){var c=b.x-a.getX(),d=b.y-a.getY(),c=c/b.frameCount,d=d/b.frameCount;a.setX(a.getX()+c);a.setY(a.getY()+d);b.frameCount--;a.brush&&!a.brush.stop&&a.brush.lineTo(a.getX(),-1*a.getY())}if(!b.isStart){var d;d=b.getNumberValue("VALUE1",b);b.isStart=!0;b.frameCount=Math.max(Math.floor(d*Entry.FPS),1);b.x=b.getNumberValue("VALUE2",b);b.y=b.getNumberValue("VALUE3",b);1==b.frameCount&&c()}if(0!=b.frameCount)return c(),b;delete b.isStart;delete b.frameCount;return b.callReturn()}}, -rotate_by_angle:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"number",params:["90"]},null],type:"rotate_by_angle"},paramsKeyMap:{VALUE:0},"class":"rotate",isNotFor:[],func:function(a,b){var c=b.getNumberValue("VALUE",b);a.setRotation(a.getRotation()+c);return b.callReturn()}},rotate_by_angle_dropdown:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Dropdown", -options:[["45","45"],["90","90"],["135","135"],["180","180"]],value:"45",fontSize:11},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:["45",null],type:"rotate_by_angle_dropdown"},paramsKeyMap:{VALUE:0},"class":"ebs",isNotFor:[],func:function(a,b){var c=b.getField("VALUE",b);a.setRotation(a.getRotation()+Number(c));return b.callReturn()}},see_angle:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png", -size:12}],events:{},def:{params:[{type:"number",params:["90"]},null],type:"see_angle"},paramsKeyMap:{VALUE:0},"class":"rotate",isNotFor:[],func:function(a,b){var c=b.getNumberValue("VALUE",b);a.setDirection(c);return b.callReturn()}},see_direction:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"DropdownDynamic",value:null,menuName:"sprites",fontSize:11},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[null,null]},paramsKeyMap:{VALUE:0},func:function(a, -b){var c=b.getField("VALUE",b),d=Entry.container.getEntity(c),c=d.getX()-a.getX(),d=d.getY()-a.getY();0<=c?a.setRotation(Math.atan(d/c)/Math.PI*180+90):a.setRotation(Math.atan(d/c)/Math.PI*180+270);return b.callReturn()}},locate_xy:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"number",params:["0"]},{type:"number",params:["0"]},null],type:"locate_xy"}, -paramsKeyMap:{VALUE1:0,VALUE2:1},"class":"move_absolute",isNotFor:[],func:function(a,b){var c=b.getNumberValue("VALUE1",b),d=b.getNumberValue("VALUE2",b);a.setX(c);a.setY(d);a.brush&&!a.brush.stop&&a.brush.lineTo(a.getX(),-1*a.getY());return b.callReturn()}},locate_x:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"number",params:["10"]},null],type:"locate_x"},paramsKeyMap:{VALUE:0}, -"class":"move_absolute",isNotFor:[],func:function(a,b){var c=b.getNumberValue("VALUE",b);a.setX(c);a.brush&&!a.brush.stop&&a.brush.lineTo(a.getX(),-1*a.getY());return b.callReturn()}},locate_y:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"number",params:["10"]},null],type:"locate_y"},paramsKeyMap:{VALUE:0},"class":"move_absolute",isNotFor:[],func:function(a,b){var c=b.getNumberValue("VALUE", -b);a.setY(c);a.brush&&!a.brush.stop&&a.brush.lineTo(a.getX(),-1*a.getY());return b.callReturn()}},locate:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"DropdownDynamic",value:null,menuName:"spritesWithMouse",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_MOVING},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[null,null],type:"locate"},paramsKeyMap:{VALUE:0},"class":"move_absolute",isNotFor:[],func:function(a,b){var c=b.getField("VALUE",b),d;"mouse"== -c?(c=Entry.stage.mouseCoordinate.x,d=Entry.stage.mouseCoordinate.y):(d=Entry.container.getEntity(c),c=d.getX(),d=d.getY());a.setX(Number(c));a.setY(Number(d));a.brush&&!a.brush.stop&&a.brush.lineTo(c,-1*d);return b.callReturn()}},move_xy_time:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"number",params:["2"]}, -{type:"number",params:["10"]},{type:"number",params:["10"]},null],type:"move_xy_time"},paramsKeyMap:{VALUE1:0,VALUE2:1,VALUE3:2},"class":"move_relative",isNotFor:[],func:function(a,b){function c(){a.setX(a.getX()+b.dX);a.setY(a.getY()+b.dY);b.frameCount--;a.brush&&!a.brush.stop&&a.brush.lineTo(a.getX(),-1*a.getY())}if(!b.isStart){var d;d=b.getNumberValue("VALUE1",b);var e=b.getNumberValue("VALUE2",b),f=b.getNumberValue("VALUE3",b);b.isStart=!0;b.frameCount=Math.max(Math.floor(d*Entry.FPS),1);b.dX= -e/b.frameCount;b.dY=f/b.frameCount;1==b.frameCount&&c()}if(0!=b.frameCount)return c(),b;delete b.isStart;delete b.frameCount;return b.callReturn()}},rotate_by_angle_time:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Angle"},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"number",params:["2"]},null,null],type:"rotate_by_angle_time"},paramsKeyMap:{VALUE:1},"class":"rotate",isNotFor:[],func:function(a,b){if(!b.isStart){var c; -c=b.getNumberValue("VALUE",b);var d=b.getNumberField("VALUE",b);b.isStart=!0;b.frameCount=Math.floor(c*Entry.FPS);b.dAngle=d/b.frameCount}if(0!=b.frameCount)return a.setRotation(a.getRotation()+b.dAngle),b.frameCount--,b;delete b.isStart;delete b.frameCount;return b.callReturn()}},bounce_wall:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[null],type:"bounce_wall"},"class":"walk",isNotFor:[],func:function(a, -b){var c=a.parent.getRotateMethod(),d="free"==c?(a.getRotation()+a.getDirection()).mod(360):a.getDirection(),e;if(90>d&&0<=d||360>d&&270<=d){e=a.collision==Entry.Utils.COLLISION.UP;var f=ndgmr.checkPixelCollision(Entry.stage.wall.up,a.object,0,!1);!f&&e&&(a.collision=Entry.Utils.COLLISION.NONE);f&&e&&(f=!1);f?("free"==c?a.setRotation(-a.getRotation()-2*a.getDirection()+180):a.setDirection(-a.getDirection()+180),a.collision=Entry.Utils.COLLISION.UP):(e=a.collision==Entry.Utils.COLLISION.DOWN,f=ndgmr.checkPixelCollision(Entry.stage.wall.down, -a.object,0,!1),!f&&e&&(a.collision=Entry.Utils.COLLISION.NONE),f&&e&&(f=!1),f&&("free"==c?a.setRotation(-a.getRotation()-2*a.getDirection()+180):a.setDirection(-a.getDirection()+180),a.collision=Entry.Utils.COLLISION.DOWN))}else 270>d&&90<=d&&(e=a.collision==Entry.Utils.COLLISION.DOWN,f=ndgmr.checkPixelCollision(Entry.stage.wall.down,a.object,0,!1),!f&&e&&(a.collision=Entry.Utils.COLLISION.NONE),f&&e&&(f=!1),f?("free"==c?a.setRotation(-a.getRotation()-2*a.getDirection()+180):a.setDirection(-a.getDirection()+ -180),a.collision=Entry.Utils.COLLISION.DOWN):(e=a.collision==Entry.Utils.COLLISION.UP,f=ndgmr.checkPixelCollision(Entry.stage.wall.up,a.object,0,!1),!f&&e&&(a.collision=Entry.Utils.COLLISION.NONE),f&&e&&(f=!1),f&&("free"==c?a.setRotation(-a.getRotation()-2*a.getDirection()+180):a.setDirection(-a.getDirection()+180),a.collision=Entry.Utils.COLLISION.UP)));360>d&&180<=d?(e=a.collision==Entry.Utils.COLLISION.LEFT,d=ndgmr.checkPixelCollision(Entry.stage.wall.left,a.object,0,!1),!d&&e&&(a.collision=Entry.Utils.COLLISION.NONE), -d&&e&&(d=!1),d?("free"==c?a.setRotation(-a.getRotation()-2*a.getDirection()):a.setDirection(-a.getDirection()+360),a.collision=Entry.Utils.COLLISION.LEFT):(e=a.collision==Entry.Utils.COLLISION.RIGHT,d=ndgmr.checkPixelCollision(Entry.stage.wall.right,a.object,0,!1),!d&&e&&(a.collision=Entry.Utils.COLLISION.NONE),d&&e&&(d=!1),d&&("free"==c?a.setRotation(-a.getRotation()-2*a.getDirection()):a.setDirection(-a.getDirection()+360),a.collision=Entry.Utils.COLLISION.RIGHT))):180>d&&0<=d&&(e=a.collision== -Entry.Utils.COLLISION.RIGHT,d=ndgmr.checkPixelCollision(Entry.stage.wall.right,a.object,0,!1),!d&&e&&(a.collision=Entry.Utils.COLLISION.NONE),d&&e&&(d=!1),d?("free"==c?a.setRotation(-a.getRotation()-2*a.getDirection()):a.setDirection(-a.getDirection()+360),a.collision=Entry.Utils.COLLISION.RIGHT):(e=a.collision==Entry.Utils.COLLISION.LEFT,d=ndgmr.checkPixelCollision(Entry.stage.wall.left,a.object,0,!1),!d&&e&&(a.collision=Entry.Utils.COLLISION.NONE),d&&e&&(d=!1),d&&("free"==c?a.setRotation(-a.getRotation()- -2*a.getDirection()):a.setDirection(-a.getDirection()+360),a.collision=Entry.Utils.COLLISION.LEFT)));return b.callReturn()}},flip_arrow_horizontal:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[null]},func:function(a,b){a.setDirection(a.getDirection()+180);return b.callReturn()}},flip_arrow_vertical:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/moving_03.png",size:12}], -events:{},def:{params:[null]},func:function(a,b){a.setDirection(a.getDirection()+180);return b.callReturn()}},see_angle_object:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"DropdownDynamic",value:null,menuName:"spritesWithMouse",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_MOVING},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[null,null],type:"see_angle_object"},paramsKeyMap:{VALUE:0},"class":"rotate_absolute",isNotFor:[],func:function(a,b){var c= -b.getField("VALUE",b),d=a.getX(),e=a.getY();if(a.parent.id==c)return b.callReturn();"mouse"==c?(c=Entry.stage.mouseCoordinate.y,d=Entry.stage.mouseCoordinate.x-d,e=c-e):(c=Entry.container.getEntity(c),d=c.getX()-d,e=c.getY()-e);e=0===d&&0===e?a.getDirection()+a.getRotation():0<=d?-Math.atan(e/d)/Math.PI*180+90:-Math.atan(e/d)/Math.PI*180+270;d=a.getDirection()+a.getRotation();a.setRotation(a.getRotation()+e-d);return b.callReturn()}},see_angle_direction:{color:"#A751E3",skeleton:"basic",statements:[], -params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"number",params:["90"]},null],type:"see_angle_direction"},paramsKeyMap:{VALUE:0},"class":"rotate",isNotFor:[],func:function(a,b){var c=b.getNumberValue("VALUE",b),d=a.getDirection()+a.getRotation();a.setRotation(a.getRotation()+c-d);return b.callReturn()}},rotate_direction:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator", -img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"number",params:["90"]},null],type:"rotate_direction"},paramsKeyMap:{VALUE:0},"class":"rotate",isNotFor:[],func:function(a,b){var c=b.getNumberValue("VALUE",b);a.setDirection(c+a.getDirection());return b.callReturn()}},locate_object_time:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"DropdownDynamic",value:null,menuName:"spritesWithMouse",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_MOVING}, -{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"number",params:["2"]},null,null],type:"locate_object_time"},paramsKeyMap:{VALUE:0,TARGET:1},"class":"move_absolute",isNotFor:[],func:function(a,b){if(!b.isStart){var c,d,e;d=b.getField("TARGET",b);c=b.getNumberValue("VALUE",b);c=Math.floor(c*Entry.FPS);e=Entry.stage.mouseCoordinate;if(0!=c)"mouse"==d?(d=e.x-a.getX(),e=e.y-a.getY()):(e=Entry.container.getEntity(d),d=e.getX()-a.getX(),e=e.getY()-a.getY()),b.isStart= -!0,b.frameCount=c,b.dX=d/b.frameCount,b.dY=e/b.frameCount;else return"mouse"==d?(d=Number(e.x),e=Number(e.y)):(e=Entry.container.getEntity(d),d=e.getX(),e=e.getY()),a.setX(d),a.setY(e),a.brush&&!a.brush.stop&&a.brush.lineTo(a.getX(),-1*a.getY()),b.callReturn()}if(0!=b.frameCount)return a.setX(a.getX()+b.dX),a.setY(a.getY()+b.dY),b.frameCount--,a.brush&&!a.brush.stop&&a.brush.lineTo(a.getX(),-1*a.getY()),b;delete b.isStart;delete b.frameCount;return b.callReturn()}},rotate_absolute:{color:"#A751E3", -skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"angle"},null],type:"rotate_absolute"},paramsKeyMap:{VALUE:0},"class":"rotate_absolute",isNotFor:[],func:function(a,b){var c=b.getNumberValue("VALUE",b);a.setRotation(c);return b.callReturn()}},rotate_relative:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png", -size:12}],events:{},def:{params:[{type:"angle"},null],type:"rotate_relative"},paramsKeyMap:{VALUE:0},"class":"rotate",isNotFor:[],func:function(a,b){var c=b.getNumberValue("VALUE",b);a.setRotation(c+a.getRotation());return b.callReturn()}},direction_absolute:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"angle"},null],type:"direction_absolute"},paramsKeyMap:{VALUE:0},"class":"rotate_absolute", -isNotFor:[],func:function(a,b){var c=b.getNumberValue("VALUE",b);a.setDirection(c);return b.callReturn()}},direction_relative:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"angle"},null],type:"direction_relative"},paramsKeyMap:{VALUE:0},"class":"rotate",isNotFor:[],func:function(a,b){var c=b.getNumberValue("VALUE",b);a.setDirection(c+a.getDirection());return b.callReturn()}}, -move_to_angle:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"angle"},{type:"number",params:["10"]},null],type:"move_to_angle"},paramsKeyMap:{ANGLE:0,VALUE:1},"class":"move_rotate",isNotFor:[],func:function(a,b){var c=b.getNumberValue("VALUE",b),d=b.getNumberValue("ANGLE",b);a.setX(a.getX()+c*Math.cos((d-90)/180*Math.PI));a.setY(a.getY()-c* -Math.sin((d-90)/180*Math.PI));a.brush&&!a.brush.stop&&a.brush.lineTo(a.getX(),-1*a.getY());return b.callReturn()}},rotate_by_time:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"number",params:["2"]},{type:"angle"},null],type:"rotate_by_time"},paramsKeyMap:{VALUE:0,ANGLE:1},"class":"rotate",isNotFor:[],func:function(a,b){function c(){a.setRotation(a.getRotation()+ -b.dAngle);b.frameCount--}if(!b.isStart){var d;d=b.getNumberValue("VALUE",b);var e=b.getNumberValue("ANGLE",b);b.isStart=!0;b.frameCount=Math.max(Math.floor(d*Entry.FPS),1);b.dAngle=e/b.frameCount;1==b.frameCount&&c()}if(0!=b.frameCount)return c(),b;delete b.isStart;delete b.frameCount;return b.callReturn()}},direction_relative_duration:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png", -size:12}],events:{},def:{params:[{type:"text",params:["2"]},{type:"angle"},null],type:"direction_relative_duration"},paramsKeyMap:{DURATION:0,AMOUNT:1},"class":"rotate",isNotFor:[],func:function(a,b){function c(){a.setDirection(a.getDirection()+b.dDirection);b.frameCount--}if(!b.isStart){var d;d=b.getNumberValue("DURATION",b);var e=b.getNumberValue("AMOUNT",b);b.isStart=!0;b.frameCount=Math.max(Math.floor(d*Entry.FPS),1);b.dDirection=e/b.frameCount;1==b.frameCount&&c()}if(0!=b.frameCount)return c(), -b;delete b.isStart;delete b.frameCount;delete b.dDirection;return b.callReturn()}},neobot_sensor_value:{color:"#00979D",skeleton:"basic_string_field",fontColor:"#fff",statements:[],template:"%1 \uac12",params:[{type:"Dropdown",options:[["1\ubc88 \ud3ec\ud2b8","IN1"],["2\ubc88 \ud3ec\ud2b8","IN2"],["3\ubc88 \ud3ec\ud2b8","IN3"],["\ub9ac\ubaa8\ucee8","IR"],["\ubc30\ud130\ub9ac","BAT"]],value:"IN1",fontSize:11}],events:{},def:{params:[null],type:"neobot_sensor_value"},paramsKeyMap:{PORT:0},"class":"neobot_value", -isNotFor:["neobot"],func:function(a,b){a=b.getStringField("PORT");return Entry.hw.portData[a]}},neobot_sensor_convert_scale:{color:"#00979D",skeleton:"basic_string_field",fontColor:"#fff",statements:[],template:"%1 \uac12\uc758 \ubc94\uc704\ub97c %2 ~ %3 \uc5d0\uc11c %4 ~ %5 (\uc73c)\ub85c \ubcc0\ud658",params:[{type:"Dropdown",options:[["1\ubc88 \ud3ec\ud2b8","IN1"],["2\ubc88 \ud3ec\ud2b8","IN2"],["3\ubc88 \ud3ec\ud2b8","IN3"],["\ub9ac\ubaa8\ucee8","IR"],["\ubc30\ud130\ub9ac","BAT"]],value:"IN1", -fontSize:11},{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Block",accept:"string"}],events:{},def:{params:[null,{type:"number",params:["0"]},{type:"number",params:["255"]},{type:"number",params:["0"]},{type:"number",params:["100"]}],type:"neobot_sensor_convert_scale"},paramsKeyMap:{PORT:0,OMIN:1,OMAX:2,MIN:3,MAX:4},"class":"neobot_value",isNotFor:["neobot"],func:function(a,b){a=b.getStringField("PORT");a=Entry.hw.portData[a];var c=b.getNumberValue("OMIN", -b),d=b.getNumberValue("OMAX",b),e=b.getNumberValue("MIN",b);b=b.getNumberValue("MAX",b);if(c>d)var f=c,c=d,d=f;e>b&&(f=e,e=b,b=f);a=Math.min(b,(b-e)/(d-c)*(a-c)+e);a=Math.max(e,a);return Math.round(a)}},neobot_left_motor:{color:"#00979D",skeleton:"basic",statements:[],template:"\uc67c\ucabd \ubaa8\ud130\ub97c %1 %2 \uc758 \uc18d\ub3c4\ub85c \ud68c\uc804 %3",params:[{type:"Dropdown",options:[["\uc55e\uc73c\ub85c","16"],["\ub4a4\ub85c","32"]],value:"16",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW}, -{type:"Dropdown",options:[["0","0"],["1","1"],["2","2"],["3","3"],["4","4"],["5","5"],["6","6"],["7","7"],["8","8"],["9","9"],["10","10"],["11","11"],["12","12"],["13","13"],["14","14"],["15","15"]],value:"0",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,"15",null],type:"neobot_left_motor"},paramsKeyMap:{DIRECTION:0,SPEED:1},"class":"neobot_motor",isNotFor:["neobot"],func:function(a,b){a=b.getNumberField("SPEED"); -var c=b.getNumberField("DIRECTION");Entry.hw.sendQueue.DCL=a+c;return b.callReturn()}},neobot_stop_left_motor:{color:"#00979D",skeleton:"basic",statements:[],template:"\uc67c\ucabd \ubaa8\ud130\ub97c \uc815\uc9c0 %1",params:[{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null],type:"neobot_stop_left_motor"},"class":"neobot_motor",isNotFor:["neobot"],func:function(a,b){Entry.hw.sendQueue.DCL=0;return b.callReturn()}},neobot_right_motor:{color:"#00979D",skeleton:"basic", -statements:[],template:"\uc624\ub978\ucabd \ubaa8\ud130\ub97c %1 %2 \uc758 \uc18d\ub3c4\ub85c \ud68c\uc804 %3",params:[{type:"Dropdown",options:[["\uc55e\uc73c\ub85c","16"],["\ub4a4\ub85c","32"]],value:"16",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW},{type:"Dropdown",options:[["0","0"],["1","1"],["2","2"],["3","3"],["4","4"],["5","5"],["6","6"],["7","7"],["8","8"],["9","9"],["10","10"],["11","11"],["12","12"],["13","13"],["14","14"],["15","15"]],value:"0",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW}, -{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,"15",null],type:"neobot_right_motor"},paramsKeyMap:{DIRECTION:0,SPEED:1},"class":"neobot_motor",isNotFor:["neobot"],func:function(a,b){a=b.getNumberField("SPEED");var c=b.getNumberField("DIRECTION");Entry.hw.sendQueue.DCR=a+c;return b.callReturn()}},neobot_stop_right_motor:{color:"#00979D",skeleton:"basic",statements:[],template:"\uc624\ub978\ucabd \ubaa8\ud130\ub97c \uc815\uc9c0 %1",params:[{type:"Indicator", -img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null],type:"neobot_stop_right_motor"},"class":"neobot_motor",isNotFor:["neobot"],func:function(a,b){Entry.hw.sendQueue.DCR=0;return b.callReturn()}},neobot_all_motor:{color:"#00979D",skeleton:"basic",statements:[],template:"\uc591\ucabd \ubaa8\ud130\ub97c %1 %2\uc758 \uc18d\ub3c4\ub85c %3\ucd08 \ub3d9\uc548 \ud68c\uc804 %4",params:[{type:"Dropdown",options:[["\uc55e\uc73c\ub85c","1"],["\ub4a4\ub85c","2"],["\uc81c\uc790\ub9ac\uc5d0\uc11c \uc67c\ucabd \ub3cc\uae30", -"3"],["\uc81c\uc790\ub9ac\uc5d0\uc11c \uc624\ub978\ucabd \ub3cc\uae30","4"],["\uc67c\ucabd\uc73c\ub85c \ub3cc\uae30","5"],["\uc624\ub978\ucabd\uc73c\ub85c \ub3cc\uae30","6"]],value:"1",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW},{type:"Dropdown",options:[["0","0"],["1","1"],["2","2"],["3","3"],["4","4"],["5","5"],["6","6"],["7","7"],["8","8"],["9","9"],["10","10"],["11","11"],["12","12"],["13","13"],["14","14"],["15","15"]],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:["1","15",{type:"number",params:["0"]}],type:"neobot_all_motor"},paramsKeyMap:{DIRECTION:0,SPEED:1,DURATION:2},"class":"neobot_motor",isNotFor:["neobot"],func:function(a,b){if(b.isStart){if(1==b.timeFlag)return b;delete b.timeFlag;delete b.isStart;Entry.hw.sendQueue.DCL=0;Entry.hw.sendQueue.DCR=0;Entry.engine.isContinue=!1;return b.callReturn()}a=b.getNumberField("SPEED");var c=b.getNumberField("DIRECTION"), -d=b.getNumberValue("DURATION");0>d&&(d=0);switch(c){case 1:Entry.hw.sendQueue.DCL=16+a;Entry.hw.sendQueue.DCR=16+a;break;case 2:Entry.hw.sendQueue.DCL=32+a;Entry.hw.sendQueue.DCR=32+a;break;case 3:Entry.hw.sendQueue.DCL=32+a;Entry.hw.sendQueue.DCR=16+a;break;case 4:Entry.hw.sendQueue.DCL=16+a;Entry.hw.sendQueue.DCR=32+a;break;case 5:Entry.hw.sendQueue.DCL=0;Entry.hw.sendQueue.DCR=16+a;break;case 6:Entry.hw.sendQueue.DCL=16+a,Entry.hw.sendQueue.DCR=0}if(0===d)return b.callReturn();b.isStart=!0;b.timeFlag= -1;setTimeout(function(){b.timeFlag=0},1E3*d);return b}},neobot_stop_all_motor:{color:"#00979D",skeleton:"basic",statements:[],template:"\uc591\ucabd \ubaa8\ud130\ub97c \uc815\uc9c0 %1",params:[{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null],type:"neobot_stop_all_motor"},"class":"neobot_motor",isNotFor:["neobot"],func:function(a,b){Entry.hw.sendQueue.DCL=0;Entry.hw.sendQueue.DCR=0;return b.callReturn()}},neobot_set_servo:{color:"#00979D",skeleton:"basic",statements:[], -template:"%1 \ud3ec\ud2b8\uc758 \uc11c\ubcf4\ubaa8\ud130\ub97c %2 \ub3c4 \uc774\ub3d9 %3",params:[{type:"Dropdown",options:[["OUT1","1"],["OUT2","2"],["OUT3","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,null,null],type:"neobot_set_servo"},paramsKeyMap:{PORT:0,DEGREE:1},"class":"neobot_output",isNotFor:["neobot"],func:function(a,b){a=b.getNumberField("PORT"); -var c=b.getNumberValue("DEGREE");0>c?c=0:180c?c=0:255Entry.Albert.tempo&&(Entry.Albert.tempo=1);return a.callReturn()}}, +albert_set_tempo_to:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[{type:"text",params:["60"]},null],type:"albert_set_tempo_to"},paramsKeyMap:{VALUE:0},"class":"albert_buzzer",isNotFor:["albert"],func:function(b,a){Entry.Albert.tempo=a.getNumberValue("VALUE");1>Entry.Albert.tempo&&(Entry.Albert.tempo=1);return a.callReturn()}},albert_move_forward:{color:"#00979D",skeleton:"basic", +statements:[],params:[{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null]},func:function(b,a){var c=Entry.hw.sendQueue;if(a.isStart){if(1==a.timeFlag)return a;delete a.timeFlag;delete a.isStart;Entry.engine.isContinue=!1;c.leftWheel=0;c.rightWheel=0;return a.callReturn()}a.isStart=!0;a.timeFlag=1;c.leftWheel=30;c.rightWheel=30;setTimeout(function(){a.timeFlag=0},1E3);return a}},albert_move_backward:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Indicator", +img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null]},func:function(b,a){var c=Entry.hw.sendQueue;if(a.isStart){if(1==a.timeFlag)return c.leftWheel=-30,c.rightWheel=-30,a;delete a.timeFlag;delete a.isStart;Entry.engine.isContinue=!1;c.leftWheel=0;c.rightWheel=0;return a.callReturn()}a.isStart=!0;a.timeFlag=1;setTimeout(function(){a.timeFlag=0},1E3);return a}},albert_turn_around:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[["\uc67c\ucabd","LEFT"], +["\uc624\ub978\ucabd","RIGHT"]],value:"LEFT",fontSize:11},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,null]},paramsKeyMap:{DIRECTION:0},func:function(b,a){var c=Entry.hw.sendQueue;if(a.isStart){if(1==a.timeFlag)return c.leftWheel=a.leftValue,c.rightWheel=a.rightValue,a;delete a.timeFlag;delete a.isStart;delete a.leftValue;delete a.rightValue;Entry.engine.isContinue=!1;c.leftWheel=0;c.rightWheel=0;return a.callReturn()}c="LEFT"==a.getField("DIRECTION",a); +a.leftValue=c?-30:30;a.rightValue=c?30:-30;a.isStart=!0;a.timeFlag=1;setTimeout(function(){a.timeFlag=0},1E3);return a}},albert_set_led_to:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[["\uc67c\ucabd","LEFT"],["\uc624\ub978\ucabd","RIGHT"],["\uc591\ucabd","FRONT"]],value:"LEFT",fontSize:11},{type:"Dropdown",options:[["\ube68\uac04\uc0c9","4"],["\ub178\ub780\uc0c9","6"],["\ucd08\ub85d\uc0c9","2"],["\ud558\ub298\uc0c9","3"],["\ud30c\ub780\uc0c9","1"],["\ubcf4\ub77c\uc0c9", +"5"],["\ud558\uc580\uc0c9","7"]],value:"4",fontSize:11},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,null,null]},paramsKeyMap:{DIRECTION:0,COLOR:1},func:function(b,a){var c=Entry.hw.sendQueue,d=a.getField("DIRECTION",a),e=+a.getField("COLOR",a);"FRONT"==d?(c.leftEye=e,c.rightEye=e):"LEFT"==d?c.leftEye=e:c.rightEye=e;return a.callReturn()}},albert_clear_led:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[["\uc67c\ucabd", +"LEFT"],["\uc624\ub978\ucabd","RIGHT"],["\uc591\ucabd","FRONT"]],value:"LEFT",fontSize:11},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,null]},paramsKeyMap:{DIRECTION:0},func:function(b,a){var c=Entry.hw.sendQueue,d=a.getField("DIRECTION",a);"FRONT"==d?(c.leftEye=0,c.rightEye=0):"LEFT"==d?c.leftEye=0:c.rightEye=0;return a.callReturn()}},albert_change_wheels_by:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[["\uc67c\ucabd", +"LEFT"],["\uc624\ub978\ucabd","RIGHT"],["\uc591\ucabd","FRONT"]],value:"LEFT",fontSize:11},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,null]},paramsKeyMap:{DIRECTION:0,VALUE:1},func:function(b,a){var c=Entry.hw.sendQueue,d=Entry.hw.portData,e=a.getField("DIRECTION"),f=a.getNumberValue("VALUE");"LEFT"==e?c.leftWheel=void 0!=c.leftWheel?c.leftWheel+f:d.leftWheel+f:("RIGHT"!=e&&(c.leftWheel=void 0!=c.leftWheel?c.leftWheel+f: +d.leftWheel+f),c.rightWheel=void 0!=c.rightWheel?c.rightWheel+f:d.rightWheel+f);return a.callReturn()}},albert_set_wheels_to:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[["\uc67c\ucabd","LEFT"],["\uc624\ub978\ucabd","RIGHT"],["\uc591\ucabd","FRONT"]],value:"LEFT",fontSize:11},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,null]},paramsKeyMap:{DIRECTION:0,VALUE:1},func:function(b,a){var c= +Entry.hw.sendQueue,d=a.getField("DIRECTION"),e=a.getNumberValue("VALUE");"LEFT"==d?c.leftWheel=e:("RIGHT"!=d&&(c.leftWheel=e),c.rightWheel=e);return a.callReturn()}},arduino_text:{color:"#00979D",skeleton:"basic_string_field",statements:[],params:[{type:"TextInput",value:10}],events:{},def:{params:[]},paramsKeyMap:{NAME:0},func:function(b,a){return a.getStringField("NAME")}},arduino_send:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"}],events:{},def:{params:[]}, +paramsKeyMap:{VALUE:0},func:function(b,a){var c=a.getValue("VALUE",a),d=new XMLHttpRequest;d.open("POST","http://localhost:23518/arduino/",!1);d.send(String(c));Entry.assert(200==d.status,"arduino is not connected");return a.callReturn()}},arduino_get_number:{color:"#00979D",skeleton:"basic_string_field",statements:[],params:[{type:"Block",accept:"string"}],events:{},def:{params:[]},paramsKeyMap:{VALUE:0},func:function(b,a){var c=a.getValue("VALUE",a),d=new XMLHttpRequest;d.open("POST","http://localhost:23518/arduino/", +!1);d.send(String(c));Entry.assert(200==d.status,"arduino is not connected");return+d.responseText}},arduino_get_string:{color:"#00979D",skeleton:"basic_string_field",statements:[],params:[{type:"Block",accept:"string"}],events:{},def:{params:[]},paramsKeyMap:{VALUE:0},func:function(b,a){var c=a.getValue("VALUE",a),d=new XMLHttpRequest;d.open("POST","http://localhost:23518/arduino/",!1);d.send(String(c));Entry.assert(200==d.status,"arduino is not connected");return d.responseText}},arduino_get_sensor_number:{color:"#00979D", +skeleton:"basic_string_field",statements:[],params:[{type:"Dropdown",options:[["0","A0"],["1","A1"],["2","A2"],["3","A3"],["4","A4"],["5","A5"]],value:"A0",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW}],events:{},def:{params:[null]},paramsKeyMap:{PORT:0},func:function(b,a){return a.getStringField("PORT")}},arduino_get_port_number:{color:"#00979D",skeleton:"basic_string_field",statements:[],params:[{type:"Dropdown",options:[["0","0"],["1","1"],["2","2"],["3","3"],["4","4"],["5","5"],["6","6"], +["7","7"],["8","8"],["9","9"],["10","10"],["11","11"],["12","12"],["13","13"]],value:"0",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW}],events:{},def:{params:[null]},paramsKeyMap:{PORT:0},func:function(b,a){return a.getStringField("PORT")}},arduino_get_pwm_port_number:{color:"#00979D",skeleton:"basic_string_field",statements:[],params:[{type:"Dropdown",options:[["3","3"],["5","5"],["6","6"],["9","9"],["10","10"],["11","11"]],value:"3",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW}],events:{}, +def:{params:[null]},paramsKeyMap:{PORT:0},func:function(b,a){return a.getStringField("PORT")}},arduino_get_number_sensor_value:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],params:[{type:"Block",accept:"string"}],events:{},def:{params:[{type:"arduino_get_sensor_number"}],type:"arduino_get_number_sensor_value"},paramsKeyMap:{VALUE:0},"class":"arduino_value",isNotFor:["arduino"],func:function(b,a){var c=a.getValue("VALUE",a);return Entry.hw.getAnalogPortValue(c[1])}}, +arduino_get_digital_value:{color:"#00979D",fontColor:"#fff",skeleton:"basic_boolean_field",statements:[],params:[{type:"Block",accept:"string"}],events:{},def:{params:[{type:"arduino_get_port_number"}],type:"arduino_get_digital_value"},paramsKeyMap:{VALUE:0},"class":"arduino_value",isNotFor:["arduino"],func:function(b,a){var c=a.getNumberValue("VALUE",a);return Entry.hw.getDigitalPortValue(c)}},arduino_toggle_led:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"}, +{type:"Dropdown",options:[[Lang.Blocks.ARDUINO_on,"on"],[Lang.Blocks.ARDUINO_off,"off"]],value:"on",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[{type:"arduino_get_port_number"},null,null],type:"arduino_toggle_led"},paramsKeyMap:{VALUE:0,OPERATOR:1},"class":"arduino_set",isNotFor:["arduino"],func:function(b,a){var c=a.getNumberValue("VALUE"),d="on"==a.getField("OPERATOR")?255:0;Entry.hw.setDigitalPortValue(c, +d);return a.callReturn()}},arduino_toggle_pwm:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[{type:"arduino_get_pwm_port_number"},{type:"arduino_text",params:["255"]},null],type:"arduino_toggle_pwm"},paramsKeyMap:{PORT:0,VALUE:1},"class":"arduino_set",isNotFor:["arduino"],func: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()}},arduino_convert_scale:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],params:[{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Block",accept:"string"}],events:{},def:{params:[{type:"arduino_get_number_sensor_value",params:[{type:"arduino_get_sensor_number",id:"bl5e"}]},{type:"number", +params:["0"]},{type:"number",params:["1023"]},{type:"number",params:["0"]},{type:"number",params:["100"]}],type:"arduino_convert_scale"},paramsKeyMap:{VALUE1:0,VALUE2:1,VALUE3:2,VALUE4:3,VALUE5:4},"class":"arduino",isNotFor:["arduino"],func:function(b,a){var c=a.getNumberValue("VALUE1",a),d=a.getNumberValue("VALUE2",a),e=a.getNumberValue("VALUE3",a),f=a.getNumberValue("VALUE4",a),g=a.getNumberValue("VALUE5",a);if(d>e)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", +a))}},sensorBoard_is_button_pressed:{color:"#00979D",fontColor:"#fff",skeleton:"basic_boolean_field",statements:[],params:[{type:"Dropdown",options:[["\ube68\uac04","8"],["\ud30c\ub780","9"],["\ub178\ub791","10"],["\ucd08\ub85d","11"]],value:"8",fontSize:11}],events:{},def:{params:[null],type:"sensorBoard_is_button_pressed"},paramsKeyMap:{PORT:0},"class":"sensorBoard",isNotFor:["sensorBoard"],func:function(b,a){return Entry.hw.getDigitalPortValue(a.getNumberField("PORT",a))}},sensorBoard_led:{color:"#00979D", +skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[["\ube68\uac04","2"],["\ucd08\ub85d","3"],["\ud30c\ub780","4"],["\ub178\ub791","5"]],value:"2",fontSize:11},{type:"Dropdown",options:[["\ucf1c\uae30","255"],["\ub044\uae30","0"]],value:"255",fontSize:11},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,null,null],type:"sensorBoard_led"},paramsKeyMap:{PORT:0,OPERATOR:1},"class":"sensorBoard",isNotFor:["sensorBoard"],func:function(b,a){Entry.hw.setDigitalPortValue(a.getField("PORT"), +a.getNumberField("OPERATOR"));return a.callReturn()}},arduino_download_connector:{skeleton:"basic_button",isNotFor:["arduinoDisconnected"],color:"#eee",params:[{type:"Text",text:Entry.isOffline?Lang.Blocks.ARDUINO_open_connector:Lang.Blocks.ARDUINO_download_connector,color:"#333",align:"center"}],events:{mousedown:[function(){Entry.hw.downloadConnector()}]}},arduino_download_source:{skeleton:"basic_button",isNotFor:["arduinoDisconnected"],color:"#eee",params:[{type:"Text",text:Lang.Blocks.ARDUINO_download_source, +color:"#333",align:"center"}],events:{mousedown:[function(){Entry.hw.downloadSource()}]}},arduino_connected:{skeleton:"basic_button",color:"#eee",isNotFor:["arduinoConnected"],params:[{type:"Text",text:Lang.Blocks.ARDUINO_connected,color:"#333",align:"center"}],events:{}},arduino_reconnect:{skeleton:"basic_button",color:"#eee",isNotFor:["arduinoDisconnected"],params:[{type:"Text",text:Lang.Blocks.ARDUINO_reconnect,color:"#333",align:"center"}],events:{mousedown:[function(){Entry.hw.retryConnect()}]}}, +CODEino_get_sensor_number:{color:"#00979D",skeleton:"basic_string_field",statements:[],params:[{type:"Dropdown",options:[["0","A0"],["1","A1"],["2","A2"],["3","A3"],["4","A4"],["5","A5"],["6","A6"]],value:"A0",fontSize:11}],events:{},def:{params:[null]},paramsKeyMap:{PORT:0},func:function(b,a){return a.getStringField("PORT")}},CODEino_get_named_sensor_value:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.CODEino_sensor_name_0, +"0"],[Lang.Blocks.CODEino_sensor_name_1,"1"],[Lang.Blocks.CODEino_sensor_name_2,"2"],[Lang.Blocks.CODEino_sensor_name_3,"3"],[Lang.Blocks.CODEino_sensor_name_4,"4"],[Lang.Blocks.CODEino_sensor_name_5,"5"],[Lang.Blocks.CODEino_sensor_name_6,"6"]],value:"0",fontSize:11}],events:{},def:{params:[null],type:"CODEino_get_named_sensor_value"},paramsKeyMap:{PORT:0},"class":"CODEino",isNotFor:["CODEino"],func:function(b,a){return Entry.hw.getAnalogPortValue(a.getField("PORT",a))}},CODEino_get_sound_status:{color:"#00979D", +fontColor:"#fff",skeleton:"basic_boolean_field",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.CODEino_string_11,"GREAT"],[Lang.Blocks.CODEino_string_12,"SMALL"]],value:"GREAT",fontSize:11}],events:{},def:{params:[null],type:"CODEino_get_sound_status"},paramsKeyMap:{STATUS:0},"class":"CODEino",isNotFor:["CODEino"],func:function(b,a){return"GREAT"==a.getField("STATUS",a)?600Entry.hw.getAnalogPortValue(0)?1:0}},CODEino_get_light_status:{color:"#00979D", +fontColor:"#fff",skeleton:"basic_boolean_field",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.CODEino_string_14,"BRIGHT"],[Lang.Blocks.CODEino_string_15,"DARK"]],value:"BRIGHT",fontSize:11}],events:{},def:{params:[null],type:"CODEino_get_light_status"},paramsKeyMap:{STATUS:0},"class":"CODEino",isNotFor:["CODEino"],func:function(b,a){return"DARK"==a.getField("STATUS",a)?800Entry.hw.getAnalogPortValue(1)?1:0}},CODEino_is_button_pressed:{color:"#00979D", +fontColor:"#fff",skeleton:"basic_boolean_field",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.CODEino_string_3,"4"],[Lang.Blocks.CODEino_string_4,"17"],[Lang.Blocks.CODEino_string_5,"18"],[Lang.Blocks.CODEino_string_6,"19"],[Lang.Blocks.CODEino_string_7,"20"]],value:"4",fontSize:11}],events:{},def:{params:[null],type:"CODEino_is_button_pressed"},paramsKeyMap:{PORT:0},"class":"CODEino",isNotFor:["CODEino"],func:function(b,a){var c=a.getNumberField("PORT",a);return 14d?1:0;if("RIGHT"==c||"FRONT"==c)return 30d?1:0}},CODEino_get_accelerometer_value:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[], +params:[{type:"Dropdown",options:[["X","3"],["Y","4"],["Z","5"]],value:"3",fontSize:11}],events:{},def:{params:[null],type:"CODEino_get_accelerometer_value"},paramsKeyMap:{PORT:0},"class":"CODEino",isNotFor:["CODEino"],func: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)}},nemoino_get_named_sensor_value:{color:"#00979D",fontColor:"#fff", +skeleton:"basic_string_field",statements:[],template:"%1 \uc13c\uc11c\uac12",params:[{type:"Dropdown",options:[["\uc18c\ub9ac","0"],["\ube5b","1"],["\uc2ac\ub77c\uc774\ub354","2"],["\uc800\ud56d-A","3"],["\uc800\ud56d-B","4"],["\uc800\ud56d-C","5"],["\uc800\ud56d-D","6"]],value:"0",fontSize:11}],events:{},def:{params:[null],type:"nemoino_get_named_sensor_value"},paramsKeyMap:{PORT:0},"class":"nemoino",isNotFor:["nemoino"],func:function(b,a){return Entry.hw.getAnalogPortValue(a.getField("PORT",a))}}, +nemoino_get_sound_status:{color:"#00979D",fontColor:"#fff",skeleton:"basic_boolean_field",statements:[],template:"\uc18c\ub9ac\uc13c\uc11c %1",params:[{type:"Dropdown",options:[["\uc18c\ub9ac\ud07c","GREAT"],["\uc18c\ub9ac\uc791\uc74c","SMALL"]],value:"GREAT",fontSize:11}],events:{},def:{params:[null],type:"nemoino_get_sound_status"},paramsKeyMap:{STATUS:0},"class":"nemoino",isNotFor:["nemoino"],func:function(b,a){return"GREAT"==a.getField("STATUS",a)?600Entry.hw.getAnalogPortValue(0)? +1:0}},nemoino_is_button_pressed:{color:"#00979D",fontColor:"#fff",skeleton:"basic_boolean_field",statements:[],template:"\ubcf4\ub4dc\uc758 %1",params:[{type:"Dropdown",options:[["\ubc84\ud2bc\ub204\ub984","4"],["A\uc5f0\uacb0\ub428","17"],["B\uc5f0\uacb0\ub428","18"],["C\uc5f0\uacb0\ub428","19"],["D\uc5f0\uacb0\ub428","20"]],value:"4",fontSize:11}],events:{},def:{params:[null],type:"nemoino_is_button_pressed"},paramsKeyMap:{PORT:0},"class":"nemoino",isNotFor:["nemoino"],func:function(b,a){var c= +a.getNumberField("PORT",a);return 14d?1:0;if("RIGHT"==c||"FRONT"==c)return 30d?1:0}},nemoino_get_accelerometer_value:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],template:"3\ucd95 \uac00\uc18d\ub3c4\uc13c\uc11c %1 \ucd95\uc758 \uc13c\uc11c\uac12",params:[{type:"Dropdown",options:[["X","3"],["Y","4"],["Z","5"]],value:"3",fontSize:11}],events:{},def:{params:[null],type:"nemoino_get_accelerometer_value"},paramsKeyMap:{PORT:0},"class":"nemoino",isNotFor:["nemoino"],func: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)}},bitbrick_sensor_value:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],params:[{type:"DropdownDynamic",value:null,fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW,menuName:Entry.Bitbrick.sensorList}],events:{},def:{params:[null],type:"bitbrick_sensor_value"},paramsKeyMap:{PORT:0},"class":"condition",isNotFor:["bitbrick"],func:function(b,a){var c= +a.getStringField("PORT");return Entry.hw.portData[c].value}},bitbrick_is_touch_pressed:{color:"#00979D",fontColor:"#fff",skeleton:"basic_boolean_field",statements:[],params:[{type:"DropdownDynamic",value:null,fontSize:11,menuName:Entry.Bitbrick.touchList}],events:{},def:{params:[null],type:"bitbrick_is_touch_pressed"},paramsKeyMap:{PORT:0},"class":"condition",isNotFor:["bitbrick"],func:function(b,a){return 0===Entry.hw.portData[a.getStringField("PORT")].value}},bitbrick_turn_off_color_led:{color:"#00979D", +skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null],type:"bitbrick_turn_off_color_led",id:"i3je"},"class":"condition",isNotFor:["bitbrick"],func:function(b,a){Entry.hw.sendQueue.LEDR=0;Entry.hw.sendQueue.LEDG=0;Entry.hw.sendQueue.LEDB=0;return a.callReturn()}},bitbrick_turn_on_color_led_by_rgb:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Block", +accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[{type:"text",params:["255"]},{type:"text",params:["255"]},{type:"text",params:["255"]},null],type:"bitbrick_turn_on_color_led_by_rgb"},paramsKeyMap:{rValue:0,gValue:1,bValue:2},"class":"condition",isNotFor:["bitbrick"],func:function(b,a){var c=a.getNumberValue("rValue"),d=a.getNumberValue("gValue"),e=a.getNumberValue("bValue"),f=Entry.adjustValueWithMaxMin,g=Entry.hw.sendQueue;g.LEDR=f(c,0,255);g.LEDG= +f(d,0,255);g.LEDB=f(e,0,255);return a.callReturn()}},bitbrick_turn_on_color_led_by_picker:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Color"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null],type:"bitbrick_turn_on_color_led_by_picker"},paramsKeyMap:{VALUE:0},"class":"condition",isNotFor:["bitbrick"],func:function(b,a){var c=a.getStringField("VALUE");Entry.hw.sendQueue.LEDR=parseInt(c.substr(1,2),16);Entry.hw.sendQueue.LEDG=parseInt(c.substr(3, +2),16);Entry.hw.sendQueue.LEDB=parseInt(c.substr(5,2),16);return a.callReturn()}},bitbrick_turn_on_color_led_by_value:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[{type:"text",params:["0"]},null],type:"bitbrick_turn_on_color_led_by_value"},paramsKeyMap:{VALUE:0},"class":"condition",isNotFor:["bitbrick"],func:function(b,a){var c=a.getNumberValue("VALUE"),d,e,f,c=c%200;67>c? +(d=200-3*c,e=3*c,f=0):134>c?(c-=67,d=0,e=200-3*c,f=3*c):201>c&&(c-=134,d=3*c,e=0,f=200-3*c);Entry.hw.sendQueue.LEDR=d;Entry.hw.sendQueue.LEDG=e;Entry.hw.sendQueue.LEDB=f;return a.callReturn()}},bitbrick_buzzer:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[{type:"text",params:["60"]},null],type:"bitbrick_buzzer"},paramsKeyMap:{VALUE:0},"class":"condition",isNotFor:["bitbrick"], +func:function(b,a){if(a.isStart)return Entry.hw.sendQueue.buzzer=0,delete a.isStart,a.callReturn();var c=a.getNumberValue("VALUE");Entry.hw.sendQueue.buzzer=c;a.isStart=!0;return a}},bitbrick_turn_off_all_motors:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null],type:"bitbrick_turn_off_all_motors"},"class":"condition",isNotFor:["bitbrick"],func:function(b,a){var c=Entry.hw.sendQueue,d=Entry.Bitbrick;d.servoList().map(function(a){c[a[1]]= +0});d.dcList().map(function(a){c[a[1]]=128});return a.callReturn()}},bitbrick_dc_speed:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"DropdownDynamic",value:null,fontSize:11,menuName:Entry.Bitbrick.dcList},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,{type:"text",params:["60"]},null],type:"bitbrick_dc_speed"},paramsKeyMap:{PORT:0,VALUE:1},"class":"condition",isNotFor:["bitbrick"],func:function(b,a){var c=a.getNumberValue("VALUE"), +c=Math.min(c,Entry.Bitbrick.dcMaxValue),c=Math.max(c,Entry.Bitbrick.dcMinValue);Entry.hw.sendQueue[a.getStringField("PORT")]=c+128;return a.callReturn()}},bitbrick_dc_direction_speed:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"DropdownDynamic",value:null,fontSize:11,menuName:Entry.Bitbrick.dcList},{type:"Dropdown",options:[[Lang.Blocks.BITBRICK_dc_direction_cw,"CW"],[Lang.Blocks.BITBRICK_dc_direction_ccw,"CCW"]],value:"CW",fontSize:11},{type:"Block",accept:"string"},{type:"Indicator", +img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,null,{type:"text",params:["100"]},null],type:"bitbrick_dc_direction_speed"},paramsKeyMap:{PORT:0,DIRECTION:1,VALUE:2},"class":"condition",isNotFor:["bitbrick"],func:function(b,a){var c="CW"===a.getStringField("DIRECTION"),d=a.getNumberValue("VALUE"),d=Math.min(d,Entry.Bitbrick.dcMaxValue),d=Math.max(d,0);Entry.hw.sendQueue[a.getStringField("PORT")]=c?d+128:128-d;return a.callReturn()}},bitbrick_servomotor_angle:{color:"#00979D", +skeleton:"basic",statements:[],params:[{type:"DropdownDynamic",value:null,fontSize:11,menuName:Entry.Bitbrick.servoList},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,{type:"text",params:["100"]},null],type:"bitbrick_servomotor_angle"},paramsKeyMap:{PORT:0,VALUE:1},"class":"condition",isNotFor:["bitbrick"],func:function(b,a){var c=Entry.Bitbrick.servoMaxValue-(a.getNumberValue("VALUE")+1),c=Math.min(c,Entry.Bitbrick.servoMaxValue), +c=Math.max(c,Entry.Bitbrick.servoMinValue);Entry.hw.sendQueue[a.getStringField("PORT")]=c;return a.callReturn()}},bitbrick_convert_scale:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],params:[{type:"DropdownDynamic",value:null,fontSize:11,menuName:Entry.Bitbrick.sensorList},{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Block",accept:"string"}],events:{},def:{params:[null,{type:"number",params:["0"]},{type:"number", +params:["1023"]},{type:"number",params:["-100"]},{type:"number",params:["100"]}],type:"bitbrick_convert_scale"},paramsKeyMap:{PORT:0,VALUE2:1,VALUE3:2,VALUE4:3,VALUE5:4},"class":"condition",isNotFor:["bitbrick"],func:function(b,a){var c=a.getNumberField("PORT"),d=Entry.hw.portData[c].value,c=a.getNumberValue("VALUE2",a),e=a.getNumberValue("VALUE3",a),f=a.getNumberValue("VALUE4",a),g=a.getNumberValue("VALUE5",a);if(f>g)var h=f,f=g,g=h;d-=c;d*=(g-f)/(e-c);d+=f;d=Math.min(g,d);d=Math.max(f,d);return Math.round(d)}}, +start_drawing:{color:"#FF9E20",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/brush_03.png",size:12}],events:{},def:{params:[null],type:"start_drawing"},"class":"brush_control",isNotFor:["textBox"],func:function(b,a){b.brush?b.brush.stop=!1:Entry.setBasicBrush(b);Entry.stage.sortZorder();b.brush.moveTo(b.getX(),-1*b.getY());return a.callReturn()}},stop_drawing:{color:"#FF9E20",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/brush_03.png",size:12}], +events:{},def:{params:[null],type:"stop_drawing"},"class":"brush_control",isNotFor:["textBox"],func:function(b,a){b.brush&&b.shape&&(b.brush.stop=!0);return a.callReturn()}},set_color:{color:"#FF9E20",skeleton:"basic",statements:[],params:[{type:"Color"},{type:"Indicator",img:"block_icon/brush_03.png",size:12}],events:{},def:{params:[null],type:"set_color"},paramsKeyMap:{VALUE:0},"class":"brush_color",isNotFor:["textBox"],func:function(b,a){var c=a.getField("VALUE",a);b.brush||(Entry.setBasicBrush(b), +b.brush.stop=!0);b.brush&&(c=Entry.hex2rgb(c),b.brush.rgb=c,b.brush.endStroke(),b.brush.beginStroke("rgba("+c.r+","+c.g+","+c.b+","+b.brush.opacity/100+")"),b.brush.moveTo(b.getX(),-1*b.getY()));return a.callReturn()}},set_random_color:{color:"#FF9E20",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/brush_03.png",size:12}],events:{},def:{params:[null],type:"set_random_color"},"class":"brush_color",isNotFor:["textBox"],func:function(b,a){b.brush||(Entry.setBasicBrush(b),b.brush.stop= +!0);if(b.brush){var c=Entry.generateRgb();b.brush.rgb=c;b.brush.endStroke();b.brush.beginStroke("rgba("+c.r+","+c.g+","+c.b+","+b.brush.opacity/100+")");b.brush.moveTo(b.getX(),-1*b.getY())}return a.callReturn()}},change_thickness:{color:"#FF9E20",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/brush_03.png",size:12}],events:{},def:{params:[{type:"number",params:["1"]},null],type:"change_thickness"},paramsKeyMap:{VALUE:0},"class":"brush_thickness", +isNotFor:["textBox"],func:function(b,a){var c=a.getNumberValue("VALUE",a);b.brush||(Entry.setBasicBrush(b),b.brush.stop=!0);b.brush&&(b.brush.thickness+=c,1>b.brush.thickness&&(b.brush.thickness=1),b.brush.setStrokeStyle(b.brush.thickness),b.brush.moveTo(b.getX(),-1*b.getY()));return a.callReturn()}},set_thickness:{color:"#FF9E20",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/brush_03.png",size:12}],events:{},def:{params:[{type:"number",params:["1"]}, +null],type:"set_thickness"},paramsKeyMap:{VALUE:0},"class":"brush_thickness",isNotFor:["textBox"],func:function(b,a){var c=a.getNumberValue("VALUE",a);b.brush||(Entry.setBasicBrush(b),b.brush.stop=!0);b.brush&&(b.brush.thickness=c,b.brush.setStrokeStyle(b.brush.thickness),b.brush.moveTo(b.getX(),-1*b.getY()));return a.callReturn()}},change_opacity:{color:"#FF9E20",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/brush_03.png",size:12}],events:{}, +def:{params:[{type:"number",params:["10"]},null],type:"change_opacity"},paramsKeyMap:{VALUE:0},"class":"brush_opacity",isNotFor:["textBox"],func:function(b,a){var c=a.getNumberValue("VALUE",a);b.brush||(Entry.setBasicBrush(b),b.brush.stop=!0);c=Entry.adjustValueWithMaxMin(b.brush.opacity+c,0,100);b.brush&&(b.brush.opacity=c,b.brush.endStroke(),c=b.brush.rgb,b.brush.beginStroke("rgba("+c.r+","+c.g+","+c.b+","+b.brush.opacity/100+")"),b.brush.moveTo(b.getX(),-1*b.getY()));return a.callReturn()}},set_opacity:{color:"#FF9E20", +skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/brush_03.png",size:12}],events:{},def:{params:[{type:"number",params:["50"]},null],type:"set_opacity"},paramsKeyMap:{VALUE:0},"class":"brush_opacity",isNotFor:["textBox"],func:function(b,a){var c=a.getNumberValue("VALUE",a);b.brush||(Entry.setBasicBrush(b),b.brush.stop=!0);b.brush&&(b.brush.opacity=Entry.adjustValueWithMaxMin(c,0,100),b.brush.endStroke(),c=b.brush.rgb,b.brush.beginStroke("rgba("+ +c.r+","+c.g+","+c.b+","+b.brush.opacity/100+")"),b.brush.moveTo(b.getX(),-1*b.getY()));return a.callReturn()}},brush_erase_all:{color:"#FF9E20",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/brush_03.png",size:12}],events:{},def:{params:[null],type:"brush_erase_all"},"class":"brush_clear",isNotFor:["textBox"],func:function(b,a){var c=b.brush;if(c){var d=c._stroke.style,e=c._strokeStyle.width;c.clear().setStrokeStyle(e).beginStroke(d);c.moveTo(b.getX(),-1*b.getY())}c=b.parent.getStampEntities(); +c.map(function(a){a.removeClone()});c=null;return a.callReturn()}},brush_stamp:{color:"#FF9E20",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/brush_03.png",size:12}],events:{},def:{params:[null],type:"brush_stamp"},"class":"stamp",isNotFor:["textBox"],func:function(b,a){b.parent.addStampEntity(b);return a.callReturn()}},change_brush_transparency:{color:"#FF9E20",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/brush_03.png", +size:12}],events:{},def:{params:[{type:"number",params:["10"]},null],type:"change_brush_transparency"},paramsKeyMap:{VALUE:0},"class":"brush_opacity",isNotFor:["textBox"],func:function(b,a){var c=a.getNumberValue("VALUE",a);b.brush||(Entry.setBasicBrush(b),b.brush.stop=!0);c=Entry.adjustValueWithMaxMin(b.brush.opacity-c,0,100);b.brush&&(b.brush.opacity=c,b.brush.endStroke(),c=b.brush.rgb,b.brush.beginStroke("rgba("+c.r+","+c.g+","+c.b+","+b.brush.opacity/100+")"),b.brush.moveTo(b.getX(),-1*b.getY())); +return a.callReturn()}},set_brush_tranparency:{color:"#FF9E20",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/brush_03.png",size:12}],events:{},def:{params:[{type:"number",params:["50"]},null],type:"set_brush_tranparency"},paramsKeyMap:{VALUE:0},"class":"brush_opacity",isNotFor:["textBox"],func:function(b,a){var c=a.getNumberValue("VALUE",a);b.brush||(Entry.setBasicBrush(b),b.brush.stop=!0);b.brush&&(b.brush.opacity=Entry.adjustValueWithMaxMin(c, +0,100),b.brush.endStroke(),c=b.brush.rgb,b.brush.beginStroke("rgba("+c.r+","+c.g+","+c.b+","+(1-b.brush.opacity/100)+")"),b.brush.moveTo(b.getX(),-1*b.getY()));return a.callReturn()}},number:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"TextInput",value:10}],events:{},def:{params:[]},paramsKeyMap:{NUM:0},func:function(b,a){return a.getField("NUM",a)},isPrimitive:!0},angle:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Angle"}],events:{},def:{params:[null], +type:"angle"},paramsKeyMap:{ANGLE:0},func:function(b,a){return a.getNumberField("ANGLE")}},get_x_coordinate:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Text",text:Lang.Blocks.CALC_get_x_coordinate,color:"#3D3D3D"}],events:{},def:{params:[null],type:"get_x_coordinate"},"class":"calc",isNotFor:[],func:function(b,a){return b.getX()}},get_y_coordinate:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Text",text:Lang.Blocks.CALC_get_y_coordinate, +color:"#3D3D3D"}],events:{},def:{params:[null],type:"get_y_coordinate"},"class":"calc",isNotFor:[],func:function(b,a){return b.getY()}},get_angle:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Text",text:Lang.Blocks.CALC_get_angle,color:"#3D3D3D"}],events:{},def:{params:[null]},func:function(b,a){return parseFloat(b.getRotation().toFixed(1))}},get_rotation_direction:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.CALC_rotation_value, +"ROTATION"],[Lang.Blocks.CALC_direction_value,"DIRECTION"]],value:"ROTATION",fontSize:11}],events:{},def:{params:[null],type:"get_rotation_direction"},paramsKeyMap:{OPERATOR:0},"class":"calc",isNotFor:[],func:function(b,a){return"DIRECTION"==a.getField("OPERATOR",a).toUpperCase()?parseFloat(b.getDirection().toFixed(1)):parseFloat(b.getRotation().toFixed(1))}},distance_something:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Text",text:Lang.Blocks.CALC_distance_something_1, +color:"#3D3D3D"},{type:"DropdownDynamic",value:null,menuName:"spritesWithMouse",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_CALC},{type:"Text",text:Lang.Blocks.CALC_distance_something_2,color:"#3D3D3D"}],events:{},def:{params:[null,null,null],type:"distance_something"},paramsKeyMap:{VALUE:1},"class":"calc_distance",isNotFor:[],func:function(b,a){var c=a.getField("VALUE",a);if("mouse"==c)return c=Entry.stage.mouseCoordinate,Math.sqrt(Math.pow(b.getX()-c.x,2)+Math.pow(b.getY()-c.y,2));c=Entry.container.getEntity(c); +return Math.sqrt(Math.pow(b.getX()-c.getX(),2)+Math.pow(b.getY()-c.getY(),2))}},coordinate_mouse:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Text",text:Lang.Blocks.CALC_coordinate_mouse_1,color:"#3D3D3D"},{type:"Dropdown",options:[["x","x"],["y","y"]],value:"x",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_CALC},{type:"Text",text:Lang.Blocks.CALC_coordinate_mouse_2,color:"#3D3D3D"}],events:{},def:{params:[null,null,null],type:"coordinate_mouse"},paramsKeyMap:{VALUE:1}, +"class":"calc",isNotFor:[],func:function(b,a){return"x"===a.getField("VALUE",a)?+Entry.stage.mouseCoordinate.x:+Entry.stage.mouseCoordinate.y}},coordinate_object:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Text",text:Lang.Blocks.CALC_coordinate_object_1,color:"#3D3D3D"},{type:"DropdownDynamic",value:null,menuName:"spritesWithSelf",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_CALC},{type:"Text",text:Lang.Blocks.CALC_coordinate_object_2,color:"#3D3D3D"},{type:"Dropdown", +options:[[Lang.Blocks.CALC_coordinate_x_value,"x"],[Lang.Blocks.CALC_coordinate_y_value,"y"],[Lang.Blocks.CALC_coordinate_rotation_value,"rotation"],[Lang.Blocks.CALC_coordinate_direction_value,"direction"],[Lang.Blocks.CALC_coordinate_size_value,"size"],[Lang.Blocks.CALC_picture_index,"picture_index"],[Lang.Blocks.CALC_picture_name,"picture_name"]],value:"x",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_CALC}],events:{},def:{params:[null,null,null,null],type:"coordinate_object"},paramsKeyMap:{VALUE:1, +COORDINATE:3},"class":"calc",isNotFor:[],func:function(b,a){var c=a.getField("VALUE",a),c="self"==c?b:Entry.container.getEntity(c);switch(a.getField("COORDINATE",a)){case "x":return c.getX();case "y":return c.getY();case "rotation":return c.getRotation();case "direction":return c.getDirection();case "picture_index":var d=c.parent,d=d.pictures;return d.indexOf(c.picture)+1;case "size":return+c.getSize().toFixed(1);case "picture_name":return d=c.parent,d=d.pictures,d[d.indexOf(c.picture)].name}}},calc_basic:{color:"#FFD974", +skeleton:"basic_string_field",statements:[],params:[{type:"Block",accept:"string"},{type:"Dropdown",options:[["+","PLUS"],["-","MINUS"],["x","MULTI"],["/","DIVIDE"]],value:"PLUS",fontSize:11,noArrow:!0},{type:"Block",accept:"string"}],events:{},def:{params:[{type:"number",params:["10"]},"PLUS",{type:"number",params:["10"]}],type:"calc_basic"},defs:[{params:[{type:"number",params:["10"]},"PLUS",{type:"number",params:["10"]}],type:"calc_basic"},{params:[{type:"number",params:["10"]},"MINUS",{type:"number", +params:["10"]}],type:"calc_basic"},{params:[{type:"number",params:["10"]},"MULTI",{type:"number",params:["10"]}],type:"calc_basic"},{params:[{type:"number",params:["10"]},"DIVIDE",{type:"number",params:["10"]}],type:"calc_basic"}],paramsKeyMap:{LEFTHAND:0,OPERATOR:1,RIGHTHAND:2},"class":"calc",isNotFor:[],func:function(b,a){var c=a.getField("OPERATOR",a),d=a.getNumberValue("LEFTHAND",a),e=a.getNumberValue("RIGHTHAND",a);return"PLUS"==c?d+e:"MINUS"==c?d-e:"MULTI"==c?d*e:d/e}},calc_plus:{color:"#FFD974", +skeleton:"basic_string_field",statements:[],params:[{type:"Block",accept:"string"},{type:"Text",text:"+",color:"#3D3D3D"},{type:"Block",accept:"string"}],events:{},def:{params:[null]},paramsKeyMap:{LEFTHAND:0,RIGHTHAND:2},func:function(b,a){var c=a.getNumberValue("LEFTHAND",a),d=a.getNumberValue("RIGHTHAND",a);return c+d}},calc_minus:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Block",accept:"string"},{type:"Text",text:"-",color:"#3D3D3D"},{type:"Block",accept:"string"}], +events:{},def:{params:[null]},paramsKeyMap:{LEFTHAND:0,RIGHTHAND:2},func:function(b,a){var c=a.getNumberValue("LEFTHAND",a),d=a.getNumberValue("RIGHTHAND",a);return c-d}},calc_times:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Block",accept:"string"},{type:"Text",text:"x",color:"#3D3D3D"},{type:"Block",accept:"string"}],events:{},def:{params:[null]},paramsKeyMap:{LEFTHAND:0,RIGHTHAND:2},func:function(b,a){var c=a.getNumberValue("LEFTHAND",a),d=a.getNumberValue("RIGHTHAND", +a);return c*d}},calc_divide:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Block",accept:"string"},{type:"Text",text:"/",color:"#3D3D3D"},{type:"Block",accept:"string"}],events:{},def:{params:[null]},paramsKeyMap:{LEFTHAND:0,RIGHTHAND:2},func:function(b,a){var c=a.getNumberValue("LEFTHAND",a),d=a.getNumberValue("RIGHTHAND",a);return c/d}},calc_mod:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Block",accept:"string"},{type:"Text",text:"/", +color:"#3D3D3D"},{type:"Block",accept:"string"},{type:"Text",text:Lang.Blocks.CALC_calc_mod_3,color:"#3D3D3D"}],events:{},def:{params:[{type:"number",params:["10"]},null,{type:"number",params:["10"]},null],type:"calc_mod"},paramsKeyMap:{LEFTHAND:0,RIGHTHAND:2},"class":"calc",isNotFor:[],func:function(b,a){var c=a.getNumberValue("LEFTHAND",a),d=a.getNumberValue("RIGHTHAND",a);return c%d}},calc_share:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Block",accept:"string"}, +{type:"Text",text:"/",color:"#3D3D3D"},{type:"Block",accept:"string"},{type:"Text",text:"\uc758 \ubaab",color:"#3D3D3D"}],events:{},def:{params:[{type:"number",params:["10"]},null,{type:"number",params:["10"]},null],type:"calc_share"},paramsKeyMap:{LEFTHAND:0,RIGHTHAND:2},"class":"calc",isNotFor:[],func:function(b,a){var c=a.getNumberValue("LEFTHAND",a),d=a.getNumberValue("RIGHTHAND",a);return Math.floor(c/d)}},calc_operation:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Text", +text:Lang.Blocks.CALC_calc_operation_of_1,color:"#3D3D3D"},{type:"Block",accept:"string"},{type:"Text",text:Lang.Blocks.CALC_calc_operation_of_2,color:"#3D3D3D"},{type:"Dropdown",options:[[Lang.Blocks.CALC_calc_operation_square,"square"],[Lang.Blocks.CALC_calc_operation_root,"root"],[Lang.Blocks.CALC_calc_operation_sin,"sin"],[Lang.Blocks.CALC_calc_operation_cos,"cos"],[Lang.Blocks.CALC_calc_operation_tan,"tan"],[Lang.Blocks.CALC_calc_operation_asin,"asin_radian"],[Lang.Blocks.CALC_calc_operation_acos, +"acos_radian"],[Lang.Blocks.CALC_calc_operation_atan,"atan_radian"],[Lang.Blocks.CALC_calc_operation_log,"log"],[Lang.Blocks.CALC_calc_operation_ln,"ln"],[Lang.Blocks.CALC_calc_operation_unnatural,"unnatural"],[Lang.Blocks.CALC_calc_operation_floor,"floor"],[Lang.Blocks.CALC_calc_operation_ceil,"ceil"],[Lang.Blocks.CALC_calc_operation_round,"round"],[Lang.Blocks.CALC_calc_operation_factorial,"factorial"],[Lang.Blocks.CALC_calc_operation_abs,"abs"]],value:"square",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_CALC}], +events:{},def:{params:[null,{type:"number",params:["10"]},null,null],type:"calc_operation"},paramsKeyMap:{LEFTHAND:1,VALUE:3},"class":"calc",isNotFor:[],func:function(b,a){var c=a.getNumberValue("LEFTHAND",a),d=a.getField("VALUE",a);if(-1<["asin_radian","acos_radian"].indexOf(d)&&(1c))throw Error("x range exceeded");d.indexOf("_")&&(d=d.split("_")[0]);-1<["sin","cos","tan"].indexOf(d)&&(c=Entry.toRadian(c));var e=0;switch(d){case "square":e=c*c;break;case "factorial":e=Entry.factorial(c);break; +case "root":e=Math.sqrt(c);break;case "log":e=Math.log(c)/Math.LN10;break;case "ln":e=Math.log(c);break;case "asin":case "acos":case "atan":e=Entry.toDegrees(Math[d](c));break;case "unnatural":e=c-Math.floor(c);0>c&&(e=1-e);break;default:e=Math[d](c)}return Math.round(1E3*e)/1E3}},calc_rand:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Text",text:Lang.Blocks.CALC_calc_rand_1,color:"#3D3D3D"},{type:"Block",accept:"string"},{type:"Text",text:Lang.Blocks.CALC_calc_rand_2, +color:"#3D3D3D"},{type:"Block",accept:"string"},{type:"Text",text:Lang.Blocks.CALC_calc_rand_3,color:"#3D3D3D"}],events:{},def:{params:[null,{type:"number",params:["0"]},null,{type:"number",params:["10"]},null],type:"calc_rand"},paramsKeyMap:{LEFTHAND:1,RIGHTHAND:3},"class":"calc",isNotFor:[],func:function(b,a){var c=a.getStringValue("LEFTHAND",a),d=a.getStringValue("RIGHTHAND",a),e=Math.min(c,d),f=Math.max(c,d),c=Entry.isFloat(c);return Entry.isFloat(d)||c?(Math.random()*(f-e)+e).toFixed(2):Math.floor(Math.random()* +(f-e+1)+e)}},get_date:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Text",text:Lang.Blocks.CALC_get_date_1,color:"#3D3D3D"},{type:"Dropdown",options:[[Lang.Blocks.CALC_get_date_year,"YEAR"],[Lang.Blocks.CALC_get_date_month,"MONTH"],[Lang.Blocks.CALC_get_date_day,"DAY"],[Lang.Blocks.CALC_get_date_hour,"HOUR"],[Lang.Blocks.CALC_get_date_minute,"MINUTE"],[Lang.Blocks.CALC_get_date_second,"SECOND"]],value:"YEAR",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_CALC},{type:"Text", +text:Lang.Blocks.CALC_get_date_2,color:"#3D3D3D"}],events:{},def:{params:[null,"YEAR",null],type:"get_date"},paramsKeyMap:{VALUE:1},"class":"calc_date",isNotFor:[],func:function(b,a){var c=a.getField("VALUE",a),d=new Date;return"YEAR"==c?d.getFullYear():"MONTH"==c?d.getMonth()+1:"DAY"==c?d.getDate():"HOUR"==c?d.getHours():"MINUTE"==c?d.getMinutes():d.getSeconds()}},get_sound_duration:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Text",text:Lang.Blocks.CALC_get_sound_duration_1, +color:"#3D3D3D"},{type:"DropdownDynamic",value:null,menuName:"sounds",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_CALC},{type:"Text",text:Lang.Blocks.CALC_get_sound_duration_2,color:"#3D3D3D"}],events:{},def:{params:[null,null,null],type:"get_sound_duration"},paramsKeyMap:{VALUE:1},"class":"calc_duration",isNotFor:[],func:function(b,a){for(var c=a.getField("VALUE",a),d=b.parent.sounds,e=0;ed||d>c.length-1)throw Error();return c[d]}},length_of_string:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Text",text:Lang.Blocks.CALC_length_of_string_1,color:"#3D3D3D"},{type:"Block",accept:"string"},{type:"Text",text:Lang.Blocks.CALC_length_of_string_2,color:"#3D3D3D"}],events:{},def:{params:[null, +{type:"text",params:[Lang.Blocks.entry]},null],type:"length_of_string"},paramsKeyMap:{STRING:1},"class":"calc_string",isNotFor:[],func:function(b,a){return a.getStringValue("STRING",a).length}},substring:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Text",text:Lang.Blocks.CALC_substring_1,color:"#3D3D3D"},{type:"Block",accept:"string"},{type:"Text",text:Lang.Blocks.CALC_substring_2,color:"#3D3D3D"},{type:"Block",accept:"string"},{type:"Text",text:Lang.Blocks.CALC_substring_3, +color:"#3D3D3D"},{type:"Block",accept:"string"},{type:"Text",text:Lang.Blocks.CALC_substring_4,color:"#3D3D3D"}],events:{},def:{params:[null,{type:"text",params:[Lang.Blocks.hi_entry]},null,{type:"number",params:["2"]},null,{type:"number",params:["5"]},null],type:"substring"},paramsKeyMap:{STRING:1,START:3,END:5},"class":"calc_string",isNotFor:[],func:function(b,a){var c=a.getStringValue("STRING",a),d=a.getNumberValue("START",a)-1,e=a.getNumberValue("END",a)-1,f=c.length-1;if(0>d||0>e||d>f||e>f)throw Error(); +return c.substring(Math.min(d,e),Math.max(d,e)+1)}},replace_string:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Text",text:Lang.Blocks.CALC_replace_string_1,color:"#3D3D3D"},{type:"Block",accept:"string"},{type:"Text",text:Lang.Blocks.CALC_replace_string_2,color:"#3D3D3D"},{type:"Block",accept:"string"},{type:"Text",text:Lang.Blocks.CALC_replace_string_3,color:"#3D3D3D"},{type:"Block",accept:"string"},{type:"Text",text:Lang.Blocks.CALC_replace_string_4,color:"#3D3D3D"}], +events:{},def:{params:[null,{type:"text",params:[Lang.Blocks.hi_entry]},null,{type:"text",params:[Lang.Blocks.hello]},null,{type:"text",params:[Lang.Blocks.nice]},null],type:"replace_string"},paramsKeyMap:{STRING:1,OLD_WORD:3,NEW_WORD:5},"class":"calc_string",isNotFor:[],func:function(b,a){return a.getStringValue("STRING",a).replace(new RegExp(a.getStringValue("OLD_WORD",a),"gm"),a.getStringValue("NEW_WORD",a))}},change_string_case:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Text", +text:Lang.Blocks.CALC_change_string_case_1,color:"#3D3D3D"},{type:"Block",accept:"string"},{type:"Text",text:Lang.Blocks.CALC_change_string_case_2,color:"#3D3D3D"},{type:"Dropdown",options:[[Lang.Blocks.CALC_change_string_case_sub_1,"toUpperCase"],[Lang.Blocks.CALC_change_string_case_sub_2,"toLowerCase"]],value:"toUpperCase",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_CALC},{type:"Text",text:Lang.Blocks.CALC_change_string_case_3,color:"#3D3D3D"}],events:{},def:{params:[null,{type:"text",params:["Hello Entry!"]}, +null,null,null],type:"change_string_case"},paramsKeyMap:{STRING:1,CASE:3},"class":"calc_string",isNotFor:[],func:function(b,a){return a.getStringValue("STRING",a)[a.getField("CASE",a)]()}},index_of_string:{color:"#FFD974",skeleton:"basic_string_field",statements:[],params:[{type:"Text",text:Lang.Blocks.CALC_index_of_string_1,color:"#3D3D3D"},{type:"Block",accept:"string"},{type:"Text",text:Lang.Blocks.CALC_index_of_string_2,color:"#3D3D3D"},{type:"Block",accept:"string"},{type:"Text",text:Lang.Blocks.CALC_index_of_string_3, +color:"#3D3D3D"}],events:{},def:{params:[null,{type:"text",params:[Lang.Blocks.hi_entry]},null,{type:"text",params:[Lang.Blocks.entry]},null],type:"index_of_string"},paramsKeyMap:{LEFTHAND:1,RIGHTHAND:3},"class":"calc_string",isNotFor:[],func:function(b,a){var c=a.getStringValue("LEFTHAND",a),d=a.getStringValue("RIGHTHAND",a),c=c.indexOf(d);return-1c)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, +a.callReturn()):a.getBooleanValue("BOOL",a)?(a.isCondition=!0,a.getStatement("STACK",a)):a.callReturn()}},if_else:{color:"#498deb",skeleton:"basic_double_loop",statements:[{accept:"basic"},{accept:"basic"}],params:[{type:"Block",accept:"boolean"},{type:"Indicator",img:"block_icon/flow_03.png",size:12},{type:"LineBreak"}],events:{},def:{params:[{type:"True"},null],type:"if_else"},paramsKeyMap:{BOOL:0},statementsKeyMap:{STACK_IF:0,STACK_ELSE:1},"class":"condition",isNotFor:[],func:function(b,a){if(a.isCondition)return delete a.isCondition, +a.callReturn();var c=a.getBooleanValue("BOOL",a);a.isCondition=!0;return c?a.getStatement("STACK_IF",a):a.getStatement("STACK_ELSE",a)}},create_clone:{color:"#498deb",skeleton:"basic",statements:[],params:[{type:"DropdownDynamic",value:null,menuName:"clone",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_FLOW},{type:"Indicator",img:"block_icon/flow_03.png",size:12}],events:{},def:{params:[null,null],type:"create_clone"},paramsKeyMap:{VALUE:0},"class":"clone",isNotFor:[],func:function(b,a){var c=a.getField("VALUE", +a),d=a.callReturn();"self"==c?b.parent.addCloneEntity(b.parent,b,null):Entry.container.getObject(c).addCloneEntity(b.parent,null,null);return d}},delete_clone:{color:"#498deb",skeleton:"basic_without_next",statements:[],params:[{type:"Indicator",img:"block_icon/flow_03.png",size:12}],events:{},def:{params:[null],type:"delete_clone"},"class":"clone",isNotFor:[],func:function(b,a){if(!b.isClone)return a.callReturn();b.removeClone();return this.die()}},when_clone_start:{color:"#498deb",skeleton:"basic_event", +statements:[],params:[{type:"Indicator",img:"block_icon/start_icon_clone.png",size:17,position:{x:0,y:-2}}],events:{},def:{params:[null],type:"when_clone_start"},"class":"clone",isNotFor:[],func:function(b,a){return a.callReturn()},event:"when_clone_start"},stop_run:{color:"#498deb",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/flow_03.png",size:12}],events:{},def:{params:[null]},func:function(b,a){return Entry.engine.toggleStop()}},repeat_while_true:{color:"#498deb",skeleton:"basic_loop", +statements:[{accept:"basic"}],params:[{type:"Block",accept:"boolean"},{type:"Dropdown",options:[[Lang.Blocks.FLOW_repeat_while_true_until,"until"],[Lang.Blocks.FLOW_repeat_while_true_while,"while"]],value:"until",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_FLOW},{type:"Indicator",img:"block_icon/flow_03.png",size:12}],events:{},def:{params:[{type:"True"},null,null],type:"repeat_while_true"},paramsKeyMap:{BOOL:0,OPTION:1},statementsKeyMap:{DO:0},"class":"repeat",isNotFor:[],func:function(b,a){var c= +a.getBooleanValue("BOOL",a);"until"==a.getField("OPTION",a)&&(c=!c);return(a.isLooped=c)?a.getStatement("DO",a):a.callReturn()}},stop_object:{color:"#498deb",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.FLOW_stop_object_all,"all"],[Lang.Blocks.FLOW_stop_object_this_object,"thisOnly"],[Lang.Blocks.FLOW_stop_object_this_thread,"thisThread"],[Lang.Blocks.FLOW_stop_object_other_thread,"otherThread"]],value:"all",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_FLOW},{type:"Indicator", +img:"block_icon/flow_03.png",size:12}],events:{},def:{params:[null,null],type:"stop_object"},paramsKeyMap:{TARGET:0},"class":"terminate",isNotFor:[],func:function(b,a){var c=a.getField("TARGET",a),d=Entry.container;switch(c){case "all":return d.clearRunningState(),this.die();case "thisOnly":return b.parent.script.clearExecutorsByEntity(b),this.die();case "thisObject":return b.parent.script.clearExecutors(),this.die();case "thisThread":return this.die();case "otherThread":for(var c=this.executor,d= +b.parent.script,e=d.executors,f=0;f +a.count?(50>d.leftFloor&&50>d.rightFloor?a.count++:a.count=0,d=d.leftFloor-d.rightFloor,c.leftWheel=45+.25*d,c.rightWheel=45-.25*d):(a.count=0,a.boardState=2);break;case 2:d=d.leftFloor-d.rightFloor;c.leftWheel=45+.25*d;c.rightWheel=45-.25*d;a.boardState=3;var e=setTimeout(function(){a.boardState=4;Entry.Hamster.removeTimeout(e)},250);Entry.Hamster.timeouts.push(e);break;case 3:d=d.leftFloor-d.rightFloor;c.leftWheel=45+.25*d;c.rightWheel=45-.25*d;break;case 4:c.leftWheel=0,c.rightWheel=0,a.boardState= +0,a.isMoving=!1}return a}delete a.isStart;delete a.isMoving;delete a.count;delete a.boardState;Entry.engine.isContinue=!1;c.leftWheel=0;c.rightWheel=0;return a.callReturn()}a.isStart=!0;a.isMoving=!0;a.count=0;a.boardState=1;c.leftWheel=45;c.rightWheel=45;Entry.Hamster.setLineTracerMode(c,0);return a}},hamster_turn_once:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.General.left,"LEFT"],[Lang.General.right,"RIGHT"]],value:"LEFT",fontSize:11},{type:"Indicator", +img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,null],type:"hamster_turn_once"},paramsKeyMap:{DIRECTION:0},"class":"hamster_board",isNotFor:["hamster"],func:function(b,a){var c=Entry.hw.sendQueue,d=Entry.hw.portData;if(a.isStart){if(a.isMoving){if(a.isLeft)switch(a.boardState){case 1:2>a.count?50d.leftFloor&&(a.boardState=3);break;case 3:2>a.count?20>d.leftFloor&&a.count++:(a.count=0,a.boardState=4);break;case 4:50< +d.leftFloor&&(a.boardState=5);break;case 5:d=d.leftFloor-d.rightFloor,-15a.count?50d.rightFloor&&(a.boardState=3);break;case 3:2>a.count?20>d.rightFloor&&a.count++:(a.count=0,a.boardState=4);break;case 4:50Entry.Hamster.tempo&&(Entry.Hamster.tempo=1);return a.callReturn()}},hamster_set_tempo_to:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[{type:"text",params:["60"]},null],type:"hamster_set_tempo_to"},paramsKeyMap:{VALUE:0},"class":"hamster_buzzer",isNotFor:["hamster"],func:function(b,a){Entry.Hamster.tempo= +a.getNumberValue("VALUE");1>Entry.Hamster.tempo&&(Entry.Hamster.tempo=1);return a.callReturn()}},hamster_set_port_to:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.HAMSTER_port_a,"A"],[Lang.Blocks.HAMSTER_port_b,"B"],[Lang.Blocks.HAMSTER_port_ab,"AB"]],value:"A",fontSize:11},{type:"Dropdown",options:[[Lang.Blocks.HAMSTER_analog_input,"0"],[Lang.Blocks.HAMSTER_digital_input,"1"],[Lang.Blocks.HAMSTER_servo_output,"8"],[Lang.Blocks.HAMSTER_pwm_output,"9"], +[Lang.Blocks.HAMSTER_digital_output,"10"]],value:"0",fontSize:11},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,null,null],type:"hamster_set_port_to"},paramsKeyMap:{PORT:0,MODE:1},"class":"hamster_port",isNotFor:["hamster"],func:function(b,a){var c=Entry.hw.sendQueue,d=a.getField("PORT",a),e=+a.getField("MODE",a);"A"==d?c.ioModeA=e:("B"!=d&&(c.ioModeA=e),c.ioModeB=e);return a.callReturn()}},hamster_change_output_by:{color:"#00979D",skeleton:"basic",statements:[], +params:[{type:"Dropdown",options:[[Lang.Blocks.HAMSTER_port_a,"A"],[Lang.Blocks.HAMSTER_port_b,"B"],[Lang.Blocks.HAMSTER_port_ab,"AB"]],value:"A",fontSize:11},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,{type:"text",params:["10"]},null],type:"hamster_change_output_by"},paramsKeyMap:{PORT:0,VALUE:1},"class":"hamster_port",isNotFor:["hamster"],func:function(b,a){var c=Entry.hw.sendQueue,d=a.getField("PORT"),e=a.getNumberValue("VALUE"); +"A"==d?c.outputA=void 0!=c.outputA?c.outputA+e:e:("B"!=d&&(c.outputA=void 0!=c.outputA?c.outputA+e:e),c.outputB=void 0!=c.outputB?c.outputB+e:e);return a.callReturn()}},hamster_set_output_to:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.HAMSTER_port_a,"A"],[Lang.Blocks.HAMSTER_port_b,"B"],[Lang.Blocks.HAMSTER_port_ab,"AB"]],value:"A",fontSize:11},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null, +{type:"text",params:["100"]},null],type:"hamster_set_output_to"},paramsKeyMap:{PORT:0,VALUE:1},"class":"hamster_port",isNotFor:["hamster"],func:function(b,a){var c=Entry.hw.sendQueue,d=a.getField("PORT"),e=a.getNumberValue("VALUE");"A"==d?c.outputA=e:("B"!=d&&(c.outputA=e),c.outputB=e);return a.callReturn()}},is_clicked:{color:"#AEB8FF",skeleton:"basic_boolean_field",statements:[],params:[{type:"Text",text:Lang.Blocks.JUDGEMENT_is_clicked,color:"#3D3D3D"}],events:{},def:{params:[null],type:"is_clicked"}, +"class":"boolean_input",isNotFor:[],func:function(b,a){return Entry.stage.isClick}},is_press_some_key:{color:"#AEB8FF",skeleton:"basic_boolean_field",statements:[],params:[{type:"Keyboard",value:81},{type:"Text",text:Lang.Blocks.JUDGEMENT_is_press_some_key_2,color:"#3D3D3D"}],events:{},def:{params:[null,null],type:"is_press_some_key"},paramsKeyMap:{VALUE:0},"class":"boolean_input",isNotFor:[],func:function(b,a){var c=+a.getField("VALUE",a);return 0<=Entry.pressedKeys.indexOf(c)}},reach_something:{color:"#AEB8FF", +skeleton:"basic_boolean_field",statements:[],params:[{type:"Text",text:Lang.Blocks.JUDGEMENT_reach_something_1,color:"#3D3D3D"},{type:"DropdownDynamic",value:null,menuName:"collision",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_JUDGE},{type:"Text",text:Lang.Blocks.JUDGEMENT_reach_something_2,color:"#3D3D3D"}],events:{},def:{params:[null,null,null],type:"reach_something"},paramsKeyMap:{VALUE:1},"class":"boolean_collision",isNotFor:[],func:function(b,a){if(!b.getVisible())return!1;var c=a.getField("VALUE", +a),d=b.object,e=/wall/.test(c),f=ndgmr.checkPixelCollision;if(e)switch(e=Entry.stage.wall,c){case "wall":if(f(d,e.up,.2,!0)||f(d,e.down,.2,!0)||f(d,e.left,.2,!0)||f(d,e.right,.2,!0))return!0;break;case "wall_up":if(f(d,e.up,.2,!0))return!0;break;case "wall_down":if(f(d,e.down,.2,!0))return!0;break;case "wall_right":if(f(d,e.right,.2,!0))return!0;break;case "wall_left":if(f(d,e.left,.2,!0))return!0}else{if("mouse"==c)return f=Entry.stage.canvas,f=d.globalToLocal(f.mouseX,f.mouseY),d.hitTest(f.x,f.y); +c=Entry.container.getEntity(c);if("textBox"==c.type||"textBox"==b.type){f=c.object.getTransformedBounds();d=d.getTransformedBounds();if(Entry.checkCollisionRect(d,f))return!0;for(var c=c.parent.clonedEntities,e=0,g=c.length;e","BIGGER"]],value:"EQUAL",fontSize:11},{type:"Block",accept:"string"}],events:{},def:{params:[null],type:"boolean_comparison"},paramsKeyMap:{LEFTHAND:0,OPERATOR:1,RIGHTHAND:2},func:function(b,a){var c=a.getField("OPERATOR",a),d=a.getNumberValue("LEFTHAND",a),e=a.getNumberValue("RIGHTHAND",a); +return"EQUAL"==c?d==e:"BIGGER"==c?d>e:d",color:"#3D3D3D"},{type:"Block",accept:"string"}],events:{},def:{params:[{type:"number",params:["10"]},null,{type:"number",params:["10"]}],type:"boolean_bigger"},paramsKeyMap:{LEFTHAND:0,RIGHTHAND:2},"class":"boolean_compare",isNotFor:[],func:function(b,a){var c=a.getNumberValue("LEFTHAND",a),d=a.getNumberValue("RIGHTHAND",a);return c>d}},boolean_smaller:{color:"#AEB8FF", +skeleton:"basic_boolean_field",statements:[],params:[{type:"Block",accept:"string"},{type:"Text",text:"<",color:"#3D3D3D"},{type:"Block",accept:"string"}],events:{},def:{params:[{type:"number",params:["10"]},null,{type:"number",params:["10"]}],type:"boolean_smaller"},paramsKeyMap:{LEFTHAND:0,RIGHTHAND:2},"class":"boolean_compare",isNotFor:[],func:function(b,a){var c=a.getNumberValue("LEFTHAND",a),d=a.getNumberValue("RIGHTHAND",a);return c","GREATER"],["<","LESS"],["\u2265","GREATER_OR_EQUAL"],["\u2264","LESS_OR_EQUAL"]],value:"EQUAL",fontSize:11,noArrow:!0},{type:"Block",accept:"string"}],events:{},def:{params:[{type:"text",params:["10"]},"EQUAL",{type:"text",params:["10"]}],type:"boolean_basic_operator"},defs:[{params:[{type:"text", +params:["10"]},"EQUAL",{type:"text",params:["10"]}],type:"boolean_basic_operator"},{params:[{type:"text",params:["10"]},"GREATER",{type:"text",params:["10"]}],type:"boolean_basic_operator"},{params:[{type:"text",params:["10"]},"LESS",{type:"text",params:["10"]}],type:"boolean_basic_operator"},{params:[{type:"text",params:["10"]},"GREATER_OR_EQUAL",{type:"text",params:["10"]}],type:"boolean_basic_operator"},{params:[{type:"text",params:["10"]},"LESS_OR_EQUAL",{type:"text",params:["10"]}],type:"boolean_basic_operator"}], +paramsKeyMap:{LEFTHAND:0,OPERATOR:1,RIGHTHAND:2},"class":"boolean_compare",isNotFor:[],func:function(b,a){var c=a.getField("OPERATOR",a),d=a.getStringValue("LEFTHAND",a),e=a.getStringValue("RIGHTHAND",a);switch(c){case "EQUAL":return d==e;case "GREATER":return+d>+e;case "LESS":return+d<+e;case "GREATER_OR_EQUAL":return+d>=+e;case "LESS_OR_EQUAL":return+d<=+e}}},show:{color:"#EC4466",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/looks_03.png",size:12}],events:{},def:{params:[null], +type:"show"},"class":"visibility",isNotFor:[],func:function(b,a){b.setVisible(!0);return a.callReturn()}},hide:{color:"#EC4466",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/looks_03.png",size:12}],events:{},def:{params:[null],type:"hide"},"class":"visibility",isNotFor:[],func:function(b,a){b.setVisible(!1);return a.callReturn()}},dialog_time:{color:"#EC4466",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Dropdown", +options:[[Lang.Blocks.speak,"speak"]],value:"speak",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_LOOKS},{type:"Indicator",img:"block_icon/looks_03.png",size:12}],events:{},def:{params:[{type:"text",params:[Lang.Blocks.block_hi]},{type:"number",params:["4"]},null,null],type:"dialog_time"},paramsKeyMap:{VALUE:0,SECOND:1,OPTION:2},"class":"say",isNotFor:["textBox"],func:function(b,a){if(!a.isStart){var c=a.getNumberValue("SECOND",a),d=a.getStringValue("VALUE",a),e=a.getField("OPTION",a);a.isStart= +!0;a.timeFlag=1;d||"number"==typeof d||(d=" ");d=Entry.convertToRoundedDecimals(d,3);new Entry.Dialog(b,d,e);b.syncDialogVisible(b.getVisible());setTimeout(function(){a.timeFlag=0},1E3*c)}if(0==a.timeFlag)return delete a.timeFlag,delete a.isStart,b.dialog&&b.dialog.remove(),a.callReturn();b.dialog||(d=a.getStringValue("VALUE",a),e=a.getField("OPTION",a),d||"number"==typeof d||(d=" "),d=Entry.convertToRoundedDecimals(d,3),new Entry.Dialog(b,d,e),b.syncDialogVisible(b.getVisible()));return a}}, +dialog:{color:"#EC4466",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Dropdown",options:[[Lang.Blocks.speak,"speak"]],value:"speak",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_LOOKS},{type:"Indicator",img:"block_icon/looks_03.png",size:12}],events:{},def:{params:[{type:"text",params:[Lang.Blocks.block_hi]},null,null],type:"dialog"},paramsKeyMap:{VALUE:0,OPTION:1},"class":"say",isNotFor:["textBox"],func:function(b,a){var c=a.getStringValue("VALUE",a);c||"number"== +typeof c||(c=" ");var d=a.getField("OPTION",a),c=Entry.convertToRoundedDecimals(c,3);new Entry.Dialog(b,c,d);b.syncDialogVisible(b.getVisible());return a.callReturn()}},remove_dialog:{color:"#EC4466",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/looks_03.png",size:12}],events:{},def:{params:[null],type:"remove_dialog"},"class":"say",isNotFor:["textBox"],func:function(b,a){b.dialog&&b.dialog.remove();return a.callReturn()}},change_to_nth_shape:{color:"#EC4466",skeleton:"basic", +statements:[],params:[{type:"DropdownDynamic",value:null,menuName:"pictures",fontSize:11},{type:"Indicator",img:"block_icon/looks_03.png",size:12}],events:{},def:{params:[null,null],type:"change_to_nth_shape"},paramsKeyMap:{VALUE:0},"class":"shape",isNotFor:[],func:function(b,a){var c=a.getField("VALUE",a),c=b.parent.getPicture(c);b.setImage(c);return a.callReturn()}},change_to_next_shape:{color:"#EC4466",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.LOOKS_change_shape_next, +"next"],[Lang.Blocks.LOOKS_change_shape_prev,"prev"]],value:"next",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_LOOKS},{type:"Indicator",img:"block_icon/looks_03.png",size:12}],events:{},def:{params:[null,null],type:"change_to_next_shape"},paramsKeyMap:{DRIECTION:0},"class":"shape",isNotFor:["textBox"],func:function(b,a){var c;c="prev"!==a.getStringField("DRIECTION")?b.parent.getNextPicture(b.picture.id):b.parent.getPrevPicture(b.picture.id);b.setImage(c);return a.callReturn()}},set_effect_volume:{color:"#EC4466", +skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.color,"color"],[Lang.Blocks.brightness,"brightness"],[Lang.Blocks.opacity,"opacity"]],value:"color",fontSize:11},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/looks_03.png",size:12}],events:{},def:{params:[null,{type:"number",params:["10"]},null],type:"set_effect_volume"},paramsKeyMap:{EFFECT:0,VALUE:1},"class":"effect",isNotFor:["textBox"],func:function(b,a){var c=a.getField("EFFECT",a),d=a.getNumberValue("VALUE", +a);"color"==c?b.effect.hue=d+b.effect.hue:"lens"!=c&&"swriling"!=c&&"pixel"!=c&&"mosaic"!=c&&("brightness"==c?b.effect.brightness=d+b.effect.brightness:"blur"!=c&&"opacity"==c&&(b.effect.alpha+=d/100));b.applyFilter();return a.callReturn()}},set_effect:{color:"#EC4466",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.color,"color"],[Lang.Blocks.brightness,"brightness"],[Lang.Blocks.opacity,"opacity"]],value:"color",fontSize:11},{type:"Block",accept:"string"},{type:"Indicator", +img:"block_icon/looks_03.png",size:12}],events:{},def:{params:[null,{type:"number",params:["100"]},null],type:"set_effect"},paramsKeyMap:{EFFECT:0,VALUE:1},"class":"effect",isNotFor:["textBox"],func:function(b,a){var c=a.getField("EFFECT",a),d=a.getNumberValue("VALUE",a);"color"==c?b.effect.hue=d:"lens"!=c&&"swriling"!=c&&"pixel"!=c&&"mosaic"!=c&&("brightness"==c?b.effect.brightness=d:"blur"!=c&&"opacity"==c&&(b.effect.alpha=d/100));b.applyFilter();return a.callReturn()}},erase_all_effects:{color:"#EC4466", +skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/looks_03.png",size:12}],events:{},def:{params:[null],type:"erase_all_effects"},"class":"effect",isNotFor:["textBox"],func:function(b,a){b.resetFilter();return a.callReturn()}},change_scale_percent:{color:"#EC4466",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/looks_03.png",size:12}],events:{},def:{params:[{type:"number",params:["10"]},null],type:"change_scale_percent"}, +paramsKeyMap:{VALUE:0},"class":"scale",isNotFor:[],func:function(b,a){var c=(a.getNumberValue("VALUE",a)+100)/100;b.setScaleX(b.getScaleX()*c);b.setScaleY(b.getScaleY()*c);return a.callReturn()}},set_scale_percent:{color:"#EC4466",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/looks_03.png",size:12}],events:{},def:{params:[{type:"number",params:["100"]},null],type:"set_scale_percent"},paramsKeyMap:{VALUE:0},"class":"scale",isNotFor:[],func:function(b, +a){var c=a.getNumberValue("VALUE",a)/100,d=b.snapshot_;b.setScaleX(c*d.scaleX);b.setScaleY(c*d.scaleY);return a.callReturn()}},change_scale_size:{color:"#EC4466",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/looks_03.png",size:12}],events:{},def:{params:[{type:"number",params:["10"]},null],type:"change_scale_size"},paramsKeyMap:{VALUE:0},"class":"scale",isNotFor:[],func:function(b,a){var c=a.getNumberValue("VALUE",a);b.setSize(b.getSize()+ +c);return a.callReturn()}},set_scale_size:{color:"#EC4466",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/looks_03.png",size:12}],events:{},def:{params:[{type:"number",params:["100"]},null],type:"set_scale_size"},paramsKeyMap:{VALUE:0},"class":"scale",isNotFor:[],func:function(b,a){var c=a.getNumberValue("VALUE",a);b.setSize(c);return a.callReturn()}},flip_y:{color:"#EC4466",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/looks_03.png", +size:12}],events:{},def:{params:[null],type:"flip_y"},"class":"flip",isNotFor:[],func:function(b,a){b.setScaleX(-1*b.getScaleX());return a.callReturn()}},flip_x:{color:"#EC4466",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/looks_03.png",size:12}],events:{},def:{params:[null],type:"flip_x"},"class":"flip",isNotFor:[],func:function(b,a){b.setScaleY(-1*b.getScaleY());return a.callReturn()}},set_object_order:{color:"#EC4466",skeleton:"basic",statements:[],params:[{type:"DropdownDynamic", +value:null,menuName:"objectSequence",fontSize:11},{type:"Indicator",img:"block_icon/looks_03.png",size:12}],events:{},def:{params:[null,null],type:"set_object_order"},paramsKeyMap:{VALUE:0},"class":"z-index",isNotFor:[],func:function(b,a){var c=a.getField("VALUE",a),d=Entry.container.getCurrentObjects().indexOf(b.parent);if(-1f)throw Error("object is not available for current scene");switch(d){case "FRONT":c=0;break;case "FORWARD":c=Math.max(0,f-1);break;case "BACKWARD":c=Math.min(e,f+1);break;case "BACK":c=e}Entry.container.moveElementByBlock(f,c);return a.callReturn()}}, +move_direction:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"number",params:["10"]},null],type:"move_direction"},paramsKeyMap:{VALUE:0},"class":"walk",isNotFor:[],func:function(b,a){var c=a.getNumberValue("VALUE",a);b.setX(b.getX()+c*Math.cos((b.getRotation()+b.getDirection()-90)/180*Math.PI));b.setY(b.getY()-c*Math.sin((b.getRotation()+b.getDirection()-90)/180*Math.PI)); +b.brush&&!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY());return a.callReturn()}},move_x:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"number",params:["10"]},null],type:"move_x"},paramsKeyMap:{VALUE:0},"class":"move_relative",isNotFor:[],func:function(b,a){var c=a.getNumberValue("VALUE",a);b.setX(b.getX()+c);b.brush&&!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY()); +return a.callReturn()}},move_y:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"number",params:["10"]},null],type:"move_y"},paramsKeyMap:{VALUE:0},"class":"move_relative",isNotFor:[],func:function(b,a){var c=a.getNumberValue("VALUE",a);b.setY(b.getY()+c);b.brush&&!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY());return a.callReturn()}},locate_xy_time:{color:"#A751E3",skeleton:"basic", +statements:[],params:[{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"number",params:["2"]},{type:"number",params:["10"]},{type:"number",params:["10"]},null],type:"locate_xy_time"},paramsKeyMap:{VALUE1:0,VALUE2:1,VALUE3:2},"class":"move_absolute",isNotFor:[],func:function(b,a){function c(){var c=a.x-b.getX(),d=a.y-b.getY(),c=c/a.frameCount,d=d/a.frameCount;b.setX(b.getX()+ +c);b.setY(b.getY()+d);a.frameCount--;b.brush&&!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY())}if(!a.isStart){var d;d=a.getNumberValue("VALUE1",a);a.isStart=!0;a.frameCount=Math.max(Math.floor(d*Entry.FPS),1);a.x=a.getNumberValue("VALUE2",a);a.y=a.getNumberValue("VALUE3",a);1==a.frameCount&&c()}if(0!=a.frameCount)return c(),a;delete a.isStart;delete a.frameCount;return a.callReturn()}},rotate_by_angle:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator", +img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"number",params:["90"]},null],type:"rotate_by_angle"},paramsKeyMap:{VALUE:0},"class":"rotate",isNotFor:[],func:function(b,a){var c=a.getNumberValue("VALUE",a);b.setRotation(b.getRotation()+c);return a.callReturn()}},rotate_by_angle_dropdown:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[["45","45"],["90","90"],["135","135"],["180","180"]],value:"45",fontSize:11},{type:"Indicator",img:"block_icon/moving_03.png", +size:12}],events:{},def:{params:["45",null],type:"rotate_by_angle_dropdown"},paramsKeyMap:{VALUE:0},"class":"ebs",isNotFor:[],func:function(b,a){var c=a.getField("VALUE",a);b.setRotation(b.getRotation()+ +c);return a.callReturn()}},see_angle:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"number",params:["90"]},null],type:"see_angle"},paramsKeyMap:{VALUE:0},"class":"rotate", +isNotFor:[],func:function(b,a){var c=a.getNumberValue("VALUE",a);b.setDirection(c);return a.callReturn()}},see_direction:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"DropdownDynamic",value:null,menuName:"sprites",fontSize:11},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[null,null]},paramsKeyMap:{VALUE:0},func:function(b,a){var c=a.getField("VALUE",a),d=Entry.container.getEntity(c),c=d.getX()-b.getX(),d=d.getY()-b.getY();0<=c?b.setRotation(Math.atan(d/ +c)/Math.PI*180+90):b.setRotation(Math.atan(d/c)/Math.PI*180+270);return a.callReturn()}},locate_xy:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"number",params:["0"]},{type:"number",params:["0"]},null],type:"locate_xy"},paramsKeyMap:{VALUE1:0,VALUE2:1},"class":"move_absolute",isNotFor:[],func:function(b,a){var c=a.getNumberValue("VALUE1", +a),d=a.getNumberValue("VALUE2",a);b.setX(c);b.setY(d);b.brush&&!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY());return a.callReturn()}},locate_x:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"number",params:["10"]},null],type:"locate_x"},paramsKeyMap:{VALUE:0},"class":"move_absolute",isNotFor:[],func:function(b,a){var c=a.getNumberValue("VALUE",a);b.setX(c);b.brush&& +!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY());return a.callReturn()}},locate_y:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"number",params:["10"]},null],type:"locate_y"},paramsKeyMap:{VALUE:0},"class":"move_absolute",isNotFor:[],func:function(b,a){var c=a.getNumberValue("VALUE",a);b.setY(c);b.brush&&!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY());return a.callReturn()}}, +locate:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"DropdownDynamic",value:null,menuName:"spritesWithMouse",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_MOVING},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[null,null],type:"locate"},paramsKeyMap:{VALUE:0},"class":"move_absolute",isNotFor:[],func:function(b,a){var c=a.getField("VALUE",a),d;"mouse"==c?(c=Entry.stage.mouseCoordinate.x,d=Entry.stage.mouseCoordinate.y):(d=Entry.container.getEntity(c), +c=d.getX(),d=d.getY());b.setX(+c);b.setY(+d);b.brush&&!b.brush.stop&&b.brush.lineTo(c,-1*d);return a.callReturn()}},move_xy_time:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"number",params:["2"]},{type:"number",params:["10"]},{type:"number",params:["10"]},null],type:"move_xy_time"},paramsKeyMap:{VALUE1:0,VALUE2:1, +VALUE3:2},"class":"move_relative",isNotFor:[],func:function(b,a){function c(){b.setX(b.getX()+a.dX);b.setY(b.getY()+a.dY);a.frameCount--;b.brush&&!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY())}if(!a.isStart){var d;d=a.getNumberValue("VALUE1",a);var e=a.getNumberValue("VALUE2",a),f=a.getNumberValue("VALUE3",a);a.isStart=!0;a.frameCount=Math.max(Math.floor(d*Entry.FPS),1);a.dX=e/a.frameCount;a.dY=f/a.frameCount;1==a.frameCount&&c()}if(0!=a.frameCount)return c(),a;delete a.isStart;delete a.frameCount; +return a.callReturn()}},rotate_by_angle_time:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Angle"},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"number",params:["2"]},null,null],type:"rotate_by_angle_time"},paramsKeyMap:{VALUE:1},"class":"rotate",isNotFor:[],func:function(b,a){if(!a.isStart){var c;c=a.getNumberValue("VALUE",a);var d=a.getNumberField("VALUE",a);a.isStart=!0;a.frameCount=Math.floor(c*Entry.FPS); +a.dAngle=d/a.frameCount}if(0!=a.frameCount)return b.setRotation(b.getRotation()+a.dAngle),a.frameCount--,a;delete a.isStart;delete a.frameCount;return a.callReturn()}},bounce_wall:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[null],type:"bounce_wall"},"class":"walk",isNotFor:[],func:function(b,a){var c=b.parent.getRotateMethod(),d="free"==c?(b.getRotation()+b.getDirection()).mod(360):b.getDirection(),e=Entry.Utils.COLLISION.NONE; +if(90>d&&0<=d||360>d&&270<=d){var e=b.collision==Entry.Utils.COLLISION.UP,f=ndgmr.checkPixelCollision(Entry.stage.wall.up,b.object,0,!1);!f&&e&&(b.collision=Entry.Utils.COLLISION.NONE);f&&e&&(f=!1);f?("free"==c?b.setRotation(-b.getRotation()-2*b.getDirection()+180):b.setDirection(-b.getDirection()+180),b.collision=Entry.Utils.COLLISION.UP):(e=b.collision==Entry.Utils.COLLISION.DOWN,f=ndgmr.checkPixelCollision(Entry.stage.wall.down,b.object,0,!1),!f&&e&&(b.collision=Entry.Utils.COLLISION.NONE),f&& +e&&(f=!1),f&&("free"==c?b.setRotation(-b.getRotation()-2*b.getDirection()+180):b.setDirection(-b.getDirection()+180),b.collision=Entry.Utils.COLLISION.DOWN))}else 270>d&&90<=d&&(e=b.collision==Entry.Utils.COLLISION.DOWN,f=ndgmr.checkPixelCollision(Entry.stage.wall.down,b.object,0,!1),!f&&e&&(b.collision=Entry.Utils.COLLISION.NONE),f&&e&&(f=!1),f?("free"==c?b.setRotation(-b.getRotation()-2*b.getDirection()+180):b.setDirection(-b.getDirection()+180),b.collision=Entry.Utils.COLLISION.DOWN):(e=b.collision== +Entry.Utils.COLLISION.UP,f=ndgmr.checkPixelCollision(Entry.stage.wall.up,b.object,0,!1),!f&&e&&(b.collision=Entry.Utils.COLLISION.NONE),f&&e&&(f=!1),f&&("free"==c?b.setRotation(-b.getRotation()-2*b.getDirection()+180):b.setDirection(-b.getDirection()+180),b.collision=Entry.Utils.COLLISION.UP)));360>d&&180<=d?(e=b.collision==Entry.Utils.COLLISION.LEFT,d=ndgmr.checkPixelCollision(Entry.stage.wall.left,b.object,0,!1),!d&&e&&(b.collision=Entry.Utils.COLLISION.NONE),d&&e&&(d=!1),d?("free"==c?b.setRotation(-b.getRotation()- +2*b.getDirection()):b.setDirection(-b.getDirection()+360),b.collision=Entry.Utils.COLLISION.LEFT):(e=b.collision==Entry.Utils.COLLISION.RIGHT,d=ndgmr.checkPixelCollision(Entry.stage.wall.right,b.object,0,!1),!d&&e&&(b.collision=Entry.Utils.COLLISION.NONE),d&&e&&(d=!1),d&&("free"==c?b.setRotation(-b.getRotation()-2*b.getDirection()):b.setDirection(-b.getDirection()+360),b.collision=Entry.Utils.COLLISION.RIGHT))):180>d&&0<=d&&(e=b.collision==Entry.Utils.COLLISION.RIGHT,d=ndgmr.checkPixelCollision(Entry.stage.wall.right, +b.object,0,!1),!d&&e&&(b.collision=Entry.Utils.COLLISION.NONE),d&&e&&(d=!1),d?("free"==c?b.setRotation(-b.getRotation()-2*b.getDirection()):b.setDirection(-b.getDirection()+360),b.collision=Entry.Utils.COLLISION.RIGHT):(e=b.collision==Entry.Utils.COLLISION.LEFT,d=ndgmr.checkPixelCollision(Entry.stage.wall.left,b.object,0,!1),!d&&e&&(b.collision=Entry.Utils.COLLISION.NONE),d&&e&&(d=!1),d&&("free"==c?b.setRotation(-b.getRotation()-2*b.getDirection()):b.setDirection(-b.getDirection()+360),b.collision= +Entry.Utils.COLLISION.LEFT)));return a.callReturn()}},flip_arrow_horizontal:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[null]},func:function(b,a){b.setDirection(b.getDirection()+180);return a.callReturn()}},flip_arrow_vertical:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[null]},func:function(b,a){b.setDirection(b.getDirection()+ +180);return a.callReturn()}},see_angle_object:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"DropdownDynamic",value:null,menuName:"spritesWithMouse",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_MOVING},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[null,null],type:"see_angle_object"},paramsKeyMap:{VALUE:0},"class":"rotate_absolute",isNotFor:[],func:function(b,a){var c=a.getField("VALUE",a),d=b.getX(),e=b.getY();if(b.parent.id==c)return a.callReturn(); +"mouse"==c?(c=Entry.stage.mouseCoordinate.y,d=Entry.stage.mouseCoordinate.x-d,e=c-e):(c=Entry.container.getEntity(c),d=c.getX()-d,e=c.getY()-e);e=0===d&&0===e?b.getDirection()+b.getRotation():0<=d?-Math.atan(e/d)/Math.PI*180+90:-Math.atan(e/d)/Math.PI*180+270;d=b.getDirection()+b.getRotation();b.setRotation(b.getRotation()+e-d);return a.callReturn()}},see_angle_direction:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png", +size:12}],events:{},def:{params:[{type:"number",params:["90"]},null],type:"see_angle_direction"},paramsKeyMap:{VALUE:0},"class":"rotate",isNotFor:[],func:function(b,a){var c=a.getNumberValue("VALUE",a),d=b.getDirection()+b.getRotation();b.setRotation(b.getRotation()+c-d);return a.callReturn()}},rotate_direction:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"number",params:["90"]}, +null],type:"rotate_direction"},paramsKeyMap:{VALUE:0},"class":"rotate",isNotFor:[],func:function(b,a){var c=a.getNumberValue("VALUE",a);b.setDirection(c+b.getDirection());return a.callReturn()}},locate_object_time:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"DropdownDynamic",value:null,menuName:"spritesWithMouse",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_MOVING},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"number", +params:["2"]},null,null],type:"locate_object_time"},paramsKeyMap:{VALUE:0,TARGET:1},"class":"move_absolute",isNotFor:[],func:function(b,a){if(!a.isStart){var c,d,e;d=a.getField("TARGET",a);c=a.getNumberValue("VALUE",a);c=Math.floor(c*Entry.FPS);e=Entry.stage.mouseCoordinate;if(0!=c)"mouse"==d?(d=e.x-b.getX(),e=e.y-b.getY()):(e=Entry.container.getEntity(d),d=e.getX()-b.getX(),e=e.getY()-b.getY()),a.isStart=!0,a.frameCount=c,a.dX=d/a.frameCount,a.dY=e/a.frameCount;else return"mouse"==d?(d=+e.x,e=+e.y): +(e=Entry.container.getEntity(d),d=e.getX(),e=e.getY()),b.setX(d),b.setY(e),b.brush&&!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY()),a.callReturn()}if(0!=a.frameCount)return b.setX(b.getX()+a.dX),b.setY(b.getY()+a.dY),a.frameCount--,b.brush&&!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY()),a;delete a.isStart;delete a.frameCount;return a.callReturn()}},rotate_absolute:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png", +size:12}],events:{},def:{params:[{type:"angle"},null],type:"rotate_absolute"},paramsKeyMap:{VALUE:0},"class":"rotate_absolute",isNotFor:[],func:function(b,a){var c=a.getNumberValue("VALUE",a);b.setRotation(c);return a.callReturn()}},rotate_relative:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"angle"},null],type:"rotate_relative"},paramsKeyMap:{VALUE:0},"class":"rotate", +isNotFor:[],func:function(b,a){var c=a.getNumberValue("VALUE",a);b.setRotation(c+b.getRotation());return a.callReturn()}},direction_absolute:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"angle"},null],type:"direction_absolute"},paramsKeyMap:{VALUE:0},"class":"rotate_absolute",isNotFor:[],func:function(b,a){var c=a.getNumberValue("VALUE",a);b.setDirection(c);return a.callReturn()}}, +direction_relative:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"angle"},null],type:"direction_relative"},paramsKeyMap:{VALUE:0},"class":"rotate",isNotFor:[],func:function(b,a){var c=a.getNumberValue("VALUE",a);b.setDirection(c+b.getDirection());return a.callReturn()}},move_to_angle:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"}, +{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"angle"},{type:"number",params:["10"]},null],type:"move_to_angle"},paramsKeyMap:{ANGLE:0,VALUE:1},"class":"move_rotate",isNotFor:[],func:function(b,a){var c=a.getNumberValue("VALUE",a),d=a.getNumberValue("ANGLE",a);b.setX(b.getX()+c*Math.cos((d-90)/180*Math.PI));b.setY(b.getY()-c*Math.sin((d-90)/180*Math.PI));b.brush&&!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY());return a.callReturn()}}, +rotate_by_time:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"number",params:["2"]},{type:"angle"},null],type:"rotate_by_time"},paramsKeyMap:{VALUE:0,ANGLE:1},"class":"rotate",isNotFor:[],func:function(b,a){function c(){b.setRotation(b.getRotation()+a.dAngle);a.frameCount--}if(!a.isStart){var d;d=a.getNumberValue("VALUE",a);var e=a.getNumberValue("ANGLE", +a);a.isStart=!0;a.frameCount=Math.max(Math.floor(d*Entry.FPS),1);a.dAngle=e/a.frameCount;1==a.frameCount&&c()}if(0!=a.frameCount)return c(),a;delete a.isStart;delete a.frameCount;return a.callReturn()}},direction_relative_duration:{color:"#A751E3",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/moving_03.png",size:12}],events:{},def:{params:[{type:"text",params:["2"]},{type:"angle"},null],type:"direction_relative_duration"}, +paramsKeyMap:{DURATION:0,AMOUNT:1},"class":"rotate",isNotFor:[],func:function(b,a){function c(){b.setDirection(b.getDirection()+a.dDirection);a.frameCount--}if(!a.isStart){var d;d=a.getNumberValue("DURATION",a);var e=a.getNumberValue("AMOUNT",a);a.isStart=!0;a.frameCount=Math.max(Math.floor(d*Entry.FPS),1);a.dDirection=e/a.frameCount;1==a.frameCount&&c()}if(0!=a.frameCount)return c(),a;delete a.isStart;delete a.frameCount;delete a.dDirection;return a.callReturn()}},neobot_sensor_value:{color:"#00979D", +skeleton:"basic_string_field",fontColor:"#fff",statements:[],template:"%1 \uac12",params:[{type:"Dropdown",options:[["1\ubc88 \ud3ec\ud2b8","IN1"],["2\ubc88 \ud3ec\ud2b8","IN2"],["3\ubc88 \ud3ec\ud2b8","IN3"],["\ub9ac\ubaa8\ucee8","IR"],["\ubc30\ud130\ub9ac","BAT"]],value:"IN1",fontSize:11}],events:{},def:{params:[null],type:"neobot_sensor_value"},paramsKeyMap:{PORT:0},"class":"neobot_value",isNotFor:["neobot"],func:function(b,a){var c=a.getStringField("PORT");return Entry.hw.portData[c]}},neobot_sensor_convert_scale:{color:"#00979D", +skeleton:"basic_string_field",fontColor:"#fff",statements:[],template:"%1 \uac12\uc758 \ubc94\uc704\ub97c %2 ~ %3 \uc5d0\uc11c %4 ~ %5 (\uc73c)\ub85c \ubcc0\ud658",params:[{type:"Dropdown",options:[["1\ubc88 \ud3ec\ud2b8","IN1"],["2\ubc88 \ud3ec\ud2b8","IN2"],["3\ubc88 \ud3ec\ud2b8","IN3"],["\ub9ac\ubaa8\ucee8","IR"],["\ubc30\ud130\ub9ac","BAT"]],value:"IN1",fontSize:11},{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Block",accept:"string"}],events:{}, +def:{params:[null,{type:"number",params:["0"]},{type:"number",params:["255"]},{type:"number",params:["0"]},{type:"number",params:["100"]}],type:"neobot_sensor_convert_scale"},paramsKeyMap:{PORT:0,OMIN:1,OMAX:2,MIN:3,MAX:4},"class":"neobot_value",isNotFor:["neobot"],func:function(b,a){var c=a.getStringField("PORT"),c=Entry.hw.portData[c],d=a.getNumberValue("OMIN",a),e=a.getNumberValue("OMAX",a),f=a.getNumberValue("MIN",a),g=a.getNumberValue("MAX",a);if(d>e)var h=d,d=e,e=h;f>g&&(h=f,f=g,g=h);c=(g-f)/ +(e-d)*(c-d);c+=f;c=Math.min(g,c);c=Math.max(f,c);return Math.round(c)}},neobot_left_motor:{color:"#00979D",skeleton:"basic",statements:[],template:"\uc67c\ucabd \ubaa8\ud130\ub97c %1 %2 \uc758 \uc18d\ub3c4\ub85c \ud68c\uc804 %3",params:[{type:"Dropdown",options:[["\uc55e\uc73c\ub85c","16"],["\ub4a4\ub85c","32"]],value:"16",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW},{type:"Dropdown",options:[["0","0"],["1","1"],["2","2"],["3","3"],["4","4"],["5","5"],["6","6"],["7","7"],["8","8"],["9","9"], +["10","10"],["11","11"],["12","12"],["13","13"],["14","14"],["15","15"]],value:"0",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,"15",null],type:"neobot_left_motor"},paramsKeyMap:{DIRECTION:0,SPEED:1},"class":"neobot_motor",isNotFor:["neobot"],func:function(b,a){var c=a.getNumberField("SPEED"),d=a.getNumberField("DIRECTION");Entry.hw.sendQueue.DCL=c+d;return a.callReturn()}},neobot_stop_left_motor:{color:"#00979D", +skeleton:"basic",statements:[],template:"\uc67c\ucabd \ubaa8\ud130\ub97c \uc815\uc9c0 %1",params:[{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null],type:"neobot_stop_left_motor"},"class":"neobot_motor",isNotFor:["neobot"],func:function(b,a){Entry.hw.sendQueue.DCL=0;return a.callReturn()}},neobot_right_motor:{color:"#00979D",skeleton:"basic",statements:[],template:"\uc624\ub978\ucabd \ubaa8\ud130\ub97c %1 %2 \uc758 \uc18d\ub3c4\ub85c \ud68c\uc804 %3",params:[{type:"Dropdown", +options:[["\uc55e\uc73c\ub85c","16"],["\ub4a4\ub85c","32"]],value:"16",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW},{type:"Dropdown",options:[["0","0"],["1","1"],["2","2"],["3","3"],["4","4"],["5","5"],["6","6"],["7","7"],["8","8"],["9","9"],["10","10"],["11","11"],["12","12"],["13","13"],["14","14"],["15","15"]],value:"0",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,"15",null],type:"neobot_right_motor"}, +paramsKeyMap:{DIRECTION:0,SPEED:1},"class":"neobot_motor",isNotFor:["neobot"],func:function(b,a){var c=a.getNumberField("SPEED"),d=a.getNumberField("DIRECTION");Entry.hw.sendQueue.DCR=c+d;return a.callReturn()}},neobot_stop_right_motor:{color:"#00979D",skeleton:"basic",statements:[],template:"\uc624\ub978\ucabd \ubaa8\ud130\ub97c \uc815\uc9c0 %1",params:[{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null],type:"neobot_stop_right_motor"},"class":"neobot_motor", +isNotFor:["neobot"],func:function(b,a){Entry.hw.sendQueue.DCR=0;return a.callReturn()}},neobot_all_motor:{color:"#00979D",skeleton:"basic",statements:[],template:"\uc591\ucabd \ubaa8\ud130\ub97c %1 %2\uc758 \uc18d\ub3c4\ub85c %3\ucd08 \ub3d9\uc548 \ud68c\uc804 %4",params:[{type:"Dropdown",options:[["\uc55e\uc73c\ub85c","1"],["\ub4a4\ub85c","2"],["\uc81c\uc790\ub9ac\uc5d0\uc11c \uc67c\ucabd \ub3cc\uae30","3"],["\uc81c\uc790\ub9ac\uc5d0\uc11c \uc624\ub978\ucabd \ub3cc\uae30","4"],["\uc67c\ucabd\uc73c\ub85c \ub3cc\uae30", +"5"],["\uc624\ub978\ucabd\uc73c\ub85c \ub3cc\uae30","6"]],value:"1",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW},{type:"Dropdown",options:[["0","0"],["1","1"],["2","2"],["3","3"],["4","4"],["5","5"],["6","6"],["7","7"],["8","8"],["9","9"],["10","10"],["11","11"],["12","12"],["13","13"],["14","14"],["15","15"]],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:["1","15", +{type:"number",params:["0"]}],type:"neobot_all_motor"},paramsKeyMap:{DIRECTION:0,SPEED:1,DURATION:2},"class":"neobot_motor",isNotFor:["neobot"],func:function(b,a){if(a.isStart){if(1==a.timeFlag)return a;delete a.timeFlag;delete a.isStart;Entry.hw.sendQueue.DCL=0;Entry.hw.sendQueue.DCR=0;Entry.engine.isContinue=!1;return a.callReturn()}var c=a.getNumberField("SPEED"),d=a.getNumberField("DIRECTION"),e=a.getNumberValue("DURATION");0>e&&(e=0);switch(d){case 1:Entry.hw.sendQueue.DCL=16+c;Entry.hw.sendQueue.DCR= +16+c;break;case 2:Entry.hw.sendQueue.DCL=32+c;Entry.hw.sendQueue.DCR=32+c;break;case 3:Entry.hw.sendQueue.DCL=32+c;Entry.hw.sendQueue.DCR=16+c;break;case 4:Entry.hw.sendQueue.DCL=16+c;Entry.hw.sendQueue.DCR=32+c;break;case 5:Entry.hw.sendQueue.DCL=0;Entry.hw.sendQueue.DCR=16+c;break;case 6:Entry.hw.sendQueue.DCL=16+c,Entry.hw.sendQueue.DCR=0}if(0===e)return a.callReturn();a.isStart=!0;a.timeFlag=1;setTimeout(function(){a.timeFlag=0},1E3*e);return a}},neobot_stop_all_motor:{color:"#00979D",skeleton:"basic", +statements:[],template:"\uc591\ucabd \ubaa8\ud130\ub97c \uc815\uc9c0 %1",params:[{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null],type:"neobot_stop_all_motor"},"class":"neobot_motor",isNotFor:["neobot"],func:function(b,a){Entry.hw.sendQueue.DCL=0;Entry.hw.sendQueue.DCR=0;return a.callReturn()}},neobot_set_servo:{color:"#00979D",skeleton:"basic",statements:[],template:"%1 \ud3ec\ud2b8\uc758 \uc11c\ubcf4\ubaa8\ud130\ub97c %2 \ub3c4 \uc774\ub3d9 %3",params:[{type:"Dropdown", +options:[["OUT1","1"],["OUT2","2"],["OUT3","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,null,null],type:"neobot_set_servo"},paramsKeyMap:{PORT:0,DEGREE:1},"class":"neobot_output",isNotFor:["neobot"],func:function(b,a){var c=a.getNumberField("PORT"),d=a.getNumberValue("DEGREE");0>d?d=0:180d?d=0:255c&&(c=0);return Entry.Robotis_carCont.postCallReturn(b,[[d,e+(a-1)*f,f,c]],Entry.Robotis_openCM70.delay)}},robotis_openCM70_aux_led_module:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.robotis_common_port_3,"3"],[Lang.Blocks.robotis_common_port_4,"4"],[Lang.Blocks.robotis_common_port_5,"5"],[Lang.Blocks.robotis_common_port_6,"6"]],value:"3",fontSize:11},{type:"Dropdown",options:[[Lang.Blocks.robotis_cm_led_both+Lang.Blocks.robotis_common_off, -"0"],[Lang.Blocks.robotis_cm_led_right+Lang.Blocks.robotis_common_on,"1"],[Lang.Blocks.robotis_cm_led_left+Lang.Blocks.robotis_common_on,"2"],[Lang.Blocks.robotis_cm_led_both+Lang.Blocks.robotis_common_on,"3"]],value:"0",fontSize:11},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,null,null],type:"robotis_openCM70_aux_led_module"},paramsKeyMap:{PORT:0,LED_MODULE:1},"class":"robotis_openCM70_cm",isNotFor:["robotis_openCM70"],func:function(a,b){a=b.getField("PORT", -b);var c=b.getField("LED_MODULE",b),d=Entry.Robotis_openCM70.INSTRUCTION.WRITE,e,f;e=Entry.Robotis_openCM70.CONTROL_TABLE.AUX_LED_MODULE[0];f=Entry.Robotis_openCM70.CONTROL_TABLE.AUX_LED_MODULE[1];return Entry.Robotis_carCont.postCallReturn(b,[[d,e+(a-1)*f,f,c]],Entry.Robotis_openCM70.delay)}},robotis_openCM70_aux_custom:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.robotis_common_port_3,"3"],[Lang.Blocks.robotis_common_port_4,"4"],[Lang.Blocks.robotis_common_port_5, -"5"],[Lang.Blocks.robotis_common_port_6,"6"]],value:"3",fontSize:11},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,{type:"number",params:["0"]},null],type:"robotis_openCM70_aux_custom"},paramsKeyMap:{PORT:0,VALUE:1},"class":"robotis_openCM70_cm",isNotFor:["robotis_openCM70"],func:function(a,b){a=b.getField("PORT",b);var c=b.getNumberValue("VALUE"),d=Entry.Robotis_openCM70.INSTRUCTION.WRITE,e,f;e=Entry.Robotis_openCM70.CONTROL_TABLE.AUX_CUSTOM[0]; -f=Entry.Robotis_openCM70.CONTROL_TABLE.AUX_CUSTOM[1];return Entry.Robotis_carCont.postCallReturn(b,[[d,e+(a-1)*f,f,c]],Entry.Robotis_openCM70.delay)}},robotis_openCM70_cm_custom:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[{type:"number",params:["0"]},{type:"number",params:["0"]},null],type:"robotis_openCM70_cm_custom"},paramsKeyMap:{ADDRESS:0, -VALUE:1},"class":"robotis_openCM70_custom",isNotFor:["robotis_openCM70"],func:function(a,b){a=Entry.Robotis_openCM70.INSTRUCTION.WRITE;var c,d;c=b.getNumberValue("ADDRESS");d=b.getNumberValue("VALUE");return Entry.Robotis_carCont.postCallReturn(b,[[a,c,65535a&&(a=0);createjs.Sound.setVolume(a);return b.callReturn()}},sound_volume_set:{color:"#A4D01D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/sound_03.png",size:12}],events:{},def:{params:[{type:"number",params:["10"]},null],type:"sound_volume_set"},paramsKeyMap:{VALUE:0},"class":"sound_volume",isNotFor:[],func:function(a,b){a=b.getNumberValue("VALUE", -b)/100;1a&&(a=0);createjs.Sound.setVolume(a);return b.callReturn()}},sound_silent_all:{color:"#A4D01D",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/sound_03.png",size:12}],events:{},def:{params:[null],type:"sound_silent_all"},"class":"sound_stop",isNotFor:[],func:function(a,b){createjs.Sound.stop();return b.callReturn()}},get_sounds:{color:"#A4D01D",skeleton:"basic_string_field",statements:[],params:[{type:"DropdownDynamic",value:null,menuName:"sounds",fontSize:11, -arrowColor:EntryStatic.ARROW_COLOR_SOUNDS}],events:{},def:{params:[null],type:"get_sounds"},paramsKeyMap:{VALUE:0},func:function(a,b){return b.getStringField("VALUE")}},sound_something_with_block:{color:"#A4D01D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/sound_03.png",size:12}],events:{},def:{params:[{type:"get_sounds"},null],type:"sound_something_with_block"},paramsKeyMap:{VALUE:0},"class":"sound_play",isNotFor:[],func:function(a,b){var c= -b.getStringValue("VALUE",b);(a=a.parent.getSound(c))&&createjs.Sound.play(a.id);return b.callReturn()}},sound_something_second_with_block:{color:"#A4D01D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/sound_03.png",size:12}],events:{},def:{params:[{type:"get_sounds",id:"95dw"},{type:"number",params:["1"]},null],type:"sound_something_second_with_block"},paramsKeyMap:{VALUE:0,SECOND:1},"class":"sound_play",isNotFor:[], -func:function(a,b){var c=b.getStringValue("VALUE",b),d=b.getNumberValue("SECOND",b);(a=a.parent.getSound(c))&&createjs.Sound.play(a.id,{startTime:0,duration:1E3*d});return b.callReturn()}},sound_something_wait_with_block:{color:"#A4D01D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/sound_03.png",size:12}],events:{},def:{params:[{type:"get_sounds"},null],type:"sound_something_wait_with_block"},paramsKeyMap:{VALUE:0},"class":"sound_wait",isNotFor:[], -func:function(a,b){if(b.isPlay){if(1==b.playState)return b;delete b.playState;delete b.isPlay;return b.callReturn()}b.isPlay=!0;b.playState=1;var c=b.getStringValue("VALUE",b);if(a=a.parent.getSound(c))createjs.Sound.play(a.id),setTimeout(function(){b.playState=0},1E3*a.duration);return b}},sound_something_second_wait_with_block:{color:"#A4D01D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/sound_03.png",size:12}], -events:{},def:{params:[{type:"get_sounds"},{type:"number",params:["1"]},null],type:"sound_something_second_wait_with_block"},paramsKeyMap:{VALUE:0,SECOND:1},"class":"sound_wait",isNotFor:[],func:function(a,b){if(b.isPlay){if(1==b.playState)return b;delete b.isPlay;delete b.playState;return b.callReturn()}b.isPlay=!0;b.playState=1;var c=b.getStringValue("VALUE",b);if(a=a.parent.getSound(c)){var d=createjs.Sound.play(a.id);a=b.getNumberValue("SECOND",b);setTimeout(function(){d.stop();b.playState=0}, -1E3*a);d.addEventListener("complete",function(b){})}return b}},sound_from_to:{color:"#A4D01D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/sound_03.png",size:12}],events:{},def:{params:[{type:"get_sounds"},{type:"text",params:["1"]},{type:"text",params:["10"]},null],type:"sound_from_to"},paramsKeyMap:{VALUE:0,START:1,END:2},"class":"sound_play",isNotFor:[],func:function(a,b){var c= -b.getStringValue("VALUE",b);if(a=a.parent.getSound(c)){var c=1E3*b.getNumberValue("START",b),d=1E3*b.getNumberValue("END",b);createjs.Sound.play(a.id,{startTime:Math.min(c,d),duration:Math.max(c,d)-Math.min(c,d)})}return b.callReturn()}},sound_from_to_and_wait:{color:"#A4D01D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/sound_03.png",size:12}],events:{},def:{params:[{type:"get_sounds"}, -{type:"text",params:["1"]},{type:"text",params:["10"]},null],type:"sound_from_to_and_wait"},paramsKeyMap:{VALUE:0,START:1,END:2},"class":"sound_wait",isNotFor:[],func:function(a,b){if(b.isPlay){if(1==b.playState)return b;delete b.isPlay;delete b.playState;return b.callReturn()}b.isPlay=!0;b.playState=1;var c=b.getStringValue("VALUE",b);if(a=a.parent.getSound(c)){var d=1E3*b.getNumberValue("START",b),e=1E3*b.getNumberValue("END",b),c=Math.min(d,e),d=Math.max(d,e)-c;createjs.Sound.play(a.id,{startTime:c, -duration:d});setTimeout(function(){b.playState=0},d)}return b}},when_run_button_click:{color:"#3BBD70",skeleton:"basic_event",statements:[],params:[{type:"Indicator",img:"block_icon/start_icon_play.png",size:17,position:{x:0,y:-2}}],events:{},def:{params:[null],type:"when_run_button_click"},"class":"event",isNotFor:[],func:function(a,b){return b.callReturn()},event:"start"},press_some_key:{color:"#3BBD70",skeleton:"basic_event",statements:[],params:[{type:"Indicator",img:"block_icon/start_icon_keyboard.png", -size:17,position:{x:0,y:-2}},{type:"Dropdown",options:[["q","81"],["w","87"],["e","69"],["r","82"],["a","65"],["s","83"],["d","68"],["\uc704\ucabd \ud654\uc0b4\ud45c","38"],["\uc544\ub798\ucabd \ud654\uc0b4\ud45c","40"],["\uc67c\ucabd \ud654\uc0b4\ud45c","37"],["\uc624\ub978\ucabd \ud654\uc0b4\ud45c","39"],["\uc5d4\ud130","13"],["\uc2a4\ud398\uc774\uc2a4","32"]],value:"81",fontSize:11},{type:"Indicator",img:"block_icon/start_03.png",size:12}],events:{},def:{params:[null,null,null]},paramsKeyMap:{VALUE:1}, -func:function(a,b){return b.callReturn()}},when_some_key_pressed:{color:"#3BBD70",skeleton:"basic_event",statements:[],params:[{type:"Indicator",img:"block_icon/start_icon_keyboard.png",size:17,position:{x:0,y:-2}},{type:"Keyboard",value:"81"}],events:{},def:{params:[null,"81"],type:"when_some_key_pressed"},paramsKeyMap:{VALUE:1},"class":"event",isNotFor:[],func:function(a,b){return b.callReturn()},event:"keyPress"},mouse_clicked:{color:"#3BBD70",skeleton:"basic_event",statements:[],params:[{type:"Indicator", -img:"block_icon/start_icon_mouse.png",size:17,position:{x:0,y:-2}}],events:{},def:{params:[null],type:"mouse_clicked"},"class":"event",isNotFor:[],func:function(a,b){return b.callReturn()},event:"mouse_clicked"},mouse_click_cancled:{color:"#3BBD70",skeleton:"basic_event",statements:[],params:[{type:"Indicator",img:"block_icon/start_icon_mouse.png",size:17,position:{x:0,y:-2}}],events:{},def:{params:[null],type:"mouse_click_cancled"},"class":"event",isNotFor:[],func:function(a,b){return b.callReturn()}, -event:"mouse_click_cancled"},when_object_click:{color:"#3BBD70",skeleton:"basic_event",statements:[],params:[{type:"Indicator",img:"block_icon/start_icon_mouse.png",size:17,position:{x:0,y:-2}}],events:{},def:{params:[null],type:"when_object_click"},"class":"event",isNotFor:[],func:function(a,b){return b.callReturn()},event:"when_object_click"},when_object_click_canceled:{color:"#3BBD70",skeleton:"basic_event",statements:[],params:[{type:"Indicator",img:"block_icon/start_icon_mouse.png",size:17,position:{x:0, -y:-2}}],events:{},def:{params:[null],type:"when_object_click_canceled"},"class":"event",isNotFor:[],func:function(a,b){return b.callReturn()},event:"when_object_click_canceled"},when_some_key_click:{color:"#3BBD70",skeleton:"basic_event",statements:[],params:[{type:"Indicator",img:"block_icon/start_icon_keyboard.png",size:17,position:{x:0,y:-2}}],events:{},def:{params:[null]},func:function(a,b){return b.callReturn()},event:"keyPress"},when_message_cast:{color:"#3BBD70",skeleton:"basic_event",statements:[], -params:[{type:"Indicator",img:"block_icon/start_icon_signal.png",size:17,position:{x:0,y:-2}},{type:"DropdownDynamic",value:null,menuName:"messages",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_START}],events:{dataAdd:[function(a){var b=Entry.variableContainer;b&&b.addRef("_messageRefs",a)}],viewDestroy:[function(a){var b=Entry.variableContainer;b&&b.removeRef("_messageRefs",a)}]},def:{params:[null,null],type:"when_message_cast"},paramsKeyMap:{VALUE:1},"class":"message",isNotFor:["message"],func:function(a, -b){return b.callReturn()},event:"when_message_cast"},message_cast:{color:"#3BBD70",skeleton:"basic",statements:[],params:[{type:"DropdownDynamic",value:null,menuName:"messages",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_START},{type:"Indicator",img:"block_icon/start_03.png",size:12}],events:{dataAdd:[function(a){var b=Entry.variableContainer;b&&b.addRef("_messageRefs",a)}],viewDestroy:[function(a){var b=Entry.variableContainer;b&&b.removeRef("_messageRefs",a)}]},def:{params:[null,null],type:"message_cast"}, -paramsKeyMap:{VALUE:0},"class":"message",isNotFor:["message"],func:function(a,b){a=b.getField("VALUE",b);var c=Entry.isExist(a,"id",Entry.variableContainer.messages_);if("null"==a||!c)throw Error("value can not be null or undefined");Entry.container.mapEntityIncludeCloneOnScene(Entry.engine.raiseKeyEvent,["when_message_cast",a]);return b.callReturn()}},message_cast_wait:{color:"#3BBD70",skeleton:"basic",statements:[],params:[{type:"DropdownDynamic",value:null,menuName:"messages",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_START}, -{type:"Indicator",img:"block_icon/start_03.png",size:12}],events:{dataAdd:[function(a){var b=Entry.variableContainer;b&&b.addRef("_messageRefs",a)}],dataDestroy:[function(a){var b=Entry.variableContainer;b&&b.removeRef("_messageRefs",a)}]},def:{params:[null,null],type:"message_cast_wait"},paramsKeyMap:{VALUE:0},"class":"message",isNotFor:["message"],func:function(a,b){if(b.runningScript){a=b.runningScript;for(var c=a.length,d=0;da.array_.length)throw Error("can not remove value from array");a.array_.splice(d-1,1);a.updateView();return b.callReturn()}},insert_value_to_list:{color:"#E457DC",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"DropdownDynamic",value:null,menuName:"lists",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_VARIABLE},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/variable_03.png",size:12}],events:{dataAdd:[function(a){var b=Entry.variableContainer; -b&&b.addRef("_variableRefs",a)}],dataDestroy:[function(a){var b=Entry.variableContainer;b&&b.removeRef("_variableRefs",a)}]},def:{params:[{type:"text",params:["10"]},null,{type:"text",params:["1"]},null],type:"insert_value_to_list"},paramsKeyMap:{DATA:0,LIST:1,INDEX:2},"class":"list",isNotFor:["list","listNotExist"],func:function(a,b){var c=b.getField("LIST",b),d=b.getValue("DATA",b),e=b.getValue("INDEX",b);a=Entry.variableContainer.getList(c,a);if(!a.array_||isNaN(e)||0==e||e>a.array_.length+1)throw Error("can not insert value to array"); -a.array_.splice(e-1,0,{data:d});a.updateView();return b.callReturn()}},change_value_list_index:{color:"#E457DC",skeleton:"basic",statements:[],params:[{type:"DropdownDynamic",value:null,menuName:"lists",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_VARIABLE},{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/variable_03.png",size:12}],events:{dataAdd:[function(a){var b=Entry.variableContainer;b&&b.addRef("_variableRefs",a)}],dataDestroy:[function(a){var b= -Entry.variableContainer;b&&b.removeRef("_variableRefs",a)}]},def:{params:[null,{type:"text",params:["1"]},{type:"text",params:["10"]},null],type:"change_value_list_index"},paramsKeyMap:{LIST:0,INDEX:1,DATA:2},"class":"list",isNotFor:["list","listNotExist"],func:function(a,b){var c=b.getField("LIST",b),d=b.getValue("DATA",b),e=b.getValue("INDEX",b);a=Entry.variableContainer.getList(c,a);if(!a.array_||isNaN(e)||e>a.array_.length)throw Error("can not insert value to array");a.array_[e-1].data=d;a.updateView(); -return b.callReturn()}},value_of_index_from_list:{color:"#E457DC",skeleton:"basic_string_field",statements:[],params:[{type:"Text",text:Lang.Blocks.VARIABLE_value_of_index_from_list_1,color:"white"},{type:"DropdownDynamic",value:null,menuName:"lists",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_VARIABLE},{type:"Text",text:Lang.Blocks.VARIABLE_value_of_index_from_list_2,color:"white"},{type:"Block",accept:"string"},{type:"Text",text:Lang.Blocks.VARIABLE_value_of_index_from_list_3,color:"white"}], -events:{dataAdd:[function(a){var b=Entry.variableContainer;b&&b.addRef("_variableRefs",a)}],dataDestroy:[function(a){var b=Entry.variableContainer;b&&b.removeRef("_variableRefs",a)}]},def:{params:[null,null,null,{type:"number",params:["1"]}],type:"value_of_index_from_list"},paramsKeyMap:{LIST:1,INDEX:3},"class":"list_element",isNotFor:["list","listNotExist"],func:function(a,b){var c=b.getField("LIST",b);b=b.getValue("INDEX",b);a=Entry.variableContainer.getList(c,a);b=Entry.getListRealIndex(b,a);if(!a.array_|| -isNaN(b)||b>a.array_.length)throw Error("can not insert value to array");return a.array_[b-1].data}},length_of_list:{color:"#E457DC",skeleton:"basic_string_field",statements:[],params:[{type:"Text",text:Lang.Blocks.VARIABLE_length_of_list_1,color:"white"},{type:"DropdownDynamic",value:null,menuName:"lists",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_VARIABLE},{type:"Text",text:Lang.Blocks.VARIABLE_length_of_list_2,color:"white"}],events:{dataAdd:[function(a){var b=Entry.variableContainer;b&&b.addRef("_variableRefs", -a)}],dataDestroy:[function(a){var b=Entry.variableContainer;b&&b.removeRef("_variableRefs",a)}]},def:{params:[null,null,null],type:"length_of_list"},paramsKeyMap:{LIST:1},"class":"list",isNotFor:["list","listNotExist"],func:function(a,b){b=b.getField("LIST",b);return Entry.variableContainer.getList(b,a).array_.length}},show_list:{color:"#E457DC",skeleton:"basic",statements:[],params:[{type:"DropdownDynamic",value:null,menuName:"lists",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_VARIABLE},{type:"Indicator", -img:"block_icon/variable_03.png",size:12}],events:{dataAdd:[function(a){var b=Entry.variableContainer;b&&b.addRef("_variableRefs",a)}],dataDestroy:[function(a){var b=Entry.variableContainer;b&&b.removeRef("_variableRefs",a)}]},def:{params:[null,null],type:"show_list"},paramsKeyMap:{LIST:0},"class":"list_visibility",isNotFor:["list","listNotExist"],func:function(a,b){a=b.getField("LIST",b);Entry.variableContainer.getList(a).setVisible(!0);return b.callReturn()}},hide_list:{color:"#E457DC",skeleton:"basic", -statements:[],params:[{type:"DropdownDynamic",value:null,menuName:"lists",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_VARIABLE},{type:"Indicator",img:"block_icon/variable_03.png",size:12}],events:{dataAdd:[function(a){var b=Entry.variableContainer;b&&b.addRef("_variableRefs",a)}],dataDestroy:[function(a){var b=Entry.variableContainer;b&&b.removeRef("_variableRefs",a)}]},def:{params:[null,null],type:"hide_list"},paramsKeyMap:{LIST:0},"class":"list_visibility",isNotFor:["list","listNotExist"],func:function(a, -b){a=b.getField("LIST",b);Entry.variableContainer.getList(a).setVisible(!1);return b.callReturn()}},options_for_list:{color:"#E457DC",skeleton:"basic_string_field",statements:[],params:[{type:"Dropdown",options:[["\uccab\ubc88\uc9f8","FIRST"],["\ub9c8\uc9c0\ub9c9","LAST"],["\ubb34\uc791\uc704","RANDOM"]],value:"FIRST",fontSize:11}],events:{},def:{params:[null]},paramsKeyMap:{OPERATOR:0},func:function(a,b){return b.getField("OPERATOR",b)}},set_visible_answer:{color:"#E457DC",skeleton:"basic",statements:[], -params:[{type:"Dropdown",options:[[Lang.Blocks.CALC_timer_visible_show,"SHOW"],[Lang.Blocks.CALC_timer_visible_hide,"HIDE"]],value:"SHOW",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_VARIABLE},{type:"Indicator",img:"block_icon/variable_03.png",size:12}],events:{viewAdd:[function(a){Entry.container&&Entry.container.showProjectAnswer()}],viewDestroy:[function(a){Entry.container&&Entry.container.hideProjectAnswer(a)}]},def:{params:["HIDE",null],type:"set_visible_answer"},paramsKeyMap:{BOOL:0},"class":"ask", -isNotFor:[],func:function(a,b){"HIDE"==b.getField("BOOL",b)?Entry.container.inputValue.setVisible(!1):Entry.container.inputValue.setVisible(!0);return b.callReturn()}},is_included_in_list:{color:"#E457DC",skeleton:"basic_boolean_field",statements:[],params:[{type:"Text",text:Lang.Blocks.VARIABLE_is_included_in_list_1,color:"white"},{type:"DropdownDynamic",value:null,menuName:"lists",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_VARIABLE},{type:"Text",text:Lang.Blocks.VARIABLE_is_included_in_list_2, -color:"white"},{type:"Block",accept:"string"},{type:"Text",text:Lang.Blocks.VARIABLE_is_included_in_list_3,color:"white"}],events:{dataAdd:[function(a){var b=Entry.variableContainer;b&&b.addRef("_variableRefs",a)}],dataDestroy:[function(a){var b=Entry.variableContainer;b&&b.removeRef("_variableRefs",a)}]},def:{params:[null,null,null,{type:"text",params:["10"]},null],type:"is_included_in_list"},paramsKeyMap:{LIST:1,DATA:3},"class":"list",isNotFor:["list","listNotExist"],func:function(a,b){var c=b.getField("LIST", -b);b=b.getStringValue("DATA",b);a=Entry.variableContainer.getList(c,a);if(!a)return!1;a=a.array_;for(var c=0,d=a.length;ch&&(h=Math.round(h-155),f=-h,g=0,Entry.dplay.vel_value=f);if(b.isStart){if(1==b.timeFlag)return Entry.hw.setDigitalPortValue(3,0),Entry.hw.setDigitalPortValue(5,0),Entry.hw.setDigitalPortValue(6,0),Entry.hw.setDigitalPortValue(11,0),b;if(2==b.timeFlag)return Entry.hw.setDigitalPortValue(a,f),Entry.hw.setDigitalPortValue(c,g),Entry.hw.setDigitalPortValue(d,f),Entry.hw.setDigitalPortValue(e,g),delete b.isStart,delete b.timeFlag, -Entry.engine.isContinue=!1,b.callReturn()}else{b.isStart=!0;b.timeFlag=1;var k=setTimeout(function(){b.timeFlag=2;Entry.dplay.removeTimeout(k)},50);Entry.dplay.timeouts.push(k);return b}}},dplay_buzzer:{color:"#00979D",fontColor:"#FFF",skeleton:"basic",statements:[],template:"\ub514\uc9c0\ud138 10\ubc88 \ubd80\uc800\ub97c %1 %2 %3 \ubc15\uc790\ub85c \uc5f0\uc8fc\ud558\uae30",params:[{type:"Dropdown",options:[["\ub3c4","1"],["\ub3c4#","2"],["\ub808","3"],["\ubbf8b","4"],["\ubbf8","5"],["\ud30c","6"], -["\ud30c#","7"],["\uc194","8"],["\uc194#","9"],["\ub77c","10"],["\uc2dcb","11"],["\uc2dc","12"],["\ubb34\uc74c","100"]],value:"1",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW},{type:"Dropdown",options:[["1","1"],["2","2"],["3","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:["1","1",{type:"text",params:["0.5"]},null],type:"dplay_buzzer"},paramsKeyMap:{NOTE:0,OCTAVE:1, -VALUE:2},"class":"dplay_set",isNotFor:["dplay"],func:function(a,b){if(b.isStart){if(1==b.timeFlag)return b;Entry.hw.setDigitalPortValue(10,100);delete b.isStart;delete b.timeFlag;Entry.engine.isContinue=!1;return b.callReturn()}a=b.getNumberField("NOTE",b);var c=b.getNumberField("OCTAVE",b),d=b.getNumberValue("VALUE"),c=a+12*(c-1),d=6E4*d/60;b.isStart=!0;b.timeFlag=1;100==a?Entry.hw.setDigitalPortValue(10,100):Entry.hw.setDigitalPortValue(10,c);if(100m?(l=Math.round(m-155),f=-l,g=0,Entry.dplay.Left_value=f):0==m&&(g=f=0,Entry.dplay.Left_value=0));"2"==n&&(d=6,e=11,0m?(l=Math.round(m-155),h=-l,k=0,Entry.dplay.Right_value=h):0==m&&(k=h=0,Entry.dplay.Right_value=h));"3"==n&&(a=3,c=5,d=6,e=11,0m?(l=Math.round(m-155),f=-l,g=0,h=-l,k=0,Entry.dplay.Left_value=f,Entry.dplay.Right_value=h):0==m&&(k=h=g=f=0,Entry.dplay.Left_value=0,Entry.dplay.Right_value=0));if(b.isStart){if(1==b.timeFlag)return Entry.hw.setDigitalPortValue(3,0),Entry.hw.setDigitalPortValue(5,0),Entry.hw.setDigitalPortValue(6,0),Entry.hw.setDigitalPortValue(11,0),b;if(2==b.timeFlag)return Entry.hw.setDigitalPortValue(a,f),Entry.hw.setDigitalPortValue(c,g),Entry.hw.setDigitalPortValue(d,k),Entry.hw.setDigitalPortValue(e, -h),delete b.isStart,delete b.timeFlag,Entry.engine.isContinue=!1,b.callReturn()}else{b.isStart=!0;b.timeFlag=1;var q=setTimeout(function(){b.timeFlag=2;Entry.dplay.removeTimeout(q)},50);Entry.dplay.timeouts.push(q);return b}}},dplay_robot_speed_set:{color:"#00979D",fontColor:"#FFF",skeleton:"basic",statements:[],template:"\uc624\ub978\ucabd \ubc14\ud034 %1 \uc67c\ucabd \ubc14\ud034 %2(\uc73c)\ub85c \uc815\ud558\uae30 %3",params:[{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Indicator", -img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[{type:"text",params:["100"]},{type:"text",params:["100"]},null],type:"dplay_robot_speed_set"},paramsKeyMap:{R_VALUE:0,L_VALUE:1},"class":"dplay_robot",isNotFor:["dplay"],func:function(a,b){var c=a=0,d=0,e=0,f=0,f=0,f=b.getNumberValue("L_VALUE",b),f=Math.max(f,-100),f=Math.min(f,100);0f?(f=Math.round(f-155),a=-f,c=0,Entry.dplay.Left_value=a):0==f&&(c=a=0,Entry.dplay.Left_value= -0);f=b.getNumberValue("R_VALUE",b);f=Math.max(f,-100);f=Math.min(f,100);0f?(f=Math.round(f-155),d=-f,e=0,Entry.dplay.Right_value=d):0==f&&(e=d=0,Entry.dplay.Right_value=0);if(b.isStart){if(1==b.timeFlag)return Entry.hw.setDigitalPortValue(3,0),Entry.hw.setDigitalPortValue(5,0),Entry.hw.setDigitalPortValue(6,0),Entry.hw.setDigitalPortValue(11,0),b;if(2==b.timeFlag)return Entry.hw.setDigitalPortValue(3,a),Entry.hw.setDigitalPortValue(5,c), -Entry.hw.setDigitalPortValue(6,e),Entry.hw.setDigitalPortValue(11,d),delete b.isStart,delete b.timeFlag,Entry.engine.isContinue=!1,b.callReturn()}else{b.isStart=!0;b.timeFlag=1;var g=setTimeout(function(){b.timeFlag=2;Entry.dplay.removeTimeout(g)},50);Entry.dplay.timeouts.push(g);return b}}},dplay_robot_stop:{color:"#00979D",fontColor:"#FFF",skeleton:"basic",statements:[],template:"\ub85c\ubd07\uc744 \uc815\uc9c0\ud558\uae30 %1",params:[{type:"Indicator",img:"block_icon/hardware_03.png",size:12}], -events:{},def:{params:[null],type:"dplay_robot_stop"},paramsKeyMap:{},"class":"dplay_robot",isNotFor:["dplay"],func:function(a,b){Entry.hw.setDigitalPortValue(3,0);Entry.hw.setDigitalPortValue(5,0);Entry.hw.setDigitalPortValue(11,0);Entry.hw.setDigitalPortValue(6,0);return b.callReturn()}},nemoino_get_number_sensor_value:{parent:"arduino_get_number_sensor_value",isNotFor:["nemoino"],def:{params:[{type:"arduino_get_sensor_number"}],type:"nemoino_get_number_sensor_value"},"class":"arduino_value"},nemoino_get_digital_value:{parent:"arduino_get_digital_value", -isNotFor:["nemoino"],def:{params:[{type:"arduino_get_port_number"}],type:"nemoino_get_digital_value"},"class":"arduino_value"},nemoino_toggle_led:{parent:"arduino_toggle_led",isNotFor:["nemoino"],def:{params:[{type:"arduino_get_port_number"},null,null],type:"nemoino_toggle_led"},"class":"arduino_set"},nemoino_toggle_pwm:{parent:"arduino_toggle_pwm",isNotFor:["nemoino"],def:{params:[{type:"arduino_get_pwm_port_number"},{type:"arduino_text",params:["255"]},null],type:"nemoino_toggle_pwm"},"class":"arduino_set"}, -nemoino_convert_scale:{parent:"arduino_convert_scale",isNotFor:["nemoino"],def:{params:[{type:"arduino_get_number_sensor_value",params:[{type:"arduino_get_sensor_number"}]},{type:"number",params:["0"]},{type:"number",params:["1023"]},{type:"number",params:["0"]},{type:"number",params:["100"]}],type:"nemoino_convert_scale"},"class":"arduino"},sensorBoard_get_number_sensor_value:{parent:"arduino_get_number_sensor_value",isNotFor:["sensorBoard"],def:{params:[{type:"arduino_get_sensor_number"}],type:"sensorBoard_get_number_sensor_value"}, -"class":"arduino_value"},sensorBoard_get_digital_value:{parent:"arduino_get_digital_value",isNotFor:["sensorBoard"],def:{params:[{type:"arduino_get_port_number"}],type:"sensorBoard_get_digital_value"},"class":"arduino_value"},sensorBoard_toggle_led:{parent:"arduino_toggle_led",isNotFor:["sensorBoard"],def:{params:[{type:"arduino_get_port_number"},null,null],type:"sensorBoard_toggle_led"},"class":"arduino_set"},sensorBoard_toggle_pwm:{parent:"arduino_toggle_pwm",isNotFor:["sensorBoard"],def:{params:[{type:"arduino_get_pwm_port_number"}, -{type:"arduino_text",params:["255"]},null],type:"sensorBoard_toggle_pwm"},"class":"arduino_set"},sensorBoard_convert_scale:{parent:"arduino_convert_scale",isNotFor:["sensorBoard"],def:{params:[{type:"arduino_get_number_sensor_value",params:[{type:"arduino_get_sensor_number",id:"bl5e"}]},{type:"number",params:["0"]},{type:"number",params:["1023"]},{type:"number",params:["0"]},{type:"number",params:["100"]}],type:"sensorBoard_convert_scale"},"class":"arduino"},CODEino_get_number_sensor_value:{parent:"arduino_get_number_sensor_value", -isNotFor:["CODEino"],def:{params:[{type:"arduino_get_sensor_number"}],type:"CODEino_get_number_sensor_value"},"class":"arduino_value"},CODEino_get_digital_value:{parent:"arduino_get_digital_value",isNotFor:["CODEino"],def:{params:[{type:"arduino_get_port_number"}],type:"CODEino_get_digital_value"},"class":"arduino_value"},CODEino_toggle_led:{parent:"arduino_toggle_led",isNotFor:["CODEino"],def:{params:[{type:"arduino_get_port_number"},null,null],type:"CODEino_toggle_led"},"class":"arduino_set"},CODEino_toggle_pwm:{parent:"arduino_toggle_pwm", -isNotFor:["CODEino"],def:{params:[{type:"arduino_get_pwm_port_number"},{type:"arduino_text",params:["255"]},null],type:"CODEino_toggle_pwm"},"class":"arduino_set"},CODEino_convert_scale:{parent:"arduino_convert_scale",isNotFor:["CODEino"],def:{params:[{type:"arduino_get_number_sensor_value",params:[{type:"arduino_get_sensor_number"}]},{type:"number",params:["0"]},{type:"number",params:["1023"]},{type:"number",params:["0"]},{type:"number",params:["100"]}],type:"CODEino_convert_scale"},"class":"arduino"}, -ardublock_get_number_sensor_value:{parent:"arduino_get_number_sensor_value",isNotFor:["ardublock"],def:{params:[{type:"arduino_get_sensor_number"}],type:"ardublock_get_number_sensor_value"},"class":"arduino_value"},ardublock_get_digital_value:{parent:"arduino_get_digital_value",isNotFor:["ardublock"],def:{params:[{type:"arduino_get_port_number"}],type:"ardublock_get_digital_value"},"class":"arduino_value"},ardublock_toggle_led:{parent:"arduino_toggle_led",isNotFor:["ardublock"],def:{params:[{type:"arduino_get_port_number"}, -null,null],type:"ardublock_toggle_led"},"class":"arduino_set"},ardublock_toggle_pwm:{parent:"arduino_toggle_pwm",isNotFor:["ardublock"],def:{params:[{type:"arduino_get_pwm_port_number"},{type:"arduino_text",params:["255"]},null],type:"ardublock_toggle_pwm"},"class":"arduino_set"},ardublock_convert_scale:{parent:"arduino_convert_scale",isNotFor:["ardublock"],def:{params:[{type:"arduino_get_number_sensor_value",params:[{type:"arduino_get_sensor_number"}]},{type:"number",params:["0"]},{type:"number", -params:["1023"]},{type:"number",params:["0"]},{type:"number",params:["100"]}],type:"ardublock_convert_scale"},"class":"arduino"},joystick_get_number_sensor_value:{parent:"arduino_get_number_sensor_value",isNotFor:["joystick"],def:{params:[{type:"arduino_get_sensor_number"}],type:"joystick_get_number_sensor_value"},"class":"arduino_value"},joystick_get_digital_value:{parent:"arduino_get_digital_value",isNotFor:["joystick"],def:{params:[{type:"arduino_get_port_number"}],type:"joystick_get_digital_value"}, -"class":"arduino_value"},joystick_toggle_led:{parent:"arduino_toggle_led",isNotFor:["joystick"],def:{params:[{type:"arduino_get_port_number"},null,null],type:"joystick_toggle_led"},"class":"arduino_set"},joystick_toggle_pwm:{parent:"arduino_toggle_pwm",isNotFor:["joystick"],def:{params:[{type:"arduino_get_pwm_port_number"},{type:"arduino_text",params:["255"]},null],type:"joystick_toggle_pwm"},"class":"arduino_set"},joystick_convert_scale:{parent:"arduino_convert_scale",isNotFor:["joystick"],def:{params:[{type:"arduino_get_number_sensor_value", -params:[{type:"arduino_get_sensor_number"}]},{type:"number",params:["0"]},{type:"number",params:["1023"]},{type:"number",params:["0"]},{type:"number",params:["100"]}],type:"joystick_convert_scale"},"class":"arduino"},ebs_if:{parent:"_if",def:{type:"_if",params:[{type:"reach_something",params:[null,"wall"]}]}},ebs_if2:{parent:"_if",def:{type:"_if",params:[{type:"reach_something",params:[null,"cwz5"]}]}}}; -(function(){for(var a in Entry.block){var b=Entry.block[a];if(b.parent){var c=function(){};c.prototype=Entry.block[b.parent];var c=new c,d;for(d in b)c[d]=b[d];Entry.block[a]=c}}})();"object"==typeof exports&&(exports.block=Entry.block);Entry.BlockMenu=function(a,b,c,d){Entry.Model(this,!1);this._align=b||"CENTER";this._scroll=void 0!==d?d:!1;this._bannedClass=[];this._categories=[];this.suffix="blockMenu";a="string"===typeof a?$("#"+a):$(a);if("DIV"!==a.prop("tagName"))return console.error("Dom is not div element");this.view=a;this.visible=!0;this._svgId="blockMenu"+(new Date).getTime();this._clearCategory();this._categoryData=c;this._generateView(c);this._splitters=[];this.setWidth();this.svg=Entry.SVG(this._svgId);Entry.Utils.addFilters(this.svg, -this.suffix);b=Entry.Utils.addBlockPattern(this.svg,this.suffix);this.patternRect=b.rect;this.pattern=b.pattern;this.svgGroup=this.svg.elem("g");this.svgThreadGroup=this.svgGroup.elem("g");this.svgThreadGroup.board=this;this.svgBlockGroup=this.svgGroup.elem("g");this.svgBlockGroup.board=this;this.changeEvent=new Entry.Event(this);c&&this._generateCategoryCodes(c);this.observe(this,"_handleDragBlock",["dragBlock"]);this._scroll&&(this._scroller=new Entry.BlockMenuScroller(this),this._addControl(a)); -Entry.documentMousedown&&Entry.documentMousedown.attach(this,this.setSelectedBlock);this._categoryCodes&&Entry.keyPressed&&Entry.keyPressed.attach(this,this._captureKeyEvent);Entry.windowResized&&(a=_.debounce(this.updateOffset,200),Entry.windowResized.attach(this,a))}; -(function(a){a.schema={code:null,dragBlock:null,closeBlock:null,selectedBlockView:null};a._generateView=function(b){var a=this.view,d=this;b&&(this._categoryCol=Entry.Dom("ul",{class:"entryCategoryListWorkspace",parent:a}),this._generateCategoryView(b));this.blockMenuContainer=Entry.Dom("div",{"class":"blockMenuContainer",parent:a});this.svgDom=Entry.Dom($(''),{parent:this.blockMenuContainer});this.svgDom.mouseenter(function(b){d._scroller&& -d._scroller.setOpacity(1);b=d.workspace.selectedBlockView;!Entry.playground||Entry.playground.resizing||b&&b.dragMode===Entry.DRAG_MODE_DRAG||(Entry.playground.focusBlockMenu=!0,b=d.svgGroup.getBBox(),b=b.width+b.x+64,b>Entry.interfaceState.menuWidth&&(this.widthBackup=Entry.interfaceState.menuWidth-64,$(this).stop().animate({width:b-62},200)))});this.svgDom.mouseleave(function(b){Entry.playground&&!Entry.playground.resizing&&(d._scroller&&d._scroller.setOpacity(0),(b=this.widthBackup)&&$(this).stop().animate({width:b}, -200),delete this.widthBackup,delete Entry.playground.focusBlockMenu)});$(window).scroll(function(){d.updateOffset()})};a.changeCode=function(b){if(!(b instanceof Entry.Code))return console.error("You must inject code instance");this.codeListener&&this.code.changeEvent.detach(this.codeListener);var a=this;this.set({code:b});this.codeListener=this.code.changeEvent.attach(this,function(){a.changeEvent.notify()});b.createView(this);this.align()};a.bindCodeView=function(b){this.svgBlockGroup.remove(); -this.svgThreadGroup.remove();this.svgBlockGroup=b.svgBlockGroup;this.svgThreadGroup=b.svgThreadGroup;this.svgGroup.appendChild(this.svgThreadGroup);this.svgGroup.appendChild(this.svgBlockGroup);this._scroller&&this.svgGroup.appendChild(this._scroller.svgGroup)};a.align=function(b){var a=this.code;if(a){this._clearSplitters();a.view&&!b&&a.view.reDraw();b=a.getThreads();for(var a=10,d="LEFT"==this._align?10:this.svgDom.width()/2,e,f=0,g=b.length;fthis._bannedClass.indexOf(b)&&this._bannedClass.push(b);this.align(a)};a.unbanClass=function(b,a){b=this._bannedClass.indexOf(b);-1a&&(b.preventDefault(),this.selectMenu(a-49))};a.setPatternRectFill=function(b){this.patternRect.attr({fill:b});this.pattern.attr({style:""})};a.disablePattern=function(){this.pattern.attr({style:"display: none"})};a._clearCategory=function(){this._selectedCategoryView=null;this._categories=[];var b=this._categoryElems,a;for(a in b)b[a].remove();this._categoryElems={};b=this._categoryCodes;for(a in b){var d=b[a];d.constructor==Entry.Code&& -d.clear()}this._categoryCodes=null};a.setCategoryData=function(b){this._clearCategory();this._categoryData=b;this._generateCategoryView(b);this._generateCategoryCodes(b)};a._generateCategoryView=function(b){if(b)for(var a=0;a=a?this.setVisible(!1):this.setVisible(!0)};a._reset=function(){this.vY=0;this.vScrollbar.attr({y:this.vY});this.resizeScrollBar()};a.onMouseDown=function(b){function a(b){b.stopPropagation&&b.stopPropagation();b.preventDefault&&b.preventDefault();b=b.originalEvent&&b.originalEvent.touches?b.originalEvent.touches[0]:b;var c=e.dragInstance; -e.scroll(b.pageY-c.offsetY);c.set({offsetY:b.pageY})}function d(b){$(document).unbind(".scroll");delete e.dragInstance}var e=this;b.stopPropagation&&b.stopPropagation();b.preventDefault&&b.preventDefault();if(0===b.button||b.originalEvent&&b.originalEvent.touches){Entry.documentMousedown&&Entry.documentMousedown.notify(b);var f;f=b.originalEvent&&b.originalEvent.touches?b.originalEvent.touches[0]:b;var g=$(document);g.bind("mousemove.scroll",a);g.bind("mouseup.scroll",d);g.bind("touchmove.scroll", -a);g.bind("touchend.scroll",d);e.dragInstance=new Entry.DragInstance({startY:f.pageY,offsetY:f.pageY})}b.stopPropagation()};a._addControl=function(){$(this.vScrollbar).bind("mousedown touchstart",this.mouseHandler)}})(Entry.BlockMenuScroller.prototype);Entry.BlockView=function(a,b,c){Entry.Model(this,!1);this.block=a;this._lazyUpdatePos=_.debounce(a._updatePos.bind(a),200);this._board=b;this._observers=[];this.set(a);this.svgGroup=b.svgBlockGroup.elem("g");this._schema=Entry.block[a.type];this._schema.changeEvent&&(this._schemaChangeEvent=this._schema.changeEvent.attach(this,this._updateSchema));var d=this._skeleton=Entry.skeleton[this._schema.skeleton];this._contents=[];this._statements=[];this.magnet={};this._paramMap={};d.magnets&&d.magnets(this).next&& -(this.svgGroup.nextMagnet=this.block,this._nextGroup=this.svgGroup.elem("g"),this._observers.push(this.observe(this,"_updateMagnet",["contentHeight"])));this.isInBlockMenu=this.getBoard()instanceof Entry.BlockMenu;var e=this;this.mouseHandler=function(){var b=e.block.events;b&&b.mousedown&&b.mousedown.forEach(function(b){b(e)});e.onMouseDown.apply(e,arguments)};this._startRender(a,c);this._observers.push(this.block.observe(this,"_setMovable",["movable"]));this._observers.push(this.block.observe(this, +size:12}],events:{},def:{params:[null,{type:"number",params:["1"]},null],type:"robotis_openCM70_cm_buzzer_index"},paramsKeyMap:{CM_BUZZER_INDEX:0,CM_BUZZER_TIME:1},"class":"robotis_openCM70_cm",isNotFor:["robotis_openCM70"],func:function(b,a){var c=a.getField("CM_BUZZER_INDEX",a),d=a.getNumberValue("CM_BUZZER_TIME",a),e=Entry.Robotis_openCM70.INSTRUCTION.WRITE,f=0,g=0,h=0,k=0,l=0,f=Entry.Robotis_openCM70.CONTROL_TABLE.CM_BUZZER_TIME[0],g=Entry.Robotis_openCM70.CONTROL_TABLE.CM_BUZZER_TIME[1],h=parseInt(10* +d);50d&&(d=0);return Entry.Robotis_carCont.postCallReturn(a,[[e,f+(c-1)*g,g,d]],Entry.Robotis_openCM70.delay)}},robotis_openCM70_aux_led_module:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.robotis_common_port_3,"3"],[Lang.Blocks.robotis_common_port_4,"4"],[Lang.Blocks.robotis_common_port_5,"5"],[Lang.Blocks.robotis_common_port_6,"6"]],value:"3",fontSize:11},{type:"Dropdown",options:[[Lang.Blocks.robotis_cm_led_both+ +Lang.Blocks.robotis_common_off,"0"],[Lang.Blocks.robotis_cm_led_right+Lang.Blocks.robotis_common_on,"1"],[Lang.Blocks.robotis_cm_led_left+Lang.Blocks.robotis_common_on,"2"],[Lang.Blocks.robotis_cm_led_both+Lang.Blocks.robotis_common_on,"3"]],value:"0",fontSize:11},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,null,null],type:"robotis_openCM70_aux_led_module"},paramsKeyMap:{PORT:0,LED_MODULE:1},"class":"robotis_openCM70_cm",isNotFor:["robotis_openCM70"],func:function(b, +a){var c=a.getField("PORT",a),d=a.getField("LED_MODULE",a),e=Entry.Robotis_openCM70.INSTRUCTION.WRITE,f=0,g=0,f=Entry.Robotis_openCM70.CONTROL_TABLE.AUX_LED_MODULE[0],g=Entry.Robotis_openCM70.CONTROL_TABLE.AUX_LED_MODULE[1];return Entry.Robotis_carCont.postCallReturn(a,[[e,f+(c-1)*g,g,d]],Entry.Robotis_openCM70.delay)}},robotis_openCM70_aux_custom:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.robotis_common_port_3,"3"],[Lang.Blocks.robotis_common_port_4, +"4"],[Lang.Blocks.robotis_common_port_5,"5"],[Lang.Blocks.robotis_common_port_6,"6"]],value:"3",fontSize:11},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,{type:"number",params:["0"]},null],type:"robotis_openCM70_aux_custom"},paramsKeyMap:{PORT:0,VALUE:1},"class":"robotis_openCM70_cm",isNotFor:["robotis_openCM70"],func:function(b,a){var c=a.getField("PORT",a),d=a.getNumberValue("VALUE"),e=Entry.Robotis_openCM70.INSTRUCTION.WRITE, +f=0,g=0,f=Entry.Robotis_openCM70.CONTROL_TABLE.AUX_CUSTOM[0],g=Entry.Robotis_openCM70.CONTROL_TABLE.AUX_CUSTOM[1];return Entry.Robotis_carCont.postCallReturn(a,[[e,f+(c-1)*g,g,d]],Entry.Robotis_openCM70.delay)}},robotis_openCM70_cm_custom:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[{type:"number",params:["0"]},{type:"number",params:["0"]},null], +type:"robotis_openCM70_cm_custom"},paramsKeyMap:{ADDRESS:0,VALUE:1},"class":"robotis_openCM70_custom",isNotFor:["robotis_openCM70"],func:function(b,a){var c=Entry.Robotis_openCM70.INSTRUCTION.WRITE,d=0,e=0,d=a.getNumberValue("ADDRESS"),e=a.getNumberValue("VALUE");return Entry.Robotis_carCont.postCallReturn(a,[[c,d,65535c&&(c=0);createjs.Sound.setVolume(c);return a.callReturn()}},sound_volume_set:{color:"#A4D01D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/sound_03.png",size:12}],events:{},def:{params:[{type:"number",params:["10"]},null],type:"sound_volume_set"}, +paramsKeyMap:{VALUE:0},"class":"sound_volume",isNotFor:[],func:function(b,a){var c=a.getNumberValue("VALUE",a)/100;1c&&(c=0);createjs.Sound.setVolume(c);return a.callReturn()}},sound_silent_all:{color:"#A4D01D",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/sound_03.png",size:12}],events:{},def:{params:[null],type:"sound_silent_all"},"class":"sound_stop",isNotFor:[],func:function(b,a){createjs.Sound.stop();return a.callReturn()}},get_sounds:{color:"#A4D01D",skeleton:"basic_string_field", +statements:[],params:[{type:"DropdownDynamic",value:null,menuName:"sounds",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_SOUNDS}],events:{},def:{params:[null],type:"get_sounds"},paramsKeyMap:{VALUE:0},func:function(b,a){return a.getStringField("VALUE")}},sound_something_with_block:{color:"#A4D01D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/sound_03.png",size:12}],events:{},def:{params:[{type:"get_sounds"},null],type:"sound_something_with_block"}, +paramsKeyMap:{VALUE:0},"class":"sound_play",isNotFor:[],func:function(b,a){var c=a.getStringValue("VALUE",a);(c=b.parent.getSound(c))&&createjs.Sound.play(c.id);return a.callReturn()}},sound_something_second_with_block:{color:"#A4D01D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/sound_03.png",size:12}],events:{},def:{params:[{type:"get_sounds",id:"95dw"},{type:"number",params:["1"]},null],type:"sound_something_second_with_block"}, +paramsKeyMap:{VALUE:0,SECOND:1},"class":"sound_play",isNotFor:[],func:function(b,a){var c=a.getStringValue("VALUE",a),d=a.getNumberValue("SECOND",a);(c=b.parent.getSound(c))&&createjs.Sound.play(c.id,{startTime:0,duration:1E3*d});return a.callReturn()}},sound_something_wait_with_block:{color:"#A4D01D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/sound_03.png",size:12}],events:{},def:{params:[{type:"get_sounds"},null],type:"sound_something_wait_with_block"}, +paramsKeyMap:{VALUE:0},"class":"sound_wait",isNotFor:[],func:function(b,a){if(a.isPlay){if(1==a.playState)return a;delete a.playState;delete a.isPlay;return a.callReturn()}a.isPlay=!0;a.playState=1;var c=a.getStringValue("VALUE",a);if(c=b.parent.getSound(c))createjs.Sound.play(c.id),setTimeout(function(){a.playState=0},1E3*c.duration);return a}},sound_something_second_wait_with_block:{color:"#A4D01D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Block",accept:"string"}, +{type:"Indicator",img:"block_icon/sound_03.png",size:12}],events:{},def:{params:[{type:"get_sounds"},{type:"number",params:["1"]},null],type:"sound_something_second_wait_with_block"},paramsKeyMap:{VALUE:0,SECOND:1},"class":"sound_wait",isNotFor:[],func:function(b,a){if(a.isPlay){if(1==a.playState)return a;delete a.isPlay;delete a.playState;return a.callReturn()}a.isPlay=!0;a.playState=1;var c=a.getStringValue("VALUE",a);if(c=b.parent.getSound(c)){var d=createjs.Sound.play(c.id),c=a.getNumberValue("SECOND", +a);setTimeout(function(){d.stop();a.playState=0},1E3*c);d.addEventListener("complete",function(a){})}return a}},sound_from_to:{color:"#A4D01D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/sound_03.png",size:12}],events:{},def:{params:[{type:"get_sounds"},{type:"text",params:["1"]},{type:"text",params:["10"]},null],type:"sound_from_to"},paramsKeyMap:{VALUE:0,START:1,END:2},"class":"sound_play", +isNotFor:[],func:function(b,a){var c=a.getStringValue("VALUE",a);if(c=b.parent.getSound(c)){var d=1E3*a.getNumberValue("START",a),e=1E3*a.getNumberValue("END",a);createjs.Sound.play(c.id,{startTime:Math.min(d,e),duration:Math.max(d,e)-Math.min(d,e)})}return a.callReturn()}},sound_from_to_and_wait:{color:"#A4D01D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/sound_03.png",size:12}], +events:{},def:{params:[{type:"get_sounds"},{type:"text",params:["1"]},{type:"text",params:["10"]},null],type:"sound_from_to_and_wait"},paramsKeyMap:{VALUE:0,START:1,END:2},"class":"sound_wait",isNotFor:[],func:function(b,a){if(a.isPlay){if(1==a.playState)return a;delete a.isPlay;delete a.playState;return a.callReturn()}a.isPlay=!0;a.playState=1;var c=a.getStringValue("VALUE",a);if(c=b.parent.getSound(c)){var d=1E3*a.getNumberValue("START",a),e=1E3*a.getNumberValue("END",a),f=Math.min(d,e),d=Math.max(d, +e)-f;createjs.Sound.play(c.id,{startTime:f,duration:d});setTimeout(function(){a.playState=0},d)}return a}},when_run_button_click:{color:"#3BBD70",skeleton:"basic_event",statements:[],params:[{type:"Indicator",img:"block_icon/start_icon_play.png",size:17,position:{x:0,y:-2}}],events:{},def:{params:[null],type:"when_run_button_click"},"class":"event",isNotFor:[],func:function(b,a){return a.callReturn()},event:"start"},press_some_key:{color:"#3BBD70",skeleton:"basic_event",statements:[],params:[{type:"Indicator", +img:"block_icon/start_icon_keyboard.png",size:17,position:{x:0,y:-2}},{type:"Dropdown",options:[["q","81"],["w","87"],["e","69"],["r","82"],["a","65"],["s","83"],["d","68"],["\uc704\ucabd \ud654\uc0b4\ud45c","38"],["\uc544\ub798\ucabd \ud654\uc0b4\ud45c","40"],["\uc67c\ucabd \ud654\uc0b4\ud45c","37"],["\uc624\ub978\ucabd \ud654\uc0b4\ud45c","39"],["\uc5d4\ud130","13"],["\uc2a4\ud398\uc774\uc2a4","32"]],value:"81",fontSize:11},{type:"Indicator",img:"block_icon/start_03.png",size:12}],events:{},def:{params:[null, +null,null]},paramsKeyMap:{VALUE:1},func:function(b,a){return a.callReturn()}},when_some_key_pressed:{color:"#3BBD70",skeleton:"basic_event",statements:[],params:[{type:"Indicator",img:"block_icon/start_icon_keyboard.png",size:17,position:{x:0,y:-2}},{type:"Keyboard",value:"81"}],events:{},def:{params:[null,"81"],type:"when_some_key_pressed"},paramsKeyMap:{VALUE:1},"class":"event",isNotFor:[],func:function(b,a){return a.callReturn()},event:"keyPress"},mouse_clicked:{color:"#3BBD70",skeleton:"basic_event", +statements:[],params:[{type:"Indicator",img:"block_icon/start_icon_mouse.png",size:17,position:{x:0,y:-2}}],events:{},def:{params:[null],type:"mouse_clicked"},"class":"event",isNotFor:[],func:function(b,a){return a.callReturn()},event:"mouse_clicked"},mouse_click_cancled:{color:"#3BBD70",skeleton:"basic_event",statements:[],params:[{type:"Indicator",img:"block_icon/start_icon_mouse.png",size:17,position:{x:0,y:-2}}],events:{},def:{params:[null],type:"mouse_click_cancled"},"class":"event",isNotFor:[], +func:function(b,a){return a.callReturn()},event:"mouse_click_cancled"},when_object_click:{color:"#3BBD70",skeleton:"basic_event",statements:[],params:[{type:"Indicator",img:"block_icon/start_icon_mouse.png",size:17,position:{x:0,y:-2}}],events:{},def:{params:[null],type:"when_object_click"},"class":"event",isNotFor:[],func:function(b,a){return a.callReturn()},event:"when_object_click"},when_object_click_canceled:{color:"#3BBD70",skeleton:"basic_event",statements:[],params:[{type:"Indicator",img:"block_icon/start_icon_mouse.png", +size:17,position:{x:0,y:-2}}],events:{},def:{params:[null],type:"when_object_click_canceled"},"class":"event",isNotFor:[],func:function(b,a){return a.callReturn()},event:"when_object_click_canceled"},when_some_key_click:{color:"#3BBD70",skeleton:"basic_event",statements:[],params:[{type:"Indicator",img:"block_icon/start_icon_keyboard.png",size:17,position:{x:0,y:-2}}],events:{},def:{params:[null]},func:function(b,a){return a.callReturn()},event:"keyPress"},when_message_cast:{color:"#3BBD70",skeleton:"basic_event", +statements:[],params:[{type:"Indicator",img:"block_icon/start_icon_signal.png",size:17,position:{x:0,y:-2}},{type:"DropdownDynamic",value:null,menuName:"messages",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_START}],events:{dataAdd:[function(b){var a=Entry.variableContainer;a&&a.addRef("_messageRefs",b)}],viewDestroy:[function(b){var a=Entry.variableContainer;a&&a.removeRef("_messageRefs",b)}]},def:{params:[null,null],type:"when_message_cast"},paramsKeyMap:{VALUE:1},"class":"message",isNotFor:["message"], +func:function(b,a){return a.callReturn()},event:"when_message_cast"},message_cast:{color:"#3BBD70",skeleton:"basic",statements:[],params:[{type:"DropdownDynamic",value:null,menuName:"messages",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_START},{type:"Indicator",img:"block_icon/start_03.png",size:12}],events:{dataAdd:[function(b){var a=Entry.variableContainer;a&&a.addRef("_messageRefs",b)}],viewDestroy:[function(b){var a=Entry.variableContainer;a&&a.removeRef("_messageRefs",b)}]},def:{params:[null, +null],type:"message_cast"},paramsKeyMap:{VALUE:0},"class":"message",isNotFor:["message"],func:function(b,a){var c=a.getField("VALUE",a),d=Entry.isExist(c,"id",Entry.variableContainer.messages_);if("null"==c||!d)throw Error("value can not be null or undefined");Entry.container.mapEntityIncludeCloneOnScene(Entry.engine.raiseKeyEvent,["when_message_cast",c]);return a.callReturn()}},message_cast_wait:{color:"#3BBD70",skeleton:"basic",statements:[],params:[{type:"DropdownDynamic",value:null,menuName:"messages", +fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_START},{type:"Indicator",img:"block_icon/start_03.png",size:12}],events:{dataAdd:[function(b){var a=Entry.variableContainer;a&&a.addRef("_messageRefs",b)}],dataDestroy:[function(b){var a=Entry.variableContainer;a&&a.removeRef("_messageRefs",b)}]},def:{params:[null,null],type:"message_cast_wait"},paramsKeyMap:{VALUE:0},"class":"message",isNotFor:["message"],func:function(b,a){if(a.runningScript){for(var c=a.runningScript,d=c.length,e=0;ec.array_.length)throw Error("can not remove value from array");c.array_.splice(d-1,1);c.updateView();return a.callReturn()}},insert_value_to_list:{color:"#E457DC",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"DropdownDynamic",value:null,menuName:"lists",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_VARIABLE}, +{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/variable_03.png",size:12}],events:{dataAdd:[function(b){var a=Entry.variableContainer;a&&a.addRef("_variableRefs",b)}],dataDestroy:[function(b){var a=Entry.variableContainer;a&&a.removeRef("_variableRefs",b)}]},def:{params:[{type:"text",params:["10"]},null,{type:"text",params:["1"]},null],type:"insert_value_to_list"},paramsKeyMap:{DATA:0,LIST:1,INDEX:2},"class":"list",isNotFor:["list","listNotExist"],func:function(b,a){var c=a.getField("LIST", +a),d=a.getValue("DATA",a),e=a.getValue("INDEX",a),c=Entry.variableContainer.getList(c,b);if(!c.array_||isNaN(e)||0==e||e>c.array_.length+1)throw Error("can not insert value to array");c.array_.splice(e-1,0,{data:d});c.updateView();return a.callReturn()}},change_value_list_index:{color:"#E457DC",skeleton:"basic",statements:[],params:[{type:"DropdownDynamic",value:null,menuName:"lists",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_VARIABLE},{type:"Block",accept:"string"},{type:"Block",accept:"string"}, +{type:"Indicator",img:"block_icon/variable_03.png",size:12}],events:{dataAdd:[function(b){var a=Entry.variableContainer;a&&a.addRef("_variableRefs",b)}],dataDestroy:[function(b){var a=Entry.variableContainer;a&&a.removeRef("_variableRefs",b)}]},def:{params:[null,{type:"text",params:["1"]},{type:"text",params:["10"]},null],type:"change_value_list_index"},paramsKeyMap:{LIST:0,INDEX:1,DATA:2},"class":"list",isNotFor:["list","listNotExist"],func:function(b,a){var c=a.getField("LIST",a),d=a.getValue("DATA", +a),e=a.getValue("INDEX",a),c=Entry.variableContainer.getList(c,b);if(!c.array_||isNaN(e)||e>c.array_.length)throw Error("can not insert value to array");c.array_[e-1].data=d;c.updateView();return a.callReturn()}},value_of_index_from_list:{color:"#E457DC",skeleton:"basic_string_field",statements:[],params:[{type:"Text",text:Lang.Blocks.VARIABLE_value_of_index_from_list_1,color:"white"},{type:"DropdownDynamic",value:null,menuName:"lists",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_VARIABLE},{type:"Text", +text:Lang.Blocks.VARIABLE_value_of_index_from_list_2,color:"white"},{type:"Block",accept:"string"},{type:"Text",text:Lang.Blocks.VARIABLE_value_of_index_from_list_3,color:"white"}],events:{dataAdd:[function(b){var a=Entry.variableContainer;a&&a.addRef("_variableRefs",b)}],dataDestroy:[function(b){var a=Entry.variableContainer;a&&a.removeRef("_variableRefs",b)}]},def:{params:[null,null,null,{type:"number",params:["1"]}],type:"value_of_index_from_list"},paramsKeyMap:{LIST:1,INDEX:3},"class":"list_element", +isNotFor:["list","listNotExist"],func:function(b,a){var c=a.getField("LIST",a),d=a.getValue("INDEX",a),c=Entry.variableContainer.getList(c,b),d=Entry.getListRealIndex(d,c);if(!c.array_||isNaN(d)||d>c.array_.length)throw Error("can not insert value to array");return c.array_[d-1].data}},length_of_list:{color:"#E457DC",skeleton:"basic_string_field",statements:[],params:[{type:"Text",text:Lang.Blocks.VARIABLE_length_of_list_1,color:"white"},{type:"DropdownDynamic",value:null,menuName:"lists",fontSize:11, +arrowColor:EntryStatic.ARROW_COLOR_VARIABLE},{type:"Text",text:Lang.Blocks.VARIABLE_length_of_list_2,color:"white"}],events:{dataAdd:[function(b){var a=Entry.variableContainer;a&&a.addRef("_variableRefs",b)}],dataDestroy:[function(b){var a=Entry.variableContainer;a&&a.removeRef("_variableRefs",b)}]},def:{params:[null,null,null],type:"length_of_list"},paramsKeyMap:{LIST:1},"class":"list",isNotFor:["list","listNotExist"],func:function(b,a){var c=a.getField("LIST",a);return Entry.variableContainer.getList(c, +b).array_.length}},show_list:{color:"#E457DC",skeleton:"basic",statements:[],params:[{type:"DropdownDynamic",value:null,menuName:"lists",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_VARIABLE},{type:"Indicator",img:"block_icon/variable_03.png",size:12}],events:{dataAdd:[function(b){var a=Entry.variableContainer;a&&a.addRef("_variableRefs",b)}],dataDestroy:[function(b){var a=Entry.variableContainer;a&&a.removeRef("_variableRefs",b)}]},def:{params:[null,null],type:"show_list"},paramsKeyMap:{LIST:0}, +"class":"list_visibility",isNotFor:["list","listNotExist"],func:function(b,a){var c=a.getField("LIST",a);Entry.variableContainer.getList(c).setVisible(!0);return a.callReturn()}},hide_list:{color:"#E457DC",skeleton:"basic",statements:[],params:[{type:"DropdownDynamic",value:null,menuName:"lists",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_VARIABLE},{type:"Indicator",img:"block_icon/variable_03.png",size:12}],events:{dataAdd:[function(b){var a=Entry.variableContainer;a&&a.addRef("_variableRefs", +b)}],dataDestroy:[function(b){var a=Entry.variableContainer;a&&a.removeRef("_variableRefs",b)}]},def:{params:[null,null],type:"hide_list"},paramsKeyMap:{LIST:0},"class":"list_visibility",isNotFor:["list","listNotExist"],func:function(b,a){var c=a.getField("LIST",a);Entry.variableContainer.getList(c).setVisible(!1);return a.callReturn()}},options_for_list:{color:"#E457DC",skeleton:"basic_string_field",statements:[],params:[{type:"Dropdown",options:[["\uccab\ubc88\uc9f8","FIRST"],["\ub9c8\uc9c0\ub9c9", +"LAST"],["\ubb34\uc791\uc704","RANDOM"]],value:"FIRST",fontSize:11}],events:{},def:{params:[null]},paramsKeyMap:{OPERATOR:0},func:function(b,a){return a.getField("OPERATOR",a)}},set_visible_answer:{color:"#E457DC",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.CALC_timer_visible_show,"SHOW"],[Lang.Blocks.CALC_timer_visible_hide,"HIDE"]],value:"SHOW",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_VARIABLE},{type:"Indicator",img:"block_icon/variable_03.png",size:12}], +events:{viewAdd:[function(b){Entry.container&&Entry.container.showProjectAnswer()}],viewDestroy:[function(b){Entry.container&&Entry.container.hideProjectAnswer(b)}]},def:{params:["HIDE",null],type:"set_visible_answer"},paramsKeyMap:{BOOL:0},"class":"ask",isNotFor:[],func:function(b,a){"HIDE"==a.getField("BOOL",a)?Entry.container.inputValue.setVisible(!1):Entry.container.inputValue.setVisible(!0);return a.callReturn()}},is_included_in_list:{color:"#E457DC",skeleton:"basic_boolean_field",statements:[], +params:[{type:"Text",text:Lang.Blocks.VARIABLE_is_included_in_list_1,color:"white"},{type:"DropdownDynamic",value:null,menuName:"lists",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_VARIABLE},{type:"Text",text:Lang.Blocks.VARIABLE_is_included_in_list_2,color:"white"},{type:"Block",accept:"string"},{type:"Text",text:Lang.Blocks.VARIABLE_is_included_in_list_3,color:"white"}],events:{dataAdd:[function(b){var a=Entry.variableContainer;a&&a.addRef("_variableRefs",b)}],dataDestroy:[function(b){var a=Entry.variableContainer; +a&&a.removeRef("_variableRefs",b)}]},def:{params:[null,null,null,{type:"text",params:["10"]},null],type:"is_included_in_list"},paramsKeyMap:{LIST:1,DATA:3},"class":"list",isNotFor:["list","listNotExist"],func:function(b,a){var c=a.getField("LIST",a),d=a.getStringValue("DATA",a),c=Entry.variableContainer.getList(c,b);if(!c)return!1;for(var c=c.array_,e=0,f=c.length;ek&&(k=Math.round(k-155),g=-k,h=0,Entry.dplay.vel_value=g);if(a.isStart){if(1==a.timeFlag)return Entry.hw.setDigitalPortValue(3,0),Entry.hw.setDigitalPortValue(5,0),Entry.hw.setDigitalPortValue(6,0),Entry.hw.setDigitalPortValue(11,0),a;if(2==a.timeFlag)return Entry.hw.setDigitalPortValue(c, +g),Entry.hw.setDigitalPortValue(d,h),Entry.hw.setDigitalPortValue(e,g),Entry.hw.setDigitalPortValue(f,h),delete a.isStart,delete a.timeFlag,Entry.engine.isContinue=!1,a.callReturn()}else{a.isStart=!0;a.timeFlag=1;var l=setTimeout(function(){a.timeFlag=2;Entry.dplay.removeTimeout(l)},50);Entry.dplay.timeouts.push(l);return a}}},dplay_buzzer:{color:"#00979D",fontColor:"#FFF",skeleton:"basic",statements:[],template:"\ub514\uc9c0\ud138 10\ubc88 \ubd80\uc800\ub97c %1 %2 %3 \ubc15\uc790\ub85c \uc5f0\uc8fc\ud558\uae30", +params:[{type:"Dropdown",options:[["\ub3c4","1"],["\ub3c4#","2"],["\ub808","3"],["\ubbf8b","4"],["\ubbf8","5"],["\ud30c","6"],["\ud30c#","7"],["\uc194","8"],["\uc194#","9"],["\ub77c","10"],["\uc2dcb","11"],["\uc2dc","12"],["\ubb34\uc74c","100"]],value:"1",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW},{type:"Dropdown",options:[["1","1"],["2","2"],["3","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:["1","1",{type:"text",params:["0.5"]},null],type:"dplay_buzzer"},paramsKeyMap:{NOTE:0,OCTAVE:1,VALUE:2},"class":"dplay_set",isNotFor:["dplay"],func:function(b,a){if(a.isStart){if(1==a.timeFlag)return a;Entry.hw.setDigitalPortValue(10,100);delete a.isStart;delete a.timeFlag;Entry.engine.isContinue=!1;return a.callReturn()}var c=a.getNumberField("NOTE",a),d=a.getNumberField("OCTAVE",a),e=a.getNumberValue("VALUE"),d=c+12*(d-1),e=6E4*e/60;a.isStart=!0;a.timeFlag=1;100== +c?Entry.hw.setDigitalPortValue(10,100):Entry.hw.setDigitalPortValue(10,d);if(100q?(n=Math.round(q-155),g=-n,h=0,Entry.dplay.Left_value=g):0==q&&(h=g=0,Entry.dplay.Left_value=0));"2"==m&&(e=6,f=11,0q?(n=Math.round(q-155),k=-n,l=0,Entry.dplay.Right_value= +k):0==q&&(l=k=0,Entry.dplay.Right_value=k));"3"==m&&(c=3,d=5,e=6,f=11,0q?(n=Math.round(q-155),g=-n,h=0,k=-n,l=0,Entry.dplay.Left_value=g,Entry.dplay.Right_value=k):0==q&&(l=k=h=g=0,Entry.dplay.Left_value=0,Entry.dplay.Right_value=0));if(a.isStart){if(1==a.timeFlag)return Entry.hw.setDigitalPortValue(3,0),Entry.hw.setDigitalPortValue(5,0),Entry.hw.setDigitalPortValue(6,0),Entry.hw.setDigitalPortValue(11,0), +a;if(2==a.timeFlag)return Entry.hw.setDigitalPortValue(c,g),Entry.hw.setDigitalPortValue(d,h),Entry.hw.setDigitalPortValue(e,l),Entry.hw.setDigitalPortValue(f,k),delete a.isStart,delete a.timeFlag,Entry.engine.isContinue=!1,a.callReturn()}else{a.isStart=!0;a.timeFlag=1;var r=setTimeout(function(){a.timeFlag=2;Entry.dplay.removeTimeout(r)},50);Entry.dplay.timeouts.push(r);return a}}},dplay_robot_speed_set:{color:"#00979D",fontColor:"#FFF",skeleton:"basic",statements:[],template:"\uc624\ub978\ucabd \ubc14\ud034 %1 \uc67c\ucabd \ubc14\ud034 %2(\uc73c)\ub85c \uc815\ud558\uae30 %3", +params:[{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[{type:"text",params:["100"]},{type:"text",params:["100"]},null],type:"dplay_robot_speed_set"},paramsKeyMap:{R_VALUE:0,L_VALUE:1},"class":"dplay_robot",isNotFor:["dplay"],func:function(b,a){var c=0,d=0,e=0,f=0,g=0,g=0,g=a.getNumberValue("L_VALUE",a),g=Math.max(g,-100),g=Math.min(g,100);0 +g?(g=Math.round(g-155),c=-g,d=0,Entry.dplay.Left_value=c):0==g&&(d=c=0,Entry.dplay.Left_value=0);g=a.getNumberValue("R_VALUE",a);g=Math.max(g,-100);g=Math.min(g,100);0g?(g=Math.round(g-155),e=-g,f=0,Entry.dplay.Right_value=e):0==g&&(f=e=0,Entry.dplay.Right_value=0);if(a.isStart){if(1==a.timeFlag)return Entry.hw.setDigitalPortValue(3,0),Entry.hw.setDigitalPortValue(5,0),Entry.hw.setDigitalPortValue(6,0),Entry.hw.setDigitalPortValue(11,0), +a;if(2==a.timeFlag)return Entry.hw.setDigitalPortValue(3,c),Entry.hw.setDigitalPortValue(5,d),Entry.hw.setDigitalPortValue(6,f),Entry.hw.setDigitalPortValue(11,e),delete a.isStart,delete a.timeFlag,Entry.engine.isContinue=!1,a.callReturn()}else{a.isStart=!0;a.timeFlag=1;var h=setTimeout(function(){a.timeFlag=2;Entry.dplay.removeTimeout(h)},50);Entry.dplay.timeouts.push(h);return a}}},dplay_robot_stop:{color:"#00979D",fontColor:"#FFF",skeleton:"basic",statements:[],template:"\ub85c\ubd07\uc744 \uc815\uc9c0\ud558\uae30 %1", +params:[{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null],type:"dplay_robot_stop"},paramsKeyMap:{},"class":"dplay_robot",isNotFor:["dplay"],func:function(b,a){Entry.hw.setDigitalPortValue(3,0);Entry.hw.setDigitalPortValue(5,0);Entry.hw.setDigitalPortValue(11,0);Entry.hw.setDigitalPortValue(6,0);return a.callReturn()}},nemoino_get_number_sensor_value:{parent:"arduino_get_number_sensor_value",isNotFor:["nemoino"],def:{params:[{type:"arduino_get_sensor_number"}], +type:"nemoino_get_number_sensor_value"},"class":"arduino_value"},nemoino_get_digital_value:{parent:"arduino_get_digital_value",isNotFor:["nemoino"],def:{params:[{type:"arduino_get_port_number"}],type:"nemoino_get_digital_value"},"class":"arduino_value"},nemoino_toggle_led:{parent:"arduino_toggle_led",isNotFor:["nemoino"],def:{params:[{type:"arduino_get_port_number"},null,null],type:"nemoino_toggle_led"},"class":"arduino_set"},nemoino_toggle_pwm:{parent:"arduino_toggle_pwm",isNotFor:["nemoino"],def:{params:[{type:"arduino_get_pwm_port_number"}, +{type:"arduino_text",params:["255"]},null],type:"nemoino_toggle_pwm"},"class":"arduino_set"},nemoino_convert_scale:{parent:"arduino_convert_scale",isNotFor:["nemoino"],def:{params:[{type:"arduino_get_number_sensor_value",params:[{type:"arduino_get_sensor_number"}]},{type:"number",params:["0"]},{type:"number",params:["1023"]},{type:"number",params:["0"]},{type:"number",params:["100"]}],type:"nemoino_convert_scale"},"class":"arduino"},sensorBoard_get_number_sensor_value:{parent:"arduino_get_number_sensor_value", +isNotFor:["sensorBoard"],def:{params:[{type:"arduino_get_sensor_number"}],type:"sensorBoard_get_number_sensor_value"},"class":"arduino_value"},sensorBoard_get_digital_value:{parent:"arduino_get_digital_value",isNotFor:["sensorBoard"],def:{params:[{type:"arduino_get_port_number"}],type:"sensorBoard_get_digital_value"},"class":"arduino_value"},sensorBoard_toggle_led:{parent:"arduino_toggle_led",isNotFor:["sensorBoard"],def:{params:[{type:"arduino_get_port_number"},null,null],type:"sensorBoard_toggle_led"}, +"class":"arduino_set"},sensorBoard_toggle_pwm:{parent:"arduino_toggle_pwm",isNotFor:["sensorBoard"],def:{params:[{type:"arduino_get_pwm_port_number"},{type:"arduino_text",params:["255"]},null],type:"sensorBoard_toggle_pwm"},"class":"arduino_set"},sensorBoard_convert_scale:{parent:"arduino_convert_scale",isNotFor:["sensorBoard"],def:{params:[{type:"arduino_get_number_sensor_value",params:[{type:"arduino_get_sensor_number",id:"bl5e"}]},{type:"number",params:["0"]},{type:"number",params:["1023"]},{type:"number", +params:["0"]},{type:"number",params:["100"]}],type:"sensorBoard_convert_scale"},"class":"arduino"},CODEino_get_number_sensor_value:{parent:"arduino_get_number_sensor_value",isNotFor:["CODEino"],def:{params:[{type:"arduino_get_sensor_number"}],type:"CODEino_get_number_sensor_value"},"class":"arduino_value"},CODEino_get_digital_value:{parent:"arduino_get_digital_value",isNotFor:["CODEino"],def:{params:[{type:"arduino_get_port_number"}],type:"CODEino_get_digital_value"},"class":"arduino_value"},CODEino_toggle_led:{parent:"arduino_toggle_led", +isNotFor:["CODEino"],def:{params:[{type:"arduino_get_port_number"},null,null],type:"CODEino_toggle_led"},"class":"arduino_set"},CODEino_toggle_pwm:{parent:"arduino_toggle_pwm",isNotFor:["CODEino"],def:{params:[{type:"arduino_get_pwm_port_number"},{type:"arduino_text",params:["255"]},null],type:"CODEino_toggle_pwm"},"class":"arduino_set"},CODEino_convert_scale:{parent:"arduino_convert_scale",isNotFor:["CODEino"],def:{params:[{type:"arduino_get_number_sensor_value",params:[{type:"arduino_get_sensor_number"}]}, +{type:"number",params:["0"]},{type:"number",params:["1023"]},{type:"number",params:["0"]},{type:"number",params:["100"]}],type:"CODEino_convert_scale"},"class":"arduino"},ardublock_get_number_sensor_value:{parent:"arduino_get_number_sensor_value",isNotFor:["ardublock"],def:{params:[{type:"arduino_get_sensor_number"}],type:"ardublock_get_number_sensor_value"},"class":"arduino_value"},ardublock_get_digital_value:{parent:"arduino_get_digital_value",isNotFor:["ardublock"],def:{params:[{type:"arduino_get_port_number"}], +type:"ardublock_get_digital_value"},"class":"arduino_value"},ardublock_toggle_led:{parent:"arduino_toggle_led",isNotFor:["ardublock"],def:{params:[{type:"arduino_get_port_number"},null,null],type:"ardublock_toggle_led"},"class":"arduino_set"},ardublock_toggle_pwm:{parent:"arduino_toggle_pwm",isNotFor:["ardublock"],def:{params:[{type:"arduino_get_pwm_port_number"},{type:"arduino_text",params:["255"]},null],type:"ardublock_toggle_pwm"},"class":"arduino_set"},ardublock_convert_scale:{parent:"arduino_convert_scale", +isNotFor:["ardublock"],def:{params:[{type:"arduino_get_number_sensor_value",params:[{type:"arduino_get_sensor_number"}]},{type:"number",params:["0"]},{type:"number",params:["1023"]},{type:"number",params:["0"]},{type:"number",params:["100"]}],type:"ardublock_convert_scale"},"class":"arduino"},joystick_get_number_sensor_value:{parent:"arduino_get_number_sensor_value",isNotFor:["joystick"],def:{params:[{type:"arduino_get_sensor_number"}],type:"joystick_get_number_sensor_value"},"class":"arduino_value"}, +joystick_get_digital_value:{parent:"arduino_get_digital_value",isNotFor:["joystick"],def:{params:[{type:"arduino_get_port_number"}],type:"joystick_get_digital_value"},"class":"arduino_value"},joystick_toggle_led:{parent:"arduino_toggle_led",isNotFor:["joystick"],def:{params:[{type:"arduino_get_port_number"},null,null],type:"joystick_toggle_led"},"class":"arduino_set"},joystick_toggle_pwm:{parent:"arduino_toggle_pwm",isNotFor:["joystick"],def:{params:[{type:"arduino_get_pwm_port_number"},{type:"arduino_text", +params:["255"]},null],type:"joystick_toggle_pwm"},"class":"arduino_set"},joystick_convert_scale:{parent:"arduino_convert_scale",isNotFor:["joystick"],def:{params:[{type:"arduino_get_number_sensor_value",params:[{type:"arduino_get_sensor_number"}]},{type:"number",params:["0"]},{type:"number",params:["1023"]},{type:"number",params:["0"]},{type:"number",params:["100"]}],type:"joystick_convert_scale"},"class":"arduino"},ebs_if:{parent:"_if",def:{type:"_if",params:[{type:"reach_something",params:[null, +"wall"]}]}},ebs_if2:{parent:"_if",def:{type:"_if",params:[{type:"reach_something",params:[null,"cwz5"]}]}}};(function(){for(var b in Entry.block){var a=Entry.block[b];if(a.parent){var c=function(){};c.prototype=Entry.block[a.parent];var c=new c,d;for(d in a)c[d]=a[d];Entry.block[b]=c}}})();"object"==typeof exports&&(exports.block=Entry.block);Entry.BlockMenu=function(b,a,c,d){Entry.Model(this,!1);this._align=a||"CENTER";this._scroll=void 0!==d?d:!1;this._bannedClass=[];this._categories=[];this.suffix="blockMenu";b="string"===typeof b?$("#"+b):$(b);if("DIV"!==b.prop("tagName"))return console.error("Dom is not div element");this.view=b;this.visible=!0;this._svgId="blockMenu"+(new Date).getTime();this._clearCategory();this._categoryData=c;this._generateView(c);this._splitters=[];this.setWidth();this.svg=Entry.SVG(this._svgId);Entry.Utils.addFilters(this.svg, +this.suffix);a=Entry.Utils.addBlockPattern(this.svg,this.suffix);this.patternRect=a.rect;this.pattern=a.pattern;this.svgGroup=this.svg.elem("g");this.svgThreadGroup=this.svgGroup.elem("g");this.svgThreadGroup.board=this;this.svgBlockGroup=this.svgGroup.elem("g");this.svgBlockGroup.board=this;this.changeEvent=new Entry.Event(this);c&&this._generateCategoryCodes(c);this.observe(this,"_handleDragBlock",["dragBlock"]);this._scroll&&(this._scroller=new Entry.BlockMenuScroller(this),this._addControl(b)); +Entry.documentMousedown&&Entry.documentMousedown.attach(this,this.setSelectedBlock);this._categoryCodes&&Entry.keyPressed&&Entry.keyPressed.attach(this,this._captureKeyEvent);Entry.windowResized&&(b=_.debounce(this.updateOffset,200),Entry.windowResized.attach(this,b))}; +(function(b){b.schema={code:null,dragBlock:null,closeBlock:null,selectedBlockView:null};b._generateView=function(a){var b=this.view,d=this;a&&(this._categoryCol=Entry.Dom("ul",{class:"entryCategoryListWorkspace",parent:b}),this._generateCategoryView(a));this.blockMenuContainer=Entry.Dom("div",{"class":"blockMenuContainer",parent:b});this.svgDom=Entry.Dom($(''),{parent:this.blockMenuContainer});this.svgDom.mouseenter(function(a){d._scroller&& +d._scroller.setOpacity(1);a=d.workspace.selectedBlockView;!Entry.playground||Entry.playground.resizing||a&&a.dragMode===Entry.DRAG_MODE_DRAG||(Entry.playground.focusBlockMenu=!0,a=d.svgGroup.getBBox(),a=a.width+a.x+64,a>Entry.interfaceState.menuWidth&&(this.widthBackup=Entry.interfaceState.menuWidth-64,$(this).stop().animate({width:a-62},200)))});this.svgDom.mouseleave(function(a){Entry.playground&&!Entry.playground.resizing&&(d._scroller&&d._scroller.setOpacity(0),(a=this.widthBackup)&&$(this).stop().animate({width:a}, +200),delete this.widthBackup,delete Entry.playground.focusBlockMenu)});$(window).scroll(function(){d.updateOffset()})};b.changeCode=function(a){if(!(a instanceof Entry.Code))return console.error("You must inject code instance");this.codeListener&&this.code.changeEvent.detach(this.codeListener);var b=this;this.set({code:a});this.codeListener=this.code.changeEvent.attach(this,function(){b.changeEvent.notify()});a.createView(this);this.align()};b.bindCodeView=function(a){this.svgBlockGroup.remove(); +this.svgThreadGroup.remove();this.svgBlockGroup=a.svgBlockGroup;this.svgThreadGroup=a.svgThreadGroup;this.svgGroup.appendChild(this.svgThreadGroup);this.svgGroup.appendChild(this.svgBlockGroup);this._scroller&&this.svgGroup.appendChild(this._scroller.svgGroup)};b.align=function(a){var b=this.code;if(b){this._clearSplitters();b.view&&!a&&b.view.reDraw();a=b.getThreads();for(var b=10,d="LEFT"==this._align?10:this.svgDom.width()/2,e,f=0,g=a.length;fthis._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});this.pattern.attr({style:""})};b.disablePattern=function(){this.pattern.attr({style:"display: none"})};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; +e.scroll(a.pageY-c.offsetY);c.set({offsetY:a.pageY})}function d(a){$(document).unbind(".scroll");delete e.dragInstance}var e=this;a.stopPropagation&&a.stopPropagation();a.preventDefault&&a.preventDefault();if(0===a.button||a.originalEvent&&a.originalEvent.touches){Entry.documentMousedown&&Entry.documentMousedown.notify(a);var f;f=a.originalEvent&&a.originalEvent.touches?a.originalEvent.touches[0]:a;var g=$(document);g.bind("mousemove.scroll",b);g.bind("mouseup.scroll",d);g.bind("touchmove.scroll", +b);g.bind("touchend.scroll",d);e.dragInstance=new Entry.DragInstance({startY:f.pageY,offsetY:f.pageY})}a.stopPropagation()};b._addControl=function(){$(this.vScrollbar).bind("mousedown touchstart",this.mouseHandler)}})(Entry.BlockMenuScroller.prototype);Entry.BlockView=function(b,a,c){Entry.Model(this,!1);this.block=b;this._lazyUpdatePos=_.debounce(b._updatePos.bind(b),200);this._board=a;this._observers=[];this.set(b);this.svgGroup=a.svgBlockGroup.elem("g");this._schema=Entry.block[b.type];this._schema.changeEvent&&(this._schemaChangeEvent=this._schema.changeEvent.attach(this,this._updateSchema));var d=this._skeleton=Entry.skeleton[this._schema.skeleton];this._contents=[];this._statements=[];this.magnet={};this._paramMap={};d.magnets&&d.magnets(this).next&& +(this.svgGroup.nextMagnet=this.block,this._nextGroup=this.svgGroup.elem("g"),this._observers.push(this.observe(this,"_updateMagnet",["contentHeight"])));this.isInBlockMenu=this.getBoard()instanceof Entry.BlockMenu;var e=this;this.mouseHandler=function(){var a=e.block.events;a&&a.mousedown&&a.mousedown.forEach(function(a){a(e)});e.onMouseDown.apply(e,arguments)};this._startRender(b,c);this._observers.push(this.block.observe(this,"_setMovable",["movable"]));this._observers.push(this.block.observe(this, "_setReadOnly",["movable"]));this._observers.push(this.block.observe(this,"_setCopyable",["copyable"]));this._observers.push(this.block.observe(this,"_updateColor",["deletable"],!1));this._observers.push(this.observe(this,"_updateBG",["magneting"],!1));this._observers.push(this.observe(this,"_updateOpacity",["visible"],!1));this._observers.push(this.observe(this,"_updateDisplay",["display"],!1));this._observers.push(this.observe(this,"_updateShadow",["shadow"]));this._observers.push(this.observe(this, -"_updateMagnet",["offsetY"]));this._observers.push(b.code.observe(this,"_setBoard",["board"],!1));this.dragMode=Entry.DRAG_MODE_NONE;Entry.Utils.disableContextmenu(this.svgGroup.node);(b=a.events.viewAdd)&&!this.isInBlockMenu&&b.forEach(function(b){Entry.Utils.isFunction(b)&&b(a)})};Entry.BlockView.PARAM_SPACE=5;Entry.BlockView.DRAG_RADIUS=5; -(function(a){a.schema={id:0,type:Entry.STATIC.BLOCK_RENDER_MODEL,x:0,y:0,offsetX:0,offsetY:0,width:0,height:0,contentWidth:0,contentHeight:0,magneting:!1,visible:!0,animating:!1,shadow:!0,display:!0};a._startRender=function(b,a){var d=this;b=this._skeleton;this.svgGroup.attr({class:"block"});var e=b.classes;e&&0!==e.length&&e.forEach(function(b){d.svgGroup.addClass(b)});e=b.path(this);this.pathGroup=this.svgGroup.elem("g");this._updateMagnet();this._path=this.pathGroup.elem("path");this.getBoard().patternRect&& -($(this._path).mouseenter(function(b){d._mouseEnable&&d._changeFill(!0)}),$(this._path).mouseleave(function(b){d._mouseEnable&&d._changeFill(!1)}));var f=this._schema.color;this.block.deletable===Entry.Block.DELETABLE_FALSE_LIGHTEN&&(f=Entry.Utils.colorLighten(f));this._fillColor=f;e={d:e,fill:f,class:"blockPath"};if(this.magnet.next||this._skeleton.nextShadow)f=this.getBoard().suffix,this.pathGroup.attr({filter:"url(#entryBlockShadowFilter_"+f+")"});else if(this.magnet.string||this.magnet.boolean)e.stroke= -b.outerLine;b.outerLine&&(e["stroke-width"]="0.6");this._path.attr(e);this._moveTo(this.x,this.y,!1);this._startContentRender(a);!0!==this._board.disableMouseEvent&&this._addControl();this.bindPrev()};a._startContentRender=function(b){b=void 0===b?Entry.Workspace.MODE_BOARD:b;this.contentSvgGroup&&this.contentSvgGroup.remove();var a=this._schema;a.statements&&a.statements.length&&this.statementSvgGroup&&this.statementSvgGroup.remove();this._contents=[];this.contentSvgGroup=this.svgGroup.elem("g"); -a.statements&&a.statements.length&&(this.statementSvgGroup=this.svgGroup.elem("g"));switch(b){case Entry.Workspace.MODE_BOARD:case Entry.Workspace.MODE_OVERLAYBOARD:for(var d=/(%\d)/mi,e=(a.template?a.template:Lang.template[this.block.type]).split(d),f=a.params,g=0;gEntry.BlockView.DRAG_RADIUS)&&m.movable&&(m.isInBlockMenu?e.cloneToGlobal(b):(b=!1,m.dragMode!=Entry.DRAG_MODE_DRAG&&(m._toGlobalCoordinate(),m.dragMode= -Entry.DRAG_MODE_DRAG,m.block.getThread().changeEvent.notify(),Entry.GlobalSvg.setView(m,c),b=!0),this.animating&&this.set({animating:!1}),0===m.dragInstance.height&&m.dragInstance.set({height:-1+m.height}),c=m.dragInstance,m._moveBy(d.pageX-c.offsetX,d.pageY-c.offsetY,!1),c.set({offsetX:d.pageX,offsetY:d.pageY}),Entry.GlobalSvg.position(),m.originPos||(m.originPos={x:m.x,y:m.y}),b&&e.generateCodeMagnetMap(),m._updateCloseBlock()))}function d(b){$(document).unbind(".block");m.terminateDrag(b);e&&e.set({dragBlock:null}); -m._changeFill(!1);Entry.GlobalSvg.remove();delete this.mouseDownCoordinate;delete m.dragInstance}b.stopPropagation&&b.stopPropagation();b.preventDefault&&b.preventDefault();this._changeFill(!1);var e=this.getBoard();Entry.documentMousedown&&Entry.documentMousedown.notify(b);if(!this.readOnly&&!e.viewOnly){e.setSelectedBlock(this);this.dominate();if(0===b.button||b.originalEvent&&b.originalEvent.touches){var f;f=b.originalEvent&&b.originalEvent.touches?b.originalEvent.touches[0]:b;this.mouseDownCoordinate= -{x:f.pageX,y:f.pageY};var g=$(document);g.bind("mousemove.block touchmove.block",c);g.bind("mouseup.block touchend.block",d);this.dragInstance=new Entry.DragInstance({startX:f.pageX,startY:f.pageY,offsetX:f.pageX,offsetY:f.pageY,height:0,mode:!0});e.set({dragBlock:this});this.addDragging();this.dragMode=Entry.DRAG_MODE_MOUSEDOWN}else if(Entry.Utils.isRightButton(b)){var h=this,k=h.block;if(this.isInBlockMenu)return;f=[];var g={text:Lang.Blocks.Duplication_option,enable:this.copyable,callback:function(){Entry.do("cloneBlock", -k)}},l={text:Lang.Blocks.CONTEXT_COPY_option,enable:this.copyable,callback:function(){h.block.copyToClipboard()}},n={text:Lang.Blocks.Delete_Blocks,enable:k.isDeletable(),callback:function(){Entry.do("destroyBlock",h.block)}};f.push(g);f.push(l);f.push(n);Entry.ContextMenu.show(f)}var m=this;e.workspace.getMode()===Entry.Workspace.MODE_VIMBOARD&&b&&document.getElementsByClassName("CodeMirror")[0].dispatchEvent(Entry.Utils.createMouseEvent("dragStart",event))}};a.vimBoardEvent=function(b,a,d){b&&(b= -Entry.Utils.createMouseEvent(a,b),d&&(b.block=d),document.getElementsByClassName("CodeMirror")[0].dispatchEvent(b))};a.terminateDrag=function(b){var a=this.getBoard(),d=this.dragMode,e=this.block,f=a.workspace.getMode();this.removeDragging();this.set({visible:!0});this.dragMode=Entry.DRAG_MODE_NONE;if(f===Entry.Workspace.MODE_VIMBOARD)a instanceof Entry.BlockMenu?(a.terminateDrag(),this.vimBoardEvent(b,"dragEnd",e)):a.clear();else if(d===Entry.DRAG_MODE_DRAG){var f=this.dragInstance&&this.dragInstance.isNew, -g=Entry.GlobalSvg,h=this.block.getPrevBlock(this.block);b=!1;switch(Entry.GlobalSvg.terminateDrag(this)){case g.DONE:g=a.magnetedBlockView;g instanceof Entry.BlockView&&(g=g.block);h&&!g?Entry.do("separateBlock",e):h||g||f?g?("next"===g.view.magneting?(h=e.getLastBlock(),this.dragMode=d,a.separate(e),this.dragMode=Entry.DRAG_MODE_NONE,Entry.do("insertBlock",g,h).isPass(f),Entry.ConnectionRipple.setView(g.view).dispose()):(Entry.do("insertBlock",e,g).isPass(f),b=!0),createjs.Sound.play("entryMagneting")): -Entry.do("moveBlock",e).isPass(f):e.getThread().view.isGlobal()?Entry.do("moveBlock",e):Entry.do("separateBlock",e);break;case g.RETURN:e=this.block;d=this.originPos;h?(this.set({animating:!1}),createjs.Sound.play("entryMagneting"),this.bindPrev(h),e.insert(h)):(f=e.getThread().view.getParent(),f instanceof Entry.Board?this._moveTo(d.x,d.y,!1):(createjs.Sound.play("entryMagneting"),Entry.do("insertBlock",e,f)));break;case g.REMOVE:createjs.Sound.play("entryDelete"),f?this.block.destroy(!1,!0):this.block.doDestroyBelow(!1)}a.setMagnetedBlock(null); -b&&Entry.ConnectionRipple.setView(e.view).dispose()}this.destroyShadow();delete this.originPos;this.dominate()};a._updateCloseBlock=function(){var b=this.getBoard(),a;if(this._skeleton.magnets){for(var d in this.magnet)if(a="next"===d?this.getBoard().getNearestMagnet(this.x,this.y+this.getBelowHeight(),d):this.getBoard().getNearestMagnet(this.x,this.y,d))return b.setMagnetedBlock(a.view,d);b.setMagnetedBlock(null)}};a.dominate=function(){this.block.getThread().view.dominate()};a.getSvgRoot=function(){for(var b= -this.getBoard().svgBlockGroup,a=this.svgGroup;a.parentNode!==b;)a=a.parentNode;return a};a.getBoard=function(){return this._board};a._setBoard=function(){this._board=this._board.code.board};a.destroy=function(b){this._destroyObservers();var a=this.svgGroup;b?$(a).fadeOut(100,function(){a.remove()}):a.remove();this._contents.forEach(function(b){b.constructor!==Entry.Block&&b.destroy()});var d=this.block;(b=d.events.viewDestroy)&&!this.isInBlockMenu&&b.forEach(function(b){Entry.Utils.isFunction(b)&& -b(d)});this._schemaChangeEvent&&this._schemaChangeEvent.destroy()};a.getShadow=function(){this._shadow||(this._shadow=Entry.SVG.createElement(this.svgGroup.cloneNode(!0),{opacity:.5}),this.getBoard().svgGroup.appendChild(this._shadow));return this._shadow};a.destroyShadow=function(){this._shadow&&(this._shadow.remove(),delete this._shadow)};a._updateMagnet=function(){if(this._skeleton.magnets){var b=this._skeleton.magnets(this);b.next&&this._nextGroup.attr("transform","translate("+b.next.x+","+b.next.y+ -")");this.magnet=b;this.block.getThread().changeEvent.notify()}};a._updateBG=function(){if(this._board.dragBlock&&this._board.dragBlock.dragInstance){var b=this.svgGroup;if(this.magnet.next){if(b=this.magneting){var a=this._board.dragBlock.getShadow(),d=this.getAbsoluteCoordinate(),e;if("previous"===b)e=this.magnet.next,e="translate("+(d.x+e.x)+","+(d.y+e.y)+")";else if("next"===b){e=this.magnet.previous;var f=this._board.dragBlock.getBelowHeight();e="translate("+(d.x+e.x)+","+(d.y+e.y-f)+")"}$(a).attr({transform:e, -display:"block"});this._clonedShadow=a;this.background&&(this.background.remove(),this.nextBackground.remove(),delete this.background,delete this.nextBackground);"previous"===b&&(b=this._board.dragBlock.getBelowHeight()+this.offsetY,this.originalHeight=this.offsetY,this.set({offsetY:b}))}else this._clonedShadow&&(this._clonedShadow.attr({display:"none"}),delete this._clonedShadow),b=this.originalHeight,void 0!==b&&(this.background&&(this.background.remove(),this.nextBackground.remove(),delete this.background, -delete this.nextBackground),this.set({offsetY:b}),delete this.originalHeight);(b=this.block.thread.changeEvent)&&b.notify()}else this.magneting?(b.attr({filter:"url(#entryBlockHighlightFilter_"+this.getBoard().suffix+")"}),b.addClass("outputHighlight")):(b.removeClass("outputHighlight"),b.removeAttr("filter"))}};a.addDragging=function(){this.svgGroup.addClass("dragging")};a.removeDragging=function(){this.svgGroup.removeClass("dragging")};a.addSelected=function(){this.svgGroup.addClass("selected")}; -a.removeSelected=function(){this.svgGroup.removeClass("selected")};a.getSkeleton=function(){return this._skeleton};a.getContentPos=function(){return this._skeleton.contentPos(this)};a.renderText=function(){this._startContentRender(Entry.Workspace.MODE_VIMBOARD)};a.renderBlock=function(){this._startContentRender(Entry.Workspace.MODE_BOARD)};a._updateOpacity=function(){this.svgGroup.attr({opacity:!1===this.visible?0:1});this.visible&&this._setPosition()};a._updateShadow=function(){this.shadow&&Entry.Utils.colorDarken(this._schema.color, -.7)};a._setMovable=function(){this.movable=null!==this.block.isMovable()?this.block.isMovable():void 0!==this._skeleton.movable?this._skeleton.movable:!0};a._setReadOnly=function(){this.readOnly=null!==this.block.isReadOnly()?this.block.isReadOnly():void 0!==this._skeleton.readOnly?this._skeleton.readOnly:!1};a._setCopyable=function(){this.copyable=null!==this.block.isCopyable()?this.block.isCopyable():void 0!==this._skeleton.copyable?this._skeleton.copyable:!0};a.bumpAway=function(b,a){var d=this; -b=b||15;a?window.setTimeout(function(){d._moveBy(b,b,!1)},a):d._moveBy(b,b,!1)};a.bindPrev=function(b){if(b){if(this._toLocalCoordinate(b.view._nextGroup),(b=b.getNextBlock())&&b!==this.block){var a=this.block.getLastBlock();a.view.magnet.next?b.view._toLocalCoordinate(a.view._nextGroup):(b.view._toGlobalCoordinate(),b.separate(),b.view.bumpAway(null,100))}}else if(b=this.block.getPrevBlock())this._toLocalCoordinate(b.view._nextGroup),(b=this.block.getNextBlock())&&b.view&&b.view._toLocalCoordinate(this._nextGroup)}; -a.getAbsoluteCoordinate=function(b){b=void 0!==b?b:this.dragMode;if(b===Entry.DRAG_MODE_DRAG)return{x:this.x,y:this.y};b=this.block.getThread().view.requestAbsoluteCoordinate(this);b.x+=this.x;b.y+=this.y;return b};a.getBelowHeight=function(){return this.block.getThread().view.requestPartHeight(this)};a._updateDisplay=function(){this.svgGroup.attr({display:!1===this.display?"none":"block"});this.display&&this._setPosition()};a._updateColor=function(){var b=this._schema.color;this.block.deletable=== -Entry.Block.DELETABLE_FALSE_LIGHTEN&&(b=Entry.Utils.colorLighten(b));this._fillColor=b;this._path.attr({fill:b});this._updateContents()};a._updateContents=function(){for(var b=0;ba&&(d+="...");return d};a.appendSvgOptionGroup=function(){return this._block.view.getBoard().svgGroup.elem("g")};a.getValue=function(){return this._block.params[this._index]};a.setValue=function(b,a){this.value!=b&&(this.value=b,this._block.params[this._index]=b,a&&this._blockView.reDraw())};a._isEditable=function(){if(this._block.view.dragMode==Entry.DRAG_MODE_DRAG)return!1;var b=this._block.view,a=b.getBoard();if(!0===a.disableMouseEvent)return!1;var d=a.workspace.selectedBlockView; -if(!d||a!=d.getBoard())return!1;a=b.getSvgRoot();return a==d.svgGroup||$(a).has($(b.svgGroup))};a._selectBlockView=function(){var b=this._block.view;b.getBoard().setSelectedBlock(b)};a._bindRenderOptions=function(){var b=this;$(this.svgGroup).bind("mouseup touchend",function(a){b._isEditable()&&(b.destroyOption(),b._startValue=b.getValue(),b.renderOptions())})};a.pointer=function(b){b=b||[];b.unshift(this._index);b.unshift(Entry.PARAM);return this._block.pointer(b)}})(Entry.Field.prototype);Entry.FieldBlock=function(a,b,c,d,e){Entry.Model(this,!1);this._blockView=b;this._block=b.block;this._valueBlock=null;this.box=new Entry.BoxModel;this.changeEvent=new Entry.Event(this);this._index=c;this.contentIndex=e;this._content=a;this.acceptType=a.accept;this._restoreCurrent=a.restore;this.view=this;this.svgGroup=null;this._position=a.position;this.box.observe(b,"alignContent",["width","height"]);this.observe(this,"_updateBG",["magneting"],!1);this.renderStart(b.getBoard(),d)}; +"_updateMagnet",["offsetY"]));this._observers.push(a.code.observe(this,"_setBoard",["board"],!1));this.dragMode=Entry.DRAG_MODE_NONE;Entry.Utils.disableContextmenu(this.svgGroup.node);(a=b.events.viewAdd)&&!this.isInBlockMenu&&a.forEach(function(a){Entry.Utils.isFunction(a)&&a(b)})};Entry.BlockView.PARAM_SPACE=5;Entry.BlockView.DRAG_RADIUS=5; +(function(b){b.schema={id:0,type:Entry.STATIC.BLOCK_RENDER_MODEL,x:0,y:0,offsetX:0,offsetY:0,width:0,height:0,contentWidth:0,contentHeight:0,magneting:!1,visible:!0,animating:!1,shadow:!0,display:!0};b._startRender=function(a,b){var d=this,e=this._skeleton;this.svgGroup.attr({class:"block"});var f=e.classes;f&&0!==f.length&&f.forEach(function(a){d.svgGroup.addClass(a)});f=e.path(this);this.pathGroup=this.svgGroup.elem("g");this._updateMagnet();this._path=this.pathGroup.elem("path");this.getBoard().patternRect&& +($(this._path).mouseenter(function(a){d._mouseEnable&&d._changeFill(!0)}),$(this._path).mouseleave(function(a){d._mouseEnable&&d._changeFill(!1)}));var g=this._schema.color;this.block.deletable===Entry.Block.DELETABLE_FALSE_LIGHTEN&&(g=Entry.Utils.colorLighten(g));this._fillColor=g;f={d:f,fill:g,class:"blockPath"};if(this.magnet.next||this._skeleton.nextShadow)g=this.getBoard().suffix,this.pathGroup.attr({filter:"url(#entryBlockShadowFilter_"+g+")"});else if(this.magnet.string||this.magnet.boolean)f.stroke= +e.outerLine;e.outerLine&&(f["stroke-width"]="0.6");this._path.attr(f);this._moveTo(this.x,this.y,!1);this._startContentRender(b);!0!==this._board.disableMouseEvent&&this._addControl();this.bindPrev()};b._startContentRender=function(a){a=void 0===a?Entry.Workspace.MODE_BOARD:a;this.contentSvgGroup&&this.contentSvgGroup.remove();var b=this._schema;b.statements&&b.statements.length&&this.statementSvgGroup&&this.statementSvgGroup.remove();this._contents=[];this.contentSvgGroup=this.svgGroup.elem("g"); +b.statements&&b.statements.length&&(this.statementSvgGroup=this.svgGroup.elem("g"));switch(a){case Entry.Workspace.MODE_BOARD:case Entry.Workspace.MODE_OVERLAYBOARD:for(var d=/(%\d)/mi,e=(b.template?b.template:Lang.template[this.block.type]).split(d),f=b.params,g=0;gEntry.BlockView.DRAG_RADIUS)&&m.movable&&(m.isInBlockMenu?e.cloneToGlobal(a):(a=!1,m.dragMode!=Entry.DRAG_MODE_DRAG&&(m._toGlobalCoordinate(),m.dragMode= +Entry.DRAG_MODE_DRAG,m.block.getThread().changeEvent.notify(),Entry.GlobalSvg.setView(m,c),a=!0),this.animating&&this.set({animating:!1}),0===m.dragInstance.height&&m.dragInstance.set({height:-1+m.height}),c=m.dragInstance,m._moveBy(d.pageX-c.offsetX,d.pageY-c.offsetY,!1),c.set({offsetX:d.pageX,offsetY:d.pageY}),Entry.GlobalSvg.position(),m.originPos||(m.originPos={x:m.x,y:m.y}),a&&e.generateCodeMagnetMap(),m._updateCloseBlock()))}function d(a){$(document).unbind(".block");m.terminateDrag(a);e&&e.set({dragBlock:null}); +m._changeFill(!1);Entry.GlobalSvg.remove();delete this.mouseDownCoordinate;delete m.dragInstance}a.stopPropagation&&a.stopPropagation();a.preventDefault&&a.preventDefault();this._changeFill(!1);var e=this.getBoard();Entry.documentMousedown&&Entry.documentMousedown.notify(a);if(!this.readOnly&&!e.viewOnly){e.setSelectedBlock(this);this.dominate();if(0===a.button||a.originalEvent&&a.originalEvent.touches){var f;f=a.originalEvent&&a.originalEvent.touches?a.originalEvent.touches[0]:a;this.mouseDownCoordinate= +{x:f.pageX,y:f.pageY};var g=$(document);g.bind("mousemove.block touchmove.block",c);g.bind("mouseup.block touchend.block",d);this.dragInstance=new Entry.DragInstance({startX:f.pageX,startY:f.pageY,offsetX:f.pageX,offsetY:f.pageY,height:0,mode:!0});e.set({dragBlock:this});this.addDragging();this.dragMode=Entry.DRAG_MODE_MOUSEDOWN}else if(Entry.Utils.isRightButton(a)){var h=this,k=h.block;if(this.isInBlockMenu)return;f=[];var g={text:Lang.Blocks.Duplication_option,enable:this.copyable,callback:function(){Entry.do("cloneBlock", +k)}},l={text:Lang.Blocks.CONTEXT_COPY_option,enable:this.copyable,callback:function(){h.block.copyToClipboard()}},n={text:Lang.Blocks.Delete_Blocks,enable:k.isDeletable(),callback:function(){Entry.do("destroyBlock",h.block)}};f.push(g);f.push(l);f.push(n);Entry.ContextMenu.show(f)}var m=this;e.workspace.getMode()===Entry.Workspace.MODE_VIMBOARD&&a&&document.getElementsByClassName("CodeMirror")[0].dispatchEvent(Entry.Utils.createMouseEvent("dragStart",event))}};b.vimBoardEvent=function(a,b,d){a&&(a= +Entry.Utils.createMouseEvent(b,a),d&&(a.block=d),document.getElementsByClassName("CodeMirror")[0].dispatchEvent(a))};b.terminateDrag=function(a){var b=this.getBoard(),d=this.dragMode,e=this.block,f=b.workspace.getMode();this.removeDragging();this.set({visible:!0});this.dragMode=Entry.DRAG_MODE_NONE;if(f===Entry.Workspace.MODE_VIMBOARD)b instanceof Entry.BlockMenu?(b.terminateDrag(),this.vimBoardEvent(a,"dragEnd",e)):b.clear();else if(d===Entry.DRAG_MODE_DRAG){var f=this.dragInstance&&this.dragInstance.isNew, +g=Entry.GlobalSvg;a=!1;var h=this.block.getPrevBlock(this.block);a=!1;switch(Entry.GlobalSvg.terminateDrag(this)){case g.DONE:g=b.magnetedBlockView;g instanceof Entry.BlockView&&(g=g.block);h&&!g?Entry.do("separateBlock",e):h||g||f?g?("next"===g.view.magneting?(h=e.getLastBlock(),this.dragMode=d,b.separate(e),this.dragMode=Entry.DRAG_MODE_NONE,Entry.do("insertBlock",g,h).isPass(f),Entry.ConnectionRipple.setView(g.view).dispose()):(Entry.do("insertBlock",e,g).isPass(f),a=!0),createjs.Sound.play("entryMagneting")): +Entry.do("moveBlock",e).isPass(f):e.getThread().view.isGlobal()?Entry.do("moveBlock",e):Entry.do("separateBlock",e);break;case g.RETURN:e=this.block;d=this.originPos;h?(this.set({animating:!1}),createjs.Sound.play("entryMagneting"),this.bindPrev(h),e.insert(h)):(f=e.getThread().view.getParent(),f instanceof Entry.Board?this._moveTo(d.x,d.y,!1):(createjs.Sound.play("entryMagneting"),Entry.do("insertBlock",e,f)));break;case g.REMOVE:createjs.Sound.play("entryDelete"),f?this.block.destroy(!1,!0):this.block.doDestroyBelow(!1)}b.setMagnetedBlock(null); +a&&Entry.ConnectionRipple.setView(e.view).dispose()}this.destroyShadow();delete this.originPos;this.dominate()};b._updateCloseBlock=function(){var a=this.getBoard(),b;if(this._skeleton.magnets){for(var d in this.magnet)if(b="next"===d?this.getBoard().getNearestMagnet(this.x,this.y+this.getBelowHeight(),d):this.getBoard().getNearestMagnet(this.x,this.y,d))return a.setMagnetedBlock(b.view,d);a.setMagnetedBlock(null)}};b.dominate=function(){this.block.getThread().view.dominate()};b.getSvgRoot=function(){for(var a= +this.getBoard().svgBlockGroup,b=this.svgGroup;b.parentNode!==a;)b=b.parentNode;return b};b.getBoard=function(){return this._board};b._setBoard=function(){this._board=this._board.code.board};b.destroy=function(a){this._destroyObservers();var b=this.svgGroup;a?$(b).fadeOut(100,function(){b.remove()}):b.remove();this._contents.forEach(function(a){a.constructor!==Entry.Block&&a.destroy()});var d=this.block;(a=d.events.viewDestroy)&&!this.isInBlockMenu&&a.forEach(function(a){Entry.Utils.isFunction(a)&& +a(d)});this._schemaChangeEvent&&this._schemaChangeEvent.destroy()};b.getShadow=function(){this._shadow||(this._shadow=Entry.SVG.createElement(this.svgGroup.cloneNode(!0),{opacity:.5}),this.getBoard().svgGroup.appendChild(this._shadow));return this._shadow};b.destroyShadow=function(){this._shadow&&(this._shadow.remove(),delete this._shadow)};b._updateMagnet=function(){if(this._skeleton.magnets){var a=this._skeleton.magnets(this);a.next&&this._nextGroup.attr("transform","translate("+a.next.x+","+a.next.y+ +")");this.magnet=a;this.block.getThread().changeEvent.notify()}};b._updateBG=function(){if(this._board.dragBlock&&this._board.dragBlock.dragInstance){var a=this.svgGroup;if(this.magnet.next){if(a=this.magneting){var b=this._board.dragBlock.getShadow(),d=this.getAbsoluteCoordinate(),e;if("previous"===a)e=this.magnet.next,e="translate("+(d.x+e.x)+","+(d.y+e.y)+")";else if("next"===a){e=this.magnet.previous;var f=this._board.dragBlock.getBelowHeight();e="translate("+(d.x+e.x)+","+(d.y+e.y-f)+")"}$(b).attr({transform:e, +display:"block"});this._clonedShadow=b;this.background&&(this.background.remove(),this.nextBackground.remove(),delete this.background,delete this.nextBackground);"previous"===a&&(a=this._board.dragBlock.getBelowHeight()+this.offsetY,this.originalHeight=this.offsetY,this.set({offsetY:a}))}else this._clonedShadow&&(this._clonedShadow.attr({display:"none"}),delete this._clonedShadow),a=this.originalHeight,void 0!==a&&(this.background&&(this.background.remove(),this.nextBackground.remove(),delete this.background, +delete this.nextBackground),this.set({offsetY:a}),delete this.originalHeight);(a=this.block.thread.changeEvent)&&a.notify()}else this.magneting?(a.attr({filter:"url(#entryBlockHighlightFilter_"+this.getBoard().suffix+")"}),a.addClass("outputHighlight")):(a.removeClass("outputHighlight"),a.removeAttr("filter"))}};b.addDragging=function(){this.svgGroup.addClass("dragging")};b.removeDragging=function(){this.svgGroup.removeClass("dragging")};b.addSelected=function(){this.svgGroup.addClass("selected")}; +b.removeSelected=function(){this.svgGroup.removeClass("selected")};b.getSkeleton=function(){return this._skeleton};b.getContentPos=function(){return this._skeleton.contentPos(this)};b.renderText=function(){this._startContentRender(Entry.Workspace.MODE_VIMBOARD)};b.renderBlock=function(){this._startContentRender(Entry.Workspace.MODE_BOARD)};b._updateOpacity=function(){this.svgGroup.attr({opacity:!1===this.visible?0:1});this.visible&&this._setPosition()};b._updateShadow=function(){this.shadow&&Entry.Utils.colorDarken(this._schema.color, +.7)};b._setMovable=function(){this.movable=null!==this.block.isMovable()?this.block.isMovable():void 0!==this._skeleton.movable?this._skeleton.movable:!0};b._setReadOnly=function(){this.readOnly=null!==this.block.isReadOnly()?this.block.isReadOnly():void 0!==this._skeleton.readOnly?this._skeleton.readOnly:!1};b._setCopyable=function(){this.copyable=null!==this.block.isCopyable()?this.block.isCopyable():void 0!==this._skeleton.copyable?this._skeleton.copyable:!0};b.bumpAway=function(a,b){var d=this; +a=a||15;b?window.setTimeout(function(){d._moveBy(a,a,!1)},b):d._moveBy(a,a,!1)};b.bindPrev=function(a){if(a){if(this._toLocalCoordinate(a.view._nextGroup),(a=a.getNextBlock())&&a!==this.block){var b=this.block.getLastBlock();b.view.magnet.next?a.view._toLocalCoordinate(b.view._nextGroup):(a.view._toGlobalCoordinate(),a.separate(),a.view.bumpAway(null,100))}}else if(a=this.block.getPrevBlock())this._toLocalCoordinate(a.view._nextGroup),(a=this.block.getNextBlock())&&a.view&&a.view._toLocalCoordinate(this._nextGroup)}; +b.getAbsoluteCoordinate=function(a){a=void 0!==a?a:this.dragMode;if(a===Entry.DRAG_MODE_DRAG)return{x:this.x,y:this.y};a=this.block.getThread().view.requestAbsoluteCoordinate(this);a.x+=this.x;a.y+=this.y;return a};b.getBelowHeight=function(){return this.block.getThread().view.requestPartHeight(this)};b._updateDisplay=function(){this.svgGroup.attr({display:!1===this.display?"none":"block"});this.display&&this._setPosition()};b._updateColor=function(){var a=this._schema.color;this.block.deletable=== +Entry.Block.DELETABLE_FALSE_LIGHTEN&&(a=Entry.Utils.colorLighten(a));this._fillColor=a;this._path.attr({fill:a});this._updateContents()};b._updateContents=function(){for(var a=0;ae||d.splice(e,1)}};b.raiseEvent=function(a,b,d){a=this._eventMap[a];var e=[];if(void 0!==a){for(var f=0;fe||d.splice(e,1)};b.doDestroyThread=function(a,b){var d=this._data,e=d.indexOf(a);0>e||d.splice(e,1)};b.getThreads=function(){return this._data.map(function(a){return a})};b.toJSON=function(){for(var a= +this.getThreads(),b=[],d=0,e=a.length;db&&(d+="...");return d};b.appendSvgOptionGroup=function(){return this._block.view.getBoard().svgGroup.elem("g")};b.getValue=function(){return this._block.params[this._index]};b.setValue=function(a,b){this.value!=a&&(this.value=a,this._block.params[this._index]=a,b&&this._blockView.reDraw())};b._isEditable=function(){if(this._block.view.dragMode==Entry.DRAG_MODE_DRAG)return!1;var a=this._block.view,b=a.getBoard();if(!0===b.disableMouseEvent)return!1;var d=b.workspace.selectedBlockView; +if(!d||b!=d.getBoard())return!1;b=a.getSvgRoot();return b==d.svgGroup||$(b).has($(a.svgGroup))};b._selectBlockView=function(){var a=this._block.view;a.getBoard().setSelectedBlock(a)};b._bindRenderOptions=function(){var a=this;$(this.svgGroup).bind("mouseup touchend",function(b){a._isEditable()&&(a.destroyOption(),a._startValue=a.getValue(),a.renderOptions())})};b.pointer=function(a){a=a||[];a.unshift(this._index);a.unshift(Entry.PARAM);return this._block.pointer(a)}})(Entry.Field.prototype);Entry.FieldAngle=function(b,a,c){this._block=a.block;this._blockView=a;this.box=new Entry.BoxModel;this.svgGroup=null;this.position=b.position;this._contents=b;this._index=c;b=this.getValue();this.setValue(this.modValue(void 0!==b?b:90));this.renderStart()};Entry.Utils.inherit(Entry.Field,Entry.FieldAngle); +(function(b){b.renderStart=function(){this.svgGroup&&$(this.svgGroup).remove();this.svgGroup=this._blockView.contentSvgGroup.elem("g",{class:"entry-input-field"});this.textElement=this.svgGroup.elem("text",{x:4,y:4,"font-size":"9pt"});this.textElement.textContent=this.getText();var a=this.getTextWidth(),b=this.position&&this.position.y?this.position.y:0;this._header=this.svgGroup.elem("rect",{x:0,y:b-8,rx:3,ry:3,width:a,height:16,rx:3,ry:3,fill:"#fff","fill-opacity":.4});this.svgGroup.appendChild(this.textElement); +this._bindRenderOptions();this.box.set({x:0,y:0,width:a,height:16})};b.renderOptions=function(){var a=this;this._attachDisposeEvent(function(){a.applyValue();a.destroyOption()});this.optionGroup=Entry.Dom("input",{class:"entry-widget-input-field",parent:$("body")});this.optionGroup.val(this.value);this.optionGroup.on("mousedown",function(a){a.stopPropagation()});this.optionGroup.on("keyup",function(b){var c=b.keyCode||b.which;a.applyValue(b);-1<[13,27].indexOf(c)&&a.destroyOption()});var b=this.getAbsolutePosFromDocument(); +b.y-=this.box.height/2;this.optionGroup.css({height:16,left:b.x,top:b.y,width:a.box.width});this.optionGroup.select();this.svgOptionGroup=this.appendSvgOptionGroup();this.svgOptionGroup.elem("circle",{x:0,y:0,r:49,class:"entry-field-angle-circle"});this._dividerGroup=this.svgOptionGroup.elem("g");for(b=0;360>b;b+=15)this._dividerGroup.elem("line",{x1:49,y1:0,x2:49-(0===b%45?10:5),y2:0,transform:"rotate("+b+", 0, 0)",class:"entry-angle-divider"});b=this.getAbsolutePosFromBoard();b.x+=this.box.width/ +2;b.y=b.y+this.box.height/2+49+1;this.svgOptionGroup.attr({class:"entry-field-angle",transform:"translate("+b.x+","+b.y+")"});var b=a.getAbsolutePosFromDocument(),d=[b.x+a.box.width/2,b.y+a.box.height/2+1];$(this.svgOptionGroup).mousemove(function(b){a.optionGroup.val(a.modValue(function(a,b){var c=b[0]-a[0],d=b[1]-a[1]-49-1,e=Math.atan(-d/c),e=Entry.toDegrees(e),e=90-e;0>c?e+=180:0Math.PI?1:0;this._fillPath=this.svgOptionGroup.elem("path",{d:"M 0,0 v -49 A 49,49 0 %LARGE 1 %X,%Y z".replace("%X",b).replace("%Y",d).replace("%LARGE",a),class:"entry-angle-fill-area"});this.svgOptionGroup.appendChild(this._dividerGroup);this._indicator&&this._indicator.remove();this._indicator=this.svgOptionGroup.elem("line",{x1:0,y1:0,x2:b,y2:d});this._indicator.attr({class:"entry-angle-indicator"})}; +b.applyValue=function(){var a=this.optionGroup.val();isNaN(a)||""===a||(a=this.modValue(a),this.setValue(a),this.updateGraph(),this.textElement.textContent=this.getValue(),this.optionGroup&&this.optionGroup.val(a),this.resize())};b.resize=function(){var a=this.getTextWidth();this._header.attr({width:a});this.optionGroup&&this.optionGroup.css({width:a});this.box.set({width:a});this._block.view.alignContent()};b.getTextWidth=function(){return this.textElement?this.textElement.getComputedTextLength()+ +8:8};b.getText=function(){return this.getValue()+"\u00b0"};b.modValue=function(a){return a%360};b.destroyOption=function(){this.disposeEvent&&(Entry.disposeEvent.detach(this.disposeEvent),delete this.documentDownEvent);this.optionGroup&&(this.optionGroup.remove(),delete this.optionGroup);this.svgOptionGroup&&(this.svgOptionGroup.remove(),delete this.svgOptionGroup);this.textElement.textContent=this.getText();this.command()}})(Entry.FieldAngle.prototype);Entry.FieldBlock=function(b,a,c,d,e){Entry.Model(this,!1);this._blockView=a;this._block=a.block;this._valueBlock=null;this.box=new Entry.BoxModel;this.changeEvent=new Entry.Event(this);this._index=c;this.contentIndex=e;this._content=b;this.acceptType=b.accept;this._restoreCurrent=b.restore;this.view=this;this.svgGroup=null;this._position=b.position;this.box.observe(a,"alignContent",["width","height"]);this.observe(this,"_updateBG",["magneting"],!1);this.renderStart(a.getBoard(),d)}; Entry.Utils.inherit(Entry.Field,Entry.FieldBlock); -(function(a){a.schema={magneting:!1};a.renderStart=function(b,a){this.svgGroup=this._blockView.contentSvgGroup.elem("g");this.view=this;this._nextGroup=this.svgGroup;this.box.set({x:0,y:0,width:0,height:20});var d=this.getValue();d&&!d.view&&(d.setThread(this),d.createView(b,a),d.getThread().view.setParent(this));this.updateValueBlock(d);this._blockView.getBoard().constructor!==Entry.Board&&this._valueBlock.view.removeControl()};a.align=function(b,a,d){var e=this.svgGroup;this._position&&(this._position.x&& -(b=this._position.x),this._position.y&&(a=this._position.y));var f=this._valueBlock;f&&(a=-.5*f.view.height);f="translate("+b+","+a+")";void 0===d||d?e.animate({transform:f},300,mina.easeinout):e.attr({transform:f});this.box.set({x:b,y:a})};a.calcWH=function(){var b=this._valueBlock;b?(b=b.view,this.box.set({width:b.width,height:b.height})):this.box.set({width:15,height:20})};a.calcHeight=a.calcWH;a.destroy=function(){};a.inspectBlock=function(){var b=null;if(this._originBlock)b=this._originBlock.type, -delete this._originBlock;else switch(this.acceptType){case "boolean":b="True";break;case "string":b="text";break;case "param":b="function_field_label"}return this._createBlockByType(b)};a._setValueBlock=function(b){this._restoreCurrent&&(this._originBlock=this._valueBlock);b||(b=this.inspectBlock());this._valueBlock=b;this.setValue(b);b.setThread(this);b.getThread().view.setParent(this);return this._valueBlock};a.getValueBlock=function(){return this._valueBlock};a.updateValueBlock=function(b){b instanceof -Entry.Block||(b=void 0);this._destroyObservers();b=this._setValueBlock(b).view;b.bindPrev(this);this._blockView.alignContent();this._posObserver=b.observe(this,"updateValueBlock",["x","y"],!1);this._sizeObserver=b.observe(this,"calcWH",["width","height"]);b=this._blockView.getBoard();b.constructor===Entry.Board&&b.generateCodeMagnetMap()};a._destroyObservers=function(){this._sizeObserver&&this._sizeObserver.destroy();this._posObserver&&this._posObserver.destroy()};a.getPrevBlock=function(b){return this._valueBlock=== -b?this:null};a.getNextBlock=function(){return null};a.requestAbsoluteCoordinate=function(b){b=this._blockView;var a=b.contentPos;b=b.getAbsoluteCoordinate();b.x+=this.box.x+a.x;b.y+=this.box.y+a.y;return b};a.dominate=function(){this._blockView.dominate()};a.isGlobal=function(){return!1};a.separate=function(b){this.getCode().createThread([b]);this.calcWH();this.changeEvent.notify()};a.getCode=function(){return this._block.thread.getCode()};a.cut=function(b){return this._valueBlock===b?[b]:null};a.replace= -function(b){"string"===typeof b&&(b=this._createBlockByType(b));var a=this._valueBlock;Entry.block[a.type].isPrimitive?(a.doNotSplice=!0,a.destroy()):"param"===this.acceptType?(this._destroyObservers(),a.view._toGlobalCoordinate(),b.getTerminateOutputBlock().view._contents[1].replace(a)):(this._destroyObservers(),a.view._toGlobalCoordinate(),this.separate(a),a.view.bumpAway(30,150));this.updateValueBlock(b);b.view._toLocalCoordinate(this.svgGroup);this.calcWH();this.changeEvent.notify()};a.setParent= -function(b){this._parent=b};a.getParent=function(){return this._parent};a._createBlockByType=function(b){this._block.getThread();var a=this._blockView.getBoard();b=new Entry.Block({type:b},this);var d=a.workspace,e;d&&(e=d.getMode());b.createView(a,e);return b};a.spliceBlock=function(){this.updateValueBlock()};a._updateBG=function(){this.magneting?this._bg=this.svgGroup.elem("path",{d:"m 8,12 l -4,0 -2,-2 0,-3 3,0 1,-1 0,-12 -1,-1 -3,0 0,-3 2,-2 l 4,0 z",fill:"#fff",stroke:"#fff","fill-opacity":.7, -transform:"translate(0,12)"}):this._bg&&(this._bg.remove(),delete this._bg)};a.getThread=function(){return this};a.pointer=function(b){b.unshift(this._index);b.unshift(Entry.PARAM);return this._block.pointer(b)}})(Entry.FieldBlock.prototype);Entry.Scroller=function(a,b,c){this._horizontal=void 0===b?!0:b;this._vertical=void 0===c?!0:c;this.board=a;this.svgGroup=null;this.vRatio=this.vY=this.vWidth=this.hRatio=this.hX=this.hWidth=0;this._visible=!0;this._opacity=-1;this.createScrollBar();this.setOpacity(0);this._bindEvent();this._scrollCommand=_.debounce(Entry.do,200)};Entry.Scroller.RADIUS=7; -(function(a){a.createScrollBar=function(){var b=Entry.Scroller.RADIUS,a=this;this.svgGroup=this.board.svg.elem("g").attr({class:"boardScrollbar"});this._horizontal&&(this.hScrollbar=this.svgGroup.elem("rect",{height:2*b,rx:b,ry:b}),this.hScrollbar.mousedown=function(b){function e(b){b.stopPropagation();b.preventDefault();b.originalEvent.touches&&(b=b.originalEvent.touches[0]);var d=a.dragInstance;a.scroll((b.pageX-d.offsetX)/a.hRatio,0);d.set({offsetX:b.pageX,offsetY:b.pageY})}function f(b){$(document).unbind(".scroll"); -delete a.dragInstance}if(0===b.button||b instanceof Touch){Entry.documentMousedown&&Entry.documentMousedown.notify(b);var g=$(document);g.bind("mousemove.scroll",e);g.bind("mouseup.scroll",f);g.bind("touchmove.scroll",e);g.bind("touchend.scroll",f);a.dragInstance=new Entry.DragInstance({startX:b.pageX,startY:b.pageY,offsetX:b.pageX,offsetY:b.pageY})}b.stopPropagation()});this._vertical&&(this.vScrollbar=this.svgGroup.elem("rect",{width:2*b,rx:b,ry:b}),this.vScrollbar.mousedown=function(b){function e(b){b.stopPropagation(); -b.preventDefault();b.originalEvent.touches&&(b=b.originalEvent.touches[0]);var d=a.dragInstance;a.scroll(0,(b.pageY-d.offsetY)/a.vRatio);d.set({offsetX:b.pageX,offsetY:b.pageY})}function f(b){$(document).unbind(".scroll");delete a.dragInstance}if(0===b.button||b instanceof Touch){Entry.documentMousedown&&Entry.documentMousedown.notify(b);var g=$(document);g.bind("mousemove.scroll",e);g.bind("mouseup.scroll",f);g.bind("touchmove.scroll",e);g.bind("touchend.scroll",f);a.dragInstance=new Entry.DragInstance({startX:b.pageX, -startY:b.pageY,offsetX:b.pageX,offsetY:b.pageY})}b.stopPropagation()})};a.updateScrollBar=function(b,a){this._horizontal&&(this.hX+=b*this.hRatio,this.hScrollbar.attr({x:this.hX}));this._vertical&&(this.vY+=a*this.vRatio,this.vScrollbar.attr({y:this.vY}))};a.scroll=function(b,a){if(this.board.code){var d=this.board.svgBlockGroup.getBoundingClientRect(),e=this.board.svgDom,f=d.left-this.board.offset().left,g=d.top-this.board.offset().top,h=d.height;b=Math.max(-d.width+Entry.BOARD_PADDING-f,b);a=Math.max(-h+ -Entry.BOARD_PADDING-g,a);b=Math.min(e.width()-Entry.BOARD_PADDING-f,b);a=Math.min(e.height()-Entry.BOARD_PADDING-g,a);this._scroll(b,a);this._diffs||(this._diffs=[0,0]);this._diffs[0]+=b;this._diffs[1]+=a;this._scrollCommand("scrollBoard",this._diffs[0],this._diffs[1],!0)}};a._scroll=function(b,a){this.board.code.moveBy(b,a);this.updateScrollBar(b,a)};a.setVisible=function(b){b!=this.isVisible()&&(this._visible=b,this.svgGroup.attr({display:!0===b?"block":"none"}))};a.isVisible=function(){return this._visible}; -a.setOpacity=function(b){this._opacity!=b&&(this.hScrollbar.attr({opacity:b}),this.vScrollbar.attr({opacity:b}),this._opacity=b)};a.resizeScrollBar=function(){if(this._visible){var b=this.board,a=b.svgBlockGroup.getBoundingClientRect(),d=b.svgDom,e=d.width(),d=d.height(),f=a.left-b.offset().left,b=a.top-b.offset().top,g=a.width,a=a.height;if(this._horizontal){var h=-g+Entry.BOARD_PADDING,k=e-Entry.BOARD_PADDING,g=(e+2*Entry.Scroller.RADIUS)*g/(k-h+g);isNaN(g)&&(g=0);this.hX=(f-h)/(k-h)*(e-g-2*Entry.Scroller.RADIUS); -this.hScrollbar.attr({width:g,x:this.hX,y:d-2*Entry.Scroller.RADIUS});this.hRatio=(e-g-2*Entry.Scroller.RADIUS)/(k-h)}this._vertical&&(f=-a+Entry.BOARD_PADDING,g=d-Entry.BOARD_PADDING,a=(d+2*Entry.Scroller.RADIUS)*a/(g-f+a),this.vY=(b-f)/(g-f)*(d-a-2*Entry.Scroller.RADIUS),this.vScrollbar.attr({height:a,y:this.vY,x:e-2*Entry.Scroller.RADIUS}),this.vRatio=(d-a-2*Entry.Scroller.RADIUS)/(g-f))}};a._bindEvent=function(){var b=_.debounce(this.resizeScrollBar,200);this.board.changeEvent.attach(this,b); -Entry.windowResized&&Entry.windowResized.attach(this,b)}})(Entry.Scroller.prototype);Entry.Board=function(a){Entry.Model(this,!1);this.changeEvent=new Entry.Event(this);this.createView(a);this.updateOffset();this.scroller=new Entry.Scroller(this,!0,!0);this._magnetMap={};Entry.ANIMATION_DURATION=200;Entry.BOARD_PADDING=100;this._initContextOptions();Entry.Utils.disableContextmenu(this.svgDom);this._addControl();this._bindEvent()};Entry.Board.OPTION_PASTE=0;Entry.Board.OPTION_ALIGN=1;Entry.Board.OPTION_CLEAR=2; -(function(a){a.schema={code:null,dragBlock:null,magnetedBlockView:null,selectedBlockView:null};a.createView=function(b){var a=b.dom,a="string"===typeof a?$("#"+a):$(a);if("DIV"!==a.prop("tagName"))return console.error("Dom is not div element");this.view=a;this._svgId="play"+(new Date).getTime();this.workspace=b.workspace;this._activatedBlockView=null;this.wrapper=Entry.Dom("div",{parent:a,class:"entryBoardWrapper"});this.svgDom=Entry.Dom($(''), -{parent:this.wrapper});this.visible=!0;var d=this;this.svg=Entry.SVG(this._svgId);$(window).scroll(function(){d.updateOffset()});this.svgGroup=this.svg.elem("g");this.svgThreadGroup=this.svgGroup.elem("g");this.svgThreadGroup.board=this;this.svgBlockGroup=this.svgGroup.elem("g");this.svgBlockGroup.board=this;b.isOverlay?(this.wrapper.addClass("entryOverlayBoard"),this.generateButtons(),this.suffix="overlayBoard"):this.suffix="board";Entry.Utils.addFilters(this.svg,this.suffix);b=Entry.Utils.addBlockPattern(this.svg, -this.suffix);this.patternRect=b.rect;this.pattern=b.pattern};a.changeCode=function(b){this.code&&this.codeListener&&this.code.changeEvent.detach(this.codeListener);this.set({code:b});var a=this;b&&(this.codeListener=this.code.changeEvent.attach(this,function(){a.changeEvent.notify()}),b.createView(this));this.scroller.resizeScrollBar()};a.bindCodeView=function(b){this.svgBlockGroup.remove();this.svgThreadGroup.remove();this.svgBlockGroup=b.svgBlockGroup;this.svgThreadGroup=b.svgThreadGroup;this.svgGroup.appendChild(this.svgThreadGroup); -this.svgGroup.appendChild(this.svgBlockGroup)};a.setMagnetedBlock=function(b,a){if(this.magnetedBlockView){if(this.magnetedBlockView===b)return;this.magnetedBlockView.set({magneting:!1})}this.set({magnetedBlockView:b});b&&(b.set({magneting:a}),b.dominate())};a.getCode=function(){return this.code};a.findById=function(b){return this.code.findById(b)};a._addControl=function(){var b=this.svgDom,a=this;b.mousedown(function(){a.onMouseDown.apply(a,arguments)});b.bind("touchstart",function(){a.onMouseDown.apply(a, -arguments)});b.on("wheel",function(){a.mouseWheel.apply(a,arguments)});var d=a.scroller;d&&(b.mouseenter(function(b){d.setOpacity(1)}),b.mouseleave(function(b){d.setOpacity(0)}))};a.onMouseDown=function(b){function a(b){b.stopPropagation&&b.stopPropagation();b.preventDefault&&b.preventDefault();b=b.originalEvent&&b.originalEvent.touches?b.originalEvent.touches[0]:b;var c=f.dragInstance;f.scroller.scroll(b.pageX-c.offsetX,b.pageY-c.offsetY);c.set({offsetX:b.pageX,offsetY:b.pageY})}function d(b){$(document).unbind(".entryBoard"); -delete f.dragInstance}if(this.workspace.getMode()!=Entry.Workspace.MODE_VIMBOARD){b.stopPropagation&&b.stopPropagation();b.preventDefault&&b.preventDefault();if(0===b.button||b.originalEvent&&b.originalEvent.touches){b=b.originalEvent&&b.originalEvent.touches?b.originalEvent.touches[0]:b;Entry.documentMousedown&&Entry.documentMousedown.notify(b);var e=$(document);e.bind("mousemove.entryBoard",a);e.bind("mouseup.entryBoard",d);e.bind("touchmove.entryBoard",a);e.bind("touchend.entryBoard",d);this.dragInstance= -new Entry.DragInstance({startX:b.pageX,startY:b.pageY,offsetX:b.pageX,offsetY:b.pageY})}else if(Entry.Utils.isRightButton(b)){if(!this.visible)return;b=[];this._contextOptions[Entry.Board.OPTION_PASTE].option.enable=!!Entry.clipboard;for(e=0;eb&&(f=f+e+10,e=0,d=15);e=Math.max(e,k.width);l=d+15;h._moveTo(f,l,!1);d=d+k.height+15}}this.scroller.resizeScrollBar()};a.clear=function(){this.svgBlockGroup.remove();this.svgThreadGroup.remove()};a.updateOffset=function(){this._offset=this.svg.getBoundingClientRect();var b=$(window),a=b.scrollTop(), -b=b.scrollLeft(),d=this._offset;this.relativeOffset={top:d.top-a,left:d.left-b};this.btnWrapper&&this.btnWrapper.attr({transform:"translate("+(d.width/2-65)+","+(d.height-200)+")"})};a.generateButtons=function(){var b=this,a=this.svgGroup.elem("g");this.btnWrapper=a;var d=a.elem("text",{x:27,y:33,class:"entryFunctionButtonText"});d.textContent=Lang.Buttons.save;var e=a.elem("text",{x:102.5,y:33,class:"entryFunctionButtonText"});e.textContent=Lang.Buttons.cancel;var f=a.elem("circle",{cx:27.5,cy:27.5, -r:27.5,class:"entryFunctionButton"}),a=a.elem("circle",{cx:102.5,cy:27.5,r:27.5,class:"entryFunctionButton"});$(f).bind("mousedown touchstart",function(){b.save()});$(d).bind("mousedown touchstart",function(){b.save()});$(a).bind("mousedown touchstart",function(){b.cancelEdit()});$(e).bind("mousedown touchstart",function(){b.cancelEdit()})};a.cancelEdit=function(){this.workspace.setMode(Entry.Workspace.MODE_BOARD,"cancelEdit")};a.save=function(){this.workspace.setMode(Entry.Workspace.MODE_BOARD,"save")}; -a.generateCodeMagnetMap=function(){var b=this.code;if(b&&this.dragBlock)for(var a in this.dragBlock.magnet){var d=this._getCodeBlocks(b,a);d.sort(function(b,a){return b.point-a.point});d.unshift({point:-Number.MAX_VALUE,blocks:[]});for(var e=1;eg.point&&(g.blocks.push(h),l++,g=d[l],g););delete f.startBlock}f.endPoint=Number.MAX_VALUE;d[e-1].endPoint=f.point}this._magnetMap[a]=d}};a._getCodeBlocks=function(b,a){b=b.getThreads(); -var d=[],e;switch(a){case "previous":e=this._getNextMagnets;break;case "next":e=this._getPreviousMagnets;break;case "string":e=this._getFieldMagnets;break;case "boolean":e=this._getFieldMagnets;break;case "param":e=this._getOutputMagnets;break;default:return[]}for(var f=0;fd.endPoint)f=h+1;else{e=d.blocks;for(f=0;fb||a.splice(b,1))};a.raiseEvent=function(b,a,d){b=this._eventMap[b];var e=[];if(void 0!==b){for(var f=0;fb||a.splice(b,1)};a.doDestroyThread=function(b,a){a=this._data;b=a.indexOf(b);0>b||a.splice(b,1)};a.getThreads=function(){return this._data.map(function(b){return b})};a.toJSON=function(){for(var b=this.getThreads(),a=[],d=0, -e=b.length;dc;c+=15)this._dividerGroup.elem("line",{x1:49,y1:0,x2:49-(0===c%45?10:5),y2:0,transform:"rotate("+c+", 0, 0)",class:"entry-angle-divider"});c=this.getAbsolutePosFromBoard();c.x+=this.box.width/ -2;c.y=c.y+this.box.height/2+49+1;this.svgOptionGroup.attr({class:"entry-field-angle",transform:"translate("+c.x+","+c.y+")"});var c=a.getAbsolutePosFromDocument(),d=[c.x+a.box.width/2,c.y+a.box.height/2+1];$(this.svgOptionGroup).mousemove(function(c){a.optionGroup.val(a.modValue(function(a,b){var c=b[0]-a[0];a=b[1]-a[1]-49-1;b=Math.atan(-a/c);b=Entry.toDegrees(b);b=90-b;0>c?b+=180:0Math.PI?1:0;this._fillPath=this.svgOptionGroup.elem("path",{d:"M 0,0 v -49 A 49,49 0 %LARGE 1 %X,%Y z".replace("%X",c).replace("%Y",d).replace("%LARGE",a),class:"entry-angle-fill-area"});this.svgOptionGroup.appendChild(this._dividerGroup);this._indicator&&this._indicator.remove();this._indicator=this.svgOptionGroup.elem("line",{x1:0,y1:0,x2:c,y2:d});this._indicator.attr({class:"entry-angle-indicator"})}; -a.applyValue=function(){var a=this.optionGroup.val();isNaN(a)||(a=this.modValue(a),this.setValue(a),this.updateGraph(),this.textElement.textContent=this.getValue(),this.optionGroup&&this.optionGroup.val(a),this.resize())};a.resize=function(){var a=this.getTextWidth();this._header.attr({width:a});this.optionGroup&&this.optionGroup.css({width:a});this.box.set({width:a});this._block.view.alignContent()};a.getTextWidth=function(){return this.textElement?this.textElement.getComputedTextLength()+8:8};a.getText= -function(){return this.getValue()+"\u00b0"};a.modValue=function(a){return a%360};a.destroyOption=function(){this.disposeEvent&&(Entry.disposeEvent.detach(this.disposeEvent),delete this.documentDownEvent);this.optionGroup&&(this.optionGroup.remove(),delete this.optionGroup);this.svgOptionGroup&&(this.svgOptionGroup.remove(),delete this.svgOptionGroup);this.textElement.textContent=this.getText();this.command()}})(Entry.FieldAngle.prototype);Entry.FieldColor=function(a,b,c){this._block=b.block;this._blockView=b;this.box=new Entry.BoxModel;this.svgGroup=null;this._contents=a;this._index=c;this._position=a.position;this.key=a.key;this.setValue(this.getValue()||"#FF0000");this.renderStart(b)};Entry.Utils.inherit(Entry.Field,Entry.FieldColor); -(function(a){a.renderStart=function(){this.svgGroup&&$(this.svgGroup).remove();this.svgGroup=this._blockView.contentSvgGroup.elem("g",{class:"entry-field-color"});var a=this._position,c;a?(c=a.x||0,a=a.y||0):(c=0,a=-8);this._header=this.svgGroup.elem("rect",{x:c,y:a,width:14.5,height:16,fill:this.getValue()});this._bindRenderOptions();this.box.set({x:c,y:a,width:14.5,height:16})};a.renderOptions=function(){var a=this;this._attachDisposeEvent();var c=Entry.FieldColor.getWidgetColorList();this.optionGroup= -Entry.Dom("table",{class:"entry-widget-color-table",parent:$("body")});for(var d=0;d'),{parent:this._container});this.svg=Entry.SVG("globalSvg");this.top=this.left=0;this._inited=!0}}; -a.setView=function(a,c){if(a!=this._view&&!a.block.isReadOnly()&&a.movable)return this._view=a,this._mode=c,c!==Entry.Workspace.MODE_VIMBOARD&&a.set({visible:!1}),this.draw(),this.show(),this.align(),this.position(),!0};a.draw=function(){var a=this._view;this._svg&&this.remove();var c=this._mode==Entry.Workspace.MODE_VIMBOARD;this.svgGroup=Entry.SVG.createElement(a.svgGroup.cloneNode(!0),{opacity:1});this.svg.appendChild(this.svgGroup);c&&(a=$(this.svgGroup),a.find("g").css({filter:"none"}),a.find("path").velocity({opacity:0}, -{duration:500}),a.find("text").velocity({fill:"#000000"},{duration:530}))};a.remove=function(){this.svgGroup&&(this.svgGroup.remove(),delete this.svgGroup,delete this._view,delete this._offsetX,delete this._offsetY,delete this._startX,delete this._startY,this.hide())};a.align=function(){var a=this._view.getSkeleton().box(this._view).offsetX||0,c=this._view.getSkeleton().box(this._view).offsetY||0,a=-1*a+1,c=-1*c+1;this._offsetX=a;this._offsetY=c;this.svgGroup.attr({transform:"translate("+a+","+c+ -")"})};a.show=function(){this._container.removeClass("entryRemove")};a.hide=function(){this._container.addClass("entryRemove")};a.position=function(){var a=this._view;if(a){var c=a.getAbsoluteCoordinate(),a=a.getBoard().offset();this.left=c.x+a.left-this._offsetX;this.top=c.y+a.top-this._offsetY;this.svgDom.css({transform:"translate3d("+this.left+"px,"+this.top+"px, 0px)"})}};a.terminateDrag=function(a){var c=Entry.mouseCoordinate,d=a.getBoard(),e=d.workspace.blockMenu,f=e.offset().left,g=e.offset().top, -h=e.visible?e.svgDom.width():0;return c.y>d.offset().top-20&&c.x>f+h?this.DONE:c.y>g&&c.x>f&&e.visible?a.block.isDeletable()?this.REMOVE:this.RETURN:this.RETURN};a.addControl=function(a){this.onMouseDown.apply(this,arguments)};a.onMouseDown=function(a){function c(a){var b=a.pageX;a=a.pageY;var c=e.left+(b-e._startX),d=e.top+(a-e._startY);e.svgDom.css({left:c,top:d});e._startX=b;e._startY=a;e.left=c;e.top=d}function d(a){$(document).unbind(".block")}this._startY=a.pageY;var e=this;a.stopPropagation(); -a.preventDefault();var f=$(document);f.bind("mousemove.block",c);f.bind("mouseup.block",d);f.bind("touchmove.block",c);f.bind("touchend.block",d);this._startX=a.pageX;this._startY=a.pageY}})(Entry.GlobalSvg);Entry.Mutator=function(){};(function(a){a.mutate=function(a,c){a=Entry.block[a];void 0===a.changeEvent&&(a.changeEvent=new Entry.Event);a.template=c.template;a.params=c.params;a.changeEvent.notify(1)}})(Entry.Mutator);(function(a){})(Entry.Mutator.prototype);Entry.RenderView=function(a,b){this._align=b||"CENTER";a="string"===typeof a?$("#"+a):$(a);if("DIV"!==a.prop("tagName"))return console.error("Dom is not div element");this.view=a;this.viewOnly=!0;this.suffix="renderView";this.disableMouseEvent=this.visible=!0;this._svgId="renderView_"+(new Date).getTime();this._generateView();this.offset=this.svgDom.offset();this.setWidth();this.svg=Entry.SVG(this._svgId);Entry.Utils.addFilters(this.svg,this.suffix);this.svg&&(this.svgGroup=this.svg.elem("g"),this.svgThreadGroup= +(function(b){b.DONE=0;b._inited=!1;b.REMOVE=1;b.RETURN=2;b.createDom=function(){if(!this.inited){$("#globalSvgSurface").remove();$("#globalSvg").remove();var a=$("body");this._container=Entry.Dom("div",{classes:["globalSvgSurface","entryRemove"],id:"globalSvgSurface",parent:a});this.svgDom=Entry.Dom($(''),{parent:this._container});this.svg=Entry.SVG("globalSvg");this.top=this.left=0;this._inited=!0}}; +b.setView=function(a,b){if(a!=this._view&&!a.block.isReadOnly()&&a.movable)return this._view=a,this._mode=b,b!==Entry.Workspace.MODE_VIMBOARD&&a.set({visible:!1}),this.draw(),this.show(),this.align(),this.position(),!0};b.draw=function(){var a=this._view;this._svg&&this.remove();var b=this._mode==Entry.Workspace.MODE_VIMBOARD;this.svgGroup=Entry.SVG.createElement(a.svgGroup.cloneNode(!0),{opacity:1});this.svg.appendChild(this.svgGroup);b&&(a=$(this.svgGroup),a.find("g").css({filter:"none"}),a.find("path").velocity({opacity:0}, +{duration:500}),a.find("text").velocity({fill:"#000000"},{duration:530}))};b.remove=function(){this.svgGroup&&(this.svgGroup.remove(),delete this.svgGroup,delete this._view,delete this._offsetX,delete this._offsetY,delete this._startX,delete this._startY,this.hide())};b.align=function(){var a=this._view.getSkeleton().box(this._view).offsetX||0,b=this._view.getSkeleton().box(this._view).offsetY||0,a=-1*a+1,b=-1*b+1;this._offsetX=a;this._offsetY=b;this.svgGroup.attr({transform:"translate("+a+","+b+ +")"})};b.show=function(){this._container.removeClass("entryRemove")};b.hide=function(){this._container.addClass("entryRemove")};b.position=function(){var a=this._view;if(a){var b=a.getAbsoluteCoordinate(),a=a.getBoard().offset();this.left=b.x+a.left-this._offsetX;this.top=b.y+a.top-this._offsetY;this.svgDom.css({transform:"translate3d("+this.left+"px,"+this.top+"px, 0px)"})}};b.terminateDrag=function(a){var b=Entry.mouseCoordinate,d=a.getBoard(),e=d.workspace.blockMenu,f=e.offset().left,g=e.offset().top, +h=e.visible?e.svgDom.width():0;return b.y>d.offset().top-20&&b.x>f+h?this.DONE:b.y>g&&b.x>f&&e.visible?a.block.isDeletable()?this.REMOVE:this.RETURN:this.RETURN};b.addControl=function(a){this.onMouseDown.apply(this,arguments)};b.onMouseDown=function(a){function b(a){var c=a.pageX;a=a.pageY;var d=e.left+(c-e._startX),f=e.top+(a-e._startY);e.svgDom.css({left:d,top:f});e._startX=c;e._startY=a;e.left=d;e.top=f}function d(a){$(document).unbind(".block")}this._startY=a.pageY;var e=this;a.stopPropagation(); +a.preventDefault();var f=$(document);f.bind("mousemove.block",b);f.bind("mouseup.block",d);f.bind("touchmove.block",b);f.bind("touchend.block",d);this._startX=a.pageX;this._startY=a.pageY}})(Entry.GlobalSvg);Entry.Mutator=function(){};(function(b){b.mutate=function(a,b){var d=Entry.block[a];void 0===d.changeEvent&&(d.changeEvent=new Entry.Event);d.template=b.template;d.params=b.params;d.changeEvent.notify(1)}})(Entry.Mutator);(function(b){})(Entry.Mutator.prototype);Entry.RenderView=function(b,a){this._align=a||"CENTER";b="string"===typeof b?$("#"+b):$(b);if("DIV"!==b.prop("tagName"))return console.error("Dom is not div element");this.view=b;this.viewOnly=!0;this.suffix="renderView";this.disableMouseEvent=this.visible=!0;this._svgId="renderView_"+(new Date).getTime();this._generateView();this.offset=this.svgDom.offset();this.setWidth();this.svg=Entry.SVG(this._svgId);Entry.Utils.addFilters(this.svg,this.suffix);this.svg&&(this.svgGroup=this.svg.elem("g"),this.svgThreadGroup= this.svgGroup.elem("g"),this.svgThreadGroup.board=this,this.svgBlockGroup=this.svgGroup.elem("g"),this.svgBlockGroup.board=this)}; -(function(a){a.schema={code:null,dragBlock:null,closeBlock:null,selectedBlockView:null};a._generateView=function(){this.renderViewContainer=Entry.Dom("div",{"class":"renderViewContainer",parent:this.view});this.svgDom=Entry.Dom($(''),{parent:this.renderViewContainer})};a.changeCode=function(a){if(!(a instanceof Entry.Code))return console.error("You must inject code instance");this.code=a;this.svg|| -(this.svg=Entry.SVG(this._svgId),this.svgGroup=this.svg.elem("g"),this.svgThreadGroup=this.svgGroup.elem("g"),this.svgThreadGroup.board=this,this.svgBlockGroup=this.svgGroup.elem("g"),this.svgBlockGroup.board=this);a.createView(this);this.align();this.resize()};a.align=function(){var a=this.code.getThreads();if(a&&0!==a.length){for(var c=0,d="LEFT"==this._align?20:this.svgDom.width()/2,e=0,f=a.length;e'),{parent:this.renderViewContainer})};b.changeCode=function(a){if(!(a instanceof Entry.Code))return console.error("You must inject code instance");this.code=a;this.svg|| +(this.svg=Entry.SVG(this._svgId),this.svgGroup=this.svg.elem("g"),this.svgThreadGroup=this.svgGroup.elem("g"),this.svgThreadGroup.board=this,this.svgBlockGroup=this.svgGroup.elem("g"),this.svgBlockGroup.board=this);a.createView(this);this.align();this.resize()};b.align=function(){var a=this.code.getThreads();if(a&&0!==a.length){for(var b=0,d="LEFT"==this._align?20:this.svgDom.width()/2,e=0,f=a.length;e'), +{parent:this.wrapper});this.visible=!0;var d=this;this.svg=Entry.SVG(this._svgId);$(window).scroll(function(){d.updateOffset()});this.svgGroup=this.svg.elem("g");this.svgThreadGroup=this.svgGroup.elem("g");this.svgThreadGroup.board=this;this.svgBlockGroup=this.svgGroup.elem("g");this.svgBlockGroup.board=this;a.isOverlay?(this.wrapper.addClass("entryOverlayBoard"),this.generateButtons(),this.suffix="overlayBoard"):this.suffix="board";Entry.Utils.addFilters(this.svg,this.suffix);a=Entry.Utils.addBlockPattern(this.svg, +this.suffix);this.patternRect=a.rect;this.pattern=a.pattern};b.changeCode=function(a){this.code&&this.codeListener&&this.code.changeEvent.detach(this.codeListener);this.set({code:a});var b=this;a&&(this.codeListener=this.code.changeEvent.attach(this,function(){b.changeEvent.notify()}),a.createView(this));this.scroller.resizeScrollBar()};b.bindCodeView=function(a){this.svgBlockGroup.remove();this.svgThreadGroup.remove();this.svgBlockGroup=a.svgBlockGroup;this.svgThreadGroup=a.svgThreadGroup;this.svgGroup.appendChild(this.svgThreadGroup); +this.svgGroup.appendChild(this.svgBlockGroup)};b.setMagnetedBlock=function(a,b){if(this.magnetedBlockView){if(this.magnetedBlockView===a)return;this.magnetedBlockView.set({magneting:!1})}this.set({magnetedBlockView:a});a&&(a.set({magneting:b}),a.dominate())};b.getCode=function(){return this.code};b.findById=function(a){return this.code.findById(a)};b._addControl=function(){var a=this.svgDom,b=this;a.mousedown(function(){b.onMouseDown.apply(b,arguments)});a.bind("touchstart",function(){b.onMouseDown.apply(b, +arguments)});a.on("wheel",function(){b.mouseWheel.apply(b,arguments)});var d=b.scroller;d&&(a.mouseenter(function(a){d.setOpacity(1)}),a.mouseleave(function(a){d.setOpacity(0)}))};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=f.dragInstance;f.scroller.scroll(a.pageX-c.offsetX,a.pageY-c.offsetY);c.set({offsetX:a.pageX,offsetY:a.pageY})}function d(a){$(document).unbind(".entryBoard"); +delete f.dragInstance}if(this.workspace.getMode()!=Entry.Workspace.MODE_VIMBOARD){a.stopPropagation&&a.stopPropagation();a.preventDefault&&a.preventDefault();if(0===a.button||a.originalEvent&&a.originalEvent.touches){a=a.originalEvent&&a.originalEvent.touches?a.originalEvent.touches[0]:a;Entry.documentMousedown&&Entry.documentMousedown.notify(a);var e=$(document);e.bind("mousemove.entryBoard",b);e.bind("mouseup.entryBoard",d);e.bind("touchmove.entryBoard",b);e.bind("touchend.entryBoard",d);this.dragInstance= +new Entry.DragInstance({startX:a.pageX,startY:a.pageY,offsetX:a.pageX,offsetY:a.pageY})}else if(Entry.Utils.isRightButton(a)){if(!this.visible)return;a=[];this._contextOptions[Entry.Board.OPTION_PASTE].option.enable=!!Entry.clipboard;for(e=0;ea&&(f=f+e+10,e=0,d=15);e=Math.max(e,k.width);l=d+15;h._moveTo(f,l,!1);d=d+k.height+15}}this.scroller.resizeScrollBar()};b.clear=function(){this.svgBlockGroup.remove();this.svgThreadGroup.remove()};b.updateOffset=function(){this._offset=this.svg.getBoundingClientRect();var a=$(window),b=a.scrollTop(), +a=a.scrollLeft(),d=this._offset;this.relativeOffset={top:d.top-b,left:d.left-a};this.btnWrapper&&this.btnWrapper.attr({transform:"translate("+(d.width/2-65)+","+(d.height-200)+")"})};b.generateButtons=function(){var a=this,b=this.svgGroup.elem("g");this.btnWrapper=b;var d=b.elem("text",{x:27,y:33,class:"entryFunctionButtonText"});d.textContent=Lang.Buttons.save;var e=b.elem("text",{x:102.5,y:33,class:"entryFunctionButtonText"});e.textContent=Lang.Buttons.cancel;var f=b.elem("circle",{cx:27.5,cy:27.5, +r:27.5,class:"entryFunctionButton"}),b=b.elem("circle",{cx:102.5,cy:27.5,r:27.5,class:"entryFunctionButton"});$(f).bind("mousedown touchstart",function(){a.save()});$(d).bind("mousedown touchstart",function(){a.save()});$(b).bind("mousedown touchstart",function(){a.cancelEdit()});$(e).bind("mousedown touchstart",function(){a.cancelEdit()})};b.cancelEdit=function(){this.workspace.setMode(Entry.Workspace.MODE_BOARD,"cancelEdit")};b.save=function(){this.workspace.setMode(Entry.Workspace.MODE_BOARD,"save")}; +b.generateCodeMagnetMap=function(){var a=this.code;if(a&&this.dragBlock)for(var b in this.dragBlock.magnet){var d=this._getCodeBlocks(a,b);d.sort(function(a,b){return a.point-b.point});d.unshift({point:-Number.MAX_VALUE,blocks:[]});for(var e=1;eg.point&&(g.blocks.push(h),l++,g=d[l],g););delete f.startBlock}f.endPoint=Number.MAX_VALUE;d[e-1].endPoint=f.point}this._magnetMap[b]=d}};b._getCodeBlocks=function(a,b){var d=a.getThreads(), +e=[],f;switch(b){case "previous":f=this._getNextMagnets;break;case "next":f=this._getPreviousMagnets;break;case "string":f=this._getFieldMagnets;break;case "boolean":f=this._getFieldMagnets;break;case "param":f=this._getOutputMagnets;break;default:return[]}for(var g=0;gd.endPoint)f=h+1;else{e=d.blocks;for(f=0;fthis.events[b].indexOf(f)&&this.events[b].push(f)}}this._schema.event&&this.thread.registerEvent(this,this._schema.event);a=this.params;b=this._schema.params;for(e=0;b&&e=e&&g>=b)}};b.align=function(){var a=this.getPosition();this.svgGroup.attr({transform:"translate("+a.x+","+a.y+")"})};b.setPosition=function(){if(this.board){var a=this.board.svgDom;this._x=a.width()-110;this._y=a.height()-110;this.align()}};b.getPosition=function(){return{x:this._x,y:this._y}};b.tAnimation=function(a){if(a!==this.isOver){a=void 0===a?!0:a;var b,d=this.trashcanTop;b=a?{translateX:15,translateY:-25, +rotateZ:30}:{translateX:0,translateY:0,rotateZ:0};$(d).velocity(b,{duration:50});this.isOver=a}};b.setBoard=function(a){this._dragBlockObserver&&this._dragBlockObserver.destroy();this.board=a;this.svgGroup||this._generateView();var b=a.svg,d=b.firstChild;d?b.insertBefore(this.svgGroup,d):b.appendChild(this.svgGroup);this._dragBlockObserver=a.observe(this,"updateDragBlock",["dragBlock"]);this.svgGroup.attr({filter:"url(#entryTrashcanFilter_"+a.suffix+")"});this.setPosition()}})(Entry.FieldTrashcan.prototype);Entry.Vim=function(b){b="string"===typeof b?$("#"+b):$(b);if("DIV"!==b.prop("tagName"))return console.error("Dom is not div element");this.createDom(b);this._parser=new Entry.Parser("maze","js",this.codeMirror);this._blockParser=new Entry.Parser("maze","block");Entry.Model(this,!1);window.eventset=[]}; +(function(b){b.createDom=function(a){function b(a){var c=e.getCodeToText(a.block);e.codeMirror.display.dragFunctions.leave(a);var d=Entry.Utils.createMouseEvent("mousedown",a);e.codeMirror.display.scroller.dispatchEvent(d);var c=c.split("\n"),k=c.length-1,l=0;c.forEach(function(a,b){e.codeMirror.replaceSelection(a);l=e.doc.getCursor().line;e.codeMirror.indentLine(l);0!==b&&k===b||e.codeMirror.replaceSelection("\n")});a=Entry.Utils.createMouseEvent("mouseup",a);e.codeMirror.display.scroller.dispatchEvent(a)} function d(a){e.codeMirror.display.dragFunctions.over(a)}var e;this.view=Entry.Dom("div",{parent:a,class:"entryVimBoard"});this.codeMirror=CodeMirror(this.view[0],{lineNumbers:!0,value:"",mode:{name:"javascript",globalVars:!0},theme:"default",indentUnit:4,styleActiveLine:!0,extraKeys:{"Ctrl-Space":"javascriptComplete",Tab:function(a){var b=Array(a.getOption("indentUnit")+1).join(" ");a.replaceSelection(b)}},lint:!0,viewportMargin:10});this.doc=this.codeMirror.getDoc();e=this;a=this.view[0];a.removeEventListener("dragEnd", -c);a.removeEventListener("dragOver",d);a.addEventListener("dragEnd",c);a.addEventListener("dragOver",d)};a.hide=function(){this.view.addClass("entryRemove")};a.show=function(){this.view.removeClass("entryRemove")};a.textToCode=function(){var a=this.codeMirror.getValue(),a=this._parser.parse(a);if(0===a.length)throw"\ube14\ub85d \ud30c\uc2f1 \uc624\ub958";return a};a.codeToText=function(a){a=this._blockParser.parse(a);this.codeMirror.setValue(a)};a.getCodeToText=function(a){return this._blockParser.parse(a)}})(Entry.Vim.prototype);Entry.Xml={};Entry.Xml.isTypeOf=function(a,b){return b.getAttribute("type")==a};Entry.Xml.getNextBlock=function(a){a=a.childNodes;for(var b=0;b"+d[1];c.addEventListener("click",function(){Entry.engine.toggleStop()});this.view_.appendChild(c);this.curtainView_=c;Entry.pictureEditable&&(c=Entry.createElement("div","entryPicture"),c.addClass("entryPlaygroundPictureWorkspace"),c.addClass("entryRemove"),this.view_.appendChild(c),this.generatePictureView(c),this.pictureView_=c);c=Entry.createElement("div","entryText");c.addClass("entryPlaygroundTextWorkspace");c.addClass("entryRemove");this.view_.appendChild(c);this.generateTextView(c); +this.textView_=c;Entry.soundEditable&&(c=Entry.createElement("div","entrySound"),c.addClass("entryPlaygroundSoundWorkspace"),c.addClass("entryRemove"),this.view_.appendChild(c),this.generateSoundView(c),this.soundView_=c);c=Entry.createElement("div","entryDefault");c.addClass("entryPlaygroundDefaultWorkspace");this.view_.appendChild(c);this.generateDefaultView(c);this.defaultView_=c;c=Entry.createElement("div","entryCode");c.addClass("entryPlaygroundCodeWorkspace");c.addClass("entryRemove");this.view_.appendChild(c); +this.generateCodeView(c);this.codeView_=c;d=Entry.createElement("div");d.addClass("entryPlaygroundResizeWorkspace","entryRemove");this.resizeHandle_=d;this.view_.appendChild(d);this.initializeResizeHandle(d);this.codeView_=c;Entry.addEventListener("run",function(a){Entry.playground.curtainView_.removeClass("entryRemove")});Entry.addEventListener("stop",function(a){Entry.playground.curtainView_.addClass("entryRemove")})}};Entry.Playground.prototype.generateDefaultView=function(b){return b}; +Entry.Playground.prototype.generateTabView=function(b){var a=this,c=Entry.createElement("ul");c.addClass("entryTabListWorkspace");this.tabList_=c;b.appendChild(c);this.tabViewElements={};b=Entry.createElement("li","entryCodeTab");b.innerHTML=Lang.Workspace.tab_code;b.addClass("entryTabListItemWorkspace");b.addClass("entryTabSelected");c.appendChild(b);b.bindOnClick(function(b){a.changeViewMode("code");a.blockMenu.reDraw()});this.tabViewElements.code=b;Entry.pictureEditable&&(b=Entry.createElement("li", +"entryPictureTab"),b.innerHTML=Lang.Workspace.tab_picture,b.addClass("entryTabListItemWorkspace"),c.appendChild(b),b.bindOnClick(function(a){Entry.playground.changeViewMode("picture")}),this.tabViewElements.picture=b,b=Entry.createElement("li","entryTextboxTab"),b.innerHTML=Lang.Workspace.tab_text,b.addClass("entryTabListItemWorkspace"),c.appendChild(b),b.bindOnClick(function(a){Entry.playground.changeViewMode("text")}),this.tabViewElements.text=b,b.addClass("entryRemove"));Entry.soundEditable&&(b= +Entry.createElement("li","entrySoundTab"),b.innerHTML=Lang.Workspace.tab_sound,b.addClass("entryTabListItemWorkspace"),c.appendChild(b),b.bindOnClick(function(a){Entry.playground.changeViewMode("sound")}),this.tabViewElements.sound=b);Entry.hasVariableManager&&(b=Entry.createElement("li","entryVariableTab"),b.innerHTML=Lang.Workspace.tab_attribute,b.addClass("entryTabListItemWorkspace"),b.addClass("entryVariableTabWorkspace"),c.appendChild(b),b.bindOnClick(function(a){Entry.playground.toggleOnVariableView(); +Entry.playground.changeViewMode("variable")}),this.tabViewElements.variable=b)}; +Entry.Playground.prototype.generateCodeView=function(b){var a=this.createVariableView();b.appendChild(a);this.variableView_=a;b=Entry.Dom(b);a=Entry.Dom("div",{parent:b,id:"entryWorkspaceBoard",class:"entryWorkspaceBoard"});b=Entry.Dom("div",{parent:b,id:"entryWorkspaceBlockMenu",class:"entryWorkspaceBlockMenu"});this.mainWorkspace=new Entry.Workspace({blockMenu:{dom:b,align:"LEFT",categoryData:EntryStatic.getAllBlocks(),scroll:!0},board:{dom:a}});this.blockMenu=this.mainWorkspace.blockMenu;this.board= +this.mainWorkspace.board;Entry.hw&&this.updateHW()}; +Entry.Playground.prototype.generatePictureView=function(b){if("workspace"==Entry.type){var a=Entry.createElement("div","entryAddPicture");a.addClass("entryPlaygroundAddPicture");a.bindOnClick(function(a){Entry.dispatchEvent("openPictureManager")});var c=Entry.createElement("div","entryAddPictureInner");c.addClass("entryPlaygroundAddPictureInner");c.innerHTML=Lang.Workspace.picture_add;a.appendChild(c);b.appendChild(a);a=Entry.createElement("ul","entryPictureList");a.addClass("entryPlaygroundPictureList"); +$&&$(a).sortable({start:function(a,b){b.item.data("start_pos",b.item.index())},stop:function(a,b){var c=b.item.data("start_pos"),g=b.item.index();Entry.playground.movePicture(c,g)},axis:"y"});b.appendChild(a);this.pictureListView_=a;a=Entry.createElement("div","entryPainter");a.addClass("entryPlaygroundPainter");b.appendChild(a);this.painter=new Entry.Painter;this.painter.initialize(a)}else"phone"==Entry.type&&(a=Entry.createElement("div","entryAddPicture"),a.addClass("entryPlaygroundAddPicturePhone"), +a.bindOnClick(function(a){Entry.dispatchEvent("openPictureManager")}),c=Entry.createElement("div","entryAddPictureInner"),c.addClass("entryPlaygroundAddPictureInnerPhone"),c.innerHTML=Lang.Workspace.picture_add,a.appendChild(c),b.appendChild(a),a=Entry.createElement("ul","entryPictureList"),a.addClass("entryPlaygroundPictureListPhone"),$&&$(a).sortable({start:function(a,b){b.item.data("start_pos",b.item.index())},stop:function(a,b){var c=b.item.data("start_pos"),g=b.item.index();Entry.playground.movePicture(c, +g)},axis:"y"}),b.appendChild(a),this.pictureListView_=a)}; +Entry.Playground.prototype.generateTextView=function(b){var a=Entry.createElement("div");b.appendChild(a);b=Entry.createElement("div");b.addClass("textProperties");a.appendChild(b);var c=Entry.createElement("div");c.addClass("entryTextFontSelect");b.appendChild(c);var d=Entry.createElement("select","entryPainterAttrFontName");d.addClass("entryPlaygroundPainterAttrFontName","entryTextFontSelecter");d.size="1";d.onchange=function(a){Entry.playground.object.entity.setFontType(a.target.value)};for(var e= +0;e p").html(Lang.Menus.linebreak_on_desc_1),$(".entryPlaygroundLinebreakDescription > ul > li").eq(0).html(Lang.Menus.linebreak_on_desc_2),$(".entryPlaygroundLinebreakDescription > ul > li").eq(1).html(Lang.Menus.linebreak_on_desc_3)); +Entry.playground.setFontAlign(Entry.playground.object.entity.getTextAlign());b=Entry.playground.object.entity.getFontSize();Entry.playground.fontSizeIndiciator.style.width=b+"%";Entry.playground.fontSizeKnob.style.left=.88*b+"px"}};Entry.Playground.prototype.injectSound=function(){var b=this.soundListView_;if(b){for(;b.hasChildNodes();)b.removeChild(b.lastChild);if(this.object)for(var a=this.object.sounds,c=0,d=a.length;c