From b2bf4ffbb797e0ccb92d6f148fc023ad63df67db Mon Sep 17 00:00:00 2001 From: vivid Date: Mon, 17 Oct 2016 15:35:28 +0900 Subject: [PATCH] remove scene bug fix --- dist/entry.js | 35088 ++++++++++++++++++++++---------------------- dist/entry.min.js | 2801 ++-- src/container.js | 24 +- 3 files changed, 18878 insertions(+), 19035 deletions(-) diff --git a/dist/entry.js b/dist/entry.js index c1099ea5b3..908f326fa4 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(); @@ -17,37 +17,35 @@ var Entry = {block:{}, TEXT_ALIGN_CENTER:0, TEXT_ALIGN_LEFT:1, TEXT_ALIGN_RIGHT: 0 === Object.keys(Entry.container.inputValue).length && Entry.variableContainer.generateAnswer(); Entry.start(); Entry.Loader.isLoaded() && Entry.Loader.handleLoad(); - 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 d = 0;d < b.length;d++) { - for (var c = b[d], e = {category:c.getAttribute("id"), blocks:[]}, c = c.childNodes, f = 0;f < c.length;f++) { - var g = c[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 d = [], c = jQuery.parseXML(a).getElementsByTagName("category"), e = 0;e < c.length;e++) { + for (var f = c[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")); + } + d.push(g); + } + Entry.playground.setBlockMenu(d); +}, 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())) { @@ -56,178 +54,177 @@ 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 d = 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 d = 9 * a / 16; + Entry.engine.view_.style.width = a + "px"; Entry.engine.view_.style.height = d + "px"; Entry.engine.view_.style.top = "40px"; - 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 c = Entry.engine.view_.getElementsByClassName("entryAddButtonWorkspace_w")[0]; - c && (Entry.objectAddable ? (c.style.top = d + 24 + "px", c.style.width = .7 * b + "px") : c.style.display = "none"); + c && (Entry.objectAddable ? (c.style.top = d + 24 + "px", c.style.width = .7 * a + "px") : c.style.display = "none"); if (c = Entry.engine.view_.getElementsByClassName("entryRunButtonWorkspace_w")[0]) { - Entry.objectAddable ? (c.style.top = d + 24 + "px", c.style.left = .7 * b + "px", c.style.width = .3 * b + "px") : (c.style.left = "2px", c.style.top = d + 24 + "px", c.style.width = b - 4 + "px"); + Entry.objectAddable ? (c.style.top = d + 24 + "px", c.style.left = .7 * a + "px", c.style.width = .3 * a + "px") : (c.style.left = "2px", c.style.top = d + 24 + "px", c.style.width = a - 4 + "px"); } if (c = Entry.engine.view_.getElementsByClassName("entryStopButtonWorkspace_w")[0]) { - Entry.objectAddable ? (c.style.top = d + 24 + "px", c.style.left = .7 * b + "px", c.style.width = .3 * b + "px") : (c.style.left = "2px", c.style.top = d + 24 + "px", c.style.width = b + "px"); + Entry.objectAddable ? (c.style.top = d + 24 + "px", c.style.left = .7 * a + "px", c.style.width = .3 * a + "px") : (c.style.left = "2px", c.style.top = d + 24 + "px", c.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 d = a.target, c = 0 !== $(b.view_).find(d).length, d = d.tagName.toUpperCase(); - a = a.type; - !b.isEditing || "INPUT" === d && c || "touchstart" === a || b.editObjectValues(!1); + 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 d = b.target, c = 0 !== $(a.view_).find(d).length, d = d.tagName.toUpperCase(); + b = b.type; + !a.isEditing || "INPUT" === d && c || "touchstart" === b || a.editObjectValues(!1); } -}, generateFunctionSchema:function(a) { - a = "func_" + a; - if (!Entry.block[a]) { - var b = function() { +}, generateFunctionSchema:function(b) { + b = "func_" + b; + if (!Entry.block[b]) { + var a = function() { }; - b.prototype = Entry.block.function_general; - b = new b; - b.changeEvent = new Entry.Event; - b.template = Lang.template.function_general; - Entry.block[a] = b; + a.prototype = Entry.block.function_general; + a = new a; + a.changeEvent = new Entry.Event; + a.template = Lang.template.function_general; + Entry.block[b] = a; } }}; window.Entry = Entry; Entry.Albert = {PORT_MAP:{leftWheel:0, rightWheel:0, buzzer:0, leftEye:0, rightEye:0, note:0, bodyLed:0, frontLed:0, padWidth:0, padHeight:0}, setZero:function() { - var a = Entry.Albert.PORT_MAP, b = Entry.hw.sendQueue, d; - for (d in a) { - b[d] = a[d]; + var b = Entry.Albert.PORT_MAP, a = Entry.hw.sendQueue, d; + for (d in b) { + a[d] = b[d]; } 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:{temperature:{name:Lang.Blocks.ALBERT_sensor_temperature, type:"input", pos:{x:0, y:0}}, accelerationX:{name:Lang.Blocks.ALBERT_sensor_acceleration_x, type:"input", pos:{x:0, y:0}}, accelerationY:{name:Lang.Blocks.ALBERT_sensor_acceleration_y, type:"input", pos:{x:0, y:0}}, accelerationZ:{name:Lang.Blocks.ALBERT_sensor_acceleration_z, type:"input", pos:{x:0, y:0}}, frontOid:{name:Lang.Blocks.ALBERT_sensor_front_oid, type:"input", pos:{x:0, y:0}}, backOid:{name:Lang.Blocks.ALBERT_sensor_back_oid, type:"input", pos:{x:0, y:0}}, positionX:{name:Lang.Blocks.ALBERT_sensor_position_x, type:"input", pos:{x:0, y:0}}, positionY:{name:Lang.Blocks.ALBERT_sensor_position_y, type:"input", pos:{x:0, y:0}}, orientation:{name:Lang.Blocks.ALBERT_sensor_orientation, 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_left_proximity, type:"input", pos:{x:178, y:401}}, rightProximity:{name:Lang.Blocks.ALBERT_sensor_right_proximity, 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_en, type:"output", pos:{x:367, y:308}}, frontLed:{name:Lang.Hw.front + " " + Lang.Hw.led_en, 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); +rightEye:{name:Lang.Hw.rightEye, type:"output", pos:{x:164, y:13}}, bodyLed:{name:Lang.Hw.body + " " + Lang.Hw.led_en, type:"output", pos:{x:367, y:308}}, frontLed:{name:Lang.Hw.front + " " + Lang.Hw.led_en, 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 = []; }, controller:{PI:3.14159265, PI2:6.2831853, prevDirection:0, prevDirectionFine:0, directionFineCount:0, positionCount:0, finalPositionCount:0, GAIN_ANGLE:30, GAIN_ANGLE_FINE:30, GAIN_POSITION_FINE:30, STRAIGHT_SPEED:20, MAX_BASE_SPEED:20, GAIN_BASE_SPEED:1, GAIN_POSITION:35, POSITION_TOLERANCE_FINE:3, POSITION_TOLERANCE_FINE_LARGE:5, POSITION_TOLERANCE_ROUGH:5, POSITION_TOLERANCE_ROUGH_LARGE:10, ORIENTATION_TOLERANCE_FINE:.08, ORIENTATION_TOLERANCE_ROUGH:.09, ORIENTATION_TOLERANCE_ROUGH_LARGE:.18, MINIMUM_WHEEL_SPEED:18, MINIMUM_WHEEL_SPEED_FINE:15, clear:function() { this.finalPositionCount = this.positionCount = this.directionFineCount = this.prevDirectionFine = this.prevDirection = 0; -}, controlAngleFine:function(a, b) { - var d = Entry.hw.sendQueue; - a = this.validateRadian(b - a); - b = Math.abs(a); - if (b < this.ORIENTATION_TOLERANCE_FINE) { +}, controlAngleFine:function(b, a) { + var d = Entry.hw.sendQueue, c = this.validateRadian(a - b), e = Math.abs(c); + if (e < this.ORIENTATION_TOLERANCE_FINE) { return !1; } - var c = 0 < a ? 1 : -1; - if (0 > c * this.prevDirectionFine && 5 < ++this.directionFineCount) { + var f = 0 < c ? 1 : -1; + if (0 > f * this.prevDirectionFine && 5 < ++this.directionFineCount) { return !1; } - this.prevDirectionFine = c; - 0 < a ? (a = Math.log(1 + b) * this.GAIN_ANGLE_FINE, a < this.MINIMUM_WHEEL_SPEED && (a = this.MINIMUM_WHEEL_SPEED)) : (a = -Math.log(1 + b) * this.GAIN_ANGLE_FINE, a > -this.MINIMUM_WHEEL_SPEED && (a = -this.MINIMUM_WHEEL_SPEED)); - a = parseInt(a); - d.leftWheel = -a; - d.rightWheel = a; + this.prevDirectionFine = f; + f = 0; + 0 < c ? (f = Math.log(1 + e) * this.GAIN_ANGLE_FINE, f < this.MINIMUM_WHEEL_SPEED && (f = this.MINIMUM_WHEEL_SPEED)) : (f = -Math.log(1 + e) * this.GAIN_ANGLE_FINE, f > -this.MINIMUM_WHEEL_SPEED && (f = -this.MINIMUM_WHEEL_SPEED)); + f = parseInt(f); + d.leftWheel = -f; + d.rightWheel = f; return !0; -}, controlAngle:function(a, b) { - var d = Entry.hw.sendQueue; - a = this.validateRadian(b - a); - b = Math.abs(a); - if (b < this.ORIENTATION_TOLERANCE_ROUGH) { +}, controlAngle:function(b, a) { + var d = Entry.hw.sendQueue, c = this.validateRadian(a - b), e = Math.abs(c); + if (e < this.ORIENTATION_TOLERANCE_ROUGH) { return !1; } - var c = 0 < a ? 1 : -1; - if (b < this.ORIENTATION_TOLERANCE_ROUGH_LARGE && 0 > c * this.prevDirection) { + var f = 0 < c ? 1 : -1; + if (e < this.ORIENTATION_TOLERANCE_ROUGH_LARGE && 0 > f * this.prevDirection) { return !1; } - this.prevDirection = c; - 0 < a ? (a = Math.log(1 + b) * this.GAIN_ANGLE, a < this.MINIMUM_WHEEL_SPEED && (a = this.MINIMUM_WHEEL_SPEED)) : (a = -Math.log(1 + b) * this.GAIN_ANGLE, a > -this.MINIMUM_WHEEL_SPEED && (a = -this.MINIMUM_WHEEL_SPEED)); - a = parseInt(a); - d.leftWheel = -a; - d.rightWheel = a; + this.prevDirection = f; + f = 0; + 0 < c ? (f = Math.log(1 + e) * this.GAIN_ANGLE, f < this.MINIMUM_WHEEL_SPEED && (f = this.MINIMUM_WHEEL_SPEED)) : (f = -Math.log(1 + e) * this.GAIN_ANGLE, f > -this.MINIMUM_WHEEL_SPEED && (f = -this.MINIMUM_WHEEL_SPEED)); + f = parseInt(f); + d.leftWheel = -f; + d.rightWheel = f; return !0; -}, controlPositionFine:function(a, b, d, c, e) { +}, controlPositionFine:function(b, a, d, c, e) { var f = Entry.hw.sendQueue; - d = this.validateRadian(Math.atan2(e - b, c - a) - d); + d = this.validateRadian(Math.atan2(e - a, c - b) - d); var g = Math.abs(d); - a = c - a; - b = e - b; - b = Math.sqrt(a * a + b * b); - if (b < this.POSITION_TOLERANCE_FINE) { + b = c - b; + a = e - a; + a = Math.sqrt(b * b + a * a); + if (a < this.POSITION_TOLERANCE_FINE) { return !1; } - if (b < this.POSITION_TOLERANCE_FINE_LARGE && 5 < ++this.finalPositionCount) { + if (a < this.POSITION_TOLERANCE_FINE_LARGE && 5 < ++this.finalPositionCount) { return this.finalPositionCount = 0, !1; } - d = 0 < d ? Math.log(1 + g) * this.GAIN_POSITION_FINE : -Math.log(1 + g) * this.GAIN_POSITION_FINE; - d = parseInt(d); - f.leftWheel = this.MINIMUM_WHEEL_SPEED_FINE - d; - f.rightWheel = this.MINIMUM_WHEEL_SPEED_FINE + d; + a = 0; + a = 0 < d ? Math.log(1 + g) * this.GAIN_POSITION_FINE : -Math.log(1 + g) * this.GAIN_POSITION_FINE; + a = parseInt(a); + f.leftWheel = this.MINIMUM_WHEEL_SPEED_FINE - a; + f.rightWheel = this.MINIMUM_WHEEL_SPEED_FINE + a; return !0; -}, controlPosition:function(a, b, d, c, e) { +}, controlPosition:function(b, a, d, c, e) { var f = Entry.hw.sendQueue; - d = this.validateRadian(Math.atan2(e - b, c - a) - d); + d = this.validateRadian(Math.atan2(e - a, c - b) - d); var g = Math.abs(d); - a = c - a; - b = e - b; - b = Math.sqrt(a * a + b * b); - if (b < this.POSITION_TOLERANCE_ROUGH) { + b = c - b; + a = e - a; + a = Math.sqrt(b * b + a * a); + if (a < this.POSITION_TOLERANCE_ROUGH) { return !1; } - if (b < this.POSITION_TOLERANCE_ROUGH_LARGE) { + if (a < this.POSITION_TOLERANCE_ROUGH_LARGE) { if (10 < ++this.positionCount) { return this.positionCount = 0, !1; } } else { this.positionCount = 0; } - .01 > g ? (f.leftWheel = this.STRAIGHT_SPEED, f.rightWheel = this.STRAIGHT_SPEED) : (b = (this.MINIMUM_WHEEL_SPEED + .5 / g) * this.GAIN_BASE_SPEED, b > this.MAX_BASE_SPEED && (b = this.MAX_BASE_SPEED), d = 0 < d ? Math.log(1 + g) * this.GAIN_POSITION : -Math.log(1 + g) * this.GAIN_POSITION, b = parseInt(b), d = parseInt(d), f.leftWheel = b - d, f.rightWheel = b + d); + .01 > g ? (f.leftWheel = this.STRAIGHT_SPEED, f.rightWheel = this.STRAIGHT_SPEED) : (a = (this.MINIMUM_WHEEL_SPEED + .5 / g) * this.GAIN_BASE_SPEED, a > this.MAX_BASE_SPEED && (a = this.MAX_BASE_SPEED), e = 0, e = 0 < d ? Math.log(1 + g) * this.GAIN_POSITION : -Math.log(1 + g) * this.GAIN_POSITION, a = parseInt(a), e = parseInt(e), f.leftWheel = a - e, f.rightWheel = a + e); return !0; -}, validateRadian:function(a) { - return a > this.PI ? a - this.PI2 : a < -this.PI ? a + this.PI2 : a; -}, toRadian:function(a) { - return 3.14159265 * a / 180; +}, validateRadian:function(b) { + return b > this.PI ? b - this.PI2 : b < -this.PI ? b + this.PI2 : b; +}, toRadian:function(b) { + return 3.14159265 * b / 180; }}, name:"albert"}; Blockly.Blocks.albert_hand_found = {init:function() { this.setColour("#00979D"); @@ -235,9 +232,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 d = Entry.hw.portData; + return 40 < d.leftProximity || 40 < d.rightProximity; }; Blockly.Blocks.albert_is_oid_value = {init:function() { this.setColour("#00979D"); @@ -247,11 +244,9 @@ Blockly.Blocks.albert_is_oid_value = {init:function() { this.setOutput(!0, "Boolean"); this.setInputsInline(!0); }}; -Entry.block.albert_is_oid_value = function(a, b) { - a = Entry.hw.portData; - var d = b.getField("OID", b); - b = b.getNumberValue("VALUE"); - return "FRONT" == d ? a.frontOid == b : a.backOid == b; +Entry.block.albert_is_oid_value = function(b, a) { + var d = Entry.hw.portData, c = a.getField("OID", a), e = a.getNumberValue("VALUE"); + return "FRONT" == c ? d.frontOid == e : d.backOid == e; }; Blockly.Blocks.albert_value = {init:function() { this.setColour("#00979D"); @@ -260,10 +255,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 d = Entry.hw.portData, c = a.getField("DEVICE"); + return d[c]; }; Blockly.Blocks.albert_move_forward_for_secs = {init:function() { this.setColour("#00979D"); @@ -274,30 +268,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 d = 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(); + d.leftWheel = 0; + d.rightWheel = 0; + return a.callReturn(); } - b.isStart = !0; - b.timeFlag = 1; - a.leftWheel = 30; - a.rightWheel = 30; - a = 1E3 * b.getNumberValue("VALUE"); - var d = setTimeout(function() { - b.timeFlag = 0; - Entry.Albert.removeTimeout(d); - }, a); - Entry.Albert.timeouts.push(d); - return b; + a.isStart = !0; + a.timeFlag = 1; + d.leftWheel = 30; + d.rightWheel = 30; + var d = 1E3 * a.getNumberValue("VALUE"), c = setTimeout(function() { + a.timeFlag = 0; + Entry.Albert.removeTimeout(c); + }, d); + Entry.Albert.timeouts.push(c); + return a; }; Blockly.Blocks.albert_move_backward_for_secs = {init:function() { this.setColour("#00979D"); @@ -308,30 +301,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 d = 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(); + d.leftWheel = 0; + d.rightWheel = 0; + return a.callReturn(); } - b.isStart = !0; - b.timeFlag = 1; - a.leftWheel = -30; - a.rightWheel = -30; - a = 1E3 * b.getNumberValue("VALUE"); - var d = setTimeout(function() { - b.timeFlag = 0; - Entry.Albert.removeTimeout(d); - }, a); - Entry.Albert.timeouts.push(d); - return b; + a.isStart = !0; + a.timeFlag = 1; + d.leftWheel = -30; + d.rightWheel = -30; + var d = 1E3 * a.getNumberValue("VALUE"), c = setTimeout(function() { + a.timeFlag = 0; + Entry.Albert.removeTimeout(c); + }, d); + Entry.Albert.timeouts.push(c); + return a; }; Blockly.Blocks.albert_turn_for_secs = {init:function() { this.setColour("#00979D"); @@ -342,29 +334,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 d = 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(); + d.leftWheel = 0; + d.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 d = setTimeout(function() { - b.timeFlag = 0; - Entry.Albert.removeTimeout(d); - }, a); - Entry.Albert.timeouts.push(d); - return b; + a.isStart = !0; + a.timeFlag = 1; + "LEFT" == a.getField("DIRECTION", a) ? (d.leftWheel = -30, d.rightWheel = 30) : (d.leftWheel = 30, d.rightWheel = -30); + var d = 1E3 * a.getNumberValue("VALUE"), c = setTimeout(function() { + a.timeFlag = 0; + Entry.Albert.removeTimeout(c); + }, d); + Entry.Albert.timeouts.push(c); + return a; }; Blockly.Blocks.albert_change_both_wheels_by = {init:function() { this.setColour("#00979D"); @@ -377,12 +368,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 d = b.getNumberValue("LEFT"), c = b.getNumberValue("RIGHT"); - a.leftWheel = void 0 != a.leftWheel ? a.leftWheel + d : d; - a.rightWheel = void 0 != a.rightWheel ? a.rightWheel + c : c; - return b.callReturn(); +Entry.block.albert_change_both_wheels_by = function(b, a) { + var d = Entry.hw.sendQueue, c = a.getNumberValue("LEFT"), e = a.getNumberValue("RIGHT"); + d.leftWheel = void 0 != d.leftWheel ? d.leftWheel + c : c; + d.rightWheel = void 0 != d.rightWheel ? d.rightWheel + e : e; + return a.callReturn(); }; Blockly.Blocks.albert_set_both_wheels_to = {init:function() { this.setColour("#00979D"); @@ -395,11 +385,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 d = Entry.hw.sendQueue; + d.leftWheel = a.getNumberValue("LEFT"); + d.rightWheel = a.getNumberValue("RIGHT"); + return a.callReturn(); }; Blockly.Blocks.albert_change_wheel_by = {init:function() { this.setColour("#00979D"); @@ -410,11 +400,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 d = b.getField("DIRECTION"), c = b.getNumberValue("VALUE"); - "LEFT" == d ? a.leftWheel = void 0 != a.leftWheel ? a.leftWheel + c : c : ("RIGHT" != d && (a.leftWheel = void 0 != a.leftWheel ? a.leftWheel + c : c), a.rightWheel = void 0 != a.rightWheel ? a.rightWheel + c : c); - return b.callReturn(); +Entry.block.albert_change_wheel_by = function(b, a) { + var d = Entry.hw.sendQueue, c = a.getField("DIRECTION"), e = a.getNumberValue("VALUE"); + "LEFT" == c ? d.leftWheel = void 0 != d.leftWheel ? d.leftWheel + e : e : ("RIGHT" != c && (d.leftWheel = void 0 != d.leftWheel ? d.leftWheel + e : e), d.rightWheel = void 0 != d.rightWheel ? d.rightWheel + e : e); + return a.callReturn(); }; Blockly.Blocks.albert_set_wheel_to = {init:function() { this.setColour("#00979D"); @@ -425,11 +414,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 d = b.getField("DIRECTION"), c = b.getNumberValue("VALUE"); - "LEFT" == d ? a.leftWheel = c : ("RIGHT" != d && (a.leftWheel = c), a.rightWheel = c); - return b.callReturn(); +Entry.block.albert_set_wheel_to = function(b, a) { + var d = Entry.hw.sendQueue, c = a.getField("DIRECTION"), e = a.getNumberValue("VALUE"); + "LEFT" == c ? d.leftWheel = e : ("RIGHT" != c && (d.leftWheel = e), d.rightWheel = e); + return a.callReturn(); }; Blockly.Blocks.albert_stop = {init:function() { this.setColour("#00979D"); @@ -438,11 +426,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 d = Entry.hw.sendQueue; + d.leftWheel = 0; + d.rightWheel = 0; + return a.callReturn(); }; Blockly.Blocks.albert_set_pad_size_to = {init:function() { this.setColour("#00979D"); @@ -455,11 +443,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 d = Entry.hw.sendQueue; + d.padWidth = a.getNumberValue("WIDTH"); + d.padHeight = a.getNumberValue("HEIGHT"); + return a.callReturn(); }; Blockly.Blocks.albert_move_to_x_y_on_board = {init:function() { this.setColour("#00979D"); @@ -472,62 +460,61 @@ Blockly.Blocks.albert_move_to_x_y_on_board = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.albert_move_to_x_y_on_board = function(a, b) { - var d = Entry.hw.sendQueue, c = Entry.hw.portData; - a = Entry.Albert.controller; - if (b.isStart) { - if (b.isMoving) { - 0 <= c.positionX && (b.x = c.positionX); - 0 <= c.positionY && (b.y = c.positionY); - b.theta = c.orientation; - switch(b.boardState) { +Entry.block.albert_move_to_x_y_on_board = function(b, a) { + var d = Entry.hw.sendQueue, c = Entry.hw.portData, e = Entry.Albert.controller; + if (a.isStart) { + if (a.isMoving) { + 0 <= c.positionX && (a.x = c.positionX); + 0 <= c.positionY && (a.y = c.positionY); + a.theta = c.orientation; + switch(a.boardState) { case 1: - if (0 == b.initialized) { - if (0 > b.x || 0 > b.y) { + if (0 == a.initialized) { + if (0 > a.x || 0 > a.y) { d.leftWheel = 20; d.rightWheel = -20; break; } - b.initialized = !0; + a.initialized = !0; } - d = a.toRadian(b.theta); - 0 == a.controlAngle(d, Math.atan2(b.targetY - b.y, b.targetX - b.x)) && (b.boardState = 2); + d = e.toRadian(a.theta); + 0 == e.controlAngle(d, Math.atan2(a.targetY - a.y, a.targetX - a.x)) && (a.boardState = 2); break; case 2: - 0 == a.controlPosition(b.x, b.y, a.toRadian(b.theta), b.targetX, b.targetY) && (b.boardState = 3); + 0 == e.controlPosition(a.x, a.y, e.toRadian(a.theta), a.targetX, a.targetY) && (a.boardState = 3); break; case 3: - 0 == a.controlPositionFine(b.x, b.y, a.toRadian(b.theta), b.targetX, b.targetY) && (d.leftWheel = 0, d.rightWheel = 0, b.isMoving = !1); + 0 == e.controlPositionFine(a.x, a.y, e.toRadian(a.theta), a.targetX, a.targetY) && (d.leftWheel = 0, d.rightWheel = 0, a.isMoving = !1); } - return b; + return a; } - delete b.isStart; - delete b.isMoving; - delete b.initialized; - delete b.boardState; - delete b.x; - delete b.y; - delete b.theta; - delete b.targetX; - delete b.targetY; + delete a.isStart; + delete a.isMoving; + delete a.initialized; + delete a.boardState; + delete a.x; + delete a.y; + delete a.theta; + delete a.targetX; + delete a.targetY; Entry.engine.isContinue = !1; d.leftWheel = 0; d.rightWheel = 0; - return b.callReturn(); + return a.callReturn(); } - b.isStart = !0; - b.isMoving = !0; - b.initialized = !1; - b.boardState = 1; - b.x = -1; - b.y = -1; - b.theta = -200; - b.targetX = b.getNumberValue("X"); - b.targetY = b.getNumberValue("Y"); - a.clear(); + a.isStart = !0; + a.isMoving = !0; + a.initialized = !1; + a.boardState = 1; + a.x = -1; + a.y = -1; + a.theta = -200; + a.targetX = a.getNumberValue("X"); + a.targetY = a.getNumberValue("Y"); + e.clear(); d.leftWheel = 0; d.rightWheel = 0; - return b; + return a; }; Blockly.Blocks.albert_set_orientation_on_board = {init:function() { this.setColour("#00979D"); @@ -538,41 +525,40 @@ Blockly.Blocks.albert_set_orientation_on_board = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.albert_set_orientation_on_board = function(a, b) { - a = Entry.hw.sendQueue; - var d = Entry.hw.portData, c = Entry.Albert.controller; - if (b.isStart) { - if (b.isMoving) { - b.theta = d.orientation; - switch(b.boardState) { +Entry.block.albert_set_orientation_on_board = function(b, a) { + var d = Entry.hw.sendQueue, c = Entry.hw.portData, e = Entry.Albert.controller; + if (a.isStart) { + if (a.isMoving) { + a.theta = c.orientation; + switch(a.boardState) { case 1: - var d = c.toRadian(b.theta), e = c.toRadian(b.targetTheta); - 0 == c.controlAngle(d, e) && (b.boardState = 2); + var c = e.toRadian(a.theta), f = e.toRadian(a.targetTheta); + 0 == e.controlAngle(c, f) && (a.boardState = 2); break; case 2: - d = c.toRadian(b.theta), e = c.toRadian(b.targetTheta), 0 == c.controlAngleFine(d, e) && (a.leftWheel = 0, a.rightWheel = 0, b.isMoving = !1); + c = e.toRadian(a.theta), f = e.toRadian(a.targetTheta), 0 == e.controlAngleFine(c, f) && (d.leftWheel = 0, d.rightWheel = 0, a.isMoving = !1); } - return b; + return a; } - delete b.isStart; - delete b.isMoving; - delete b.boardState; - delete b.theta; - delete b.targetTheta; + delete a.isStart; + delete a.isMoving; + delete a.boardState; + delete a.theta; + delete a.targetTheta; Entry.engine.isContinue = !1; - a.leftWheel = 0; - a.rightWheel = 0; - return b.callReturn(); + d.leftWheel = 0; + d.rightWheel = 0; + return a.callReturn(); } - b.isStart = !0; - b.isMoving = !0; - b.boardState = 1; - b.theta = -200; - b.targetTheta = b.getNumberValue("ORIENTATION"); - c.clear(); - a.leftWheel = 0; - a.rightWheel = 0; - return b; + a.isStart = !0; + a.isMoving = !0; + a.boardState = 1; + a.theta = -200; + a.targetTheta = a.getNumberValue("ORIENTATION"); + e.clear(); + d.leftWheel = 0; + d.rightWheel = 0; + return a; }; Blockly.Blocks.albert_set_eye_to = {init:function() { this.setColour("#00979D"); @@ -582,11 +568,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 d = b.getField("DIRECTION", b), c = Number(b.getField("COLOR", b)); - "LEFT" == d ? a.leftEye = c : ("RIGHT" != d && (a.leftEye = c), a.rightEye = c); - return b.callReturn(); +Entry.block.albert_set_eye_to = function(b, a) { + var d = Entry.hw.sendQueue, c = a.getField("DIRECTION", a), e = Number(a.getField("COLOR", a)); + "LEFT" == c ? d.leftEye = e : ("RIGHT" != c && (d.leftEye = e), d.rightEye = e); + return a.callReturn(); }; Blockly.Blocks.albert_clear_eye = {init:function() { this.setColour("#00979D"); @@ -595,11 +580,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 d = b.getField("DIRECTION", b); - "LEFT" == d ? a.leftEye = 0 : ("RIGHT" != d && (a.leftEye = 0), a.rightEye = 0); - return b.callReturn(); +Entry.block.albert_clear_eye = function(b, a) { + var d = Entry.hw.sendQueue, c = a.getField("DIRECTION", a); + "LEFT" == c ? d.leftEye = 0 : ("RIGHT" != c && (d.leftEye = 0), d.rightEye = 0); + return a.callReturn(); }; Blockly.Blocks.albert_body_led = {init:function() { this.setColour("#00979D"); @@ -608,10 +592,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 d = Entry.hw.sendQueue; + "ON" == a.getField("STATE", a) ? d.bodyLed = 1 : d.bodyLed = 0; + return a.callReturn(); }; Blockly.Blocks.albert_front_led = {init:function() { this.setColour("#00979D"); @@ -620,10 +604,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 d = Entry.hw.sendQueue; + "ON" == a.getField("STATE", a) ? d.frontLed = 1 : d.frontLed = 0; + return a.callReturn(); }; Blockly.Blocks.albert_beep = {init:function() { this.setColour("#00979D"); @@ -632,28 +616,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 d = 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(); + d.buzzer = 0; + return a.callReturn(); } - b.isStart = !0; - b.timeFlag = 1; - a.buzzer = 440; - a.note = 0; - var d = setTimeout(function() { - b.timeFlag = 0; - Entry.Albert.removeTimeout(d); + a.isStart = !0; + a.timeFlag = 1; + d.buzzer = 440; + d.note = 0; + var c = setTimeout(function() { + a.timeFlag = 0; + Entry.Albert.removeTimeout(c); }, 200); - Entry.Albert.timeouts.push(d); - return b; + Entry.Albert.timeouts.push(c); + return a; }; Blockly.Blocks.albert_change_buzzer_by = {init:function() { this.setColour("#00979D"); @@ -664,12 +648,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 d = b.getNumberValue("VALUE"); - a.buzzer = void 0 != a.buzzer ? a.buzzer + d : d; - a.note = 0; - return b.callReturn(); +Entry.block.albert_change_buzzer_by = function(b, a) { + var d = Entry.hw.sendQueue, c = a.getNumberValue("VALUE"); + d.buzzer = void 0 != d.buzzer ? d.buzzer + c : c; + d.note = 0; + return a.callReturn(); }; Blockly.Blocks.albert_set_buzzer_to = {init:function() { this.setColour("#00979D"); @@ -680,11 +663,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 d = Entry.hw.sendQueue; + d.buzzer = a.getNumberValue("VALUE"); + d.note = 0; + return a.callReturn(); }; Blockly.Blocks.albert_clear_buzzer = {init:function() { this.setColour("#00979D"); @@ -693,11 +676,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 d = Entry.hw.sendQueue; + d.buzzer = 0; + d.note = 0; + return a.callReturn(); }; Blockly.Blocks.albert_play_note_for = {init:function() { this.setColour("#00979D"); @@ -709,37 +692,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 d = 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; d.note = 0; - return b.callReturn(); + return a.callReturn(); } - a = b.getNumberField("NOTE", b); - var c = b.getNumberField("OCTAVE", b), e = 6E4 * b.getNumberValue("VALUE", b) / Entry.Albert.tempo; - b.isStart = !0; - b.timeFlag = 1; + var c = 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; d.buzzer = 0; - d.note = a + 12 * (c - 1); - if (100 < e) { - var f = setTimeout(function() { + d.note = c + 12 * (e - 1); + if (100 < f) { + var h = setTimeout(function() { d.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"); @@ -750,28 +732,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 d = 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 d = b.getNumberValue("VALUE"), d = 6E4 * d / Entry.Albert.tempo; - a.buzzer = 0; - a.note = 0; - var c = setTimeout(function() { - b.timeFlag = 0; - Entry.Albert.removeTimeout(c); - }, d); - Entry.Albert.timeouts.push(c); - return b; + a.isStart = !0; + a.timeFlag = 1; + var c = a.getNumberValue("VALUE"), c = 6E4 * c / Entry.Albert.tempo; + d.buzzer = 0; + d.note = 0; + var e = setTimeout(function() { + a.timeFlag = 0; + Entry.Albert.removeTimeout(e); + }, c); + Entry.Albert.timeouts.push(e); + return a; }; Blockly.Blocks.albert_change_tempo_by = {init:function() { this.setColour("#00979D"); @@ -782,10 +764,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"); @@ -796,15 +778,15 @@ 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(); }; 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 + @@ -812,16 +794,16 @@ Entry.Arduino = {name:"arduino", setZero:function() { 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.ArduinoExt = {name:"ArduinoExt", getSensorKey:function() { - return "xxxxxxxx".replace(/[xy]/g, function(a) { - var b = 16 * Math.random() | 0; - return ("x" == a ? b : b & 0 | 0).toString(16); + return "xxxxxxxx".replace(/[xy]/g, function(b) { + var a = 16 * Math.random() | 0; + return ("x" == b ? a : a & 0 | 0).toString(16); }).toUpperCase(); -}, getSensorTime:function(a) { - return (new Date).getTime() + a; +}, getSensorTime:function(b) { + return (new Date).getTime() + b; }, setZero:function() { - Entry.hw.sendQueue.SET ? Object.keys(Entry.hw.sendQueue.SET).forEach(function(a) { - Entry.hw.sendQueue.SET[a].data = 0; - Entry.hw.sendQueue.TIME = Entry.ArduinoExt.getSensorTime(Entry.hw.sendQueue.SET[a].type); + Entry.hw.sendQueue.SET ? Object.keys(Entry.hw.sendQueue.SET).forEach(function(b) { + Entry.hw.sendQueue.SET[b].data = 0; + Entry.hw.sendQueue.TIME = Entry.ArduinoExt.getSensorTime(Entry.hw.sendQueue.SET[b].type); Entry.hw.sendQueue.KEY = Entry.ArduinoExt.getSensorKey(); }) : Entry.hw.sendQueue = {SET:{0:{type:Entry.ArduinoExt.sensorTypes.DIGITAL, data:0}, 1:{type:Entry.ArduinoExt.sensorTypes.DIGITAL, data:0}, 2:{type:Entry.ArduinoExt.sensorTypes.DIGITAL, data:0}, 3:{type:Entry.ArduinoExt.sensorTypes.DIGITAL, data:0}, 4:{type:Entry.ArduinoExt.sensorTypes.DIGITAL, data:0}, 5:{type:Entry.ArduinoExt.sensorTypes.DIGITAL, data:0}, 6:{type:Entry.ArduinoExt.sensorTypes.DIGITAL, data:0}, 7:{type:Entry.ArduinoExt.sensorTypes.DIGITAL, data:0}, 8:{type:Entry.ArduinoExt.sensorTypes.DIGITAL, data:0}, 9:{type:Entry.ArduinoExt.sensorTypes.DIGITAL, data:0}, 10:{type:Entry.ArduinoExt.sensorTypes.DIGITAL, data:0}, 11:{type:Entry.ArduinoExt.sensorTypes.DIGITAL, data:0}, 12:{type:Entry.ArduinoExt.sensorTypes.DIGITAL, data:0}, 13:{type:Entry.ArduinoExt.sensorTypes.DIGITAL, data:0}}, TIME:Entry.ArduinoExt.getSensorTime(Entry.ArduinoExt.sensorTypes.DIGITAL), KEY:Entry.ArduinoExt.getSensorKey()}; @@ -830,15 +812,15 @@ Entry.ArduinoExt = {name:"ArduinoExt", getSensorKey:function() { 1661, 3322, 6645], 10:[55, 110, 220, 440, 880, 1760, 3520, 7040], 11:[58, 117, 233, 466, 932, 1865, 3729, 7459], 12:[62, 123, 247, 494, 988, 1976, 3951, 7902]}, BlockState:{}}; 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 = []; }, monitorTemplate:{imgPath:"hw/dplay.png", width:500, height:600, 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 + @@ -848,16 +830,16 @@ Lang.Hw.port_ko, type:"input", pos:{x:0, y:0}}}, mode:"both"}}; Entry.nemoino = {name:"nemoino", setZero:Entry.Arduino.setZero}; Entry.joystick = {name:"joystick", setZero:Entry.Arduino.setZero}; Entry.CODEino = {name:"CODEino", getSensorKey:function() { - return "xxxxxxxx".replace(/[xy]/g, function(a) { - var b = 16 * Math.random() | 0; - return ("x" == a ? b : b & 0 | 0).toString(16); + return "xxxxxxxx".replace(/[xy]/g, function(b) { + var a = 16 * Math.random() | 0; + return ("x" == b ? a : a & 0 | 0).toString(16); }).toUpperCase(); -}, getSensorTime:function(a) { - return (new Date).getTime() + a; +}, getSensorTime:function(b) { + return (new Date).getTime() + b; }, monitorTemplate:Entry.Arduino.monitorTemplate, setZero:function() { - Entry.hw.sendQueue.SET ? Object.keys(Entry.hw.sendQueue.SET).forEach(function(a) { - Entry.hw.sendQueue.SET[a].data = 0; - Entry.hw.sendQueue.TIME = Entry.CODEino.getSensorTime(Entry.hw.sendQueue.SET[a].type); + Entry.hw.sendQueue.SET ? Object.keys(Entry.hw.sendQueue.SET).forEach(function(b) { + Entry.hw.sendQueue.SET[b].data = 0; + Entry.hw.sendQueue.TIME = Entry.CODEino.getSensorTime(Entry.hw.sendQueue.SET[b].type); Entry.hw.sendQueue.KEY = Entry.CODEino.getSensorKey(); }) : Entry.hw.sendQueue = {SET:{0:{type:Entry.CODEino.sensorTypes.DIGITAL, data:0}, 1:{type:Entry.CODEino.sensorTypes.DIGITAL, data:0}, 2:{type:Entry.CODEino.sensorTypes.DIGITAL, data:0}, 3:{type:Entry.CODEino.sensorTypes.DIGITAL, data:0}, 4:{type:Entry.CODEino.sensorTypes.DIGITAL, data:0}, 5:{type:Entry.CODEino.sensorTypes.DIGITAL, data:0}, 6:{type:Entry.CODEino.sensorTypes.DIGITAL, data:0}, 7:{type:Entry.CODEino.sensorTypes.DIGITAL, data:0}, 8:{type:Entry.CODEino.sensorTypes.DIGITAL, data:0}, 9:{type:Entry.CODEino.sensorTypes.DIGITAL, data:0}, 10:{type:Entry.CODEino.sensorTypes.DIGITAL, data:0}, 11:{type:Entry.CODEino.sensorTypes.DIGITAL, data:0}, 12:{type:Entry.CODEino.sensorTypes.DIGITAL, data:0}, 13:{type:Entry.CODEino.sensorTypes.DIGITAL, data:0}}, TIME:Entry.CODEino.getSensorTime(Entry.CODEino.sensorTypes.DIGITAL), KEY:Entry.CODEino.getSensorKey()}; @@ -869,8 +851,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"); @@ -881,13 +863,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 d = new XMLHttpRequest; - d.open("POST", "http://localhost:23518/arduino/", !1); - d.send(String(a)); - Entry.assert(200 == d.status, "arduino is not connected"); - return b.callReturn(); +Entry.block.arduino_send = function(b, a) { + var d = a.getValue("VALUE", a), c = new XMLHttpRequest; + c.open("POST", "http://localhost:23518/arduino/", !1); + c.send(String(d)); + Entry.assert(200 == c.status, "arduino is not connected"); + return a.callReturn(); }; Blockly.Blocks.arduino_get_string = {init:function() { this.setColour("#00979D"); @@ -897,13 +878,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 d = a.getValue("VALUE", a), c = new XMLHttpRequest; + c.open("POST", "http://localhost:23518/arduino/", !1); + c.send(String(d)); + Entry.assert(200 == c.status, "arduino is not connected"); + return Number(c.responseText); }; Blockly.Blocks.arduino_get_number = {init:function() { this.setColour("#00979D"); @@ -913,13 +893,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 d = a.getValue("VALUE", a), c = new XMLHttpRequest; + c.open("POST", "http://localhost:23518/arduino/", !1); + c.send(String(d)); + Entry.assert(200 == c.status, "arduino is not connected"); + return c.responseText; }; Blockly.Blocks.arduino_get_sensor_number = {init:function() { this.setColour("#00979D"); @@ -928,8 +907,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"); @@ -938,8 +917,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"); @@ -948,8 +927,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"); @@ -959,9 +938,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 d = a.getValue("VALUE", a); + return Entry.hw.getAnalogPortValue(d[1]); }; Blockly.Blocks.arduino_get_digital_value = {init:function() { this.setColour("#00979D"); @@ -971,9 +950,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 d = a.getNumberValue("VALUE", a); + return Entry.hw.getDigitalPortValue(d); }; Blockly.Blocks.arduino_toggle_led = {init:function() { this.setColour("#00979D"); @@ -985,11 +964,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 d = b.getField("OPERATOR"); - Entry.hw.setDigitalPortValue(a, "on" == d ? 255 : 0); - return b.callReturn(); +Entry.block.arduino_toggle_led = function(b, a) { + var d = a.getNumberValue("VALUE"), c = a.getField("OPERATOR"); + Entry.hw.setDigitalPortValue(d, "on" == c ? 255 : 0); + return a.callReturn(); }; Blockly.Blocks.arduino_toggle_pwm = {init:function() { this.setColour("#00979D"); @@ -1003,11 +981,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 d = b.getNumberValue("VALUE"), d = Math.round(d), d = Math.max(d, 0), d = Math.min(d, 255); - Entry.hw.setDigitalPortValue(a, d); - return b.callReturn(); +Entry.block.arduino_toggle_pwm = function(b, a) { + var d = a.getNumberValue("PORT"), c = a.getNumberValue("VALUE"), c = Math.round(c), c = Math.max(c, 0), c = Math.min(c, 255); + Entry.hw.setDigitalPortValue(d, c); + return a.callReturn(); }; Blockly.Blocks.arduino_convert_scale = {init:function() { this.setColour("#00979D"); @@ -1026,18 +1003,17 @@ Blockly.Blocks.arduino_convert_scale = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.arduino_convert_scale = function(a, b) { - var d = b.getNumberValue("VALUE1", b), c = 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 d = a.getNumberValue("VALUE1", a), c = a.getNumberValue("VALUE2", a), e = a.getNumberValue("VALUE3", a), f = a.getNumberValue("VALUE4", a), g = a.getNumberValue("VALUE5", a); if (c > e) { - var f = c, c = e, e = f - } - a > b && (f = a, a = b, b = f); - d = (b - a) / (e - c) * (d - c); - d += a; - d = Math.min(b, d); - d = Math.max(a, d); + var h = c, c = e, e = h + } + f > g && (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); }; Blockly.Blocks.sensorBoard_get_named_sensor_value = {init:function() { @@ -1046,8 +1022,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"); @@ -1056,8 +1032,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"); @@ -1066,9 +1042,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() { @@ -1097,8 +1073,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"); @@ -1106,8 +1082,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"); @@ -1115,8 +1091,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"); @@ -1124,8 +1100,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"); @@ -1133,9 +1109,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 d = a.getNumberField("PORT", a); + return 14 < d ? !Entry.hw.getAnalogPortValue(d - 14) : !Entry.hw.getDigitalPortValue(d); }; Blockly.Blocks.CODEino_get_accelerometer_direction = {init:function() { this.setColour("#00979D"); @@ -1144,22 +1120,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 d = a.getField("DIRECTION", a), c = 0; + "LEFT" == d || "RIGHT" == d ? c = 3 : "FRONT" == d || "REAR" == d ? c = 4 : "REVERSE" == d && (c = 5); + c = Entry.hw.getAnalogPortValue(c); + c = 180 / 137 * (c - 265); + c += -90; + c = Math.min(90, c); + c = Math.max(-90, c); + c = Math.round(c); + if ("LEFT" == d || "REAR" == d) { + return -30 > c ? 1 : 0; } - if ("RIGHT" == a || "FRONT" == a) { - return 30 < b ? 1 : 0; + if ("RIGHT" == d || "FRONT" == d) { + return 30 < c ? 1 : 0; } - if ("REVERSE" == a) { - return -50 > b ? 1 : 0; + if ("REVERSE" == d) { + return -50 > c ? 1 : 0; } }; Blockly.Blocks.CODEino_get_accelerometer_value = {init:function() { @@ -1168,19 +1145,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 d = Entry.hw.getAnalogPortValue(b.getField("PORT", b)), c = 265, e = 402; - a = -90; - b = 90; - if (c > e) { - var f = c, c = e, e = f +Entry.block.CODEino_get_accelerometer_value = function(b, a) { + var d = 265, c = 402, e = -90, f = 90, g = Entry.hw.getAnalogPortValue(a.getField("PORT", a)); + if (d > c) { + var h = d, d = c, c = h } - a > b && (f = a, a = b, b = f); - d = (b - a) / (e - c) * (d - c); - d += a; - d = Math.min(b, d); - d = Math.max(a, d); - return Math.round(d); + e > f && (h = e, e = f, f = h); + g = (f - e) / (c - d) * (g - d); + 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"); @@ -1192,13 +1167,12 @@ Blockly.Blocks.dplay_select_led = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.dplay_select_led = function(a, b) { - var d = b.getField("PORT"); - a = 7; - "7" == d ? a = 7 : "8" == d ? a = 8 : "9" == d ? a = 9 : "10" == d && (a = 10); - d = b.getField("OPERATOR"); - Entry.hw.setDigitalPortValue(a, "on" == d ? 255 : 0); - return b.callReturn(); +Entry.block.dplay_select_led = function(b, a) { + var d = a.getField("PORT"), c = 7; + "7" == d ? c = 7 : "8" == d ? c = 8 : "9" == d ? c = 9 : "10" == d && (c = 10); + d = a.getField("OPERATOR"); + Entry.hw.setDigitalPortValue(c, "on" == d ? 255 : 0); + return a.callReturn(); }; Blockly.Blocks.dplay_get_switch_status = {init:function() { this.setColour("#00979D"); @@ -1208,11 +1182,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 d = 2; - "2" == a ? d = 2 : "4" == a && (d = 4); - return "OFF" == b.getField("STATUS") ? 1 == Entry.hw.getDigitalPortValue(d) ? 1 : 0 : 0 == Entry.hw.getDigitalPortValue(d) ? 1 : 0; +Entry.block.dplay_get_switch_status = function(b, a) { + var d = a.getField("PORT"), c = 2; + "2" == d ? c = 2 : "4" == d && (c = 4); + return "OFF" == a.getField("STATUS") ? 1 == Entry.hw.getDigitalPortValue(c) ? 1 : 0 : 0 == Entry.hw.getDigitalPortValue(c) ? 1 : 0; }; Blockly.Blocks.dplay_get_light_status = {init:function() { this.setColour("#00979D"); @@ -1220,8 +1193,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"); @@ -1233,9 +1206,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 d = a.getValue("VALUE", a); + return Entry.hw.getAnalogPortValue(d[1]); }; Blockly.Blocks.dplay_get_tilt = {init:function() { this.setColour("#00979D"); @@ -1243,8 +1216,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"); @@ -1255,15 +1228,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 d = 0; - "3" == a ? d = 5 : "6" == a && (d = 11); - var c = b.getField("OPERATOR"), e = 0, f = 0; - "FRONT" == c ? (e = 255, f = 0) : "REAR" == c ? (e = 0, f = 255) : "OFF" == c && (f = e = 0); - Entry.hw.setDigitalPortValue(a, e); +Entry.block.dplay_DCmotor = function(b, a) { + var d = a.getField("PORT"), c = 0; + "3" == d ? c = 5 : "6" == d && (c = 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(d, f); - return b.callReturn(); + Entry.hw.setDigitalPortValue(c, g); + return a.callReturn(); }; Blockly.Blocks.dplay_buzzer = {init:function() { this.setColour("#00979D"); @@ -1277,16 +1249,15 @@ Blockly.Blocks.dplay_buzzer = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.dplay_buzzer = function(a, b) { - var d = b.getField("PORT"); - a = 2; - "1" == d ? a = 2 : "2" == d ? a = 4 : "3" == d && (a = 7); - d = b.getNumberValue("VALUE"); +Entry.block.dplay_buzzer = function(b, a) { + var d = a.getField("PORT"), c = 2; + "1" == d ? c = 2 : "2" == d ? c = 4 : "3" == d && (c = 7); + d = a.getNumberValue("VALUE"); d = Math.round(d); d = Math.max(d, 0); d = Math.min(d, 100); - Entry.hw.setDigitalPortValue(a, d); - return b.callReturn(); + Entry.hw.setDigitalPortValue(c, d); + return a.callReturn(); }; Blockly.Blocks.dplay_servo = {init:function() { this.setColour("#00979D"); @@ -1298,42 +1269,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 d = a.getNumberValue("VALUE"), d = Math.round(d), d = Math.max(d, 0), d = Math.min(d, 180); + Entry.hw.setDigitalPortValue(9, d); + 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, d = 1;5 > d;d++) { - var c = b[d]; - c && (c.value || 0 === c.value) && a.push([d + " - " + Lang.Blocks["BITBRICK_" + c.type], d.toString()]); + for (var b = [], a = Entry.hw.portData, d = 1;5 > d;d++) { + var c = a[d]; + c && (c.value || 0 === c.value) && b.push([d + " - " + Lang.Blocks["BITBRICK_" + c.type], d.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, d = 1;5 > d;d++) { - var c = b[d]; - c && "touch" === c.type && a.push([d.toString(), d.toString()]); + for (var b = [], a = Entry.hw.portData, d = 1;5 > d;d++) { + var c = a[d]; + c && "touch" === c.type && b.push([d.toString(), d.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, d = 5;9 > d;d++) { - var c = b[d]; - c && "SERVO" === c.type && a.push(["ABCD"[d - 5], d.toString()]); + for (var b = [], a = Entry.hw.portData, d = 5;9 > d;d++) { + var c = a[d]; + c && "SERVO" === c.type && b.push(["ABCD"[d - 5], d.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, d = 5;9 > d;d++) { - var c = b[d]; - c && "DC" === c.type && a.push(["ABCD"[d - 5], d.toString()]); + for (var b = [], a = Entry.hw.portData, d = 5;9 > d;d++) { + var c = a[d]; + c && "DC" === c.type && b.push(["ABCD"[d - 5], d.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, @@ -1344,9 +1312,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 d = a.getStringField("PORT"); + return Entry.hw.portData[d].value; }; Blockly.Blocks.bitbrick_is_touch_pressed = {init:function() { this.setColour("#00979D"); @@ -1354,8 +1322,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"); @@ -1364,11 +1332,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"); @@ -1383,13 +1351,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 d = b.getNumberValue("gValue"), c = b.getNumberValue("bValue"), e = Entry.adjustValueWithMaxMin, f = Entry.hw.sendQueue; - f.LEDR = e(a, 0, 255); - f.LEDG = e(d, 0, 255); - f.LEDB = e(c, 0, 255); - return b.callReturn(); +Entry.block.bitbrick_turn_on_color_led_by_rgb = function(b, a) { + var d = a.getNumberValue("rValue"), c = a.getNumberValue("gValue"), e = a.getNumberValue("bValue"), f = Entry.adjustValueWithMaxMin, g = Entry.hw.sendQueue; + g.LEDR = f(d, 0, 255); + g.LEDG = f(c, 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"); @@ -1398,12 +1365,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 d = a.getStringField("VALUE"); + Entry.hw.sendQueue.LEDR = parseInt(d.substr(1, 2), 16); + Entry.hw.sendQueue.LEDG = parseInt(d.substr(3, 2), 16); + Entry.hw.sendQueue.LEDB = parseInt(d.substr(5, 2), 16); + return a.callReturn(); }; Blockly.Blocks.bitbrick_turn_on_color_led_by_value = {init:function() { this.setColour("#00979D"); @@ -1414,15 +1381,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 d, c, e; - a %= 200; - 67 > a ? (d = 200 - 3 * a, c = 3 * a, e = 0) : 134 > a ? (a -= 67, d = 0, c = 200 - 3 * a, e = 3 * a) : 201 > a && (a -= 134, d = 3 * a, c = 0, e = 200 - 3 * a); - Entry.hw.sendQueue.LEDR = d; - Entry.hw.sendQueue.LEDG = c; - Entry.hw.sendQueue.LEDB = e; - return b.callReturn(); +Entry.block.bitbrick_turn_on_color_led_by_value = function(b, a) { + var d = a.getNumberValue("VALUE"), c, e, f, d = d % 200; + 67 > d ? (c = 200 - 3 * d, e = 3 * d, f = 0) : 134 > d ? (d -= 67, c = 0, e = 200 - 3 * d, f = 3 * d) : 201 > d && (d -= 134, c = 3 * d, e = 0, f = 200 - 3 * d); + Entry.hw.sendQueue.LEDR = c; + Entry.hw.sendQueue.LEDG = e; + Entry.hw.sendQueue.LEDB = f; + return a.callReturn(); }; Blockly.Blocks.bitbrick_buzzer = {init:function() { this.setColour("#00979D"); @@ -1433,14 +1398,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 d = a.getNumberValue("VALUE"); + Entry.hw.sendQueue.buzzer = d; + a.isStart = !0; + return a; }; Blockly.Blocks.bitbrick_turn_off_all_motors = {init:function() { this.setColour("#00979D"); @@ -1449,16 +1414,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 d = Entry.hw.sendQueue; - a = Entry.Bitbrick; - a.servoList().map(function(b) { - d[b[1]] = 0; +Entry.block.bitbrick_turn_off_all_motors = function(b, a) { + var d = Entry.hw.sendQueue, c = Entry.Bitbrick; + c.servoList().map(function(a) { + d[a[1]] = 0; }); - a.dcList().map(function(b) { - d[b[1]] = 128; + c.dcList().map(function(a) { + d[a[1]] = 128; }); - return b.callReturn(); + return a.callReturn(); }; Blockly.Blocks.bitbrick_dc_speed = {init:function() { this.setColour("#00979D"); @@ -1469,12 +1433,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 d = a.getNumberValue("VALUE"), d = Math.min(d, Entry.Bitbrick.dcMaxValue), d = Math.max(d, Entry.Bitbrick.dcMinValue); + Entry.hw.sendQueue[a.getStringField("PORT")] = d + 128; + return a.callReturn(); }; Blockly.Blocks.bitbrick_dc_direction_speed = {init:function() { this.setColour("#00979D"); @@ -1485,11 +1447,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 d = b.getNumberValue("VALUE"), d = Math.min(d, Entry.Bitbrick.dcMaxValue), d = Math.max(d, 0); - Entry.hw.sendQueue[b.getStringField("PORT")] = a ? d + 128 : 128 - d; - return b.callReturn(); +Entry.block.bitbrick_dc_direction_speed = function(b, a) { + var d = "CW" === a.getStringField("DIRECTION"), c = a.getNumberValue("VALUE"), c = Math.min(c, Entry.Bitbrick.dcMaxValue), c = Math.max(c, 0); + Entry.hw.sendQueue[a.getStringField("PORT")] = d ? c + 128 : 128 - c; + return a.callReturn(); }; Blockly.Blocks.bitbrick_servomotor_angle = {init:function() { this.setColour("#00979D"); @@ -1500,12 +1461,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 d = a.getNumberValue("VALUE") + 1, d = Math.min(d, Entry.Bitbrick.servoMaxValue), d = Math.max(d, Entry.Bitbrick.servoMinValue); + Entry.hw.sendQueue[a.getStringField("PORT")] = d; + return a.callReturn(); }; Blockly.Blocks.bitbrick_convert_scale = {init:function() { this.setColour("#00979D"); @@ -1522,21 +1481,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 d = Entry.hw.portData[a].value, c = 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; +Entry.block.bitbrick_convert_scale = function(b, a) { + var d = a.getNumberField("PORT"), c = Entry.hw.portData[d].value, d = 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 = (b - a) / (e - c) * (d - c); - d += a; - d = Math.min(b, d); - d = Math.max(a, d); - return Math.round(d); + c -= d; + c *= (g - f) / (e - d); + c += f; + c = Math.min(g, c); + c = Math.max(f, c); + return Math.round(c); }; var categoryColor = "#FF9E20"; Blockly.Blocks.start_drawing = {init:function() { @@ -1546,11 +1501,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); @@ -1559,9 +1514,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); @@ -1572,11 +1527,11 @@ Blockly.Blocks.set_color = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.set_color = function(a, b) { - var d = b.getField("VALUE", b); - a.brush || (Entry.setBasicBrush(a), a.brush.stop = !0); - a.brush && (d = Entry.hex2rgb(d), a.brush.rgb = d, a.brush.endStroke(), a.brush.beginStroke("rgba(" + d.r + "," + d.g + "," + d.b + "," + a.brush.opacity / 100 + ")"), a.brush.moveTo(a.getX(), -1 * a.getY())); - return b.callReturn(); +Entry.block.set_color = function(b, a) { + var d = a.getField("VALUE", a); + b.brush || (Entry.setBasicBrush(b), b.brush.stop = !0); + b.brush && (d = Entry.hex2rgb(d), b.brush.rgb = d, b.brush.endStroke(), b.brush.beginStroke("rgba(" + d.r + "," + d.g + "," + d.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); @@ -1585,16 +1540,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 d = Entry.generateRgb(); - a.brush.rgb = d; - a.brush.endStroke(); - a.brush.beginStroke("rgba(" + d.r + "," + d.g + "," + d.b + "," + a.brush.opacity / 100 + ")"); - a.brush.moveTo(a.getX(), -1 * a.getY()); + b.brush.rgb = d; + b.brush.endStroke(); + b.brush.beginStroke("rgba(" + d.r + "," + d.g + "," + d.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); @@ -1605,11 +1560,11 @@ Blockly.Blocks.change_thickness = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.change_thickness = function(a, b) { - var d = b.getNumberValue("VALUE", b); - a.brush || (Entry.setBasicBrush(a), a.brush.stop = !0); - a.brush && (a.brush.thickness += d, 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 d = a.getNumberValue("VALUE", a); + b.brush || (Entry.setBasicBrush(b), b.brush.stop = !0); + b.brush && (b.brush.thickness += d, 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); @@ -1620,11 +1575,11 @@ Blockly.Blocks.set_thickness = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.set_thickness = function(a, b) { - var d = b.getNumberValue("VALUE", b); - a.brush || (Entry.setBasicBrush(a), a.brush.stop = !0); - a.brush && (a.brush.thickness = d, 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 d = a.getNumberValue("VALUE", a); + b.brush || (Entry.setBasicBrush(b), b.brush.stop = !0); + b.brush && (b.brush.thickness = d, 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); @@ -1635,12 +1590,12 @@ Blockly.Blocks.change_opacity = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.change_opacity = function(a, b) { - var d = b.getNumberValue("VALUE", b); - a.brush || (Entry.setBasicBrush(a), a.brush.stop = !0); - d = Entry.adjustValueWithMaxMin(a.brush.opacity + d, 0, 100); - a.brush && (a.brush.opacity = d, a.brush.endStroke(), d = a.brush.rgb, a.brush.beginStroke("rgba(" + d.r + "," + d.g + "," + d.b + "," + a.brush.opacity / 100 + ")"), a.brush.moveTo(a.getX(), -1 * a.getY())); - return b.callReturn(); +Entry.block.change_opacity = function(b, a) { + var d = a.getNumberValue("VALUE", a); + b.brush || (Entry.setBasicBrush(b), b.brush.stop = !0); + d = Entry.adjustValueWithMaxMin(b.brush.opacity + d, 0, 100); + b.brush && (b.brush.opacity = d, b.brush.endStroke(), d = b.brush.rgb, b.brush.beginStroke("rgba(" + d.r + "," + d.g + "," + d.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); @@ -1651,11 +1606,11 @@ Blockly.Blocks.set_opacity = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.set_opacity = function(a, b) { - var d = b.getNumberValue("VALUE", b); - a.brush || (Entry.setBasicBrush(a), a.brush.stop = !0); - a.brush && (a.brush.opacity = Entry.adjustValueWithMaxMin(d, 0, 100), a.brush.endStroke(), d = a.brush.rgb, a.brush.beginStroke("rgba(" + d.r + "," + d.g + "," + d.b + "," + a.brush.opacity / 100 + ")"), a.brush.moveTo(a.getX(), -1 * a.getY())); - return b.callReturn(); +Entry.block.set_opacity = function(b, a) { + var d = a.getNumberValue("VALUE", a); + b.brush || (Entry.setBasicBrush(b), b.brush.stop = !0); + b.brush && (b.brush.opacity = Entry.adjustValueWithMaxMin(d, 0, 100), b.brush.endStroke(), d = b.brush.rgb, b.brush.beginStroke("rgba(" + d.r + "," + d.g + "," + d.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); @@ -1664,19 +1619,19 @@ Blockly.Blocks.brush_erase_all = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.brush_erase_all = function(a, b) { - var d = a.brush; +Entry.block.brush_erase_all = function(b, a) { + var d = b.brush; if (d) { var c = d._stroke.style, e = d._strokeStyle.width; d.clear().setStrokeStyle(e).beginStroke(c); - d.moveTo(a.getX(), -1 * a.getY()); + d.moveTo(b.getX(), -1 * b.getY()); } - a = a.parent.getStampEntities(); - a.map(function(b) { - b.removeClone(); + d = b.parent.getStampEntities(); + d.map(function(a) { + a.removeClone(); }); - a = null; - return b.callReturn(); + d = null; + return a.callReturn(); }; Blockly.Blocks.brush_stamp = {init:function() { this.setColour(categoryColor); @@ -1685,9 +1640,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); @@ -1698,12 +1653,12 @@ Blockly.Blocks.change_brush_transparency = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.change_brush_transparency = function(a, b) { - var d = b.getNumberValue("VALUE", b); - a.brush || (Entry.setBasicBrush(a), a.brush.stop = !0); - d = Entry.adjustValueWithMaxMin(a.brush.opacity - d, 0, 100); - a.brush && (a.brush.opacity = d, a.brush.endStroke(), d = a.brush.rgb, a.brush.beginStroke("rgba(" + d.r + "," + d.g + "," + d.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 d = a.getNumberValue("VALUE", a); + b.brush || (Entry.setBasicBrush(b), b.brush.stop = !0); + d = Entry.adjustValueWithMaxMin(b.brush.opacity - d, 0, 100); + b.brush && (b.brush.opacity = d, b.brush.endStroke(), d = b.brush.rgb, b.brush.beginStroke("rgba(" + d.r + "," + d.g + "," + d.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); @@ -1714,11 +1669,11 @@ Blockly.Blocks.set_brush_tranparency = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.set_brush_tranparency = function(a, b) { - var d = b.getNumberValue("VALUE", b); - a.brush || (Entry.setBasicBrush(a), a.brush.stop = !0); - a.brush && (a.brush.opacity = Entry.adjustValueWithMaxMin(d, 0, 100), a.brush.endStroke(), d = a.brush.rgb, a.brush.beginStroke("rgba(" + d.r + "," + d.g + "," + d.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 d = a.getNumberValue("VALUE", a); + b.brush || (Entry.setBasicBrush(b), b.brush.stop = !0); + b.brush && (b.brush.opacity = Entry.adjustValueWithMaxMin(d, 0, 100), b.brush.endStroke(), d = b.brush.rgb, b.brush.beginStroke("rgba(" + d.r + "," + d.g + "," + d.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() { @@ -1727,8 +1682,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); @@ -1736,8 +1691,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); @@ -1745,8 +1700,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); @@ -1754,8 +1709,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); @@ -1763,8 +1718,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); @@ -1773,8 +1728,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); @@ -1782,13 +1737,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 d = a.getField("VALUE", a); + if ("mouse" == d) { + return d = Entry.stage.mouseCoordinate, Math.sqrt(Math.pow(b.getX() - d.x, 2) + Math.pow(b.getY() - d.y, 2)); } - b = Entry.container.getEntity(b); - return Math.sqrt(Math.pow(a.getX() - b.getX(), 2) + Math.pow(a.getY() - b.getY(), 2)); + d = Entry.container.getEntity(d); + return Math.sqrt(Math.pow(b.getX() - d.getX(), 2) + Math.pow(b.getY() - d.getY(), 2)); }; Blockly.Blocks.coordinate_mouse = {init:function() { this.setColour(calcBlockColor); @@ -1796,8 +1751,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) ? Number(Entry.stage.mouseCoordinate.x) : Number(Entry.stage.mouseCoordinate.y); }; Blockly.Blocks.coordinate_object = {init:function() { this.setColour(calcBlockColor); @@ -1806,24 +1761,24 @@ Blockly.Blocks.coordinate_object = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.coordinate_object = function(a, b) { - var d = b.getField("VALUE", b); - a = "self" == d ? a : Entry.container.getEntity(d); - switch(b.getField("COORDINATE", b)) { +Entry.block.coordinate_object = function(b, a) { + var d = a.getField("VALUE", a), d = "self" == d ? b : Entry.container.getEntity(d); + switch(a.getField("COORDINATE", a)) { case "x": - return a.getX(); + return d.getX(); case "y": - return a.getY(); + return d.getY(); case "rotation": - return a.getRotation(); + return d.getRotation(); case "direction": - return a.getDirection(); + return d.getDirection(); case "picture_index": - return b = a.parent, b = b.pictures, b.indexOf(a.picture) + 1; + var c = d.parent, c = c.pictures; + return c.indexOf(d.picture) + 1; case "size": - return Number(a.getSize().toFixed(1)); + return Number(d.getSize().toFixed(1)); case "picture_name": - return b = a.parent, b = b.pictures, b[b.indexOf(a.picture)].name; + return c = d.parent, c = c.pictures, c[c.indexOf(d.picture)].name; } }; Blockly.Blocks.calc_basic = {init:function() { @@ -1834,11 +1789,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 d = b.getNumberValue("LEFTHAND", b); - b = b.getNumberValue("RIGHTHAND", b); - return "PLUS" == a ? d + b : "MINUS" == a ? d - b : "MULTI" == a ? d * b : d / b; +Entry.block.calc_basic = function(b, a) { + var d = a.getField("OPERATOR", a), c = a.getNumberValue("LEFTHAND", a), e = a.getNumberValue("RIGHTHAND", a); + return "PLUS" == d ? c + e : "MINUS" == d ? c - e : "MULTI" == d ? c * e : c / e; }; Blockly.Blocks.calc_plus = {init:function() { this.setColour(calcBlockColor); @@ -1848,10 +1801,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 d = a.getNumberValue("LEFTHAND", a), c = a.getNumberValue("RIGHTHAND", a); + return d + c; }; Blockly.Blocks.calc_minus = {init:function() { this.setColour(calcBlockColor); @@ -1861,10 +1813,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 d = a.getNumberValue("LEFTHAND", a), c = a.getNumberValue("RIGHTHAND", a); + return d - c; }; Blockly.Blocks.calc_times = {init:function() { this.setColour(calcBlockColor); @@ -1874,10 +1825,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 d = a.getNumberValue("LEFTHAND", a), c = a.getNumberValue("RIGHTHAND", a); + return d * c; }; Blockly.Blocks.calc_divide = {init:function() { this.setColour(calcBlockColor); @@ -1887,10 +1837,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 d = a.getNumberValue("LEFTHAND", a), c = a.getNumberValue("RIGHTHAND", a); + return d / c; }; Blockly.Blocks.calc_mod = {init:function() { this.setColour(calcBlockColor); @@ -1902,10 +1851,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 d = a.getNumberValue("LEFTHAND", a), c = a.getNumberValue("RIGHTHAND", a); + return d % c; }; Blockly.Blocks.calc_share = {init:function() { this.setColour(calcBlockColor); @@ -1917,10 +1865,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 d = a.getNumberValue("LEFTHAND", a), c = a.getNumberValue("RIGHTHAND", a); + return Math.floor(d / c); }; Blockly.Blocks.calc_operation = {init:function() { this.setColour(calcBlockColor); @@ -1933,45 +1880,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 d = a.getNumberValue("LEFTHAND", a), c = a.getField("VALUE", a); + if (-1 < ["asin_radian", "acos_radian"].indexOf(c) && (1 < d || -1 > d)) { throw Error("x range exceeded"); } - b.indexOf("_") && (b = b.split("_")[0]); - -1 < ["sin", "cos", "tan"].indexOf(b) && (a = Entry.toRadian(a)); - switch(b) { + c.indexOf("_") && (c = c.split("_")[0]); + -1 < ["sin", "cos", "tan"].indexOf(c) && (d = Entry.toRadian(d)); + var e = 0; + switch(c) { case "square": - b = a * a; + e = d * d; break; case "factorial": - b = Entry.factorial(a); + e = Entry.factorial(d); break; case "root": - b = Math.sqrt(a); + e = Math.sqrt(d); break; case "log": - b = Math.log(a) / Math.LN10; + e = Math.log(d) / Math.LN10; break; case "ln": - b = Math.log(a); + e = Math.log(d); break; case "asin": ; case "acos": ; case "atan": - b = Entry.toDegrees(Math[b](a)); + e = Entry.toDegrees(Math[c](d)); break; case "unnatural": - b = a - Math.floor(a); - 0 > a && (b = 1 - b); + e = d - Math.floor(d); + 0 > d && (e = 1 - e); break; default: - b = Math[b](a); + e = Math[c](d); } - return Math.round(1E3 * b) / 1E3; + return Math.round(1E3 * e) / 1E3; }; Blockly.Blocks.calc_rand = {init:function() { this.setColour(calcBlockColor); @@ -1983,12 +1930,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 d = Math.min(a, b), c = Math.max(a, b); - a = Entry.isFloat(a); - return Entry.isFloat(b) || a ? (Math.random() * (c - d) + d).toFixed(2) : Math.floor(Math.random() * (c - d + 1) + d); +Entry.block.calc_rand = function(b, a) { + var d = a.getStringValue("LEFTHAND", a), c = a.getStringValue("RIGHTHAND", a), e = Math.min(d, c), f = Math.max(d, c), d = Entry.isFloat(d); + return Entry.isFloat(c) || d ? (Math.random() * (f - e) + e).toFixed(2) : Math.floor(Math.random() * (f - e + 1) + e); }; Blockly.Blocks.get_date = {init:function() { this.setColour(calcBlockColor); @@ -1997,10 +1941,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 d = a.getField("VALUE", a), c = new Date; + return "YEAR" == d ? c.getFullYear() : "MONTH" == d ? c.getMonth() + 1 : "DAY" == d ? c.getDate() : "HOUR" == d ? c.getHours() : "MINUTE" == d ? c.getMinutes() : c.getSeconds(); }; Blockly.Blocks.get_sound_duration = {init:function() { this.setColour(calcBlockColor); @@ -2010,12 +1953,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 d = 0;d < a.length;d++) { - if (a[d].id == b) { - return a[d].duration; +Entry.block.get_sound_duration = function(b, a) { + for (var d = a.getField("VALUE", a), c = b.parent.sounds, e = 0;e < c.length;e++) { + if (c[e].id == d) { + return c[e].duration; } } }; @@ -2027,12 +1968,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); @@ -2044,14 +1985,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 d = Entry.engine.projectTimer; - "SHOW" == a ? d.setVisible(!0) : d.setVisible(!1); - return b.callReturn(); +Entry.block.set_visible_project_timer = function(b, a) { + var d = a.getField("ACTION", a), c = Entry.engine.projectTimer; + "SHOW" == d ? c.setVisible(!0) : c.setVisible(!1); + return a.callReturn(); }; Blockly.Blocks.timer_variable = {init:function() { this.setColour(calcBlockColor); @@ -2059,7 +1999,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() { @@ -2069,10 +2009,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() { @@ -2085,13 +2025,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 d = a.getStringValue("LEFTHAND", a), c = a.getNumberValue("RIGHTHAND", a) - 1; + if (0 > c || c > d.length - 1) { throw Error(); } - return a[b]; + return d[c]; }; Blockly.Blocks.length_of_string = {init:function() { this.setColour(calcBlockColor); @@ -2101,8 +2040,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); @@ -2116,15 +2055,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 d = b.getNumberValue("START", b) - 1; - b = b.getNumberValue("END", b) - 1; - var c = a.length - 1; - if (0 > d || 0 > b || d > c || b > c) { +Entry.block.substring = function(b, a) { + var d = a.getStringValue("STRING", a), c = a.getNumberValue("START", a) - 1, e = a.getNumberValue("END", a) - 1, f = d.length - 1; + if (0 > c || 0 > e || c > f || e > f) { throw Error(); } - return a.substring(Math.min(d, b), Math.max(d, b) + 1); + return d.substring(Math.min(c, e), Math.max(c, e) + 1); }; Blockly.Blocks.replace_string = {init:function() { this.setColour(calcBlockColor); @@ -2138,8 +2074,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); @@ -2151,8 +2087,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); @@ -2164,11 +2100,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 d = a.getStringValue("LEFTHAND", a), c = a.getStringValue("RIGHTHAND", a), d = d.indexOf(c); + return -1 < d ? d + 1 : 0; }; Blockly.Blocks.combine_something = {init:function() { this.setColour(calcBlockColor); @@ -2180,10 +2114,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 d = a.getStringValue("VALUE1", a), c = a.getStringValue("VALUE2", a); + return d + c; }; Blockly.Blocks.get_sound_volume = {init:function() { this.setColour(calcBlockColor); @@ -2191,7 +2124,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() { @@ -2203,13 +2136,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 d = b.getNumberValue("RIGHTHAND", b); - if (isNaN(a) || isNaN(d)) { +Entry.block.quotient_and_mod = function(b, a) { + var d = a.getNumberValue("LEFTHAND", a), c = a.getNumberValue("RIGHTHAND", a); + if (isNaN(d) || isNaN(c)) { throw Error(); } - return "QUOTIENT" == b.getField("OPERATOR", b) ? Math.floor(a / d) : a % d; + return "QUOTIENT" == a.getField("OPERATOR", a) ? Math.floor(d / c) : d % c; }; Blockly.Blocks.choose_project_timer_action = {init:function() { this.setColour(calcBlockColor); @@ -2220,18 +2152,17 @@ 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 d = Entry.engine, c = d.projectTimer; - "START" == a ? c.isInit ? c.isInit && c.isPaused && (c.pauseStart && (c.pausedTime += (new Date).getTime() - c.pauseStart), delete c.pauseStart, c.isPaused = !1) : d.startProjectTimer() : "STOP" == a ? c.isInit && !c.isPaused && (c.isPaused = !0, c.pauseStart = (new Date).getTime()) : "RESET" == a && c.isInit && (c.setValue(0), c.start = (new Date).getTime(), c.pausedTime = 0, delete c.pauseStart); - return b.callReturn(); +Entry.block.choose_project_timer_action = function(b, a) { + var d = a.getField("ACTION"), c = Entry.engine, e = c.projectTimer; + "START" == d ? e.isInit ? e.isInit && e.isPaused && (e.pauseStart && (e.pausedTime += (new Date).getTime() - e.pauseStart), delete e.pauseStart, e.isPaused = !1) : c.startProjectTimer() : "STOP" == d ? e.isInit && !e.isPaused && (e.isPaused = !0, e.pauseStart = (new Date).getTime()) : "RESET" == d && e.isInit && (e.setValue(0), e.start = (new Date).getTime(), e.pausedTime = 0, delete e.pauseStart); + return a.callReturn(); }; Entry.Cobl = {name:"cobl", setZero:function() { - for (var a = 0;14 > a;a++) { - Entry.hw.sendQueue[a] = 0; + for (var b = 0;14 > b;b++) { + Entry.hw.sendQueue[b] = 0; } Entry.hw.update(); }}; @@ -2241,7 +2172,7 @@ Blockly.Blocks.cobl_read_ultrason = {init:function() { this.setInputsInline(!0); this.setOutput(!0, "Number"); }}; -Entry.block.cobl_read_ultrason = function(a, b) { +Entry.block.cobl_read_ultrason = function(b, a) { return Entry.hw.getAnalogPortValue("ultrason"); }; Blockly.Blocks.cobl_read_potenmeter = {init:function() { @@ -2250,7 +2181,7 @@ Blockly.Blocks.cobl_read_potenmeter = {init:function() { this.setInputsInline(!0); this.setOutput(!0, "Number"); }}; -Entry.block.cobl_read_potenmeter = function(a, b) { +Entry.block.cobl_read_potenmeter = function(b, a) { console.log("cobl_read_potenmeter"); return Entry.hw.getAnalogPortValue("potenmeter"); }; @@ -2260,7 +2191,7 @@ Blockly.Blocks.cobl_read_irread1 = {init:function() { this.setInputsInline(!0); this.setOutput(!0, "Number"); }}; -Entry.block.cobl_read_irread1 = function(a, b) { +Entry.block.cobl_read_irread1 = function(b, a) { return Entry.hw.getAnalogPortValue("potenmeter"); }; Blockly.Blocks.cobl_read_irread2 = {init:function() { @@ -2269,8 +2200,8 @@ Blockly.Blocks.cobl_read_irread2 = {init:function() { this.setInputsInline(!0); this.setOutput(!0, "Number"); }}; -Entry.block.cobl_read_irread2 = function(a, b) { - b.getValue("irread2", b); +Entry.block.cobl_read_irread2 = function(b, a) { + a.getValue("irread2", a); return Entry.hw.getAnalogPortValue("irread2"); }; Blockly.Blocks.cobl_read_joyx = {init:function() { @@ -2279,7 +2210,7 @@ Blockly.Blocks.cobl_read_joyx = {init:function() { this.setInputsInline(!0); this.setOutput(!0, "Number"); }}; -Entry.block.cobl_read_joyx = function(a, b) { +Entry.block.cobl_read_joyx = function(b, a) { return Entry.hw.getAnalogPortValue("joyx"); }; Blockly.Blocks.cobl_read_joyy = {init:function() { @@ -2288,7 +2219,7 @@ Blockly.Blocks.cobl_read_joyy = {init:function() { this.setInputsInline(!0); this.setOutput(!0, "Number"); }}; -Entry.block.cobl_read_joyy = function(a, b) { +Entry.block.cobl_read_joyy = function(b, a) { return Entry.hw.getAnalogPortValue("joyy"); }; Blockly.Blocks.cobl_read_sens1 = {init:function() { @@ -2297,7 +2228,7 @@ Blockly.Blocks.cobl_read_sens1 = {init:function() { this.setInputsInline(!0); this.setOutput(!0, "Number"); }}; -Entry.block.cobl_read_sens1 = function(a, b) { +Entry.block.cobl_read_sens1 = function(b, a) { return Entry.hw.getAnalogPortValue("sens1"); }; Blockly.Blocks.cobl_read_sens2 = {init:function() { @@ -2306,7 +2237,7 @@ Blockly.Blocks.cobl_read_sens2 = {init:function() { this.setInputsInline(!0); this.setOutput(!0, "Number"); }}; -Entry.block.cobl_read_sens2 = function(a, b) { +Entry.block.cobl_read_sens2 = function(b, a) { return Entry.hw.getAnalogPortValue("sens2"); }; Blockly.Blocks.cobl_read_tilt = {init:function() { @@ -2315,7 +2246,7 @@ Blockly.Blocks.cobl_read_tilt = {init:function() { this.setInputsInline(!0); this.setOutput(!0, "Number"); }}; -Entry.block.cobl_read_tilt = function(a, b) { +Entry.block.cobl_read_tilt = function(b, a) { return Entry.hw.getAnalogPortValue("tilt"); }; Blockly.Blocks.cobl_get_port_number = {init:function() { @@ -2325,8 +2256,8 @@ Blockly.Blocks.cobl_get_port_number = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.cobl_get_port_number = function(a, b) { - return b.getStringField("PORT"); +Entry.block.cobl_get_port_number = function(b, a) { + return a.getStringField("PORT"); }; Blockly.Blocks.cobl_read_temps = {init:function() { this.setColour("#00979D"); @@ -2335,12 +2266,12 @@ Blockly.Blocks.cobl_read_temps = {init:function() { this.setInputsInline(!0); this.setOutput(!0, "Number"); }}; -Entry.block.cobl_read_temps = function(a, b) { - a = b.getValue("VALUE", b); - if (1 == a) { +Entry.block.cobl_read_temps = function(b, a) { + var d = a.getValue("VALUE", a); + if (1 == d) { return Entry.hw.getAnalogPortValue("temps1"); } - if (2 == a) { + if (2 == d) { return Entry.hw.getAnalogPortValue("temps2"); } }; @@ -2351,12 +2282,12 @@ Blockly.Blocks.cobl_read_light = {init:function() { this.setInputsInline(!0); this.setOutput(!0, "Number"); }}; -Entry.block.cobl_read_light = function(a, b) { - a = b.getValue("VALUE", b); - if (1 == a) { +Entry.block.cobl_read_light = function(b, a) { + var d = a.getValue("VALUE", a); + if (1 == d) { return Entry.hw.getAnalogPortValue("light1"); } - if (2 == a) { + if (2 == d) { return Entry.hw.getAnalogPortValue("light2"); } }; @@ -2367,12 +2298,12 @@ Blockly.Blocks.cobl_read_btn = {init:function() { this.setInputsInline(!0); this.setOutput(!0, "Boolean"); }}; -Entry.block.cobl_read_btn = function(a, b) { - a = b.getValue("VALUE", b); - if (1 == a) { +Entry.block.cobl_read_btn = function(b, a) { + var d = a.getValue("VALUE", a); + if (1 == d) { return Entry.hw.getDigitalPortValue("btn1"); } - if (2 == a) { + if (2 == d) { return Entry.hw.getDigitalPortValue("btn2"); } }; @@ -2386,12 +2317,11 @@ Blockly.Blocks.cobl_led_control = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.cobl_led_control = function(a, b) { - a = b.getStringField("PORT"); - var d = b.getStringField("OPERATOR"); - Entry.hw.setDigitalPortValue("RainBowLED_IDX", a); - Entry.hw.setDigitalPortValue("RainBowLED_COL", d); - return b.callReturn(); +Entry.block.cobl_led_control = function(b, a) { + var d = a.getStringField("PORT"), c = a.getStringField("OPERATOR"); + Entry.hw.setDigitalPortValue("RainBowLED_IDX", d); + Entry.hw.setDigitalPortValue("RainBowLED_COL", c); + return a.callReturn(); }; Blockly.Blocks.cobl_text = {init:function() { this.setColour("#00979D"); @@ -2399,8 +2329,8 @@ Blockly.Blocks.cobl_text = {init:function() { this.setOutput(!0, "String"); this.setInputsInline(!0); }}; -Entry.block.cobl_text = function(a, b) { - return b.getStringField("NAME"); +Entry.block.cobl_text = function(b, a) { + return a.getStringField("NAME"); }; Blockly.Blocks.cobl_servo_angle_control = {init:function() { this.setColour("#00979D"); @@ -2413,13 +2343,12 @@ Blockly.Blocks.cobl_servo_angle_control = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.cobl_servo_angle_control = function(a, b) { +Entry.block.cobl_servo_angle_control = function(b, a) { console.log("servo - test"); - a = b.getNumberValue("PORT"); - var d = b.getNumberValue("VALUE"), d = Math.round(d), d = Math.max(d, 15), d = Math.min(d, 165); - 1 == a && (console.log("servo 1 degree " + d), Entry.hw.setDigitalPortValue("Servo1", d)); - 2 == a && (console.log("servo 2 degree " + d), Entry.hw.setDigitalPortValue("Servo2", d)); - return b.callReturn(); + var d = a.getNumberValue("PORT"), c = a.getNumberValue("VALUE"), c = Math.round(c), c = Math.max(c, 15), c = Math.min(c, 165); + 1 == d && (console.log("servo 1 degree " + c), Entry.hw.setDigitalPortValue("Servo1", c)); + 2 == d && (console.log("servo 2 degree " + c), Entry.hw.setDigitalPortValue("Servo2", c)); + return a.callReturn(); }; Blockly.Blocks.cobl_melody = {init:function() { this.setColour("#00979D"); @@ -2429,11 +2358,11 @@ Blockly.Blocks.cobl_melody = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.cobl_melody = function(a, b) { - a = b.getStringField("MELODY"); - console.log("cobl_melody" + a); - Entry.hw.setDigitalPortValue("Melody", a); - return b.callReturn(); +Entry.block.cobl_melody = function(b, a) { + var d = a.getStringField("MELODY"); + console.log("cobl_melody" + d); + Entry.hw.setDigitalPortValue("Melody", d); + return a.callReturn(); }; Blockly.Blocks.cobl_dcmotor = {init:function() { this.setColour("#00979D"); @@ -2447,13 +2376,12 @@ Blockly.Blocks.cobl_dcmotor = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.cobl_dcmotor = function(a, b) { - a = b.getStringField("MOTOR"); - var d = b.getStringField("DIRECTION"), c = b.getStringField("SPEED"); - console.log("MOTOR" + a + " Direction" + d + " speed" + c); - 1 == a && (Entry.hw.setDigitalPortValue("DC1_DIR", d), Entry.hw.setDigitalPortValue("DC1_SPEED", c)); - 2 == a && (Entry.hw.setDigitalPortValue("DC2_DIR", d), Entry.hw.setDigitalPortValue("DC2_SPEED", c)); - return b.callReturn(); +Entry.block.cobl_dcmotor = function(b, a) { + var d = a.getStringField("MOTOR"), c = a.getStringField("DIRECTION"), e = a.getStringField("SPEED"); + console.log("MOTOR" + d + " Direction" + c + " speed" + e); + 1 == d && (Entry.hw.setDigitalPortValue("DC1_DIR", c), Entry.hw.setDigitalPortValue("DC1_SPEED", e)); + 2 == d && (Entry.hw.setDigitalPortValue("DC2_DIR", c), Entry.hw.setDigitalPortValue("DC2_SPEED", e)); + return a.callReturn(); }; Blockly.Blocks.cobl_extention_port = {init:function() { this.setColour("#00979D"); @@ -2465,12 +2393,11 @@ Blockly.Blocks.cobl_extention_port = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.cobl_extention_port = function(a, b) { - a = b.getStringField("PORT"); - var d = b.getStringField("LEVEL"); - 1 == a && Entry.hw.setDigitalPortValue("EXUSB1", d); - 2 == a && Entry.hw.setDigitalPortValue("EXUSB2", d); - return b.callReturn(); +Entry.block.cobl_extention_port = function(b, a) { + var d = a.getStringField("PORT"), c = a.getStringField("LEVEL"); + 1 == d && Entry.hw.setDigitalPortValue("EXUSB1", c); + 2 == d && Entry.hw.setDigitalPortValue("EXUSB2", c); + return a.callReturn(); }; Blockly.Blocks.cobl_external_led = {init:function() { this.setColour("#00979D"); @@ -2487,14 +2414,13 @@ Blockly.Blocks.cobl_external_led = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.cobl_external_led = function(a, b) { - a = b.getNumberValue("LED"); - var d = b.getStringField("RED"), c = b.getStringField("GREEN"), e = b.getStringField("BLUE"); - Entry.hw.setDigitalPortValue("ELED_IDX", a); - Entry.hw.setDigitalPortValue("ELED_R", d); - Entry.hw.setDigitalPortValue("ELED_G", c); - Entry.hw.setDigitalPortValue("ELED_B", e); - return b.callReturn(); +Entry.block.cobl_external_led = function(b, a) { + var d = a.getNumberValue("LED"), c = a.getStringField("RED"), e = a.getStringField("GREEN"), f = a.getStringField("BLUE"); + Entry.hw.setDigitalPortValue("ELED_IDX", d); + Entry.hw.setDigitalPortValue("ELED_R", c); + Entry.hw.setDigitalPortValue("ELED_G", e); + Entry.hw.setDigitalPortValue("ELED_B", f); + return a.callReturn(); }; Blockly.Blocks.cobl_7_segment = {init:function() { this.setColour("#00979D"); @@ -2505,35 +2431,35 @@ Blockly.Blocks.cobl_7_segment = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.cobl_7_segment = function(a, b) { - a = b.getNumberValue("VALUE"); - Entry.hw.setDigitalPortValue("7SEG", a); - return b.callReturn(); +Entry.block.cobl_7_segment = function(b, a) { + var d = a.getNumberValue("VALUE"); + Entry.hw.setDigitalPortValue("7SEG", d); + return a.callReturn(); }; Entry.Codestar = {name:"codestar", 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/codestar.png", width:333, height:409, listPorts:{13:{name:"\uc9c4\ub3d9\ubaa8\ud130", type:"output", pos:{x:0, y:0}}, 6:{name:"\uc9c4\ub3d9\uc13c\uc11c", type:"input", pos:{x:0, y:0}}}, ports:{7:{name:"\ube68\uac04\uc0c9", type:"output", pos:{x:238, y:108}}, 8:{name:"\ud30c\ub780\uc0c9", type:"output", pos:{x:265, y:126}}, 9:{name:"3\uc0c9 \ube68\uac04\uc0c9", type:"output", pos:{x:292, y:34}}, 10:{name:"3\uc0c9 \ub179\uc0c9", type:"output", pos:{x:292, y:34}}, 11:{name:"3\uc0c9 \ud30c\ub780\uc0c9", type:"output", pos:{x:292, y:34}}, 12:{name:"\ubc84\ud2bc", type:"input", pos:{x:248, y:142}}, a0:{name:"\uc67c\ucabd \ubcbd\uac10\uc9c0", type:"input", pos:{x:24, y:231}}, a2:{name:"\ub9c8\uc774\ud06c", type:"input", pos:{x:225, y:67}}, a3:{name:"\ubd80\uc800", type:"output", pos:{x:283, y:105}}, a4:{name:"\uc67c\ucabd \ub77c\uc778\uac10\uc9c0", type:"input", pos:{x:37, y:353}}, a5:{name:"\uc624\ub978\ucabd \ub77c\uc778\uac10\uc9c0", type:"input", pos:{x:50, y:368}}, a6:{name:"\uc870\ub3c4\uc13c\uc11c", type:"input", pos:{x:273, y:22}}, a7:{name:"\uc624\ub978\ucabd \ubcbd\uac10\uc9c0", type:"input", pos:{x:103, y:381}}, temperature:{name:"\uc628\ub3c4\uc13c\uc11c", type:"input", pos:{x:311, y:238}}, sonar:{name:"\ucd08\uc74c\ud30c", type:"input", pos:{x:7, y:277}}, leftwheel:{name:"\uc67c\ucabd \ubc14\ud034", type:"output", pos:{x:177, y:370}}, rightwheel:{name:"\uc624\ub978\ucabd \ubc14\ud034", type:"output", pos:{x:83, y:218}}}, mode:"both"}}; -Entry.EV3 = {PORT_MAP:{A:0, B:0, C:0, D:0, 1:void 0, 2:void 0, 3:void 0, 4:void 0}, motorMovementTypes:{Degrees:0, Power:1}, deviceTypes:{NxtTouch:1, NxtLight:2, NxtSound:3, NxtColor:4, NxtUltrasonic:5, NxtTemperature:6, LMotor:7, MMotor:8, Touch:16, Color:29, Ultrasonic:30, Gyroscope:32, Infrared:33, Initializing:125, Empty:126, WrongPort:127, Unknown:255}, colorSensorValue:" 000000 0000FF 00FF00 FFFF00 FF0000 FFFFFF A52A2A".split(" "), timeouts:[], removeTimeout:function(a) { - clearTimeout(a); - var b = this.timeouts; - a = b.indexOf(a); - 0 <= a && b.splice(a, 1); +Entry.EV3 = {PORT_MAP:{A:0, B:0, C:0, D:0, 1:void 0, 2:void 0, 3:void 0, 4:void 0}, motorMovementTypes:{Degrees:0, Power:1}, deviceTypes:{NxtTouch:1, NxtLight:2, NxtSound:3, NxtColor:4, NxtUltrasonic:5, NxtTemperature:6, LMotor:7, MMotor:8, Touch:16, Color:29, Ultrasonic:30, Gyroscope:32, Infrared:33, Initializing:125, Empty:126, WrongPort:127, Unknown:255}, colorSensorValue:" 000000 0000FF 00FF00 FFFF00 FF0000 FFFFFF A52A2A".split(" "), 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 = []; }, setZero:function() { - var a = this.PORT_MAP; - Object.keys(a).forEach(function(b) { - /[A-D]/i.test(b) ? Entry.hw.sendQueue[b] = {type:Entry.EV3.motorMovementTypes.Power, power:0} : Entry.hw.sendQueue[b] = a[b]; + var b = this.PORT_MAP; + Object.keys(b).forEach(function(a) { + /[A-D]/i.test(a) ? Entry.hw.sendQueue[a] = {type:Entry.EV3.motorMovementTypes.Power, power:0} : Entry.hw.sendQueue[a] = b[a]; }); Entry.hw.update(); }, name:"EV3"}; @@ -2543,12 +2469,11 @@ Blockly.Blocks.ev3_get_sensor_value = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.ev3_get_sensor_value = function(a, b) { - b.getStringField("PORT", b); - a = Entry.hw.getDigitalPortValue(b.getNumberField("PORT", b)); - var d; - $.isPlainObject(a) && (d = a.siValue || 0); - return d; +Entry.block.ev3_get_sensor_value = function(b, a) { + a.getStringField("PORT", a); + var d = Entry.hw.getDigitalPortValue(a.getNumberField("PORT", a)), c; + $.isPlainObject(d) && (c = d.siValue || 0); + return c; }; Blockly.Blocks.ev3_touch_sensor = {init:function() { this.setColour("#00979D"); @@ -2556,12 +2481,11 @@ Blockly.Blocks.ev3_touch_sensor = {init:function() { this.setOutput(!0, "Boolean"); this.setInputsInline(!0); }}; -Entry.block.ev3_touch_sensor = function(a, b) { - b.getStringField("PORT", b); - a = Entry.hw.getDigitalPortValue(b.getNumberField("PORT", b)); - b = !1; - a.type == Entry.EV3.deviceTypes.Touch && 1 <= Number(a.siValue) && (b = !0); - return b; +Entry.block.ev3_touch_sensor = function(b, a) { + a.getStringField("PORT", a); + var d = Entry.hw.getDigitalPortValue(a.getNumberField("PORT", a)), c = !1; + d.type == Entry.EV3.deviceTypes.Touch && 1 <= Number(d.siValue) && (c = !0); + return c; }; Blockly.Blocks.ev3_color_sensor = {init:function() { this.setColour("#00979D"); @@ -2569,33 +2493,31 @@ Blockly.Blocks.ev3_color_sensor = {init:function() { this.setOutput(!0, "String"); this.setInputsInline(!0); }}; -Entry.block.ev3_color_sensor = function(a, b) { - b.getStringField("PORT", b); - a = b.getStringField("RGB", b); - b = Entry.hw.getDigitalPortValue(b.getNumberField("PORT", b)); - var d = ""; - if (b.type == Entry.EV3.deviceTypes.Color) { - if (0 == b.siValue) { - d = ""; +Entry.block.ev3_color_sensor = function(b, a) { + a.getStringField("PORT", a); + var d = a.getStringField("RGB", a), c = Entry.hw.getDigitalPortValue(a.getNumberField("PORT", a)), e = ""; + if (c.type == Entry.EV3.deviceTypes.Color) { + if (0 == c.siValue) { + e = ""; } else { - switch(a) { + switch(d) { case "RGB": - d = Entry.EV3.colorSensorValue[b.siValue]; + e = Entry.EV3.colorSensorValue[c.siValue]; break; case "R": - d = Entry.EV3.colorSensorValue[b.siValue].substring(0, 2); + e = Entry.EV3.colorSensorValue[c.siValue].substring(0, 2); break; case "G": - d = Entry.EV3.colorSensorValue[b.siValue].substring(2, 4); + e = Entry.EV3.colorSensorValue[c.siValue].substring(2, 4); break; case "B": - d = Entry.EV3.colorSensorValue[b.siValue].substring(4, 6); + e = Entry.EV3.colorSensorValue[c.siValue].substring(4, 6); } } } else { - d = "\uceec\ub7ec \uc13c\uc11c \uc544\ub2d8"; + e = "\uceec\ub7ec \uc13c\uc11c \uc544\ub2d8"; } - return d; + return e; }; Blockly.Blocks.ev3_motor_power = {init:function() { this.setColour("#00979D"); @@ -2606,11 +2528,10 @@ Blockly.Blocks.ev3_motor_power = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.ev3_motor_power = function(a, b) { - a = b.getStringField("PORT", b); - var d = b.getValue("VALUE", b); - Entry.hw.sendQueue[a] = {id:Math.floor(1E5 * Math.random(), 0), type:Entry.EV3.motorMovementTypes.Power, power:d}; - return b.callReturn(); +Entry.block.ev3_motor_power = function(b, a) { + var d = a.getStringField("PORT", a), c = a.getValue("VALUE", a); + Entry.hw.sendQueue[d] = {id:Math.floor(1E5 * Math.random(), 0), type:Entry.EV3.motorMovementTypes.Power, power:c}; + return a.callReturn(); }; Blockly.Blocks.ev3_motor_power_on_time = {init:function() { this.setColour("#00979D"); @@ -2623,28 +2544,28 @@ Blockly.Blocks.ev3_motor_power_on_time = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.ev3_motor_power_on_time = function(a, b) { - a = b.getStringField("PORT", b); - if (b.isStart) { - if (1 == b.timeFlag) { - return b; +Entry.block.ev3_motor_power_on_time = function(b, a) { + var d = a.getStringField("PORT", a); + if (a.isStart) { + if (1 == a.timeFlag) { + return a; } - delete b.isStart; - delete b.timeFlag; - Entry.engine.isContinue = !1; - Entry.hw.sendQueue[a] = {id:Math.floor(1E5 * Math.random(), 0), type:Entry.EV3.motorMovementTypes.Power, power:0}; - return b.callReturn(); + delete a.isStart; + delete a.timeFlag; + Entry.engine.isContinue = !1; + Entry.hw.sendQueue[d] = {id:Math.floor(1E5 * Math.random(), 0), type:Entry.EV3.motorMovementTypes.Power, power:0}; + return a.callReturn(); } - var d = b.getValue("TIME", b), c = b.getValue("VALUE", b); - b.isStart = !0; - b.timeFlag = 1; - Entry.hw.sendQueue[a] = {id:Math.floor(1E5 * Math.random(), 0), type:Entry.EV3.motorMovementTypes.Power, power:c}; - var e = setTimeout(function() { - b.timeFlag = 0; - Entry.EV3.removeTimeout(e); - }, 1E3 * d); - Entry.EV3.timeouts.push(e); - return b; + var c = a.getValue("TIME", a), e = a.getValue("VALUE", a); + a.isStart = !0; + a.timeFlag = 1; + Entry.hw.sendQueue[d] = {id:Math.floor(1E5 * Math.random(), 0), type:Entry.EV3.motorMovementTypes.Power, power:e}; + var f = setTimeout(function() { + a.timeFlag = 0; + Entry.EV3.removeTimeout(f); + }, 1E3 * c); + Entry.EV3.timeouts.push(f); + return a; }; Blockly.Blocks.ev3_motor_degrees = {init:function() { this.setColour("#00979D"); @@ -2655,13 +2576,12 @@ Blockly.Blocks.ev3_motor_degrees = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.ev3_motor_degrees = function(a, b) { - a = b.getStringField("PORT", b); - var d = b.getValue("DEGREE", b); - 0 >= d ? d = 0 : 720 <= d && (d = 720); - var c = b.getStringField("DIRECTION", b); - Entry.hw.sendQueue[a] = {id:Math.floor(1E5 * Math.random(), 0), type:Entry.EV3.motorMovementTypes.Degrees, degree:d, power:"CW" == c ? 50 : -50}; - return b.callReturn(); +Entry.block.ev3_motor_degrees = function(b, a) { + var d = a.getStringField("PORT", a), c = a.getValue("DEGREE", a); + 0 >= c ? c = 0 : 720 <= c && (c = 720); + var e = a.getStringField("DIRECTION", a); + Entry.hw.sendQueue[d] = {id:Math.floor(1E5 * Math.random(), 0), type:Entry.EV3.motorMovementTypes.Degrees, degree:c, power:"CW" == e ? 50 : -50}; + return a.callReturn(); }; Blockly.Blocks.wait_second = {init:function() { this.setColour("#498deb"); @@ -2672,23 +2592,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 d = a.getNumberValue("SECOND", a); setTimeout(function() { - b.timeFlag = 0; - }, 60 / (Entry.FPS || 60) * a * 1E3); - return b; + a.timeFlag = 0; + }, 60 / (Entry.FPS || 60) * d * 1E3); + return a; }; Blockly.Blocks.repeat_basic = {init:function() { this.setColour("#498deb"); @@ -2700,20 +2620,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 d; + if (!a.isLooped) { + a.isLooped = !0; + d = a.getNumberValue("VALUE", a); + if (0 > d) { throw Error(Lang.Blocks.FLOW_repeat_basic_errorMsg); } - b.iterCount = Math.floor(a); + a.iterCount = Math.floor(d); } - 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"); @@ -2723,9 +2644,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"); @@ -2734,7 +2655,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() { @@ -2746,8 +2667,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"); @@ -2759,8 +2680,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"); @@ -2774,13 +2695,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 d = a.getBooleanValue("BOOL", a); + a.isLooped = !0; + return d ? a.getStatement("STACK_IF", a) : a.getStatement("STACK_ELSE", a); }; Blockly.Blocks.create_clone = {init:function() { this.setColour("#498deb"); @@ -2791,11 +2712,10 @@ Blockly.Blocks.create_clone = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.create_clone = function(a, b) { - var d = b.getField("VALUE", b); - b = b.callReturn(); - "self" == d ? a.parent.addCloneEntity(a.parent, a, null) : Entry.container.getObject(d).addCloneEntity(a.parent, null, null); - return b; +Entry.block.create_clone = function(b, a) { + var d = a.getField("VALUE", a), c = a.callReturn(); + "self" == d ? b.parent.addCloneEntity(b.parent, b, null) : Entry.container.getObject(d).addCloneEntity(b.parent, null, null); + return c; }; Blockly.Blocks.delete_clone = {init:function() { this.setColour("#498deb"); @@ -2803,11 +2723,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"); @@ -2815,8 +2735,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"); @@ -2825,7 +2745,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() { @@ -2837,10 +2757,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 d = a.getBooleanValue("BOOL", a); + "until" == a.getField("OPTION", a) && (d = !d); + return (a.isLooped = d) ? a.getStatement("DO", a) : a.callReturn(); }; Blockly.Blocks.stop_object = {init:function() { this.setColour("#498deb"); @@ -2851,18 +2771,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 d = Entry.container; - switch(b) { +Entry.block.stop_object = function(b, a) { + var d = a.getField("TARGET", a), c = Entry.container; + switch(d) { case "all": - return d.clearRunningState(), this.die(); + return c.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() { @@ -2871,7 +2790,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(); }; @@ -2882,13 +2801,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 d = b.parent.getClonedEntities(); + d.map(function(a) { + a.removeClone(); }); - a = null; - return b.callReturn(); + d = 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(); @@ -2922,18 +2841,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, d) { - return b.register[b.hashId].run(); +Entry.block.function_param_string = function(b, a, d) { + 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]]; @@ -2943,18 +2862,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, d) { - return b.register[b.hashId].run(); +Entry.block.function_param_boolean = function(b, a, d) { + 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]]; @@ -2967,8 +2886,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() { }}; @@ -2977,12 +2896,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 d = 0;d < b.length;d++) { - var c = b[d], e = c.getAttribute("hashid"); + a.length || this.appendDummyInput().appendField(Lang.Blocks.FUNCTION_function); + for (var d = 0;d < a.length;d++) { + var c = a[d], e = c.getAttribute("hashid"); switch(c.getAttribute("type").toLowerCase()) { case "label": this.appendDummyInput().appendField(c.getAttribute("content")); @@ -2994,11 +2913,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 d = this.inputList[b]; + for (var b = document.createElement("mutation"), a = 1;a < this.inputList.length;a++) { + var d = this.inputList[a]; if (d.fieldRow[0] && d.fieldRow[0] instanceof Blockly.FieldLabel) { var d = d.fieldRow[0], c = document.createElement("field"); c.setAttribute("type", "label"); @@ -3006,34 +2925,34 @@ Blockly.Blocks.function_general = {init:function() { } else { d.connection && "String" == d.connection.check_[0] ? (c = document.createElement("field"), c.setAttribute("type", "string"), c.setAttribute("hashid", d.name)) : d.connection && "Boolean" == d.connection.check_[0] && (c = document.createElement("field"), c.setAttribute("type", "boolean"), c.setAttribute("hashid", d.name)); } - a.appendChild(c); + b.appendChild(c); } - 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 d = 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 d = Entry.variableContainer.getFunction(a.hashId); + a.thread = new Entry.Script(b); + a.thread.register = a.values; for (var c = 0;c < d.content.childNodes.length;c++) { - "function_create" == d.content.childNodes[c].getAttribute("type") && b.thread.init(d.content.childNodes[c]); + "function_create" == d.content.childNodes[c].getAttribute("type") && a.thread.init(d.content.childNodes[c]); } } - if (a = Entry.Engine.computeThread(a, b.thread)) { - return b.thread = a, b; + if (d = Entry.Engine.computeThread(b, a.thread)) { + return a.thread = d, 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()) { @@ -3041,31 +2960,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, d; - for (d in a) { - b[d] = a[d]; + var b = Entry.Hamster.PORT_MAP, a = Entry.hw.sendQueue, d; + for (d in b) { + a[d] = b[d]; } 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}}, inputA:{name:Lang.Blocks.HAMSTER_sensor_input_a, type:"input", pos:{x:0, y:0}}, inputB:{name:Lang.Blocks.HAMSTER_sensor_input_b, type:"input", pos:{x:0, y:0}}, accelerationX:{name:Lang.Blocks.HAMSTER_sensor_acceleration_x, type:"input", pos:{x:0, y:0}}, accelerationY:{name:Lang.Blocks.HAMSTER_sensor_acceleration_y, type:"input", pos:{x:0, y:0}}, accelerationZ:{name:Lang.Blocks.HAMSTER_sensor_acceleration_z, 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}}, 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_left_proximity, type:"input", pos:{x:122, y:156}}, rightProximity:{name:Lang.Blocks.HAMSTER_sensor_right_proximity, type:"input", pos:{x:10, y:108}}, leftFloor:{name:Lang.Blocks.HAMSTER_sensor_left_floor, type:"input", pos:{x:100, y:234}}, rightFloor:{name:Lang.Blocks.HAMSTER_sensor_right_floor, type:"input", pos:{x:13, y:180}}, light:{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_en, type:"output", @@ -3076,9 +2995,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 d = Entry.hw.portData; + return 50 < d.leftProximity || 50 < d.rightProximity; }; Blockly.Blocks.hamster_value = {init:function() { this.setColour("#00979D"); @@ -3087,10 +3006,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 d = Entry.hw.portData, c = a.getField("DEVICE"); + return d[c]; }; Blockly.Blocks.hamster_move_forward_once = {init:function() { this.setColour("#00979D"); @@ -3099,53 +3017,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 d = Entry.hw.portData; - if (b.isStart) { - if (b.isMoving) { - switch(b.boardState) { +Entry.block.hamster_move_forward_once = function(b, a) { + var d = Entry.hw.sendQueue, c = Entry.hw.portData; + if (a.isStart) { + if (a.isMoving) { + switch(a.boardState) { case 1: - 2 > b.count ? (50 > d.leftFloor && 50 > d.rightFloor ? b.count++ : b.count = 0, d = d.leftFloor - d.rightFloor, a.leftWheel = 45 + .25 * d, a.rightWheel = 45 - .25 * d) : (b.count = 0, b.boardState = 2); + 2 > a.count ? (50 > c.leftFloor && 50 > c.rightFloor ? a.count++ : a.count = 0, c = c.leftFloor - c.rightFloor, d.leftWheel = 45 + .25 * c, d.rightWheel = 45 - .25 * c) : (a.count = 0, a.boardState = 2); break; case 2: - d = d.leftFloor - d.rightFloor; - a.leftWheel = 45 + .25 * d; - a.rightWheel = 45 - .25 * d; - b.boardState = 3; - var c = setTimeout(function() { - b.boardState = 4; - Entry.Hamster.removeTimeout(c); + c = c.leftFloor - c.rightFloor; + d.leftWheel = 45 + .25 * c; + d.rightWheel = 45 - .25 * c; + a.boardState = 3; + var e = setTimeout(function() { + a.boardState = 4; + Entry.Hamster.removeTimeout(e); }, 250); - Entry.Hamster.timeouts.push(c); + Entry.Hamster.timeouts.push(e); break; case 3: - d = d.leftFloor - d.rightFloor; - a.leftWheel = 45 + .25 * d; - a.rightWheel = 45 - .25 * d; + c = c.leftFloor - c.rightFloor; + d.leftWheel = 45 + .25 * c; + d.rightWheel = 45 - .25 * c; break; case 4: - a.leftWheel = 0, a.rightWheel = 0, b.boardState = 0, b.isMoving = !1; + d.leftWheel = 0, d.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(); + d.leftWheel = 0; + d.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; + d.leftWheel = 45; + d.rightWheel = 45; + Entry.Hamster.setLineTracerMode(d, 0); + return a; }; Blockly.Blocks.hamster_turn_once = {init:function() { this.setColour("#00979D"); @@ -3154,65 +3071,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 d = Entry.hw.portData; - if (b.isStart) { - if (b.isMoving) { - if (b.isLeft) { - switch(b.boardState) { +Entry.block.hamster_turn_once = function(b, a) { + var d = Entry.hw.sendQueue, c = Entry.hw.portData; + if (a.isStart) { + if (a.isMoving) { + if (a.isLeft) { + switch(a.boardState) { case 1: - 2 > b.count ? 50 < d.leftFloor && b.count++ : (b.count = 0, b.boardState = 2); + 2 > a.count ? 50 < c.leftFloor && a.count++ : (a.count = 0, a.boardState = 2); break; case 2: - 20 > d.leftFloor && (b.boardState = 3); + 20 > c.leftFloor && (a.boardState = 3); break; case 3: - 2 > b.count ? 20 > d.leftFloor && b.count++ : (b.count = 0, b.boardState = 4); + 2 > a.count ? 20 > c.leftFloor && a.count++ : (a.count = 0, a.boardState = 4); break; case 4: - 50 < d.leftFloor && (b.boardState = 5); + 50 < c.leftFloor && (a.boardState = 5); break; case 5: - d = d.leftFloor - d.rightFloor, -15 < d ? (a.leftWheel = 0, a.rightWheel = 0, b.boardState = 0, b.isMoving = !1) : (a.leftWheel = .5 * d, a.rightWheel = .5 * -d); + c = c.leftFloor - c.rightFloor, -15 < c ? (d.leftWheel = 0, d.rightWheel = 0, a.boardState = 0, a.isMoving = !1) : (d.leftWheel = .5 * c, d.rightWheel = .5 * -c); } } else { - switch(b.boardState) { + switch(a.boardState) { case 1: - 2 > b.count ? 50 < d.rightFloor && b.count++ : (b.count = 0, b.boardState = 2); + 2 > a.count ? 50 < c.rightFloor && a.count++ : (a.count = 0, a.boardState = 2); break; case 2: - 20 > d.rightFloor && (b.boardState = 3); + 20 > c.rightFloor && (a.boardState = 3); break; case 3: - 2 > b.count ? 20 > d.rightFloor && b.count++ : (b.count = 0, b.boardState = 4); + 2 > a.count ? 20 > c.rightFloor && a.count++ : (a.count = 0, a.boardState = 4); break; case 4: - 50 < d.rightFloor && (b.boardState = 5); + 50 < c.rightFloor && (a.boardState = 5); break; case 5: - d = d.rightFloor - d.leftFloor, -15 < d ? (a.leftWheel = 0, a.rightWheel = 0, b.boardState = 0, b.isMoving = !1) : (a.leftWheel = .5 * -d, a.rightWheel = .5 * d); + c = c.rightFloor - c.leftFloor, -15 < c ? (d.leftWheel = 0, d.rightWheel = 0, a.boardState = 0, a.isMoving = !1) : (d.leftWheel = .5 * -c, d.rightWheel = .5 * c); } } - 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(); + d.leftWheel = 0; + d.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, d.leftWheel = -45, d.rightWheel = 45) : (a.isLeft = !1, d.leftWheel = 45, d.rightWheel = -45); + Entry.Hamster.setLineTracerMode(d, 0); + return a; }; Blockly.Blocks.hamster_move_forward_for_secs = {init:function() { this.setColour("#00979D"); @@ -3223,31 +3139,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 d = 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(); + d.leftWheel = 0; + d.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 d = setTimeout(function() { - b.timeFlag = 0; - Entry.Hamster.removeTimeout(d); - }, a); - Entry.Hamster.timeouts.push(d); - return b; + a.isStart = !0; + a.timeFlag = 1; + d.leftWheel = 30; + d.rightWheel = 30; + Entry.Hamster.setLineTracerMode(d, 0); + var d = 1E3 * a.getNumberValue("VALUE"), c = setTimeout(function() { + a.timeFlag = 0; + Entry.Hamster.removeTimeout(c); + }, d); + Entry.Hamster.timeouts.push(c); + return a; }; Blockly.Blocks.hamster_move_backward_for_secs = {init:function() { this.setColour("#00979D"); @@ -3258,31 +3173,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 d = 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(); + d.leftWheel = 0; + d.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 d = setTimeout(function() { - b.timeFlag = 0; - Entry.Hamster.removeTimeout(d); - }, a); - Entry.Hamster.timeouts.push(d); - return b; + a.isStart = !0; + a.timeFlag = 1; + d.leftWheel = -30; + d.rightWheel = -30; + Entry.Hamster.setLineTracerMode(d, 0); + var d = 1E3 * a.getNumberValue("VALUE"), c = setTimeout(function() { + a.timeFlag = 0; + Entry.Hamster.removeTimeout(c); + }, d); + Entry.Hamster.timeouts.push(c); + return a; }; Blockly.Blocks.hamster_turn_for_secs = {init:function() { this.setColour("#00979D"); @@ -3293,30 +3207,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 d = 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(); + d.leftWheel = 0; + d.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 d = setTimeout(function() { - b.timeFlag = 0; - Entry.Hamster.removeTimeout(d); - }, a); - Entry.Hamster.timeouts.push(d); - return b; + a.isStart = !0; + a.timeFlag = 1; + "LEFT" == a.getField("DIRECTION", a) ? (d.leftWheel = -30, d.rightWheel = 30) : (d.leftWheel = 30, d.rightWheel = -30); + Entry.Hamster.setLineTracerMode(d, 0); + var d = 1E3 * a.getNumberValue("VALUE"), c = setTimeout(function() { + a.timeFlag = 0; + Entry.Hamster.removeTimeout(c); + }, d); + Entry.Hamster.timeouts.push(c); + return a; }; Blockly.Blocks.hamster_change_both_wheels_by = {init:function() { this.setColour("#00979D"); @@ -3329,13 +3242,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 d = b.getNumberValue("LEFT"), c = b.getNumberValue("RIGHT"); - a.leftWheel = void 0 != a.leftWheel ? a.leftWheel + d : d; - a.rightWheel = void 0 != a.rightWheel ? a.rightWheel + c : c; - Entry.Hamster.setLineTracerMode(a, 0); - return b.callReturn(); +Entry.block.hamster_change_both_wheels_by = function(b, a) { + var d = Entry.hw.sendQueue, c = a.getNumberValue("LEFT"), e = a.getNumberValue("RIGHT"); + d.leftWheel = void 0 != d.leftWheel ? d.leftWheel + c : c; + d.rightWheel = void 0 != d.rightWheel ? d.rightWheel + e : e; + Entry.Hamster.setLineTracerMode(d, 0); + return a.callReturn(); }; Blockly.Blocks.hamster_set_both_wheels_to = {init:function() { this.setColour("#00979D"); @@ -3348,12 +3260,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 d = Entry.hw.sendQueue; + d.leftWheel = a.getNumberValue("LEFT"); + d.rightWheel = a.getNumberValue("RIGHT"); + Entry.Hamster.setLineTracerMode(d, 0); + return a.callReturn(); }; Blockly.Blocks.hamster_change_wheel_by = {init:function() { this.setColour("#00979D"); @@ -3364,12 +3276,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 d = b.getField("DIRECTION"), c = b.getNumberValue("VALUE"); - "LEFT" == d ? a.leftWheel = void 0 != a.leftWheel ? a.leftWheel + c : c : ("RIGHT" != d && (a.leftWheel = void 0 != a.leftWheel ? a.leftWheel + c : c), a.rightWheel = void 0 != a.rightWheel ? a.rightWheel + c : c); - Entry.Hamster.setLineTracerMode(a, 0); - return b.callReturn(); +Entry.block.hamster_change_wheel_by = function(b, a) { + var d = Entry.hw.sendQueue, c = a.getField("DIRECTION"), e = a.getNumberValue("VALUE"); + "LEFT" == c ? d.leftWheel = void 0 != d.leftWheel ? d.leftWheel + e : e : ("RIGHT" != c && (d.leftWheel = void 0 != d.leftWheel ? d.leftWheel + e : e), d.rightWheel = void 0 != d.rightWheel ? d.rightWheel + e : e); + Entry.Hamster.setLineTracerMode(d, 0); + return a.callReturn(); }; Blockly.Blocks.hamster_set_wheel_to = {init:function() { this.setColour("#00979D"); @@ -3380,12 +3291,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 d = b.getField("DIRECTION"), c = b.getNumberValue("VALUE"); - "LEFT" == d ? a.leftWheel = c : ("RIGHT" != d && (a.leftWheel = c), a.rightWheel = c); - Entry.Hamster.setLineTracerMode(a, 0); - return b.callReturn(); +Entry.block.hamster_set_wheel_to = function(b, a) { + var d = Entry.hw.sendQueue, c = a.getField("DIRECTION"), e = a.getNumberValue("VALUE"); + "LEFT" == c ? d.leftWheel = e : ("RIGHT" != c && (d.leftWheel = e), d.rightWheel = e); + Entry.Hamster.setLineTracerMode(d, 0); + return a.callReturn(); }; Blockly.Blocks.hamster_follow_line_using = {init:function() { this.setColour("#00979D"); @@ -3395,15 +3305,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 d = b.getField("COLOR"), c = b.getField("DIRECTION"), e = 1; - "RIGHT" == c ? e = 2 : "BOTH" == c && (e = 3); - "WHITE" == d && (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 d = Entry.hw.sendQueue, c = a.getField("COLOR"), e = a.getField("DIRECTION"), f = 1; + "RIGHT" == e ? f = 2 : "BOTH" == e && (f = 3); + "WHITE" == c && (f += 7); + d.leftWheel = 0; + d.rightWheel = 0; + Entry.Hamster.setLineTracerMode(d, f); + return a.callReturn(); }; Blockly.Blocks.hamster_follow_line_until = {init:function() { this.setColour("#00979D"); @@ -3413,19 +3322,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 d = Entry.hw.portData, c = b.getField("COLOR"), e = b.getField("DIRECTION"), f = 4; - "RIGHT" == e ? f = 5 : "FRONT" == e ? f = 6 : "REAR" == e && (f = 7); - "WHITE" == c && (f += 7); - if (b.isStart) { - if (c = Entry.Hamster, d.lineTracerStateId != c.lineTracerStateId && (c.lineTracerStateId = d.lineTracerStateId, 64 == d.lineTracerState)) { - return delete b.isStart, Entry.engine.isContinue = !1, c.setLineTracerMode(a, 0), b.callReturn(); +Entry.block.hamster_follow_line_until = function(b, a) { + var d = Entry.hw.sendQueue, c = 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, c.lineTracerStateId != e.lineTracerStateId && (e.lineTracerStateId = c.lineTracerStateId, 64 == c.lineTracerState)) { + return delete a.isStart, Entry.engine.isContinue = !1, e.setLineTracerMode(d, 0), a.callReturn(); } } else { - b.isStart = !0, a.leftWheel = 0, a.rightWheel = 0, Entry.Hamster.setLineTracerMode(a, f); + a.isStart = !0, d.leftWheel = 0, d.rightWheel = 0, Entry.Hamster.setLineTracerMode(d, g); } - return b; + return a; }; Blockly.Blocks.hamster_set_following_speed_to = {init:function() { this.setColour("#00979D"); @@ -3434,9 +3342,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 = Number(a.getField("SPEED", a)); + return a.callReturn(); }; Blockly.Blocks.hamster_stop = {init:function() { this.setColour("#00979D"); @@ -3445,12 +3353,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 d = Entry.hw.sendQueue; + d.leftWheel = 0; + d.rightWheel = 0; + Entry.Hamster.setLineTracerMode(d, 0); + return a.callReturn(); }; Blockly.Blocks.hamster_set_led_to = {init:function() { this.setColour("#00979D"); @@ -3460,11 +3368,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 d = b.getField("DIRECTION", b), c = Number(b.getField("COLOR", b)); - "LEFT" == d ? a.leftLed = c : ("RIGHT" != d && (a.leftLed = c), a.rightLed = c); - return b.callReturn(); +Entry.block.hamster_set_led_to = function(b, a) { + var d = Entry.hw.sendQueue, c = a.getField("DIRECTION", a), e = Number(a.getField("COLOR", a)); + "LEFT" == c ? d.leftLed = e : ("RIGHT" != c && (d.leftLed = e), d.rightLed = e); + return a.callReturn(); }; Blockly.Blocks.hamster_clear_led = {init:function() { this.setColour("#00979D"); @@ -3473,11 +3380,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 d = b.getField("DIRECTION", b); - "LEFT" == d ? a.leftLed = 0 : ("RIGHT" != d && (a.leftLed = 0), a.rightLed = 0); - return b.callReturn(); +Entry.block.hamster_clear_led = function(b, a) { + var d = Entry.hw.sendQueue, c = a.getField("DIRECTION", a); + "LEFT" == c ? d.leftLed = 0 : ("RIGHT" != c && (d.leftLed = 0), d.rightLed = 0); + return a.callReturn(); }; Blockly.Blocks.hamster_beep = {init:function() { this.setColour("#00979D"); @@ -3486,28 +3392,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 d = 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(); + d.buzzer = 0; + return a.callReturn(); } - b.isStart = !0; - b.timeFlag = 1; - a.buzzer = 440; - a.note = 0; - var d = setTimeout(function() { - b.timeFlag = 0; - Entry.Hamster.removeTimeout(d); + a.isStart = !0; + a.timeFlag = 1; + d.buzzer = 440; + d.note = 0; + var c = setTimeout(function() { + a.timeFlag = 0; + Entry.Hamster.removeTimeout(c); }, 200); - Entry.Hamster.timeouts.push(d); - return b; + Entry.Hamster.timeouts.push(c); + return a; }; Blockly.Blocks.hamster_change_buzzer_by = {init:function() { this.setColour("#00979D"); @@ -3518,12 +3424,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 d = b.getNumberValue("VALUE"); - a.buzzer = void 0 != a.buzzer ? a.buzzer + d : d; - a.note = 0; - return b.callReturn(); +Entry.block.hamster_change_buzzer_by = function(b, a) { + var d = Entry.hw.sendQueue, c = a.getNumberValue("VALUE"); + d.buzzer = void 0 != d.buzzer ? d.buzzer + c : c; + d.note = 0; + return a.callReturn(); }; Blockly.Blocks.hamster_set_buzzer_to = {init:function() { this.setColour("#00979D"); @@ -3534,11 +3439,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 d = Entry.hw.sendQueue; + d.buzzer = a.getNumberValue("VALUE"); + d.note = 0; + return a.callReturn(); }; Blockly.Blocks.hamster_clear_buzzer = {init:function() { this.setColour("#00979D"); @@ -3547,11 +3452,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 d = Entry.hw.sendQueue; + d.buzzer = 0; + d.note = 0; + return a.callReturn(); }; Blockly.Blocks.hamster_play_note_for = {init:function() { this.setColour("#00979D"); @@ -3563,37 +3468,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 d = 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; d.note = 0; - return b.callReturn(); + return a.callReturn(); } - a = b.getNumberField("NOTE", b); - var c = b.getNumberField("OCTAVE", b), e = 6E4 * b.getNumberValue("VALUE", b) / Entry.Hamster.tempo; - b.isStart = !0; - b.timeFlag = 1; + var c = 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; d.buzzer = 0; - d.note = a + 12 * (c - 1); - if (100 < e) { - var f = setTimeout(function() { + d.note = c + 12 * (e - 1); + if (100 < f) { + var h = setTimeout(function() { d.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"); @@ -3604,28 +3508,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 d = 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 d = b.getNumberValue("VALUE"), d = 6E4 * d / Entry.Hamster.tempo; - a.buzzer = 0; - a.note = 0; - var c = setTimeout(function() { - b.timeFlag = 0; - Entry.Hamster.removeTimeout(c); - }, d); - Entry.Hamster.timeouts.push(c); - return b; + a.isStart = !0; + a.timeFlag = 1; + var c = a.getNumberValue("VALUE"), c = 6E4 * c / Entry.Hamster.tempo; + d.buzzer = 0; + d.note = 0; + var e = setTimeout(function() { + a.timeFlag = 0; + Entry.Hamster.removeTimeout(e); + }, c); + Entry.Hamster.timeouts.push(e); + return a; }; Blockly.Blocks.hamster_change_tempo_by = {init:function() { this.setColour("#00979D"); @@ -3636,10 +3540,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"); @@ -3650,10 +3554,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"); @@ -3663,11 +3567,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 d = b.getField("PORT", b), c = Number(b.getField("MODE", b)); - "A" == d ? a.ioModeA = c : ("B" != d && (a.ioModeA = c), a.ioModeB = c); - return b.callReturn(); +Entry.block.hamster_set_port_to = function(b, a) { + var d = Entry.hw.sendQueue, c = a.getField("PORT", a), e = Number(a.getField("MODE", a)); + "A" == c ? d.ioModeA = e : ("B" != c && (d.ioModeA = e), d.ioModeB = e); + return a.callReturn(); }; Blockly.Blocks.hamster_change_output_by = {init:function() { this.setColour("#00979D"); @@ -3678,11 +3581,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 d = b.getField("PORT"), c = b.getNumberValue("VALUE"); - "A" == d ? a.outputA = void 0 != a.outputA ? a.outputA + c : c : ("B" != d && (a.outputA = void 0 != a.outputA ? a.outputA + c : c), a.outputB = void 0 != a.outputB ? a.outputB + c : c); - return b.callReturn(); +Entry.block.hamster_change_output_by = function(b, a) { + var d = Entry.hw.sendQueue, c = a.getField("PORT"), e = a.getNumberValue("VALUE"); + "A" == c ? d.outputA = void 0 != d.outputA ? d.outputA + e : e : ("B" != c && (d.outputA = void 0 != d.outputA ? d.outputA + e : e), d.outputB = void 0 != d.outputB ? d.outputB + e : e); + return a.callReturn(); }; Blockly.Blocks.hamster_set_output_to = {init:function() { this.setColour("#00979D"); @@ -3693,11 +3595,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 d = b.getField("PORT"), c = b.getNumberValue("VALUE"); - "A" == d ? a.outputA = c : ("B" != d && (a.outputA = c), a.outputB = c); - return b.callReturn(); +Entry.block.hamster_set_output_to = function(b, a) { + var d = Entry.hw.sendQueue, c = a.getField("PORT"), e = a.getNumberValue("VALUE"); + "A" == c ? d.outputA = e : ("B" != c && (d.outputA = e), d.outputB = e); + return a.callReturn(); }; Blockly.Blocks.is_clicked = {init:function() { this.setColour("#AEB8FF"); @@ -3705,7 +3606,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() { @@ -3715,9 +3616,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 d = Number(a.getField("VALUE", a)); + return 0 <= Entry.pressedKeys.indexOf(d); }; Blockly.Blocks.reach_something = {init:function() { this.setColour("#AEB8FF"); @@ -3727,68 +3628,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 d = b.getField("VALUE", b); - b = a.object; - var c = /wall/.test(d), e = ndgmr.checkPixelCollision; - if (c) { - switch(a = Entry.stage.wall, d) { + var d = a.getField("VALUE", a), c = b.object, e = /wall/.test(d), f = ndgmr.checkPixelCollision; + if (e) { + switch(e = Entry.stage.wall, d) { 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(c, e.up, .2, !0) || f(c, e.down, .2, !0) || f(c, e.left, .2, !0) || f(c, e.right, .2, !0)) { return !0; } break; case "wall_up": - if (e(b, a.up, .2, !0)) { + if (f(c, e.up, .2, !0)) { return !0; } break; case "wall_down": - if (e(b, a.down, .2, !0)) { + if (f(c, e.down, .2, !0)) { return !0; } break; case "wall_right": - if (e(b, a.right, .2, !0)) { + if (f(c, e.right, .2, !0)) { return !0; } break; case "wall_left": - if (e(b, a.left, .2, !0)) { + if (f(c, e.left, .2, !0)) { return !0; } ; } } else { if ("mouse" == d) { - return e = Entry.stage.canvas, e = b.globalToLocal(e.mouseX, e.mouseY), b.hitTest(e.x, e.y); + return f = Entry.stage.canvas, f = c.globalToLocal(f.mouseX, f.mouseY), c.hitTest(f.x, f.y); } d = Entry.container.getEntity(d); - if ("textBox" == d.type || "textBox" == a.type) { - e = d.object.getTransformedBounds(); - b = b.getTransformedBounds(); - if (Entry.checkCollisionRect(b, e)) { + if ("textBox" == d.type || "textBox" == b.type) { + f = d.object.getTransformedBounds(); + c = c.getTransformedBounds(); + if (Entry.checkCollisionRect(c, f)) { return !0; } - a = d.parent.clonedEntities; - d = 0; - for (c = a.length;d < c;d++) { - var f = a[d]; - if (!f.isStamp && f.getVisible() && Entry.checkCollisionRect(b, f.object.getTransformedBounds())) { + for (var d = d.parent.clonedEntities, e = 0, g = d.length;e < g;e++) { + var h = d[e]; + if (!h.isStamp && h.getVisible() && Entry.checkCollisionRect(c, h.object.getTransformedBounds())) { return !0; } } } else { - if (d.getVisible() && e(b, d.object, .2, !0)) { + if (d.getVisible() && f(c, d.object, .2, !0)) { return !0; } - a = d.parent.clonedEntities; - d = 0; - for (c = a.length;d < c;d++) { - if (f = a[d], !f.isStamp && f.getVisible() && e(b, f.object, .2, !0)) { + d = d.parent.clonedEntities; + e = 0; + for (g = d.length;e < g;e++) { + if (h = d[e], !h.isStamp && h.getVisible() && f(c, h.object, .2, !0)) { return !0; } } @@ -3804,11 +3701,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 d = b.getNumberValue("LEFTHAND", b); - b = b.getNumberValue("RIGHTHAND", b); - return "EQUAL" == a ? d == b : "BIGGER" == a ? d > b : d < b; +Entry.block.boolean_comparison = function(b, a) { + var d = a.getField("OPERATOR", a), c = a.getNumberValue("LEFTHAND", a), e = a.getNumberValue("RIGHTHAND", a); + return "EQUAL" == d ? c == e : "BIGGER" == d ? c > e : c < e; }; Blockly.Blocks.boolean_equal = {init:function() { this.setColour("#AEB8FF"); @@ -3818,10 +3713,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 d = a.getStringValue("LEFTHAND", a), c = a.getStringValue("RIGHTHAND", a); + return d == c; }; Blockly.Blocks.boolean_bigger = {init:function() { this.setColour("#AEB8FF"); @@ -3831,10 +3725,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 d = a.getNumberValue("LEFTHAND", a), c = a.getNumberValue("RIGHTHAND", a); + return d > c; }; Blockly.Blocks.boolean_smaller = {init:function() { this.setColour("#AEB8FF"); @@ -3844,10 +3737,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 d = a.getNumberValue("LEFTHAND", a), c = a.getNumberValue("RIGHTHAND", a); + return d < c; }; Blockly.Blocks.boolean_and_or = {init:function() { this.setColour("#AEB8FF"); @@ -3857,11 +3749,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 d = b.getBooleanValue("LEFTHAND", b); - b = b.getBooleanValue("RIGHTHAND", b); - return "AND" == a ? d && b : d || b; +Entry.block.boolean_and_or = function(b, a) { + var d = a.getField("OPERATOR", a), c = a.getBooleanValue("LEFTHAND", a), e = a.getBooleanValue("RIGHTHAND", a); + return "AND" == d ? c && e : c || e; }; Blockly.Blocks.boolean_and = {init:function() { this.setColour("#AEB8FF"); @@ -3871,10 +3761,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 d = a.getBooleanValue("LEFTHAND", a), c = a.getBooleanValue("RIGHTHAND", a); + return d && c; }; Blockly.Blocks.boolean_or = {init:function() { this.setColour("#AEB8FF"); @@ -3884,10 +3773,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 d = a.getBooleanValue("LEFTHAND", a), c = a.getBooleanValue("RIGHTHAND", a); + return d || c; }; Blockly.Blocks.boolean_not = {init:function() { this.setColour("#AEB8FF"); @@ -3898,8 +3786,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"); @@ -3908,8 +3796,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"); @@ -3917,7 +3805,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() { @@ -3926,7 +3814,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() { @@ -3937,21 +3825,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 d = b.getStringValue("LEFTHAND", b); - b = b.getStringValue("RIGHTHAND", b); - switch(a) { +Entry.block.boolean_basic_operator = function(b, a) { + var d = a.getField("OPERATOR", a), c = a.getStringValue("LEFTHAND", a), e = a.getStringValue("RIGHTHAND", a); + switch(d) { case "EQUAL": - return d == b; + return c == e; case "GREATER": - return Number(d) > Number(b); + return Number(c) > Number(e); case "LESS": - return Number(d) < Number(b); + return Number(c) < Number(e); case "GREATER_OR_EQUAL": - return Number(d) >= Number(b); + return Number(c) >= Number(e); case "LESS_OR_EQUAL": - return Number(d) <= Number(b); + return Number(c) <= Number(e); } }; Blockly.Blocks.show = {init:function() { @@ -3961,9 +3847,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"); @@ -3972,9 +3858,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"); @@ -3989,20 +3875,20 @@ Blockly.Blocks.dialog_time = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.dialog_time = function(a, b) { - if (!b.isStart) { - var d = b.getNumberValue("SECOND", b), c = 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 d = a.getNumberValue("SECOND", a), c = a.getStringValue("VALUE", a), e = a.getField("OPTION", a); + a.isStart = !0; + a.timeFlag = 1; c || "number" == typeof c || (c = " "); c = Entry.convertToRoundedDecimals(c, 3); - new Entry.Dialog(a, c, e); - a.syncDialogVisible(a.getVisible()); + new Entry.Dialog(b, c, e); + b.syncDialogVisible(b.getVisible()); setTimeout(function() { - b.timeFlag = 0; + a.timeFlag = 0; }, 1E3 * d); } - 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"); @@ -4015,13 +3901,13 @@ Blockly.Blocks.dialog = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.dialog = function(a, b) { - var d = b.getStringValue("VALUE", b); +Entry.block.dialog = function(b, a) { + var d = a.getStringValue("VALUE", a); d || "number" == typeof d || (d = " "); - var c = b.getField("OPTION", b), d = Entry.convertToRoundedDecimals(d, 3); - new Entry.Dialog(a, d, c); - a.syncDialogVisible(a.getVisible()); - return b.callReturn(); + var c = a.getField("OPTION", a), d = Entry.convertToRoundedDecimals(d, 3); + new Entry.Dialog(b, d, c); + b.syncDialogVisible(b.getVisible()); + return a.callReturn(); }; Blockly.Blocks.remove_dialog = {init:function() { this.setColour("#EC4466"); @@ -4030,9 +3916,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"); @@ -4043,10 +3929,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 d = b.getField("VALUE", b), d = a.parent.getPicture(d); - a.setImage(d); - return b.callReturn(); +Entry.block.change_to_nth_shape = function(b, a) { + var d = a.getField("VALUE", a), d = b.parent.getPicture(d); + b.setImage(d); + return a.callReturn(); }; Blockly.Blocks.change_to_next_shape = {init:function() { this.setColour("#EC4466"); @@ -4055,11 +3941,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 d; - d = b.fields && "prev" === b.getStringField("DRIECTION") ? a.parent.getPrevPicture(a.picture.id) : a.parent.getNextPicture(a.picture.id); - a.setImage(d); - return b.callReturn(); + d = a.fields && "prev" === a.getStringField("DRIECTION") ? b.parent.getPrevPicture(b.picture.id) : b.parent.getNextPicture(b.picture.id); + b.setImage(d); + return a.callReturn(); }; Blockly.Blocks.set_effect_volume = {init:function() { this.setColour("#EC4466"); @@ -4072,11 +3958,11 @@ Blockly.Blocks.set_effect_volume = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.set_effect_volume = function(a, b) { - var d = b.getField("EFFECT", b), c = b.getNumberValue("VALUE", b); - "color" == d ? a.effect.hue = c + a.effect.hue : "lens" != d && "swriling" != d && "pixel" != d && "mosaic" != d && ("brightness" == d ? a.effect.brightness = c + a.effect.brightness : "blur" != d && "opacity" == d && (a.effect.alpha += c / 100)); - a.applyFilter(); - return b.callReturn(); +Entry.block.set_effect_volume = function(b, a) { + var d = a.getField("EFFECT", a), c = a.getNumberValue("VALUE", a); + "color" == d ? b.effect.hue = c + b.effect.hue : "lens" != d && "swriling" != d && "pixel" != d && "mosaic" != d && ("brightness" == d ? b.effect.brightness = c + b.effect.brightness : "blur" != d && "opacity" == d && (b.effect.alpha += c / 100)); + b.applyFilter(); + return a.callReturn(); }; Blockly.Blocks.set_effect = {init:function() { this.setColour("#EC4466"); @@ -4089,11 +3975,11 @@ Blockly.Blocks.set_effect = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.set_effect = function(a, b) { - var d = b.getField("EFFECT", b), c = b.getNumberValue("VALUE", b); - "color" == d ? a.effect.hue = c : "lens" != d && "swriling" != d && "pixel" != d && "mosaic" != d && ("brightness" == d ? a.effect.brightness = c : "blur" != d && "opacity" == d && (a.effect.alpha = c / 100)); - a.applyFilter(); - return b.callReturn(); +Entry.block.set_effect = function(b, a) { + var d = a.getField("EFFECT", a), c = a.getNumberValue("VALUE", a); + "color" == d ? b.effect.hue = c : "lens" != d && "swriling" != d && "pixel" != d && "mosaic" != d && ("brightness" == d ? b.effect.brightness = c : "blur" != d && "opacity" == d && (b.effect.alpha = c / 100)); + b.applyFilter(); + return a.callReturn(); }; Blockly.Blocks.erase_all_effects = {init:function() { this.setColour("#EC4466"); @@ -4102,9 +3988,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"); @@ -4115,11 +4001,11 @@ Blockly.Blocks.change_scale_percent = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.change_scale_percent = function(a, b) { - var d = (b.getNumberValue("VALUE", b) + 100) / 100; - a.setScaleX(a.getScaleX() * d); - a.setScaleY(a.getScaleY() * d); - return b.callReturn(); +Entry.block.change_scale_percent = function(b, a) { + var d = (a.getNumberValue("VALUE", a) + 100) / 100; + b.setScaleX(b.getScaleX() * d); + b.setScaleY(b.getScaleY() * d); + return a.callReturn(); }; Blockly.Blocks.set_scale_percent = {init:function() { this.setColour("#EC4466"); @@ -4130,11 +4016,11 @@ Blockly.Blocks.set_scale_percent = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.set_scale_percent = function(a, b) { - var d = b.getNumberValue("VALUE", b) / 100, c = a.snapshot_; - a.setScaleX(d * c.scaleX); - a.setScaleY(d * c.scaleY); - return b.callReturn(); +Entry.block.set_scale_percent = function(b, a) { + var d = a.getNumberValue("VALUE", a) / 100, c = b.snapshot_; + b.setScaleX(d * c.scaleX); + b.setScaleY(d * c.scaleY); + return a.callReturn(); }; Blockly.Blocks.change_scale_size = {init:function() { this.setColour("#EC4466"); @@ -4145,10 +4031,10 @@ Blockly.Blocks.change_scale_size = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.change_scale_size = function(a, b) { - var d = b.getNumberValue("VALUE", b); - a.setSize(a.getSize() + d); - return b.callReturn(); +Entry.block.change_scale_size = function(b, a) { + var d = a.getNumberValue("VALUE", a); + b.setSize(b.getSize() + d); + return a.callReturn(); }; Blockly.Blocks.set_scale_size = {init:function() { this.setColour("#EC4466"); @@ -4159,10 +4045,10 @@ Blockly.Blocks.set_scale_size = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.set_scale_size = function(a, b) { - var d = b.getNumberValue("VALUE", b); - a.setSize(d); - return b.callReturn(); +Entry.block.set_scale_size = function(b, a) { + var d = a.getNumberValue("VALUE", a); + b.setSize(d); + return a.callReturn(); }; Blockly.Blocks.flip_y = {init:function() { this.setColour("#EC4466"); @@ -4171,9 +4057,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"); @@ -4182,9 +4068,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"); @@ -4195,11 +4081,10 @@ Blockly.Blocks.set_object_order = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.set_object_order = function(a, b) { - var d = b.getField("VALUE", b); - a = Entry.container.getCurrentObjects().indexOf(a.parent); - if (-1 < a) { - return Entry.container.moveElementByBlock(a, d), b.callReturn(); +Entry.block.set_object_order = function(b, a) { + var d = a.getField("VALUE", a), c = Entry.container.getCurrentObjects().indexOf(b.parent); + if (-1 < c) { + return Entry.container.moveElementByBlock(c, d), a.callReturn(); } throw Error("object is not available"); }; @@ -4211,8 +4096,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"); @@ -4223,12 +4108,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 d = b.getStringValue("VALUE"); +Entry.block.change_to_some_shape = function(b, a) { + var d = a.getStringValue("VALUE"); Entry.parseNumber(d); - d = a.parent.getPicture(d); - a.setImage(d); - return b.callReturn(); + d = b.parent.getPicture(d); + b.setImage(d); + return a.callReturn(); }; Blockly.Blocks.add_effect_amount = {init:function() { this.setColour("#EC4466"); @@ -4241,11 +4126,11 @@ Blockly.Blocks.add_effect_amount = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.add_effect_amount = function(a, b) { - var d = b.getField("EFFECT", b), c = b.getNumberValue("VALUE", b); - "color" == d ? a.effect.hsv = c + a.effect.hsv : "brightness" == d ? a.effect.brightness = c + a.effect.brightness : "transparency" == d && (a.effect.alpha -= c / 100); - a.applyFilter(); - return b.callReturn(); +Entry.block.add_effect_amount = function(b, a) { + var d = a.getField("EFFECT", a), c = a.getNumberValue("VALUE", a); + "color" == d ? b.effect.hsv = c + b.effect.hsv : "brightness" == d ? b.effect.brightness = c + b.effect.brightness : "transparency" == d && (b.effect.alpha -= c / 100); + b.applyFilter(); + return a.callReturn(); }; Blockly.Blocks.change_effect_amount = {init:function() { this.setColour("#EC4466"); @@ -4258,11 +4143,11 @@ Blockly.Blocks.change_effect_amount = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.change_effect_amount = function(a, b) { - var d = b.getField("EFFECT", b), c = b.getNumberValue("VALUE", b); - "color" == d ? a.effect.hsv = c : "brightness" == d ? a.effect.brightness = c : "transparency" == d && (a.effect.alpha = 1 - c / 100); - a.applyFilter(); - return b.callReturn(); +Entry.block.change_effect_amount = function(b, a) { + var d = a.getField("EFFECT", a), c = a.getNumberValue("VALUE", a); + "color" == d ? b.effect.hsv = c : "brightness" == d ? b.effect.brightness = c : "transparency" == d && (b.effect.alpha = 1 - c / 100); + b.applyFilter(); + return a.callReturn(); }; Blockly.Blocks.set_effect_amount = {init:function() { this.setColour("#EC4466"); @@ -4275,11 +4160,11 @@ Blockly.Blocks.set_effect_amount = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.set_effect_amount = function(a, b) { - var d = b.getField("EFFECT", b), c = b.getNumberValue("VALUE", b); - "color" == d ? a.effect.hue = c + a.effect.hue : "brightness" == d ? a.effect.brightness = c + a.effect.brightness : "transparency" == d && (a.effect.alpha -= c / 100); - a.applyFilter(); - return b.callReturn(); +Entry.block.set_effect_amount = function(b, a) { + var d = a.getField("EFFECT", a), c = a.getNumberValue("VALUE", a); + "color" == d ? b.effect.hue = c + b.effect.hue : "brightness" == d ? b.effect.brightness = c + b.effect.brightness : "transparency" == d && (b.effect.alpha -= c / 100); + b.applyFilter(); + return a.callReturn(); }; Blockly.Blocks.set_entity_effect = {init:function() { this.setColour("#EC4466"); @@ -4292,11 +4177,11 @@ Blockly.Blocks.set_entity_effect = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.set_entity_effect = function(a, b) { - var d = b.getField("EFFECT", b), c = b.getNumberValue("VALUE", b); - "color" == d ? a.effect.hue = c : "brightness" == d ? a.effect.brightness = c : "transparency" == d && (a.effect.alpha = 1 - c / 100); - a.applyFilter(); - return b.callReturn(); +Entry.block.set_entity_effect = function(b, a) { + var d = a.getField("EFFECT", a), c = a.getNumberValue("VALUE", a); + "color" == d ? b.effect.hue = c : "brightness" == d ? b.effect.brightness = c : "transparency" == d && (b.effect.alpha = 1 - c / 100); + b.applyFilter(); + return a.callReturn(); }; Blockly.Blocks.change_object_index = {init:function() { this.setColour("#EC4466"); @@ -4306,11 +4191,9 @@ Blockly.Blocks.change_object_index = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.change_object_index = function(a, b) { - var d, c = 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 d, c = 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(c) { @@ -4318,16 +4201,16 @@ Entry.block.change_object_index = function(a, b) { d = 0; break; case "FORWARD": - d = Math.max(0, a - 1); + d = Math.max(0, f - 1); break; case "BACKWARD": - d = Math.min(e, a + 1); + d = Math.min(e, f + 1); break; case "BACK": d = e; } - Entry.container.moveElementByBlock(a, d); - return b.callReturn(); + Entry.container.moveElementByBlock(f, d); + return a.callReturn(); }; Blockly.Blocks.move_direction = {init:function() { this.setColour("#A751E3"); @@ -4338,12 +4221,12 @@ Blockly.Blocks.move_direction = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.move_direction = function(a, b) { - var d = b.getNumberValue("VALUE", b); - a.setX(a.getX() + d * Math.cos((a.getRotation() + a.getDirection() - 90) / 180 * Math.PI)); - a.setY(a.getY() - d * 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 d = a.getNumberValue("VALUE", a); + b.setX(b.getX() + d * Math.cos((b.getRotation() + b.getDirection() - 90) / 180 * Math.PI)); + b.setY(b.getY() - d * 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"); @@ -4354,11 +4237,11 @@ Blockly.Blocks.move_x = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.move_x = function(a, b) { - var d = b.getNumberValue("VALUE", b); - a.setX(a.getX() + d); - a.brush && !a.brush.stop && a.brush.lineTo(a.getX(), -1 * a.getY()); - return b.callReturn(); +Entry.block.move_x = function(b, a) { + var d = a.getNumberValue("VALUE", a); + b.setX(b.getX() + d); + 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"); @@ -4369,11 +4252,11 @@ Blockly.Blocks.move_y = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.move_y = function(a, b) { - var d = b.getNumberValue("VALUE", b); - a.setY(a.getY() + d); - a.brush && !a.brush.stop && a.brush.lineTo(a.getX(), -1 * a.getY()); - return b.callReturn(); +Entry.block.move_y = function(b, a) { + var d = a.getNumberValue("VALUE", a); + b.setY(b.getY() + d); + 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"); @@ -4388,29 +4271,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 d; - d = b.getNumberValue("VALUE1", b); - b.isStart = !0; - b.frameCount = Math.floor(d * Entry.FPS); - b.x = b.getNumberValue("VALUE2", b); - b.y = b.getNumberValue("VALUE3", b); - } - if (0 != b.frameCount) { - d = b.x - a.getX(); - var c = b.y - a.getY(); - d /= b.frameCount; - c /= b.frameCount; - a.setX(a.getX() + d); - a.setY(a.getY() + c); - b.frameCount--; - a.brush && !a.brush.stop && a.brush.lineTo(a.getX(), -1 * a.getY()); - return b; + d = a.getNumberValue("VALUE1", a); + a.isStart = !0; + a.frameCount = Math.floor(d * Entry.FPS); + a.x = a.getNumberValue("VALUE2", a); + a.y = a.getNumberValue("VALUE3", a); + } + if (0 != a.frameCount) { + d = a.x - b.getX(); + var c = a.y - b.getY(); + d /= a.frameCount; + c /= a.frameCount; + b.setX(b.getX() + d); + b.setY(b.getY() + c); + 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"); @@ -4421,10 +4304,10 @@ Blockly.Blocks.rotate_by_angle = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.rotate_by_angle = function(a, b) { - var d = b.getNumberValue("VALUE", b); - a.setRotation(a.getRotation() + d); - return b.callReturn(); +Entry.block.rotate_by_angle = function(b, a) { + var d = a.getNumberValue("VALUE", a); + b.setRotation(b.getRotation() + d); + return a.callReturn(); }; Blockly.Blocks.rotate_by_angle_dropdown = {init:function() { this.setColour("#A751E3"); @@ -4434,10 +4317,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 d = b.getField("VALUE", b); - a.setRotation(a.getRotation() + Number(d)); - return b.callReturn(); +Entry.block.rotate_by_angle_dropdown = function(b, a) { + var d = a.getField("VALUE", a); + b.setRotation(b.getRotation() + Number(d)); + return a.callReturn(); }; Blockly.Blocks.see_angle = {init:function() { this.setColour("#A751E3"); @@ -4448,10 +4331,10 @@ Blockly.Blocks.see_angle = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.see_angle = function(a, b) { - var d = b.getNumberValue("VALUE", b); - a.setDirection(d); - return b.callReturn(); +Entry.block.see_angle = function(b, a) { + var d = a.getNumberValue("VALUE", a); + b.setDirection(d); + return a.callReturn(); }; Blockly.Blocks.see_direction = {init:function() { this.setColour("#A751E3"); @@ -4462,10 +4345,10 @@ Blockly.Blocks.see_direction = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.see_direction = function(a, b) { - var d = b.getField("VALUE", b), c = Entry.container.getEntity(d), d = c.getX() - a.getX(), c = c.getY() - a.getY(); - 0 <= d ? a.setRotation(Math.atan(c / d) / Math.PI * 180 + 90) : a.setRotation(Math.atan(c / d) / Math.PI * 180 + 270); - return b.callReturn(); +Entry.block.see_direction = function(b, a) { + var d = a.getField("VALUE", a), c = Entry.container.getEntity(d), d = c.getX() - b.getX(), c = c.getY() - b.getY(); + 0 <= d ? b.setRotation(Math.atan(c / d) / Math.PI * 180 + 90) : b.setRotation(Math.atan(c / d) / Math.PI * 180 + 270); + return a.callReturn(); }; Blockly.Blocks.locate_xy = {init:function() { this.setColour("#A751E3"); @@ -4478,13 +4361,13 @@ Blockly.Blocks.locate_xy = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.locate_xy = function(a, b) { - var d = b.getNumberValue("VALUE1", b); - a.setX(d); - d = b.getNumberValue("VALUE2", b); - a.setY(d); - a.brush && !a.brush.stop && a.brush.lineTo(a.getX(), -1 * a.getY()); - return b.callReturn(); +Entry.block.locate_xy = function(b, a) { + var d = a.getNumberValue("VALUE1", a); + b.setX(d); + d = a.getNumberValue("VALUE2", a); + b.setY(d); + 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"); @@ -4495,11 +4378,11 @@ Blockly.Blocks.locate_x = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.locate_x = function(a, b) { - var d = b.getNumberValue("VALUE", b); - a.setX(d); - a.brush && !a.brush.stop && a.brush.lineTo(a.getX(), -1 * a.getY()); - return b.callReturn(); +Entry.block.locate_x = function(b, a) { + var d = a.getNumberValue("VALUE", a); + b.setX(d); + 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"); @@ -4510,11 +4393,11 @@ Blockly.Blocks.locate_y = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.locate_y = function(a, b) { - var d = b.getNumberValue("VALUE", b); - a.setY(d); - a.brush && !a.brush.stop && a.brush.lineTo(a.getX(), -1 * a.getY()); - return b.callReturn(); +Entry.block.locate_y = function(b, a) { + var d = a.getNumberValue("VALUE", a); + b.setY(d); + b.brush && !b.brush.stop && b.brush.lineTo(b.getX(), -1 * b.getY()); + return a.callReturn(); }; Blockly.Blocks.locate = {init:function() { this.setColour("#A751E3"); @@ -4525,13 +4408,13 @@ Blockly.Blocks.locate = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.locate = function(a, b) { - var d = b.getField("VALUE", b), c; +Entry.block.locate = function(b, a) { + var d = a.getField("VALUE", a), c; "mouse" == d ? (d = Entry.stage.mouseCoordinate.x, c = Entry.stage.mouseCoordinate.y) : (c = Entry.container.getEntity(d), d = c.getX(), c = c.getY()); - a.setX(Number(d)); - a.setY(Number(c)); - a.brush && !a.brush.stop && a.brush.lineTo(d, -1 * c); - return b.callReturn(); + b.setX(Number(d)); + b.setY(Number(c)); + b.brush && !b.brush.stop && b.brush.lineTo(d, -1 * c); + return a.callReturn(); }; Blockly.Blocks.move_xy_time = {init:function() { this.setColour("#A751E3"); @@ -4546,22 +4429,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 d; - d = b.getNumberValue("VALUE1", b); - var c = b.getNumberValue("VALUE2", b), e = b.getNumberValue("VALUE3", b); - b.isStart = !0; - b.frameCount = Math.floor(d * Entry.FPS); - b.dX = c / b.frameCount; - b.dY = e / b.frameCount; + d = a.getNumberValue("VALUE1", a); + var c = a.getNumberValue("VALUE2", a), e = a.getNumberValue("VALUE3", a); + a.isStart = !0; + a.frameCount = Math.floor(d * Entry.FPS); + a.dX = c / 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"); @@ -4585,21 +4468,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 d; - d = b.getNumberValue("VALUE", b); - var c = b.getNumberField("VALUE", b); - b.isStart = !0; - b.frameCount = Math.floor(d * Entry.FPS); - b.dAngle = c / b.frameCount; + d = a.getNumberValue("VALUE", a); + var c = a.getNumberField("VALUE", a); + a.isStart = !0; + a.frameCount = Math.floor(d * Entry.FPS); + a.dAngle = c / 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"); @@ -4617,23 +4500,22 @@ Blockly.Blocks.bounce_wall = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.bounce_wall = function(a, b) { - var d = a.parent.getRotateMethod(), c = "free" == d ? (a.getRotation() + a.getDirection()).mod(360) : a.getDirection(), e; +Entry.block.bounce_wall = function(b, a) { + var d = b.parent.getRotateMethod(), c = "free" == d ? (b.getRotation() + b.getDirection()).mod(360) : b.getDirection(), e = Entry.Utils.COLLISION.NONE; if (90 > c && 0 <= c || 360 > c && 270 <= c) { - 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" == d ? 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" == d ? a.setRotation(-a.getRotation() - 2 * a.getDirection() + 180) : a.setDirection(-a.getDirection() + 180), a.collision = + f ? ("free" == d ? 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" == d ? b.setRotation(-b.getRotation() - 2 * b.getDirection() + 180) : b.setDirection(-b.getDirection() + 180), b.collision = Entry.Utils.COLLISION.DOWN)); } else { - 270 > c && 90 <= c && (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" == d ? 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" == d ? a.setRotation(-a.getRotation() - 2 * a.getDirection() + 180) : a.setDirection(-a.getDirection() + 180), a.collision = Entry.Utils.COLLISION.UP))); + 270 > c && 90 <= c && (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" == d ? 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" == d ? b.setRotation(-b.getRotation() - 2 * b.getDirection() + 180) : b.setDirection(-b.getDirection() + 180), b.collision = Entry.Utils.COLLISION.UP))); } - 360 > c && 180 <= c ? (e = a.collision == Entry.Utils.COLLISION.LEFT, c = ndgmr.checkPixelCollision(Entry.stage.wall.left, a.object, 0, !1), !c && e && (a.collision = Entry.Utils.COLLISION.NONE), c && e && (c = !1), c ? ("free" == d ? 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, c = ndgmr.checkPixelCollision(Entry.stage.wall.right, a.object, 0, !1), !c && - e && (a.collision = Entry.Utils.COLLISION.NONE), c && e && (c = !1), c && ("free" == d ? a.setRotation(-a.getRotation() - 2 * a.getDirection()) : a.setDirection(-a.getDirection() + 360), a.collision = Entry.Utils.COLLISION.RIGHT))) : 180 > c && 0 <= c && (e = a.collision == Entry.Utils.COLLISION.RIGHT, c = ndgmr.checkPixelCollision(Entry.stage.wall.right, a.object, 0, !1), !c && e && (a.collision = Entry.Utils.COLLISION.NONE), c && e && (c = !1), c ? ("free" == d ? 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, c = ndgmr.checkPixelCollision(Entry.stage.wall.left, a.object, 0, !1), !c && e && (a.collision = Entry.Utils.COLLISION.NONE), c && e && (c = !1), c && ("free" == d ? a.setRotation(-a.getRotation() - 2 * a.getDirection()) : a.setDirection(-a.getDirection() + 360), a.collision = Entry.Utils.COLLISION.LEFT))); - return b.callReturn(); + 360 > c && 180 <= c ? (e = b.collision == Entry.Utils.COLLISION.LEFT, c = ndgmr.checkPixelCollision(Entry.stage.wall.left, b.object, 0, !1), !c && e && (b.collision = Entry.Utils.COLLISION.NONE), c && e && (c = !1), c ? ("free" == d ? 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, c = ndgmr.checkPixelCollision(Entry.stage.wall.right, b.object, 0, !1), !c && + e && (b.collision = Entry.Utils.COLLISION.NONE), c && e && (c = !1), c && ("free" == d ? b.setRotation(-b.getRotation() - 2 * b.getDirection()) : b.setDirection(-b.getDirection() + 360), b.collision = Entry.Utils.COLLISION.RIGHT))) : 180 > c && 0 <= c && (e = b.collision == Entry.Utils.COLLISION.RIGHT, c = ndgmr.checkPixelCollision(Entry.stage.wall.right, b.object, 0, !1), !c && e && (b.collision = Entry.Utils.COLLISION.NONE), c && e && (c = !1), c ? ("free" == d ? 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, c = ndgmr.checkPixelCollision(Entry.stage.wall.left, b.object, 0, !1), !c && e && (b.collision = Entry.Utils.COLLISION.NONE), c && e && (c = !1), c && ("free" == d ? 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"); @@ -4642,9 +4524,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"); @@ -4653,9 +4535,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"); @@ -4666,16 +4548,16 @@ Blockly.Blocks.see_angle_object = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.see_angle_object = function(a, b) { - var d = b.getField("VALUE", b), c = a.getX(), e = a.getY(); - if (a.parent.id == d) { - return b.callReturn(); +Entry.block.see_angle_object = function(b, a) { + var d = a.getField("VALUE", a), c = b.getX(), e = b.getY(); + if (b.parent.id == d) { + return a.callReturn(); } "mouse" == d ? (d = Entry.stage.mouseCoordinate.y, c = Entry.stage.mouseCoordinate.x - c, e = d - e) : (d = Entry.container.getEntity(d), c = d.getX() - c, e = d.getY() - e); - e = 0 === c && 0 === e ? a.getDirection() + a.getRotation() : 0 <= c ? -Math.atan(e / c) / Math.PI * 180 + 90 : -Math.atan(e / c) / Math.PI * 180 + 270; - c = a.getDirection() + a.getRotation(); - a.setRotation(a.getRotation() + e - c); - return b.callReturn(); + e = 0 === c && 0 === e ? b.getDirection() + b.getRotation() : 0 <= c ? -Math.atan(e / c) / Math.PI * 180 + 90 : -Math.atan(e / c) / Math.PI * 180 + 270; + c = b.getDirection() + b.getRotation(); + b.setRotation(b.getRotation() + e - c); + return a.callReturn(); }; Blockly.Blocks.see_angle_direction = {init:function() { this.setColour("#A751E3"); @@ -4686,10 +4568,10 @@ Blockly.Blocks.see_angle_direction = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.see_angle_direction = function(a, b) { - var d = b.getNumberValue("VALUE", b), c = a.getDirection() + a.getRotation(); - a.setRotation(a.getRotation() + d - c); - return b.callReturn(); +Entry.block.see_angle_direction = function(b, a) { + var d = a.getNumberValue("VALUE", a), c = b.getDirection() + b.getRotation(); + b.setRotation(b.getRotation() + d - c); + return a.callReturn(); }; Blockly.Blocks.rotate_direction = {init:function() { this.setColour("#A751E3"); @@ -4700,10 +4582,10 @@ Blockly.Blocks.rotate_direction = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.rotate_direction = function(a, b) { - var d = b.getNumberValue("VALUE", b); - a.setDirection(d + a.getDirection()); - return b.callReturn(); +Entry.block.rotate_direction = function(b, a) { + var d = a.getNumberValue("VALUE", a); + b.setDirection(d + b.getDirection()); + return a.callReturn(); }; Blockly.Blocks.locate_object_time = {init:function() { this.setColour("#A751E3"); @@ -4716,25 +4598,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 d, c, e; - c = b.getField("TARGET", b); - d = b.getNumberValue("VALUE", b); + c = a.getField("TARGET", a); + d = a.getNumberValue("VALUE", a); d = Math.floor(d * Entry.FPS); e = Entry.stage.mouseCoordinate; if (0 != d) { - "mouse" == c ? (c = e.x - a.getX(), e = e.y - a.getY()) : (e = Entry.container.getEntity(c), c = e.getX() - a.getX(), e = e.getY() - a.getY()), b.isStart = !0, b.frameCount = d, b.dX = c / b.frameCount, b.dY = e / b.frameCount; + "mouse" == c ? (c = e.x - b.getX(), e = e.y - b.getY()) : (e = Entry.container.getEntity(c), c = e.getX() - b.getX(), e = e.getY() - b.getY()), a.isStart = !0, a.frameCount = d, a.dX = c / a.frameCount, a.dY = e / a.frameCount; } else { - return "mouse" == c ? (c = Number(e.x), e = Number(e.y)) : (e = Entry.container.getEntity(c), c = e.getX(), e = e.getY()), a.setX(c), a.setY(e), a.brush && !a.brush.stop && a.brush.lineTo(a.getX(), -1 * a.getY()), b.callReturn(); + return "mouse" == c ? (c = Number(e.x), e = Number(e.y)) : (e = Entry.container.getEntity(c), c = e.getX(), e = e.getY()), b.setX(c), 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"); @@ -4745,10 +4627,10 @@ Blockly.Blocks.rotate_absolute = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.rotate_absolute = function(a, b) { - var d = b.getNumberValue("VALUE", b); - a.setRotation(d); - return b.callReturn(); +Entry.block.rotate_absolute = function(b, a) { + var d = a.getNumberValue("VALUE", a); + b.setRotation(d); + return a.callReturn(); }; Blockly.Blocks.rotate_relative = {init:function() { this.setColour("#A751E3"); @@ -4759,10 +4641,10 @@ Blockly.Blocks.rotate_relative = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.rotate_relative = function(a, b) { - var d = b.getNumberValue("VALUE", b); - a.setRotation(d + a.getRotation()); - return b.callReturn(); +Entry.block.rotate_relative = function(b, a) { + var d = a.getNumberValue("VALUE", a); + b.setRotation(d + b.getRotation()); + return a.callReturn(); }; Blockly.Blocks.direction_absolute = {init:function() { this.setColour("#A751E3"); @@ -4773,10 +4655,10 @@ Blockly.Blocks.direction_absolute = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.direction_absolute = function(a, b) { - var d = b.getNumberValue("VALUE", b); - a.setDirection(d); - return b.callReturn(); +Entry.block.direction_absolute = function(b, a) { + var d = a.getNumberValue("VALUE", a); + b.setDirection(d); + return a.callReturn(); }; Blockly.Blocks.direction_relative = {init:function() { this.setColour("#A751E3"); @@ -4787,10 +4669,10 @@ Blockly.Blocks.direction_relative = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.direction_relative = function(a, b) { - var d = b.getNumberValue("VALUE", b); - a.setDirection(d + a.getDirection()); - return b.callReturn(); +Entry.block.direction_relative = function(b, a) { + var d = a.getNumberValue("VALUE", a); + b.setDirection(d + b.getDirection()); + return a.callReturn(); }; Blockly.Blocks.move_to_angle = {init:function() { this.setColour("#A751E3"); @@ -4803,12 +4685,12 @@ Blockly.Blocks.move_to_angle = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.move_to_angle = function(a, b) { - var d = b.getNumberValue("VALUE", b), c = b.getNumberValue("ANGLE", b); - a.setX(a.getX() + d * Math.cos((c - 90) / 180 * Math.PI)); - a.setY(a.getY() - d * Math.sin((c - 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 d = a.getNumberValue("VALUE", a), c = a.getNumberValue("ANGLE", a); + b.setX(b.getX() + d * Math.cos((c - 90) / 180 * Math.PI)); + b.setY(b.getY() - d * Math.sin((c - 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"); @@ -4822,21 +4704,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 d; - d = b.getNumberValue("VALUE", b); - var c = b.getNumberValue("ANGLE", b); - b.isStart = !0; - b.frameCount = Math.floor(d * Entry.FPS); - b.dAngle = c / b.frameCount; + d = a.getNumberValue("VALUE", a); + var c = a.getNumberValue("ANGLE", a); + a.isStart = !0; + a.frameCount = Math.floor(d * Entry.FPS); + a.dAngle = c / 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"); @@ -4849,26 +4731,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 d; - d = b.getNumberValue("DURATION", b); - var c = b.getNumberValue("AMOUNT", b); - b.isStart = !0; - b.frameCount = Math.floor(d * Entry.FPS); - b.dDirection = c / b.frameCount; + d = a.getNumberValue("DURATION", a); + var c = a.getNumberValue("AMOUNT", a); + a.isStart = !0; + a.frameCount = Math.floor(d * Entry.FPS); + a.dDirection = c / 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", @@ -4879,9 +4761,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 d = a.getStringField("PORT"); + return Entry.hw.portData[d]; }; Blockly.Blocks.neobot_left_motor = {init:function() { this.setColour("#00979D"); @@ -4891,11 +4773,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 d = b.getNumberField("DIRECTION"); - Entry.hw.sendQueue.DCL = a + d; - return b.callReturn(); +Entry.block.neobot_left_motor = function(b, a) { + var d = a.getNumberField("SPEED"), c = a.getNumberField("DIRECTION"); + Entry.hw.sendQueue.DCL = d + c; + return a.callReturn(); }; Blockly.Blocks.neobot_stop_left_motor = {init:function() { this.setColour("#00979D"); @@ -4904,9 +4785,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"); @@ -4916,11 +4797,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 d = b.getNumberField("DIRECTION"); - Entry.hw.sendQueue.DCR = a + d; - return b.callReturn(); +Entry.block.neobot_right_motor = function(b, a) { + var d = a.getNumberField("SPEED"), c = a.getNumberField("DIRECTION"); + Entry.hw.sendQueue.DCR = d + c; + return a.callReturn(); }; Blockly.Blocks.neobot_stop_right_motor = {init:function() { this.setColour("#00979D"); @@ -4929,9 +4809,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"); @@ -4942,34 +4822,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 d = 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 + d; + Entry.hw.sendQueue.DCR = 16 + d; break; case 2: - Entry.hw.sendQueue.DCL = 32 + a; - Entry.hw.sendQueue.DCR = 32 + a; + Entry.hw.sendQueue.DCL = 32 + d; + Entry.hw.sendQueue.DCR = 32 + d; break; case 3: - Entry.hw.sendQueue.DCL = 32 + a; - Entry.hw.sendQueue.DCR = 16 + a; + Entry.hw.sendQueue.DCL = 32 + d; + Entry.hw.sendQueue.DCR = 16 + d; break; case 4: - Entry.hw.sendQueue.DCL = 16 + a; - Entry.hw.sendQueue.DCR = 32 + a; + Entry.hw.sendQueue.DCL = 16 + d; + Entry.hw.sendQueue.DCR = 32 + d; break; case 5: Entry.hw.sendQueue.DCL = 0; - Entry.hw.sendQueue.DCR = 16 + a; + Entry.hw.sendQueue.DCR = 16 + d; break; case 6: - Entry.hw.sendQueue.DCL = 16 + a, Entry.hw.sendQueue.DCR = 0; + Entry.hw.sendQueue.DCL = 16 + d, Entry.hw.sendQueue.DCR = 0; } - return b.callReturn(); + return a.callReturn(); }; Blockly.Blocks.neobot_set_servo = {init:function() { this.setColour("#00979D"); @@ -4979,13 +4859,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 d = b.getNumberField("DEGREE"); - Entry.hw.sendQueue["OUT" + a] = d; - 3 === a && (a = 4); - Entry.hw.sendQueue.OPT |= a; - return b.callReturn(); +Entry.block.neobot_set_servo = function(b, a) { + var d = a.getNumberField("PORT"), c = a.getNumberField("DEGREE"); + Entry.hw.sendQueue["OUT" + d] = c; + 3 === d && (d = 4); + Entry.hw.sendQueue.OPT |= d; + return a.callReturn(); }; Blockly.Blocks.neobot_set_output = {init:function() { this.setColour("#00979D"); @@ -4996,14 +4875,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 d = b.getNumberValue("VALUE", b), c = a; - 0 > d ? d = 0 : 255 < d && (d = 255); - 3 === c && (c = 4); - Entry.hw.sendQueue["OUT" + a] = d; - Entry.hw.sendQueue.OPT &= ~c; - return b.callReturn(); +Entry.block.neobot_set_output = function(b, a) { + var d = a.getStringField("PORT", a), c = a.getNumberValue("VALUE", a), e = d; + 0 > c ? c = 0 : 255 < c && (c = 255); + 3 === e && (e = 4); + Entry.hw.sendQueue["OUT" + d] = c; + Entry.hw.sendQueue.OPT &= ~e; + return a.callReturn(); }; Blockly.Blocks.neobot_set_fnd = {init:function() { this.setColour("#00979D"); @@ -5014,11 +4892,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 d = a.getNumberValue("VALUE", a); + 255 < d ? d = 255 : 0 > d && (d = 0); + Entry.hw.sendQueue.FND = d; + return a.callReturn(); }; Blockly.Blocks.neobot_play_note_for = {init:function() { this.setColour("#00979D"); @@ -5029,55 +4907,55 @@ 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 d = 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 d = b.getNumberField("NOTE", b), c = b.getNumberField("OCTAVE", b), e = b.getNumberField("DURATION", b), d = d + 12 * c; - b.isStart = !0; - b.timeFlag = 1; - 65 < d && (d = 65); - a.SND = d; + var c = a.getNumberField("NOTE", a), e = a.getNumberField("OCTAVE", a), f = a.getNumberField("DURATION", a), c = c + 12 * e; + a.isStart = !0; + a.timeFlag = 1; + 65 < c && (c = 65); + d.SND = c; setTimeout(function() { - b.timeFlag = 0; - }, 1 / e * 2E3); - return b; + a.timeFlag = 0; + }, 1 / f * 2E3); + return a; }; Entry.Roborobo_Roduino = {name:"roborobo_roduino", INSTRUCTION:{DIGITAL_READ:1, DIGITAL_SET_MODE:2, DIGITAL_WRITE:3, ANALOG_WRITE:4, ANALOG_READ:5, MOTOR:6, COLOR:7}, setZero:function() { - for (var a = 0;5 > a;a++) { - Entry.hw.sendQueue[a] = 0; + for (var b = 0;5 > b;b++) { + Entry.hw.sendQueue[b] = 0; } this.ColorPin = [0, 0, 0]; Entry.hw.update(); -}, setSendData:function(a) { - Entry.hw.sendQueue = a; +}, setSendData:function(b) { + Entry.hw.sendQueue = b; Entry.hw.update(); this.wait(32); -}, wait:function(a) { - for (var b = (new Date).getTime(), d = b;d < b + a;) { +}, wait:function(b) { + for (var a = (new Date).getTime(), d = a;d < a + b;) { d = (new Date).getTime(); } }, ColorPin:[0, 0, 0]}; Entry.Roborobo_SchoolKit = {name:"roborobo_schoolkit", INSTRUCTION:{DIGITAL_READ:1, DIGITAL_WRITE:2, MOTOR:3, COLOR:4, SERVO:5}, setZero:function() { - for (var a = 0;5 > a;a++) { - Entry.hw.sendQueue[a] = 0; + for (var b = 0;5 > b;b++) { + Entry.hw.sendQueue[b] = 0; } this.ColorPin = [0, 0, 0]; Entry.hw.update(); -}, setSendData:function(a) { - Entry.hw.sendQueue = a; +}, setSendData:function(b) { + Entry.hw.sendQueue = b; Entry.hw.update(); this.wait(32); -}, wait:function(a) { - for (var b = (new Date).getTime(), d = b;d < b + a;) { +}, wait:function(b) { + for (var a = (new Date).getTime(), d = a;d < a + b;) { d = (new Date).getTime(); } }, ColorPin:[0, 0, 0]}; @@ -5087,7 +4965,7 @@ Blockly.Blocks.roduino_on_block = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.roduino_on_block = function(a, b) { +Entry.block.roduino_on_block = function(b, a) { return "1"; }; Blockly.Blocks.roduino_off_block = {init:function() { @@ -5096,7 +4974,7 @@ Blockly.Blocks.roduino_off_block = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.roduino_off_block = function(a, b) { +Entry.block.roduino_off_block = function(b, a) { return "0"; }; Blockly.Blocks.roduino_get_analog_number = {init:function() { @@ -5106,8 +4984,8 @@ Blockly.Blocks.roduino_get_analog_number = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.roduino_get_analog_number = function(a, b) { - return b.getStringField("PORT"); +Entry.block.roduino_get_analog_number = function(b, a) { + return a.getStringField("PORT"); }; Blockly.Blocks.roduino_get_port_number = {init:function() { this.setColour("#00979D"); @@ -5116,8 +4994,8 @@ Blockly.Blocks.roduino_get_port_number = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.roduino_get_port_number = function(a, b) { - return b.getStringField("PORT"); +Entry.block.roduino_get_port_number = function(b, a) { + return a.getStringField("PORT"); }; Blockly.Blocks.roduino_get_analog_value = {init:function() { this.setColour("#00979D"); @@ -5127,10 +5005,10 @@ Blockly.Blocks.roduino_get_analog_value = {init:function() { this.setInputsInline(!0); this.setOutput(!0, "Number"); }}; -Entry.block.roduino_get_analog_value = function(a, b) { - a = parseInt(b.getValue("VALUE", b)); - Entry.Roduino.setSendData([Entry.Roduino.INSTRUCTION.ANALOG_READ, a]); - return Entry.hw.getAnalogPortValue(a); +Entry.block.roduino_get_analog_value = function(b, a) { + var d = parseInt(a.getValue("VALUE", a)); + Entry.Roduino.setSendData([Entry.Roduino.INSTRUCTION.ANALOG_READ, d]); + return Entry.hw.getAnalogPortValue(d); }; Blockly.Blocks.roduino_get_digital_value = {init:function() { this.setColour("#00979D"); @@ -5140,10 +5018,10 @@ Blockly.Blocks.roduino_get_digital_value = {init:function() { this.setInputsInline(!0); this.setOutput(!0, "Number"); }}; -Entry.block.roduino_get_digital_value = function(a, b) { - a = b.getNumberValue("VALUE"); - Entry.Roborobo_Roduino.setSendData([Entry.Roborobo_Roduino.INSTRUCTION.DIGITAL_READ, a]); - return Entry.hw.portData[a - 2]; +Entry.block.roduino_get_digital_value = function(b, a) { + var d = a.getNumberValue("VALUE"); + Entry.Roborobo_Roduino.setSendData([Entry.Roborobo_Roduino.INSTRUCTION.DIGITAL_READ, d]); + return Entry.hw.portData[d - 2]; }; Blockly.Blocks.roduino_get_color = {init:function() { this.setColour("#00979D"); @@ -5151,24 +5029,22 @@ Blockly.Blocks.roduino_get_color = {init:function() { this.setInputsInline(!0); this.setOutput(!0, "Number"); }}; -Entry.block.roduino_get_color = function(a, b) { - a = 0; - b = b.getField("VALUE", b); - var d = [Entry.hw.portData[Entry.Roborobo_Roduino.ColorPin[0] - 2], Entry.hw.portData[Entry.Roborobo_Roduino.ColorPin[1] - 2], Entry.hw.portData[Entry.Roborobo_Roduino.ColorPin[2] - 2]]; - switch(b) { +Entry.block.roduino_get_color = function(b, a) { + var d = 0, c = a.getField("VALUE", a), e = [Entry.hw.portData[Entry.Roborobo_Roduino.ColorPin[0] - 2], Entry.hw.portData[Entry.Roborobo_Roduino.ColorPin[1] - 2], Entry.hw.portData[Entry.Roborobo_Roduino.ColorPin[2] - 2]]; + switch(c) { case "red": - 1 == d[0] && 0 == d[1] && 0 == d[2] && (a = 1); + 1 == e[0] && 0 == e[1] && 0 == e[2] && (d = 1); break; case "green": - 0 == d[0] && 1 == d[1] && 0 == d[2] && (a = 1); + 0 == e[0] && 1 == e[1] && 0 == e[2] && (d = 1); break; case "blue": - 0 == d[0] && 0 == d[1] && 1 == d[2] && (a = 1); + 0 == e[0] && 0 == e[1] && 1 == e[2] && (d = 1); break; case "yellow": - 1 == d[0] && 1 == d[1] && 1 == d[2] && (a = 1); + 1 == e[0] && 1 == e[1] && 1 == e[2] && (d = 1); } - return a; + return d; }; Blockly.Blocks.roduino_set_digital = {init:function() { this.setColour("#00979D"); @@ -5180,11 +5056,10 @@ Blockly.Blocks.roduino_set_digital = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.roduino_set_digital = function(a, b) { - a = b.getNumberValue("VALUE"); - var d = b.getField("OPERATOR"); - Entry.Roborobo_Roduino.setSendData([Entry.Roborobo_Roduino.INSTRUCTION.DIGITAL_WRITE, a, "on" == d ? 1 : 0]); - return b.callReturn(); +Entry.block.roduino_set_digital = function(b, a) { + var d = a.getNumberValue("VALUE"), c = a.getField("OPERATOR"); + Entry.Roborobo_Roduino.setSendData([Entry.Roborobo_Roduino.INSTRUCTION.DIGITAL_WRITE, d, "on" == c ? 1 : 0]); + return a.callReturn(); }; Blockly.Blocks.roduino_motor = {init:function() { this.setColour("#00979D"); @@ -5194,16 +5069,12 @@ Blockly.Blocks.roduino_motor = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.roduino_motor = function(a, b) { - pin2 = 0; - var d; - value2 = 0; - a = b.getField("MODE"); - d = b.getField("OPERATOR"); - "motor1" == a ? (a = 9, pin2 = 10) : (a = 11, pin2 = 12); - "cw" == d ? (d = 1, value2 = 0) : "ccw" == d ? (d = 0, value2 = 1) : value2 = d = 0; - Entry.Roborobo_Roduino.setSendData([Entry.Roborobo_Roduino.INSTRUCTION.MOTOR, a, d, pin2, value2]); - return b.callReturn(); +Entry.block.roduino_motor = function(b, a) { + var d = pin2 = 0, c = value2 = 0, d = a.getField("MODE"), c = a.getField("OPERATOR"); + "motor1" == d ? (d = 9, pin2 = 10) : (d = 11, pin2 = 12); + "cw" == c ? (c = 1, value2 = 0) : "ccw" == c ? (c = 0, value2 = 1) : value2 = c = 0; + Entry.Roborobo_Roduino.setSendData([Entry.Roborobo_Roduino.INSTRUCTION.MOTOR, d, c, pin2, value2]); + return a.callReturn(); }; Blockly.Blocks.roduino_set_color_pin = {init:function() { this.setColour("#00979D"); @@ -5218,12 +5089,11 @@ Blockly.Blocks.roduino_set_color_pin = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.roduino_set_color_pin = function(a, b) { - a = b.getNumberValue("RED", b); - var d = b.getNumberValue("GREEN", b), c = b.getNumberValue("BLUE", b); - Entry.Roborobo_Roduino.ColorPin = [a, d, c]; - Entry.Roborobo_Roduino.setSendData([Entry.Roborobo_Roduino.INSTRUCTION.COLOR, a, d, c]); - return b.callReturn(); +Entry.block.roduino_set_color_pin = function(b, a) { + var d = a.getNumberValue("RED", a), c = a.getNumberValue("GREEN", a), e = a.getNumberValue("BLUE", a); + Entry.Roborobo_Roduino.ColorPin = [d, c, e]; + Entry.Roborobo_Roduino.setSendData([Entry.Roborobo_Roduino.INSTRUCTION.COLOR, d, c, e]); + return a.callReturn(); }; Blockly.Blocks.schoolkit_on_block = {init:function() { this.setColour("#00979D"); @@ -5231,7 +5101,7 @@ Blockly.Blocks.schoolkit_on_block = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.schoolkit_on_block = function(a, b) { +Entry.block.schoolkit_on_block = function(b, a) { return "1"; }; Blockly.Blocks.schoolkit_off_block = {init:function() { @@ -5240,7 +5110,7 @@ Blockly.Blocks.schoolkit_off_block = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.schoolkit_off_block = function(a, b) { +Entry.block.schoolkit_off_block = function(b, a) { return "0"; }; Blockly.Blocks.schoolkit_get_out_port_number = {init:function() { @@ -5250,8 +5120,8 @@ Blockly.Blocks.schoolkit_get_out_port_number = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.schoolkit_get_out_port_number = function(a, b) { - return b.getNumberField("PORT"); +Entry.block.schoolkit_get_out_port_number = function(b, a) { + return a.getNumberField("PORT"); }; Blockly.Blocks.schoolkit_set_output = {init:function() { this.setColour("#00979D"); @@ -5263,11 +5133,10 @@ Blockly.Blocks.schoolkit_set_output = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.schoolkit_set_output = function(a, b) { - a = b.getNumberValue("VALUE"); - var d = b.getField("OPERATOR"); - Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.DIGITAL_WRITE, a, "on" == d ? 1 : 0]); - return b.callReturn(); +Entry.block.schoolkit_set_output = function(b, a) { + var d = a.getNumberValue("VALUE"), c = a.getField("OPERATOR"); + Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.DIGITAL_WRITE, d, "on" == c ? 1 : 0]); + return a.callReturn(); }; Blockly.Blocks.schoolkit_get_in_port_number = {init:function() { this.setColour("#00979D"); @@ -5276,8 +5145,8 @@ Blockly.Blocks.schoolkit_get_in_port_number = {init:function() { this.setOutput(!0, "Number"); this.setInputsInline(!0); }}; -Entry.block.schoolkit_get_in_port_number = function(a, b) { - return b.getNumberField("PORT"); +Entry.block.schoolkit_get_in_port_number = function(b, a) { + return a.getNumberField("PORT"); }; Blockly.Blocks.schoolkit_get_input_value = {init:function() { this.setColour("#00979D"); @@ -5287,10 +5156,10 @@ Blockly.Blocks.schoolkit_get_input_value = {init:function() { this.setInputsInline(!0); this.setOutput(!0, "Boolean"); }}; -Entry.block.schoolkit_get_input_value = function(a, b) { - a = b.getNumberValue("VALUE"); - Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.DIGITAL_READ, a]); - return Entry.hw.portData[a - 7]; +Entry.block.schoolkit_get_input_value = function(b, a) { + var d = a.getNumberValue("VALUE"); + Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.DIGITAL_READ, d]); + return Entry.hw.portData[d - 7]; }; Blockly.Blocks.schoolkit_motor = {init:function() { this.setColour("#00979D"); @@ -5301,15 +5170,11 @@ Blockly.Blocks.schoolkit_motor = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.schoolkit_motor = function(a, b) { - var d; - d = b.getField("MODE"); - a = b.getField("OPERATOR"); - var c = b.getNumberValue("VALUE"); - d = "motor1" == d ? 7 : 8; - 255 < c ? c = 255 : 0 > c && (c = 0); - "cw" == a ? Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.MOTOR, 1, d, c]) : "ccw" == a ? Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.MOTOR, 2, d, c]) : "stop" == a && Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.MOTOR, 0, d, c]); - return b.callReturn(); +Entry.block.schoolkit_motor = function(b, a) { + var d = 0, d = a.getField("MODE"), c = a.getField("OPERATOR"), e = a.getNumberValue("VALUE"), d = "motor1" == d ? 7 : 8; + 255 < e ? e = 255 : 0 > e && (e = 0); + "cw" == c ? Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.MOTOR, 1, d, e]) : "ccw" == c ? Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.MOTOR, 2, d, e]) : "stop" == c && Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.MOTOR, 0, d, e]); + return a.callReturn(); }; Blockly.Blocks.schoolkit_set_servo_value = {init:function() { this.setColour("#00979D"); @@ -5324,12 +5189,11 @@ Blockly.Blocks.schoolkit_set_servo_value = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.schoolkit_set_servo_value = function(a, b) { - a = b.getNumberValue("PIN"); - var d = b.getNumberValue("VALUE"); - 0 > d ? d = 0 : 180 < d && (d = 180); - Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.SERVO, a, d]); - return b.callReturn(); +Entry.block.schoolkit_set_servo_value = function(b, a) { + var d = a.getNumberValue("PIN"), c = a.getNumberValue("VALUE"); + 0 > c ? c = 0 : 180 < c && (c = 180); + Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.SERVO, d, c]); + return a.callReturn(); }; 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() { Entry.hw.sendQueue.setZero = [1]; @@ -5339,47 +5203,47 @@ Entry.Robotis_carCont = {INSTRUCTION:{NONE:0, WRITE:3, READ:2}, CONTROL_TABLE:{C this.update(); this.setRobotisData([[Entry.Robotis_carCont.INSTRUCTION.WRITE, 152, 2, 0], [Entry.Robotis_carCont.INSTRUCTION.WRITE, 154, 2, 0]]); this.update(); -}, name:"robotis_carCont", delay:40, postCallReturn:function(a, b, d) { +}, name:"robotis_carCont", delay:40, postCallReturn:function(b, a, d) { if (0 >= d) { - 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; }, d); - return a; -}, wait:function(a, b) { - Entry.hw.socket.send(JSON.stringify(a)); - for (var d = a = (new Date).getTime();d < a + b;) { - d = (new Date).getTime(); + return b; +}, wait:function(b, a) { + Entry.hw.socket.send(JSON.stringify(b)); + for (var d = (new Date).getTime(), c = d;c < d + a;) { + c = (new Date).getTime(); } }, update:function() { Entry.hw.update(); - var a = Entry.hw.sendQueue.ROBOTIS_DATA; - a && a.forEach(function(b) { - b.send = !0; + var b = Entry.hw.sendQueue.ROBOTIS_DATA; + b && b.forEach(function(a) { + a.send = !0; }); this.setRobotisData(null); }, filterSendData:function() { - var a = Entry.hw.sendQueue.ROBOTIS_DATA; - return a ? a.filter(function(b) { - return !0 !== b.send; + var b = Entry.hw.sendQueue.ROBOTIS_DATA; + return b ? b.filter(function(a) { + return !0 !== a.send; }) : null; -}, setRobotisData:function(a) { - var b = this.filterSendData(); - Entry.hw.sendQueue.ROBOTIS_DATA = null == a ? b : b ? b.concat(a) : a; +}, setRobotisData:function(b) { + var a = this.filterSendData(); + Entry.hw.sendQueue.ROBOTIS_DATA = null == b ? a : a ? a.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() { @@ -5403,14 +5267,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 d = 0, c = b.getStringField("SIZE"); - "BYTE" == c ? d = 1 : "WORD" == c ? d = 2 : "DWORD" == c && (d = 4); - b = b.getNumberValue("VALUE"); - Entry.Robotis_carCont.setRobotisData([[a, b, d, 0, d]]); +Entry.block.robotis_openCM70_cm_custom_value = function(b, a) { + var d = Entry.Robotis_openCM70.INSTRUCTION.READ, c = 0, e = 0, f = 0, c = a.getStringField("SIZE"); + "BYTE" == c ? e = 1 : "WORD" == c ? e = 2 : "DWORD" == c && (e = 4); + f = c = a.getNumberValue("VALUE"); + Entry.Robotis_carCont.setRobotisData([[d, c, 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"); @@ -5420,22 +5283,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 d = 0, c = 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], d = Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTED[0], c = 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], d = Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTING[0], - c = 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], d = Entry.Robotis_openCM70.CONTROL_TABLE.CM_USER_BUTTON[0], c = Entry.Robotis_openCM70.CONTROL_TABLE.CM_USER_BUTTON[1]); - e += 0 * f; - Entry.Robotis_carCont.setRobotisData([[a, d, c, 0, f]]); +Entry.block.robotis_openCM70_sensor_value = function(b, a) { + var d = Entry.Robotis_openCM70.INSTRUCTION.READ, c = 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], c = 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], c = 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], c = 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([[d, c, 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"); @@ -5447,46 +5308,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 d = 0, c = 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], d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_SERVO_POSITION[0], c = 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], d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_IR[0], c = 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], d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_TOUCH[0], c = 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], d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_TEMPERATURE[0], c = 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], d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_BRIGHTNESS[0], c = 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], d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_HYDRO_THEMO_HUMIDITY[0], - c = 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], d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_HYDRO_THEMO_TEMPER[0], c = 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], - d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_ULTRASONIC[0], c = 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], d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_MAGNETIC[0], c = 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], - d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_MOTION_DETECTION[0], c = 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], d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_COLOR[0], c = 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], - d = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_CUSTOM[0], c = Entry.Robotis_openCM70.CONTROL_TABLE.AUX_CUSTOM[1]); - e += h * f; - 0 != h && (c = 6 * f); - Entry.Robotis_carCont.setRobotisData([[a, d, c, 0, f]]); +Entry.block.robotis_openCM70_aux_sensor_value = function(b, a) { + var d = Entry.Robotis_openCM70.INSTRUCTION.READ, c = 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], c = 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], c = 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], c = 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], c = 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], c = 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], c = 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], c = 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], + c = 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], c = 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], + c = 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], c = 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], + c = 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([[d, c, 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"); @@ -5503,14 +5361,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 d = b.getNumberValue("CM_BUZZER_TIME", b), c = 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 * d); - 50 < g && (g = 50); - return Entry.Robotis_carCont.postCallReturn(b, [[c, e, f, g], [c, Entry.Robotis_openCM70.CONTROL_TABLE.CM_BUZZER_INDEX[0], Entry.Robotis_openCM70.CONTROL_TABLE.CM_BUZZER_INDEX[1], a]], 1E3 * d); +Entry.block.robotis_openCM70_cm_buzzer_index = function(b, a) { + var d = a.getField("CM_BUZZER_INDEX", a), c = 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 * c); + 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, d]], 1E3 * c); }; Blockly.Blocks.robotis_openCM70_cm_buzzer_melody = {init:function() { this.setColour("#00979D"); @@ -5523,10 +5379,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 d = Entry.Robotis_openCM70.INSTRUCTION.WRITE; - return Entry.Robotis_carCont.postCallReturn(b, [[d, Entry.Robotis_openCM70.CONTROL_TABLE.CM_BUZZER_TIME[0], Entry.Robotis_openCM70.CONTROL_TABLE.CM_BUZZER_TIME[1], 255], [d, 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 d = a.getField("CM_BUZZER_MELODY", a), c = 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, [[c, e, f, 255], [c, g, h, d]], 1E3); }; Blockly.Blocks.robotis_openCM70_cm_sound_detected_clear = {init:function() { this.setColour("#00979D"); @@ -5535,8 +5390,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 d = Entry.Robotis_openCM70.INSTRUCTION.WRITE, c = 0, e = 0, c = 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, [[d, c, e, 0]], Entry.Robotis_openCM70.delay); }; Blockly.Blocks.robotis_openCM70_cm_led = {init:function() { this.setColour("#00979D"); @@ -5546,11 +5402,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 d = b.getField("VALUE", b), c = 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, [[c, e, f, d]], Entry.Robotis_openCM70.delay); +Entry.block.robotis_openCM70_cm_led = function(b, a) { + var d = a.getField("CM_LED", a), c = a.getField("VALUE", a), e = Entry.Robotis_openCM70.INSTRUCTION.WRITE, f = 0, g = 0; + "CM_LED_R" == d ? (f = Entry.Robotis_openCM70.CONTROL_TABLE.CM_LED_R[0], g = Entry.Robotis_openCM70.CONTROL_TABLE.CM_LED_R[1]) : "CM_LED_G" == d ? (f = Entry.Robotis_openCM70.CONTROL_TABLE.CM_LED_G[0], g = Entry.Robotis_openCM70.CONTROL_TABLE.CM_LED_G[1]) : "CM_LED_B" == d && (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, c]], Entry.Robotis_openCM70.delay); }; Blockly.Blocks.robotis_openCM70_cm_motion = {init:function() { this.setColour("#00979D"); @@ -5562,13 +5417,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 d, c, e; - d = Entry.Robotis_openCM70.CONTROL_TABLE.CM_MOTION[0]; - c = Entry.Robotis_openCM70.CONTROL_TABLE.CM_MOTION[1]; - e = b.getNumberValue("VALUE", b); - return Entry.Robotis_carCont.postCallReturn(b, [[a, d, c, e]], Entry.Robotis_openCM70.delay); +Entry.block.robotis_openCM70_cm_motion = function(b, a) { + var d = Entry.Robotis_openCM70.INSTRUCTION.WRITE, c = 0, e = 0, f = 0, c = 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, [[d, c, e, f]], Entry.Robotis_openCM70.delay); }; Blockly.Blocks.robotis_openCM70_aux_motor_speed = {init:function() { this.setColour("#00979D"); @@ -5579,13 +5430,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 d = b.getField("DIRECTION_ANGLE", b), c = 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" == d ? (c += 1024, 2047 < c && (c = 2047)) : 1023 < c && (c = 1023); - return Entry.Robotis_carCont.postCallReturn(b, [[e, f + (a - 1) * g, g, c]], Entry.Robotis_openCM70.delay); +Entry.block.robotis_openCM70_aux_motor_speed = function(b, a) { + var d = a.getField("PORT", a), c = 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" == c ? (e += 1024, 2047 < e && (e = 2047)) : 1023 < e && (e = 1023); + return Entry.Robotis_carCont.postCallReturn(a, [[f, g + (d - 1) * h, h, e]], Entry.Robotis_openCM70.delay); }; Blockly.Blocks.robotis_openCM70_aux_servo_mode = {init:function() { this.setColour("#00979D"); @@ -5595,12 +5443,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 d = b.getField("MODE", b), c = 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, [[c, e + (a - 1) * f, f, d]], Entry.Robotis_openCM70.delay); +Entry.block.robotis_openCM70_aux_servo_mode = function(b, a) { + var d = a.getField("PORT", a), c = 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 + (d - 1) * g, g, c]], Entry.Robotis_openCM70.delay); }; Blockly.Blocks.robotis_openCM70_aux_servo_speed = {init:function() { this.setColour("#00979D"); @@ -5611,13 +5456,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 d = b.getField("DIRECTION_ANGLE", b), c = 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" == d ? (c += 1024, 2047 < c && (c = 2047)) : 1023 < c && (c = 1023); - return Entry.Robotis_carCont.postCallReturn(b, [[e, f + (a - 1) * g, g, c]], Entry.Robotis_openCM70.delay); +Entry.block.robotis_openCM70_aux_servo_speed = function(b, a) { + var d = a.getField("PORT", a), c = 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" == c ? (e += 1024, 2047 < e && (e = 2047)) : 1023 < e && (e = 1023); + return Entry.Robotis_carCont.postCallReturn(a, [[f, g + (d - 1) * h, h, e]], Entry.Robotis_openCM70.delay); }; Blockly.Blocks.robotis_openCM70_aux_servo_position = {init:function() { this.setColour("#00979D"); @@ -5628,13 +5470,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 d = b.getNumberValue("VALUE"), c = 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 < d ? d = 1023 : 0 > d && (d = 0); - return Entry.Robotis_carCont.postCallReturn(b, [[c, e + (a - 1) * f, f, d]], Entry.Robotis_openCM70.delay); +Entry.block.robotis_openCM70_aux_servo_position = function(b, a) { + var d = a.getField("PORT", a), c = 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 < c ? c = 1023 : 0 > c && (c = 0); + return Entry.Robotis_carCont.postCallReturn(a, [[e, f + (d - 1) * g, g, c]], Entry.Robotis_openCM70.delay); }; Blockly.Blocks.robotis_openCM70_aux_led_module = {init:function() { this.setColour("#00979D"); @@ -5645,12 +5484,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 d = b.getField("LED_MODULE", b), c = 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, [[c, e + (a - 1) * f, f, d]], Entry.Robotis_openCM70.delay); +Entry.block.robotis_openCM70_aux_led_module = function(b, a) { + var d = a.getField("PORT", a), c = 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 + (d - 1) * g, g, c]], Entry.Robotis_openCM70.delay); }; Blockly.Blocks.robotis_openCM70_aux_custom = {init:function() { this.setColour("#00979D"); @@ -5661,12 +5497,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 d = b.getNumberValue("VALUE"), c = 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, [[c, e + (a - 1) * f, f, d]], Entry.Robotis_openCM70.delay); +Entry.block.robotis_openCM70_aux_custom = function(b, a) { + var d = a.getField("PORT", a), c = 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 + (d - 1) * g, g, c]], Entry.Robotis_openCM70.delay); }; Blockly.Blocks.robotis_openCM70_cm_custom = {init:function() { this.setColour("#00979D"); @@ -5681,12 +5514,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 d, c; - d = b.getNumberValue("ADDRESS"); - c = b.getNumberValue("VALUE"); - return Entry.Robotis_carCont.postCallReturn(b, [[a, d, 65535 < c ? 4 : 255 < c ? 2 : 1, c]], Entry.Robotis_openCM70.delay); +Entry.block.robotis_openCM70_cm_custom = function(b, a) { + var d = Entry.Robotis_openCM70.INSTRUCTION.WRITE, c = 0, e = 0, c = a.getNumberValue("ADDRESS"), e = a.getNumberValue("VALUE"); + return Entry.Robotis_carCont.postCallReturn(a, [[d, c, 65535 < e ? 4 : 255 < e ? 2 : 1, e]], Entry.Robotis_openCM70.delay); }; Blockly.Blocks.robotis_carCont_sensor_value = {init:function() { this.setColour("#00979D"); @@ -5695,19 +5525,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 d = 0, c = 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], d = Entry.Robotis_carCont.CONTROL_TABLE.CM_SPRING_LEFT[2], c = 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], d = Entry.Robotis_carCont.CONTROL_TABLE.CM_SPRING_RIGHT[2], c = 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], d = Entry.Robotis_carCont.CONTROL_TABLE.CM_SWITCH[0], c = 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], d = Entry.Robotis_carCont.CONTROL_TABLE.CM_SOUND_DETECTED[0], c = 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], d = Entry.Robotis_carCont.CONTROL_TABLE.CM_SOUND_DETECTING[0], c = 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], d = Entry.Robotis_carCont.CONTROL_TABLE.CM_IR_LEFT[2], c = 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], d = Entry.Robotis_carCont.CONTROL_TABLE.CM_IR_RIGHT[2], c = 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], d = Entry.Robotis_carCont.CONTROL_TABLE.CM_CALIBRATION_LEFT[0], c = 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], d = Entry.Robotis_carCont.CONTROL_TABLE.CM_CALIBRATION_RIGHT[0], c = 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], d = Entry.Robotis_carCont.CONTROL_TABLE.CM_BUTTON_STATUS[0], - c = Entry.Robotis_carCont.CONTROL_TABLE.CM_BUTTON_STATUS[1]); - Entry.Robotis_carCont.setRobotisData([[a, d, c, 0, f]]); +Entry.block.robotis_carCont_sensor_value = function(b, a) { + var d = Entry.Robotis_carCont.INSTRUCTION.READ, c = 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], c = 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], c = 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], c = 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], c = 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], c = 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], c = 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], c = 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], c = 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], c = 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], c = Entry.Robotis_carCont.CONTROL_TABLE.CM_BUTTON_STATUS[0], + e = Entry.Robotis_carCont.CONTROL_TABLE.CM_BUTTON_STATUS[1]); + Entry.Robotis_carCont.setRobotisData([[d, c, 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"); @@ -5716,14 +5544,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 d = b.getField("VALUE_RIGHT", b), c = 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 == d ? g = 9 : 1 == a && 0 == d && (g = 8); - 0 == a && 1 == d && (g = 1); - return Entry.Robotis_carCont.postCallReturn(b, [[c, e, f, g]], Entry.Robotis_carCont.delay); +Entry.block.robotis_carCont_cm_led = function(b, a) { + var d = a.getField("VALUE_LEFT", a), c = 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 == d && 1 == c ? h = 9 : 1 == d && 0 == c && (h = 8); + 0 == d && 1 == c && (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"); @@ -5732,8 +5557,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 d = Entry.Robotis_carCont.INSTRUCTION.WRITE, c = 0, e = 0, c = 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, [[d, c, e, 0]], Entry.Robotis_carCont.delay); }; Blockly.Blocks.robotis_carCont_aux_motor_speed = {init:function() { this.setColour("#00979D"); @@ -5744,13 +5570,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 d = b.getField("DIRECTION", b); - a = b.getField("DIRECTION_ANGLE", b); - var c = b.getNumberValue("VALUE"), e = Entry.Robotis_carCont.INSTRUCTION.WRITE, f; - "LEFT" == d ? (d = Entry.Robotis_carCont.CONTROL_TABLE.AUX_MOTOR_SPEED_LEFT[0], f = Entry.Robotis_carCont.CONTROL_TABLE.AUX_MOTOR_SPEED_LEFT[1]) : (d = Entry.Robotis_carCont.CONTROL_TABLE.AUX_MOTOR_SPEED_RIGHT[0], f = Entry.Robotis_carCont.CONTROL_TABLE.AUX_MOTOR_SPEED_RIGHT[1]); - "CW" == a ? (c += 1024, 2047 < c && (c = 2047)) : 1023 < c && (c = 1023); - return Entry.Robotis_carCont.postCallReturn(b, [[e, d, f, c]], Entry.Robotis_carCont.delay); +Entry.block.robotis_carCont_aux_motor_speed = function(b, a) { + var d = a.getField("DIRECTION", a), c = a.getField("DIRECTION_ANGLE", a), e = a.getNumberValue("VALUE"), f = Entry.Robotis_carCont.INSTRUCTION.WRITE, g = 0, h = 0; + "LEFT" == d ? (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" == c ? (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"); @@ -5761,12 +5585,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 d = b.getField("DIRECTION", b); - a = b.getNumberValue("VALUE"); - var c = Entry.Robotis_carCont.INSTRUCTION.WRITE, e; - "LEFT" == d ? (d = Entry.Robotis_carCont.CONTROL_TABLE.CM_CALIBRATION_LEFT[0], e = Entry.Robotis_carCont.CONTROL_TABLE.CM_CALIBRATION_LEFT[1]) : (d = 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, [[c, d, e, a]], Entry.Robotis_carCont.delay); +Entry.block.robotis_carCont_cm_calibration = function(b, a) { + var d = a.getField("DIRECTION", a), c = a.getNumberValue("VALUE"), e = Entry.Robotis_carCont.INSTRUCTION.WRITE, f = 0, g = 0; + "LEFT" == d ? (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, c]], Entry.Robotis_carCont.delay); }; Blockly.Blocks.when_scene_start = {init:function() { this.setColour("#3BBD70"); @@ -5774,8 +5596,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"); @@ -5784,10 +5606,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 d = a.getField("VALUE", a); + if (d = Entry.scene.getSceneById(d)) { + Entry.scene.selectScene(d), Entry.engine.fireEvent("when_scene_start"); } return null; }; @@ -5798,11 +5620,9 @@ Blockly.Blocks.start_neighbor_scene = {init:function() { this.setInputsInline(!0); this.setPreviousStatement(!0); }}; -Entry.block.start_neighbor_scene = function(a, b) { - var d = Entry.scene.selectedScene; - a = Entry.scene.getScenes(); - d = a.indexOf(d); - "next" == b.getField("OPERATOR", b) ? d + 1 < a.length && (b = Entry.scene.getSceneById(a[d + 1].id)) && (Entry.scene.selectScene(b), Entry.engine.fireEvent("when_scene_start")) : 0 < d && (b = Entry.scene.getSceneById(a[d - 1].id)) && (Entry.scene.selectScene(b), Entry.engine.fireEvent("when_scene_start")); +Entry.block.start_neighbor_scene = function(b, a) { + var d = Entry.scene.selectedScene, c = Entry.scene.getScenes(), d = c.indexOf(d); + "next" == a.getField("OPERATOR", a) ? d + 1 < c.length && (c = Entry.scene.getSceneById(c[d + 1].id)) && (Entry.scene.selectScene(c), Entry.engine.fireEvent("when_scene_start")) : 0 < d && (c = Entry.scene.getSceneById(c[d - 1].id)) && (Entry.scene.selectScene(c), Entry.engine.fireEvent("when_scene_start")); return null; }; Blockly.Blocks.sound_something = {init:function() { @@ -5814,10 +5634,10 @@ Blockly.Blocks.sound_something = {init:function() { this.setNextStatement(!0); this.setPreviousStatement(!0); }}; -Entry.block.sound_something = function(a, b) { - var d = b.getField("VALUE", b); - Entry.isExist(d, "id", a.parent.sounds) && createjs.Sound.play(d); - return b.callReturn(); +Entry.block.sound_something = function(b, a) { + var d = a.getField("VALUE", a); + Entry.isExist(d, "id", b.parent.sounds) && createjs.Sound.play(d); + return a.callReturn(); }; Blockly.Blocks.sound_something_second = {init:function() { this.setColour("#A4D01D"); @@ -5830,15 +5650,15 @@ Blockly.Blocks.sound_something_second = {init:function() { this.setNextStatement(!0); this.setPreviousStatement(!0); }}; -Entry.block.sound_something_second = function(a, b) { - var d = b.getField("VALUE", b), c = b.getNumberValue("SECOND", b); - if (Entry.isExist(d, "id", a.parent.sounds)) { +Entry.block.sound_something_second = function(b, a) { + var d = a.getField("VALUE", a), c = a.getNumberValue("SECOND", a); + if (Entry.isExist(d, "id", b.parent.sounds)) { var e = createjs.Sound.play(d); setTimeout(function() { e.stop(); }, 1E3 * c); } - return b.callReturn(); + return a.callReturn(); }; Blockly.Blocks.sound_something_wait = {init:function() { this.setColour("#A4D01D"); @@ -5849,22 +5669,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 d = b.getField("VALUE", b), c = a.parent.getSound(d); - Entry.isExist(d, "id", a.parent.sounds) && (createjs.Sound.play(d), setTimeout(function() { - b.playState = 0; + a.isPlay = !0; + a.playState = 1; + var d = a.getField("VALUE", a), c = b.parent.getSound(d); + Entry.isExist(d, "id", b.parent.sounds) && (createjs.Sound.play(d), setTimeout(function() { + a.playState = 0; }, 1E3 * c.duration)); - return b; + return a; }; Blockly.Blocks.sound_something_second_wait = {init:function() { this.setColour("#A4D01D"); @@ -5877,29 +5697,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 d = b.getField("VALUE", b); - if (Entry.isExist(d, "id", a.parent.sounds)) { - var c = createjs.Sound.play(d); - a = b.getNumberValue("SECOND", b); + a.isPlay = !0; + a.playState = 1; + var d = a.getField("VALUE", a); + if (Entry.isExist(d, "id", b.parent.sounds)) { + var c = createjs.Sound.play(d), d = a.getNumberValue("SECOND", a); setTimeout(function() { c.stop(); - b.playState = 0; - }, 1E3 * a); - c.addEventListener("complete", function(b) { + a.playState = 0; + }, 1E3 * d); + c.addEventListener("complete", function(a) { }); } - return b; + return a; }; Blockly.Blocks.sound_volume_change = {init:function() { this.setColour("#A4D01D"); @@ -5910,13 +5729,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 d = a.getNumberValue("VALUE", a) / 100, d = d + createjs.Sound.getVolume(); + 1 < d && (d = 1); + 0 > d && (d = 0); + createjs.Sound.setVolume(d); + return a.callReturn(); }; Blockly.Blocks.sound_volume_set = {init:function() { this.setColour("#A4D01D"); @@ -5927,12 +5745,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 d = a.getNumberValue("VALUE", a) / 100; + 1 < d && (d = 1); + 0 > d && (d = 0); + createjs.Sound.setVolume(d); + return a.callReturn(); }; Blockly.Blocks.sound_silent_all = {init:function() { this.setColour("#A4D01D"); @@ -5941,9 +5759,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"); @@ -5953,8 +5771,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"); @@ -5965,10 +5783,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 d = b.getStringValue("VALUE", b); - (a = a.parent.getSound(d)) && createjs.Sound.play(a.id); - return b.callReturn(); +Entry.block.sound_something_with_block = function(b, a) { + var d = a.getStringValue("VALUE", a); + (d = b.parent.getSound(d)) && createjs.Sound.play(d.id); + return a.callReturn(); }; Blockly.Blocks.sound_something_second_with_block = {init:function() { this.setColour("#A4D01D"); @@ -5981,10 +5799,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 d = b.getStringValue("VALUE", b), c = b.getNumberValue("SECOND", b); - (a = a.parent.getSound(d)) && createjs.Sound.play(a.id, {startTime:0, duration:1E3 * c}); - return b.callReturn(); +Entry.block.sound_something_second_with_block = function(b, a) { + var d = a.getStringValue("VALUE", a), c = a.getNumberValue("SECOND", a); + (d = b.parent.getSound(d)) && createjs.Sound.play(d.id, {startTime:0, duration:1E3 * c}); + return a.callReturn(); }; Blockly.Blocks.sound_something_wait_with_block = {init:function() { this.setColour("#A4D01D"); @@ -5995,24 +5813,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 d = b.getStringValue("VALUE", b); - if (a = a.parent.getSound(d)) { - createjs.Sound.play(a.id), setTimeout(function() { - b.playState = 0; - }, 1E3 * a.duration); + a.isPlay = !0; + a.playState = 1; + var d = a.getStringValue("VALUE", a); + if (d = b.parent.getSound(d)) { + createjs.Sound.play(d.id), setTimeout(function() { + a.playState = 0; + }, 1E3 * d.duration); } - return b; + return a; }; Blockly.Blocks.sound_something_second_wait_with_block = {init:function() { this.setColour("#A4D01D"); @@ -6025,29 +5843,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 d = b.getStringValue("VALUE", b); - if (a = a.parent.getSound(d)) { - var c = createjs.Sound.play(a.id); - a = b.getNumberValue("SECOND", b); + a.isPlay = !0; + a.playState = 1; + var d = a.getStringValue("VALUE", a); + if (d = b.parent.getSound(d)) { + var c = createjs.Sound.play(d.id), d = a.getNumberValue("SECOND", a); setTimeout(function() { c.stop(); - b.playState = 0; - }, 1E3 * a); - c.addEventListener("complete", function(b) { + a.playState = 0; + }, 1E3 * d); + c.addEventListener("complete", function(a) { }); } - return b; + return a; }; Blockly.Blocks.sound_from_to = {init:function() { this.setColour("#A4D01D"); @@ -6062,13 +5879,13 @@ Blockly.Blocks.sound_from_to = {init:function() { this.setNextStatement(!0); this.setPreviousStatement(!0); }}; -Entry.block.sound_from_to = function(a, b) { - var d = b.getStringValue("VALUE", b); - if (a = a.parent.getSound(d)) { - var d = 1E3 * b.getNumberValue("START", b), c = 1E3 * b.getNumberValue("END", b); - createjs.Sound.play(a.id, {startTime:Math.min(d, c), duration:Math.max(d, c) - Math.min(d, c)}); +Entry.block.sound_from_to = function(b, a) { + var d = a.getStringValue("VALUE", a); + if (d = b.parent.getSound(d)) { + var c = 1E3 * a.getNumberValue("START", a), e = 1E3 * a.getNumberValue("END", a); + createjs.Sound.play(d.id, {startTime:Math.min(c, e), duration:Math.max(c, e) - Math.min(c, e)}); } - return b.callReturn(); + return a.callReturn(); }; Blockly.Blocks.sound_from_to_and_wait = {init:function() { this.setColour("#A4D01D"); @@ -6083,26 +5900,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 d = b.getStringValue("VALUE", b); - if (a = a.parent.getSound(d)) { - var c = 1E3 * b.getNumberValue("START", b), e = 1E3 * b.getNumberValue("END", b), d = Math.min(c, e), c = Math.max(c, e) - d; - createjs.Sound.play(a.id, {startTime:d, duration:c}); + a.isPlay = !0; + a.playState = 1; + var d = a.getStringValue("VALUE", a); + if (d = b.parent.getSound(d)) { + var c = 1E3 * a.getNumberValue("START", a), e = 1E3 * a.getNumberValue("END", a), f = Math.min(c, e), c = Math.max(c, e) - f; + createjs.Sound.play(d.id, {startTime:f, duration:c}); setTimeout(function() { - b.playState = 0; + a.playState = 0; }, c); } - return b; + return a; }; Blockly.Blocks.when_run_button_click = {init:function() { this.setColour("#3BBD70"); @@ -6110,8 +5927,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"); @@ -6120,8 +5937,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"); @@ -6129,8 +5946,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"); @@ -6138,8 +5955,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"); @@ -6147,8 +5964,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"); @@ -6156,8 +5973,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"); @@ -6165,8 +5982,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"); @@ -6174,23 +5991,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"); @@ -6199,21 +6016,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 d = Entry.isExist(a, "id", Entry.variableContainer.messages_); - if ("null" == a || !d) { +}, 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 d = a.getField("VALUE", a), c = Entry.isExist(d, "id", Entry.variableContainer.messages_); + if ("null" == d || !c) { 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", d]); + return a.callReturn(); }; Blockly.Blocks.message_cast_wait = {init:function() { this.setColour("#3BBD70"); @@ -6221,33 +6037,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 d = a.length, c = 0;c < d;c++) { - 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 d = a.runningScript, c = d.length, e = 0;e < c;e++) { + var f = d.shift(); + f && !f.isEnd() && d.push(f); + } + return d.length ? a : a.callReturn(); + } + d = a.getField("VALUE", a); + f = Entry.isExist(d, "id", Entry.variableContainer.messages_); + if ("null" == d || !f) { throw Error("value can not be null or undefined"); } - d = Entry.container.mapEntityIncludeCloneOnScene(Entry.engine.raiseKeyEvent, ["when_message_cast", a]); - for (a = [];d.length;) { - (e = d.shift()) && (a = a.concat(e)); + c = Entry.container.mapEntityIncludeCloneOnScene(Entry.engine.raiseKeyEvent, ["when_message_cast", d]); + for (d = [];c.length;) { + (f = c.shift()) && (d = d.concat(f)); } - b.runningScript = a; - return b; + a.runningScript = d; + return a; }; var colour = "#FFCA36"; Blockly.Blocks.text = {init:function() { @@ -6256,8 +6071,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); @@ -6268,10 +6083,10 @@ Blockly.Blocks.text_write = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.text_write = function(a, b) { - var d = b.getStringValue("VALUE", b), d = Entry.convertToRoundedDecimals(d, 3); - a.setText(d); - return b.callReturn(); +Entry.block.text_write = function(b, a) { + var d = a.getStringValue("VALUE", a), d = Entry.convertToRoundedDecimals(d, 3); + b.setText(d); + return a.callReturn(); }; Blockly.Blocks.text_append = {init:function() { this.setColour(colour); @@ -6282,10 +6097,10 @@ Blockly.Blocks.text_append = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.text_append = function(a, b) { - var d = b.getStringValue("VALUE", b); - a.setText(Entry.convertToRoundedDecimals(a.getText(), 3) + Entry.convertToRoundedDecimals(d, 3)); - return b.callReturn(); +Entry.block.text_append = function(b, a) { + var d = a.getStringValue("VALUE", a); + b.setText(Entry.convertToRoundedDecimals(b.getText(), 3) + Entry.convertToRoundedDecimals(d, 3)); + return a.callReturn(); }; Blockly.Blocks.text_prepend = {init:function() { this.setColour(colour); @@ -6296,10 +6111,10 @@ Blockly.Blocks.text_prepend = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.text_prepend = function(a, b) { - var d = b.getStringValue("VALUE", b); - a.setText(Entry.convertToRoundedDecimals(d, 3) + Entry.convertToRoundedDecimals(a.getText(), 3)); - return b.callReturn(); +Entry.block.text_prepend = function(b, a) { + var d = a.getStringValue("VALUE", a); + b.setText(Entry.convertToRoundedDecimals(d, 3) + Entry.convertToRoundedDecimals(b.getText(), 3)); + return a.callReturn(); }; Blockly.Blocks.text_flush = {init:function() { this.setColour(colour); @@ -6308,9 +6123,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() { @@ -6330,22 +6145,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 d = b.getField("VARIABLE", b), c = b.getNumberValue("VALUE", b), c = Entry.parseNumber(c); +}, 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 d = a.getField("VARIABLE", a), c = a.getNumberValue("VALUE", a), e = 0, c = Entry.parseNumber(c); if (0 == c && "boolean" == typeof c) { throw Error("Type is not correct"); } - d = Entry.variableContainer.getVariable(d, a); - a = Entry.getMaxFloatPoint([c, d.getValue()]); - d.setValue((c + d.getValue()).toFixed(a)); - return b.callReturn(); + d = Entry.variableContainer.getVariable(d, b); + e = Entry.getMaxFloatPoint([c, d.getValue()]); + d.setValue((c + d.getValue()).toFixed(e)); + return a.callReturn(); }; Blockly.Blocks.set_variable = {init:function() { this.setColour("#E457DC"); @@ -6357,17 +6172,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 d = b.getField("VARIABLE", b), c = b.getValue("VALUE", b); - Entry.variableContainer.getVariable(d, a).setValue(c); - 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 d = a.getField("VARIABLE", a), c = a.getValue("VALUE", a); + Entry.variableContainer.getVariable(d, b).setValue(c); + return a.callReturn(); }; Blockly.Blocks.show_variable = {init:function() { this.setColour("#E457DC"); @@ -6376,19 +6191,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 d = b.getField("VARIABLE", b); - a = Entry.variableContainer.getVariable(d, 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 d = a.getField("VARIABLE", a), d = Entry.variableContainer.getVariable(d, b); + d.setVisible(!0); + d.updateView(); + return a.callReturn(); }; Blockly.Blocks.hide_variable = {init:function() { this.setColour("#E457DC"); @@ -6397,17 +6211,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 d = b.getField("VARIABLE", b); - Entry.variableContainer.getVariable(d, 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 d = a.getField("VARIABLE", a); + Entry.variableContainer.getVariable(d, b).setVisible(!1); + return a.callReturn(); }; Blockly.Blocks.get_y = {init:function() { this.setColour(230); @@ -6420,16 +6234,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 d = a.getField("VARIABLE", a); + return Entry.variableContainer.getVariable(d, b).getValue(); }; Blockly.Blocks.ask_and_wait = {init:function() { this.setColour("#E457DC"); @@ -6441,30 +6255,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 d = Entry.container.inputValue, c = Entry.stage.inputField, e = b.getValue("VALUE", b); +Entry.block.ask_and_wait = function(b, a) { + var d = Entry.container.inputValue, c = Entry.stage.inputField, e = a.getValue("VALUE", a); if (!e) { throw Error("message can not be empty"); } - if (d.sprite == a && c && !c._isHidden) { - return b; + if (d.sprite == b && c && !c._isHidden) { + return a; } - if (d.sprite != a && b.isInit) { - return a.dialog && a.dialog.remove(), delete b.isInit, b.callReturn(); + if (d.sprite != b && a.isInit) { + return b.dialog && b.dialog.remove(), delete a.isInit, a.callReturn(); } - if (d.complete && d.sprite == a && c._isHidden && b.isInit) { - return a.dialog && a.dialog.remove(), delete d.complete, delete b.isInit, b.callReturn(); + if (d.complete && d.sprite == b && c._isHidden && a.isInit) { + return b.dialog && b.dialog.remove(), delete d.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(); - d.script = b; - d.sprite = a; - b.isInit = !0; - return b; + d.script = a; + d.sprite = b; + a.isInit = !0; + return a; }; Blockly.Blocks.get_canvas_input_value = {init:function() { this.setColour("#E457DC"); @@ -6474,10 +6288,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() { @@ -6490,20 +6304,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 d = b.getField("LIST", b), c = b.getValue("VALUE", b); - a = Entry.variableContainer.getList(d, a); - a.array_ || (a.array_ = []); - a.array_.push({data:c}); - 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 d = a.getField("LIST", a), c = a.getValue("VALUE", a), d = Entry.variableContainer.getList(d, b); + d.array_ || (d.array_ = []); + d.array_.push({data:c}); + d.updateView(); + return a.callReturn(); }; Blockly.Blocks.remove_value_from_list = {init:function() { this.setColour("#E457DC"); @@ -6516,15 +6329,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 d = b.getField("LIST", b), c = b.getValue("VALUE", b); - a = Entry.variableContainer.getList(d, a); - if (!a.array_ || isNaN(c) || c > a.array_.length) { +Entry.block.remove_value_from_list = function(b, a) { + var d = a.getField("LIST", a), c = a.getValue("VALUE", a), d = Entry.variableContainer.getList(d, b); + if (!d.array_ || isNaN(c) || c > d.array_.length) { throw Error("can not remove value from array"); } - a.array_.splice(c - 1, 1); - a.updateView(); - return b.callReturn(); + d.array_.splice(c - 1, 1); + d.updateView(); + return a.callReturn(); }; Blockly.Blocks.insert_value_to_list = {init:function() { this.setColour("#E457DC"); @@ -6539,15 +6351,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 d = b.getField("LIST", b), c = b.getValue("DATA", b), e = b.getValue("INDEX", b); - a = Entry.variableContainer.getList(d, a); - if (!a.array_ || isNaN(e) || 0 == e || e > a.array_.length + 1) { +Entry.block.insert_value_to_list = function(b, a) { + var d = a.getField("LIST", a), c = a.getValue("DATA", a), e = a.getValue("INDEX", a), d = Entry.variableContainer.getList(d, b); + if (!d.array_ || isNaN(e) || 0 == e || e > d.array_.length + 1) { throw Error("can not insert value to array"); } - a.array_.splice(e - 1, 0, {data:c}); - a.updateView(); - return b.callReturn(); + d.array_.splice(e - 1, 0, {data:c}); + d.updateView(); + return a.callReturn(); }; Blockly.Blocks.change_value_list_index = {init:function() { this.setColour("#E457DC"); @@ -6562,15 +6373,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 d = b.getField("LIST", b), c = b.getValue("DATA", b), e = b.getValue("INDEX", b); - a = Entry.variableContainer.getList(d, a); - if (!a.array_ || isNaN(e) || e > a.array_.length) { +Entry.block.change_value_list_index = function(b, a) { + var d = a.getField("LIST", a), c = a.getValue("DATA", a), e = a.getValue("INDEX", a), d = Entry.variableContainer.getList(d, b); + if (!d.array_ || isNaN(e) || e > d.array_.length) { throw Error("can not insert value to array"); } - a.array_[e - 1].data = c; - a.updateView(); - return b.callReturn(); + d.array_[e - 1].data = c; + d.updateView(); + return a.callReturn(); }; Blockly.Blocks.value_of_index_from_list = {init:function() { this.setColour("#E457DC"); @@ -6582,15 +6392,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 d = b.getField("LIST", b); - b = b.getValue("INDEX", b); - a = Entry.variableContainer.getList(d, 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 d = a.getField("LIST", a), c = a.getValue("INDEX", a), d = Entry.variableContainer.getList(d, b), c = Entry.getListRealIndex(c, d); + if (!d.array_ || isNaN(c) || c > d.array_.length) { throw Error("can not insert value to array"); } - return a.array_[b - 1].data; + return d.array_[c - 1].data; }; Blockly.Blocks.length_of_list = {init:function() { this.setColour("#E457DC"); @@ -6600,9 +6407,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 d = a.getField("LIST", a); + return Entry.variableContainer.getList(d).array_.length; }; Blockly.Blocks.show_list = {init:function() { this.setColour("#E457DC"); @@ -6612,10 +6419,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 d = a.getField("LIST", a); + Entry.variableContainer.getList(d).setVisible(!0); + return a.callReturn(); }; Blockly.Blocks.hide_list = {init:function() { this.setColour("#E457DC"); @@ -6625,10 +6432,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 d = a.getField("LIST", a); + Entry.variableContainer.getList(d).setVisible(!1); + return a.callReturn(); }; Blockly.Blocks.options_for_list = {init:function() { this.setColour("#E457DC"); @@ -6638,8 +6445,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"); @@ -6651,12 +6458,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"); @@ -6668,37 +6475,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 d = a.getField("LIST", a), c = a.getStringValue("DATA", a), d = Entry.variableContainer.getList(d); + if (!d) { return !1; } - a = a.array_; - for (var d = 0, c = a.length;d < c;d++) { - if (a[d].data.toString() == b.toString()) { + for (var d = d.array_, e = 0, f = d.length;e < f;e++) { + if (d[e].data.toString() == c.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, d; - for (d in a) { - b[d] = a[d]; + var b = Entry.Xbot.PORT_MAP, a = Entry.hw.sendQueue, d; + for (d in b) { + a[d] = b[d]; } 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"}; @@ -6708,10 +6512,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 d = Entry.hw.portData, c = a.getField("DEVICE"); + return d[c]; }; Blockly.Blocks.xbot_analogValue = {init:function() { this.setColour("#00979D"); @@ -6719,10 +6522,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 d = Entry.hw.portData, c = a.getField("DEVICE"); + return d[c]; }; Blockly.Blocks.xbot_digitalOutput = {init:function() { this.setColour("#00979D"); @@ -6732,14 +6534,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 d = b.getStringField("DEVICE", b), c = b.getStringField("VALUE", b); - a.D13 = "D13" == d && "HIGH" == c ? 1 : 0; - a.D4 = "D4" == d && "HIGH" == c ? 1 : 0; - a.D7 = "D7" == d && "HIGH" == c ? 1 : 0; - a.D12 = "D12" == d && "HIGH" == c ? 1 : 0; - return b.callReturn(); +Entry.block.xbot_digitalOutput = function(b, a) { + var d = Entry.hw.sendQueue, c = a.getStringField("DEVICE", a), e = a.getStringField("VALUE", a); + d.D13 = "D13" == c && "HIGH" == e ? 1 : 0; + d.D4 = "D4" == c && "HIGH" == e ? 1 : 0; + d.D7 = "D7" == c && "HIGH" == e ? 1 : 0; + d.D12 = "D12" == c && "HIGH" == e ? 1 : 0; + return a.callReturn(); }; Blockly.Blocks.xbot_analogOutput = {init:function() { this.setColour("#00979D"); @@ -6750,11 +6551,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 d = b.getStringField("DEVICE", b), c = b.getNumberValue("VALUE", b); - "analogD5" == d ? a.analogD5 = c : "analogD6" == d && (a.analogD6 = c); - return b.callReturn(); +Entry.block.xbot_analogOutput = function(b, a) { + var d = Entry.hw.sendQueue, c = a.getStringField("DEVICE", a), e = a.getNumberValue("VALUE", a); + "analogD5" == c ? d.analogD5 = e : "analogD6" == c && (d.analogD6 = e); + return a.callReturn(); }; Blockly.Blocks.xbot_servo = {init:function() { this.setColour("#00979D"); @@ -6765,11 +6565,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 d = b.getStringField("DEVICE", b), c = b.getNumberValue("VALUE", b); - "head" == d ? a.head = c : "right" == d ? a.armR = c : "left" == d && (a.armL = c); - return b.callReturn(); +Entry.block.xbot_servo = function(b, a) { + var d = Entry.hw.sendQueue, c = a.getStringField("DEVICE", a), e = a.getNumberValue("VALUE", a); + "head" == c ? d.head = e : "right" == c ? d.armR = e : "left" == c && (d.armL = e); + return a.callReturn(); }; Blockly.Blocks.xbot_oneWheel = {init:function() { this.setColour("#00979D"); @@ -6780,11 +6579,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 d = b.getStringField("DEVICE", b), c = b.getNumberValue("VALUE", b); - "rightWheel" == d ? a.rightWheel = c : "leftWheel" == d ? a.leftWheel = c : a.rightWheel = a.leftWheel = c; - return b.callReturn(); +Entry.block.xbot_oneWheel = function(b, a) { + var d = Entry.hw.sendQueue, c = a.getStringField("DEVICE", a), e = a.getNumberValue("VALUE", a); + "rightWheel" == c ? d.rightWheel = e : "leftWheel" == c ? d.leftWheel = e : d.rightWheel = d.leftWheel = e; + return a.callReturn(); }; Blockly.Blocks.xbot_twoWheel = {init:function() { this.setColour("#00979D"); @@ -6797,11 +6595,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 d = Entry.hw.sendQueue; + d.rightWheel = a.getNumberValue("rightWheel"); + d.leftWheel = a.getNumberValue("leftWheel"); + return a.callReturn(); }; Blockly.Blocks.xbot_rgb = {init:function() { this.setColour("#00979D"); @@ -6816,12 +6614,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 d = Entry.hw.sendQueue; + d.ledR = a.getNumberValue("ledR"); + d.ledG = a.getNumberValue("ledG"); + d.ledB = a.getNumberValue("ledB"); + return a.callReturn(); }; Blockly.Blocks.xbot_rgb_picker = {init:function() { this.setColour("#00979D"); @@ -6830,13 +6628,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 d = Entry.hw.sendQueue; - d.ledR = parseInt(.3 * parseInt(a.substr(1, 2), 16)); - d.ledG = parseInt(.3 * parseInt(a.substr(3, 2), 16)); - d.ledB = parseInt(.3 * parseInt(a.substr(5, 2), 16)); - return b.callReturn(); +Entry.block.xbot_rgb_picker = function(b, a) { + var d = a.getStringField("VALUE"), c = Entry.hw.sendQueue; + c.ledR = parseInt(.3 * parseInt(d.substr(1, 2), 16)); + c.ledG = parseInt(.3 * parseInt(d.substr(3, 2), 16)); + c.ledB = parseInt(.3 * parseInt(d.substr(5, 2), 16)); + return a.callReturn(); }; Blockly.Blocks.xbot_buzzer = {init:function() { this.setColour("#00979D"); @@ -6847,13 +6644,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 d = b.getStringField("NOTE", b), c = b.getStringField("OCTAVE", b), e = b.getNumberValue("VALUE", b), d = d + c; - a.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; - a.duration = 40 * e; - return b.callReturn(); +Entry.block.xbot_buzzer = function(b, a) { + var d = Entry.hw.sendQueue, c = a.getStringField("NOTE", a), e = a.getStringField("OCTAVE", a), f = a.getNumberValue("VALUE", a), c = c + e; + d.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; + d.duration = 40 * f; + return a.callReturn(); }; Blockly.Blocks.xbot_lcd = {init:function() { this.setColour("#00979D"); @@ -6864,5201 +6660,3405 @@ Blockly.Blocks.xbot_lcd = {init:function() { this.setPreviousStatement(!0); this.setNextStatement(!0); }}; -Entry.block.xbot_lcd = function(a, b) { - a = Entry.hw.sendQueue; - var d = b.getNumberField("LINE", b), c = b.getStringValue("VALUE", b); - 0 == d ? (a.lcdNum = 0, a.lcdTxt = c) : 1 == d && (a.lcdNum = 1, a.lcdTxt = c); - return b.callReturn(); +Entry.block.xbot_lcd = function(b, a) { + var d = Entry.hw.sendQueue, c = a.getNumberField("LINE", a), e = a.getStringValue("VALUE", a); + 0 == c ? (d.lcdNum = 0, d.lcdTxt = e) : 1 == c && (d.lcdNum = 1, d.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 c = this._hashMap, e; for (e in c) { delete c[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]; c[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), c = 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), c = this._hashMap, e = b.length - 1;0 <= e;e--) { + var f = b[e]; + a.unshift.call(this, f); c[f.id] = f; } }; - a.insert = function(a, c) { - b.splice.call(this, c, 0, a); - this._hashMap[a.id] = a; + b.insert = function(b, c) { + a.splice.call(this, c, 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, c) { - a = b.slice.call(this, a, c); - c = this._hashMap; - for (var e in a) { - delete c[a[e].id]; + b.slice = function(b, c) { + var e = a.slice.call(this, b, c), 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, c) { - var e = b.slice.call(arguments, 2), f = this._hashMap; - c = void 0 === c ? this.length - a : c; - for (var g = b.splice.call(this, a, c), h = 0, k = g.length;h < k;h++) { + b.splice = function(b, c) { + var e = a.slice.call(arguments, 2), f = this._hashMap; + c = void 0 === c ? this.length - b : c; + for (var g = a.splice.call(this, b, c), 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, c) { + b.moveFromTo = function(b, c) { var e = this.length - 1; - 0 > a || 0 > c || a > e || c > e || b.splice.call(this, c, 0, b.splice.call(this, a, 1)[0]); + 0 > b || 0 > c || b > e || c > e || a.splice.call(this, c, 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 c = this; - b = {obj:b, fn:a, destroy:function() { +(function(b) { + b.attach = function(a, b) { + var c = this, e = {obj:a, fn:b, destroy:function() { c.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.Observer = function(b, a, d, c) { + this.parent = b; + this.object = a; + this.funcName = d; + this.attrs = c; + b.push(this); +}; +(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.Container = function() { + this.objects_ = []; + this.cachedPicture = {}; + this.inputValue = {}; + this.currentObjects_ = this.copiedObject = null; }; -Entry.Utils.generateId = function() { - return ("0000" + (Math.random() * Math.pow(36, 4) << 0).toString(36)).substr(-4); +Entry.Container.prototype.generateView = function(b, a) { + var d = this; + this._view = b; + this._view.addClass("entryContainer"); + 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"); + }); + var c = Entry.createElement("div"), e = "entryContainerListWorkspaceWrapper"; + Entry.isForLecture && (e += " lecture"); + c.addClass(e); + Entry.Utils.disableContextmenu(c); + $(c).bind("mousedown touchstart", function(a) { + function b(a) { + q && 5 < Math.sqrt(Math.pow(a.pageX - q.x, 2) + Math.pow(a.pageY - q.y, 2)) && e && (clearTimeout(e), e = null); + } + function c(a) { + a.stopPropagation(); + l.unbind(".container"); + e && (clearTimeout(e), e = null); + } + var e = null, l = $(document), m = a.type, n = !1; + if (Entry.Utils.isRightButton(a)) { + d._rightClick(a), n = !0; + } else { + var q = {x:a.clientX, y:a.clientY}; + "touchstart" !== m || n || (a.stopPropagation(), a = Entry.Utils.convertMouseEvent(a), e = setTimeout(function() { + e && (e = null, d._rightClick(a)); + }, 1E3), l.bind("mousemove.container touchmove.container", b), l.bind("mouseup.container touchend.container", c)); + } + }); + this._view.appendChild(c); + e = Entry.createElement("ul"); + e.addClass("entryContainerListWorkspace"); + c.appendChild(e); + this.listView_ = e; + this.enableSort(); }; -Entry.Utils.intersectArray = function(a, b) { - for (var d = [], c = 0;c < a.length;c++) { - for (var e = 0;e < b.length;e++) { - if (a[c] == b[e]) { - d.push(a[c]); - break; - } +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 d = a.item.data("start_pos"), c = a.item.index(); + Entry.container.moveElement(d, c); + }, axis:"y", cancel:"input.selectedEditingObject"}); +}; +Entry.Container.prototype.disableSort = function() { + $ && $(this.listView_).sortable("destroy"); +}; +Entry.Container.prototype.updateListView = function() { + if (this.listView_) { + for (var b = this.listView_;b.hasChildNodes();) { + b.removeChild(b.lastChild); + } + var a = this.getCurrentObjects(), d; + for (d in a) { + b.appendChild(a[d].view_); } + Entry.stage.sortZorder(); } - return d; }; -Entry.Utils.isPointInMatrix = function(a, b, d) { - d = void 0 === d ? 0 : d; - var c = a.offsetX ? a.x + a.offsetX : a.x, e = a.offsetY ? a.y + a.offsety : a.y; - return c - d <= b.x && c + a.width + d >= b.x && e - d <= b.y && e + a.height + d >= b.y; +Entry.Container.prototype.setObjects = function(b) { + for (var a in b) { + var d = new Entry.EntryObject(b[a]); + this.objects_.push(d); + d.generateView(); + d.pictures.map(function(a) { + Entry.playground.generatePictureElement(a); + }); + d.sounds.map(function(a) { + Entry.playground.generateSoundElement(a); + }); + } + 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.Utils.colorDarken = function(a, b) { - function d(b) { - 2 != b.length && (b = "0" + b); - return b; +Entry.Container.prototype.getPictureElement = function(b, a) { + var d = this.getObject(a).getPicture(b); + if (d) { + return d.view; } - var c, e; - 7 === a.length ? (c = parseInt(a.substr(1, 2), 16), e = parseInt(a.substr(3, 2), 16), a = parseInt(a.substr(5, 2), 16)) : (c = 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; - c = d(Math.floor(c * b).toString(16)); - e = d(Math.floor(e * b).toString(16)); - a = d(Math.floor(a * b).toString(16)); - return "#" + c + 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 d = a; - "string" == typeof d && -1 != d.indexOf(".") && 1 === parseFloat(d) && (a = "100%"); - d = "string" === typeof a && -1 != a.indexOf("%"); - a = Math.min(b, Math.max(0, parseFloat(a))); - d && (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, d; - 7 === a.length ? (b = parseInt(a.substr(1, 2), 16), d = parseInt(a.substr(3, 2), 16), a = parseInt(a.substr(5, 2), 16)) : (b = parseInt(a.substr(1, 2), 16), d = parseInt(a.substr(2, 2), 16), a = parseInt(a.substr(3, 2), 16)); - b = Entry.Utils.bound01(b, 255); - d = Entry.Utils.bound01(d, 255); - a = Entry.Utils.bound01(a, 255); - var c = Math.max(b, d, a), e = Math.min(b, d, a), f, g = (c + e) / 2; - if (c == e) { - f = e = 0; - } else { - var h = c - e, e = .5 < g ? h / (2 - c - e) : h / (c + e); - switch(c) { - case b: - f = (d - a) / h + (d < a ? 6 : 0); - break; - case d: - f = (a - b) / h + 2; - break; - case a: - f = (b - d) / h + 4; + throw Error("No picture found"); +}; +Entry.Container.prototype.setPicture = function(b) { + var a = this.getObject(b.objectId), d; + for (d in a.pictures) { + if (b.id === a.pictures[d].id) { + var c = {}; + c.dimension = b.dimension; + c.id = b.id; + c.filename = b.filename; + c.fileurl = b.fileurl; + c.name = b.name; + c.view = a.pictures[d].view; + a.pictures[d] = c; + return; } - f /= 6; } - return {h:360 * f, s:e, l:g}; + throw Error("No picture found"); }; -Entry.Utils.hslToHex = function(a) { - function b(b, a, d) { - 0 > d && (d += 1); - 1 < d && --d; - return d < 1 / 6 ? b + 6 * (a - b) * d : .5 > d ? a : d < 2 / 3 ? b + (a - b) * (2 / 3 - d) * 6 : b; - } - function d(b) { - return 1 == b.length ? "0" + b : "" + b; - } - var c, e; - e = Entry.Utils.bound01(a.h, 360); - c = Entry.Utils.bound01(a.s, 1); - a = Entry.Utils.bound01(a.l, 1); - if (0 === c) { - c = a = e = a; - } else { - var f = .5 > a ? a * (1 + c) : a + c - a * c, g = 2 * a - f; - c = b(g, f, e + 1 / 3); - a = b(g, f, e); - e = b(g, f, e - 1 / 3); +Entry.Container.prototype.selectPicture = function(b, a) { + var d = this.getObject(a), c = d.getPicture(b); + if (c) { + return d.selectedPicture = c, d.entity.setImage(c), d.updateThumbnailView(), d.id; } - a *= 255; - e *= 255; - return "#" + [d(Math.round(255 * c).toString(16)), d(Math.round(a).toString(16)), d(Math.round(e).toString(16))].join(""); + throw Error("No picture found"); }; -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.Container.prototype.addObject = function(b, a) { + var d = new Entry.EntryObject(b); + d.name = Entry.getOrderedName(d.name, this.objects_); + Entry.stateManager && Entry.stateManager.addCommand("add object", this, this.removeObject, d); + d.scene || (d.scene = Entry.scene.selectedScene); + "number" == typeof a ? b.sprite.category && "background" == b.sprite.category.main ? (d.setLock(!0), this.objects_.push(d)) : this.objects_.splice(a, 0, d) : b.sprite.category && "background" == b.sprite.category.main ? this.objects_.push(d) : this.objects_.unshift(d); + d.generateView(); + d.pictures.map(function(a) { + Entry.playground.generatePictureElement(a); + }); + d.sounds.map(function(a) { + Entry.playground.generateSoundElement(a); + }); + this.setCurrentObjects(); + this.updateObjectsOrder(); + this.updateListView(); + this.selectObject(d.id); + Entry.variableContainer.updateViews(); + return new Entry.State(this, this.removeObject, d); }; -Entry.Utils.makeActivityReporter = function() { - Entry.activityReporter = new Entry.ActivityReporter; - Entry.commander && Entry.commander.addReporter(Entry.activityReporter); - return Entry.activityReporter; +Entry.Container.prototype.addCloneObject = function(b, a) { + var d = b.toJSON(), c = Entry.generateHash(); + Entry.variableContainer.addCloneLocalVariables({objectId:d.id, newObjectId:c, json:d}); + d.id = c; + d.scene = a || Entry.scene.selectedScene; + this.addObject(d); +}; +Entry.Container.prototype.removeObject = function(b) { + var a = this.objects_.indexOf(b), d = b.toJSON(); + Entry.stateManager && Entry.stateManager.addCommand("remove object", this, this.addObject, d, a); + d = new Entry.State(this.addObject, d, a); + b.destroy(); + this.objects_.splice(a, 1); + this.setCurrentObjects(); + Entry.stage.sortZorder(); + a = this.getCurrentObjects(); + a.length ? this.selectObject(a[0].id) : (this.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 d; }; -Entry.Utils.initEntryEvent_ = function() { - Entry.events_ || (Entry.events_ = []); +Entry.Container.prototype.selectObject = function(b, a) { + var d = this.getObject(b); + a && d && Entry.scene.selectScene(d.scene); + this.mapObjectOnScene(function(a) { + a.view_ && a.view_.removeClass("selectedObject"); + a.isSelected_ = !1; + }); + d && (d.view_ && d.view_.addClass("selectedObject"), d.isSelected_ = !0); + Entry.playground && Entry.playground.injectObject(d); + "minimize" != Entry.type && Entry.engine.isState("stop") && Entry.stage.selectObject(d); }; -Entry.sampleColours = []; -Entry.assert = function(a, b) { - if (!a) { - throw Error(b || "Assert failed"); +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, d = 0;d < a;d++) { + var c = this.objects_[d]; + if (c.id == b) { + return c; + } } }; -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.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.createElement = function(a, b) { - a = a instanceof HTMLElement ? a : document.createElement(a); - b && (a.id = b); - a.hasClass = function(b) { - return this.className.match(new RegExp("(\\s|^)" + b + "(\\s|$)")); - }; - a.addClass = function(b) { - for (var a = 0;a < arguments.length;a++) { - b = arguments[a], this.hasClass(b) || (this.className += " " + b); +Entry.Container.prototype.getVariable = function(b) { + for (var a = 0;a < this.variables_.length;a++) { + var d = this.variables_[a]; + if (d.getId() == b || d.getName() == b) { + return d; } - }; - 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|$)"), " ")); - } - }; - a.bindOnClick = function(b) { - $(this).on("click tab", function(a) { - a.stopImmediatePropagation(); - b.call(this, a); - }); - }; - return a; -}; -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.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.Container.prototype.moveElement = function(b, a, d) { + var c; + c = this.getCurrentObjects(); + b = this.getAllObjects().indexOf(c[b]); + a = this.getAllObjects().indexOf(c[a]); + !d && 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.dispatchEvent = function(a, b) { - this.events_ || (this.events_ = {}); - if (this.events_[a]) { - for (var d = 0, c = this.events_[a].length;d < c;d++) { - this.events_[a][d].call(window, b); - } - } +Entry.Container.prototype.moveElementByBlock = function(b, a) { + var d = this.getCurrentObjects().splice(b, 1)[0]; + this.getCurrentObjects().splice(a, 0, d); + Entry.stage.sortZorder(); + this.updateListView(); }; -Entry.removeEventListener = function(a, b) { - if (this.events_[a]) { - for (var d = 0, c = this.events_[a].length;d < c;d++) { - if (this.events_[a][d] === b) { - this.events_[a].splice(d, 1); +Entry.Container.prototype.getDropdownList = function(b, a) { + var d = []; + switch(b) { + case "sprites": + for (var c = this.getCurrentObjects(), e = c.length, f = 0;f < e;f++) { + a = c[f], d.push([a.name, a.id]); + } + break; + case "spritesWithMouse": + c = this.getCurrentObjects(); + e = c.length; + for (f = 0;f < e;f++) { + a = c[f], d.push([a.name, a.id]); + } + d.push([Lang.Blocks.mouse_pointer, "mouse"]); + break; + case "spritesWithSelf": + c = this.getCurrentObjects(); + e = c.length; + for (f = 0;f < e;f++) { + a = c[f], d.push([a.name, a.id]); + } + d.push([Lang.Blocks.self, "self"]); + break; + case "collision": + d.push([Lang.Blocks.mouse_pointer, "mouse"]); + c = this.getCurrentObjects(); + e = c.length; + for (f = 0;f < e;f++) { + a = c[f], d.push([a.name, a.id]); + } + d.push([Lang.Blocks.wall, "wall"]); + d.push([Lang.Blocks.wall_up, "wall_up"]); + d.push([Lang.Blocks.wall_down, "wall_down"]); + d.push([Lang.Blocks.wall_right, "wall_right"]); + d.push([Lang.Blocks.wall_left, "wall_left"]); + break; + case "pictures": + a = Entry.playground.object || a; + if (!a) { break; } - } + c = a.pictures; + for (f = 0;f < c.length;f++) { + e = c[f], d.push([e.name, e.id]); + } + break; + case "messages": + c = Entry.variableContainer.messages_; + for (f = 0;f < c.length;f++) { + e = c[f], d.push([e.name, e.id]); + } + break; + case "variables": + c = Entry.variableContainer.variables_; + for (f = 0;f < c.length;f++) { + e = c[f], e.object_ && Entry.playground.object && e.object_ != Entry.playground.object.id || d.push([e.getName(), e.getId()]); + } + d && 0 !== d.length || d.push([Lang.Blocks.VARIABLE_variable, "null"]); + break; + case "lists": + a = Entry.playground.object || a; + c = Entry.variableContainer.lists_; + for (f = 0;f < c.length;f++) { + e = c[f], e.object_ && a && e.object_ != a.id || d.push([e.getName(), e.getId()]); + } + d && 0 !== d.length || d.push([Lang.Blocks.VARIABLE_list, "null"]); + break; + case "scenes": + c = Entry.scene.scenes_; + for (f = 0;f < c.length;f++) { + e = c[f], d.push([e.name, e.id]); + } + break; + case "sounds": + a = Entry.playground.object || a; + if (!a) { + break; + } + c = a.sounds; + for (f = 0;f < c.length;f++) { + e = c[f], d.push([e.name, e.id]); + } + break; + case "clone": + d.push([Lang.Blocks.oneself, "self"]); + e = this.objects_.length; + for (f = 0;f < e;f++) { + a = this.objects_[f], d.push([a.name, a.id]); + } + break; + case "objectSequence": + for (e = this.getCurrentObjects().length, f = 0;f < e;f++) { + d.push([(f + 1).toString(), f.toString()]); + } + ; } + d.length || (d = [[Lang.Blocks.no_target, "null"]]); + return d; }; -Entry.removeAllEventListener = function(a) { - this.events_ && this.events_[a] && delete this.events_[a]; +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.addTwoNumber = function(a, b) { - if (isNaN(a) || isNaN(b)) { - return a + b; +Entry.Container.prototype.mapObject = function(b, a) { + for (var d = this.objects_.length, c = [], e = 0;e < d;e++) { + c.push(b(this.objects_[e], a)); } - a += ""; - b += ""; - var d = a.indexOf("."), c = b.indexOf("."), e = 0, f = 0; - 0 < d && (e = a.length - d - 1); - 0 < c && (f = b.length - c - 1); - return 0 < e || 0 < f ? e >= f ? (parseFloat(a) + parseFloat(b)).toFixed(e) : (parseFloat(a) + parseFloat(b)).toFixed(f) : parseInt(a) + parseInt(b); + return c; }; -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.Container.prototype.mapObjectOnScene = function(b, a) { + for (var d = this.getCurrentObjects(), c = d.length, e = [], f = 0;f < c;f++) { + e.push(b(d[f], a)); + } + return e; }; -Entry.rgb2hex = function(a, b, d) { - return "#" + (16777216 + (a << 16) + (b << 8) + d).toString(16).slice(1); +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.generateRgb = function() { - return {r:Math.floor(256 * Math.random()), g:Math.floor(256 * Math.random()), b:Math.floor(256 * Math.random())}; +Entry.Container.prototype.mapEntity = function(b, a) { + for (var d = this.objects_.length, c = [], e = 0;e < d;e++) { + c.push(b(this.objects_[e].entity, a)); + } + return c; }; -Entry.adjustValueWithMaxMin = function(a, b, d) { - return a > d ? d : a < b ? b : a; +Entry.Container.prototype.mapEntityOnScene = function(b, a) { + for (var d = this.getCurrentObjects(), c = d.length, e = [], f = 0;f < c;f++) { + e.push(b(d[f].entity, a)); + } + return e; }; -Entry.isExist = function(a, b, d) { - for (var c = 0;c < d.length;c++) { - if (d[c][b] == a) { - return d[c]; +Entry.Container.prototype.mapEntityIncludeClone = function(b, a) { + for (var d = this.objects_, c = d.length, e = [], f = 0;f < c;f++) { + var g = d[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 !1; + return e; }; -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.Container.prototype.mapEntityIncludeCloneOnScene = function(b, a) { + for (var d = this.getCurrentObjects(), c = d.length, e = [], f = 0;f < c;f++) { + var g = d[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.removeElement = function(a) { - a && a.parentNode && a.parentNode.removeChild(a); +Entry.Container.prototype.getCachedPicture = function(b) { + Entry.assert("string" == typeof b, "pictureId must be string"); + return this.cachedPicture[b]; }; -Entry.getElementsByClassName = function(a) { - for (var b = [], d = document.getElementsByTagName("*"), c = 0;c < d.length;c++) { - -1 < (" " + d[c].className + " ").indexOf(" " + a + " ") && b.push(d[c]); +Entry.Container.prototype.cachePicture = function(b, a) { + this.cachedPicture[b] = a; +}; +Entry.Container.prototype.toJSON = function() { + for (var b = [], a = this.objects_.length, d = 0;d < a;d++) { + b.push(this.objects_[d].toJSON()); } return b; }; -Entry.parseNumber = function(a) { - return "string" != typeof a || isNaN(Number(a)) ? "number" != typeof a || isNaN(Number(a)) ? !1 : a : Number(a); -}; -Entry.countStringLength = function(a) { - var b, d = 0; - for (b = 0;b < a.length;b++) { - 255 < a.charCodeAt(b) ? d += 2 : d++; +Entry.Container.prototype.takeSequenceSnapshot = function() { + for (var b = this.objects_.length, a = this.objects_, d = 0;d < b;d++) { + a[d].index = d; } - return d; }; -Entry.cutStringByLength = function(a, b) { - var d, c = 0; - for (d = 0;c < b && d < a.length;d++) { - 255 < a.charCodeAt(d) ? c += 2 : c++; +Entry.Container.prototype.loadSequenceSnapshot = function() { + for (var b = this.objects_.length, a = Array(b), d = 0;d < b;d++) { + var c = this.objects_[d]; + a[c.index || d] = c; + delete c.index; } - return a.substr(0, d); + this.objects_ = a; + this.setCurrentObjects(); + Entry.stage.sortZorder(); + this.updateListView(); }; -Entry.isChild = function(a, b) { - if (!b) { - for (;b.parentNode;) { - if ((b = b.parentNode) == a) { - return !0; - } +Entry.Container.prototype.getInputValue = function() { + return this.inputValue.getValue(); +}; +Entry.Container.prototype.setInputValue = function(b) { + this.inputValue.complete || (b ? this.inputValue.setValue(b) : this.inputValue.setValue(0), Entry.stage.hideInputField(), Entry.console && Entry.console.stopInput(b), this.inputValue.complete = !0); +}; +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.Container.prototype.setCopiedObject = function(b) { + this.copiedObject = b; +}; +Entry.Container.prototype.updateObjectsOrder = function() { + for (var b = Entry.scene.getScenes(), a = [], d = 0;d < b.length;d++) { + for (var c = this.getSceneObjects(b[d]), e = 0;e < c.length;e++) { + a.push(c[e]); } } - return !1; + this.objects_ = a; }; -Entry.launchFullScreen = function(a) { - a.requestFullscreen ? a.requestFullscreen() : a.mozRequestFulScreen ? a.mozRequestFulScreen() : a.webkitRequestFullscreen ? a.webkitRequestFullscreen() : a.msRequestFullScreen && a.msRequestFullScreen(); +Entry.Container.prototype.getSceneObjects = function(b) { + b = b || Entry.scene.selectedScene; + for (var a = [], d = this.getAllObjects(), c = 0;c < d.length;c++) { + b.id == d[c].scene.id && a.push(d[c]); + } + return a; }; -Entry.exitFullScreen = function() { - document.exitFullScreen ? document.exitFullScreen() : document.mozCancelFullScreen ? document.mozCancelFullScreen() : document.webkitExitFullscreen && document.webkitExitFullscreen(); +Entry.Container.prototype.setCurrentObjects = function() { + this.currentObjects_ = this.getSceneObjects(); }; -Entry.isPhone = function() { - return !1; +Entry.Container.prototype.getCurrentObjects = function() { + var b = this.currentObjects_; + b && 0 !== b.length || this.setCurrentObjects(); + return this.currentObjects_; }; -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.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.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.blurAllInputs = function() { + this.getSceneObjects().map(function(b) { + b = b.view_.getElementsByTagName("input"); + for (var a = 0, d = b.length;a < d;a++) { + b[a].blur(); + } + }); }; -Entry.bindAnimationCallback = function(a, b) { - a.addEventListener("webkitAnimationEnd", b, !1); - a.addEventListener("animationend", b, !1); - a.addEventListener("oanimationend", b, !1); +Entry.Container.prototype.showProjectAnswer = function() { + var b = this.inputValue; + b && b.setVisible(!0); }; -Entry.cloneSimpleObject = function(a) { - var b = {}, d; - for (d in a) { - b[d] = a[d]; +Entry.Container.prototype.hideProjectAnswer = function(b) { + if ((b = this.inputValue) && b.isVisible() && !Entry.engine.isState("run")) { + for (var a = Entry.container.getAllObjects(), d = ["ask_and_wait", "get_canvas_input_value", "set_visible_answer"], c = 0, e = a.length;c < e;c++) { + for (var f = a[c].script, g = 0;g < d.length;g++) { + if (f.hasBlockType(d[g])) { + return; + } + } + } + b.setVisible(!1); } - return b; }; -Entry.nodeListToArray = function(a) { - for (var b = Array(a.length), d = -1, c = a.length;++d !== c;b[d] = a[d]) { - } - return b; +Entry.Container.prototype.getView = function() { + return this._view; }; -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.Container.prototype.resize = function() { }; -Entry.isArrowOrBackspace = function(a) { - return -1 < [37, 38, 39, 40, 8].indexOf(a); +Entry.Container.prototype._rightClick = function(b) { + b.stopPropagation && b.stopPropagation(); + var 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", {x:b.clientX, y:b.clientY}); }; -Entry.hexStringToBin = function(a) { - for (var b = [], d = 0;d < a.length - 1;d += 2) { - b.push(parseInt(a.substr(d, 2), 16)); - } - return String.fromCharCode.apply(String, b); +Entry.Container.prototype.removeFuncBlocks = function(b) { + this.objects_.forEach(function(a) { + a.script.removeBlocksByType(b); + }); }; -Entry.findObjsByKey = function(a, b, d) { - for (var c = [], e = 0;e < a.length;e++) { - a[e][b] == d && c.push(a[e]); +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; + }; + b.has = function(a) { + return this.data.hasOwnProperty(a); + }; + b.remove = function(a) { + this.has(a) && (delete this.typeMap[this.data[a].type][a], delete this.data[a]); + }; + b.get = function(a) { + return this.data[a]; + }; + b.find = function() { + }; + b.clear = function() { + this.data = {}; + this.typeMap = {}; + }; +})(Entry.db); +Entry.Dom = function(b, a) { + var d = /<(\w+)>/, c; + c = b instanceof HTMLElement ? $(b) : b instanceof jQuery ? b : d.test(b) ? $(b) : $("<" + b + ">"); + if (void 0 === a) { + return c; } + a.id && c.attr("id", a.id); + a.class && c.addClass(a.class); + a.classes && a.classes.map(function(a) { + c.addClass(a); + }); + a.src && c.attr("src", a.src); + a.parent && a.parent.append(c); + c.bindOnClick = function() { + var a, b, d = 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, d); + } else { + $(this).on("click tab", d); + } + }; return c; }; -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.SVG = function(b) { + b = document.getElementById(b); + return Entry.SVG.createElement(b); }; -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.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 d; + d = "string" === typeof b ? document.createElementNS(Entry.SVG.NS, b) : b; + if (a) { + a.href && (d.setAttributeNS(Entry.SVG.NS_XLINK, "href", a.href), delete a.href); + for (var c in a) { + d.setAttribute(c, a[c]); } } - return a; -}; -Entry.toRadian = function(a) { - return a * Math.PI / 180; + this instanceof SVGElement && this.appendChild(d); + d.elem = Entry.SVG.createElement; + d.attr = Entry.SVG.attr; + d.addClass = Entry.SVG.addClass; + d.removeClass = Entry.SVG.removeClass; + d.hasClass = Entry.SVG.hasClass; + d.remove = Entry.SVG.remove; + d.removeAttr = Entry.SVG.removeAttr; + return d; }; -Entry.toDegrees = function(a) { - return 180 * a / Math.PI; +Entry.SVG.attr = function(b, a) { + if ("string" === typeof b) { + var d = {}; + d[b] = a; + b = d; + } + if (b) { + b.href && (this.setAttributeNS(Entry.SVG.NS_XLINK, "href", b.href), delete b.href); + for (var c in b) { + this.setAttribute(c, b[c]); + } + } + return this; }; -Entry.getPicturesJSON = function(a) { - for (var b = [], d = 0, c = a.length;d < c;d++) { - var e = a[d], 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.SVG.addClass = function(b) { + for (var a = this.getAttribute("class"), d = 0;d < arguments.length;d++) { + b = arguments[d], this.hasClass(b) || (a += " " + b); } - return b; + this.setAttribute("class", a); + return this; }; -Entry.getSoundsJSON = function(a) { - for (var b = [], d = 0, c = a.length;d < c;d++) { - var e = a[d], 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.SVG.removeClass = function(b) { + for (var a = this.getAttribute("class"), d = 0;d < arguments.length;d++) { + b = arguments[d], this.hasClass(b) && (a = a.replace(new RegExp("(\\s|^)" + b + "(\\s|$)"), " ")); } - return b; + this.setAttribute("class", a); + return this; }; -Entry.cutDecimal = function(a) { - return Math.round(100 * a) / 100; +Entry.SVG.hasClass = function(b) { + var a = this.getAttribute("class"); + return a ? a.match(new RegExp("(\\s|^)" + b + "(\\s|$)")) : !1; }; -Entry.getBrowserType = function() { - if (Entry.userAgent) { - return Entry.userAgent; - } - var a = navigator.userAgent, b, d = a.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || []; - if (/trident/i.test(d[1])) { - return b = /\brv[ :]+(\d+)/g.exec(a) || [], "IE " + (b[1] || ""); - } - if ("Chrome" === d[1] && (b = a.match(/\b(OPR|Edge)\/(\d+)/), null != b)) { - return b.slice(1).join(" ").replace("OPR", "Opera"); - } - d = d[2] ? [d[1], d[2]] : [navigator.appName, navigator.appVersion, "-?"]; - null != (b = a.match(/version\/(\d+)/i)) && d.splice(1, 1, b[1]); - a = d.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 d = new createjs.Shape(b); - Entry.stage.selectedObjectContainer.addChild(d); - a.brush && (a.brush = null); - a.brush = b; - a.shape && (a.shape = null); - a.shape = d; -}; -Entry.setCloneBrush = function(a, b) { - var d = new createjs.Graphics; - d.thickness = b.thickness; - d.rgb = b.rgb; - d.opacity = b.opacity; - d.setStrokeStyle(d.thickness); - d.beginStroke("rgba(" + d.rgb.r + "," + d.rgb.g + "," + d.rgb.b + "," + d.opacity / 100 + ")"); - b = new createjs.Shape(d); - Entry.stage.selectedObjectContainer.addChild(b); - a.brush && (a.brush = null); - a.brush = d; - a.shape && (a.shape = null); - a.shape = b; +Entry.SVG.remove = function() { + this.parentNode && this.parentNode.removeChild(this); }; -Entry.isFloat = function(a) { - return /\d+\.{1}\d+$/.test(a); +Entry.SVG.removeAttr = function(b) { + this.removeAttribute(b); }; -Entry.getStringIndex = function(a) { - if (!a) { - return ""; - } - for (var b = {string:a, index:1}, d = 0, c = [], e = a.length - 1;0 < e;--e) { - var f = a.charAt(e); - if (isNaN(f)) { - break; - } else { - c.unshift(f), d = e; - } - } - 0 < d && (b.string = a.substring(0, d), b.index = parseInt(c.join("")) + 1); - return b; +Entry.Dialog = function(b, a, d, c) { + b.dialog && b.dialog.remove(); + b.dialog = this; + this.parent = b; + this.padding = 10; + this.border = 2; + "number" == typeof a && (a = String(a)); + Entry.console && Entry.console.print(a, d); + this.message_ = a = a.match(/.{1,15}/g).join("\n"); + this.mode_ = d; + "speak" !== d && "ask" !== d || this.generateSpeak(); + c || Entry.stage.loadDialog(this); }; -Entry.getOrderedName = function(a, b, d) { - if (!a) { - return "untitled"; - } - if (!b || 0 === b.length) { - return a; - } - d || (d = "name"); - for (var c = 0, e = Entry.getStringIndex(a), f = 0, g = b.length;f < g;f++) { - var h = Entry.getStringIndex(b[f][d]); - e.string === h.string && h.index > c && (c = h.index); - } - return 0 < c ? e.string + c : a; +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(), d = a.height, a = 10 <= a.width ? a.width : 17, c = new createjs.Shape; + c.graphics.f("#f5f5f5").ss(2, "round").s("#6FC0DD").rr(-this.padding, -this.padding, a + 2 * this.padding, d + 2 * this.padding, this.padding); + this.object.addChild(c); + this.object.regX = a / 2; + this.object.regY = d / 2; + this.width = a; + this.height = d; + this.notch = this.createSpeakNotch("ne"); + this.update(); + this.object.addChild(this.notch); + this.object.addChild(b); + Entry.requestUpdate = !0; }; -Entry.changeXmlHashId = function(a) { - if (/function_field/.test(a.getAttribute("type"))) { - for (var b = a.getElementsByTagName("mutation"), d = 0, c = b.length;d < c;d++) { - b[d].setAttribute("hashid", Entry.generateHash()); +Entry.Dialog.prototype.update = function() { + var b = this.parent.object.getTransformedBounds(); + if (!b && "textBox" === this.parent.type) { + if (this._isNoContentTried) { + delete this._isNoContentTried; + return; } + this.parent.setText(" "); + b = this.parent.object.getTransformedBounds(); + this._isNoContentTried = !0; } + var 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)); + this._isNoContentTried && this.parent.setText(""); + Entry.requestUpdate = !0; +}; +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.getMaxFloatPoint = function(a) { - for (var b = 0, d = 0, c = a.length;d < c;d++) { - var e = String(a[d]), f = e.indexOf("."); - -1 !== f && (e = e.length - (f + 1), e > b && (b = e)); - } - return Math.min(b, 20); +Entry.Dialog.prototype.remove = function() { + Entry.stage.unloadDialog(this); + this.parent.dialog = null; + Entry.requestUpdate = !0; }; -Entry.convertToRoundedDecimals = function(a, b) { - return isNaN(a) || !this.isFloat(a) ? a : Number(Math.round(a + "e" + b) + "e-" + b); +Entry.DoneProject = function(b) { + this.generateView(b); }; -Entry.attachEventListener = function(a, b, d) { - setTimeout(function() { - a.addEventListener(b, d); - }, 0); +var p = Entry.DoneProject.prototype; +p.init = function(b) { + this.projectId = b; }; -Entry.deAttachEventListener = function(a, b, d) { - a.removeEventListener(b, d); +p.generateView = function(b) { + var a = Entry.createElement("div"); + a.addClass("entryContainerDoneWorkspace"); + this.doneContainer = a; + var d = Entry.createElement("iframe"); + d.setAttribute("id", "doneProjectframe"); + d.setAttribute("frameborder", 0); + d.setAttribute("src", "/api/iframe/project/" + b); + this.doneProjectFrame = d; + this.doneContainer.appendChild(d); + a.addClass("entryRemove"); }; -Entry.isEmpty = function(a) { - if (!a) { - return !0; +p.getView = function() { + return this.doneContainer; +}; +p.resize = function() { + document.getElementById("entryContainerWorkspaceId"); + var b = document.getElementById("doneProjectframe"), a = this.doneContainer.offsetWidth; + b.width = a + "px"; + b.height = 9 * a / 16 + "px"; +}; +Entry.Engine = function() { + function b(a) { + var b = [37, 38, 39, 40, 32], c = a.keyCode || a.which, e = Entry.stage.inputField; + 32 == c && e && e.hasFocus() || -1 < b.indexOf(c) && a.preventDefault(); } - for (var b in a) { - if (a.hasOwnProperty(b)) { - return !1; - } + this.state = "stop"; + this.popup = null; + this.isUpdating = !0; + this.speeds = [1, 15, 30, 45, 60]; + this._mouseMoved = !1; + Entry.keyPressed && Entry.keyPressed.attach(this, this.captureKeyEvent); + Entry.addEventListener("canvasClick", function(a) { + Entry.engine.fireEvent("mouse_clicked"); + }); + Entry.addEventListener("canvasClickCanceled", function(a) { + Entry.engine.fireEvent("mouse_click_cancled"); + }); + Entry.addEventListener("entityClick", function(a) { + Entry.engine.fireEventOnEntity("when_object_click", a); + }); + Entry.addEventListener("entityClickCanceled", function(a) { + Entry.engine.fireEventOnEntity("when_object_click_canceled", a); + }); + "phone" != Entry.type && (Entry.addEventListener("stageMouseMove", function(a) { + this._mouseMoved = !0; + }.bind(this)), Entry.addEventListener("stageMouseOut", function(a) { + Entry.engine.hideMouseView(); + })); + Entry.addEventListener("run", function() { + $(window).bind("keydown", b); + }); + Entry.addEventListener("stop", function() { + $(window).unbind("keydown", b); + }); + setInterval(function() { + this._mouseMoved && (this.updateMouseView(), this._mouseMoved = !1); + }.bind(this), 100); +}; +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(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(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(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(a) { + Entry.engine.toggleRun(); + }); + }.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(a) { + Entry.engine.exitFullScreen(); + }), document.addEventListener("webkitfullscreenchange", function(a) { + Entry.engine.exitFullScreen(); + }), 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(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(a) { + Entry.engine.toggleStop(); + })); + } else { + this.view_ = b; + this.view_.addClass("entryEngine_w"); + this.view_.addClass("entryEngineWorkspace_w"); + var d = Entry.createElement("button"); + this.speedButton = d; + this.speedButton.addClass("entrySpeedButtonWorkspace", "entryEngineTopWorkspace", "entryEngineButtonWorkspace_w"); + this.view_.appendChild(this.speedButton); + this.speedButton.bindOnClick(function(a) { + Entry.engine.toggleSpeedPanel(); + d.blur(); + }); + this.maximizeButton = Entry.createElement("button"); + this.maximizeButton.addClass("entryEngineButtonWorkspace_w", "entryEngineTopWorkspace", "entryMaximizeButtonWorkspace_w"); + this.view_.appendChild(this.maximizeButton); + this.maximizeButton.bindOnClick(function(a) { + Entry.engine.toggleFullscreen(); + this.blur(); + }); + var c = Entry.createElement("button"); + this.coordinateButton = c; + this.coordinateButton.addClass("entryEngineButtonWorkspace_w", "entryEngineTopWorkspace", "entryCoordinateButtonWorkspace_w"); + this.view_.appendChild(this.coordinateButton); + this.coordinateButton.bindOnClick(function(a) { + this.hasClass("toggleOn") ? this.removeClass("toggleOn") : this.addClass("toggleOn"); + c.blur(); + this.blur(); + Entry.stage.toggleCoordinator(); + }); + this.addButton = Entry.createElement("button"); + this.addButton.addClass("entryEngineButtonWorkspace_w"); + this.addButton.addClass("entryAddButtonWorkspace_w"); + this.addButton.innerHTML = Lang.Workspace.add_object; + this.addButton.bindOnClick(function(a) { + Entry.dispatchEvent("openSpriteManager"); + this.blur(); + }); + this.view_.appendChild(this.addButton); + this.runButton = Entry.createElement("button"); + this.runButton.addClass("entryEngineButtonWorkspace_w"); + this.runButton.addClass("entryRunButtonWorkspace_w"); + this.runButton.innerHTML = Lang.Workspace.run; + this.view_.appendChild(this.runButton); + this.runButton.bindOnClick(function(a) { + Entry.engine.toggleRun(); + this.blur(); + }); + this.runButton2 = Entry.createElement("button"); + this.runButton2.addClass("entryEngineButtonWorkspace_w"); + this.runButton2.addClass("entryRunButtonWorkspace_w2"); + this.view_.appendChild(this.runButton2); + this.runButton2.bindOnClick(function(a) { + this.blur(); + Entry.engine.toggleRun(); + }); + this.stopButton = Entry.createElement("button"); + this.stopButton.addClass("entryEngineButtonWorkspace_w"); + this.stopButton.addClass("entryStopButtonWorkspace_w"); + 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.stopButton2 = Entry.createElement("button"); + this.stopButton2.addClass("entryEngineButtonWorkspace_w"); + this.stopButton2.addClass("entryStopButtonWorkspace_w2"); + this.stopButton2.addClass("entryRemove"); + this.stopButton2.innerHTML = Lang.Workspace.stop; + this.view_.appendChild(this.stopButton2); + this.stopButton2.bindOnClick(function(a) { + this.blur(); + Entry.engine.toggleStop(); + }); + this.pauseButton = Entry.createElement("button"); + this.pauseButton.addClass("entryEngineButtonWorkspace_w"); + this.pauseButton.addClass("entryPauseButtonWorkspace_w"); + 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("entryMouseViewWorkspace_w"); + this.mouseView.addClass("entryRemove"); + this.view_.appendChild(this.mouseView); } - return !0; }; -Entry.Utils.disableContextmenu = function(a) { - if (a) { - $(a).on("contextmenu", function(b) { - b.stopPropagation(); - b.preventDefault(); - return !1; +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(a) { + $(this).remove(); + delete this.speedProgress_; + }), $(this.speedHandle_).remove(), delete this.speedHandle_; + } else { + this.speedPanelOn = !0; + $(Entry.stage.canvas.canvas).animate({top:"41px"}); + this.coordinateButton.addClass("entryRemove"); + this.maximizeButton.addClass("entryRemove"); + this.mouseView.addClass("entryRemoveElement"); + this.speedLabel_ = Entry.createElement("div", "entrySpeedLabelWorkspace"); + this.speedLabel_.innerHTML = Lang.Workspace.speed; + this.view_.insertBefore(this.speedLabel_, this.maximizeButton); + this.speedProgress_ = Entry.createElement("table", "entrySpeedProgressWorkspace"); + for (var b = Entry.createElement("tr"), a = this.speeds, d = 0;5 > d;d++) { + (function(d) { + var c = Entry.createElement("td", "progressCell" + d); + c.bindOnClick(function() { + Entry.engine.setSpeedMeter(a[d]); + }); + b.appendChild(c); + })(d); + } + this.view_.insertBefore(this.speedProgress_, this.maximizeButton); + this.speedProgress_.appendChild(b); + this.speedHandle_ = Entry.createElement("div", "entrySpeedHandleWorkspace"); + var c = (Entry.interfaceState.canvasWidth - 84) / 5; + $(this.speedHandle_).bind("mousedown.speedPanel touchstart.speedPanel", function(a) { + function b(a) { + a.stopPropagation(); + a = Entry.Utils.convertMouseEvent(a); + a = Math.floor((a.clientX - 80) / (5 * c) * 5); + 0 > a || 4 < a || Entry.engine.setSpeedMeter(Entry.engine.speeds[a]); + } + function d(a) { + $(document).unbind(".speedPanel"); + } + a.stopPropagation && a.stopPropagation(); + a.preventDefault && a.preventDefault(); + if (0 === a.button || a.originalEvent && a.originalEvent.touches) { + Entry.Utils.convertMouseEvent(a), a = $(document), a.bind("mousemove.speedPanel touchmove.speedPanel", b), a.bind("mouseup.speedPanel touchend.speedPanel", d); + } }); + this.view_.insertBefore(this.speedHandle_, this.maximizeButton); + this.setSpeedMeter(Entry.FPS); } }; -Entry.Utils.isRightButton = function(a) { - return 2 == a.button || a.ctrlKey; +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.Utils.isTouchEvent = function(a) { - return "mousedown" !== a.type.toLowerCase(); +Entry.Engine.prototype.start = function(b) { + createjs.Ticker.setFPS(Entry.FPS); + this.ticker = setInterval(this.update, Math.floor(1E3 / Entry.FPS)); }; -Entry.Utils.inherit = function(a, b) { - function d() { - } - d.prototype = a.prototype; - b.prototype = new d; - return b; +Entry.Engine.prototype.stop = function() { + clearInterval(this.ticker); + this.ticker = null; }; -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 d = a.elem("filter", {id:"entryTrashcanFilter_" + b}); - 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 = a.elem("filter", {id:"entryBlockShadowFilter_" + b, 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"}); - 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 d = b.elem("rect", {x:0, y:0, width:125, height:33}), c = Entry.mediaFilePath + "block_pattern_(order).png", e = 1;5 > e;e++) { - b.elem("image", {class:"pattern" + e, href:c.replace("(order)", e), x:0, y:0, width:125, height:33}); - } - return {pattern:a, rect:d}; +Entry.Engine.prototype.update = function() { + Entry.engine.isState("run") && (Entry.engine.computeObjects(), Entry.hw.update()); }; -Entry.Utils.COLLISION = {NONE:0, UP:1, RIGHT:2, LEFT:3, DOWN:4}; -Entry.Utils.createMouseEvent = function(a, b) { - var d = document.createEvent("MouseEvent"); - d.initMouseEvent(a, !0, !0, window, 0, 0, 0, b.clientX, b.clientY, !1, !1, !1, !1, 0, null); - return d; +Entry.Engine.prototype.computeObjects = function() { + Entry.container.mapObjectOnScene(this.computeFunction); }; -Entry.Utils.xmlToJsonData = function(a) { - a = $.parseXML(a); - var b = []; - a = a.childNodes[0].childNodes; - for (var d in a) { - var c = a[d]; - if (c.tagName) { - var e = {category:c.getAttribute("id"), blocks:[]}, c = c.childNodes; - for (d in c) { - var f = c[d]; - f.tagName && (f = f.getAttribute("type")) && e.blocks.push(f); - } - b.push(e); - } - } - return b; +Entry.Engine.prototype.computeFunction = function(b) { + b.script.tick(); }; -Entry.Utils.stopProjectWithToast = function(a, b, d) { - var c = a.block; - b = b || "\ub7f0\ud0c0\uc784 \uc5d0\ub7ec \ubc1c\uc0dd"; - Entry.toast && !d && Entry.toast.alert(Lang.Msgs.warn, Lang.Workspace.check_runtime_error, !0); - Entry.engine && Entry.engine.toggleStop(); - "workspace" === Entry.type && (a.block && "funcBlock" in a.block ? c = a.block.funcBlock : a.funcExecutor && (c = a.funcExecutor.scope.block, a = a.type.replace("func_", ""), Entry.Func.edit(Entry.variableContainer.functions_[a])), c && (Entry.container.selectObject(c.getCode().object.id, !0), c.view.getBoard().activateBlock(c))); - throw Error(b); -}; -Entry.Utils.AsyncError = function(a) { - this.name = "AsyncError"; - this.message = a || "\ube44\ub3d9\uae30 \ud638\ucd9c \ub300\uae30"; +Entry.Engine.computeThread = function(b, a) { + Entry.engine.isContinue = !0; + for (var d = !1;a && Entry.engine.isContinue && !d;) { + Entry.engine.isContinue = !a.isRepeat; + var c = a.run(), d = c && c === a; + a = c; + } + return a; }; -Entry.Utils.AsyncError.prototype = Error(); -Entry.Utils.AsyncError.prototype.constructor = Entry.Utils.AsyncError; -Entry.Utils.isChrome = function() { - return /chrom(e|ium)/.test(navigator.userAgent.toLowerCase()); +Entry.Engine.prototype.isState = function(b) { + return -1 < this.state.indexOf(b); }; -Entry.Utils.waitForWebfonts = function(a, b) { - for (var d = 0, c = 0, e = a.length;c < e;++c) { - (function(c) { - function e() { - h && h.offsetWidth != k && (++d, h.parentNode.removeChild(h), h = null); - if (d >= a.length && (l && clearInterval(l), d == a.length)) { - return b(), !0; - } - } - var h = document.createElement("span"); - h.innerHTML = "giItT1WQy@!-/#"; - h.style.position = "absolute"; - h.style.left = "-10000px"; - h.style.top = "-10000px"; - h.style.fontSize = "300px"; - h.style.fontFamily = "sans-serif"; - h.style.fontVariant = "normal"; - h.style.fontStyle = "normal"; - h.style.fontWeight = "normal"; - h.style.letterSpacing = "0"; - document.body.appendChild(h); - var k = h.offsetWidth; - h.style.fontFamily = c; - var l; - e() || (l = setInterval(e, 50)); - })(a[c]); - } +Entry.Engine.prototype.run = function() { + this.isState("run") ? this.toggleStop() : (this.isState("stop") || this.isState("pause")) && this.toggleRun(); }; -window.requestAnimFrame = function() { - return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function(a) { - window.setTimeout(a, 1E3 / 60); - }; -}(); -Entry.isMobile = function() { - if (Entry.device) { - return "tablet" === Entry.device; - } - var a = window.platform; - if (a && a.type && ("tablet" === a.type || "mobile" === a.type)) { - return Entry.device = "tablet", !0; +Entry.Engine.prototype.toggleRun = function() { + if ("pause" === this.state) { + this.togglePause(); + } else { + if (Entry.playground && Entry.playground.mainWorkspace) { + var b = Entry.playground.mainWorkspace, a = b.mode; + a == Entry.Workspace.MODE_VIMBOARD && b.loadCodeFromText(a); + } + 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(); + }), 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.device = "desktop"; - return !1; }; -Entry.Utils.convertMouseEvent = function(a) { - return a.originalEvent && a.originalEvent.touches ? a.originalEvent.touches[0] : a; +Entry.Engine.prototype.toggleStop = function() { + Entry.addActivity("stop"); + 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(); + }); + a.mapVariable(function(a) { + a.loadSnapshot(); + }); + a.mapList(function(a) { + a.loadSnapshot(); + a.updateView(); + }); + this.stopProjectTimer(); + b.clearRunningState(); + b.loadSequenceSnapshot(); + this.projectTimer.loadSnapshot(); + Entry.container.inputValue.loadSnapshot(); + Entry.scene.loadStartSceneSnapshot(); + Entry.Func.clearThreads(); + createjs.Sound.setVolume(1); + createjs.Sound.stop(); + this.view_.removeClass("entryEngineBlueWorkspace"); + this.runButton.removeClass("entryRemove"); + this.stopButton.addClass("entryRemove"); + this.pauseButton && this.pauseButton.addClass("entryRemove"); + this.runButton2 && this.runButton2.removeClass("entryRemove"); + this.stopButton2 && this.stopButton2.addClass("entryRemove"); + this.state = "stop"; + Entry.dispatchEvent("stop"); + Entry.stage.hideInputField(); }; -Entry.Utils.convertIntToHex = function(a) { - return a.toString(16).toUpperCase(); +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.Utils.hasSpecialCharacter = function(a) { - return /!|@|#|\$|%|\^|&|\*|\(|\)|\+|=|-|\[|\]|\\|\'|;|,|\.|\/|{|}|\||\"|:|<|>|\?/g.test(a); +Entry.Engine.prototype.fireEvent = function(b) { + "run" == this.state && Entry.container.mapEntityIncludeCloneOnScene(this.raiseEvent, b); }; -Entry.Model = function(a, b) { - var d = Entry.Model; - d.generateSchema(a); - d.generateSetter(a); - d.generateObserve(a); - (void 0 === b || b) && Object.seal(a); - return a; +Entry.Engine.prototype.raiseEvent = function(b, a) { + b.parent.script.raiseEvent(a, b); }; -(function(a) { - a.generateSchema = function(b) { - var a = b.schema; - if (void 0 !== a) { - a = JSON.parse(JSON.stringify(a)); - b.data = {}; - for (var c in a) { - (function(c) { - b.data[c] = a[c]; - Object.defineProperty(b, c, {get:function() { - return b.data[c]; - }}); - })(c); - } - b._toJSON = this._toJSON; - } - }; - a.generateSetter = function(b) { - b.set = this.set; - }; - a.set = function(b, a) { - var c = {}, e; - for (e in this.data) { - void 0 !== b[e] && (b[e] === this.data[e] ? delete b[e] : (c[e] = this.data[e], this.data[e] = b[e] instanceof Array ? b[e].concat() : b[e])); - } - a || this.notify(Object.keys(b), c); - }; - a.generateObserve = function(b) { - b.observers = []; - b.observe = this.observe; - b.unobserve = this.unobserve; - b.notify = this.notify; - }; - a.observe = function(b, a, c, e) { - c = new Entry.Observer(this.observers, b, a, c); - if (!1 !== e) { - b[a]([]); - } - return c; - }; - a.unobserve = function(b) { - b.destroy(); - }; - a.notify = function(b, a) { - "string" === typeof b && (b = [b]); - var c = this; - c.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:c, 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, d, c) { - this.parent = a; - this.object = b; - this.funcName = d; - this.attrs = c; - a.push(this); +Entry.Engine.prototype.fireEventOnEntity = function(b, a) { + "run" == this.state && Entry.container.mapEntityIncludeCloneOnScene(this.raiseEventOnEntity, [a, b]); }; -(function(a) { - a.destroy = function() { - var b = this.parent, a = b.indexOf(this); - -1 < a && b.splice(a, 1); - return this; - }; -})(Entry.Observer.prototype); -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, COMMAND_TYPES:{addThread:101, destroyThread:102, destroyBlock:103, recoverBlock:104, insertBlock:105, separateBlock:106, moveBlock:107, cloneBlock:108, uncloneBlock:109, scrollBoard:110, setFieldValue:111, selectObject:201, "do":301, -undo:302, redo:303, editPicture:401, uneditPicture:402, processPicture:403, unprocessPicture:404}}; -Entry.Command = {}; -(function(a) { - a.do = {type:Entry.STATIC.COMMAND_TYPES["do"], log:function(b) { - return [a["do"].type]; - }}; - a.undo = {type:Entry.STATIC.COMMAND_TYPES.undo, log:function(b) { - return [a.undo.type]; - }}; - a.redo = {type:Entry.STATIC.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.do = this.do.bind(this); - Entry.undo = this.undo.bind(this); - this.editor = {}; - this.reporters = []; - this._tempStorage = null; - Entry.Command.editor = this.editor; +Entry.Engine.prototype.raiseEventOnEntity = function(b, a) { + b === a[0] && b.parent.script.raiseEvent(a[1], b); }; -(function(a) { - a.do = function(b) { - var a = this, c = Array.prototype.slice.call(arguments); - c.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, c))); - e = Entry.Command[b].do.apply(this, c); - setTimeout(function() { - a.report("do"); - a.report(b, c); - }, 0); - return {value:e, isPass:this.isPass.bind(this)}; - }; - a.undo = function() { - var b = Array.prototype.slice.call(arguments), a = b.shift(), c = Entry.Command[a]; - this.report("undo"); - Entry.stateManager && Entry.stateManager.addCommand.apply(Entry.stateManager, [a, this, this.do, c.undo].concat(c.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(), c = Entry.Command[a]; - that.report("redo"); - Entry.stateManager && Entry.stateManager.addCommand.apply(Entry.stateManager, [a, this, this.undo, a].concat(c.state.apply(null, b))); - c.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 c = this.reporters; - if (0 !== c.length) { - var e; - e = b && Entry.Command[b] && Entry.Command[b].log ? Entry.Command[b].log.apply(this, a) : a; - c.forEach(function(b) { - b.add(e); - }); - } - }; -})(Entry.Commander.prototype); -(function(a) { - a.addThread = {type:Entry.STATIC.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:Entry.STATIC.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:Entry.STATIC.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:Entry.STATIC.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, d) { - b = this.editor.board.findById(b.id); - return [a.recoverBlock.type, ["block", b.stringify()], ["pointer", d], ["code", this.editor.board.code.stringify()]]; - }, undo:"destroyBlock"}; - a.insertBlock = {type:Entry.STATIC.COMMAND_TYPES.insertBlock, do:function(b, a, c) { - "string" === typeof b && (b = this.editor.board.findById(b)); - this.editor.board.insert(b, a, c); - }, state:function(b, a) { - "string" === typeof b && (b = this.editor.board.findById(b)); - a = [b.id]; - var c = b.targetPointer(); - a.push(c); - "string" !== typeof b && "basic" === b.getBlockType() && a.push(b.thread.getCount(b)); - return a; - }, log:function(b, d, c) { - "string" === typeof b && (b = this.editor.board.findById(b)); - return [a.insertBlock.type, ["blockId", b.id], ["targetPointer", b.targetPointer()], ["count", c], ["code", this.editor.board.code.stringify()]]; - }, undo:"insertBlock"}; - a.separateBlock = {type:Entry.STATIC.COMMAND_TYPES.separateBlock, do:function(b) { - b.view && b.view._toGlobalCoordinate(Entry.DRAG_MODE_DRAG); - b.doSeparate(); - }, state:function(b) { - var a = [b.id], c = b.targetPointer(); - a.push(c); - "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:Entry.STATIC.COMMAND_TYPES.moveBlock, do:function(b, a, c) { - void 0 !== a ? (b = this.editor.board.findById(b), b.moveTo(a, c)) : b._updatePos(); - }, state:function(b) { - "string" === typeof b && (b = this.editor.board.findById(b)); - return [b.id, b.x, b.y]; - }, log:function(b, d, c) { - return [a.moveBlock.type, ["blockId", b.id], ["x", b.x], ["y", b.y], ["code", this.editor.board.code.stringify()]]; - }, undo:"moveBlock"}; - a.cloneBlock = {type:Entry.STATIC.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 d = this.editor.board.code.getThreads().pop(); - return [a.cloneBlock.type, ["blockId", b.id], ["thread", d.stringify()], ["code", this.editor.board.code.stringify()]]; - }, undo:"uncloneBlock"}; - a.uncloneBlock = {type:Entry.STATIC.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:Entry.STATIC.COMMAND_TYPES.scrollBoard, do:function(b, a, c) { - c || this.editor.board.scroller._scroll(b, a); - delete this.editor.board.scroller._diffs; - }, state:function(b, a) { - return [-b, -a]; - }, log:function(b, d) { - return [a.scrollBoard.type, ["dx", b], ["dy", d]]; - }, undo:"scrollBoard"}; - a.setFieldValue = {type:Entry.STATIC.COMMAND_TYPES.setFieldValue, do:function(b, a, c, e, f) { - a.setValue(f, !0); - }, state:function(b, a, c, e, f) { - return [b, a, c, f, e]; - }, log:function(b, d, c, e, f) { - return [a.setFieldValue.type, ["pointer", c], ["newValue", f], ["code", this.editor.board.code.stringify()]]; - }, undo:"setFieldValue"}; -})(Entry.Command); -(function(a) { - a.selectObject = {type:Entry.STATIC.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); -(function(a) { - a.editPicture = {type:Entry.STATIC.COMMAND_TYPES.editPicture, do:function(b, a) { - Entry.playground.painter.lc.canRedo() && Entry.playground.painter.lc.redo(); - }, state:function(b) { - }, log:function(b) { - return [b]; - }, undo:"uneditPicture"}; - a.uneditPicture = {type:Entry.STATIC.COMMAND_TYPES.uneditPicture, do:function(b, a) { - Entry.playground.painter.lc.undo(); - }, state:function(b) { - }, log:function(b) { - return [b]; - }, undo:"editPicture"}; - a.processPicture = {type:Entry.STATIC.COMMAND_TYPES.processPicture, do:function(b, a) { - Entry.playground.painter.lc.canRedo() && Entry.playground.painter.lc.redo(); - }, state:function(b) { - }, log:function(b) { - return [b]; - }, undo:"unprocessPicture", isPass:!0}; - a.unprocessPicture = {type:Entry.STATIC.COMMAND_TYPES.unprocessPicture, do:function(b, a) { - Entry.playground.painter.lc.undo(); - }, state:function(b) { - }, log:function(b) { - return [b]; - }, undo:"processPicture", isPass:!0}; -})(Entry.Command); -Entry.Container = function() { - this.objects_ = []; - this.cachedPicture = {}; - this.inputValue = {}; - this.currentObjects_ = this.copiedObject = null; +Entry.Engine.prototype.captureKeyEvent = function(b) { + var a = b.keyCode, d = Entry.type; + b.ctrlKey && "workspace" == d ? 83 == a ? (b.preventDefault(), Entry.dispatchEvent("saveWorkspace")) : 82 == a ? (b.preventDefault(), Entry.engine.run()) : 90 == a && (b.preventDefault(), Entry.dispatchEvent(b.shiftKey ? "redo" : "undo")) : Entry.engine.isState("run") && Entry.container.mapEntityIncludeCloneOnScene(Entry.engine.raiseKeyEvent, ["keyPress", a]); + Entry.engine.isState("stop") && "workspace" === d && 37 <= a && 40 >= a && Entry.stage.moveSprite(b); }; -Entry.Container.prototype.generateView = function(a, b) { - var d = this; - this._view = a; - this._view.addClass("entryContainer"); - 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"); - b = "entryContainerListWorkspaceWrapper"; - Entry.isForLecture && (b += " lecture"); - a.addClass(b); - Entry.Utils.disableContextmenu(a); - $(a).bind("mousedown touchstart", function(b) { - function a(b) { - m && 5 < Math.sqrt(Math.pow(b.pageX - m.x, 2) + Math.pow(b.pageY - m.y, 2)) && g && (clearTimeout(g), g = null); - } - function f(b) { - b.stopPropagation(); - h.unbind(".container"); - g && (clearTimeout(g), g = null); - } - var g = null, h = $(document), k = b.type, l = !1; - if (Entry.Utils.isRightButton(b)) { - d._rightClick(b), l = !0; - } else { - var m = {x:b.clientX, y:b.clientY}; - "touchstart" !== k || l || (b.stopPropagation(), b = Entry.Utils.convertMouseEvent(b), g = setTimeout(function() { - g && (g = null, d._rightClick(b)); - }, 1E3), h.bind("mousemove.container touchmove.container", a), h.bind("mouseup.container touchend.container", f)); - } - }); - this._view.appendChild(a); - b = Entry.createElement("ul"); - b.addClass("entryContainerListWorkspace"); - a.appendChild(b); - this.listView_ = b; - this.enableSort(); +Entry.Engine.prototype.raiseKeyEvent = function(b, a) { + return b.parent.script.raiseEvent(a[0], b, String(a[1])); }; -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"}); +Entry.Engine.prototype.updateMouseView = function() { + var b = Entry.stage.mouseCoordinate; + this.mouseView.textContent = "X : " + b.x + ", Y : " + b.y; + this.mouseView.removeClass("entryRemove"); }; -Entry.Container.prototype.disableSort = function() { - $ && $(this.listView_).sortable("destroy"); +Entry.Engine.prototype.hideMouseView = function() { + this.mouseView.addClass("entryRemove"); }; -Entry.Container.prototype.updateListView = function() { - if (this.listView_) { - for (var a = this.listView_;a.hasChildNodes();) { - a.removeChild(a.lastChild); - } - var b = this.getCurrentObjects(), d; - for (d in b) { - a.appendChild(b[d].view_); +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.runButton[0]); } - Entry.stage.sortZorder(); + popup.window_.appendChild(Entry.engine.view_); } + Entry.windowResized.notify(); }; -Entry.Container.prototype.setObjects = function(a) { - for (var b in a) { - var d = new Entry.EntryObject(a[b]); - this.objects_.push(d); - d.generateView(); - d.pictures.map(function(b) { - Entry.playground.generatePictureElement(b); - }); - d.sounds.map(function(b) { - Entry.playground.generateSoundElement(b); - }); - } - 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.Engine.prototype.exitFullScreen = function() { + document.webkitIsFullScreen || document.mozIsFullScreen || document.isFullScreen || (Entry.engine.footerView_.removeClass("entryRemove"), Entry.engine.headerView_.removeClass("entryRemove")); + Entry.windowResized.notify(); }; -Entry.Container.prototype.getPictureElement = function(a, b) { - if (a = this.getObject(b).getPicture(a)) { - return a.view; - } - throw Error("No picture found"); +Entry.Engine.prototype.showProjectTimer = function() { + Entry.engine.projectTimer && this.projectTimer.setVisible(!0); }; -Entry.Container.prototype.setPicture = function(a) { - var b = this.getObject(a.objectId), d; - for (d in b.pictures) { - if (a.id === b.pictures[d].id) { - var c = {}; - c.dimension = a.dimension; - c.id = a.id; - c.filename = a.filename; - c.fileurl = a.fileurl; - c.name = a.name; - c.view = b.pictures[d].view; - b.pictures[d] = c; - return; +Entry.Engine.prototype.hideProjectTimer = function() { + var b = this.projectTimer; + if (b && b.isVisible() && !this.isState("run")) { + for (var a = Entry.container.getAllObjects(), d = ["get_project_timer_value", "reset_project_timer", "set_visible_project_timer", "choose_project_timer_action"], c = 0, e = a.length;c < e;c++) { + for (var f = a[c].script, g = 0;g < d.length;g++) { + if (f.hasBlockType(d[g])) { + return; + } + } } + b.setVisible(!1); } - throw Error("No picture found"); }; -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.Engine.prototype.clearTimer = function() { + clearInterval(this.ticker); + clearInterval(this.projectTimer.tick); +}; +Entry.Engine.prototype.startProjectTimer = function() { + 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 b = this.projectTimer; + b && (this.updateProjectTimer(0), b.isPaused = !1, b.isInit = !1, b.pausedTime = 0, clearInterval(b.tick)); +}; +Entry.Engine.prototype.updateProjectTimer = function(b) { + var a = Entry.engine, d = a.projectTimer; + if (d) { + var c = (new Date).getTime(); + "undefined" == typeof b ? d.isPaused || a.isState("pause") || d.setValue((c - d.start - d.pausedTime) / 1E3) : (d.setValue(b), d.pausedTime = 0, d.start = c); } - throw Error("No picture found"); }; -Entry.Container.prototype.addObject = function(a, b) { - var d = new Entry.EntryObject(a); - d.name = Entry.getOrderedName(d.name, this.objects_); - Entry.stateManager && Entry.stateManager.addCommand("add object", this, this.removeObject, d); - d.scene || (d.scene = Entry.scene.selectedScene); - "number" == typeof b ? a.sprite.category && "background" == a.sprite.category.main ? (d.setLock(!0), this.objects_.push(d)) : this.objects_.splice(b, 0, d) : a.sprite.category && "background" == a.sprite.category.main ? this.objects_.push(d) : this.objects_.unshift(d); - d.generateView(); - d.pictures.map(function(b) { - Entry.playground.generatePictureElement(b); +Entry.EntityObject = function(b) { + this.parent = b; + this.type = b.objectType; + this.flip = !1; + this.collision = Entry.Utils.COLLISION.NONE; + this.id = Entry.generateHash(); + "sprite" == this.type ? (this.object = new createjs.Bitmap, this.effect = {}, this.setInitialEffectValue()) : "textBox" == this.type && (this.object = new createjs.Container, this.textObject = new createjs.Text, this.textObject.font = "20px Nanum Gothic", this.textObject.textBaseline = "middle", this.textObject.textAlign = "center", this.bgObject = new createjs.Shape, this.bgObject.graphics.setStrokeStyle(1).beginStroke("#f00").drawRect(0, 0, 100, 100), this.object.addChild(this.bgObject), this.object.addChild(this.textObject), + 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(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 * a.stageX - 240), y:-this.parent.y - this.entity.getY() - (.75 * a.stageY - 135)}, this.cursor = "move", this.entity.initCommand(), Entry.container.selectObject(b)); }); - d.sounds.map(function(b) { - Entry.playground.generateSoundElement(b); + this.object.on("pressup", function(a) { + Entry.dispatchEvent("entityClickCanceled", this.entity); + this.cursor = "pointer"; + this.entity.checkCommand(); }); - this.setCurrentObjects(); - this.updateObjectsOrder(); - this.updateListView(); - this.selectObject(d.id); - Entry.variableContainer.updateViews(); - return new Entry.State(this, this.removeObject, d); -}; -Entry.Container.prototype.addCloneObject = function(a, b) { - a = a.toJSON(); - var d = Entry.generateHash(); - Entry.variableContainer.addCloneLocalVariables({objectId:a.id, newObjectId:d, json:a}); - a.id = d; - a.scene = b || Entry.scene.selectedScene; - this.addObject(a); -}; -Entry.Container.prototype.removeObject = function(a) { - var b = this.objects_.indexOf(a), d = a.toJSON(); - Entry.stateManager && Entry.stateManager.addCommand("remove object", this, this.addObject, d, b); - d = new Entry.State(this.addObject, d, 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 d; -}; -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; + 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()); }); - 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.Container.prototype.getAllObjects = function() { - return this.objects_; -}; -Entry.Container.prototype.getObject = function(a) { - !a && Entry.playground && Entry.playground.object && (a = Entry.playground.object.id); - for (var b = this.objects_.length, d = 0;d < b;d++) { - var c = this.objects_[d]; - if (c.id == a) { - return c; - } - } +Entry.EntityObject.prototype.injectModel = function(b, a) { + if ("sprite" == this.type) { + this.setImage(b); + } else { + if ("textBox" == this.type) { + var d = this.parent; + a.text = a.text || d.text || d.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.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.EntityObject.prototype.initCommand = function() { + Entry.engine.isState("stop") && (this.isCommandValid = !1, Entry.stateManager && Entry.stateManager.addCommand("edit entity", this, this.restoreEntity, this.toJSON())); }; -Entry.Container.prototype.getVariable = function(a) { - for (var b = 0;b < this.variables_.length;b++) { - var d = this.variables_[b]; - if (d.getId() == a || d.getName() == a) { - return d; - } - } +Entry.EntityObject.prototype.doCommand = function() { + this.isCommandValid = !0; }; -Entry.Container.prototype.moveElement = function(a, b, d) { - var c; - c = this.getCurrentObjects(); - a = this.getAllObjects().indexOf(c[a]); - b = this.getAllObjects().indexOf(c[b]); - !d && 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.EntityObject.prototype.checkCommand = function() { + Entry.engine.isState("stop") && !this.isCommandValid && Entry.dispatchEvent("cancelLastCommand"); }; -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.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.Container.prototype.getDropdownList = function(a, b) { - var d = []; - switch(a) { - case "sprites": - var c = this.getCurrentObjects(), e = c.length; - for (a = 0;a < e;a++) { - b = c[a], d.push([b.name, b.id]); - } - break; - case "spritesWithMouse": - c = this.getCurrentObjects(); - e = c.length; - for (a = 0;a < e;a++) { - b = c[a], d.push([b.name, b.id]); - } - d.push([Lang.Blocks.mouse_pointer, "mouse"]); - break; - case "spritesWithSelf": - c = this.getCurrentObjects(); - e = c.length; - for (a = 0;a < e;a++) { - b = c[a], d.push([b.name, b.id]); - } - d.push([Lang.Blocks.self, "self"]); - break; - case "collision": - d.push([Lang.Blocks.mouse_pointer, "mouse"]); - c = this.getCurrentObjects(); - e = c.length; - for (a = 0;a < e;a++) { - b = c[a], d.push([b.name, b.id]); - } - d.push([Lang.Blocks.wall, "wall"]); - d.push([Lang.Blocks.wall_up, "wall_up"]); - d.push([Lang.Blocks.wall_down, "wall_down"]); - d.push([Lang.Blocks.wall_right, "wall_right"]); - d.push([Lang.Blocks.wall_left, "wall_left"]); - break; - case "pictures": - b = Entry.playground.object || b; - if (!b) { - break; - } - b = b.pictures; - for (a = 0;a < b.length;a++) { - c = b[a], d.push([c.name, c.id]); - } - break; - case "messages": - b = Entry.variableContainer.messages_; - for (a = 0;a < b.length;a++) { - c = b[a], d.push([c.name, c.id]); - } - break; - case "variables": - b = Entry.variableContainer.variables_; - for (a = 0;a < b.length;a++) { - c = b[a], c.object_ && Entry.playground.object && c.object_ != Entry.playground.object.id || d.push([c.getName(), c.getId()]); - } - d && 0 !== d.length || d.push([Lang.Blocks.VARIABLE_variable, "null"]); - break; - case "lists": - b = Entry.playground.object || b; - c = Entry.variableContainer.lists_; - for (a = 0;a < c.length;a++) { - e = c[a], e.object_ && b && e.object_ != b.id || d.push([e.getName(), e.getId()]); - } - d && 0 !== d.length || d.push([Lang.Blocks.VARIABLE_list, "null"]); - break; - case "scenes": - b = Entry.scene.scenes_; - for (a = 0;a < b.length;a++) { - c = b[a], d.push([c.name, c.id]); - } - break; - case "sounds": - b = Entry.playground.object || b; - if (!b) { - break; - } - b = b.sounds; - for (a = 0;a < b.length;a++) { - c = b[a], d.push([c.name, c.id]); - } - break; - case "clone": - d.push([Lang.Blocks.oneself, "self"]); - e = this.objects_.length; - for (a = 0;a < e;a++) { - b = this.objects_[a], d.push([b.name, b.id]); - } - break; - case "objectSequence": - for (e = this.getCurrentObjects().length, a = 0;a < e;a++) { - d.push([(a + 1).toString(), a.toString()]); - } - ; - } - d.length || (d = [[Lang.Blocks.no_target, "null"]]); - return d; +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.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.EntityObject.prototype.getX = function() { + return this.x; }; -Entry.Container.prototype.mapObject = function(a, b) { - for (var d = this.objects_.length, c = [], e = 0;e < d;e++) { - c.push(a(this.objects_[e], b)); - } - return c; +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.Container.prototype.mapObjectOnScene = function(a, b) { - for (var d = this.getCurrentObjects(), c = d.length, e = [], f = 0;f < c;f++) { - e.push(a(d[f], b)); - } - return e; +Entry.EntityObject.prototype.getY = function() { + return this.y; }; -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.EntityObject.prototype.getDirection = function() { + return this.direction; }; -Entry.Container.prototype.mapEntity = function(a, b) { - for (var d = this.objects_.length, c = [], e = 0;e < d;e++) { - c.push(a(this.objects_[e].entity, b)); - } - return c; +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.Container.prototype.mapEntityOnScene = function(a, b) { - for (var d = this.getCurrentObjects(), c = d.length, e = [], f = 0;f < c;f++) { - e.push(a(d[f].entity, b)); - } - return e; +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.Container.prototype.mapEntityIncludeClone = function(a, b) { - for (var d = this.objects_, c = d.length, e = [], f = 0;f < c;f++) { - var g = d[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.EntityObject.prototype.getRotation = function() { + return this.rotation; }; -Entry.Container.prototype.mapEntityIncludeCloneOnScene = function(a, b) { - for (var d = this.getCurrentObjects(), c = d.length, e = [], f = 0;f < c;f++) { - var g = d[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.EntityObject.prototype.setRegX = function(b) { + "textBox" == this.type && (b = 0); + this.regX = b; + this.object.regX = this.regX; + Entry.requestUpdate = !0; }; -Entry.Container.prototype.getCachedPicture = function(a) { - Entry.assert("string" == typeof a, "pictureId must be string"); - return this.cachedPicture[a]; +Entry.EntityObject.prototype.getRegX = function() { + return this.regX; }; -Entry.Container.prototype.cachePicture = function(a, b) { - this.cachedPicture[a] = b; +Entry.EntityObject.prototype.setRegY = function(b) { + "textBox" == this.type && (b = 0); + this.regY = b; + this.object.regY = this.regY; + Entry.requestUpdate = !0; }; -Entry.Container.prototype.toJSON = function() { - for (var a = [], b = this.objects_.length, d = 0;d < b;d++) { - a.push(this.objects_[d].toJSON()); - } - return a; +Entry.EntityObject.prototype.getRegY = function() { + return this.regY; }; -Entry.Container.prototype.takeSequenceSnapshot = function() { - for (var a = this.objects_.length, b = this.objects_, d = 0;d < a;d++) { - b[d].index = d; - } +Entry.EntityObject.prototype.setScaleX = function(b) { + this.scaleX = b; + this.object.scaleX = this.scaleX; + this.parent.updateCoordinateView(); + this.updateDialog(); + Entry.requestUpdate = !0; }; -Entry.Container.prototype.loadSequenceSnapshot = function() { - for (var a = this.objects_.length, b = Array(a), d = 0;d < a;d++) { - var c = this.objects_[d]; - b[c.index || d] = c; - delete c.index; - } - this.objects_ = b; - this.setCurrentObjects(); - Entry.stage.sortZorder(); - this.updateListView(); +Entry.EntityObject.prototype.getScaleX = function() { + return this.scaleX; }; -Entry.Container.prototype.getInputValue = function() { - return this.inputValue.getValue(); +Entry.EntityObject.prototype.setScaleY = function(b) { + this.scaleY = b; + this.object.scaleY = this.scaleY; + this.parent.updateCoordinateView(); + this.updateDialog(); + Entry.requestUpdate = !0; }; -Entry.Container.prototype.setInputValue = function(a) { - this.inputValue.complete || (a ? this.inputValue.setValue(a) : this.inputValue.setValue(0), Entry.stage.hideInputField(), Entry.console && Entry.console.stopInput(a), this.inputValue.complete = !0); +Entry.EntityObject.prototype.getScaleY = function() { + return this.scaleY; }; -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.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.Container.prototype.setCopiedObject = function(a) { - this.copiedObject = a; +Entry.EntityObject.prototype.getSize = function() { + return (this.getWidth() * Math.abs(this.getScaleX()) + this.getHeight() * Math.abs(this.getScaleY())) / 2; }; -Entry.Container.prototype.updateObjectsOrder = function() { - for (var a = Entry.scene.getScenes(), b = [], d = 0;d < a.length;d++) { - for (var c = this.getSceneObjects(a[d]), e = 0;e < c.length;e++) { - b.push(c[e]); - } - } - this.objects_ = b; +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.Container.prototype.getSceneObjects = function(a) { - a = a || Entry.scene.selectedScene; - for (var b = [], d = this.getAllObjects(), c = 0;c < d.length;c++) { - a.id == d[c].scene.id && b.push(d[c]); - } - return b; +Entry.EntityObject.prototype.getWidth = function() { + return this.width; }; -Entry.Container.prototype.setCurrentObjects = function() { - this.currentObjects_ = this.getSceneObjects(); +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.Container.prototype.getCurrentObjects = function() { - var a = this.currentObjects_; - a && 0 !== a.length || this.setCurrentObjects(); - return this.currentObjects_; +Entry.EntityObject.prototype.getHeight = function() { + return this.height; }; -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.EntityObject.prototype.setColour = function(b) { + b || (b = "#000000"); + this.colour = b; + this.textObject && (this.textObject.color = this.colour); + Entry.requestUpdate = !0; }; -Entry.Container.prototype.blurAllInputs = function() { - this.getSceneObjects().map(function(a) { - a = a.view_.getElementsByTagName("input"); - for (var b = 0, d = a.length;b < d;b++) { - a[b].blur(); - } - }); +Entry.EntityObject.prototype.getColour = function() { + return this.colour; }; -Entry.Container.prototype.showProjectAnswer = function() { - var a = this.inputValue; - a && a.setVisible(!0); +Entry.EntityObject.prototype.setBGColour = function(b) { + b || (b = "transparent"); + this.bgColor = b; + this.updateBG(); + Entry.requestUpdate = !0; }; -Entry.Container.prototype.hideProjectAnswer = function(a) { - if ((a = this.inputValue) && a.isVisible() && !Entry.engine.isState("run")) { - for (var b = Entry.container.getAllObjects(), d = ["ask_and_wait", "get_canvas_input_value", "set_visible_answer"], c = 0, e = b.length;c < e;c++) { - for (var f = b[c].script, g = 0;g < d.length;g++) { - if (f.hasBlockType(d[g])) { - return; - } - } - } - a.setVisible(!1); - } +Entry.EntityObject.prototype.getBGColour = function() { + return this.bgColor; }; -Entry.Container.prototype.getView = function() { - return this._view; +Entry.EntityObject.prototype.setUnderLine = function(b) { + void 0 === b && (b = !1); + this.underLine = b; + this.textObject.underLine = b; + Entry.requestUpdate = !0; }; -Entry.Container.prototype.resize = function() { +Entry.EntityObject.prototype.getUnderLine = function() { + return this.underLine; }; -Entry.Container.prototype._rightClick = function(a) { - a.stopPropagation && a.stopPropagation(); - var 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", {x:a.clientX, y:a.clientY}); +Entry.EntityObject.prototype.setStrike = function(b) { + void 0 === b && (b = !1); + this.strike = b; + this.textObject.strike = b; + Entry.requestUpdate = !0; }; -Entry.Container.prototype.removeFuncBlocks = function(a) { - this.objects_.forEach(function(b) { - b.script.removeBlocksByType(a); - }); +Entry.EntityObject.prototype.getStrike = function() { + return this.strike; }; -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 d = /<(\w+)>/, c; - c = a instanceof HTMLElement ? $(a) : a instanceof jQuery ? a : d.test(a) ? $(a) : $("<" + a + ">"); - if (void 0 === b) { - return c; +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(" "), d = 0; + if (d = -1 < a.indexOf("bold")) { + a.splice(d - 1, 1), this.setFontBold(!0); + } + if (d = -1 < a.indexOf("italic")) { + a.splice(d - 1, 1), this.setFontItalic(!0); + } + d = parseInt(a.shift()); + this.setFontSize(d); + this.setFontType(a.join(" ")); + this.font = this.getFont(); + this.textObject.font = b; + Entry.stage.update(); + this.setWidth(this.textObject.getMeasuredWidth()); + this.updateBG(); + Entry.stage.updateObject(); } - b.id && c.attr("id", b.id); - b.class && c.addClass(b.class); - b.classes && b.classes.map(function(b) { - c.addClass(b); - }); - b.src && c.attr("src", b.src); - b.parent && b.parent.append(c); - c.bindOnClick = function() { - var b, a, d = 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, d); - } else { - $(this).on("click tab", d); - } - }; - return c; }; -Entry.SVG = function(a) { - a = document.getElementById(a); - return Entry.SVG.createElement(a); +Entry.EntityObject.prototype.setLineHeight = function() { + switch(this.getFontType()) { + case "Nanum Gothic Coding": + this.textObject.lineHeight = this.fontSize; + break; + default: + this.textObject.lineHeight = 0; + } }; -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 d in b) { - a.setAttribute(d, b[d]); - } - } - 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.EntityObject.prototype.syncFont = function() { + this.textObject.font = this.getFont(); + this.setLineHeight(); + Entry.stage.update(); + this.getLineBreak() || this.setWidth(this.textObject.getMeasuredWidth()); + Entry.stage.updateObject(); + Entry.requestUpdate = !0; }; -Entry.SVG.attr = function(a, b) { - if ("string" === typeof a) { - var d = {}; - d[a] = b; - a = d; +Entry.EntityObject.prototype.getFontType = function() { + return this.fontType; +}; +Entry.EntityObject.prototype.setFontType = function(b) { + "textBox" == this.parent.objectType && (this.fontType = b ? b : "Nanum Gothic", this.syncFont()); +}; +Entry.EntityObject.prototype.getFontSize = function(b) { + return this.fontSize; +}; +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(b) { + this.fontBold = b; + Entry.requestUpdate = !0; +}; +Entry.EntityObject.prototype.toggleFontBold = function() { + this.fontBold = !this.fontBold; + this.syncFont(); + return this.fontBold; +}; +Entry.EntityObject.prototype.setFontItalic = function(b) { + this.fontItalic = b; + Entry.requestUpdate = !0; +}; +Entry.EntityObject.prototype.toggleFontItalic = function() { + this.fontItalic = !this.fontItalic; + this.syncFont(); + return this.fontItalic; +}; +Entry.EntityObject.prototype.setFontName = function(b) { + for (var a = this.font.split(" "), d = [], c = 0, e = a.length;c < e;c++) { + ("bold" === a[c] || "italic" === a[c] || -1 < a[c].indexOf("px")) && d.push(a[c]); } - if (a) { - a.href && (this.setAttributeNS(Entry.SVG.NS_XLINK, "href", a.href), delete a.href); - for (var c in a) { - this.setAttribute(c, a[c]); + this.setFont(d.join(" ") + " " + b); +}; +Entry.EntityObject.prototype.getFontName = function() { + if ("textBox" == this.type) { + if (!this.font) { + return ""; + } + for (var b = this.font.split(" "), a = [], d = 0, c = b.length;d < c;d++) { + "bold" !== b[d] && "italic" !== b[d] && -1 === b[d].indexOf("px") && a.push(b[d]); } + return a.join(" ").trim(); } - return this; }; -Entry.SVG.addClass = function(a) { - for (var b = this.getAttribute("class"), d = 0;d < arguments.length;d++) { - a = arguments[d], this.hasClass(a) || (b += " " + a); - } - this.setAttribute("class", b); - return this; +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.SVG.removeClass = function(a) { - for (var b = this.getAttribute("class"), d = 0;d < arguments.length;d++) { - a = arguments[d], this.hasClass(a) && (b = b.replace(new RegExp("(\\s|^)" + a + "(\\s|$)"), " ")); - } - this.setAttribute("class", b); - return this; +Entry.EntityObject.prototype.getText = function() { + return this.text; }; -Entry.SVG.hasClass = function(a) { - var b = this.getAttribute("class"); - return b ? b.match(new RegExp("(\\s|^)" + a + "(\\s|$)")) : !1; +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.SVG.remove = function() { - this.parentNode && this.parentNode.removeChild(this); +Entry.EntityObject.prototype.getTextAlign = function() { + return this.textAlign; }; -Entry.SVG.removeAttr = function(a) { - this.removeAttribute(a); +Entry.EntityObject.prototype.setLineBreak = function(b) { + if ("textBox" == this.parent.objectType) { + 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.Dialog = function(a, b, d, c) { - a.dialog && a.dialog.remove(); - a.dialog = this; - this.parent = a; - this.padding = 10; - this.border = 2; - "number" == typeof b && (b = String(b)); - Entry.console && Entry.console.print(b, d); - this.message_ = b = b.match(/.{1,15}/g).join("\n"); - this.mode_ = d; - "speak" !== d && "ask" !== d || this.generateSpeak(); - c || Entry.stage.loadDialog(this); +Entry.EntityObject.prototype.getLineBreak = function() { + return this.lineBreak; }; -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(), d = b.height, b = 10 <= b.width ? b.width : 17, c = new createjs.Shape; - c.graphics.f("#f5f5f5").ss(2, "round").s("#6FC0DD").rr(-this.padding, -this.padding, b + 2 * this.padding, d + 2 * this.padding, this.padding); - this.object.addChild(c); - this.object.regX = b / 2; - this.object.regY = d / 2; - this.width = b; - this.height = d; - this.notch = this.createSpeakNotch("ne"); - this.update(); - this.object.addChild(this.notch); - this.object.addChild(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; + return this.visible; }; -Entry.Dialog.prototype.update = function() { - var a = this.parent.object.getTransformedBounds(); - if (!a && "textBox" === this.parent.type) { - if (this._isNoContentTried) { - delete this._isNoContentTried; - return; +Entry.EntityObject.prototype.getVisible = function() { + return this.visible; +}; +Entry.EntityObject.prototype.setImage = function(b) { + var a = this; + delete b._id; + Entry.assert("sprite" == this.type, "Set image is only for sprite object"); + b.id || (b.id = Entry.generateHash()); + this.picture = b; + var d = this.picture.dimension, c = this.getRegX() - this.getWidth() / 2, e = this.getRegY() - this.getHeight() / 2; + this.setWidth(d.width); + this.setHeight(d.height); + d.scaleX || (d.scaleX = this.getScaleX(), d.scaleY = this.getScaleY()); + this.setScaleX(this.scaleX); + this.setScaleY(this.scaleY); + this.setRegX(this.width / 2 + c); + this.setRegY(this.height / 2 + e); + var f = b.id + this.id, g = Entry.container.getCachedPicture(f); + g ? (Entry.image = g, this.object.image = g, this.object.cache(0, 0, this.getWidth(), this.getHeight())) : (g = new Image, b.fileurl ? g.src = b.fileurl : (b = b.filename, g.src = Entry.defaultPath + "/uploads/" + b.substring(0, 2) + "/" + b.substring(2, 4) + "/image/" + b + ".png"), this.object.image = g, this.object.cache(0, 0, this.getWidth(), this.getHeight()), g.onload = function(b) { + Entry.container.cachePicture(f, g); + Entry.image = g; + a.object.image = g; + a.object.cache(0, 0, a.getWidth(), a.getHeight()); + Entry.requestUpdate = !0; + }); + Entry.dispatchEvent("updateObject"); +}; +Entry.EntityObject.prototype.applyFilter = function(b) { + function a(a, b) { + for (var d in a) { + if (a[d] !== b[d]) { + return !1; + } } - this.parent.setText(" "); - a = this.parent.object.getTransformedBounds(); - this._isNoContentTried = !0; + return !0; } - var 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)); - this._isNoContentTried && this.parent.setText(""); + var d = this.effect, c = this.object; + if (b || !a(d, this.getInitialEffectValue())) { + (function(a, b) { + var d = [], c = Entry.adjustValueWithMaxMin; + a.brightness = a.brightness; + var k = new createjs.ColorMatrix; + k.adjustColor(c(a.brightness, -100, 100), 0, 0, 0); + k = new createjs.ColorMatrixFilter(k); + d.push(k); + a.hue = a.hue.mod(360); + k = new createjs.ColorMatrix; + k.adjustColor(0, 0, 0, a.hue); + k = new createjs.ColorMatrixFilter(k); + d.push(k); + var k = [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], l = 10.8 * a.hsv * Math.PI / 180, m = Math.cos(l), l = Math.sin(l), n = Math.abs(a.hsv / 100); + 1 < n && (n -= Math.floor(n)); + 0 < n && .33 >= n ? k = [1, 0, 0, 0, 0, 0, m, l, 0, 0, 0, -1 * l, m, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1] : .66 >= n ? k = [m, 0, l, 0, 0, 0, 1, 0, 0, 0, l, 0, m, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1] : .99 >= n && (k = [m, l, 0, 0, 0, -1 * l, m, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]); + k = (new createjs.ColorMatrix).concat(k); + k = new createjs.ColorMatrixFilter(k); + d.push(k); + b.alpha = a.alpha = c(a.alpha, 0, 1); + b.filters = d; + })(d, c), c.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.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.EntityObject.prototype.takeSnapshot = function() { + this.snapshot_ = this.toJSON(); + this.collision = Entry.Utils.COLLISION.NONE; }; -Entry.Dialog.prototype.remove = function() { - Entry.stage.unloadDialog(this); - this.parent.dialog = null; +Entry.EntityObject.prototype.loadSnapshot = function() { + this.snapshot_ && this.syncModel_(this.snapshot_); + "sprite" == this.parent.objectType && this.setImage(this.parent.getPicture()); Entry.requestUpdate = !0; }; -Entry.DoneProject = function(a) { - this.generateView(a); +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(); + } }; -var p = Entry.DoneProject.prototype; -p.init = function(a) { - this.projectId = a; +Entry.EntityObject.prototype.clearExecutor = function() { + this.parent.script.clearExecutorsByEntity(this); }; -p.generateView = function(a) { - var b = Entry.createElement("div"); - b.addClass("entryContainerDoneWorkspace"); - this.doneContainer = b; - var d = Entry.createElement("iframe"); - d.setAttribute("id", "doneProjectframe"); - d.setAttribute("frameborder", 0); - d.setAttribute("src", "/api/iframe/project/" + a); - this.doneProjectFrame = d; - this.doneContainer.appendChild(d); - b.addClass("entryRemove"); +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; }; -p.getView = function() { - return this.doneContainer; +Entry.EntityObject.prototype.setInitialEffectValue = function() { + this.effect = this.getInitialEffectValue(); + Entry.requestUpdate = !0; }; -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.EntityObject.prototype.getInitialEffectValue = function() { + return {blur:0, hue:0, hsv:0, brightness:0, contrast:0, saturation:0, alpha:1}; }; -Entry.Engine = function() { - function a(b) { - var a = [37, 38, 39, 40, 32], c = b.keyCode || b.which, e = Entry.stage.inputField; - 32 == c && e && e.hasFocus() || -1 < a.indexOf(c) && b.preventDefault(); - } - this.state = "stop"; - this.popup = null; - this.isUpdating = !0; - this.speeds = [1, 15, 30, 45, 60]; - this._mouseMoved = !1; - Entry.keyPressed && Entry.keyPressed.attach(this, this.captureKeyEvent); - Entry.addEventListener("canvasClick", function(b) { - Entry.engine.fireEvent("mouse_clicked"); - }); - Entry.addEventListener("canvasClickCanceled", function(b) { - Entry.engine.fireEvent("mouse_click_cancled"); - }); - Entry.addEventListener("entityClick", function(b) { - Entry.engine.fireEventOnEntity("when_object_click", b); - }); - Entry.addEventListener("entityClickCanceled", function(b) { - Entry.engine.fireEventOnEntity("when_object_click_canceled", b); - }); - "phone" != Entry.type && (Entry.addEventListener("stageMouseMove", function(b) { - this._mouseMoved = !0; - }.bind(this)), Entry.addEventListener("stageMouseOut", function(b) { - Entry.engine.hideMouseView(); - })); - Entry.addEventListener("run", function() { - $(window).bind("keydown", a); - }); - Entry.addEventListener("stop", function() { - $(window).unbind("keydown", a); - }); - setInterval(function() { - this._mouseMoved && (this.updateMouseView(), this._mouseMoved = !1); - }.bind(this), 100); +Entry.EntityObject.prototype.removeBrush = function() { + Entry.stage.selectedObjectContainer.removeChild(this.shape); + this.shape = this.brush = null; }; -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.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.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.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.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) { - 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) { - Entry.engine.footerView_.addClass("entryRemove"); - Entry.engine.headerView_.addClass("entryRemove"); - Entry.launchFullScreen(Entry.engine.view_); - }), document.addEventListener("fullscreenchange", function(b) { - Entry.engine.exitFullScreen(); - }), document.addEventListener("webkitfullscreenchange", function(b) { - Entry.engine.exitFullScreen(); - }), document.addEventListener("mozfullscreenchange", function(b) { - 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) { - 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) { - Entry.engine.toggleStop(); - })); - } else { - this.view_ = a; - this.view_.addClass("entryEngine_w"); - this.view_.addClass("entryEngineWorkspace_w"); - var d = Entry.createElement("button"); - this.speedButton = d; - this.speedButton.addClass("entrySpeedButtonWorkspace", "entryEngineTopWorkspace", "entryEngineButtonWorkspace_w"); - this.view_.appendChild(this.speedButton); - this.speedButton.bindOnClick(function(b) { - Entry.engine.toggleSpeedPanel(); - d.blur(); - }); - this.maximizeButton = Entry.createElement("button"); - this.maximizeButton.addClass("entryEngineButtonWorkspace_w", "entryEngineTopWorkspace", "entryMaximizeButtonWorkspace_w"); - this.view_.appendChild(this.maximizeButton); - this.maximizeButton.bindOnClick(function(b) { - Entry.engine.toggleFullscreen(); - this.blur(); - }); - var c = Entry.createElement("button"); - this.coordinateButton = c; - this.coordinateButton.addClass("entryEngineButtonWorkspace_w", "entryEngineTopWorkspace", "entryCoordinateButtonWorkspace_w"); - this.view_.appendChild(this.coordinateButton); - this.coordinateButton.bindOnClick(function(b) { - this.hasClass("toggleOn") ? this.removeClass("toggleOn") : this.addClass("toggleOn"); - c.blur(); - this.blur(); - Entry.stage.toggleCoordinator(); - }); - this.addButton = Entry.createElement("button"); - this.addButton.addClass("entryEngineButtonWorkspace_w"); - this.addButton.addClass("entryAddButtonWorkspace_w"); - this.addButton.innerHTML = Lang.Workspace.add_object; - this.addButton.bindOnClick(function(b) { - Entry.dispatchEvent("openSpriteManager"); - this.blur(); - }); - this.view_.appendChild(this.addButton); - this.runButton = Entry.createElement("button"); - this.runButton.addClass("entryEngineButtonWorkspace_w"); - this.runButton.addClass("entryRunButtonWorkspace_w"); - this.runButton.innerHTML = Lang.Workspace.run; - this.view_.appendChild(this.runButton); - this.runButton.bindOnClick(function(b) { - Entry.engine.toggleRun(); - this.blur(); - }); - 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.blur(); - Entry.engine.toggleRun(); - }); - this.stopButton = Entry.createElement("button"); - this.stopButton.addClass("entryEngineButtonWorkspace_w"); - this.stopButton.addClass("entryStopButtonWorkspace_w"); - this.stopButton.addClass("entryRemove"); - this.stopButton.innerHTML = Lang.Workspace.stop; - this.view_.appendChild(this.stopButton); - this.stopButton.bindOnClick(function(b) { - this.blur(); - Entry.engine.toggleStop(); - }); - this.stopButton2 = Entry.createElement("button"); - this.stopButton2.addClass("entryEngineButtonWorkspace_w"); - this.stopButton2.addClass("entryStopButtonWorkspace_w2"); - this.stopButton2.addClass("entryRemove"); - this.stopButton2.innerHTML = Lang.Workspace.stop; - this.view_.appendChild(this.stopButton2); - this.stopButton2.bindOnClick(function(b) { - this.blur(); - Entry.engine.toggleStop(); - }); - this.pauseButton = Entry.createElement("button"); - this.pauseButton.addClass("entryEngineButtonWorkspace_w"); - this.pauseButton.addClass("entryPauseButtonWorkspace_w"); - this.pauseButton.addClass("entryRemove"); - this.view_.appendChild(this.pauseButton); - this.pauseButton.bindOnClick(function(b) { - this.blur(); - Entry.engine.togglePause(); - }); - this.mouseView = Entry.createElement("div"); - this.mouseView.addClass("entryMouseViewWorkspace_w"); - this.mouseView.addClass("entryRemove"); - this.view_.appendChild(this.mouseView); +Entry.EntityObject.prototype.updateBG = function() { + if (this.bgObject) { + this.bgObject.graphics.clear(); + var b = this.getWidth(), a = this.getHeight(); + this.bgObject.graphics.setStrokeStyle(1).beginStroke().beginFill(this.getBGColour()).drawRect(-b / 2, -a / 2, b, a); + if (this.getLineBreak()) { + this.bgObject.x = 0; + } else { + switch(this.getTextAlign()) { + case Entry.TEXT_ALIGN_LEFT: + this.bgObject.x = b / 2; + break; + case Entry.TEXT_ALIGN_CENTER: + this.bgObject.x = 0; + break; + case Entry.TEXT_ALIGN_RIGHT: + this.bgObject.x = -b / 2; + } + } } }; -Entry.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).remove(); - delete this.speedProgress_; - }), $(this.speedHandle_).remove(), delete this.speedHandle_; - } else { - this.speedPanelOn = !0; - $(Entry.stage.canvas.canvas).animate({top:"41px"}); - this.coordinateButton.addClass("entryRemove"); - this.maximizeButton.addClass("entryRemove"); - this.mouseView.addClass("entryRemoveElement"); - this.speedLabel_ = Entry.createElement("div", "entrySpeedLabelWorkspace"); - 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, d = 0;5 > d;d++) { - (function(d) { - var c = Entry.createElement("td", "progressCell" + d); - c.bindOnClick(function() { - Entry.engine.setSpeedMeter(b[d]); - }); - a.appendChild(c); - })(d); - } - this.view_.insertBefore(this.speedProgress_, this.maximizeButton); - this.speedProgress_.appendChild(a); - this.speedHandle_ = Entry.createElement("div", "entrySpeedHandleWorkspace"); - var c = (Entry.interfaceState.canvasWidth - 84) / 5; - $(this.speedHandle_).bind("mousedown.speedPanel touchstart.speedPanel", function(b) { - function a(b) { - b.stopPropagation(); - b = Entry.Utils.convertMouseEvent(b); - b = Math.floor((b.clientX - 80) / (5 * c) * 5); - 0 > b || 4 < b || Entry.engine.setSpeedMeter(Entry.engine.speeds[b]); - } - function d(b) { - $(document).unbind(".speedPanel"); - } - b.stopPropagation && b.stopPropagation(); - b.preventDefault && b.preventDefault(); - if (0 === b.button || b.originalEvent && b.originalEvent.touches) { - Entry.Utils.convertMouseEvent(b), b = $(document), b.bind("mousemove.speedPanel touchmove.speedPanel", a), b.bind("mouseup.speedPanel touchend.speedPanel", d); +Entry.EntityObject.prototype.alignTextBox = function() { + if ("textBox" == this.type) { + var b = this.textObject; + if (this.lineBreak) { + var a = b.getMeasuredLineHeight(); + b.y = a / 2 - this.getHeight() / 2; + switch(this.textAlign) { + case Entry.TEXT_ALIGN_CENTER: + b.x = 0; + break; + case Entry.TEXT_ALIGN_LEFT: + b.x = -this.getWidth() / 2; + break; + case Entry.TEXT_ALIGN_RIGHT: + b.x = this.getWidth() / 2; } - }); - this.view_.insertBefore(this.speedHandle_, this.maximizeButton); - this.setSpeedMeter(Entry.FPS); + b.maxHeight = this.getHeight(); + } else { + b.x = 0, b.y = 0; + } } }; -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.EntityObject.prototype.syncDialogVisible = function() { + this.dialog && (this.dialog.object.visible = this.visible); }; -Entry.Engine.prototype.update = function() { - Entry.engine.isState("run") && (Entry.engine.computeObjects(), Entry.hw.update()); +Entry.Helper = function() { + this.visible = !1; }; -Entry.Engine.prototype.computeObjects = function() { - Entry.container.mapObjectOnScene(this.computeFunction); +p = Entry.Helper.prototype; +p.generateView = function(b, a) { + if (!this.parentView_) { + this.parentView_ = b; + this.blockHelpData = EntryStatic.blockInfo; + var d = Entry.createElement("div", "entryBlockHelperWorkspace"); + this.view = d; + Entry.isForLecture && d.addClass("lecture"); + this.parentView_.appendChild(d); + var c = Entry.createElement("div", "entryBlockHelperContentWorkspace"); + c.addClass("entryBlockHelperIntro"); + Entry.isForLecture && c.addClass("lecture"); + d.appendChild(c); + this.blockHelperContent_ = c; + this.blockHelperView_ = d; + d = Entry.createElement("div", "entryBlockHelperBlockWorkspace"); + this.blockHelperContent_.appendChild(d); + c = Entry.createElement("div", "entryBlockHelperDescriptionWorkspace"); + this.blockHelperContent_.appendChild(c); + c.innerHTML = Lang.Helper.Block_click_msg; + this.blockHelperDescription_ = c; + this._renderView = new Entry.RenderView($(d), "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.Engine.prototype.computeFunction = function(a) { - a.script.tick(); +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); + } }; -Entry.Engine.computeThread = function(a, b) { - Entry.engine.isContinue = !0; - for (a = !1;b && Entry.engine.isContinue && !a;) { - Entry.engine.isContinue = !b.isRepeat; - var d = b.run(); - a = d && d === b; - b = d; +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 d = Entry.block[b].def, d = d || {type:b}; + this.code.createThread([d]); + this.code.board.align(); + this.code.board.resize(); + var d = this.code.getThreads()[0].getFirstBlock().view, c = d.svgGroup.getBBox(); + b = c.width; + c = c.height; + d = d.getSkeleton().box(d).offsetX; + isNaN(d) && (d = 0); + this.blockHelperDescription_.innerHTML = a; + this._renderView.align(); + $(this.blockHelperDescription_).css({top:c + 30}); + this._renderView.svgDom.css({"margin-left":-(b / 2) - 20 - d}); } - return b; }; -Entry.Engine.prototype.isState = function(a) { - return -1 < this.state.indexOf(a); +p.getView = function() { + return this.view; }; -Entry.Engine.prototype.run = function() { - this.isState("run") ? this.toggleStop() : (this.isState("stop") || this.isState("pause")) && this.toggleRun(); +p.resize = function() { }; -Entry.Engine.prototype.toggleRun = function() { - if ("pause" === this.state) { - this.togglePause(); - } else { - if (Entry.playground && Entry.playground.mainWorkspace) { - var a = Entry.playground.mainWorkspace, b = a.mode; - b == Entry.Workspace.MODE_VIMBOARD && a.loadCodeFromText(b); +Entry.Activity = function(b, a) { + this.name = b; + this.timestamp = new Date; + var d = []; + if (void 0 !== a) { + for (var c = 0, e = a.length;c < e;c++) { + var f = a[c]; + d.push({key:f[0], value:f[1]}); } - 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"); } + this.data = d; }; -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(); - }); - b.mapVariable(function(b) { - b.loadSnapshot(); - }); - b.mapList(function(b) { - b.loadSnapshot(); - b.updateView(); - }); - this.stopProjectTimer(); - a.clearRunningState(); - a.loadSequenceSnapshot(); - this.projectTimer.loadSnapshot(); - Entry.container.inputValue.loadSnapshot(); - Entry.scene.loadStartSceneSnapshot(); - Entry.Func.clearThreads(); - createjs.Sound.setVolume(1); - createjs.Sound.stop(); - this.view_.removeClass("entryEngineBlueWorkspace"); - this.runButton.removeClass("entryRemove"); - this.stopButton.addClass("entryRemove"); - this.pauseButton && this.pauseButton.addClass("entryRemove"); - this.runButton2 && this.runButton2.removeClass("entryRemove"); - this.stopButton2 && this.stopButton2.addClass("entryRemove"); - this.state = "stop"; - Entry.dispatchEvent("stop"); - 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, - 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.raiseEvent = function(a, b) { - a.parent.script.raiseEvent(b, a); -}; -Entry.Engine.prototype.fireEventOnEntity = function(a, b) { - "run" == this.state && Entry.container.mapEntityIncludeCloneOnScene(this.raiseEventOnEntity, [b, a]); -}; -Entry.Engine.prototype.raiseEventOnEntity = function(a, b) { - a === b[0] && a.parent.script.raiseEvent(b[1], a); +Entry.ActivityReporter = function() { + this._activities = []; }; -Entry.Engine.prototype.captureKeyEvent = function(a) { - var b = a.keyCode, d = Entry.type; - a.ctrlKey && "workspace" == d ? 83 == b ? (a.preventDefault(), Entry.dispatchEvent("saveWorkspace")) : 82 == b ? (a.preventDefault(), Entry.engine.run()) : 90 == b && (a.preventDefault(), Entry.dispatchEvent(a.shiftKey ? "redo" : "undo")) : Entry.engine.isState("run") && Entry.container.mapEntityIncludeCloneOnScene(Entry.engine.raiseKeyEvent, ["keyPress", b]); - Entry.engine.isState("stop") && "workspace" === d && 37 <= b && 40 >= b && Entry.stage.moveSprite(a); +(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); + } + this._activities.push(a); + } + }; + b.clear = function() { + this._activities = []; + }; + b.get = function() { + return this._activities; + }; + b.report = function() { + }; +})(Entry.ActivityReporter.prototype); +Entry.State = function(b, a, d, c) { + this.caller = a; + this.func = d; + 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.Engine.prototype.raiseKeyEvent = function(a, b) { - return a.parent.script.raiseEvent(b[0], a, String(b[1])); +Entry.State.prototype.generateMessage = function() { }; -Entry.Engine.prototype.updateMouseView = function() { - var a = Entry.stage.mouseCoordinate; - this.mouseView.textContent = "X : " + a.x + ", Y : " + a.y; - this.mouseView.removeClass("entryRemove"); +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.Engine.prototype.hideMouseView = function() { - this.mouseView.addClass("entryRemove"); +Entry.StateManager.prototype.generateView = function(b, a) { }; -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.runButton[0]); +Entry.StateManager.prototype.addCommand = function(b, a, d, c) { + 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(); } - popup.window_.appendChild(Entry.engine.view_); + Entry.creationChangedEvent && Entry.creationChangedEvent.notify(); } - 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.StateManager.prototype.cancelLastCommand = function() { + this.canUndo() && (this.undoStack_.pop(), this.updateView(), Entry.creationChangedEvent && Entry.creationChangedEvent.notify()); }; -Entry.Engine.prototype.showProjectTimer = function() { - Entry.engine.projectTimer && this.projectTimer.setVisible(!0); +Entry.StateManager.prototype.getLastCommand = function() { + return this.undoStack_[this.undoStack_.length - 1]; }; -Entry.Engine.prototype.hideProjectTimer = function() { - var a = this.projectTimer; - if (a && a.isVisible() && !this.isState("run")) { - for (var b = Entry.container.getAllObjects(), d = ["get_project_timer_value", "reset_project_timer", "set_visible_project_timer", "choose_project_timer_action"], c = 0, e = b.length;c < e;c++) { - for (var f = b[c].script, g = 0;g < d.length;g++) { - if (f.hasBlockType(d[g])) { - return; - } +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; } } - a.setVisible(!1); + this.updateView(); + this.endRestore(); + Entry.creationChangedEvent && Entry.creationChangedEvent.notify(); } }; -Entry.Engine.prototype.clearTimer = function() { - clearInterval(this.ticker); - 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) { - 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)); -}; -Entry.Engine.prototype.updateProjectTimer = function(a) { - var b = Entry.engine, d = b.projectTimer; - if (d) { - var c = (new Date).getTime(); - "undefined" == typeof a ? d.isPaused || b.isState("pause") || d.setValue((c - d.start - d.pausedTime) / 1E3) : (d.setValue(a), d.pausedTime = 0, d.start = c); +Entry.StateManager.prototype.redo = function() { + if (this.canRedo() && !this.isRestoring()) { + for (this.addActivity("redo");this.redoStack_.length;) { + var b = this.redoStack_.pop(); + b.func.apply(b.caller, b.params); + if (!0 !== b.isPass) { + break; + } + } + this.updateView(); + Entry.creationChangedEvent && Entry.creationChangedEvent.notify(); } }; -Entry.EntityObject = function(a) { - this.parent = a; - this.type = a.objectType; - this.flip = !1; - this.collision = Entry.Utils.COLLISION.NONE; - this.id = Entry.generateHash(); - "sprite" == this.type ? (this.object = new createjs.Bitmap, this.effect = {}, this.setInitialEffectValue()) : "textBox" == this.type && (this.object = new createjs.Container, this.textObject = new createjs.Text, this.textObject.font = "20px Nanum Gothic", this.textObject.textBaseline = "middle", this.textObject.textAlign = "center", this.bgObject = new createjs.Shape, this.bgObject.graphics.setStrokeStyle(1).beginStroke("#f00").drawRect(0, 0, 100, 100), this.object.addChild(this.bgObject), this.object.addChild(this.textObject), - 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; - 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)); - }); - this.object.on("pressup", function(b) { - 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()); - }); -}; -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.initCommand = function() { - Entry.engine.isState("stop") && (this.isCommandValid = !1, Entry.stateManager && Entry.stateManager.addCommand("edit entity", this, this.restoreEntity, this.toJSON())); -}; -Entry.EntityObject.prototype.doCommand = function() { - this.isCommandValid = !0; -}; -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.dispatchEvent("updateObject"); - Entry.stateManager && Entry.stateManager.addCommand("restore object", this, this.restoreEntity, b); -}; -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.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.getY = function() { - return this.y; -}; -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); - 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.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.EntityObject.prototype.setRegX = function(a) { - "textBox" == this.type && (a = 0); - this.regX = a; - this.object.regX = this.regX; - Entry.requestUpdate = !0; +Entry.StateManager.prototype.startRestore = function() { + this.isRestore = !0; }; -Entry.EntityObject.prototype.getRegX = function() { - return this.regX; +Entry.StateManager.prototype.endRestore = function() { + this.isRestore = !1; }; -Entry.EntityObject.prototype.setRegY = function(a) { - "textBox" == this.type && (a = 0); - this.regY = a; - this.object.regY = this.regY; - Entry.requestUpdate = !0; +Entry.StateManager.prototype.isRestoring = function() { + return this.isRestore; }; -Entry.EntityObject.prototype.getRegY = function() { - return this.regY; +Entry.StateManager.prototype.startIgnore = function() { + this.isIgnore = !0; }; -Entry.EntityObject.prototype.setScaleX = function(a) { - this.scaleX = a; - this.object.scaleX = this.scaleX; - this.parent.updateCoordinateView(); - this.updateDialog(); - Entry.requestUpdate = !0; +Entry.StateManager.prototype.endIgnore = function() { + this.isIgnore = !1; }; -Entry.EntityObject.prototype.getScaleX = function() { - return this.scaleX; +Entry.StateManager.prototype.isIgnoring = function() { + return this.isIgnore; }; -Entry.EntityObject.prototype.setScaleY = function(a) { - this.scaleY = a; - this.object.scaleY = this.scaleY; - this.parent.updateCoordinateView(); - this.updateDialog(); - Entry.requestUpdate = !0; +Entry.StateManager.prototype.canUndo = function() { + return 0 < this.undoStack_.length && Entry.engine.isState("stop"); }; -Entry.EntityObject.prototype.getScaleY = function() { - return this.scaleY; +Entry.StateManager.prototype.canRedo = function() { + return 0 < this.redoStack_.length && Entry.engine.isState("stop"); }; -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.StateManager.prototype.addStamp = function() { + this.stamp = Entry.generateHash(); + this.undoStack_.length && (this.undoStack_[this.undoStack_.length - 1].stamp = this.stamp); }; -Entry.EntityObject.prototype.getSize = function() { - return (this.getWidth() * Math.abs(this.getScaleX()) + this.getHeight() * Math.abs(this.getScaleY())) / 2; +Entry.StateManager.prototype.isSaved = function() { + return 0 === this.undoStack_.length || this.undoStack_[this.undoStack_.length - 1].stamp == this.stamp && "string" == typeof this.stamp; }; -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.StateManager.prototype.addActivity = function(b) { + Entry.reporter && Entry.reporter.report(new Entry.State(b)); }; -Entry.EntityObject.prototype.getWidth = function() { - return this.width; +Entry.EntryObject = function(b) { + var a = this; + 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 d = 0;d < this.sounds.length;d++) { + this.sounds[d].id || (this.sounds[d].id = Entry.generateHash()), Entry.initSound(this.sounds[d]); + } + 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 (d in this.pictures) { + (function(b) { + b.objectId = this.id; + b.id || (b.id = Entry.generateHash()); + var d = new Image; + if (b.fileurl) { + d.src = b.fileurl; + } else { + if (b.fileurl) { + d.src = b.fileurl; + } else { + var f = b.filename; + d.src = Entry.defaultPath + "/uploads/" + f.substring(0, 2) + "/" + f.substring(2, 4) + "/image/" + f + ".png"; + } + } + Entry.Loader.addQueue(); + d.onload = function(d) { + Entry.container.cachePicture(b.id + a.entity.id, this); + Entry.requestUpdate = !0; + Entry.Loader.removeQueue(); + }; + d.onerror = function(a) { + Entry.Loader.removeQueue(); + }; + })(this.pictures[d]); + } + } }; -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.EntryObject.prototype.generateView = function() { + if ("workspace" == Entry.type) { + var b = Entry.createElement("li", this.id); + b.addClass("entryContainerListElementWorkspace"); + b.object = this; + Entry.Utils.disableContextmenu(b); + var a = this; + longPressTimer = null; + $(b).bind("mousedown touchstart", function(b) { + function d(a) { + a.stopPropagation(); + h && 5 < Math.sqrt(Math.pow(a.pageX - h.x, 2) + Math.pow(a.pageY - h.y, 2)) && longPressTimer && (clearTimeout(longPressTimer), longPressTimer = null); + } + function c(a) { + a.stopPropagation(); + e.unbind(".object"); + longPressTimer && (clearTimeout(longPressTimer), longPressTimer = null); + } + Entry.container.getObject(this.id) && Entry.container.selectObject(this.id); + var e = $(document), f = b.type, g = !1; + if (Entry.Utils.isRightButton(b)) { + b.stopPropagation(), Entry.documentMousedown.notify(b), g = !0, a._rightClick(b); + } else { + var h = {x:b.clientX, y:b.clientY}; + "touchstart" !== f || g || (b.stopPropagation(), Entry.documentMousedown.notify(b), longPressTimer = setTimeout(function() { + longPressTimer && (longPressTimer = null, a._rightClick(b)); + }, 1E3), e.bind("mousemove.object touchmove.object", d), e.bind("mouseup.object touchend.object", c)); + } + }); + this.view_ = b; + var d = this, b = Entry.createElement("ul"); + b.addClass("objectInfoView"); + Entry.objectEditable || b.addClass("entryHide"); + var c = Entry.createElement("li"); + c.addClass("objectInfo_visible"); + this.entity.getVisible() || c.addClass("objectInfo_unvisible"); + c.bindOnClick(function(a) { + Entry.engine.isState("run") || (a = d.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(a) { + Entry.engine.isState("run") || (a = d, a.setLock(!a.getLock()) ? this.addClass("objectInfo_lock") : this.removeClass("objectInfo_lock"), a.updateInputViews(a.getLock())); + }); + b.appendChild(c); + 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); + c = Entry.createElement("input"); + c.bindOnClick(function(a) { + a.preventDefault(); + Entry.container.selectObject(d.id); + this.readOnly || (this.focus(), this.select()); + }); + c.addClass("entryObjectNameWorkspace"); + b.appendChild(c); + this.nameView_ = c; + this.nameView_.entryObject = this; + c.setAttribute("readonly", !0); + var f = this; + this.nameView_.onblur = function(a) { + this.entryObject.name = this.value; + Entry.playground.reloadPlayground(); + }; + this.nameView_.onkeypress = function(a) { + 13 == a.keyCode && f.editObjectValues(!1); + }; + this.nameView_.value = this.name; + c = Entry.createElement("div"); + c.addClass("entryObjectEditWorkspace"); + c.object = this; + this.editView_ = c; + this.view_.appendChild(c); + $(c).mousedown(function(b) { + var d = a.isEditing; + b.stopPropagation(); + Entry.documentMousedown.notify(b); + Entry.engine.isState("run") || !1 !== d || (a.editObjectValues(!d), Entry.playground.object !== a && Entry.container.selectObject(a.id), a.nameView_.select()); + }); + c.blur = function(b) { + a.editObjectComplete(); + }; + Entry.objectEditable && Entry.objectDeletable && (c = Entry.createElement("div"), c.addClass("entryObjectDeleteWorkspace"), c.object = this, this.deleteView_ = c, this.view_.appendChild(c), c.bindOnClick(function(a) { + Entry.engine.isState("run") || Entry.container.removeObject(this.object); + })); + c = Entry.createElement("div"); + c.addClass("entryObjectInformationWorkspace"); + c.object = this; + this.isInformationToggle = !1; + b.appendChild(c); + this.informationView_ = c; + b = Entry.createElement("div"); + b.addClass("entryObjectRotationWrapperWorkspace"); + b.object = this; + this.view_.appendChild(b); + c = Entry.createElement("span"); + c.addClass("entryObjectCoordinateWorkspace"); + b.appendChild(c); + 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(a) { + a.stopPropagation(); + this.select(); + }); + var h = Entry.createElement("span"); + h.addClass("entryObjectCoordinateSpanWorkspace"); + h.innerHTML = "Y:"; + var k = Entry.createElement("input"); + k.addClass("entryObjectCoordinateInputWorkspace entryObjectCoordinateInputWorkspace_right"); + k.bindOnClick(function(a) { + a.stopPropagation(); + this.select(); + }); + k.setAttribute("readonly", !0); + var l = Entry.createElement("span"); + l.addClass("entryObjectCoordinateSizeWorkspace"); + l.innerHTML = Lang.Workspace.Size + " : "; + var m = Entry.createElement("input"); + m.addClass("entryObjectCoordinateInputWorkspace", "entryObjectCoordinateInputWorkspace_size"); + m.bindOnClick(function(a) { + a.stopPropagation(); + this.select(); + }); + m.setAttribute("readonly", !0); + c.appendChild(e); + c.appendChild(g); + c.appendChild(h); + c.appendChild(k); + c.appendChild(l); + c.appendChild(m); + c.xInput_ = g; + c.yInput_ = k; + c.sizeInput_ = m; + this.coordinateView_ = c; + d = this; + g.onkeypress = function(a) { + 13 == a.keyCode && d.editObjectValues(!1); + }; + g.onblur = function(a) { + isNaN(g.value) || d.entity.setX(Number(g.value)); + d.updateCoordinateView(); + Entry.stage.updateObject(); + }; + k.onkeypress = function(a) { + 13 == a.keyCode && d.editObjectValues(!1); + }; + k.onblur = function(a) { + isNaN(k.value) || d.entity.setY(Number(k.value)); + d.updateCoordinateView(); + Entry.stage.updateObject(); + }; + m.onkeypress = function(a) { + 13 == a.keyCode && d.editObjectValues(!1); + }; + m.onblur = function(a) { + isNaN(m.value) || d.entity.setSize(Number(m.value)); + d.updateCoordinateView(); + Entry.stage.updateObject(); + }; + c = Entry.createElement("div"); + c.addClass("entryObjectRotateLabelWrapperWorkspace"); + this.view_.appendChild(c); + this.rotateLabelWrapperView_ = c; + e = Entry.createElement("span"); + e.addClass("entryObjectRotateSpanWorkspace"); + e.innerHTML = Lang.Workspace.rotation + " : "; + var n = Entry.createElement("input"); + n.addClass("entryObjectRotateInputWorkspace"); + n.setAttribute("readonly", !0); + n.bindOnClick(function(a) { + a.stopPropagation(); + this.select(); + }); + this.rotateSpan_ = e; + this.rotateInput_ = n; + h = Entry.createElement("span"); + h.addClass("entryObjectDirectionSpanWorkspace"); + h.innerHTML = Lang.Workspace.direction + " : "; + var q = Entry.createElement("input"); + q.addClass("entryObjectDirectionInputWorkspace"); + q.setAttribute("readonly", !0); + q.bindOnClick(function(a) { + a.stopPropagation(); + this.select(); + }); + this.directionInput_ = q; + c.appendChild(e); + c.appendChild(n); + c.appendChild(h); + c.appendChild(q); + c.rotateInput_ = n; + c.directionInput_ = q; + d = this; + n.onkeypress = function(a) { + 13 == a.keyCode && d.editObjectValues(!1); + }; + n.onblur = function(a) { + a = n.value; + -1 != a.indexOf("\u02da") && (a = a.substring(0, a.indexOf("\u02da"))); + isNaN(a) || d.entity.setRotation(Number(a)); + d.updateRotationView(); + Entry.stage.updateObject(); + }; + q.onkeypress = function(a) { + 13 == a.keyCode && d.editObjectValues(!1); + }; + q.onblur = function(a) { + a = q.value; + -1 != a.indexOf("\u02da") && (a = a.substring(0, a.indexOf("\u02da"))); + isNaN(a) || d.entity.setDirection(Number(a)); + d.updateRotationView(); + Entry.stage.updateObject(); + }; + c = Entry.createElement("div"); + c.addClass("rotationMethodWrapper"); + b.appendChild(c); + this.rotationMethodWrapper_ = c; + b = Entry.createElement("span"); + b.addClass("entryObjectRotateMethodLabelWorkspace"); + c.appendChild(b); + b.innerHTML = Lang.Workspace.rotate_method + " : "; + b = Entry.createElement("div"); + b.addClass("entryObjectRotateModeWorkspace"); + b.addClass("entryObjectRotateModeAWorkspace"); + b.object = this; + this.rotateModeAView_ = b; + c.appendChild(b); + b.bindOnClick(function(a) { + Entry.engine.isState("run") || this.object.getLock() || (this.object.initRotateValue("free"), this.object.setRotateMethod("free")); + }); + b = Entry.createElement("div"); + b.addClass("entryObjectRotateModeWorkspace"); + b.addClass("entryObjectRotateModeBWorkspace"); + b.object = this; + this.rotateModeBView_ = b; + c.appendChild(b); + b.bindOnClick(function(a) { + Entry.engine.isState("run") || this.object.getLock() || (this.object.initRotateValue("vertical"), this.object.setRotateMethod("vertical")); + }); + b = Entry.createElement("div"); + b.addClass("entryObjectRotateModeWorkspace"); + b.addClass("entryObjectRotateModeCWorkspace"); + b.object = this; + this.rotateModeCView_ = b; + c.appendChild(b); + b.bindOnClick(function(a) { + Entry.engine.isState("run") || this.object.getLock() || (this.object.initRotateValue("none"), this.object.setRotateMethod("none")); + }); + this.updateThumbnailView(); + this.updateCoordinateView(); + this.updateRotateMethodView(); + this.updateInputViews(); + this.updateCoordinateView(!0); + this.updateRotationView(!0); + return this.view_; + } + if ("phone" == Entry.type) { + 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); + }), $ && (a = this, context.attach("#" + this.id, [{text:Lang.Workspace.context_rename, href:"/", action:function(a) { + a.preventDefault(); + }}, {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"), c = Entry.createElement("li"), c.addClass("objectInfo_visible"), e = Entry.createElement("li"), e.addClass("objectInfo_lock"), b.appendChild(c), 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), + c = Entry.createElement("input"), c.addClass("entryObjectNameWorkspace"), b.appendChild(c), this.nameView_ = c, this.nameView_.entryObject = this, this.nameView_.onblur = function() { + this.entryObject.name = this.value; + Entry.playground.reloadPlayground(); + }, this.nameView_.onkeypress = function(a) { + 13 == a.keyCode && d.editObjectValues(!1); + }, this.nameView_.value = this.name, Entry.objectEditable && Entry.objectDeletable && (c = Entry.createElement("div"), c.addClass("entryObjectDeletePhone"), c.object = this, this.deleteView_ = c, this.view_.appendChild(c), c.bindOnClick(function(a) { + Entry.engine.isState("run") || Entry.container.removeObject(this.object); + })), c = Entry.createElement("button"), c.addClass("entryObjectEditPhone"), c.object = this, c.bindOnClick(function(a) { + if (a = Entry.container.getObject(this.id)) { + Entry.container.selectObject(a.id), Entry.playground.injectObject(a); + } + }), this.view_.appendChild(c), c = Entry.createElement("div"), c.addClass("entryObjectInformationWorkspace"), c.object = this, this.isInformationToggle = !1, b.appendChild(c), this.informationView_ = c, c = Entry.createElement("div"), c.addClass("entryObjectRotateLabelWrapperWorkspace"), this.view_.appendChild(c), this.rotateLabelWrapperView_ = c, e = Entry.createElement("span"), e.addClass("entryObjectRotateSpanWorkspace"), e.innerHTML = Lang.Workspace.rotation + " : ", n = Entry.createElement("input"), + n.addClass("entryObjectRotateInputWorkspace"), this.rotateSpan_ = e, this.rotateInput_ = n, h = Entry.createElement("span"), h.addClass("entryObjectDirectionSpanWorkspace"), h.innerHTML = Lang.Workspace.direction + " : ", q = Entry.createElement("input"), q.addClass("entryObjectDirectionInputWorkspace"), this.directionInput_ = q, c.appendChild(e), c.appendChild(n), c.appendChild(h), c.appendChild(q), c.rotateInput_ = n, c.directionInput_ = q, d = this, n.onkeypress = function(a) { + 13 == a.keyCode && (a = n.value, -1 != a.indexOf("\u02da") && (a = a.substring(0, a.indexOf("\u02da"))), isNaN(a) || d.entity.setRotation(Number(a)), d.updateRotationView(), n.blur()); + }, n.onblur = function(a) { + d.entity.setRotation(d.entity.getRotation()); + Entry.stage.updateObject(); + }, q.onkeypress = function(a) { + 13 == a.keyCode && (a = q.value, -1 != a.indexOf("\u02da") && (a = a.substring(0, a.indexOf("\u02da"))), isNaN(a) || d.entity.setDirection(Number(a)), d.updateRotationView(), q.blur()); + }, q.onblur = function(a) { + d.entity.setDirection(d.entity.getDirection()); + Entry.stage.updateObject(); + }, b = Entry.createElement("div"), b.addClass("entryObjectRotationWrapperWorkspace"), b.object = this, this.view_.appendChild(b), c = Entry.createElement("span"), c.addClass("entryObjectCoordinateWorkspace"), b.appendChild(c), 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, m = Entry.createElement("input"), m.addClass("entryObjectCoordinateInputWorkspace", "entryObjectCoordinateInputWorkspace_size"), c.appendChild(e), c.appendChild(g), c.appendChild(h), c.appendChild(k), c.appendChild(l), c.appendChild(m), + c.xInput_ = g, c.yInput_ = k, c.sizeInput_ = m, this.coordinateView_ = c, d = this, g.onkeypress = function(a) { + 13 == a.keyCode && (isNaN(g.value) || d.entity.setX(Number(g.value)), d.updateCoordinateView(), d.blur()); + }, g.onblur = function(a) { + d.entity.setX(d.entity.getX()); + Entry.stage.updateObject(); + }, k.onkeypress = function(a) { + 13 == a.keyCode && (isNaN(k.value) || d.entity.setY(Number(k.value)), d.updateCoordinateView(), d.blur()); + }, k.onblur = function(a) { + d.entity.setY(d.entity.getY()); + Entry.stage.updateObject(); + }, c = Entry.createElement("div"), c.addClass("rotationMethodWrapper"), b.appendChild(c), this.rotationMethodWrapper_ = c, b = Entry.createElement("span"), b.addClass("entryObjectRotateMethodLabelWorkspace"), c.appendChild(b), b.innerHTML = Lang.Workspace.rotate_method + " : ", b = Entry.createElement("div"), b.addClass("entryObjectRotateModeWorkspace"), b.addClass("entryObjectRotateModeAWorkspace"), b.object = this, this.rotateModeAView_ = b, c.appendChild(b), b.bindOnClick(function(a) { + Entry.engine.isState("run") || this.object.setRotateMethod("free"); + }), b = Entry.createElement("div"), b.addClass("entryObjectRotateModeWorkspace"), b.addClass("entryObjectRotateModeBWorkspace"), b.object = this, this.rotateModeBView_ = b, c.appendChild(b), b.bindOnClick(function(a) { + Entry.engine.isState("run") || this.object.setRotateMethod("vertical"); + }), b = Entry.createElement("div"), b.addClass("entryObjectRotateModeWorkspace"), b.addClass("entryObjectRotateModeCWorkspace"), b.object = this, this.rotateModeCView_ = b, c.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.EntityObject.prototype.getBGColour = function() { - return this.bgColor; +Entry.EntryObject.prototype.setName = function(b) { + Entry.assert("string" == typeof b, "object name must be string"); + this.name = b; + this.nameView_.value = b; }; -Entry.EntityObject.prototype.setUnderLine = function(a) { - void 0 === a && (a = !1); - this.underLine = a; - this.textObject.underLine = a; - Entry.requestUpdate = !0; +Entry.EntryObject.prototype.setText = function(b) { + Entry.assert("string" == typeof b, "object text must be string"); + this.text = b; }; -Entry.EntityObject.prototype.getUnderLine = function() { - return this.underLine; +Entry.EntryObject.prototype.setScript = function(b) { + this.script = b; }; -Entry.EntityObject.prototype.setStrike = function(a) { - void 0 === a && (a = !1); - this.strike = a; - this.textObject.strike = a; - Entry.requestUpdate = !0; +Entry.EntryObject.prototype.getScriptText = function() { + return JSON.stringify(this.script.toJSON()); }; -Entry.EntityObject.prototype.getStrike = function() { - return this.strike; +Entry.EntryObject.prototype.initEntity = function(b) { + var a = {}; + a.x = a.y = 0; + a.rotation = 0; + a.direction = 90; + if ("sprite" == this.objectType) { + var d = b.sprite.pictures[0].dimension; + a.regX = d.width / 2; + a.regY = d.height / 2; + a.scaleX = a.scaleY = "background" == b.sprite.category.main || "new" == b.sprite.category.main ? Math.max(270 / d.height, 480 / d.width) : "new" == b.sprite.category.main ? 1 : 200 / (d.width + d.height); + a.width = d.width; + a.height = d.height; + } else { + if ("textBox" == this.objectType) { + 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, d = "", b.bold && (d += "bold "), b.italic && (d += "italic "), a.underline = b.underline, a.strike = b.strike, a.font = d + "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 { + a.underline = !1, a.strike = !1, a.font = "20px Nanum Gothic", a.colour = "#000000", a.bgColor = "#ffffff"; + } + } + } + return a; }; -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(" "), d; - if (d = -1 < b.indexOf("bold")) { - b.splice(d - 1, 1), this.setFontBold(!0); - } - if (d = -1 < b.indexOf("italic")) { - b.splice(d - 1, 1), this.setFontItalic(!0); - } - d = parseInt(b.shift()); - this.setFontSize(d); - this.setFontType(b.join(" ")); - this.font = this.getFont(); - this.textObject.font = a; - Entry.stage.update(); - this.setWidth(this.textObject.getMeasuredWidth()); - this.updateBG(); - Entry.stage.updateObject(); +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 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.EntityObject.prototype.setLineHeight = function() { - switch(this.getFontType()) { - case "Nanum Gothic Coding": - this.textObject.lineHeight = this.fontSize; - break; - default: - this.textObject.lineHeight = 0; +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, d = this.coordinateView_.sizeInput_.value, c = this.entity.getX().toFixed(1), e = this.entity.getY().toFixed(1), f = this.entity.getSize().toFixed(1); + b != c && (this.coordinateView_.xInput_.value = c); + a != e && (this.coordinateView_.yInput_.value = e); + d != f && (this.coordinateView_.sizeInput_.value = f); } }; -Entry.EntityObject.prototype.syncFont = function() { - this.textObject.font = this.getFont(); - this.setLineHeight(); - Entry.stage.update(); - this.getLineBreak() || this.setWidth(this.textObject.getMeasuredWidth()); - Entry.stage.updateObject(); - Entry.requestUpdate = !0; +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.EntityObject.prototype.getFontType = function() { - return this.fontType; +Entry.EntryObject.prototype.select = function(b) { + console.log(this); }; -Entry.EntityObject.prototype.setFontType = function(a) { - "textBox" == this.parent.objectType && (this.fontType = a ? a : "Nanum Gothic", this.syncFont()); +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.EntityObject.prototype.getFontSize = function(a) { - 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.setFontBold = function(a) { - this.fontBold = a; - Entry.requestUpdate = !0; -}; -Entry.EntityObject.prototype.toggleFontBold = function() { - this.fontBold = !this.fontBold; - this.syncFont(); - return this.fontBold; -}; -Entry.EntityObject.prototype.setFontItalic = function(a) { - this.fontItalic = a; - Entry.requestUpdate = !0; -}; -Entry.EntityObject.prototype.toggleFontItalic = function() { - this.fontItalic = !this.fontItalic; - this.syncFont(); - return this.fontItalic; -}; -Entry.EntityObject.prototype.setFontName = function(a) { - for (var b = this.font.split(" "), d = [], c = 0, e = b.length;c < e;c++) { - ("bold" === b[c] || "italic" === b[c] || -1 < b[c].indexOf("px")) && d.push(b[c]); +Entry.EntryObject.prototype.removePicture = function(b) { + if (2 > this.pictures.length) { + return !1; } - this.setFont(d.join(" ") + " " + a); + 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.EntityObject.prototype.getFontName = function() { - if ("textBox" == this.type) { - if (!this.font) { - return ""; +Entry.EntryObject.prototype.getPicture = function(b) { + if (!b) { + return this.selectedPicture; + } + b = b.trim(); + for (var a = this.pictures, d = a.length, c = 0;c < d;c++) { + if (a[c].id == b) { + return a[c]; } - for (var a = this.font.split(" "), b = [], d = 0, c = a.length;d < c;d++) { - "bold" !== a[d] && "italic" !== a[d] && -1 === a[d].indexOf("px") && b.push(a[d]); + } + for (c = 0;c < d;c++) { + if (a[c].name == b) { + return a[c]; } - return b.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.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.getTextAlign = function() { - return this.textAlign; -}; -Entry.EntityObject.prototype.setLineBreak = function(a) { - 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()); - Entry.stage.updateObject(); + b = Entry.parseNumber(b); + if ((!1 !== b || "boolean" != typeof b) && d >= b && 0 < b) { + return a[b - 1]; } + throw Error("No picture found"); }; -Entry.EntityObject.prototype.getLineBreak = function() { - return this.lineBreak; -}; -Entry.EntityObject.prototype.setVisible = function(a) { - void 0 === a && (a = !0); - this.visible = a; - this.object.visible = this.visible; - this.dialog && this.syncDialogVisible(); - Entry.requestUpdate = !0; - return this.visible; -}; -Entry.EntityObject.prototype.getVisible = function() { - return this.visible; -}; -Entry.EntityObject.prototype.setImage = function(a) { - var b = this; - delete a._id; - Entry.assert("sprite" == this.type, "Set image is only for sprite object"); - a.id || (a.id = Entry.generateHash()); - this.picture = a; - var d = this.picture.dimension, c = this.getRegX() - this.getWidth() / 2, e = this.getRegY() - this.getHeight() / 2; - this.setWidth(d.width); - this.setHeight(d.height); - d.scaleX || (d.scaleX = this.getScaleX(), d.scaleY = this.getScaleY()); - this.setScaleX(this.scaleX); - this.setScaleY(this.scaleY); - this.setRegX(this.width / 2 + c); - this.setRegY(this.height / 2 + e); - var f = a.id + this.id, g = Entry.container.getCachedPicture(f); - g ? (Entry.image = g, this.object.image = g, this.object.cache(0, 0, this.getWidth(), this.getHeight())) : (g = new Image, a.fileurl ? g.src = a.fileurl : (a = a.filename, g.src = Entry.defaultPath + "/uploads/" + a.substring(0, 2) + "/" + a.substring(2, 4) + "/image/" + a + ".png"), this.object.image = g, this.object.cache(0, 0, this.getWidth(), this.getHeight()), g.onload = function(a) { - Entry.container.cachePicture(f, g); - Entry.image = g; - b.object.image = g; - b.object.cache(0, 0, b.getWidth(), b.getHeight()); - Entry.requestUpdate = !0; - }); - Entry.dispatchEvent("updateObject"); +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.EntityObject.prototype.applyFilter = function(a) { - function b(b, a) { - for (var d in b) { - if (b[d] !== a[d]) { - return !1; - } +Entry.EntryObject.prototype.getPrevPicture = function(b) { + for (var a = this.pictures, d = a.length, c = 0;c < d;c++) { + if (a[c].id == b) { + return a[0 == c ? d - 1 : c - 1]; } - return !0; } - var d = this.effect, c = this.object; - if (a || !b(d, this.getInitialEffectValue())) { - (function(b, a) { - var d = [], c = Entry.adjustValueWithMaxMin; - b.brightness = b.brightness; - var k = new createjs.ColorMatrix; - k.adjustColor(c(b.brightness, -100, 100), 0, 0, 0); - k = new createjs.ColorMatrixFilter(k); - d.push(k); - b.hue = b.hue.mod(360); - k = new createjs.ColorMatrix; - k.adjustColor(0, 0, 0, b.hue); - k = new createjs.ColorMatrixFilter(k); - d.push(k); - var k = [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], l = 10.8 * b.hsv * Math.PI / 180, m = Math.cos(l), l = Math.sin(l), n = Math.abs(b.hsv / 100); - 1 < n && (n -= Math.floor(n)); - 0 < n && .33 >= n ? k = [1, 0, 0, 0, 0, 0, m, l, 0, 0, 0, -1 * l, m, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1] : .66 >= n ? k = [m, 0, l, 0, 0, 0, 1, 0, 0, 0, l, 0, m, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1] : .99 >= n && (k = [m, l, 0, 0, 0, -1 * l, m, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1]); - k = (new createjs.ColorMatrix).concat(k); - k = new createjs.ColorMatrixFilter(k); - d.push(k); - a.alpha = b.alpha = c(b.alpha, 0, 1); - a.filters = d; - })(d, c), c.cache(0, 0, this.getWidth(), this.getHeight()), Entry.requestUpdate = !0; +}; +Entry.EntryObject.prototype.getNextPicture = function(b) { + for (var a = this.pictures, d = a.length, c = 0;c < d;c++) { + if (a[c].id == b) { + return a[c == d - 1 ? 0 : c + 1]; + } } }; -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.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 : " + 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, a, b); }; -Entry.EntityObject.prototype.updateDialog = function() { - this.dialog && this.dialog.update(); - Entry.requestUpdate = !0; +Entry.EntryObject.prototype.getRotateMethod = function() { + this.rotateMethod || (this.rotateMethod = "free"); + return this.rotateMethod; }; -Entry.EntityObject.prototype.takeSnapshot = function() { - this.snapshot_ = this.toJSON(); - this.collision = Entry.Utils.COLLISION.NONE; +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.EntityObject.prototype.loadSnapshot = function() { - this.snapshot_ && this.syncModel_(this.snapshot_); - "sprite" == this.parent.objectType && this.setImage(this.parent.getPicture()); - Entry.requestUpdate = !0; +Entry.EntryObject.prototype.initRotateValue = function(b) { + this.rotateMethod != b && (b = this.entity, b.rotation = 0, b.direction = 90, b.flip = !1); }; -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.EntryObject.prototype.updateRotateMethodView = function() { + 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.EntityObject.prototype.clearExecutor = function() { - this.parent.script.clearExecutorsByEntity(this); +Entry.EntryObject.prototype.toggleInformation = function(b) { + this.setRotateMethod(this.getRotateMethod()); + void 0 === b && (b = this.isInformationToggle = !this.isInformationToggle); + b ? this.view_.addClass("informationToggle") : this.view_.removeClass("informationToggle"); }; -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.EntryObject.prototype.addCloneEntity = function(b, a, d) { + 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.EntityObject.prototype.setInitialEffectValue = function() { - this.effect = this.getInitialEffectValue(); - Entry.requestUpdate = !0; +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.EntityObject.prototype.getInitialEffectValue = function() { - return {blur:0, hue:0, hsv:0, brightness:0, contrast:0, saturation:0, alpha:1}; +Entry.EntryObject.prototype.isSelected = function() { + return this.isSelected_; }; -Entry.EntityObject.prototype.removeBrush = function() { - Entry.stage.selectedObjectContainer.removeChild(this.shape); - this.shape = this.brush = null; +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.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.EntryObject.prototype.destroy = function() { + Entry.stage.unloadEntity(this.entity); + this.view_ && Entry.removeElement(this.view_); }; -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.EntryObject.prototype.getSound = function(b) { + b = b.trim(); + for (var a = this.sounds, d = a.length, c = 0;c < d;c++) { + if (a[c].id == b) { + return a[c]; } } -}; -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 = {}; - Entry.generateFunctionSchema(this.id); - if (a) { - a = this.content._blockMap; - for (var b in a) { - Entry.Func.registerParamBlock(a[b].type); + for (c = 0;c < d;c++) { + if (a[c].name == b) { + return a[c]; } - Entry.Func.generateWsBlock(this); } - Entry.Func.registerFunction(this); - Entry.Func.updateMenu(); -}; -Entry.Func.threads = {}; -Entry.Func.registerFunction = function(a) { - if (Entry.playground) { - var b = Entry.playground.mainWorkspace; - b && (this._targetFuncBlock = b.getBlockMenu().getCategoryCodes("func").createThread([{type:"func_" + a.id}]), a.blockMenuBlock = this._targetFuncBlock); + b = Entry.parseNumber(b); + if ((!1 !== b || "boolean" != typeof b) && d >= b && 0 < b) { + return a[b - 1]; } + throw Error("No Sound"); }; -Entry.Func.executeFunction = function(a) { - var b = this.threads[a]; - if (b = Entry.Engine.computeThread(b.entity, b)) { - return this.threads[a] = b, !0; +Entry.EntryObject.prototype.addCloneVariables = function(b, a, d, c) { + a.variables = []; + a.lists = []; + d || (d = Entry.findObjsByKey(Entry.variableContainer.variables_, "object_", b.id)); + c || (c = Entry.findObjsByKey(Entry.variableContainer.lists_, "object_", b.id)); + for (b = 0;b < d.length;b++) { + a.variables.push(d[b].clone()); + } + for (b = 0;b < c.length;b++) { + a.lists.push(c[b].clone()); } - 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.EntryObject.prototype.getLock = function() { + return this.lock; }; -Entry.Func.edit = function(a) { - this.cancelEdit(); - this.targetFunc = a; - this.initEditView(a.content); - this.bindFuncChangeEvent(); - this.updateMenu(); +Entry.EntryObject.prototype.setLock = function(b) { + this.lock = b; + Entry.stage.updateObject(); + return b; }; -Entry.Func.initEditView = function(a) { - this.menuCode || this.setupMenuCode(); - var b = Entry.playground.mainWorkspace; - b.setMode(Entry.Workspace.MODE_OVERLAYBOARD); - b.changeOverlayBoardCode(a); - a.recreateView(); - b.changeOverlayBoardCode(a); - a.view.board.alignThreads(); - 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.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.Func.save = function() { - this.targetFunc.generateBlock(!0); - Entry.variableContainer.saveFunction(this.targetFunc); -}; -Entry.Func.syncFuncName = function(a) { - var b = 0; - a = a.split(" "); - var d = "", c; - c = Blockly.mainWorkspace.getAllBlocks(); - for (var e = 0;e < c.length;e++) { - var f = c[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_ && (d += h.fieldRow[0].text_, d += " "); - } - d = d.trim(); - if (d === this.srcFName && this.srcFName.split(" ").length == a.length) { - for (d = 0;d < f.length;d++) { - if (h = f[d], 0 < h.fieldRow.length && h.fieldRow[0] instanceof Blockly.FieldLabel && void 0 != h.fieldRow[0].text_) { - if (void 0 === a[b]) { - f.splice(d, 1); - break; - } else { - h.fieldRow[0].text_ = a[b]; - } - b++; - } - } - } - d = ""; - b = 0; +Entry.EntryObject.prototype.editObjectValues = function(b) { + var a; + a = this.getLock() ? [this.nameView_] : [this.coordinateView_.xInput_, this.coordinateView_.yInput_, this.rotateInput_, this.directionInput_, this.coordinateView_.sizeInput_]; + if (b) { + var d = this.nameView_; + $(a).removeClass("selectedNotEditingObject"); + $(d).removeClass("selectedNotEditingObject"); + window.setTimeout(function() { + $(d).removeAttr("readonly"); + d.addClass("selectedEditingObject"); + }); + for (b = 0;b < a.length;b++) { + $(a[b]).removeAttr("readonly"), a[b].addClass("selectedEditingObject"); + } + this.isEditing = !0; + } else { + for (b = 0;b < a.length;b++) { + a[b].blur(!0); } + this.nameView_.blur(!0); + this.blurAllInput(); + this.isEditing = !1; } - b = Blockly.Xml.workspaceToDom(Blockly.mainWorkspace); - Blockly.mainWorkspace.clear(); - Blockly.Xml.domToWorkspace(Blockly.mainWorkspace, b); }; -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 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 d in Entry.variableContainer.functions_) { - b = Entry.variableContainer.functions_[d], 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); +Entry.EntryObject.prototype.blurAllInput = function() { + 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); } - return a; }; -Entry.Func.syncFunc = function() { - var a = Entry.Func; - if (a.targetFunc) { - var b = a.workspace.topBlocks_[0].toString(), d = a.workspace.topBlocks_.length; - (a.fieldText != b || a.workspaceLength != d) && 1 > Blockly.Block.dragMode_ && (a.updateMenu(), a.fieldText = b, a.workspaceLength = d); - } -}; -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.EntryObject.prototype.addStampEntity = function(b) { + b = new Entry.StampEntity(this, b); + Entry.stage.loadEntity(b); + this.clonedEntities.push(b); + Entry.stage.sortZorder(); }; -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.EntryObject.prototype.getClonedEntities = function() { + var b = []; + this.clonedEntities.map(function(a) { + a.isStamp || b.push(a); + }); + return b; }; -Entry.Func.requestParamBlock = function(a) { - var b = Entry.generateHash(), d; - switch(a) { - case "string": - d = Entry.block.function_param_string; - break; - case "boolean": - d = Entry.block.function_param_boolean; - break; - default: - return null; - } - b = a + "Param_" + b; - a = Entry.Func.createParamBlock(b, d, a); - Entry.block[b] = a; +Entry.EntryObject.prototype.getStampEntities = function() { + var b = []; + this.clonedEntities.map(function(a) { + a.isStamp && b.push(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.EntryObject.prototype.clearExecutor = function() { + this.script.clearExecutors(); }; -Entry.Func.createParamBlock = function(a, b, d) { - var c = function() { - }; - d = "string" === d ? "function_param_string" : "function_param_boolean"; - c.prototype = b; - c = new c; - c.changeEvent = new Entry.Event; - c.template = Lang.template[d]; - return Entry.block[a] = c; +Entry.EntryObject.prototype._rightClick = function(b) { + var a = this, d = [{text:Lang.Workspace.context_rename, callback:function(b) { + b.stopPropagation(); + a.setLock(!1); + a.editObjectValues(!0); + a.nameView_.select(); + }}, {text:Lang.Workspace.context_duplicate, enable:!Entry.engine.isState("run"), callback:function() { + Entry.container.addCloneObject(a); + }}, {text:Lang.Workspace.context_remove, callback:function() { + Entry.container.removeObject(a); + }}, {text:Lang.Workspace.copy_file, callback:function() { + 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); + }}]; + b = Entry.Utils.convertMouseEvent(b); + Entry.ContextMenu.show(d, "workspace-contextmenu", {x:b.clientX, y:b.clientY}); }; -Entry.Func.updateMenu = function() { - if (Entry.playground && Entry.playground.mainWorkspace) { - var a = Entry.playground.mainWorkspace.getBlockMenu(); - this.targetFunc ? (this.menuCode || this.setupMenuCode(), a.banClass("functionInit"), a.unbanClass("functionEdit")) : (a.unbanClass("functionInit"), a.banClass("functionEdit")); - a.reDraw(); - } +Entry.Painter = function() { + this.toolbox = {selected:"cursor"}; + this.stroke = {enabled:!1, fillColor:"#000000", lineColor:"#000000", thickness:1, fill:!0, transparent:!1, style:"line", locked:!1}; + this.file = {id:Entry.generateHash(), name:"\uc0c8\uadf8\ub9bc", modified:!1, mode:"new"}; + this.font = {name:"KoPub Batang", size:20, style:"normal"}; + this.selectArea = {}; + this.firstStatement = !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.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); + this.stage.autoClear = !0; + this.stage.enableDOMEvents(!0); + this.stage.enableMouseOver(10); + this.stage.mouseMoveOutside = !0; + createjs.Touch.enable(this.stage); + this.objectContainer = new createjs.Container; + this.objectContainer.name = "container"; + this.stage.addChild(this.objectContainer); + this.ctx = this.stage.canvas.getContext("2d"); + this.ctx.imageSmoothingEnabled = !1; + this.ctx.webkitImageSmoothingEnabled = !1; + this.ctx.mozImageSmoothingEnabled = !1; + this.ctx.msImageSmoothingEnabled = !1; + this.ctx.oImageSmoothingEnabled = !1; + this.ctx_ = this.canvas_.getContext("2d"); + this.initDashedLine(); + this.initPicture(); + this.initCoordinator(); + this.initHandle(); + this.initDraw(); + var a = this; + Entry.addEventListener("textUpdate", function() { + var b = a.inputField.value(); + "" === b ? (a.inputField.hide(), delete a.inputField) : (a.inputField.hide(), a.drawText(b), a.selectToolbox("cursor")); + }); + this.selectToolbox("cursor"); }; -Entry.Func.generateBlock = function(a) { - a = Entry.block["func_" + a.id]; - var b = {template:a.template, params:a.params}, d = /(%\d)/mi, c = a.template.split(d), e = "", f = 0, g = 0, h; - for (h in c) { - var k = c[h]; - d.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.Painter.prototype.initHandle = function() { + this._handle = new createjs.Container; + this._handle.rect = new createjs.Shape; + this._handle.addChild(this._handle.rect); + 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(d) { + "cursor" === a.toolbox.selected && (a.initCommand(), this.offset = {x:this.parent.x - this.x - d.stageX, y:this.parent.y - this.y - d.stageY}, this.parent.handleMode = "move", b.isSelectCenter = !1); + }); + b.rect.on("pressmove", function(d) { + "cursor" !== a.toolbox.selected || b.isSelectCenter || (a.doCommand(), this.parent.x = d.stageX + this.offset.x, this.parent.y = d.stageY + this.offset.y, a.updateImageHandle()); + }); + b.on("mouseup", function(b) { + a.checkCommand(); + }); + 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(); + }); + b.RHandle.on("pressmove", function(b) { + a.doCommand(); + var c = b.stageX - this.parent.x; + b = b.stageY - this.parent.y; + this.parent.rotation = 0 <= c ? Math.atan(b / c) / Math.PI * 180 + 90 : Math.atan(b / c) / Math.PI * 180 + 270; + a.updateImageHandle(); + }); + b.RHandle.cursor = "crosshair"; + b.addChild(b.RHandle); + b.on("mouseup", function(b) { + a.checkCommand(); + }); + b.visible = !1; + this.handle = b; + this.stage.addChild(b); + this.updateImageHandleCursor(); }; -Entry.Func.prototype.generateBlock = function(a) { - a = Entry.Func.generateBlock(this); - this.block = a.block; - this.description = a.description; +Entry.Painter.prototype.generateCornerHandle = function() { + 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}; + }); + a.on("pressmove", function(a) { + b.doCommand(); + var c = 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 * c && 10 < this.parent.height * c && (this.parent.width *= c, this.parent.height *= c, this.offset = {x:a.stageX - this.parent.x + this.parent.regX, y:a.stageY - this.parent.y + this.parent.regY}); + b.updateImageHandle(); + }); + a.on("mouseup", function(a) { + b.checkCommand(); + }); + return a; }; -Entry.Func.generateWsBlock = function(a) { - this.unbindFuncChangeEvent(); - a = a ? a : this.targetFunc; - for (var b = a.content.getEventMap("funcDef")[0].params[0], d = 0, c = 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 + " " + (d ? d : "")}); - g[k.type] = !1; - h[k.type] = d + c; - d++; - e.push({type:"Block", accept:"boolean"}); - f += " %" + (d + c); - break; - case "function_field_string": - Entry.Mutator.mutate(k.type, {template:Lang.Blocks.FUNCTION_character_variable + " " + (c ? c : "")}), g[k.type] = !1, h[k.type] = d + c, c++, f += " %" + (d + c), e.push({type:"Block", accept:"string"}); - } - b = b.getOutputBlock(); +Entry.Painter.prototype.generateXHandle = function() { + 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}; + }); + a.on("pressmove", function(a) { + b.doCommand(); + var c = Math.abs((a.stageX - this.parent.x + this.parent.regX) / this.offset.x); + 10 < this.parent.width * c && (this.parent.width *= c, this.offset = {x:a.stageX - this.parent.x + this.parent.regX}); + b.updateImageHandle(); + }); + a.on("mouseup", function(a) { + b.checkCommand(); + }); + return a; +}; +Entry.Painter.prototype.generateYHandle = function() { + 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}; + }); + a.on("pressmove", function(a) { + b.doCommand(); + var c = Math.abs((a.stageY - this.parent.y + this.parent.regY) / this.offset.y); + 10 < this.parent.height * c && (this.parent.height *= c, this.offset = {y:a.stageY - this.parent.y + this.parent.regY}); + b.updateImageHandle(); + }); + a.on("mouseup", function(a) { + b.checkCommand(); + }); + return a; +}; +Entry.Painter.prototype.updateImageHandle = function() { + if (this.handle.visible) { + var b = this.handle, a = b.direction, d = b.width, c = 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(-d / 2, -c / 2).lt(0, -c / 2).lt(0, -c / 2).lt(+d / 2, -c / 2).lt(+d / 2, +c / 2).lt(-d / 2, +c / 2).cp(); + b.notch.graphics.clear().f("rgba(0,0,1,0.01)").ss(2, 2, 0).s("#c1c7cd").lt(0, -c / 2).lt(0, -c / 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 && (d = this.selectedObject, this.selectedObject.text ? (d.width = this.selectedObject.width, d.height = this.selectedObject.height) : (d.width = d.image.width, d.height = d.image.height), d.scaleX = b.width / d.width, d.scaleY = b.height / d.height, d.x = b.x, d.y = b.y, d.regX = d.width / 2 + e / d.scaleX, d.regY = d.height / 2 + f / d.scaleY, d.rotation = b.rotation, d.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(d.width * d.scaleX).toFixed(0), this.objectHeightInput.value = Math.abs(d.height * d.scaleY).toFixed(0), this.objectRotateInput.value = (1 * d.rotation).toFixed(0)); + this.updateImageHandleCursor(); + this.stage.update(); } - d++; - f += " %" + (d + c); - 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; +}; +Entry.Painter.prototype.updateImageHandleCursor = function() { + var b = this.handle; + b.rect.cursor = "move"; + b.RHandle.cursor = "crosshair"; + for (var a = ["nwse-resize", "ns-resize", "nesw-resize", "ew-resize"], d = Math.floor((b.rotation + 22.5) % 180 / 45), c = 0;c < d;c++) { + 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(); + b || this.initCommand(); + this.objectContainer.removeAllChildren(); + this.stage.update(); + this.colorLayerData = this.ctx.getImageData(0, 0, this.canvas.width, this.canvas.height); + 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.bindFuncChangeEvent(a); + this.reloadContext(); }; -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.Painter.prototype.newPicture = function() { + 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.Func.unbindFuncChangeEvent = function() { - this._funcChangeEvent && this._funcChangeEvent.destroy(); - delete this._funcChangeEvent; +Entry.Painter.prototype.initPicture = function() { + 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 d = new Image; + d.id = a.id ? a.id : Entry.generateHash(); + b.file.id = d.id; + b.file.name = a.name; + b.file.mode = "edit"; + d.src = a.fileurl ? a.fileurl : Entry.defaultPath + "/uploads/" + a.filename.substring(0, 2) + "/" + a.filename.substring(2, 4) + "/image/" + a.filename + ".png"; + d.onload = function(a) { + b.addImage(a.target); + }; + } + }); + Entry.addEventListener("pictureImport", function(a) { + b.addPicture(a); + }); + Entry.addEventListener("pictureNameChanged", function(a) { + b.file.name = a.name; + }); + Entry.addEventListener("pictureClear", function(a) { + b.file.modified = !1; + b.file.id = ""; + b.file.name = ""; + b.clearCanvas(); + }); }; -Entry.Helper = function() { - this.visible = !1; +Entry.Painter.prototype.initDraw = function() { + var b = this; + this.stage.on("stagemousedown", function(a) { + b.stagemousedown(a); + }); + this.stage.on("stagemouseup", function(a) { + b.stagemouseup(a); + }); + this.stage.on("stagemousemove", function(a) { + b.stagemousemove(a); + }); }; -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.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(); }; -p.bindWorkspace = function(a) { - a && (this._blockViewObserver && this._blockViewObserver.destroy(), this.workspace = a, this._blockViewObserver = a.observe(this, "_updateSelectedBlock", ["selectedBlockView"])); +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(); }; -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); - } +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 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(); }; -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 d = Entry.block[a].def, d = d || {type:a}; - this.code.createThread([d]); - this.code.board.align(); - this.code.board.resize(); - var d = this.code.getThreads()[0].getFirstBlock().view, c = d.svgGroup.getBBox(); - a = c.width; - c = c.height; - d = d.getSkeleton().box(d).offsetX; - isNaN(d) && (d = 0); - this.blockHelperDescription_.innerHTML = b; - this._renderView.align(); - $(this.blockHelperDescription_).css({top:c + 30}); - this._renderView.svgDom.css({"margin-left":-(a / 2) - 20 - d}); - } +Entry.Painter.prototype.updateHandle_ = function() { + this.stage.getChildIndex(-1 < this._handle) && this.stage.addChild(this._handle); + 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(); }; -p.getView = function() { - return this.view; +Entry.Painter.prototype.matchTolerance = function(b, a, d, c, 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 >= d - e / 100 * d && g <= d + e / 100 * d && b >= c - e / 100 * c && b <= c + e / 100 * c; }; -p.resize = function() { +Entry.Painter.prototype.matchColorOnly = function(b, a, d, c) { + return a === this.colorLayerData.data[b] && d === this.colorLayerData.data[b + 1] && c === this.colorLayerData.data[b + 2] ? !0 : !1; }; -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 = {}; +Entry.Painter.prototype.matchColor = function(b, a, d, c, e) { + return a === this.colorLayerData.data[b] && d === this.colorLayerData.data[b + 1] && c === this.colorLayerData.data[b + 2] && e === this.colorLayerData.data[b + 3] ? !0 : !1; }; -(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 = [], c; - for (c in b) { - var e = this.generatePortView(b[c], "_svgGroup"); - this._portViews[c] = 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 c in a) { - b[c] = a[c]; - } - return b; - }; - a.removePortEle = function(b, a) { - if ("object" != typeof a) { - return b; - } - for (var c in a) { - delete b[c]; - } - 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 = [], c; - for (c in b) { - var e = this.generatePortView(b[c], "_svglistGroup"); - this._listPortViews[c] = 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 c; - c = 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:c, 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, c = this._hwModule.monitorTemplate.mode, e = this._hwModule.monitorTemplate.keys || [], f = []; - if ("list" == c) { - f = this._listPortViews; - } else { - if ("both" == c) { - 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 (c = f[h], "input" == c.type) { - var k = b[h]; - 0 < e.length && $.each(e, function(b, a) { - if ($.isPlainObject(k)) { - k = k[a] || 0; - } else { - return !1; - } - }); - c.value.textContent = k ? k : 0; - c.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; - } - }), c.value.textContent = k ? k : 0, c.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, c = 0;c < b.length;c++) { - b[c].group.attr({transform:"translate(" + this._template.width * (c / 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, c) { - 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 = c; - 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, c) { - 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(), m = e, n = f, q = c; - 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, m); - this._movePort(l, f, a, n); - 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 c = listLine = wholeWidth = 0;c < b.length;c++) { - wholeWidth += b[c].width; - } - for (var e = 0, f = 0, g = initX, h, k, l = 0, c = 0;c < b.length;c++) { - k = b[c], c != b.length - 1 && (l = b[c + 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, c, 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 + "," + c + "L" + g + "," + h : "M" + (a + e) / 2 + "," + c + "l0," + (h > c ? 28 : -3) + "H" + g + "L" + g + "," + h) : a = a < g && g < e ? "m" + g + "," + c + "L" + g + "," + h : "m" + (e + a) / 2 + "," + c + "l0," + (h > c ? 28 : -3) + "H" + g + "L" + g + "," + h; - b.group.attr({transform:"translate(" + f + "," + c + ")"}); - 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 = {"1.1":Entry.Arduino, "1.9":Entry.ArduinoExt, "1.2":Entry.SensorBoard, "1.3":Entry.CODEino, "1.4":Entry.joystick, "1.5":Entry.dplay, "1.6":Entry.nemoino, "1.7":Entry.Xbot, "1.8":Entry.ardublock, "1.A":Entry.Cobl, "2.4":Entry.Hamster, "2.5":Entry.Albert, "3.1":Entry.Bitbrick, "4.2":Entry.Arduino, "5.1":Entry.Neobot, "7.1":Entry.Robotis_carCont, "7.2":Entry.Robotis_openCM70, "8.1":Entry.Arduino, "10.1":Entry.Roborobo_Roduino, "10.2":Entry.Roborobo_SchoolKit, "12.1":Entry.EV3, "B.1":Entry.Codestar}; +Entry.Painter.prototype.colorPixel = function(b, a, d, c, e) { + e || (e = 255); + this.stroke.transparent && (e = c = d = a = 0); + this.colorLayerData.data[b] = a; + this.colorLayerData.data[b + 1] = d; + this.colorLayerData.data[b + 2] = c; + 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.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, d; - this.connected = !1; - this.connectTrial++; - if (-1 < location.protocol.indexOf("https")) { - d = 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 (c) { - } - try { - d = new WebSocket("wss://hardware.play-entry.org:23518"); - } catch (c) { - } - } - d.binaryType = "arraybuffer"; - d.onopen = function() { - a.socketType = "WebSocketSecurity"; - a.initHardware(d); - }; - d.onmessage = function(b) { - b = JSON.parse(b.data); - a.checkDevice(b); - a.updatePortData(b); - }; - d.onclose = function() { - "WebSocketSecurity" === a.socketType && (this.socket = null, a.initSocket()); - }; - Entry.dispatchEvent("hwChanged"); - } - } catch (c) { - } +Entry.Painter.prototype.drawText = function(b) { + var a = document.getElementById("entryPainterAttrFontStyle").value, d = document.getElementById("entryPainterAttrFontName").value, c = document.getElementById("entryPainterAttrFontSize").value; + b = new createjs.Text(b, a + " " + c + 'px "' + d + '"', 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; }; -p.retryConnect = function() { - this.connectTrial = 0; - this.initSocket(); +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 d = 540 / a.image.height; + a.scaleX = d; + a.scaleY = d; + } + a.name = b.id; + a.id = b.id; + this.selectObject(a); + this.stage.update(); }; -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); +Entry.Painter.prototype.createBrush = function() { + this.initCommand(); + this.brush = new createjs.Shape; + this.objectContainer.addChild(this.brush); + this.stage.update(); +}; +Entry.Painter.prototype.createEraser = function() { + this.initCommand(); + this.eraser = new createjs.Shape; + this.objectContainer.addChild(this.eraser); + this.stage.update(); }; -p.setDigitalPortValue = function(a, b) { - this.sendQueue[a] = b; - this.removePortReadable(a); +Entry.Painter.prototype.clearHandle = function() { + this.handle.visible && (this.handle.visible = !1); + this.coordinator.visible && (this.coordinator.visible = !1); + this.stage.update(); }; -p.getAnalogPortValue = function(a) { - return this.connected ? this.portData["a" + a] : 0; +Entry.Painter.prototype.initCommand = function() { + var b = !1; + 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; + b && (this.handle.visible = !0); + a && (this.coordinator.visible = !0); + (b || a) && this.stage.update(); }; -p.getDigitalPortValue = function(a) { - if (!this.connected) { - return 0; - } - this.setPortReadable(a); - return void 0 !== this.portData[a] ? this.portData[a] : 0; +Entry.Painter.prototype.doCommand = function() { + this.isCommandValid = !0; }; -p.setPortReadable = function(a) { - this.sendQueue.readablePorts || (this.sendQueue.readablePorts = []); - var b = !1, d; - for (d in this.sendQueue.readablePorts) { - if (this.sendQueue.readablePorts[d] == a) { - b = !0; - break; - } - } - b || this.sendQueue.readablePorts.push(a); +Entry.Painter.prototype.checkCommand = function() { + this.isCommandValid || Entry.dispatchEvent("cancelLastCommand"); }; -p.removePortReadable = function(a) { - if (this.sendQueue.readablePorts || Array.isArray(this.sendQueue.readablePorts)) { - var b, d; - for (d in this.sendQueue.readablePorts) { - if (this.sendQueue.readablePorts[d] == a) { - b = Number(d); +Entry.Painter.prototype.restorePainter = function(b) { + this.clearHandle(); + 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(b, 0, 0); + b = new Image; + b.src = this.canvas.toDataURL(); + var d = this; + b.onload = function(a) { + a = new createjs.Bitmap(a.target); + d.objectContainer.removeAllChildren(); + d.objectContainer.addChild(a); + }; + 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); + this.reloadContext(); +}; +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 d = new createjs.Point(this.stage.mouseX, this.stage.mouseY); + d.x = Math.round(d.x); + d.y = Math.round(d.y); + for (var c = 4 * (d.y * b + d.x), e = this.colorLayerData.data[c], f = this.colorLayerData.data[c + 1], g = this.colorLayerData.data[c + 2], h = this.colorLayerData.data[c + 3], k, l, d = [[d.x, d.y]], m = Entry.hex2rgb(this.stroke.lineColor);d.length;) { + for (var c = d.pop(), n = c[0], q = c[1], c = 4 * (q * b + n);0 <= q && this.matchColor(c, e, f, g, h);) { + --q, c -= 4 * b; + } + c += 4 * b; + q += 1; + for (l = k = !1;q < a - 1 && this.matchColor(c, e, f, g, h);) { + q += 1, this.colorPixel(c, m.r, m.g, m.b), 0 < n && (this.matchColor(c - 4, e, f, g, h) ? k || (d.push([n - 1, q]), k = !0) : k && (k = !1)), n < b - 1 && (this.matchColor(c + 4, e, f, g, h) ? l || (d.push([n + 1, q]), l = !0) : l && (l = !1)), c += 4 * b; + } + if (1080 < d.length) { break; } } - this.sendQueue.readablePorts = void 0 != b ? this.sendQueue.readablePorts.slice(0, b).concat(this.sendQueue.readablePorts.slice(b + 1, this.sendQueue.readablePorts.length)) : []; + this.file.modified = !0; + this.reloadContext(); } }; -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 && "hw" == Entry.propertyPanel.selected && this.hwMonitor.update(); +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 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; + }; }; -p.closeConnection = function() { - this.socket && this.socket.close(); +Entry.Painter.prototype.move_pen = function() { + 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 = b.x; + this.oldMidPt.y = b.y; + this.file.modified = !0; + this.stage.update(); }; -p.downloadConnector = function() { - window.open("http://download.play-entry.org/apps/Entry_HW_1.5.11_Setup.exe", "_blank").focus(); +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(); }; -p.downloadGuide = function() { - window.open("http://download.play-entry.org/data/%EC%97%94%ED%8A%B8%EB%A6%AC-%ED%95%98%EB%93%9C%EC%9B%A8%EC%96%B4%EC%97%B0%EA%B2%B0%EB%A7%A4%EB%89%B4%EC%96%BC_16_08_17.hwp", "_blank").focus(); +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(); }; -p.downloadSource = function() { - window.open("http://play-entry.com/down/board.ino", "_blank").focus(); +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(); }; -p.setZero = function() { - Entry.hw.hwModule && Entry.hw.hwModule.setZero(); +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."); }; -p.checkDevice = function(a) { - void 0 !== a.company && (a = [Entry.Utils.convertIntToHex(a.company), ".", Entry.Utils.convertIntToHex(a.model)].join(""), 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()))); +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."); }; -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 c = a.getView(), c = Entry.Dom(c, {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:c}; - "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 c = this.modes[a]; - c.tabDom.removeClass("selected"); - c.contentDom.addClass("entryRemove"); - c.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; - "tablet" === this.device ? this.view_.setAttribute("class", "entry tablet") : 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); +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); }; - window.onresize = function(b) { - Entry.dispatchEvent("windowResized", b); + 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 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); + }; }; - window.onbeforeunload = this.beforeUnload; - Entry.addEventListener("saveWorkspace", function(b) { - Entry.addActivity("save"); - }); - Entry.addEventListener("showBlockHelper", function(b) { - Entry.propertyPanel.select("helper"); - }); - "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.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.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.Painter.prototype.settingShapeBlur = function() { + this.objectWidthInput.blur(); + this.objectHeightInput.blur(); + this.objectRotateInput.blur(); }; -Entry.createDom = function(a, b) { - if (b && "workspace" != b) { - "minimize" == b ? (d = Entry.createElement("canvas"), d.className = "entryCanvasWorkspace", d.id = "entryCanvas", d.width = 640, d.height = 360, c = Entry.createElement("div", "entryCanvasWrapper"), c.appendChild(d), a.appendChild(c), this.canvas_ = d, this.stage.initStage(this.canvas_), c = Entry.createElement("div"), a.appendChild(c), this.engineView = c, this.engine.generateView(this.engineView, b)) : "phone" == b && (this.stateManagerView = d = Entry.createElement("div"), this.stateManager.generateView(this.stateManagerView, - b), c = Entry.createElement("div"), a.appendChild(c), this.engineView = c, this.engine.generateView(this.engineView, b), d = Entry.createElement("canvas"), d.addClass("entryCanvasPhone"), d.id = "entryCanvas", d.width = 640, d.height = 360, c.insertBefore(d, this.engine.footerView_), this.canvas_ = d, this.stage.initStage(this.canvas_), d = Entry.createElement("div"), a.appendChild(d), this.containerView = d, this.container.generateView(this.containerView, b), d = Entry.createElement("div"), - a.appendChild(d), this.playgroundView = d, this.playground.generateView(this.playgroundView, b)); - } else { - Entry.documentMousedown.attach(this, this.cancelObjectEdit); - var d = Entry.createElement("div"); - a.appendChild(d); - this.sceneView = d; - this.scene.generateView(this.sceneView, b); - d = Entry.createElement("div"); - this.sceneView.appendChild(d); - this.stateManagerView = d; - this.stateManager.generateView(this.stateManagerView, b); - var c = Entry.createElement("div"); - a.appendChild(c); - this.engineView = c; - this.engine.generateView(this.engineView, b); - d = Entry.createElement("canvas"); - d.addClass("entryCanvasWorkspace"); - d.id = "entryCanvas"; - d.width = 640; - d.height = 360; - c.insertBefore(d, this.engine.addButton); - d.addEventListener("mousewheel", function(b) { - var a = Entry.variableContainer.getListById(Entry.stage.mouseCoordinate); - b = 0 < b.wheelDelta ? !0 : !1; - for (var d = 0;d < a.length;d++) { - var c = a[d]; - c.scrollButton_.y = b ? 46 <= c.scrollButton_.y ? c.scrollButton_.y - 23 : 23 : c.scrollButton_.y + 23; - c.updateView(); - } - }); - this.canvas_ = d; - this.stage.initStage(this.canvas_); - d = Entry.createElement("div"); - this.propertyPanel.generateView(a, b); - this.containerView = d; - this.container.generateView(this.containerView, b); - this.propertyPanel.addMode("object", this.container); - this.helper.generateView(this.containerView, b); - this.propertyPanel.addMode("helper", this.helper); - d = Entry.createElement("div"); - a.appendChild(d); - this.playgroundView = d; - this.playground.generateView(this.playgroundView, b); - this.propertyPanel.select("object"); - this.helper.bindWorkspace(this.playground.mainWorkspace); - } +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.start = function(a) { - this.FPS || (this.FPS = 60); - Entry.assert("number" == typeof this.FPS, "FPS must be number"); - Entry.engine.start(this.FPS); +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.parseOptions = function(a) { - this.type = a.type; - a.device && (this.device = a.device); - 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.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(b) { + this.clearHandle(); + this.transparent(); + this.trim(); + var a = this.canvas_.toDataURL(); + Entry.dispatchEvent("saveCanvasImage", {file:b ? this.file_ : this.file, image:a}); + this.file.modified = !1; }; -Entry.initFonts = function(a) { - this.fonts = a; - a || (this.fonts = []); +Entry.Painter.prototype.transparent = function() { + var b = this.canvas.width, a = this.canvas.height; + this.colorLayerData = this.ctx.getImageData(0, 0, b, a); + var d = b * (a - 1) * 4, c = 4 * (b - 1), e = 4 * (b * a - 1); + this.matchColorOnly(0, 255, 255, 255) ? this.fillTransparent(1, 1) : this.matchColorOnly(d, 255, 255, 255) ? this.fillTransparent(1, a) : this.matchColorOnly(c, 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.Activity = function(a, b) { - this.name = a; - this.timestamp = new Date; - a = []; - if (void 0 !== b) { - for (var d = 0, c = b.length;d < c;d++) { - var e = b[d]; - a.push({key:e[0], value:e[1]}); - } +Entry.Painter.prototype.trim = function() { + var b = this.canvas.width, a = this.ctx.getImageData(0, 0, b, this.canvas.height), d = a.data.length, c, e = null, f = null, g = null, h = null, k; + for (c = 0;c < d;c += 4) { + 0 !== a.data[c + 3] && (g = c / 4 % b, k = ~~(c / 4 / b), null === e && (e = k), null === f ? f = g : g < f && (f = g), null === h ? h = k : h < k && (h = k)); } - this.data = a; + b = h - e; + a = g - f; + d = null; + 0 === b || 0 === a ? (d = this.ctx.getImageData(0, 0, 1, 1), d.data[0] = 255, d.data[1] = 255, d.data[2] = 255, d.data[3] = 255, this.canvas_.width = 1, this.canvas_.height = 1) : (d = this.ctx.getImageData(f, e, a, b), this.canvas_.width = a, this.canvas_.height = b); + this.ctx_.putImageData(d, 0, 0); }; -Entry.ActivityReporter = function() { - this._activities = []; +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()); }; -(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.Painter.prototype.addPicture = function(b) { + this.initCommand(); + 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 d = this; + a.onload = function(a) { + d.addImage(a.target); + d.selectToolbox("cursor"); }; -})(Entry.ActivityReporter.prototype); -Entry.State = function(a, b, d, c) { - this.caller = b; - this.func = d; - 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.Painter.prototype.initCoordinator = function() { + 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.StateManager.prototype.generateView = function(a, b) { +Entry.Painter.prototype.toggleCoordinator = function() { + this.coordinator.visible = !this.coordinator.visible; + this.stage.update(); }; -Entry.StateManager.prototype.addCommand = function(a, b, d, c) { - 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.Painter.prototype.initDashedLine = function() { + createjs.Graphics.prototype.dashedLineTo = function(b, a, d, c, e) { + this.moveTo(b, a); + var f = d - b, g = c - a; + e = Math.floor(Math.sqrt(f * f + g * g) / e); + for (var f = f / e, g = g / e, h = 0;h++ < e;) { + b += f, a += g, this[0 === h % 2 ? "moveTo" : "lineTo"](b, a); } - 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]; + this[0 === h % 2 ? "moveTo" : "lineTo"](d, c); + return this; + }; + createjs.Graphics.prototype.drawDashedRect = function(b, a, d, c, e) { + this.moveTo(b, a); + d = b + d; + c = a + c; + this.dashedLineTo(b, a, d, a, e); + this.dashedLineTo(d, a, d, c, e); + this.dashedLineTo(d, c, b, c, e); + this.dashedLineTo(b, c, b, a, e); + return this; + }; + createjs.Graphics.prototype.drawResizableDashedRect = function(b, a, d, c, e, f) { + this.moveTo(b, a); + d = b + d; + c = a + c; + this.dashedLineTo(b + f, a, d - f, a, e); + this.dashedLineTo(d, a + f, d, c - f, e); + this.dashedLineTo(d - f, c, b + f, c, e); + this.dashedLineTo(b, c - f, b, a + f, e); + return this; + }; }; -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()) { - for (this.addActivity("redo");this.redoStack_.length;) { - var a = this.redoStack_.pop(); - a.func.apply(a.caller, a.params); - if (!0 !== a.isPass) { - break; - } - } - 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.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) { - var b = this; - 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 d = 0;d < this.sounds.length;d++) { - this.sounds[d].id || (this.sounds[d].id = Entry.generateHash()), Entry.initSound(this.sounds[d]); - } - 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 (d in this.pictures) { - (function(a) { - a.objectId = this.id; - a.id || (a.id = Entry.generateHash()); - var d = new Image; - if (a.fileurl) { - d.src = a.fileurl; - } else { - if (a.fileurl) { - d.src = a.fileurl; - } else { - var f = a.filename; - d.src = Entry.defaultPath + "/uploads/" + f.substring(0, 2) + "/" + f.substring(2, 4) + "/image/" + f + ".png"; - } - } - Entry.Loader.addQueue(); - d.onload = function(d) { - Entry.container.cachePicture(a.id + b.entity.id, this); - Entry.requestUpdate = !0; - Entry.Loader.removeQueue(); - }; - d.onerror = function(b) { - Entry.Loader.removeQueue(); - }; - })(this.pictures[d]); - } - } -}; -Entry.EntryObject.prototype.generateView = function() { - if ("workspace" == Entry.type) { - var a = Entry.createElement("li", this.id); - a.addClass("entryContainerListElementWorkspace"); - a.object = this; - Entry.Utils.disableContextmenu(a); - var b = this; - longPressTimer = null; - $(a).bind("mousedown touchstart", function(a) { - function d(b) { - b.stopPropagation(); - h && 5 < Math.sqrt(Math.pow(b.pageX - h.x, 2) + Math.pow(b.pageY - h.y, 2)) && longPressTimer && (clearTimeout(longPressTimer), longPressTimer = null); - } - function c(b) { - b.stopPropagation(); - e.unbind(".object"); - longPressTimer && (clearTimeout(longPressTimer), longPressTimer = null); - } - Entry.container.getObject(this.id) && Entry.container.selectObject(this.id); - var e = $(document), f = a.type, g = !1; - if (Entry.Utils.isRightButton(a)) { - a.stopPropagation(), Entry.documentMousedown.notify(a), g = !0, b._rightClick(a); - } else { - var h = {x:a.clientX, y:a.clientY}; - "touchstart" !== f || g || (a.stopPropagation(), Entry.documentMousedown.notify(a), longPressTimer = setTimeout(function() { - longPressTimer && (longPressTimer = null, b._rightClick(a)); - }, 1E3), e.bind("mousemove.object touchmove.object", d), e.bind("mouseup.object touchend.object", c)); - } - }); - this.view_ = a; - var d = this, a = Entry.createElement("ul"); - a.addClass("objectInfoView"); - Entry.objectEditable || a.addClass("entryHide"); - var c = Entry.createElement("li"); - c.addClass("objectInfo_visible"); - this.entity.getVisible() || c.addClass("objectInfo_unvisible"); - c.bindOnClick(function(b) { - Entry.engine.isState("run") || (b = d.entity, b.setVisible(!b.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 = d, b.setLock(!b.getLock()) ? this.addClass("objectInfo_lock") : this.removeClass("objectInfo_lock"), b.updateInputViews(b.getLock())); - }); - a.appendChild(c); - 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); - c = Entry.createElement("input"); - c.bindOnClick(function(b) { - b.preventDefault(); - Entry.container.selectObject(d.id); - this.readOnly || (this.focus(), this.select()); - }); - c.addClass("entryObjectNameWorkspace"); - a.appendChild(c); - this.nameView_ = c; - this.nameView_.entryObject = this; - c.setAttribute("readonly", !0); - var f = this; - this.nameView_.onblur = function(b) { - this.entryObject.name = this.value; - Entry.playground.reloadPlayground(); - }; - this.nameView_.onkeypress = function(b) { - 13 == b.keyCode && f.editObjectValues(!1); - }; - this.nameView_.value = this.name; - c = Entry.createElement("div"); - c.addClass("entryObjectEditWorkspace"); - c.object = this; - this.editView_ = c; - this.view_.appendChild(c); - $(c).mousedown(function(a) { - var d = b.isEditing; - a.stopPropagation(); - Entry.documentMousedown.notify(a); - Entry.engine.isState("run") || !1 !== d || (b.editObjectValues(!d), Entry.playground.object !== b && Entry.container.selectObject(b.id), b.nameView_.select()); - }); - c.blur = function(a) { - b.editObjectComplete(); - }; - Entry.objectEditable && Entry.objectDeletable && (c = Entry.createElement("div"), c.addClass("entryObjectDeleteWorkspace"), c.object = this, this.deleteView_ = c, this.view_.appendChild(c), c.bindOnClick(function(b) { - Entry.engine.isState("run") || Entry.container.removeObject(this.object); - })); - c = Entry.createElement("div"); - c.addClass("entryObjectInformationWorkspace"); - c.object = this; - this.isInformationToggle = !1; - a.appendChild(c); - this.informationView_ = c; - a = Entry.createElement("div"); - a.addClass("entryObjectRotationWrapperWorkspace"); - a.object = this; - this.view_.appendChild(a); - c = Entry.createElement("span"); - c.addClass("entryObjectCoordinateWorkspace"); - a.appendChild(c); - 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(); - this.select(); - }); - var h = Entry.createElement("span"); - h.addClass("entryObjectCoordinateSpanWorkspace"); - h.innerHTML = "Y:"; - var k = Entry.createElement("input"); - k.addClass("entryObjectCoordinateInputWorkspace entryObjectCoordinateInputWorkspace_right"); - k.bindOnClick(function(b) { - b.stopPropagation(); - this.select(); - }); - k.setAttribute("readonly", !0); - var l = Entry.createElement("span"); - l.addClass("entryObjectCoordinateSizeWorkspace"); - l.innerHTML = Lang.Workspace.Size + " : "; - var m = Entry.createElement("input"); - m.addClass("entryObjectCoordinateInputWorkspace", "entryObjectCoordinateInputWorkspace_size"); - m.bindOnClick(function(b) { - b.stopPropagation(); - this.select(); - }); - m.setAttribute("readonly", !0); - c.appendChild(e); - c.appendChild(g); - c.appendChild(h); - c.appendChild(k); - c.appendChild(l); - c.appendChild(m); - c.xInput_ = g; - c.yInput_ = k; - c.sizeInput_ = m; - this.coordinateView_ = c; - d = this; - g.onkeypress = function(b) { - 13 == b.keyCode && d.editObjectValues(!1); - }; - g.onblur = function(b) { - isNaN(g.value) || d.entity.setX(Number(g.value)); - d.updateCoordinateView(); - Entry.stage.updateObject(); - }; - k.onkeypress = function(b) { - 13 == b.keyCode && d.editObjectValues(!1); - }; - k.onblur = function(b) { - isNaN(k.value) || d.entity.setY(Number(k.value)); - d.updateCoordinateView(); - Entry.stage.updateObject(); - }; - m.onkeypress = function(b) { - 13 == b.keyCode && d.editObjectValues(!1); - }; - m.onblur = function(b) { - isNaN(m.value) || d.entity.setSize(Number(m.value)); - d.updateCoordinateView(); - Entry.stage.updateObject(); - }; - c = Entry.createElement("div"); - c.addClass("entryObjectRotateLabelWrapperWorkspace"); - this.view_.appendChild(c); - this.rotateLabelWrapperView_ = c; - e = Entry.createElement("span"); - e.addClass("entryObjectRotateSpanWorkspace"); - e.innerHTML = Lang.Workspace.rotation + " : "; - var n = Entry.createElement("input"); - n.addClass("entryObjectRotateInputWorkspace"); - n.setAttribute("readonly", !0); - n.bindOnClick(function(b) { - b.stopPropagation(); - this.select(); - }); - this.rotateSpan_ = e; - this.rotateInput_ = n; - h = Entry.createElement("span"); - h.addClass("entryObjectDirectionSpanWorkspace"); - h.innerHTML = Lang.Workspace.direction + " : "; - var q = Entry.createElement("input"); - q.addClass("entryObjectDirectionInputWorkspace"); - q.setAttribute("readonly", !0); - q.bindOnClick(function(b) { - b.stopPropagation(); - this.select(); - }); - this.directionInput_ = q; - c.appendChild(e); - c.appendChild(n); - c.appendChild(h); - c.appendChild(q); - c.rotateInput_ = n; - c.directionInput_ = q; - d = this; - n.onkeypress = function(b) { - 13 == b.keyCode && d.editObjectValues(!1); - }; - n.onblur = function(b) { - b = n.value; - -1 != b.indexOf("\u02da") && (b = b.substring(0, b.indexOf("\u02da"))); - isNaN(b) || d.entity.setRotation(Number(b)); - d.updateRotationView(); - Entry.stage.updateObject(); - }; - q.onkeypress = function(b) { - 13 == b.keyCode && d.editObjectValues(!1); - }; - q.onblur = function(b) { - b = q.value; - -1 != b.indexOf("\u02da") && (b = b.substring(0, b.indexOf("\u02da"))); - isNaN(b) || d.entity.setDirection(Number(b)); - d.updateRotationView(); - Entry.stage.updateObject(); - }; - c = Entry.createElement("div"); - c.addClass("rotationMethodWrapper"); - a.appendChild(c); - this.rotationMethodWrapper_ = c; - a = Entry.createElement("span"); - a.addClass("entryObjectRotateMethodLabelWorkspace"); - c.appendChild(a); - a.innerHTML = Lang.Workspace.rotate_method + " : "; - a = Entry.createElement("div"); - a.addClass("entryObjectRotateModeWorkspace"); - a.addClass("entryObjectRotateModeAWorkspace"); - a.object = this; - this.rotateModeAView_ = a; - c.appendChild(a); - a.bindOnClick(function(b) { - 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; - c.appendChild(a); - a.bindOnClick(function(b) { - 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; - c.appendChild(a); - a.bindOnClick(function(b) { - Entry.engine.isState("run") || this.object.getLock() || (this.object.initRotateValue("none"), this.object.setRotateMethod("none")); - }); - this.updateThumbnailView(); - this.updateCoordinateView(); - this.updateRotateMethodView(); - this.updateInputViews(); - this.updateCoordinateView(!0); - this.updateRotationView(!0); - return this.view_; - } - if ("phone" == Entry.type) { - return a = Entry.createElement("li", this.id), a.addClass("entryContainerListElementWorkspace"), a.object = this, a.bindOnClick(function(b) { - 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.preventDefault(); - Entry.container.removeObject(b); - }}])), this.view_ = a, a = Entry.createElement("ul"), a.addClass("objectInfoView"), c = Entry.createElement("li"), c.addClass("objectInfo_visible"), e = Entry.createElement("li"), e.addClass("objectInfo_lock"), a.appendChild(c), 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), - c = Entry.createElement("input"), c.addClass("entryObjectNameWorkspace"), a.appendChild(c), this.nameView_ = c, this.nameView_.entryObject = this, this.nameView_.onblur = function() { - this.entryObject.name = this.value; - Entry.playground.reloadPlayground(); - }, this.nameView_.onkeypress = function(b) { - 13 == b.keyCode && d.editObjectValues(!1); - }, this.nameView_.value = this.name, Entry.objectEditable && Entry.objectDeletable && (c = Entry.createElement("div"), c.addClass("entryObjectDeletePhone"), c.object = this, this.deleteView_ = c, this.view_.appendChild(c), c.bindOnClick(function(b) { - Entry.engine.isState("run") || Entry.container.removeObject(this.object); - })), c = Entry.createElement("button"), c.addClass("entryObjectEditPhone"), c.object = this, c.bindOnClick(function(b) { - if (b = Entry.container.getObject(this.id)) { - Entry.container.selectObject(b.id), Entry.playground.injectObject(b); - } - }), this.view_.appendChild(c), c = Entry.createElement("div"), c.addClass("entryObjectInformationWorkspace"), c.object = this, this.isInformationToggle = !1, a.appendChild(c), this.informationView_ = c, c = Entry.createElement("div"), c.addClass("entryObjectRotateLabelWrapperWorkspace"), this.view_.appendChild(c), this.rotateLabelWrapperView_ = c, e = Entry.createElement("span"), e.addClass("entryObjectRotateSpanWorkspace"), e.innerHTML = Lang.Workspace.rotation + " : ", n = Entry.createElement("input"), - n.addClass("entryObjectRotateInputWorkspace"), this.rotateSpan_ = e, this.rotateInput_ = n, h = Entry.createElement("span"), h.addClass("entryObjectDirectionSpanWorkspace"), h.innerHTML = Lang.Workspace.direction + " : ", q = Entry.createElement("input"), q.addClass("entryObjectDirectionInputWorkspace"), this.directionInput_ = q, c.appendChild(e), c.appendChild(n), c.appendChild(h), c.appendChild(q), c.rotateInput_ = n, c.directionInput_ = q, d = this, n.onkeypress = function(b) { - 13 == b.keyCode && (b = n.value, -1 != b.indexOf("\u02da") && (b = b.substring(0, b.indexOf("\u02da"))), isNaN(b) || d.entity.setRotation(Number(b)), d.updateRotationView(), n.blur()); - }, n.onblur = function(b) { - d.entity.setRotation(d.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) || d.entity.setDirection(Number(b)), d.updateRotationView(), q.blur()); - }, q.onblur = function(b) { - d.entity.setDirection(d.entity.getDirection()); - Entry.stage.updateObject(); - }, a = Entry.createElement("div"), a.addClass("entryObjectRotationWrapperWorkspace"), a.object = this, this.view_.appendChild(a), c = Entry.createElement("span"), c.addClass("entryObjectCoordinateWorkspace"), a.appendChild(c), 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, m = Entry.createElement("input"), m.addClass("entryObjectCoordinateInputWorkspace", "entryObjectCoordinateInputWorkspace_size"), c.appendChild(e), c.appendChild(g), c.appendChild(h), c.appendChild(k), c.appendChild(l), c.appendChild(m), - c.xInput_ = g, c.yInput_ = k, c.sizeInput_ = m, this.coordinateView_ = c, d = this, g.onkeypress = function(b) { - 13 == b.keyCode && (isNaN(g.value) || d.entity.setX(Number(g.value)), d.updateCoordinateView(), d.blur()); - }, g.onblur = function(b) { - d.entity.setX(d.entity.getX()); - Entry.stage.updateObject(); - }, k.onkeypress = function(b) { - 13 == b.keyCode && (isNaN(k.value) || d.entity.setY(Number(k.value)), d.updateCoordinateView(), d.blur()); - }, k.onblur = function(b) { - d.entity.setY(d.entity.getY()); - Entry.stage.updateObject(); - }, c = Entry.createElement("div"), c.addClass("rotationMethodWrapper"), a.appendChild(c), this.rotationMethodWrapper_ = c, a = Entry.createElement("span"), a.addClass("entryObjectRotateMethodLabelWorkspace"), c.appendChild(a), a.innerHTML = Lang.Workspace.rotate_method + " : ", a = Entry.createElement("div"), a.addClass("entryObjectRotateModeWorkspace"), a.addClass("entryObjectRotateModeAWorkspace"), a.object = this, this.rotateModeAView_ = a, c.appendChild(a), a.bindOnClick(function(b) { - Entry.engine.isState("run") || this.object.setRotateMethod("free"); - }), a = Entry.createElement("div"), a.addClass("entryObjectRotateModeWorkspace"), a.addClass("entryObjectRotateModeBWorkspace"), a.object = this, this.rotateModeBView_ = a, c.appendChild(a), a.bindOnClick(function(b) { - Entry.engine.isState("run") || this.object.setRotateMethod("vertical"); - }), a = Entry.createElement("div"), a.addClass("entryObjectRotateModeWorkspace"), a.addClass("entryObjectRotateModeCWorkspace"), a.object = this, this.rotateModeCView_ = a, c.appendChild(a), a.bindOnClick(function(b) { - 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.setText = function(a) { - Entry.assert("string" == typeof a, "object text must be string"); - this.text = a; -}; -Entry.EntryObject.prototype.setScript = function(a) { - this.script = a; -}; -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; - if ("sprite" == this.objectType) { - var d = a.sprite.pictures[0].dimension; - b.regX = d.width / 2; - b.regY = d.height / 2; - b.scaleX = b.scaleY = "background" == a.sprite.category.main || "new" == a.sprite.category.main ? Math.max(270 / d.height, 480 / d.width) : "new" == a.sprite.category.main ? 1 : 200 / (d.width + d.height); - b.width = d.width; - b.height = d.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, d = "", a.bold && (d += "bold "), a.italic && (d += "italic "), b.underline = a.underline, b.strike = a.strike, b.font = d + "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; - } - } else { - b.underline = !1, b.strike = !1, b.font = "20px Nanum Gothic", b.colour = "#000000", b.bgColor = "#ffffff"; - } - } - } - return b; -}; -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")'; - } - } 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, d = this.coordinateView_.sizeInput_.value, c = this.entity.getX().toFixed(1), e = this.entity.getY().toFixed(1), f = this.entity.getSize().toFixed(1); - a != c && (this.coordinateView_.xInput_.value = c); - b != e && (this.coordinateView_.yInput_.value = e); - d != 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.select = function(a) { - 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.removePicture = function(a) { - 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]); - 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, d = b.length, c = 0;c < d;c++) { - if (b[c].id == a) { - return b[c]; - } - } - for (c = 0;c < d;c++) { - if (b[c].name == a) { - return b[c]; - } - } - a = Entry.parseNumber(a); - if ((!1 !== a || "boolean" != typeof a) && d >= a && 0 < a) { - return b[a - 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; - return; - } - } - throw Error("No picture found"); -}; -Entry.EntryObject.prototype.getPrevPicture = function(a) { - for (var b = this.pictures, d = b.length, c = 0;c < d;c++) { - if (b[c].id == a) { - return b[0 == c ? d - 1 : c - 1]; - } - } -}; -Entry.EntryObject.prototype.getNextPicture = function(a) { - for (var b = this.pictures, d = b.length, c = 0;c < d;c++) { - if (b[c].id == a) { - return b[c == d - 1 ? 0 : c + 1]; - } - } -}; -Entry.EntryObject.prototype.selectPicture = function(a) { - var b = this.getPicture(a); - if (b) { - this.selectedPicture = b, this.entity.setImage(b), 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); - Entry.playground.reloadPlayground(); - Entry.playground.injectSound(this); - return new Entry.State(this, this.addSound, b, a); -}; -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; - 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.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()); -}; -Entry.EntryObject.prototype.toggleInformation = function(a) { - this.setRotateMethod(this.getRotateMethod()); - void 0 === a && (a = this.isInformationToggle = !this.isInformationToggle); - a ? this.view_.addClass("informationToggle") : this.view_.removeClass("informationToggle"); -}; -Entry.EntryObject.prototype.addCloneEntity = function(a, b, d) { - 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.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, d = b.length, c = 0;c < d;c++) { - if (b[c].id == a) { - return b[c]; - } - } - for (c = 0;c < d;c++) { - if (b[c].name == a) { - return b[c]; - } - } - a = Entry.parseNumber(a); - if ((!1 !== a || "boolean" != typeof a) && d >= a && 0 < a) { - return b[a - 1]; - } - throw Error("No Sound"); -}; -Entry.EntryObject.prototype.addCloneVariables = function(a, b, d, c) { - b.variables = []; - b.lists = []; - d || (d = Entry.findObjsByKey(Entry.variableContainer.variables_, "object_", a.id)); - c || (c = Entry.findObjsByKey(Entry.variableContainer.lists_, "object_", a.id)); - for (a = 0;a < d.length;a++) { - b.variables.push(d[a].clone()); - } - for (a = 0;a < c.length;a++) { - b.lists.push(c[a].clone()); - } -}; -Entry.EntryObject.prototype.getLock = function() { - return this.lock; -}; -Entry.EntryObject.prototype.setLock = function(a) { - this.lock = a; - Entry.stage.updateObject(); - return a; -}; -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.editObjectValues = function(a) { - var b; - b = this.getLock() ? [this.nameView_] : [this.coordinateView_.xInput_, this.coordinateView_.yInput_, this.rotateInput_, this.directionInput_, this.coordinateView_.sizeInput_]; - if (a) { - var d = this.nameView_; - $(b).removeClass("selectedNotEditingObject"); - $(d).removeClass("selectedNotEditingObject"); - window.setTimeout(function() { - $(d).removeAttr("readonly"); - d.addClass("selectedEditingObject"); - }); - for (a = 0;a < b.length;a++) { - $(b[a]).removeAttr("readonly"), b[a].addClass("selectedEditingObject"); - } - this.isEditing = !0; - } else { - for (a = 0;a < b.length;a++) { - b[a].blur(!0); - } - this.nameView_.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); - } -}; -Entry.EntryObject.prototype.addStampEntity = function(a) { - a = new Entry.StampEntity(this, a); - Entry.stage.loadEntity(a); - this.clonedEntities.push(a); - Entry.stage.sortZorder(); -}; -Entry.EntryObject.prototype.getClonedEntities = function() { - var a = []; - this.clonedEntities.map(function(b) { - b.isStamp || a.push(b); - }); - return a; -}; -Entry.EntryObject.prototype.getStampEntities = function() { - var a = []; - this.clonedEntities.map(function(b) { - b.isStamp && a.push(b); - }); - return a; -}; -Entry.EntryObject.prototype.clearExecutor = function() { - this.script.clearExecutors(); -}; -Entry.EntryObject.prototype._rightClick = function(a) { - var b = this, d = [{text:Lang.Workspace.context_rename, callback:function(a) { - a.stopPropagation(); - 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); - }}, {text:Lang.Workspace.context_remove, callback:function() { - Entry.container.removeObject(b); - }}, {text:Lang.Workspace.copy_file, callback:function() { - Entry.container.setCopiedObject(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); - }}]; - a = Entry.Utils.convertMouseEvent(a); - Entry.ContextMenu.show(d, "workspace-contextmenu", {x:a.clientX, y:a.clientY}); -}; -Entry.Painter = function() { - this.toolbox = {selected:"cursor"}; - this.stroke = {enabled:!1, fillColor:"#000000", lineColor:"#000000", thickness:1, fill:!0, transparent:!1, style:"line", locked:!1}; - this.file = {id:Entry.generateHash(), name:"\uc0c8\uadf8\ub9bc", modified:!1, mode:"new"}; - this.font = {name:"KoPub Batang", size:20, style:"normal"}; - this.selectArea = {}; - this.firstStatement = !1; -}; -Entry.Painter.prototype.initialize = function(a) { - this.generateView(a); - this.canvas = document.getElementById("entryPainterCanvas"); - this.canvas_ = document.getElementById("entryPainterCanvas_"); - this.stage = new createjs.Stage(this.canvas); - this.stage.autoClear = !0; - this.stage.enableDOMEvents(!0); - this.stage.enableMouseOver(10); - this.stage.mouseMoveOutside = !0; - createjs.Touch.enable(this.stage); - this.objectContainer = new createjs.Container; - this.objectContainer.name = "container"; - this.stage.addChild(this.objectContainer); - this.ctx = this.stage.canvas.getContext("2d"); - this.ctx.imageSmoothingEnabled = !1; - this.ctx.webkitImageSmoothingEnabled = !1; - this.ctx.mozImageSmoothingEnabled = !1; - this.ctx.msImageSmoothingEnabled = !1; - this.ctx.oImageSmoothingEnabled = !1; - this.ctx_ = this.canvas_.getContext("2d"); - this.initDashedLine(); - this.initPicture(); - this.initCoordinator(); - this.initHandle(); - this.initDraw(); - var b = 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")); - }); - this.selectToolbox("cursor"); -}; -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(d) { - "cursor" === b.toolbox.selected && (b.initCommand(), this.offset = {x:this.parent.x - this.x - d.stageX, y:this.parent.y - this.y - d.stageY}, this.parent.handleMode = "move", a.isSelectCenter = !1); - }); - a.rect.on("pressmove", function(d) { - "cursor" !== b.toolbox.selected || a.isSelectCenter || (b.doCommand(), this.parent.x = d.stageX + this.offset.x, this.parent.y = d.stageY + this.offset.y, b.updateImageHandle()); - }); - a.on("mouseup", function(a) { - b.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(); - }); - a.RHandle.on("pressmove", function(a) { - b.doCommand(); - var c = a.stageX - this.parent.x; - a = a.stageY - this.parent.y; - this.parent.rotation = 0 <= c ? Math.atan(a / c) / Math.PI * 180 + 90 : Math.atan(a / c) / Math.PI * 180 + 270; - b.updateImageHandle(); - }); - a.RHandle.cursor = "crosshair"; - a.addChild(a.RHandle); - a.on("mouseup", function(a) { - b.checkCommand(); - }); - a.visible = !1; - this.handle = a; - this.stage.addChild(a); - 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}; - }); - b.on("pressmove", function(b) { - a.doCommand(); - var c = 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 * c && 10 < this.parent.height * c && (this.parent.width *= c, this.parent.height *= c, this.offset = {x:b.stageX - this.parent.x + this.parent.regX, y:b.stageY - this.parent.y + this.parent.regY}); - a.updateImageHandle(); - }); - b.on("mouseup", function(b) { - a.checkCommand(); - }); - return b; -}; -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}; - }); - b.on("pressmove", function(b) { - a.doCommand(); - var c = Math.abs((b.stageX - this.parent.x + this.parent.regX) / this.offset.x); - 10 < this.parent.width * c && (this.parent.width *= c, this.offset = {x:b.stageX - this.parent.x + this.parent.regX}); - a.updateImageHandle(); - }); - b.on("mouseup", function(b) { - a.checkCommand(); - }); - return b; -}; -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}; - }); - b.on("pressmove", function(b) { - a.doCommand(); - var c = Math.abs((b.stageY - this.parent.y + this.parent.regY) / this.offset.y); - 10 < this.parent.height * c && (this.parent.height *= c, this.offset = {y:b.stageY - this.parent.y + this.parent.regY}); - a.updateImageHandle(); - }); - b.on("mouseup", function(b) { - a.checkCommand(); - }); - return b; -}; -Entry.Painter.prototype.updateImageHandle = function() { - if (this.handle.visible) { - var a = this.handle, b = a.direction, d = a.width, c = 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(-d / 2, -c / 2).lt(0, -c / 2).lt(0, -c / 2).lt(+d / 2, -c / 2).lt(+d / 2, +c / 2).lt(-d / 2, +c / 2).cp(); - a.notch.graphics.clear().f("rgba(0,0,1,0.01)").ss(2, 2, 0).s("#c1c7cd").lt(0, -c / 2).lt(0, -c / 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 && (d = this.selectedObject, this.selectedObject.text ? (d.width = this.selectedObject.width, d.height = this.selectedObject.height) : (d.width = d.image.width, d.height = d.image.height), d.scaleX = a.width / d.width, d.scaleY = a.height / d.height, d.x = a.x, d.y = a.y, d.regX = d.width / 2 + e / d.scaleX, d.regY = d.height / 2 + f / d.scaleY, d.rotation = a.rotation, d.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(d.width * d.scaleX).toFixed(0), this.objectHeightInput.value = Math.abs(d.height * d.scaleY).toFixed(0), this.objectRotateInput.value = (1 * d.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"], d = Math.floor((a.rotation + 22.5) % 180 / 45), c = 0;c < d;c++) { - 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) { - this.clearHandle(); - a || 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; - } - 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); -}; -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 d = new Image; - d.id = b.id ? b.id : Entry.generateHash(); - a.file.id = d.id; - a.file.name = b.name; - a.file.mode = "edit"; - d.src = b.fileurl ? b.fileurl : Entry.defaultPath + "/uploads/" + b.filename.substring(0, 2) + "/" + b.filename.substring(2, 4) + "/image/" + b.filename + ".png"; - d.onload = function(b) { - a.addImage(b.target); - }; - } - }); - Entry.addEventListener("pictureImport", function(b) { - a.addPicture(b); - }); - Entry.addEventListener("pictureNameChanged", function(b) { - a.file.name = b.name; - }); - Entry.addEventListener("pictureClear", function(b) { - a.file.modified = !1; - a.file.id = ""; - a.file.name = ""; - a.clearCanvas(); - }); -}; -Entry.Painter.prototype.initDraw = function() { +Entry.Painter.prototype.generateView = function(b) { var a = this; - this.stage.on("stagemousedown", function(b) { - a.stagemousedown(b); - }); - this.stage.on("stagemouseup", function(b) { - a.stagemouseup(b); - }); - this.stage.on("stagemousemove", function(b) { - a.stagemousemove(b); - }); -}; -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; - 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; - 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; - 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(); -}; -Entry.Painter.prototype.updateHandle_ = function() { - this.stage.getChildIndex(-1 < this._handle) && this.stage.addChild(this._handle); - 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, d, c, 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 >= d - e / 100 * d && g <= d + e / 100 * d && a >= c - e / 100 * c && a <= c + e / 100 * c; -}; -Entry.Painter.prototype.matchColorOnly = function(a, b, d, c) { - return b === this.colorLayerData.data[a] && d === this.colorLayerData.data[a + 1] && c === this.colorLayerData.data[a + 2] ? !0 : !1; -}; -Entry.Painter.prototype.matchColor = function(a, b, d, c, e) { - return b === this.colorLayerData.data[a] && d === this.colorLayerData.data[a + 1] && c === this.colorLayerData.data[a + 2] && e === this.colorLayerData.data[a + 3] ? !0 : !1; -}; -Entry.Painter.prototype.colorPixel = function(a, b, d, c, e) { - e || (e = 255); - this.stroke.transparent && (e = c = d = b = 0); - this.colorLayerData.data[a] = b; - this.colorLayerData.data[a + 1] = d; - this.colorLayerData.data[a + 2] = c; - 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, d = document.getElementById("entryPainterAttrFontName").value, c = document.getElementById("entryPainterAttrFontSize").value; - a = new createjs.Text(a, b + " " + c + 'px "' + d + '"', 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 < b.image.height) { - var d = 540 / b.image.height; - b.scaleX = d; - b.scaleY = d; - } - b.name = a.id; - b.id = a.id; - this.selectObject(b); - this.stage.update(); -}; -Entry.Painter.prototype.createBrush = function() { - this.initCommand(); - this.brush = new createjs.Shape; - this.objectContainer.addChild(this.brush); - this.stage.update(); -}; -Entry.Painter.prototype.createEraser = function() { - this.initCommand(); - this.eraser = new createjs.Shape; - this.objectContainer.addChild(this.eraser); - this.stage.update(); -}; -Entry.Painter.prototype.clearHandle = function() { - this.handle.visible && (this.handle.visible = !1); - this.coordinator.visible && (this.coordinator.visible = !1); - 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.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(); -}; -Entry.Painter.prototype.doCommand = function() { - this.isCommandValid = !0; -}; -Entry.Painter.prototype.checkCommand = function() { - this.isCommandValid || Entry.dispatchEvent("cancelLastCommand"); -}; -Entry.Painter.prototype.restorePainter = function(a) { - this.clearHandle(); - var b = 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(); - var d = this; - a.onload = function(b) { - b = new createjs.Bitmap(b.target); - d.objectContainer.removeAllChildren(); - d.objectContainer.addChild(b); - }; - Entry.stateManager && Entry.stateManager.addCommand("restore sprite", this, this.restorePainter, b); -}; -Entry.Painter.prototype.platten = function() { - this.colorLayerData = this.ctx.getImageData(0, 0, this.canvas.width, this.canvas.height); - this.reloadContext(); -}; -Entry.Painter.prototype.fill = function() { - if (!this.stroke.locked) { - this.stroke.locked = !0; - 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 d = new createjs.Point(this.stage.mouseX, this.stage.mouseY); - d.x = Math.round(d.x); - d.y = Math.round(d.y); - for (var c = 4 * (d.y * a + d.x), e = this.colorLayerData.data[c], f = this.colorLayerData.data[c + 1], g = this.colorLayerData.data[c + 2], h = this.colorLayerData.data[c + 3], k, l, d = [[d.x, d.y]], m = Entry.hex2rgb(this.stroke.lineColor);d.length;) { - for (var c = d.pop(), n = c[0], q = c[1], c = 4 * (q * a + n);0 <= q && this.matchColor(c, e, f, g, h);) { - --q, c -= 4 * a; - } - c += 4 * a; - q += 1; - for (l = k = !1;q < b - 1 && this.matchColor(c, e, f, g, h);) { - q += 1, this.colorPixel(c, m.r, m.g, m.b), 0 < n && (this.matchColor(c - 4, e, f, g, h) ? k || (d.push([n - 1, q]), k = !0) : k && (k = !1)), n < a - 1 && (this.matchColor(c + 4, e, f, g, h) ? l || (d.push([n + 1, q]), l = !0) : l && (l = !1)), c += 4 * a; - } - if (1080 < d.length) { - break; - } - } - this.file.modified = !0; - this.reloadContext(); - } -}; -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; - }; -}; -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); - 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.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.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_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(); -}; -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 ? - 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.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) && - 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) { - this.clearHandle(); - this.transparent(); - this.trim(); - var b = this.canvas_.toDataURL(); - Entry.dispatchEvent("saveCanvasImage", {file:a ? this.file_ : this.file, image:b}); - 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 d = a * (b - 1) * 4, c = 4 * (a - 1), e = 4 * (a * b - 1); - this.matchColorOnly(0, 255, 255, 255) ? this.fillTransparent(1, 1) : this.matchColorOnly(d, 255, 255, 255) ? this.fillTransparent(1, b) : this.matchColorOnly(c, 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; - 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), d = b.data.length, c, e = null, f = null, g = null, h = null, k; - for (c = 0;c < d;c += 4) { - 0 !== b.data[c + 3] && (g = c / 4 % a, k = ~~(c / 4 / a), 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); -}; -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.dispatchEvent("textUpdate"); - }}), this.inputField.show()); -}; -Entry.Painter.prototype.addPicture = function(a) { - 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 d = this; - b.onload = function(b) { - d.addImage(b.target); - d.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; -}; -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, d, c, e) { - this.moveTo(a, b); - var f = d - a, g = c - b; - 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); - } - this[0 === h % 2 ? "moveTo" : "lineTo"](d, c); - return this; - }; - createjs.Graphics.prototype.drawDashedRect = function(a, b, d, c, e) { - this.moveTo(a, b); - d = a + d; - c = b + c; - this.dashedLineTo(a, b, d, b, e); - this.dashedLineTo(d, b, d, c, e); - this.dashedLineTo(d, c, a, c, e); - this.dashedLineTo(a, c, a, b, e); - return this; - }; - createjs.Graphics.prototype.drawResizableDashedRect = function(a, b, d, c, e, f) { - this.moveTo(a, b); - d = a + d; - c = b + c; - this.dashedLineTo(a + f, b, d - f, b, e); - this.dashedLineTo(d, b + f, d, c - f, e); - this.dashedLineTo(d - f, c, a + f, c, e); - this.dashedLineTo(a, c - f, a, b + f, e); - return this; - }; -}; -Entry.Painter.prototype.generateView = function(a) { - var b = this; - this.view_ = a; + this.view_ = b; if (!Entry.type || "workspace" == Entry.type) { this.view_.addClass("entryPainterWorkspace"); var d = Entry.createElement("div", "entryPainterTop"); @@ -12092,26 +10092,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 d = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth; - b = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; - var c = parseInt(document.getElementById("entryCanvas").style.width), d = d - (c + 240), c = b - 349; - a.style.width = d + "px"; + a = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; + var c = parseInt(document.getElementById("entryCanvas").style.width), d = d - (c + 240), c = a - 349; + b.style.width = d + "px"; f.style.width = d - 54 + "px"; f.style.height = c + "px"; g.style.top = c + 30 + "px"; - g.style.height = b - c + "px"; + g.style.height = a - c + "px"; }); var h = Entry.createElement("nav", "entryPainterTopMenu"); h.addClass("entryPlaygroundPainterTopMenu"); @@ -12122,7 +10122,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; @@ -12137,7 +10137,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; @@ -12146,8 +10146,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; @@ -12171,7 +10171,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; @@ -12180,7 +10180,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; @@ -12189,7 +10189,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; @@ -12200,7 +10200,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"); @@ -12225,69 +10225,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"); d.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"); d.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"); d.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"); d.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"); d.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"); d.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"); d.appendChild(this.toolboxText); this.toolboxFill = Entry.createElement("li", "entryPainterToolboxFill"); this.toolboxFill.bindOnClick(function() { - b.selectToolbox("fill"); + a.selectToolbox("fill"); }); this.toolboxFill.addClass("entryPlaygroundPainterToolboxFill"); d.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"); d.appendChild(this.toolboxErase); c = Entry.createElement("li", "entryPainterToolboxCoordinate"); c.title = "\uc88c\ud45c"; c.bindOnClick(function() { - b.toggleCoordinator(); + a.toggleCoordinator(); }); c.addClass("entryPlaygroundPainterToolboxCoordinate"); d.appendChild(c); @@ -12312,8 +10312,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"); d.appendChild(this.objectWidthInput); @@ -12333,8 +10333,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"); d.appendChild(this.objectHeightInput); @@ -12358,8 +10358,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"; @@ -12383,18 +10383,18 @@ Entry.Painter.prototype.generateView = function(a) { this.attrCircleArea.appendChild(c); 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 d = Entry.createElement("div"); d.addClass("entryPlaygroundPainterAttrColorElement"); - "transparent" === a ? d.style.backgroundImage = "url(" + (Entry.mediaFilePath + "/transparent.png") + ")" : d.style.backgroundColor = a; + "transparent" === b ? d.style.backgroundImage = "url(" + (Entry.mediaFilePath + "/transparent.png") + ")" : d.style.backgroundColor = b; d.bindOnClick(function(d) { - "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; }); m.appendChild(d); }); @@ -12414,8 +10414,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 (c = 1;10 >= c;c++) { d = Entry.createElement("option"), d.value = c, d.innerHTML = c, e.appendChild(d); @@ -12447,7 +10447,7 @@ Entry.Painter.prototype.generateView = function(a) { this.attrBackgroundArea.painterAttrShapeBackgroundColor = q; d.appendChild(q); var r = !1; - q.bindOnClick(function(b) { + q.bindOnClick(function(a) { n.style.zIndex = "1"; this.style.zIndex = "10"; r = !0; @@ -12467,8 +10467,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 (c = 0;c < Entry.fonts.length;c++) { h = Entry.fonts[c], d = Entry.createElement("option"), d.value = h.family, d.innerHTML = h.name, k.appendChild(d); @@ -12483,8 +10483,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 (c = 20;72 >= c;c++) { d = Entry.createElement("option"), d.value = c, d.innerHTML = c, k.appendChild(d); @@ -12499,8 +10499,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 (c = 0;c < h.length;c++) { @@ -12522,26 +10522,26 @@ Entry.Painter.prototype.generateView = function(a) { c.value = "line"; var v = Entry.createElement("div"); v.addClass("painterAttrLineStyleBackgroundLine"); - t.bindOnClick(function(b) { + t.bindOnClick(function(a) { u.removeClass("entryRemove"); }); - u.blur = function(b) { + u.blur = function(a) { this.addClass("entryRemove"); }; - u.onmouseleave = function(b) { + u.onmouseleave = function(a) { this.addClass("entryRemove"); }; - c.bindOnClick(function(b) { + c.bindOnClick(function(a) { this.attrLineArea.removeClass(t); this.attrLineArea.appendChild(v); - this.attrLineArea.onchange(b); + this.attrLineArea.onchange(a); u.blur(); }); - v.bindOnClick(function(b) { + v.bindOnClick(function(a) { u.removeClass("entryRemove"); }); - this.attrLineArea.onchange = function(a) { - b.stroke.style = a.target.value; + this.attrLineArea.onchange = function(b) { + a.stroke.style = b.target.value; }; u.blur(); } @@ -12587,13 +10587,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"); @@ -12671,31 +10671,31 @@ Entry.Painter.prototype.selectToolbox = function(a) { this.toggleCoordinator(); } }; -Entry.Painter2 = function(a) { - this.view = a; +Entry.Painter2 = function(b) { + this.view = b; this.file = {id:Entry.generateHash(), name:"\uc0c8\uadf8\ub9bc", modified:!1, mode:"new"}; - Entry.addEventListener("pictureImport", function(b) { - this.addPicture(b); + Entry.addEventListener("pictureImport", function(a) { + this.addPicture(a); }.bind(this)); this.clipboard = null; }; -(function(a) { - a.initialize = function() { +(function(b) { + b.initialize = function() { if (!this.lc) { - var b = new Image; - b.src = "/lib/literallycanvas/lib/img/transparent-pattern.png"; + var a = new Image; + a.src = "/lib/literallycanvas/lib/img/transparent-pattern.png"; this.lc = LC.init(this.view, {imageURLPrefix:"/lib/literallycanvas/lib/img", zoomMax:3, zoomMin:.5, toolbarPosition:"bottom", imageSize:{width:960, height:540}, backgroundShapes:[LC.createShape("Rectangle", {x:0, y:0, width:960, height:540, strokeWidth:0, strokeColor:"transparent"})]}); - b.onload = function() { + a.onload = function() { this.lc.repaintLayer("background"); }.bind(this); - b = function(b) { - b.shape && !b.opts && b.shape.isPass || b.opts && b.opts.isPass ? Entry.do("processPicture", b, this.lc) : Entry.do("editPicture", b, this.lc); + a = function(a) { + a.shape && !a.opts && a.shape.isPass || a.opts && a.opts.isPass ? Entry.do("processPicture", a, this.lc) : Entry.do("editPicture", a, this.lc); this.file.modified = !0; }.bind(this); - this.lc.on("clear", b); - this.lc.on("shapeEdit", b); - this.lc.on("shapeSave", b); - this.lc.on("toolChange", function(b) { + this.lc.on("clear", a); + this.lc.on("shapeEdit", a); + this.lc.on("shapeSave", a); + this.lc.on("toolChange", function(a) { this.updateEditMenu(); }.bind(this)); this.lc.on("lc-pointerdrag", this.stagemousemove.bind(this)); @@ -12706,87 +10706,86 @@ Entry.Painter2 = function(a) { Entry.keyUpped && Entry.keyUpped.attach(this, this._keyboardUpControl); } }; - a.show = function() { + b.show = function() { this.lc || this.initialize(); this.isShow = !0; }; - a.hide = function() { + b.hide = function() { this.isShow = !1; }; - a.changePicture = function(b) { - this.file && this.file.id === b.id || (this.file.modified && confirm("\uc218\uc815\ub41c \ub0b4\uc6a9\uc744 \uc800\uc7a5\ud558\uc2dc\uaca0\uc2b5\ub2c8\uae4c?") && this.file_save(!0), this.file.modified = !1, this.lc.clear(!1), this.file.id = b.id ? b.id : Entry.generateHash(), this.file.name = b.name, this.file.mode = "edit", this.addPicture(b, !0)); + b.changePicture = function(a) { + this.file && this.file.id === a.id || (this.file.modified && confirm("\uc218\uc815\ub41c \ub0b4\uc6a9\uc744 \uc800\uc7a5\ud558\uc2dc\uaca0\uc2b5\ub2c8\uae4c?") && this.file_save(!0), this.file.modified = !1, this.lc.clear(!1), this.file.id = a.id ? a.id : Entry.generateHash(), this.file.name = a.name, this.file.mode = "edit", this.addPicture(a, !0)); }; - a.addPicture = function(b, a) { + b.addPicture = function(a, b) { var c = new Image; - c.src = b.fileurl ? b.fileurl : Entry.defaultPath + "/uploads/" + b.filename.substring(0, 2) + "/" + b.filename.substring(2, 4) + "/image/" + b.filename + ".png"; - b = b.dimension; - var e = LC.createShape("Image", {x:480, y:270, width:b.width, height:b.height, image:c}); - this.lc.saveShape(e, !a); + c.src = a.fileurl ? a.fileurl : Entry.defaultPath + "/uploads/" + a.filename.substring(0, 2) + "/" + a.filename.substring(2, 4) + "/image/" + a.filename + ".png"; + var e = a.dimension, f = LC.createShape("Image", {x:480, y:270, width:e.width, height:e.height, image:c}); + this.lc.saveShape(f, !b); c.onload = function() { this.lc.setTool(this.lc.tools.SelectShape); - this.lc.tool.setShape(this.lc, e); + this.lc.tool.setShape(this.lc, f); }.bind(this); }; - a.copy = function() { + b.copy = function() { if ("SelectShape" === this.lc.tool.name && this.lc.tool.selectedShape) { - var b = this.lc.tool.selectedShape; - this.clipboard = {className:b.className, data:b.toJSON()}; + var a = this.lc.tool.selectedShape; + this.clipboard = {className:a.className, data:a.toJSON()}; this.updateEditMenu(); } }; - a.cut = function() { + b.cut = function() { "SelectShape" === this.lc.tool.name && this.lc.tool.selectedShape && (this.copy(), this.lc.removeShape(this.lc.tool.selectedShape), this.lc.tool.setShape(this.lc, null)); }; - a.paste = function() { + b.paste = function() { if (this.clipboard) { - var b = this.lc.addShape(this.clipboard); + var a = this.lc.addShape(this.clipboard); this.lc.setTool(this.lc.tools.SelectShape); - this.lc.tool.setShape(this.lc, b); + this.lc.tool.setShape(this.lc, a); } }; - a.updateEditMenu = function() { - var b = "SelectShape" === this.lc.tool.name ? "block" : "none"; - this._cutButton.style.display = b; - this._copyButton.style.display = b; + b.updateEditMenu = function() { + var a = "SelectShape" === this.lc.tool.name ? "block" : "none"; + this._cutButton.style.display = a; + this._copyButton.style.display = a; this._pasteButton.style.display = this.clipboard ? "block" : "none"; }; - a.file_save = function() { + b.file_save = function() { this.lc.trigger("dispose"); - var b = this.lc.getImage().toDataURL(); + var a = this.lc.getImage().toDataURL(); this.file_ = JSON.parse(JSON.stringify(this.file)); - Entry.dispatchEvent("saveCanvasImage", {file:this.file_, image:b}); + Entry.dispatchEvent("saveCanvasImage", {file:this.file_, image:a}); this.file.modified = !1; }; - a.newPicture = function() { - 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); + b.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); }; - a._keyboardPressControl = function(b) { - if (this.isShow && !Entry.Utils.isInInput(b)) { - var a = b.keyCode || b.which, c = b.ctrlKey; - 8 == a || 46 == a ? (this.cut(), b.preventDefault()) : c && (67 == a ? this.copy() : 88 == a && this.cut()); - c && 86 == a && this.paste(); - this.lc.trigger("keyDown", b); + b._keyboardPressControl = function(a) { + if (this.isShow && !Entry.Utils.isInInput(a)) { + var b = a.keyCode || a.which, c = a.ctrlKey; + 8 == b || 46 == b ? (this.cut(), a.preventDefault()) : c && (67 == b ? this.copy() : 88 == b && this.cut()); + c && 86 == b && this.paste(); + this.lc.trigger("keyDown", a); } }; - a._keyboardUpControl = function(b) { - this.lc.trigger("keyUp", b); + b._keyboardUpControl = function(a) { + this.lc.trigger("keyUp", a); }; - a.initTopBar = function() { - var b = this, a = Entry.createElement(document.getElementById("canvas-top-menu")); - a.addClass("entryPlaygroundPainterTop"); - a.addClass("entryPainterTop"); + b.initTopBar = function() { + var a = this, b = Entry.createElement(document.getElementById("canvas-top-menu")); + b.addClass("entryPlaygroundPainterTop"); + b.addClass("entryPainterTop"); var c = Entry.createElement("nav", "entryPainterTopMenu"); c.addClass("entryPlaygroundPainterTopMenu"); - a.appendChild(c); + b.appendChild(c); var e = Entry.createElement("ul"); c.appendChild(e); var f = Entry.createElement("li"); c.appendChild(f); c = Entry.createElement("a", "entryPainterTopMenuFileNew"); c.bindOnClick(function() { - b.newPicture(); + a.newPicture(); }); c.addClass("entryPlaygroundPainterTopMenuFileNew"); c.innerHTML = Lang.Workspace.new_picture; @@ -12801,7 +10800,7 @@ Entry.Painter2 = function(a) { f.appendChild(c); var g = Entry.createElement("a", "entryPainterTopMenuFileSave"); g.bindOnClick(function() { - b.file_save(!1); + a.file_save(!1); }); g.addClass("entryPainterTopMenuFileSave"); g.innerHTML = Lang.Workspace.painter_file_save; @@ -12810,8 +10809,8 @@ Entry.Painter2 = function(a) { f.appendChild(c); f = Entry.createElement("a", "entryPainterTopMenuFileSaveAs"); f.bindOnClick(function() { - b.file.mode = "new"; - b.file_save(!1); + a.file.mode = "new"; + a.file_save(!1); }); f.addClass("entryPlaygroundPainterTopMenuFileSaveAs"); f.innerHTML = Lang.Workspace.painter_file_saveas; @@ -12835,7 +10834,7 @@ Entry.Painter2 = function(a) { e.appendChild(f); c = Entry.createElement("a", "entryPainterTopMenuEditCopy"); c.bindOnClick(function() { - b.copy(); + a.copy(); }); c.addClass("entryPlaygroundPainterTopMenuEditCopy"); c.innerHTML = Lang.Workspace.copy_file; @@ -12845,7 +10844,7 @@ Entry.Painter2 = function(a) { e.appendChild(f); c = Entry.createElement("a", "entryPainterTopMenuEditCut"); c.bindOnClick(function() { - b.cut(); + a.cut(); }); c.addClass("entryPlaygroundPainterTopMenuEditCut"); c.innerHTML = Lang.Workspace.cut_picture; @@ -12855,7 +10854,7 @@ Entry.Painter2 = function(a) { e.appendChild(f); c = Entry.createElement("a", "entryPainterTopMenuEditPaste"); c.bindOnClick(function() { - b.paste(); + a.paste(); }); c.addClass("entryPlaygroundPainterTopMenuEditPaste"); c.innerHTML = Lang.Workspace.paste_picture; @@ -12867,413 +10866,414 @@ Entry.Painter2 = function(a) { e.addClass("entryPlaygroundPainterTopMenuEditEraseAll"); e.innerHTML = Lang.Workspace.remove_all; e.bindOnClick(function() { - b.lc.clear(); + a.lc.clear(); }); f.appendChild(e); this.painterTopStageXY = e = Entry.createElement("div", "entryPainterTopStageXY"); e.addClass("entryPlaygroundPainterTopStageXY"); - a.appendChild(e); + b.appendChild(e); Entry.addEventListener("pictureSelected", this.changePicture.bind(this)); }; - a.stagemousemove = function(b) { - this.painterTopStageXY.textContent = "x:" + b.x.toFixed(1) + ", y:" + b.y.toFixed(1); + b.stagemousemove = function(a) { + this.painterTopStageXY.textContent = "x:" + a.x.toFixed(1) + ", y:" + a.y.toFixed(1); }; })(Entry.Painter2.prototype); -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 c = 0;c < b.length;c++) { - a += this.Thread(b[c]); + var b = ""; + a = a.getThreads(); + for (var c = 0;c < a.length;c++) { + b += this.Thread(a[c]); } - 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 c = 0;c < b.length;c++) { - a += this.Block(b[c]); + var b = ""; + a = a.getBlocks(); + for (var c = 0;c < a.length;c++) { + b += this.Block(a[c]); } - 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], c = this.publishIterateVariable(); - b = this.Thread(b.statements[0]); + b.BasicIteration = function(a) { + var b = a.params[0], c = this.publishIterateVariable(); + a = this.Thread(a.statements[0]); this.unpublishIterateVariable(); - return "for (var " + c + " = 0; " + c + " < " + a + "; " + c + "++){\n" + this.indent(b) + "}\n"; + return "for (var " + c + " = 0; " + c + " < " + b + "; " + c + "++){\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 = [], c = []; +(function(b) { + b.Program = function(a) { + var b = [], c = []; c.push({type:this.syntax.Program}); - var e = this.initScope(b), c = c.concat(this.BlockStatement(b)); + var e = this.initScope(a), c = c.concat(this.BlockStatement(a)); this.unloadScope(); - a.push(c); - return a = a.concat(e); + b.push(c); + 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, c = b.test, e = b.update, f = b.body; + b.ForStatement = function(a) { + var b = a.init, c = 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 = c.operator, c = c.right.value, h = 0; - "++" != e.operator && (e = a, a = c, c = e); + var f = this[f.type](f), b = b.declarations[0].init.value, g = c.operator, c = c.right.value, h = 0; + "++" != e.operator && (e = b, b = c, c = e); switch(g) { case "<": - h = c - a; + h = c - b; break; case "<=": - h = c + 1 - a; + h = c + 1 - b; break; case ">": - h = a - c; + h = b - c; break; case ">=": - h = a + 1 - c; + h = b + 1 - c; } - return this.BasicIteration(b, h, f); + return this.BasicIteration(a, h, f); }; - a.BlockStatement = function(b) { - var a = []; - b = b.body; - for (var c = 0;c < b.length;c++) { - var e = b[c], f = this[e.type](e); + b.BlockStatement = function(a) { + var b = []; + a = a.body; + for (var c = 0;c < a.length;c++) { + var e = a[c], 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, c = this.syntax.WhileStatement, a = this[a.type](a); + b.WhileStatement = function(a) { + var b = a.body, c = this.syntax.WhileStatement, b = this[b.type](b); if (c) { - 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, c = b.property; - console.log(a.type); - a = this[a.type](a); - console.log(a); - c = this[c.type](c, 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, c = a.property; + console.log(b.type); + b = this[b.type](b); + console.log(b); + c = this[c.type](c, 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 = c; - if (!a) { - throw {message:c + "\uc774(\uac00) \uc874\uc7ac\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.", node:b}; + b = c; + if (!b) { + throw {message:c + "\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 = [], c = 0;c < b.length;c++) { - var e = b[c]; - "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)]}]))); + b.scanDefinition = function(a) { + a = a.body; + for (var b = [], c = 0;c < a.length;c++) { + var e = a[c]; + "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 a; + return b; }; - a.BasicFunction = function(b, a) { + b.BasicFunction = function(a, b) { return null; }; - a.BasicIteration = function(b, a, c) { + b.BasicIteration = function(a, b, c) { var e = this.syntax.BasicIteration; if (!e) { - 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}; } - return {params:[a], type:e, statements:[c]}; + return {params:[b], type:e, statements:[c]}; }; - a.BasicWhile = function(b, a) { - var c = b.test.raw; + b.BasicWhile = function(a, b) { + var c = a.test.raw; if (this.syntax.BasicWhile[c]) { - return {type:this.syntax.BasicWhile[c], statements:[a]}; + return {type:this.syntax.BasicWhile[c], statements:[b]}; } - throw {message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b.test}; + throw {message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a.test}; }; - a.BasicIf = function(b) { - var a = b.consequent, a = this[a.type](a); + b.BasicIf = function(a) { + var b = a.consequent, b = this[b.type](b); try { - var c = "", e = "===" === b.test.operator ? "==" : b.test.operator; - if ("Identifier" === b.test.left.type && "Literal" === b.test.right.type) { - c = b.test.left.name + " " + e + " " + b.test.right.raw; + var c = "", e = "===" === a.test.operator ? "==" : a.test.operator; + if ("Identifier" === a.test.left.type && "Literal" === a.test.right.type) { + c = a.test.left.name + " " + e + " " + a.test.right.raw; } else { - if ("Literal" === b.test.left.type && "Identifier" === b.test.right.type) { - c = b.test.right.name + " " + e + " " + b.test.left.raw; + if ("Literal" === a.test.left.type && "Identifier" === a.test.right.type) { + c = a.test.right.name + " " + e + " " + a.test.left.raw; } else { throw Error(); } } if (this.syntax.BasicIf[c]) { - return Array.isArray(a) || "object" !== typeof a || (a = [a]), {type:this.syntax.BasicIf[c], statements:[a]}; + return Array.isArray(b) || "object" !== typeof b || (b = [b]), {type:this.syntax.BasicIf[c], statements:[b]}; } throw Error(); } catch (f) { - throw {message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b.test}; + throw {message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a.test}; } }; })(Entry.JSParser.prototype); Entry.ParserOld = {}; -Entry.Parser = function(a, b, d) { - this._mode = a; +Entry.Parser = function(b, a, d) { + this._mode = b; this.syntax = {}; this.codeMirror = d; - this._lang = b || "js"; + this._lang = a || "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); + "maze" === b && (this._stageId = Number(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); - b = this.syntax; + a = this.syntax; var c = {}, e; - for (e in b.Scope) { - c[e + "();\n"] = b.Scope[e]; + for (e in a.Scope) { + c[e + "();\n"] = a.Scope[e]; } - "BasicIf" in b && (c.front = "BasicIf"); - CodeMirror.commands.javascriptComplete = function(b) { - CodeMirror.showHint(b, null, {globalScope:c}); + "BasicIf" in a && (c.front = "BasicIf"); + CodeMirror.commands.javascriptComplete = function(a) { + CodeMirror.showHint(a, null, {globalScope:c}); }; - d.on("keyup", function(b, a) { - !b.state.completionActive && 65 <= a.keyCode && 95 >= a.keyCode && CodeMirror.showHint(b, null, {completeSingle:!1, globalScope:c}); + d.on("keyup", function(a, b) { + !a.state.completionActive && 65 <= b.keyCode && 95 >= b.keyCode && CodeMirror.showHint(a, null, {completeSingle:!1, globalScope:c}); }); break; case "block": this._parser = new Entry.BlockParser(this.syntax); } }; -(function(a) { - a.parse = function(b) { - var a = null; +(function(b) { + b.parse = function(a) { + var b = null; switch(this._lang) { case "js": try { - var c = acorn.parse(b), a = this._parser.Program(c); + var c = acorn.parse(a), b = this._parser.Program(c); } 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 = []; + 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": - b = this._parser.Code(b).match(/(.*{.*[\S|\s]+?}|.+)/g), a = Array.isArray(b) ? b.reduce(function(b, a, d) { - 1 === d && (b += "\n"); - return (-1 < a.indexOf("function") ? a + b : b + a) + "\n"; + a = this._parser.Code(a).match(/(.*{.*[\S|\s]+?}|.+)/g), b = Array.isArray(a) ? a.reduce(function(a, b, d) { + var c = ""; + 1 === d && (a += "\n"); + c = -1 < b.indexOf("function") ? b + a : a + b; + return c + "\n"; }) : ""; } - return a; + return b; }; - a.getLineNumber = function(b, a) { - var c = this.codeMirror.getValue(), e = {from:{}, to:{}}; - b = c.substring(0, b).split(/\n/gi); - e.from.line = b.length - 1; - e.from.ch = b[b.length - 1].length; - a = c.substring(0, a).split(/\n/gi); - e.to.line = a.length - 1; - e.to.ch = a[a.length - 1].length; + b.getLineNumber = function(a, b) { + var c = this.codeMirror.getValue(), e = {from:{}, to:{}}, f = c.substring(0, a).split(/\n/gi); + e.from.line = f.length - 1; + e.from.ch = f[f.length - 1].length; + c = c.substring(0, b).split(/\n/gi); + e.to.line = c.length - 1; + e.to.ch = c[c.length - 1].length; return e; }; - a.mappingSyntax = function(b) { - for (var a = Object.keys(Entry.block), c = 0;c < a.length;c++) { - var e = a[c], f = Entry.block[e]; - if (f.mode === b && -1 < this.availableCode.indexOf(e) && (f = f.syntax)) { + b.mappingSyntax = function(a) { + for (var b = Object.keys(Entry.block), c = 0;c < b.length;c++) { + var e = b[c], 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]) { @@ -13285,6190 +11285,6946 @@ Entry.Parser = function(a, b, d) { } } } - }; - a.setAvailableCode = function(b, a) { - var c = []; - b.forEach(function(b, a) { - b.forEach(function(b, a) { - c.push(b.type); - }); - }); - a instanceof Entry.Code ? a.getBlockList().forEach(function(b) { - b.type !== NtryData.START && -1 === c.indexOf(b.type) && c.push(b.type); - }) : a.forEach(function(b, a) { - b.forEach(function(b, a) { - b.type !== NtryData.START && -1 === c.indexOf(b.type) && c.push(b.type); - }); - }); - this.availableCode = this.availableCode.concat(c); - }; -})(Entry.Parser.prototype); -Entry.Pdf = function(a) { - this.generateView(a); + }; + b.setAvailableCode = function(a, b) { + var c = []; + a.forEach(function(a, b) { + a.forEach(function(a, b) { + c.push(a.type); + }); + }); + b instanceof Entry.Code ? b.getBlockList().forEach(function(a) { + a.type !== NtryData.START && -1 === c.indexOf(a.type) && c.push(a.type); + }) : b.forEach(function(a, b) { + a.forEach(function(a, b) { + a.type !== NtryData.START && -1 === c.indexOf(a.type) && c.push(a.type); + }); + }); + this.availableCode = this.availableCode.concat(c); + }; +})(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 d = "/pdfjs/web/viewer.html"; + b && "" != b && (d += "?file=" + b); + pdfViewIframe = Entry.createElement("iframe", "entryPdfIframeWorkspace"); + pdfViewIframe.setAttribute("id", "pdfViewIframe"); + pdfViewIframe.setAttribute("frameborder", 0); + pdfViewIframe.setAttribute("src", d); + 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"); + "tablet" === Entry.device && this.window_.addClass("tablet"); + 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.windowResized.notify(); +}; +Entry.Popup.prototype.resize = function(b) { + b = window.popup.window_; + var a = .9 * window.innerWidth, d = .9 * window.innerHeight - 35; + 9 * a <= 16 * d ? d = a / 16 * 9 : a = 16 * d / 9; + b.style.width = String(a) + "px"; + b.style.height = String(d + 35) + "px"; + Entry.stage && Entry.stage.updateBoundRect(); +}; +Entry.popupHelper = function(b) { + this.popupList = {}; + this.nowContent; + b && (window.popupHelper = null); + Entry.assert(!window.popupHelper, "Popup exist"); + var a = ["confirm", "spinner"], d = ["entryPopupHelperTopSpan", "entryPopupHelperBottomSpan", "entryPopupHelperLeftSpan", "entryPopupHelperRightSpan"]; + this.body_ = Entry.Dom("div", {classes:["entryPopup", "hiddenPopup", "popupHelper"]}); + var c = this; + this.body_.bindOnClick(function(b) { + if (!(c.nowContent && -1 < a.indexOf(c.nowContent.prop("type")))) { + var f = $(b.target); + d.forEach(function(a) { + f.hasClass(a) && this.popup.hide(); + }.bind(this)); + b.target == this && this.popup.hide(); + } + }); + this.body_.bind("touchstart", function(b) { + if (!(c.nowContent && -1 < a.indexOf(c.nowContent.prop("type")))) { + var f = $(b.target); + d.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 d = Entry.Dom("div"), c = Entry.Dom("div", {class:"entryPopupHelperCloseButton"}); + c.bindOnClick(function() { + a.closeEvent ? a.closeEvent(this) : this.hide(); + }.bind(this)); + var e = this; + c.bind("touchstart", function() { + a.closeEvent ? a.closeEvent(e) : e.hide(); + }); + var f = Entry.Dom("div", {class:"entryPopupHelperWrapper"}); + f.append(c); + a.title && (c = Entry.Dom("div", {class:"entryPopupHelperTitle"}), f.append(c), c.text(a.title)); + d.addClass(b); + d.append(f); + d.popupWrapper_ = f; + d.prop("type", a.type); + "function" === typeof a.setPopupLayout && a.setPopupLayout(d); + this.popupList[b] = d; +}; +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 c = Entry.Dom("div", {class:"entryObjectSelectedImgWorkspace", parent:this._view}); + this.initializeSplitter(c); + }; + b.addMode = function(a, b) { + var c = b.getView(), c = Entry.Dom(c, {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:c}; + "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 c = this.modes[b]; + c.tabDom.removeClass("selected"); + c.contentDom.addClass("entryRemove"); + c.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.Reporter = function(b) { + this.projectId = this.userId = null; + this.isRealTime = b; + this.activities = []; +}; +Entry.Reporter.prototype.start = function(b, a, d) { + 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:d})); + this.userId = a; + this.projectId = b; +}; +Entry.Reporter.prototype.report = function(b) { + if (!this.isRealTime || this.io) { + var a = [], d; + for (d in b.params) { + var c = b.params[d]; + "object" !== typeof c ? a.push(c) : c.id && a.push(c.id); + } + 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 d = 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(), c = $(window), h = a.pageX - b.left + c.scrollLeft(); + a = a.pageY - b.top + c.scrollTop(); + a = 40 - a; + b = -40 / 55; + c = $(d.selectedScene.view).find(".entrySceneRemoveButtonCoverWorkspace").offset().left; + !(h < c || h > c + 55) && a > 40 + b * (h - c) && (h = d.getNextScene()) && (h = $(h.view), $(document).trigger("mouseup"), h.trigger("mousedown")); + }); + var c = Entry.createElement("ul"); + c.addClass("entrySceneListWorkspace"); + Entry.sceneEditable && $ && $(c).sortable({start:function(a, b) { + b.item.data("start_pos", b.item.index()); + $(b.item[0]).clone(!0); + }, stop:function(a, b) { + var d = b.item.data("start_pos"), c = b.item.index(); + Entry.scene.moveScene(d, c); + }, axis:"x", tolerance:"pointer"}); + this.view_.appendChild(c); + this.listView_ = c; + Entry.sceneEditable && (c = Entry.createElement("span"), c.addClass("entrySceneElementWorkspace"), c.addClass("entrySceneAddButtonWorkspace"), c.bindOnClick(function(a) { + Entry.engine.isState("run") || Entry.scene.addScene(); + }), this.view_.appendChild(c), this.addButton_ = c); + } +}; +Entry.Scene.prototype.generateElement = function(b) { + var a = this, d = Entry.createElement("li", b.id); + d.addClass("entrySceneElementWorkspace"); + d.addClass("entrySceneButtonWorkspace"); + d.addClass("minValue"); + $(d).on("mousedown", function(a) { + Entry.engine.isState("run") ? a.preventDefault() : Entry.scene.selectScene(b); + }); + var c = Entry.createElement("input"); + c.addClass("entrySceneFieldWorkspace"); + c.value = b.name; + Entry.sceneEditable || (c.disabled = "disabled"); + var e = Entry.createElement("span"); + e.addClass("entrySceneLeftWorkspace"); + d.appendChild(e); + var f = Entry.createElement("span"); + f.addClass("entrySceneInputCover"); + f.style.width = Entry.computeInputWidth(b.name); + d.appendChild(f); + b.inputWrapper = f; + c.onkeyup = function(d) { + d = d.keyCode; + Entry.isArrowOrBackspace(d) || (b.name = this.value, f.style.width = Entry.computeInputWidth(b.name), a.resize(), 13 == d && this.blur(), 10 < this.value.length && (this.value = this.value.substring(0, 10), this.blur())); + }; + c.onblur = function(a) { + c.value = this.value; + b.name = this.value; + f.style.width = Entry.computeInputWidth(b.name); + }; + f.appendChild(c); + e = Entry.createElement("span"); + e.addClass("entrySceneRemoveButtonCoverWorkspace"); + d.appendChild(e); + if (Entry.sceneEditable) { + var g = Entry.createElement("button"); + g.addClass("entrySceneRemoveButtonWorkspace"); + 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(d); + $(d).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 = d; +}; +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, d = b.length;a < d;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), d = 0;d < a.length;d++) { + Entry.container.removeObject(a[d]); + } + 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, d = 0;d < a;d++) { + var c = this.getScenes()[d], e = c.view, f = c.inputWrapper; + delete c.view; + delete c.inputWrapper; + b.push(JSON.parse(JSON.stringify(c))); + c.view = e; + c.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(), d = 0;d < a.length;d++) { + if (a[d].id == b) { + return a[d]; + } + } + return !1; }; -p = Entry.Pdf.prototype; -p.generateView = function(a) { - var b = Entry.createElement("div", "entryPdfWorkspace"); - b.addClass("entryRemove"); - this._view = b; - var d = "/pdfjs/web/viewer.html"; - a && "" != a && (d += "?file=" + a); - pdfViewIframe = Entry.createElement("iframe", "entryPdfIframeWorkspace"); - pdfViewIframe.setAttribute("id", "pdfViewIframe"); - pdfViewIframe.setAttribute("frameborder", 0); - pdfViewIframe.setAttribute("src", d); - 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(), c = this.getPosition(), e = c.x + a.left, a = c.y + a.top, f, g; - if (b = b.dragInstance) { - f = b.offsetX, g = b.offsetY; - } - this.tAnimation(f >= 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, c = this.trashcanTop; - a = b ? {translateX:15, translateY:-25, rotateZ:30} : {translateX:0, translateY:0, rotateZ:0}; - $(c).velocity(a, {duration:50}); - this.isOver = b; +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 d = b.length - 1;0 <= d;d--) { + Entry.container.addCloneObject(b[d], a.id); } - }; - a.setBoard = function(b) { - this._dragBlockObserver && this._dragBlockObserver.destroy(); - this.board = b; - this.svgGroup || this._generateView(); - var a = b.svg, c = a.firstChild; - c ? a.insertBefore(this.svgGroup, c) : 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); - this.textType = Entry.Vim.TEXT_TYPE_PY; }; -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) { - "number" === typeof b ? this.mode = b : (this.mode = b.boardType, this.runType = b.runType, this.textType = b.textType); - switch(this.mode) { - case this.oldMode: - return; - case Entry.Workspace.MODE_VIMBOARD: - try { - this.board && this.board.hide(), this.overlayBoard && this.overlayBoard.hide(), this.set({selectedBoard:this.vimBoard}), this.vimBoard.show(), this.codeToText(this.board.code, b), this.blockMenu.renderText(function() { - this.blockMenu.reDraw(); - }.bind(this)), this.board.clear(), this.oldTextType = this.textType; - } catch (c) { - } - break; - case Entry.Workspace.MODE_BOARD: - try { - this.board.show(), this.set({selectedBoard:this.board}), this.textToCode(this.oldMode, this.oldTextType), this.vimBoard && this.vimBoard.hide(), this.overlayBoard && this.overlayBoard.hide(), this.blockMenu.renderBlock(function() { - this.blockMenu.reDraw(); - }.bind(this)), this.oldTextType = this.textType; - } catch (c) { - this.board && this.board.hide(), this.set({selectedBoard:this.vimBoard}), this.mode = Entry.Workspace.MODE_VIMBOARD, this.oldTextType == Entry.Vim.PARSER_TYPE_JS_TO_BLOCK ? (b.boardType = Entry.Workspace.MODE_VIMBOARD, b.textType = Entry.Vim.TEXT_TYPE_JS, b.runType = Entry.Vim.MAZE_MODE, this.oldTextType = Entry.Vim.PARSER_TYPE_JS_TO_BLOCK, Entry.dispatchEvent("changeMode", b), Ntry.dispatchEvent("textError", b)) : this.oldTextType == Entry.Vim.PARSER_TYPE_PY_TO_BLOCK && (b.boardType = - Entry.Workspace.MODE_VIMBOARD, b.textType = Entry.Vim.TEXT_TYPE_PY, b.runType = Entry.Vim.WORKSPACE_MODE, this.oldTextType = Entry.Vim.PARSER_TYPE_PY_TO_BLOCK, Entry.dispatchEvent("changeMode", b)); - } - 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.oldMode = this.mode; - this.changeEvent.notify(a); - }; - a.changeBoardCode = function(b) { - this._syncTextCode(); - this.board.changeCode(b); - this.mode === Entry.Workspace.MODE_VIMBOARD && this.codeToText(this.board.code); - }; - a.changeOverlayBoardCode = function(b) { - this.overlayBoard && this.overlayBoard.changeCode(b); - }; - a.changeBlockMenuCode = function(b) { - this.blockMenu.changeCode(b); - }; - a.textToCode = function(b, a) { - if (b == Entry.Workspace.MODE_VIMBOARD) { - var c = this; - b = this.vimBoard.textToCode(a); - a = this.board; - var e = a.code; - e.load(b); - e.createView(a); - this.board.reDraw(); - setTimeout(function() { - c.board.alignThreads(); - }, 0); - } - }; - a.codeToText = function(b, a) { - return this.vimBoard.codeToText(b, a); - }; - 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, c = 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()) : c && (67 == a ? e.block.copyToClipboard() : 88 == a && (b = e.block, b.copyToClipboard(), b.destroy(!0, !0), e.getBoard().setSelectedBlock(null)))); - c && 86 == a && (a = this.selectedBoard) && a instanceof Entry.Board && Entry.clipboard && Entry.do("addThread", Entry.clipboard).value.getFirstBlock().copyToClipboard(); +Entry.Scene.prototype.resize = function() { + var b = this.getScenes(), a = this.selectedScene, d = b[0]; + if (0 !== b.length && d) { + var c = $(d.view).offset().left, d = parseFloat($(a.view).css("margin-left")), e = $(this.view_).width() - c, f = 0, g; + for (g in b) { + var c = b[g], h = c.view; + h.addClass("minValue"); + $(c.inputWrapper).width(Entry.computeInputWidth(c.name)); + h = $(h); + f = f + h.width() + d; } - }; - a._handleChangeBoard = function() { - var b = this.selectedBoard; - b && b.constructor === Entry.Board && this.trashcan.setBoard(b); - }; - a._syncTextCode = function() { - if (this.mode === Entry.Workspace.MODE_VIMBOARD) { - var b = this.vimBoard.textToCode(this.textType), a = this.board, c = a.code; - c.load(b); - c.createView(a); - this.board.alignThreads(); + if (f > e) { + for (g in e -= $(a.view).width(), d = e / (b.length - 1) - (Entry.Scene.viewBasicWidth + d), b) { + c = b[g], a.id != c.id ? (c.view.removeClass("minValue"), $(c.inputWrapper).width(d)) : c.view.addClass("minValue"); + } } - }; - a.addVimBoard = function(b) { - this.vimBoard || (this.vimBoard = new Entry.Vim(b), this.vimBoard.workspace = this, this.vimBoard.hide()); - }; -})(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 c = {type:b.getAttribute("type"), index:{}}; - b = $(b).children(); - if (!b) { - return c; - } - for (var e = 0;e < b.length;e++) { - var f = b[e], g = f.tagName, h = $(f).children()[0], t = f.getAttribute("name"); - "value" === g ? "block" == h.nodeName && (c.params || (c.params = []), c.params.push(a(h)), c.index[t] = c.params.length - 1) : "field" === g && (c.params || (c.params = []), c.params.push(f.textContent), c.index[t] = c.params.length - 1); +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, d) { + Entry.assert("BLOCK" == b.tagName.toUpperCase(), b.tagName); + this.type = b.getAttribute("type"); + this.id = Number(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)); + d instanceof Entry.Script && (this.parentScript = d); + b = b.childNodes; + for (a = 0;a < b.length;a++) { + if (d = b[a], "NEXT" == d.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" == d.tagName.toUpperCase()) { + this.values || (this.values = {}); + var c = new Entry.Script(this.entity); + this.register && (c.register = this.register); + c.init(d.childNodes[0]); + this.values[d.getAttribute("name")] = c; + } else { + "FIELD" == d.tagName.toUpperCase() ? (this.fields || (this.fields = {}), this.fields[d.getAttribute("name")] = d.textContent) : "STATEMENT" == d.tagName.toUpperCase() && (this.statements || (this.statements = {}), c = new Entry.Script(this.entity), this.register && (c.register = this.register), c.init(d.childNodes[0], null, this), c.key = d.getAttribute("name"), this.statements[d.getAttribute("name")] = c); } - return c; - } - var c = Blockly.Blocks[b], e = EntryStatic.blockInfo[b], f, g; - if (e && (f = e.class, g = e.isNotFor, e = e.xml)) { - var e = $.parseXML(e), h = a(e.childNodes[0]) } - c = (new Entry.BlockMockup(c, h, b)).toJSON(); - c.class = f; - c.isNotFor = g; - _.isEmpty(c.paramsKeyMap) && delete c.paramsKeyMap; - _.isEmpty(c.statementsKeyMap) && delete c.statementsKeyMap; - c.func = Entry.block[b]; - -1 < "NUMBER TRUE FALSE TEXT FUNCTION_PARAM_BOOLEAN FUNCTION_PARAM_STRING TRUE_UN".split(" ").indexOf(b.toUpperCase()) && (c.isPrimitive = !0); - Entry.block[b] = c; - }; -})(Entry.BlockDriver.prototype); -Entry.BlockMockup = function(a, b, d) { - this.templates = []; - this.params = []; - this.statements = []; - this.color = ""; - this.output = this.isNext = this.isPrev = !1; - this.fieldCount = 0; - this.events = {}; - this.def = b || {}; - this.paramsKeyMap = {}; - this.statementsKeyMap = {}; - this.definition = {params:[], type:this.def.type}; - this.simulate(a); - this.def = this.definition; + } }; -(function(a) { - a.simulate = function(b) { - b.sensorList && (this.sensorList = b.sensorList); - b.portList && (this.portList = b.portList); - b.init.call(this); - b.whenAdd && (this.events.blockViewAdd || (this.events.blockViewAdd = []), this.events.blockViewAdd.push(b.whenAdd)); - b.whenRemove && (this.events.blockViewDestroy || (this.events.blockViewDestroy = []), this.events.blockViewDestroy.push(b.whenRemove)); - }; - a.toJSON = function() { - function b(a) { - if (a && (a = a.params)) { - for (var d = 0;d < a.length;d++) { - var c = a[d]; - c && (delete c.index, b(c)); - } - } +p.clone = function(b, a) { + var d = new Entry.Script(b); + d.id = this.id; + d.type = this.type; + d.isRepeat = this.isRepeat; + if (this.parentScript && !this.previousScript && 2 != a) { + d.parentScript = this.parentScript.clone(b); + for (var c = d.parentScript.statements[this.key] = d;c.nextScript;) { + c = c.nextScript, c.parentScript = d.parentScript; } - var a = ""; - this.output ? a = "Boolean" === this.output ? "basic_boolean_field" : "basic_string_field" : !this.isPrev && this.isNext ? a = "basic_event" : 1 == this.statements.length ? a = "basic_loop" : 2 == this.statements.length ? a = "basic_double_loop" : this.isPrev && this.isNext ? a = "basic" : this.isPrev && !this.isNext && (a = "basic_without_next"); - b(this.def); - var c = /dummy_/mi, e; - for (e in this.paramsKeyMap) { - c.test(e) && delete this.paramsKeyMap[e]; + } + this.nextScript && 1 != a && (d.nextScript = this.nextScript.clone(b, 0), d.nextScript.previousScript = this); + this.previousScript && 0 !== a && (d.previousScript = this.previousScript.clone(b, 1), d.previousScript.previousScript = this); + if (this.fields) { + d.fields = {}; + for (var e in this.fields) { + d.fields[e] = this.fields[e]; } - for (e in this.statementsKeyMap) { - c.test(e) && delete this.statementsKeyMap[e]; + } + if (this.values) { + for (e in d.values = {}, this.values) { + d.values[e] = this.values[e].clone(b); } - return {color:this.color, skeleton:a, statements:this.statements, template:this.templates.filter(function(b) { - return "string" === typeof b; - }).join(" "), params:this.params, events:this.events, def:this.def, paramsKeyMap:this.paramsKeyMap, statementsKeyMap:this.statementsKeyMap}; - }; - a.appendDummyInput = function() { - return this; - }; - a.appendValueInput = function(b) { - 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.params.push({type:"Block", accept:"string"}); - this._addToParamsKeyMap(b); - this.templates.push(this.getFieldCount()); - return this; - }; - a.appendStatementInput = function(b) { - this._addToStatementsKeyMap(b); - this.statements.push({accept:"basic"}); - }; - a.setCheck = function(b) { - var a = this.params; - "Boolean" === b && (a[a.length - 1].accept = "boolean"); - }; - a.appendField = function(b, a) { - if (!b) { - return this; + } + if (this.statements) { + for (e in d.statements = {}, this.statements) { + for (d.statements[e] = this.statements[e].clone(b, 2), c = d.statements[e], c.parentScript = d;c.nextScript;) { + c = c.nextScript, c.parentScript = d; + } } - "string" === typeof b && 0 < b.length ? a ? (b = {type:"Text", text:b, color:a}, this.params.push(b), this._addToParamsKeyMap(), this.templates.push(this.getFieldCount()), 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(void 0)) : this.templates.push(b) : b.constructor == Blockly.FieldIcon ? ("start" === b.type ? this.params.push({type:"Indicator", img:b.src_, size:17, position:{x:0, y:-2}}) : - this.params.push({type:"Indicator", img:b.src_, size:12}), this._addToParamsKeyMap(), this.templates.push(this.getFieldCount()), this.definition && this.definition.params.push(null)) : b.constructor == Blockly.FieldDropdown ? (this.params.push({type:"Dropdown", options:b.menuGenerator_, value:b.menuGenerator_[0][1], fontSize:11}), this._addToParamsKeyMap(a), this.templates.push(this.getFieldCount()), 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(void 0)) : b.constructor == Blockly.FieldDropdownDynamic ? (this.params.push({type:"DropdownDynamic", value:null, menuName:b.menuName_, fontSize:11}), this.templates.push(this.getFieldCount()), 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(void 0), this._addToParamsKeyMap(a)) : b.constructor == Blockly.FieldTextInput ? (this.params.push({type:"TextInput", value:10}), - this.templates.push(this.getFieldCount()), this._addToParamsKeyMap(a)) : b.constructor == Blockly.FieldAngle ? (this.params.push({type:"Angle"}), this.templates.push(this.getFieldCount()), 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._addToParamsKeyMap(a)) : b.constructor == Blockly.FieldKeydownInput ? (this.params.push({type:"Keyboard", value:81}), this.templates.push(this.getFieldCount()), - void 0 !== this.def.index[a] ? this.definition.params.push(this.def.params[this.def.index[a]]) : this.definition.params.push(void 0), this._addToParamsKeyMap(a)) : b.constructor == Blockly.FieldColour ? (this.params.push({type:"Color"}), this.templates.push(this.getFieldCount()), this._addToParamsKeyMap(a)) : console.log("else", b); - return this; - }; - a.setColour = function(b) { - this.color = b; - }; - a.setInputsInline = function() { - }; - a.setOutput = function(b, a) { - b && (this.output = a); - }; - a.setPreviousStatement = function(b) { - this.isPrev = b; - }; - a.setNextStatement = function(b) { - this.isNext = b; - }; - a.setEditable = function(b) { - }; - a.getFieldCount = function() { - this.fieldCount++; - return "%" + this.fieldCount; - }; - a._addToParamsKeyMap = function(b) { - b = b ? b : "dummy_" + Entry.Utils.generateId(); - var a = this.paramsKeyMap; - a[b] = Object.keys(a).length; - }; - a._addToStatementsKeyMap = function(b) { - b = b ? b : "dummy_" + Entry.Utils.generateId(); - var a = this.statementsKeyMap; - a[b] = Object.keys(a).length; - }; -})(Entry.BlockMockup.prototype); -Entry.Playground = function() { - this.enableArduino = this.isTextBGMode_ = !1; - this.viewMode_ = "default"; - var a = this; - Entry.addEventListener("textEdited", this.injectText); - Entry.addEventListener("hwChanged", this.updateHW); - Entry.addEventListener("changeMode", function(b) { - a.setMode(b); - }); + } + return d; }; -Entry.Playground.prototype.setMode = function(a) { - this.mainWorkspace.setMode(a); +p.getStatement = function(b) { + return this.statements[b]; }; -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(b) { - Entry.playground.curtainView_.removeClass("entryRemove"); - }), Entry.addEventListener("stop", function(b) { - 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(b) { - Entry.playground.curtainView_.removeClass("entryRemove"); - }), Entry.addEventListener("stop", function(b) { - Entry.playground.curtainView_.addClass("entryRemove"); - })); +p.compute = function() { }; -Entry.Playground.prototype.generateDefaultView = function(a) { - return a; +p.getValue = function(b) { + return this.values[b].run(); }; -Entry.Playground.prototype.generateTabView = function(a) { - var b = this, d = Entry.createElement("ul"); - d.addClass("entryTabListWorkspace"); - this.tabList_ = d; - a.appendChild(d); - this.tabViewElements = {}; - a = Entry.createElement("li", "entryCodeTab"); - a.innerHTML = Lang.Workspace.tab_code; - a.addClass("entryTabListItemWorkspace"); - a.addClass("entryTabSelected"); - d.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"), d.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"), d.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"), d.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"), d.appendChild(a), a.bindOnClick(function(b) { - Entry.playground.toggleOnVariableView(); - Entry.playground.changeViewMode("variable"); - }), this.tabViewElements.variable = a); +p.getNumberValue = function(b) { + return Number(this.values[b].run()); }; -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(); +p.getStringValue = function(b) { + return String(this.values[b].run()); }; -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 d = Entry.createElement("div", "entryAddPictureInner"); - d.addClass("entryPlaygroundAddPictureInner"); - d.innerHTML = Lang.Workspace.picture_add; - b.appendChild(d); - 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.Painter2(b); - } else { - "phone" == Entry.type && (b = Entry.createElement("div", "entryAddPicture"), b.addClass("entryPlaygroundAddPicturePhone"), b.bindOnClick(function(b) { - Entry.dispatchEvent("openPictureManager"); - }), d = Entry.createElement("div", "entryAddPictureInner"), d.addClass("entryPlaygroundAddPictureInnerPhone"), d.innerHTML = Lang.Workspace.picture_add, b.appendChild(d), 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); - } +p.getBooleanValue = function(b) { + return this.values[b].run() ? !0 : !1; }; -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 d = Entry.createElement("div"); - d.addClass("entryTextFontSelect"); - a.appendChild(d); - var c = Entry.createElement("select", "entryPainterAttrFontName"); - c.addClass("entryPlaygroundPainterAttrFontName", "entryTextFontSelecter"); - c.size = "1"; - c.onchange = function(b) { - Entry.playground.object.entity.setFontType(b.target.value); +p.getField = function(b) { + return this.fields[b]; +}; +p.getStringField = function(b) { + return String(this.fields[b]); +}; +p.getNumberField = function(b) { + return Number(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; +}; +(function(b, a) { + b.applyFilter = a.applyFilter; + b.removeClone = a.removeClone; + b.getWidth = a.getWidth; + b.getHeight = a.getHeight; + b.getInitialEffectValue = a.getInitialEffectValue; +})(Entry.StampEntity.prototype, Entry.EntityObject.prototype); +Entry.JsAstGenerator = function() { +}; +(function(b) { + b.generate = function(a) { + return arcon.parse(a); }; - 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; - c.appendChild(g); - } - this.fontName_ = c; - d.appendChild(c); - e = Entry.createElement("ul"); - e.addClass("entryPlayground_text_buttons"); - a.appendChild(e); - d = Entry.createElement("li"); - d.addClass("entryPlaygroundTextAlignLeft"); - d.bindOnClick(function(b) { - Entry.playground.setFontAlign(Entry.TEXT_ALIGN_LEFT); - }); - e.appendChild(d); - this.alignLeftBtn = d; - d = Entry.createElement("li"); - d.addClass("entryPlaygroundTextAlignCenter"); - d.bindOnClick(function(b) { - Entry.playground.setFontAlign(Entry.TEXT_ALIGN_CENTER); - }); - e.appendChild(d); - this.alignCenterBtn = d; - d = Entry.createElement("li"); - d.addClass("entryPlaygroundTextAlignRight"); - d.bindOnClick(function(b) { - Entry.playground.setFontAlign(Entry.TEXT_ALIGN_RIGHT); - }); - e.appendChild(d); - this.alignRightBtn = d; - d = Entry.createElement("li"); - e.appendChild(d); - c = Entry.createElement("a"); - d.appendChild(c); - c.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"); - c.appendChild(h); - h.src = Entry.mediaFilePath + "text_button_bold_false.png"; - d = Entry.createElement("li"); - e.appendChild(d); - c = Entry.createElement("a"); - d.appendChild(c); - c.bindOnClick(function() { - var b = !Entry.playground.object.entity.getUnderLine() || !1; - k.src = Entry.mediaFilePath + "text_button_underline_" + b + ".png"; - Entry.playground.object.entity.setUnderLine(b); - }); - var k = Entry.createElement("img", "entryPlaygroundText_underlineImage"); - c.appendChild(k); - k.src = Entry.mediaFilePath + "text_button_underline_false.png"; - d = Entry.createElement("li"); - e.appendChild(d); - c = Entry.createElement("a"); - d.appendChild(c); - c.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"); - c.appendChild(l); - l.src = Entry.mediaFilePath + "text_button_italic_false.png"; - d = Entry.createElement("li"); - e.appendChild(d); - c = Entry.createElement("a"); - d.appendChild(c); - c.bindOnClick(function() { - var b = !Entry.playground.object.entity.getStrike() || !1; - Entry.playground.object.entity.setStrike(b); - m.src = Entry.mediaFilePath + "text_button_strike_" + b + ".png"; - }); - var m = Entry.createElement("img", "entryPlaygroundText_strikeImage"); - c.appendChild(m); - m.src = Entry.mediaFilePath + "text_button_strike_false.png"; - c = Entry.createElement("li"); - e.appendChild(c); - d = Entry.createElement("a"); - c.appendChild(d); - d.bindOnClick(function() { - Entry.playground.toggleColourChooser("foreground"); - }); - c = Entry.createElement("img"); - d.appendChild(c); - c.src = Entry.mediaFilePath + "text_button_color_false.png"; - d = Entry.createElement("li"); - e.appendChild(d); - e = Entry.createElement("a"); - d.appendChild(e); - e.bindOnClick(function() { - Entry.playground.toggleColourChooser("background"); - }); - d = Entry.createElement("img"); - e.appendChild(d); - d.src = Entry.mediaFilePath + "text_button_background_false.png"; - e = Entry.createElement("div"); - e.addClass("entryPlayground_fgColorDiv"); - d = Entry.createElement("div"); - d.addClass("entryPlayground_bgColorDiv"); - a.appendChild(e); - a.appendChild(d); - c = Entry.createElement("div"); - c.addClass("entryPlaygroundTextColoursWrapper"); - this.coloursWrapper = c; - b.appendChild(c); - a = Entry.getColourCodes(); - for (e = 0;e < a.length;e++) { - d = Entry.createElement("div"), d.addClass("modal_colour"), d.setAttribute("colour", a[e]), d.style.backgroundColor = a[e], 0 === e && d.addClass("modalColourTrans"), d.bindOnClick(function(b) { - Entry.playground.setTextColour(b.target.getAttribute("colour")); - }), c.appendChild(d); - } - c.style.display = "none"; - c = Entry.createElement("div"); - c.addClass("entryPlaygroundTextBackgroundsWrapper"); - this.backgroundsWrapper = c; - b.appendChild(c); - for (e = 0;e < a.length;e++) { - d = Entry.createElement("div"), d.addClass("modal_colour"), d.setAttribute("colour", a[e]), d.style.backgroundColor = a[e], 0 === e && d.addClass("modalColourTrans"), d.bindOnClick(function(b) { - Entry.playground.setBackgroundColour(b.target.getAttribute("colour")); - }), c.appendChild(d); - } - c.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); +})(Entry.JsAstGenerator.prototype); +Entry.PyAstGenerator = function() { +}; +(function(b) { + b.generate = function(a) { + var b = filbert.parse, c = {locations:!1, ranges:!1}, e; + try { + return e = b(a, c), console.log("astTree", e), e; + } catch (f) { + throw f.message = " \ud30c\uc774\uc36c \ubb38\ubc95\uc744 \ud655\uc778\ud574\uc8fc\uc138\uc694", f; + } }; - a.onblur = function() { - Entry.dispatchEvent("textEdited"); +})(Entry.PyAstGenerator.prototype); +Entry.Map = function() { + this._map = {repo:{}}; +}; +(function(b) { + b.getKey = function(a) { + return a; }; - 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.put = function(a, b) { + var c = this.getKey(a); + this._map.repo[c] = b; }; - a.onblur = function() { - Entry.dispatchEvent("textEdited"); + b.contains = function(a) { + a = this.getKey(a); + return this._map.repo[a] ? !0 : !1; }; - this.textEditArea = a; - b.appendChild(a); - a = Entry.createElement("div"); - a.addClass("entryPlaygroundFontSizeWrapper"); - b.appendChild(a); - this.fontSizeWrapper = a; - var n = Entry.createElement("div"); - n.addClass("entryPlaygroundFontSizeSlider"); - a.appendChild(n); - var q = Entry.createElement("div"); - q.addClass("entryPlaygroundFontSizeIndicator"); - n.appendChild(q); - this.fontSizeIndiciator = q; - var r = Entry.createElement("div"); - r.addClass("entryPlaygroundFontSizeKnob"); - n.appendChild(r); - this.fontSizeKnob = r; - e = Entry.createElement("div"); - e.addClass("entryPlaygroundFontSizeLabel"); - e.innerHTML = "\uae00\uc790 \ud06c\uae30"; - a.appendChild(e); - var t = !1, u = 0; - r.onmousedown = function(b) { - t = !0; - u = $(n).offset().left; + b.get = function(a) { + a = this.getKey(a); + return this._map.repo[a] ? this._map.repo[a] : null; }; - r.addEventListener("touchstart", function(b) { - t = !0; - u = $(n).offset().left; - }); - document.addEventListener("mousemove", function(b) { - t && (b = b.pageX - u, b = Math.max(b, 5), b = Math.min(b, 88), r.style.left = b + "px", b /= .88, q.style.width = b + "%", Entry.playground.object.entity.setFontSize(b)); - }); - document.addEventListener("touchmove", function(b) { - t && (b = b.touches[0].pageX - u, b = Math.max(b, 5), b = Math.min(b, 88), r.style.left = b + "px", b /= .88, q.style.width = b + "%", Entry.playground.object.entity.setFontSize(b)); - }); - document.addEventListener("mouseup", function(b) { - t = !1; - }); - document.addEventListener("touchend", function(b) { - t = !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); + b.remove = function(a) { + var b = this.getKey(a); + this.contains(a) && (this._map.repo[b] = void 0); + }; + b.clear = function() { + this._map.repo = {}; + }; + b.toString = function() { + return this._map.repo; + }; +})(Entry.Map.prototype); +Entry.Queue = function() { + this.tail = this.head = null; }; -Entry.Playground.prototype.generateSoundView = function(a) { - if ("workspace" == Entry.type) { - var b = Entry.createElement("div", "entryAddSound"); - b.addClass("entryPlaygroundAddSound"); - b.bindOnClick(function(b) { - Entry.dispatchEvent("openSoundManager"); +function Node(b) { + this.data = b; + this.next = null; +} +(function(b) { + b.enqueue = function(a) { + a = new Node(a); + null === this.head ? this.head = a : this.tail.next = a; + this.tail = a; + }; + b.dequeue = function() { + var a; + null !== this.head && (a = this.head.data, this.head = this.head.next); + return a; + }; + b.clear = function() { + for (;this.dequeue();) { + } + }; + b.toString = function() { + for (var a = this.head, b = [];a;) { + b.push(a.data), a = a.next; + } + return b.toString(); + }; +})(Entry.Queue.prototype); +Entry.PyHint = function() { + function b(a, b, d) { + a = fuzzy.filter(b, a, d); + return a = a.map(function(a) { + return a.original; }); - var d = Entry.createElement("div", "entryAddSoundInner"); - d.addClass("entryPlaygroundAddSoundInner"); - d.innerHTML = Lang.Workspace.sound_add; - b.appendChild(d); - a.appendChild(b); - b = Entry.createElement("ul", "entrySoundList"); - b.addClass("entryPlaygroundSoundList"); - $ && $(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.moveSound(b, a); - }, axis:"y"}); - a.appendChild(b); - this.soundListView_ = b; - } else { - "phone" == Entry.type && (b = Entry.createElement("div", "entryAddSound"), b.addClass("entryPlaygroundAddSoundPhone"), b.bindOnClick(function(b) { - Entry.dispatchEvent("openSoundManager"); - }), d = Entry.createElement("div", "entryAddSoundInner"), d.addClass("entryPlaygroundAddSoundInnerPhone"), d.innerHTML = Lang.Workspace.sound_add, b.appendChild(d), a.appendChild(b), b = Entry.createElement("ul", "entrySoundList"), b.addClass("entryPlaygroundSoundListPhone"), $ && $(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.moveSound(b, a); - }, axis:"y"}), a.appendChild(b), this.soundListView_ = b); } -}; -Entry.Playground.prototype.injectObject = function(a) { - if (!a) { - this.changeViewMode("code"), this.object = null; - } 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(); + CodeMirror.registerHelper("hint", "python", function(c) { + var e = c.getCursor(), f = c.getTokenAt(e); + /^[\w$_]*$/.test(f.string) || (f = {start:e.ch, end:e.ch, string:"", state:f.state, className:":" == f.string ? "python-type" : null}); + var g = [], h = f.string, r; + if ("variable" == f.type) { + r = f.string, null != r && (g = g.concat(b(a, h)), g = g.concat(b(d._global, h, {extract:function(a) { + return a.displayText; + }}))); + } else { + if ("property" == f.type || "variable-2" == f.type || "." == f.state.lastToken) { + r = f.string; + c = c.getLineTokens(e.line); + for (var t = c.shift();"variable" !== t.type && "variable-2" !== t.type;) { + t = c.shift(); + } + c = t.string; + null != r && d[c] && (g = g.concat(b(d[c], h, {extract:function(a) { + return a.displayText; + }}))); + "." == f.state.lastToken && (g = g.concat(d[c])); + } + } + return {list:g.slice(0, 25), from:CodeMirror.Pos(e.line, f.start), to:CodeMirror.Pos(e.line, f.end)}; + }); + var a = "Entry;self;Hw;while True;True;False;break;for i in range;if;if else;len;random.randint".split(";"), d = {_global:[]}, c = Entry.block, e; + for (e in c) { + var f = c[e].syntax; + if (f && f.py) { + f = f.py.join(""); + f = f.split("."); + if (-1 < f[0].indexOf("def ")) { + f = f[0].split(" "); + } else { + if (1 === f.length) { + continue; + } + } + var g = f.shift(); + d[g] || (d[g] = [], d._global.push({displayText:g, text:g})); + var f = f[0].split(","), h = "(" + Array(f.length).join(" , ") + ")", f = f[0].split("(")[0]; + d[g].push({displayText:f, text:f + h}); + "def" == g ? d._global.push({displayText:g + " " + f, text:g + " " + f + h}) : d._global.push({displayText:g + "." + f, text:g + "." + f + h}); } } }; -Entry.Playground.prototype.injectCode = function() { - var a = this.mainWorkspace; - a.changeBoardCode(this.object.script); - a.getBoard().adjustThreadsPosition(); +Entry.KeyboardCode = function() { }; -Entry.Playground.prototype.injectPicture = function() { - var a = this.pictureListView_; - if (a) { - for (;a.hasChildNodes();) { - a.removeChild(a.lastChild); +(function(b) { + b.keyCodeToChar = {8:"Backspace", 9:"Tab", 13:"Enter", 16:"Shift", 17:"Ctrl", 18:"Alt", 19:"Pause/Break", 20:"Caps Lock", 27:"Esc", 32:"Space", 33:"Page Up", 34:"Page Down", 35:"End", 36:"Home", 37:"Left", 38:"Up", 39:"Right", 40:"Down", 45:"Insert", 46:"Delete", 48:"0", 49:"1", 50:"2", 51:"3", 52:"4", 53:"5", 54:"6", 55:"7", 56:"8", 57:"9", 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", 91:"Windows", 93:"Right Click", 96:"Numpad 0", 97:"Numpad 1", 98:"Numpad 2", 99:"Numpad 3", 100:"Numpad 4", 101:"Numpad 5", 102:"Numpad 6", 103:"Numpad 7", 104:"Numpad 8", 105:"Numpad 9", 106:"Numpad *", 107:"Numpad +", 109:"Numpad -", 110:"Numpad .", 111:"Numpad /", 112:"F1", 113:"F2", 114:"F3", 115:"F4", 116:"F5", 117:"F6", 118:"F7", 119:"F8", 120:"F9", 121:"F10", 122:"F11", 123:"F12", 144:"Num Lock", 145:"Scroll Lock", 182:"My Computer", 183:"My Calculator", + 186:";", 187:"=", 188:",", 189:"-", 190:".", 191:"/", 192:"`", 219:"[", 220:"\\", 221:"]", 222:"'"}; + b.keyCharToCode = {Backspace:8, Tab:9, Enter:13, Shift:16, Ctrl:17, Alt:18, "Pause/Break":19, "Caps Lock":20, Esc:27, Space:32, "Page Up":33, "Page Down":34, End:35, Home:36, Left:37, Up:38, Right:39, Down:40, Insert:45, Delete:46, 0:48, 1:49, 2:50, 3:51, 4:52, 5:53, 6:54, 7:55, 8:56, 9:57, A:65, B:66, C:67, D:68, E:69, F:70, G:71, H:72, I:73, J:74, K:75, L:76, M:77, N:78, O:79, P:80, Q:81, R:82, S:83, T:84, U:85, V:86, W:87, X:88, Y:89, Z:90, Windows:91, "Right Click":93, "Numpad 0":96, "Numpad 1":97, + "Numpad 2":98, "Numpad 3":99, "Numpad 4":100, "Numpad 5":101, "Numpad 6":102, "Numpad 7":103, "Numpad 8":104, "Numpad 9":105, "Numpad *":106, "Numpad +":107, "Numpad -":109, "Numpad .":110, "Numpad /":111, F1:112, F2:113, F3:114, F4:115, F5:116, F6:117, F7:118, F8:119, F9:120, F10:121, F11:122, F12:123, "Num Lock":144, "Scroll Lock":145, "My Computer":182, "My Calculator":183, ";":186, "=":187, ",":188, "-":189, ".":190, "/":191, "`":192, "[":219, "\\":220, "]":221, "'":222}; +})(Entry.KeyboardCode.prototype); +Entry.Console = function() { + Entry.propertyPanel && (this.createView(), Entry.propertyPanel.addMode("console", this), Entry.console = this, this._isEditing = !1, this._inputData = null); +}; +(function(b) { + b.createView = function() { + this.view = new Entry.Dom("div", {id:"entryConsole"}); + this.codeMirror = CodeMirror(this.view[0], {lineNumbers:!1, lineWrapping:!0, value:"", mode:{}, theme:"default", styleActiveLine:!1, lint:!1}); + this._doc = this.codeMirror.getDoc(); + this.codeMirror.on("beforeChange", function(a, b) { + this._isEditing ? "+delete" === b.origin && 0 === b.to.ch && b.cancel() : b.cancel(); + }.bind(this)); + this.codeMirror.on("keyup", function(a, b) { + this._isEditing && 13 === b.keyCode && this.endInput(); + }.bind(this)); + this.codeMirror.on("cursorActivity", function(a, b) { + a.execCommand("goDocEnd"); + }); + Entry.addEventListener("stop", this.clear.bind(this)); + this.clear(); + }; + b.getView = function() { + return this.view; + }; + b.clear = function() { + this.setEditing(!0); + this.codeMirror.setValue("Entry Console \n"); + this.codeMirror.execCommand("goDocEnd"); + this.setEditing(!1); + }; + b.print = function(a, b) { + this.setEditing(!0); + this.codeMirror.execCommand("goDocEnd"); + var c = this._doc.getCursor(); + this._doc.replaceRange(a + "\n", {line:c.line, ch:0}); + this._doc.addLineClass(c.line, "text", b); + "speak" === b && this.setEditing(!1); + this.codeMirror.execCommand("goDocEnd"); + "ask" === b && (this._doc.addLineClass(c.line + 1, "text", "answer"), this.codeMirror.focus()); + }; + b.endInput = function() { + var a = this._doc.getCursor(), b = this.codeMirror.lineInfo(a.line); + "answer" === b.textClass ? (this._inputData = b.text, this._doc.replaceRange("\n", {line:a.line, ch:b.text.length})) : this._inputData = this._doc.getLine(a.line - 1); + Entry.container.setInputValue(this._inputData); + this.setEditing(!1); + }; + b.stopInput = function(a) { + this.setEditing(!1); + }; + b.setEditing = function(a) { + this._isEditing !== a && (this._isEditing = a); + }; +})(Entry.Console.prototype); +Entry.TextCodingUtil = function() { +}; +(function(b) { + b._funcParamQ; + b.initQueue = function() { + this._funcParamQ = new Entry.Queue; + this._funcNameQ = new Entry.Queue; + }; + b.clearQueue = function() { + this._funcParamQ.clear(); + this._funcNameQ.clear(); + }; + b.indent = function(a) { + var b = "\t"; + a = a.split("\n"); + a.pop(); + b += a.join("\n\t"); + return b = "\t" + b.trim(); + }; + b.isNumeric = function(a) { + return a.match(/^-?\d+$|^-\d+$/) || a.match(/^-?\d+\.\d+$/) ? !0 : !1; + }; + b.isBinaryOperator = function(a) { + return "==" == a || ">" == a || "<" == a || ">=" == a || "<=" == a || "+" == a || "-" == a || "*" == a || "/" == a ? !0 : !1; + }; + b.binaryOperatorConvert = function(a) { + switch(a) { + case "==": + a = "EQUAL"; + break; + case ">": + a = "GREATER"; + break; + case "<": + a = "LESS"; + break; + case ">=": + a = "GREATER_OR_EQUAL"; + break; + case "<=": + a = "LESS_OR_EQUAL"; + break; + case "+": + a = "PLUS"; + break; + case "-": + a = "MINUS"; + break; + case "*": + a = "MULTIFLY"; + break; + case "/": + a = "DIVIDE"; + break; } - if (this.object) { - for (var b = this.object.pictures, d = 0, c = b.length;d < c;d++) { - var e = b[d].view; - e || console.log(e); - e.orderHolder.innerHTML = d + 1; - a.appendChild(e); + return a; + }; + b.logicalExpressionConvert = function(a) { + switch(a) { + case "&&": + a = null; + break; + case "||": + a = null; + break; + } + return a; + }; + b.dropdownDynamicValueConvertor = function(a, b) { + var c = b.options, e = null, f; + for (f in c) { + e = c[f]; + if ("null" == e[1]) { + return e = {}; + } + if ("mouse" == a || "wall" == a || "wall_up" == a || "wall_down" == a || "wall_right" == a || "wall_left" == a) { + return a; + } + if (a == e[1]) { + return console.log("dropdownDynamicValueConvertor value", a, e[1]), e = e[0]; + } + } + e = a; + if ("variables" == b.menuName) { + var g = Entry.variableContainer.variables_, h; + for (h in g) { + var k = g[h]; + if (k.id_ == a) { + e = k.name_; + break; + } + } + } else { + if ("lists" == b.menuName) { + for (h in g = Entry.variableContainer.lists, g) { + if (k = g[h], k.id_ == a) { + e = k.name_; + break; + } + } + } else { + if ("pictures" == b.menuName) { + for (g in h = Entry.container.getAllObjects(), h) { + for (k in c = h[g], c = c.pictures, c) { + if (f = c[k], f.id == a) { + return e = f.name; + } + } + } + } else { + if ("sounds" == b.menuName) { + for (g in h = Entry.container.getAllObjects(), h) { + for (k in c = h[g], c = c.sounds, c) { + if (f = c[k], f.id == a) { + return e = f.name; + } + } + } + } + } + } + } + return e; + }; + b.binaryOperatorValueConvertor = function(a) { + switch(a) { + case "EQUAL": + a = "=="; + break; + case "GREATER": + a = ">"; + break; + case "LESS": + a = "<"; + break; + case "GREATER_OR_EQUAL": + a = ">="; + break; + case "LESS_OR_EQUAL": + a = "<="; + break; + case "\uadf8\ub9ac\uace0": + a = "&&"; + break; + case "\ub610\ub294": + a = "||"; + break; + case "PLUS": + a = "+"; + break; + case "MINUS": + a = "-"; + break; + case "MULTI": + a = "*"; + break; + case "DIVIDE": + a = "/"; + break; + } + return a; + }; + b.variableFilter = function(a, b, c) { + var e = c; + a = a.data.type; + "change_variable" == a || "set_variable" == a || "get_variable" == a ? 1 == b && (e = eval(c)) : "length_of_list" == a || "is_included_in_list" == a ? 2 == b && (e = eval(c)) : "value_of_index_from_list" == a ? 2 == b ? e = eval(c) : 4 == b && this.isNumeric(c) && (e = c - 1) : "remove_value_from_list" == a ? 2 == b ? e = eval(c) : 1 == b && this.isNumeric(c) && (e = c - 1) : "insert_value_to_list" == a ? 2 == b ? e = eval(c) : 3 == b && this.isNumeric(c) && (e = c - 1) : "change_value_list_index" == + a ? 1 == b ? e = eval(c) : 2 == b && this.isNumeric(c) && (e = c - 1) : "add_value_to_list" == a && 2 == b && (e = eval(c)); + return e; + }; + b.isGlobalVariableExisted = function(a) { + var b = Entry.variableContainer.variables_, c; + for (c in b) { + var e = b[c]; + if (null === e.object_ && e.name_ == a) { + return !0; + } + } + return !1; + }; + b.updateGlobalVariable = function(a, b) { + var c = Entry.variableContainer.variables_, e; + for (e in c) { + var f = c[e]; + if (null === f.object_ && f.name_ == a) { + variable = {x:f.x_, y:f.y_, id:f.id_, visible:f.visible_, value:b, name:a, isCloud:f.isClud_}; + f.syncModel_(variable); + Entry.variableContainer.updateList(); + break; + } + } + }; + b.createGlobalVariable = function(a, b) { + this.isGlobalVariableExisted(a) || (Entry.variableContainer.addVariable({name:a, value:b, variableType:"variable"}), Entry.variableContainer.updateList()); + }; + b.isLocalVariableExisted = function(a, b) { + var c = Entry.variableContainer.variables_, e; + for (e in c) { + var f = c[e]; + if (f.object_ === b.id && f.name_ == a) { + return !0; + } + } + return !1; + }; + b.updateLocalVariable = function(a, b, c) { + var e = Entry.variableContainer.variables_, f; + for (f in e) { + var g = e[f]; + if (g.object_ === c.id && g.name_ == a) { + g.syncModel_({x:g.x_, y:g.y_, id:g.id_, visible:g.visible_, value:b, name:a, isCloud:g.isClud_}); + Entry.variableContainer.updateList(); + break; + } + } + }; + b.createLocalVariable = function(a, b, c) { + this.isLocalVariableExisted(a, c) || (Entry.variableContainer.addVariable({name:a, value:b, object:c.id, variableType:"variable"}), Entry.variableContainer.updateList()); + }; + b.isLocalVariable = function(a) { + var b = Entry.playground.object, c = Entry.variableContainer.variables_, e; + for (e in c) { + var f = c[e]; + if (f.object_ == b.id && f.id_ == a) { + return !0; + } + } + return !1; + }; + b.isGlobalListExisted = function(a) { + var b = Entry.variableContainer.lists_, c; + for (c in b) { + var e = b[c]; + if (null === e.object_ && e.name_ == a) { + return !0; } - 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.Playground.prototype.setPicture = function(a) { - var b = Entry.container.getPictureElement(a.id, a.objectId), d = $(b); - if (b) { - a.view = b; - b.picture = a; - b = d.find("#t_" + a.id)[0]; - if (a.fileurl) { - b.style.backgroundImage = 'url("' + a.fileurl + '")'; - } else { - var c = a.filename; - b.style.backgroundImage = 'url("' + Entry.defaultPath + "/uploads/" + c.substring(0, 2) + "/" + c.substring(2, 4) + "/thumb/" + c + '.png")'; + return !1; + }; + b.updateGlobalList = function(a, b) { + var c = Entry.variableContainer.lists_, e; + for (e in c) { + var f = c[e]; + if (null === f.object_ && f.name_ == a) { + list = {x:f.x_, y:f.y_, id:f.id_, visible:f.visible_, name:a, isCloud:f.isClud_, width:f.width_, height:f.height_, array:b}; + f.syncModel_(list); + f.updateView(); + Entry.variableContainer.updateList(); + break; + } } - d.find("#s_" + a.id)[0].innerHTML = a.dimension.width + " X " + a.dimension.height; - } - Entry.container.setPicture(a); -}; -Entry.Playground.prototype.downloadPicture = function(a) { - a = Entry.playground.object.getPicture(a); - a.fileurl ? window.open(a.fileurl) : window.open("/api/sprite/download/image/" + encodeURIComponent(a.filename) + "/" + encodeURIComponent(a.name) + ".png"); -}; -Entry.Playground.prototype.clonePicture = function(a) { - a = Entry.playground.object.getPicture(a); - this.addPicture(a, !0); -}; -Entry.Playground.prototype.selectPicture = function(a) { - for (var b = this.object.pictures, d = 0, c = b.length;d < c;d++) { - var e = b[d]; - e.id === a.id ? e.view.addClass("entryPictureSelected") : e.view.removeClass("entryPictureSelected"); - } - var f; - a && a.id && (f = Entry.container.selectPicture(a.id, a.objectId)); - this.object.id === f && Entry.dispatchEvent("pictureSelected", 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.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.Playground.prototype.injectSound = function() { - var a = this.soundListView_; - if (a) { - for (;a.hasChildNodes();) { - a.removeChild(a.lastChild); + }; + b.createGlobalList = function(a, b) { + this.isGlobalListExisted(a) || (Entry.variableContainer.addList({name:a, array:b, variableType:"list"}), Entry.variableContainer.updateList()); + }; + b.isLocalListExisted = function(a, b) { + var c = Entry.variableContainer.lists_, e; + for (e in c) { + var f = c[e]; + if (f.object_ === b.id && f.name_ == a) { + return !0; + } } - if (this.object) { - for (var b = this.object.sounds, d = 0, c = b.length;d < c;d++) { - var e = b[d].view; - e.orderHolder.innerHTML = d + 1; - a.appendChild(e); + return !1; + }; + b.updateLocalList = function(a, b, c) { + var e = Entry.variableContainer.lists_, f; + for (f in e) { + var g = e[f]; + if (g.object_ === c.id && g.name_ == a) { + g.syncModel_({x:g.x_, y:g.y_, id:g.id_, visible:g.visible_, name:a, isCloud:g.isClud_, width:g.width_, height:g.height_, array:b}); + g.updateView(); + Entry.variableContainer.updateList(); + break; } } - } -}; -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.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.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 d = this.view_.children; - for (b = 0;b < d.length;b++) { - var c = d[b]; - -1 < c.id.toUpperCase().indexOf(a.toUpperCase()) ? c.removeClass("entryRemove") : c.addClass("entryRemove"); + }; + b.createLocalList = function(a, b, c) { + this.isLocalListExisted(a, c) || (Entry.variableContainer.addList({name:a, array:b, object:c.id, variableType:"list"}), Entry.variableContainer.updateList()); + }; + b.isLocalList = function(a) { + var b = Entry.playground.object, c = Entry.variableContainer.lists_, e; + for (e in c) { + var f = c[e]; + if (f.object_ == b.id && f.id_ == a) { + return !0; + } } - Entry.pictureEditable && ("picture" == a ? (this.painter.show(), this.pictureView_.object && this.pictureView_.object == this.object || (this.pictureView_.object = this.object, this.injectPicture())) : this.painter.hide()); - if ("sound" == a && (!this.soundView_.object || this.soundView_.object != this.object)) { - this.soundView_.object = this.object, this.injectSound(); + return !1; + }; + b.isLocalType = function(a, b) { + if ("get_variable" == a.data.type || "set_variable" == a.data.type || "change_variable" == a.data.type) { + if (this.isLocalVariable(b)) { + return !0; + } } else { - if ("text" == a && "textBox" == this.object.objectType || this.textView_.object != this.object) { - this.textView_.object = this.object, this.injectText(); + if (("value_of_index_from_list" == a.data.type || "add_value_to_list" == a.data.type || "remove_value_from_list" == a.data.type || "insert_value_to_list" == a.data.type || "change_value_list_index" == a.data.type || "length_of_list" == a.data.type || "is_included_in_list" == a.data.type) && this.isLocalList(b)) { + return !0; } } - "code" == a && this.resizeHandle_ && this.resizeHandle_.removeClass("entryRemove"); - Entry.engine.isState("run") && this.curtainView_.removeClass("entryRemove"); - this.viewMode_ = a; - this.toggleOffVariableView(); - } -}; -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.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 a = Entry.playground; - Entry.stateManager && Entry.stateManager.addCommand("edit block", a, a.restoreBlock, a.object, a.object.getScriptText()); -}; -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.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.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.Playground.prototype.hideTabs = function() { - var a = ["picture", "text", "sound", "variable"], b; - for (b in a) { - this.hideTab([a[b]]); - } -}; -Entry.Playground.prototype.hideTab = function(a) { - this.tabViewElements[a] && (this.tabViewElements[a].addClass("hideTab"), this.tabViewElements[a].removeClass("showTab")); -}; -Entry.Playground.prototype.showTabs = function() { - var a = ["picture", "text", "sound", "variable"], b; - for (b in a) { - this.showTab(a[b]); - } -}; -Entry.Playground.prototype.showTab = function(a) { - this.tabViewElements[a] && (this.tabViewElements[a].addClass("showTab"), this.tabViewElements[a].removeClass("hideTab")); -}; -Entry.Playground.prototype.initializeResizeHandle = function(a) { - $(a).bind("mousedown touchstart", function(b) { - Entry.playground.resizing = !0; - Entry.documentMousemove && (Entry.playground.resizeEvent = Entry.documentMousemove.attach(this, function(b) { - Entry.playground.resizing && Entry.resizeElement({menuWidth:b.clientX - Entry.interfaceState.canvasWidth}); - })); - }); - $(document).bind("mouseup touchend", function(b) { - if (b = Entry.playground.resizeEvent) { - Entry.playground.resizing = !1, Entry.documentMousemove.detach(b), delete Entry.playground.resizeEvent; + }; + b.isEventBlock = function(a) { + a = a.data.type; + return "when_run_button_click" == a || "when_some_key_pressed" == a || "mouse_clicked" == a || "mouse_click_cancled" == a || "when_object_click" == a || "when_object_click_canceled" == a || "when_message_cast" == a || "when_scene_start" == a || "when_clone_start" == a ? !0 : !1; + }; + b.makeDefinition = function(a) { + var b = /(%.)/mi; + a = Entry.block[a.data.type].syntax.py[0].split(b); + for (var c = "", e = 0;e < a.length;e++) { + var f = a[e], c = b.test(f) ? c + "event" : c + f } - }); -}; -Entry.Playground.prototype.reloadPlayground = function() { - var a = this.mainWorkspace; - a && (a.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 a = Entry.playground.mainWorkspace.getBoard(); - a.clear(); - a.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(a) { - a = "picture" == a ? this.pictureListView_.childNodes : this.soundListView_.childNodes; - for (var b = 0, d = a.length;b < d;b++) { - a[b].orderHolder.innerHTML = b + 1; - } -}; -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"), d = 0;d < a.length;d++) { - if (a.eq(d).val() == f.value && a[d] != 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; + return c; + }; + b.isNoPrintBlock = function(a) { + return !1; + }; + b.entryEventFuncFilter = function(a) { + var b = !1; + a = a.split("\n"); + for (var c in a) { + var e = a[c]; + "def entry_event_start():" == e || "def entry_event_mouse_down():" == e || "def entry_event_mouse_up():" == e || "def entry_event_object_down():" == e || "def entry_event_scene_start():" == e || "def entry_event_clone_create():" == e ? (tokens = e.split("def"), e = tokens[1].substring(0, tokens[1].length - 1).trim() + "\n", a[c] = e, b = !0) : (new RegExp(/^def entry_event_key(.+):$/)).test(e) || (new RegExp(/^def entry_event_signal(.+):$/)).test(e) ? (tokens = e.split("def"), e = tokens[1].substring(0, + tokens[1].length - 1).trim() + "\n", a[c] = e, b = !0) : b && (e = a[c], e = e.replace("\t", ""), a[c] = e); + } + return a.join("\n"); + }; + b.eventBlockSyntaxFilter = function(a) { + return "entry_event_start" == a || "entry_event_key" == a || "entry_event_mouse_down" == a || "entry_event_mouse_up" == a || "entry_event_object_down" == a || "entry_event_signal" == a || "entry_event_scene_start" == a || "entry_event_clone_create" == a ? "def " + a : a; + }; + b.isEntryEventFunc = function(a) { + return "def entry_event_start" == a || "def entry_event_key" == a || "def entry_event_mouse_down" == a || "def entry_event_mouse_up" == a || "def entry_event_object_down" == a || "def entry_event_signal" == a || "def entry_event_scene_start" == a || "def entry_event_clone_create" == a ? !0 : !1; + }; + b.searchFuncDefParam = function(a) { + "function_field_label" == a.data.type && this._funcNameQ.enqueue(a.data.params[0]); + return a && a.data && a.data.params && a.data.params[1] ? ("function_field_string" != a.data.type && "function_field_boolean" != a.data.type || this._funcParamQ.enqueue(a.data.params[0].data.type), this.searchFuncDefParam(a.data.params[1])) : a; + }; + b.gatherFuncDefParam = function(a) { + if (a && a.data) { + if (a.data.params[0]) { + if (a.data.params[0].data) { + var b = a.data.params[0].data.type; + "function_field_string" != a.data.type && "function_field_boolean" != a.data.type || this._funcParamQ.enqueue(b); + } else { + "function_field_label" == a.data.type && this._funcNameQ.enqueue(a.data.params[0]); } } - this.picture.name = this.value; - Entry.playground.reloadPlayground(); - Entry.dispatchEvent("pictureNameChanged", this.picture); + if (a.data.params[1]) { + var c = this.searchFuncDefParam(a.data.params[1]); + c.data.params[0].data && (b = c.data.params[0].data.type, "function_field_string" != c.data.type && "function_field_boolean" != c.data.type || this._funcParamQ.enqueue(b)); + c.data.params[1] && c.data.params[1].data.params[0].data && (b = c.data.params[1].data.params[0].data.type, "function_field_string" != c.data.params[1].data.type && "function_field_boolean" != c.data.params[1].data.type || this._funcParamQ.enqueue(b)); + } } - } - var d = Entry.createElement("li", a.id); - a.view = d; - d.addClass("entryPlaygroundPictureElement"); - d.picture = a; - d.bindOnClick(function(b) { - 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(d), 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() { - Entry.playground.downloadPicture(a.id); - }}], "workspace-contextmenu"); - }); - var c = Entry.createElement("div"); - c.addClass("entryPlaygroundPictureOrder"); - d.orderHolder = c; - d.appendChild(c); - c = Entry.createElement("div", "t_" + a.id); - c.addClass("entryPlaygroundPictureThumbnail"); - if (a.fileurl) { - c.style.backgroundImage = 'url("' + a.fileurl + '")'; - } else { - var e = a.filename; - c.style.backgroundImage = 'url("' + Entry.defaultPath + "/uploads/" + e.substring(0, 2) + "/" + e.substring(2, 4) + "/thumb/" + e + '.png")'; - } - d.appendChild(c); - 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(b) { - 13 == b.keyCode && this.blur(); + return c; }; - d.appendChild(f); - c = Entry.createElement("div", "s_" + a.id); - c.addClass("entryPlaygroundPictureSize"); - c.innerHTML = a.dimension.width + " X " + a.dimension.height; - d.appendChild(c); -}; -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 d = Entry.createElement("div"); - d.addClass("entryPlaygroundSoundOrder"); - b.orderHolder = d; - b.appendChild(d); - var c = Entry.createElement("div"); - c.addClass("entryPlaygroundSoundThumbnail"); - c.addClass("entryPlaygroundSoundPlay"); - var e = !1, f; - c.addEventListener("click", function() { - e ? (e = !1, c.removeClass("entryPlaygroundSoundStop"), c.addClass("entryPlaygroundSoundPlay"), f.stop()) : (e = !0, c.removeClass("entryPlaygroundSoundPlay"), c.addClass("entryPlaygroundSoundStop"), f = createjs.Sound.play(a.id), f.addEventListener("complete", function(b) { - c.removeClass("entryPlaygroundSoundStop"); - c.addClass("entryPlaygroundSoundPlay"); - e = !1; - }), f.addEventListener("loop", function(b) { - }), f.addEventListener("failed", function(b) { - })); - }); - b.appendChild(c); - 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 b = 0, a = 0;a < h.length;a++) { - if (h[a].value == g.value && (b += 1, 1 < b)) { - alert("\uc774\ub984\uc774 \uc911\ubcf5 \ub418\uc5c8\uc2b5\ub2c8\ub2e4."); - this.focus(); - return; + b.getLastParam = function(a) { + a && a.data && a.data.params[1] && (a = this.getLastParam(a.data.params[1])); + return a; + }; + b.isFuncContentsMatch = function(a, b, c) { + for (var e = !0, f = 0;f < a.length && e;f++) { + var e = !1, g = a[f], h = b[f]; + if (g && !h) { + e = fasle; + break; + } + if (!g && h) { + e = !1; + break; + } + if (h.type == g.data.type) { + var e = !0, k = h.params, l = g.data.params, m = []; + l.map(function(a, b) { + a && m.push(a); + }); + l = m; + if (k.length == l.length) { + for (var e = !0, n = 0;n < k.length && e;n++) { + if (e = !1, k[n].name) { + for (var q in textFuncParams) { + if (k[n].name == textFuncParams[q]) { + for (var r in c) { + if (l[n].data.type == r && c[r] == q) { + e = !0; + break; + } + } + if (e) { + break; + } + } + } + } else { + "True" == k[n].type || "False" == k[n].type ? k[n].type == l[n].data.type && (e = !0) : k[n].type && k[n].params && k[n].params[0] == l[n].data.params[0] && (e = !0); + } + } + e && h.statements && 0 != h.statements.length && (e = this.isFuncContentsMatch(g.data.statements[0]._data, h.statements[0])); + } else { + e = !1; + break; } + } else { + e = !1; + break; } - this.sound.name = this.value; - Entry.playground.reloadPlayground(); } + return e; }; - g.onkeypress = function(b) { - 13 == b.keyCode && this.blur(); + b.isParamBlock = function(a) { + a = a.type; + return "ai_boolean_distance" == a || "ai_distance_value" == a || "ai_boolean_object" == a || "ai_boolean_and" == a ? !0 : !1; }; - b.appendChild(g); - d = Entry.createElement("div"); - d.addClass("entryPlaygroundSoundLength"); - d.innerHTML = a.duration + " \ucd08"; - b.appendChild(d); -}; -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); -}; -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 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.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"); + b.hasBlockInfo = function(a, b) { + var c = !1, e; + for (e in b) { + var f = b[e]; + if (e == a.type) { + for (var g in f) { + var h = f[g]; + if (h.start == a.start && h.end == a.end) { + c = !0; + break; + } + } + } + } + return c; + }; + b.updateBlockInfo = function(a, b) { + var c = b[a.type]; + if (c && Array.isArray(c) && 0 != c.legnth) { + for (var e in c) { + var f = c[e]; + if (f.start == a.start && f.end == a.end) { + break; + } else { + f = {}, f.start = a.start, f.end = a.end, c.push(f); + } + } + } else { + b[a.type] = [], f = {}, f.start = a.start, f.end = a.end, b[a.type].push(f); + } + }; + b.jsAdjustSyntax = function(a, b) { + var c = ""; + if ("ai_boolean_distance" == a.data.type) { + var e = b.split(" "), c = e[0].split("_"); + c[1] = c[1].substring(1, c[1].length - 1); + c[1] = c[1].toLowerCase(); + var c = c.join("_"), f = e[1], f = this.bTojBinaryOperatorConvertor(f), e = e[2], c = c + " " + f + " " + e; + } else { + "ai_boolean_object" == a.data.type ? (e = b.split(" "), c = e[0].split("_"), c[1] = c[1].substring(1, c[1].length - 1), c[1] = c[1].toLowerCase(), c = c.join("_"), f = e[1], e = e[2], c = c + " " + f + " " + e) : "ai_distance_value" == a.data.type ? (e = b.split(" "), c = e[0].split("_"), c[1] = c[1].substring(1, c[1].length - 1), c[1] = c[1].toLowerCase(), c = c.join("_")) : c = b; + } + return c; + }; + b.bTojBinaryOperatorConvertor = function(a) { + var b; switch(a) { - case Entry.TEXT_ALIGN_LEFT: - this.alignLeftBtn.addClass("toggle"); + case "'BIGGER'": + b = ">"; break; - case Entry.TEXT_ALIGN_CENTER: - this.alignCenterBtn.addClass("toggle"); + case "'BIGGER_EQUAL'": + b = ">="; break; - case Entry.TEXT_ALIGN_RIGHT: - this.alignRightBtn.addClass("toggle"); + case "'EQUAL'": + b = "=="; + break; + case "'SMALLER'": + b = "<"; + break; + case "'SMALLER_EQUAL'": + b = "<="; } - this.object.entity.setTextAlign(a); - } -}; -Entry.Playground.prototype.hideBlockMenu = function() { - this.mainWorkspace.getBlockMenu().hide(); -}; -Entry.Playground.prototype.showBlockMenu = function() { - this.mainWorkspace.getBlockMenu().show(); -}; -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"); - "tablet" === Entry.device && this.window_.addClass("tablet"); - 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.windowResized.notify(); -}; -Entry.Popup.prototype.resize = function(a) { - a = window.popup.window_; - var b = .9 * window.innerWidth, d = .9 * window.innerHeight - 35; - 9 * b <= 16 * d ? d = b / 16 * 9 + 35 : (b = 16 * d / 9, d += 35); - a.style.width = String(b) + "px"; - a.style.height = String(d) + "px"; - Entry.stage && Entry.stage.updateBoundRect(); + return b; + }; + b.jTobBinaryOperatorConvertor = function(a) { + var b; + switch(a) { + case ">": + b = "BIGGER"; + break; + case ">=": + b = "BIGGER_EQUAL"; + break; + case "==": + b = "EQUAL"; + break; + case "<": + b = "SMALLER"; + break; + case "<=": + b = "SMALLER_EQUAL"; + } + return b; + }; + b.radarVariableConvertor = function(a) { + return a.split("_")[1].toUpperCase(); + }; + b.tTobDropdownValueConvertor = function(a) { + return "stone" == a ? "OBSTACLE" : "wall" == a ? a.toUpperCase() : "item" == a ? a.toUpperCase() : a; + }; +})(Entry.TextCodingUtil.prototype); +Entry.BlockToJsParser = function(b) { + this.syntax = b; + this._iterVariableCount = 0; + this._iterVariableChunk = ["i", "j", "k"]; }; -Entry.popupHelper = function(a) { - this.popupList = {}; - this.nowContent; - a && (window.popupHelper = null); - Entry.assert(!window.popupHelper, "Popup exist"); - var b = ["confirm", "spinner"], d = ["entryPopupHelperTopSpan", "entryPopupHelperBottomSpan", "entryPopupHelperLeftSpan", "entryPopupHelperRightSpan"]; - this.body_ = Entry.Dom("div", {classes:["entryPopup", "hiddenPopup", "popupHelper"]}); - var c = this; - this.body_.bindOnClick(function(a) { - if (!(c.nowContent && -1 < b.indexOf(c.nowContent.prop("type")))) { - var f = $(a.target); - d.forEach(function(b) { - f.hasClass(b) && this.popup.hide(); - }.bind(this)); - a.target == this && this.popup.hide(); +(function(b) { + b.Code = function(a, b) { + this._parseMode = b; + if (a instanceof Entry.Block) { + return this.Block(a); } - }); - this.body_.bind("touchstart", function(a) { - if (!(c.nowContent && -1 < b.indexOf(c.nowContent.prop("type")))) { - var f = $(a.target); - d.forEach(function(b) { - f.hasClass(b) && this.popup.hide(); - }.bind(this)); - a.target == this && this.popup.hide(); + for (var c = "", e = a._data, f = 0;f < e.length;f++) { + c += this.Thread(e[f]); } - }); - 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]); - } -}; -Entry.popupHelper.prototype.addPopup = function(a, b) { - var d = Entry.Dom("div"), c = Entry.Dom("div", {class:"entryPopupHelperCloseButton"}); - c.bindOnClick(function() { - b.closeEvent ? b.closeEvent(this) : this.hide(); - }.bind(this)); - var e = this; - c.bind("touchstart", function() { - b.closeEvent ? b.closeEvent(e) : e.hide(); - }); - var f = Entry.Dom("div", {class:"entryPopupHelperWrapper"}); - f.append(c); - b.title && (c = Entry.Dom("div", {class:"entryPopupHelperTitle"}), f.append(c), c.text(b.title)); - d.addClass(a); - d.append(f); - d.popupWrapper_ = f; - d.prop("type", b.type); - "function" === typeof b.setPopupLayout && b.setPopupLayout(d); - this.popupList[a] = d; -}; -Entry.popupHelper.prototype.hasPopup = function(a) { - return !!this.popupList[a]; -}; -Entry.popupHelper.prototype.setPopup = function(a) { -}; -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.popupHelper.prototype.resize = function(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.popupHelper.prototype.hide = function() { - this.nowContent = void 0; - this.body_.addClass("hiddenPopup"); -}; -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.Reporter = function(a) { - this.projectId = this.userId = null; - this.isRealTime = a; - this.activities = []; -}; -Entry.Reporter.prototype.start = function(a, b, d) { - 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:d})); - this.userId = b; - this.projectId = a; -}; -Entry.Reporter.prototype.report = function(a) { - if (!this.isRealTime || this.io) { - var b = [], d; - for (d in a.params) { - var c = a.params[d]; - "object" !== typeof c ? b.push(c) : c.id && b.push(c.id); + return c.trim(); + }; + b.Thread = function(a) { + if (a instanceof Entry.Block) { + return this.Block(a); } - 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); - } -}; -Entry.Scene = function() { - var a = this; - this.scenes_ = []; - this.selectedScene = null; - this.maxCount = 20; - $(window).on("resize", function(b) { - a.resize(); - }); -}; -Entry.Scene.viewBasicWidth = 70; -Entry.Scene.prototype.generateView = function(a, b) { - var d = this; - this.view_ = a; - this.view_.addClass("entryScene"); - b && "workspace" != b || (this.view_.addClass("entrySceneWorkspace"), $(this.view_).on("mousedown", function(b) { - var a = $(this).offset(), f = $(window), g = b.pageX - a.left + f.scrollLeft(); - b = b.pageY - a.top + f.scrollTop(); - b = 40 - b; - a = -40 / 55; - f = $(d.selectedScene.view).find(".entrySceneRemoveButtonCoverWorkspace").offset().left; - !(g < f || g > f + 55) && b > 40 + a * (g - f) && (g = d.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, d = Entry.createElement("li", a.id); - d.addClass("entrySceneElementWorkspace"); - d.addClass("entrySceneButtonWorkspace"); - d.addClass("minValue"); - $(d).on("mousedown", function(b) { - Entry.engine.isState("run") ? b.preventDefault() : Entry.scene.selectScene(a); - }); - var c = Entry.createElement("input"); - c.addClass("entrySceneFieldWorkspace"); - c.value = a.name; - Entry.sceneEditable || (c.disabled = "disabled"); - var e = Entry.createElement("span"); - e.addClass("entrySceneLeftWorkspace"); - d.appendChild(e); - var f = Entry.createElement("span"); - f.addClass("entrySceneInputCover"); - f.style.width = Entry.computeInputWidth(a.name); - d.appendChild(f); - a.inputWrapper = f; - c.onkeyup = function(d) { - d = d.keyCode; - Entry.isArrowOrBackspace(d) || (a.name = this.value, f.style.width = Entry.computeInputWidth(a.name), b.resize(), 13 == d && this.blur(), 10 < this.value.length && (this.value = this.value.substring(0, 10), this.blur())); + var b = ""; + a = a.getBlocks(); + for (var c = 0;c < a.length;c++) { + var e = a[c]; + c != a.length - 1 ? (e = this.Block(e), this._parseMode == Entry.Parser.PARSE_GENERAL ? b += e + "\n" : this._parseMode == Entry.Parser.PARSE_SYNTAX && (b = e + "\n")) : (e = this.Block(e), this._parseMode == Entry.Parser.PARSE_GENERAL ? b += e : this._parseMode == Entry.Parser.PARSE_SYNTAX && (b = e)); + } + return b + "\n"; }; - c.onblur = function(b) { - c.value = this.value; - a.name = this.value; - f.style.width = Entry.computeInputWidth(a.name); + b.Block = function(a) { + var b = a._schema.syntax.js ? a._schema.syntax.js : a._schema.syntax; + return b ? a = this[b[0]](a) : ""; }; - f.appendChild(c); - e = Entry.createElement("span"); - e.addClass("entrySceneRemoveButtonCoverWorkspace"); - d.appendChild(e); - if (Entry.sceneEditable) { - var g = Entry.createElement("button"); - g.addClass("entrySceneRemoveButtonWorkspace"); - g.scene = a; - g.bindOnClick(function(b) { - b.stopPropagation(); - Entry.engine.isState("run") || confirm(Lang.Workspace.will_you_delete_scene) && Entry.scene.removeScene(this.scene); - }); - e.appendChild(g); - } - Entry.Utils.disableContextmenu(d); - $(d).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 = d; -}; -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); + b.Program = function(a) { + return ""; + }; + b.Scope = function(a) { + var b = !1, c = "", e = /(%.)/mi; + if (a._schema.syntax.js) { + var f = a._schema.syntax.js.concat(), b = !0 + } else { + f = a._schema.syntax.concat(); } - this.addButton_ && (this.getScenes().length < this.maxCount ? this.addButton_.removeClass("entryRemove") : this.addButton_.addClass("entryRemove")); - } - this.resize(); -}; -Entry.Scene.prototype.addScenes = function(a) { - if ((this.scenes_ = a) && 0 !== a.length) { - for (var b = 0, d = a.length;b < d;b++) { - this.generateElement(a[b]); + f.shift(); + for (var f = f[0].split(e), g = a._schema.params, h = a.data.params, k = 0;k < f.length;k++) { + var l = f[k]; + 0 !== l.length && "Scope" !== l && ("Judge" === l ? b = !0 : e.test(l) ? (l = l.split("%")[1], l = parseInt(l) - 1, g[l] && "Image" != g[l].type && ("Block" == g[l].type ? (l = this.Block(h[l]), c += l) : c += this[g[l].type](h[l], g[l]))) : c += l); } - } else { - this.scenes_ = [], this.scenes_.push(this.createScene()); - } - this.selectScene(this.getScenes()[0]); - this.updateView(); -}; -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.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), d = 0;d < b.length;d++) { - Entry.container.removeObject(b[d]); + "#" == c.charAt(c.length - 1) && (b = !0, c = c.substring(0, c.length - 1), c = c.trim()); + b || (c += "();"); + return c = Entry.TextCodingUtil.prototype.jsAdjustSyntax(a, c); + }; + b.BasicFunction = function(a) { + a = this.Thread(a.statements[0]); + return "function promise() {\n" + this.indent(a).trim() + "}"; + }; + b.BasicIteration = function(a) { + var b = a.params[0], c = this.publishIterateVariable(); + a = this.Thread(a.statements[0]); + this.unpublishIterateVariable(); + return "for (var " + c + " = 0; " + c + " < " + b + "; " + c + "++) {\n" + this.indent(a) + "}"; + }; + b.BasicIf = function(a) { + if (2 == a.data.statements.length) { + var b = this.Thread(a.statements[0]), c = this.Thread(a.statements[1]), e = a._schema.syntax.concat(), e = (a = a.data.params[0]) && "True" == a.data.type ? e[1] : void 0 === a ? e[1] : this.Block(a), b = "if (" + e + ") {\n" + this.indent(b) + "}\nelse {\n" + this.indent(c) + "}\n" + } else { + b = this.Thread(a.statements[0]), e = a._schema.syntax.concat(), e = (a = a.data.params[0]) && "True" == a.data.type ? e[1] : void 0 === a ? e[1] : this.Block(a), b = "if (" + e + ") {\n" + this.indent(b) + "}\n"; } - Entry.stage.removeObjectContainer(a); - $(a.view).remove(); - this.selectScene(); - } -}; -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.Scene.prototype.toJSON = function() { - for (var a = [], b = this.getScenes().length, d = 0;d < b;d++) { - var c = this.getScenes()[d], e = c.view, f = c.inputWrapper; - delete c.view; - delete c.inputWrapper; - a.push(JSON.parse(JSON.stringify(c))); - c.view = e; - c.inputWrapper = f; - } - 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.Scene.prototype.getSceneById = function(a) { - for (var b = this.getScenes(), d = 0;d < b.length;d++) { - if (b[d].id == a) { - return b[d]; + return b; + }; + b.BasicWhile = function(a) { + var b = this.Thread(a.statements[0]); + return "while (" + a._schema.syntax.concat()[1] + ") {\n" + this.indent(b) + "}\n"; + }; + b.indent = function(a) { + var b = ""; + a = a.split("\n"); + for (var c in a) { + var e = a[c]; + 0 != e.length && (b += "\t" + e + "\n"); } - } - return !1; -}; -Entry.Scene.prototype.getScenes = function() { - return this.scenes_; -}; -Entry.Scene.prototype.takeStartSceneSnapshot = function() { - this.sceneBeforeRun = this.selectedScene; -}; -Entry.Scene.prototype.loadStartSceneSnapshot = function() { - this.selectScene(this.sceneBeforeRun); - this.sceneBeforeRun = null; -}; -Entry.Scene.prototype.createScene = function() { - var a = {name:Lang.Blocks.SCENE + " " + (this.getScenes().length + 1), id:Entry.generateHash()}; - this.generateElement(a); - return a; + return b; + }; + b.publishIterateVariable = function() { + var a = "", b = this._iterVariableCount; + do { + a = this._iterVariableChunk[b % 3] + a, b = parseInt(b / 3) - 1, 0 === b && (a = this._iterVariableChunk[0] + a); + } while (0 < b); + this._iterVariableCount++; + return a; + }; + b.unpublishIterateVariable = function() { + this._iterVariableCount && this._iterVariableCount--; + }; + b.Dropdown = function(a) { + "OBSTACLE" == a ? a = "stone" : "ITEM" == a ? a = a.toLowerCase() : "WALL" == a && (a = a.toLowerCase()); + return "'" + a + "'"; + }; + b.TextInput = function(a) { + return a; + }; + b.DropdownDynamic = function(a, b) { + return a = "null" == a ? "none" : Entry.TextCodingUtil.prototype.dropdownDynamicValueConvertor(a, b); + }; +})(Entry.BlockToJsParser.prototype); +Entry.BlockToPyParser = function(b) { + this.blockSyntax = b; + this._variableMap = new Entry.Map; + this._funcMap = new Entry.Map; + this._queue = new Entry.Queue; }; -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 d = a.length - 1;0 <= d;d--) { - Entry.container.addCloneObject(a[d], b.id); +(function(b) { + b.Code = function(a, b) { + this._parseMode = b; + if (a instanceof Entry.Thread) { + return this.Thread(a); } - } -}; -Entry.Scene.prototype.resize = function() { - var a = this.getScenes(), b = this.selectedScene, d = a[0]; - if (0 !== a.length && d) { - var c = $(d.view).offset().left, d = parseFloat($(b.view).css("margin-left")), e = $(this.view_).width() - c, f = 0, g; - for (g in a) { - var c = a[g], h = c.view; - h.addClass("minValue"); - $(c.inputWrapper).width(Entry.computeInputWidth(c.name)); - h = $(h); - f = f + h.width() + d; + if (a instanceof Entry.Block) { + return this.Block(a); } - if (f > e) { - for (g in e -= $(b.view).width(), d = e / (a.length - 1) - (Entry.Scene.viewBasicWidth + d), a) { - c = a[g], b.id != c.id ? (c.view.removeClass("minValue"), $(c.inputWrapper).width(d)) : c.view.addClass("minValue"); - } + for (var c = "", e = a.getThreads(), f = 0;f < e.length;f++) { + c += this.Thread(e[f]) + "\n"; } - } -}; -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, d) { - 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)); - d instanceof Entry.Script && (this.parentScript = d); - a = a.childNodes; - for (b = 0;b < a.length;b++) { - if (d = a[b], "NEXT" == d.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" == d.tagName.toUpperCase()) { - this.values || (this.values = {}); - var c = new Entry.Script(this.entity); - this.register && (c.register = this.register); - c.init(d.childNodes[0]); - this.values[d.getAttribute("name")] = c; + return c = c.trim(); + }; + b.Thread = function(a) { + if (a instanceof Entry.Block) { + return this.Block(a); + } + var b = ""; + a = a.getBlocks(); + for (var c = !1, e = "", f = "", g = 0;g < a.length;g++) { + var h = a[g]; + if (this._parseMode == Entry.Parser.PARSE_GENERAL) { + if (Entry.TextCodingUtil.prototype.isNoPrintBlock(h)) { + continue; + } + 0 == g ? (c = Entry.TextCodingUtil.prototype.isEventBlock(h)) ? e = this.Block(h) + "\n" : f += this.Block(h) + "\n" : 0 != g && (f += this.Block(h) + "\n"); } else { - "FIELD" == d.tagName.toUpperCase() ? (this.fields || (this.fields = {}), this.fields[d.getAttribute("name")] = d.textContent) : "STATEMENT" == d.tagName.toUpperCase() && (this.statements || (this.statements = {}), c = new Entry.Script(this.entity), this.register && (c.register = this.register), c.init(d.childNodes[0], null, this), c.key = d.getAttribute("name"), this.statements[d.getAttribute("name")] = c); + this._parseMode == Entry.Parser.PARSE_SYNTAX && (b = (c = Entry.TextCodingUtil.prototype.isEventBlock(h)) ? "" : this.Block(h) + "\n"); } + this._queue.clear(); + this._variableMap.clear(); } - } -}; -p.clone = function(a, b) { - var d = new Entry.Script(a); - d.id = this.id; - d.type = this.type; - d.isRepeat = this.isRepeat; - if (this.parentScript && !this.previousScript && 2 != b) { - d.parentScript = this.parentScript.clone(a); - for (var c = d.parentScript.statements[this.key] = d;c.nextScript;) { - c = c.nextScript, c.parentScript = d.parentScript; - } - } - this.nextScript && 1 != b && (d.nextScript = this.nextScript.clone(a, 0), d.nextScript.previousScript = this); - this.previousScript && 0 !== b && (d.previousScript = this.previousScript.clone(a, 1), d.previousScript.previousScript = this); - if (this.fields) { - d.fields = {}; - for (var e in this.fields) { - d.fields[e] = this.fields[e]; + this._parseMode == Entry.Parser.PARSE_GENERAL && (b = c ? e + Entry.TextCodingUtil.prototype.indent(f) + "\n" : e + f + "\n"); + return b = b.trim() + "\n"; + }; + b.Block = function(a) { + var b = "", c; + a._schema && a._schema.syntax && (c = a._schema.syntax.py[0]); + this.isFunc(a) ? (b += this.makeFuncDef(a), this.isRegisteredFunc(a) && (c = this.makeFuncSyntax(a))) : this.isFuncStmtParam(a) && (b += a.data.type); + if (!c || null == c) { + return b; } - } - if (this.values) { - for (e in d.values = {}, this.values) { - d.values[e] = this.values[e].clone(a); + var e = /(%.)/mi, f = /(\$.)/mi; + c = c.split(e); + var g = a._schema.params, h = a.data.params, k = a._schema.skeleton, l = a._schema.paramsKeyMap, m = ""; + if (this._parseMode == Entry.Parser.PARSE_VARIABLE && k == Entry.Parser.BLOCK_SKELETON_BASIC && l) { + var n = 0 } - } - if (this.statements) { - for (e in d.statements = {}, this.statements) { - for (d.statements[e] = this.statements[e].clone(a, 2), c = d.statements[e], c.parentScript = d;c.nextScript;) { - c = c.nextScript, c.parentScript = d; + for (var q = 0;q < c.length;q++) { + if (n = c[q], 0 !== n.length) { + if (e.test(n)) { + var n = n.split("%")[1], r = Number(n) - 1; + if (g[r] && "Indicator" != g[r].type) { + if ("Block" == g[r].type) { + if (m = this.Block(h[r]).trim(), r = this._funcMap.get(m)) { + b += r; + } else { + var r = m.split("_"), t = r[0]; + 2 == r.length && ("stringParam" == t ? m = "string_param" : "booleanParam" == t && (m = "boolean_param")); + m = Entry.TextCodingUtil.prototype.variableFilter(a, n, m); + b += m; + this._parseMode == Entry.Parser.PARSE_VARIABLE && k == Entry.Parser.BLOCK_SKELETON_BASIC && l && (r = Object.keys(l), n = String(r[n++]), n = n.toLowerCase(), this._variableMap.put(n, m), this._queue.enqueue(n)); + } + } else { + m = this["Field" + g[r].type](h[r], g[r]), null == m && (m = g[r].text ? g[r].text : null), m = Entry.TextCodingUtil.prototype.binaryOperatorValueConvertor(m), m = String(m), Entry.TextCodingUtil.prototype.isNumeric(m) || Entry.TextCodingUtil.prototype.isBinaryOperator(m) || (m = String('"' + m + '"')), m = Entry.TextCodingUtil.prototype.variableFilter(a, n, m), Entry.TextCodingUtil.prototype.isLocalType(a, h[r]) && (m = "self".concat(".").concat(m)), b += m, this._parseMode == Entry.Parser.PARSE_VARIABLE && + k == Entry.Parser.BLOCK_SKELETON_BASIC && l && (r = Object.keys(l), n = String(r[n++]), n = n.toLowerCase(), this._variableMap.put(n, m), this._queue.enqueue(n)); + } + } + } else { + if (f.test(n)) { + for (n = n.split(f), m = 0;m < n.length;m++) { + r = n[m], 0 !== r.length && (f.test(r) ? (r = Number(r.split("$")[1]) - 1, b += Entry.TextCodingUtil.prototype.indent(this.Thread(a.statements[r]))) : b += r); + } + } else { + m = 0, n.search("#"), -1 != n.search("#") && (m = n.indexOf("#"), n = n.substring(m + 1)), b += n; + } + } } } - } - return d; -}; -p.getStatement = function(a) { - return this.statements[a]; -}; -p.compute = function() { -}; -p.getValue = function(a) { - return this.values[a].run(); -}; -p.getNumberValue = function(a) { - return Number(this.values[a].run()); -}; -p.getStringValue = function(a) { - return String(this.values[a].run()); -}; -p.getBooleanValue = function(a) { - return this.values[a].run() ? !0 : !1; -}; -p.getField = function(a) { - return this.fields[a]; -}; -p.getStringField = function(a) { - return String(this.fields[a]); -}; -p.getNumberField = function(a) { - return Number(this.fields[a]); -}; -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.Stage = function() { - this.variables = {}; - this.background = new createjs.Shape; - this.background.graphics.beginFill("#ffffff").drawRect(-480, -240, 960, 480); - this.objectContainers = []; - this.selectedObjectContainer = null; - this.variableContainer = new createjs.Container; - this.dialogContainer = new createjs.Container; - this.selectedObject = null; - this.isObjectClick = !1; -}; -Entry.Stage.prototype.initStage = function(a) { - this.canvas = new createjs.Stage(a.id); - this.canvas.x = 320; - this.canvas.y = 180; - this.canvas.scaleX = this.canvas.scaleY = 2 / 1.5; - createjs.Touch.enable(this.canvas); - this.canvas.enableMouseOver(10); - this.canvas.mouseMoveOutside = !0; - this.canvas.addChild(this.background); - this.canvas.addChild(this.variableContainer); - this.canvas.addChild(this.dialogContainer); - this.inputField = null; - this.initCoordinator(); - this.initHandle(); - this.mouseCoordinate = {x:0, y:0}; - if (Entry.isPhone()) { - a.ontouchstart = function(b) { - Entry.dispatchEvent("canvasClick", b); - Entry.stage.isClick = !0; - }, a.ontouchend = function(b) { - Entry.stage.isClick = !1; - Entry.dispatchEvent("canvasClickCanceled", b); - }; - } else { - var b = function(b) { - Entry.dispatchEvent("canvasClick", b); - Entry.stage.isClick = !0; - }; - a.onmousedown = b; - a.ontouchstart = b; - b = function(b) { - Entry.stage.isClick = !1; - Entry.dispatchEvent("canvasClickCanceled", b); - }; - a.onmouseup = b; - a.ontouchend = b; - $(document).click(function(b) { - Entry.stage.focused = "entryCanvas" === b.target.id ? !0 : !1; - }); - } - Entry.addEventListener("canvasClick", function(b) { - Entry.stage.isObjectClick = !1; - }); - Entry.windowResized.attach(this, function() { - Entry.stage.updateBoundRect(); - }); - $(window).scroll(function() { - Entry.stage.updateBoundRect(); - }); - b = function(b) { - b.preventDefault(); - var a = Entry.stage.getBoundRect(), e; - -1 < Entry.getBrowserType().indexOf("IE") ? (e = 480 * ((b.pageX - a.left - document.documentElement.scrollLeft) / a.width - .5), b = -270 * ((b.pageY - a.top - document.documentElement.scrollTop) / a.height - .5)) : b.changedTouches ? (e = 480 * ((b.changedTouches[0].pageX - a.left - document.body.scrollLeft) / a.width - .5), b = -270 * ((b.changedTouches[0].pageY - a.top - document.body.scrollTop) / a.height - .5)) : (e = 480 * ((b.pageX - a.left - document.body.scrollLeft) / a.width - .5), - b = -270 * ((b.pageY - a.top - document.body.scrollTop) / a.height - .5)); - Entry.stage.mouseCoordinate = {x:e.toFixed(1), y:b.toFixed(1)}; - Entry.dispatchEvent("stageMouseMove"); + this._parseMode == Entry.Parser.PARSE_VARIABLE && k == Entry.Parser.BLOCK_SKELETON_BASIC && l && (a = Object.keys(l).length) && (b = this.makeExpressionWithVariable(b, a)); + return b; + }; + b.FieldAngle = function(a) { + return a; + }; + b.FieldColor = function(a) { + return a; + }; + b.FieldDropdown = function(a) { + return a; + }; + b.FieldDropdownDynamic = function(a, b) { + console.log("FieldDropdownDynamic", a, b); + console.log("FieldDropdownDynamic Object", Entry.playground.object); + return a = "null" == a ? "None" : Entry.TextCodingUtil.prototype.dropdownDynamicValueConvertor(a, b); + }; + b.FieldImage = function(a) { + return a; + }; + b.FieldIndicator = function(a) { + return a; + }; + b.FieldKeyboard = function(a) { + return a; + }; + b.FieldOutput = function(a) { + return a; + }; + b.FieldText = function(a) { + return a; + }; + b.FieldTextInput = function(a) { + return a; + }; + b.FieldNumber = function(a) { + return a; }; - a.onmousemove = b; - a.ontouchmove = b; - a.onmouseout = function(b) { - Entry.dispatchEvent("stageMouseOut"); + b.FieldKeyboard = function(a) { + (a = Entry.KeyboardCode.prototype.keyCodeToChar[a]) && null != a || (a = "Q"); + return a; }; - Entry.addEventListener("updateObject", function(b) { - Entry.engine.isState("stop") && Entry.stage.updateObject(); - }); - Entry.addEventListener("canvasInputComplete", function(b) { - try { - var a = Entry.stage.inputField.value(); - Entry.stage.hideInputField(); - if (a) { - var e = Entry.container; - e.setInputValue(a); - e.inputValue.complete = !0; + b.getBlockType = function(a) { + return this.blockSyntax[a]; + }; + b.makeExpressionWithVariable = function(a, b) { + var c, e = c = "", f = 0, g = a.indexOf("("); + c = a.substring(0, g).trim().concat("("); + if (this._queue.toString()) { + for (;(variable = this._queue.dequeue()) && !(g = this._variableMap.get(variable), g = variable.concat(" = ").concat(g).concat("\n"), e += g, c = c.concat(variable).concat(",").concat(" "), f++, 10 < f);) { } - } catch (f) { - } - }); - this.initWall(); - this.render(); -}; -Entry.Stage.prototype.render = function() { - Entry.stage.timer && clearTimeout(Entry.stage.timer); - var a = (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)); -}; -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.requestUpdateTwice ? Entry.requestUpdateTwice = !1 : Entry.requestUpdate = !1) : Entry.requestUpdate = !1; -}; -Entry.Stage.prototype.loadObject = function(a) { - var b = a.entity.object; - this.getObjectContainerByScene(a.scene).addChild(b); - this.canvas.update(); -}; -Entry.Stage.prototype.loadEntity = function(a) { - Entry.stage.getObjectContainerByScene(a.parent.scene).addChild(a.object); - this.sortZorder(); - Entry.requestUpdate = !0; -}; -Entry.Stage.prototype.unloadEntity = function(a) { - Entry.stage.getObjectContainerByScene(a.parent.scene).removeChild(a.object); - Entry.requestUpdate = !0; -}; -Entry.Stage.prototype.loadVariable = function(a) { - var b = a.view_; - this.variables[a.id] = b; - this.variableContainer.addChild(b); - Entry.requestUpdate = !0; -}; -Entry.Stage.prototype.removeVariable = function(a) { - this.variableContainer.removeChild(a.view_); - Entry.requestUpdate = !0; -}; -Entry.Stage.prototype.loadDialog = function(a) { - this.dialogContainer.addChild(a.object); -}; -Entry.Stage.prototype.unloadDialog = function(a) { - this.dialogContainer.removeChild(a.object); -}; -Entry.Stage.prototype.sortZorder = function() { - for (var a = Entry.container.getCurrentObjects(), b = this.selectedObjectContainer, d = 0, c = a.length - 1;0 <= c;c--) { - for (var e = a[c], f = e.entity, e = e.clonedEntities, g = 0, h = e.length;g < h;g++) { - e[g].shape && b.setChildIndex(e[g].shape, d++), b.setChildIndex(e[g].object, d++); + g = c.lastIndexOf(","); + c = c.substring(0, g); + c = c.trim().concat(")"); + c = e.concat(c); + } else { + c = a; } - f.shape && b.setChildIndex(f.shape, d++); - b.setChildIndex(f.object, d++); - } -}; -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; -}; -Entry.Stage.prototype.toggleCoordinator = function() { - this.coordinator.visible = !this.coordinator.visible; - Entry.requestUpdate = !0; -}; -Entry.Stage.prototype.selectObject = function(a) { - this.selectedObject = a ? a : null; - this.updateObject(); -}; -Entry.Stage.prototype.initHandle = function() { - this.handle = new EaselHandle(this.canvas); - this.handle.setChangeListener(this, this.updateHandle); - this.handle.setEditStartListener(this, this.startEdit); - this.handle.setEditEndListener(this, this.endEdit); -}; -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); - 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); - this.handle.setVisible(!0); - var b = a.entity; - this.handle.setWidth(b.getScaleX() * b.getWidth()); - this.handle.setHeight(b.getScaleY() * b.getHeight()); - var d, c; - if ("textBox" == b.type) { - if (b.getLineBreak()) { - d = b.regX * b.scaleX, c = -b.regY * b.scaleY; - } else { - var e = b.getTextAlign(); - c = -b.regY * b.scaleY; - switch(e) { - case Entry.TEXT_ALIGN_LEFT: - d = -b.getWidth() / 2 * b.scaleX; - break; - case Entry.TEXT_ALIGN_CENTER: - d = b.regX * b.scaleX; - break; - case Entry.TEXT_ALIGN_RIGHT: - d = b.getWidth() / 2 * b.scaleX; - } - } + return c; + }; + b.isFunc = function(a) { + return "func" == a.data.type.split("_")[0] ? !0 : !1; + }; + b.isRegisteredFunc = function(a) { + a = a.data.type.split("_")[1]; + return Entry.variableContainer.functions_[a] ? !0 : !1; + }; + b.isFuncStmtParam = function(a) { + a = a.data.type.split("_")[0]; + return "stringParam" == a || "booleanParam" == a ? !0 : !1; + }; + b.makeFuncSyntax = function(a) { + var b = "", c = a._schema.template.trim(); + a = a._schema.params; + var b = /(%.)/mi, c = c.trim().split(b), e = "", f = "", g; + for (g in c) { + var h = c[g].trim(); + if (b.test(h)) { + var k = h.split("%")[1], k = Number(k) - 1; + "Indicator" != a[k].type && (f += h.concat(", ")); } else { - d = (b.regX - b.width / 2) * b.scaleX, c = (b.height / 2 - b.regY) * b.scaleY; - } - e = b.getRotation() / 180 * Math.PI; - this.handle.setX(b.getX() - d * Math.cos(e) - c * Math.sin(e)); - this.handle.setY(-b.getY() - d * Math.sin(e) + c * 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()); - this.objectUpdated = !0; - this.handle.setVisible(a.entity.getVisible()); - a.entity.getVisible() && this.handle.render(); + h = h.split(" "), e += h.join("__"); + } + } + k = f.lastIndexOf(","); + f = f.substring(0, k); + return b = e.trim().concat("(").concat(f.trim()).concat(")"); + }; + b.makeFuncDef = function(a) { + var b = "def ", c = this.getFuncInfo(a); + this.isRegisteredFunc(a) || (c.name = "f"); + if (c.name) { + b += c.name; } else { - this.handle.setVisible(!1); + return b; } - } -}; -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()); - } else { - if (0 !== b.width) { - var d = Math.abs(a.width / b.width); - b.flip && (d *= -1); - b.setScaleX(d); + b = b.concat("("); + if (c.params && 0 != c.params.length) { + for (var e in c.params) { + b += c.params[e], b = b.concat(", "); + } + a = b.lastIndexOf(","); + b = b.substring(0, a); + b = b.trim(); } - 0 !== b.height && b.setScaleY(a.height / b.height); - } - d = a.rotation / 180 * Math.PI; - if ("textBox" == b.type) { - var c; - if (b.getLineBreak()) { - b.setX(a.x), b.setY(-a.y); + b = b.concat("):").concat("\n"); + if (c.statements && c.statements.length) { + a = ""; + for (var f in c.statements) { + a += this.Block(c.statements[f]).concat("\n"); + } + a = a.concat("\n"); + b += Entry.TextCodingUtil.prototype.indent(a).concat("\n"); + } + this._funcMap.clear(); + return b; + }; + b.getFuncInfo = function(a) { + var b = {}; + if (a = a.data.type.split("_")[1]) { + var c = Entry.variableContainer.functions_[a]; + if (!c) { + return b.name = "\ud568\uc218", b; + } } else { - switch(b.getTextAlign()) { - case Entry.TEXT_ALIGN_LEFT: - b.setX(a.x - a.width / 2 * Math.cos(d)); - b.setY(-a.y + a.width / 2 * Math.sin(d)); - break; - case Entry.TEXT_ALIGN_CENTER: - b.setX(a.x); - b.setY(-a.y); - break; - case Entry.TEXT_ALIGN_RIGHT: - b.setX(a.x + a.width / 2 * Math.cos(d)), b.setY(-a.y - a.width / 2 * Math.sin(d)); + return b; + } + a = c.block.template; + var e = a.search(/(%.)/); + a = a.substring(0, e).trim().split(" ").join("__"); + Entry.TextCodingUtil.prototype.initQueue(); + Entry.TextCodingUtil.prototype.gatherFuncDefParam(c.content._data[0]._data[0].data.params[0]); + for (var f = [], g = {};m = Entry.TextCodingUtil.prototype._funcParamQ.dequeue();) { + f.push(m); + } + for (var h in f) { + g[f[h]] = h; + } + Entry.TextCodingUtil.prototype.clearQueue(); + if (g) { + var f = {}, k; + for (k in g) { + e = g[k]; + h = k.search("_"); + h = k.substring(0, h); + if ("stringParam" == h) { + var l = "value" + String(e + 1) + } else { + "booleanParam" == h && (l = "boolean" + String(e + 1)); + } + var m = l; + f[e] = m; + this._funcMap.put(k, m); } } - } else { - c = b.width / 2 + a.regX / b.scaleX, b.setX(a.x + a.regX * Math.cos(d) - a.regY * Math.sin(d)), b.setRegX(c), c = b.height / 2 + a.regY / b.scaleY, b.setY(-a.y - a.regX * Math.sin(d) - a.regY * Math.cos(d)), b.setRegY(c); - } - b.setDirection(a.direction); - b.setRotation(a.rotation); - this.selectedObject.entity.doCommand(); - this.editEntity = !1; -}; -Entry.Stage.prototype.startEdit = function() { - this.selectedObject.entity.initCommand(); -}; -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() { - Entry.dispatchEvent("canvasInputComplete"); - }})); - a = new createjs.Container; - var b = new Image; - b.src = Entry.mediaFilePath + "confirm_button.png"; - var d = new createjs.Bitmap; - d.scaleX = .23; - d.scaleY = .23; - d.x = 160; - d.y = 89; - d.cursor = "pointer"; - d.image = b; - a.addChild(d); - a.on("mousedown", function(b) { - Entry.dispatchEvent("canvasInputComplete"); - }); - this.inputSubmitButton || (this.inputField.value(""), this.canvas.addChild(a), this.inputSubmitButton = a); - this.inputField.show(); - Entry.requestUpdateTwice = !0; -}; -Entry.Stage.prototype.hideInputField = function() { - this.inputField && this.inputField.value() && this.inputField.value(""); - this.inputSubmitButton && (this.canvas.removeChild(this.inputSubmitButton), this.inputSubmitButton = null); - this.inputField && this.inputField.hide(); - Entry.requestUpdate = !0; -}; -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]); + k = c.content._data[0]._data; + l = []; + for (c = 1;c < k.length;c++) { + l.push(k[c]); } - this.selectedObjectContainer = this.objectContainers[0]; - } else { - a = this.createObjectContainer(Entry.scene.selectedScene), this.objectContainers.push(a), this.selectedObjectContainer = a; - } - this.canvas.addChild(this.selectedObjectContainer); - this.selectObjectContainer(Entry.scene.selectedScene); + a && (b.name = a); + 0 != Object.keys(f).length && (b.params = f); + 0 != l.length && (b.statements = l); + return b; + }; +})(Entry.BlockToPyParser.prototype); +Entry.JsToBlockParser = function(b) { + this.syntax = b; + this.scopeChain = []; + this.scope = null; + this._blockCount = 0; + this._blockInfo = {}; }; -Entry.Stage.prototype.selectObjectContainer = function(a) { - if (this.canvas) { - for (var b = this.objectContainers, d = 0;d < b.length;d++) { - this.canvas.removeChild(b[d]); +(function(b) { + b.Program = function(a) { + var b = [], c = []; + c.push({type:this.syntax.Program}); + for (var e in a) { + var f = a[e]; + if ("Program" != f.type) { + return; + } + this.initScope(f); + var f = this.BlockStatement(f), g; + for (g in f) { + c.push(f[g]); + } + this.unloadScope(); + 0 != c.length && b.push(c); } - this.selectedObjectContainer = this.getObjectContainerByScene(a); - 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]); - } - 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.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.getObjectContainerByScene = function(a) { - for (var b = this.objectContainers, d = 0;d < b.length;d++) { - if (b[d].scene.id == a.id) { - return b[d]; + return b; + }; + b.Identifier = function(a) { + return a.name; + }; + b.Literal = function(a, b) { + return !0 === a.value ? {type:"True"} : !1 === a.value ? {type:"False"} : "ai_distance_value" == b ? a.value : "ai_boolean_object" == b ? a.value : {type:"text", params:[a.value]}; + }; + b.ExpressionStatement = function(a) { + a = a.expression; + return this[a.type](a); + }; + b.ForStatement = function(a) { + var b = a.init, c = 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:a}; } - } -}; -Entry.Stage.prototype.moveSprite = function(a) { - if (this.selectedObject && Entry.stage.focused && !this.selectedObject.getLock()) { - var b = 5; - a.shiftKey && (b = 1); - var d = this.selectedObject.entity; - switch(a.keyCode) { - case 38: - d.setY(d.getY() + b); + var f = this[f.type](f), b = b.declarations[0].init.value, g = c.operator, c = c.right.value, h = 0; + "++" != e.operator && (e = b, b = c, c = e); + switch(g) { + case "<": + h = c - b; break; - case 40: - d.setY(d.getY() - b); + case "<=": + h = c + 1 - b; break; - case 37: - d.setX(d.getX() - b); + case ">": + h = b - c; break; - case 39: - d.setX(d.getX() + b); + case ">=": + h = b + 1 - c; } - this.updateObject(); - } -}; -Entry.Stage.prototype.getBoundRect = function(a) { - return this._boundRect ? this._boundRect : this.updateBoundRect(); -}; -Entry.Stage.prototype.updateBoundRect = function(a) { - return 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; -}; -(function(a, b) { - a.applyFilter = b.applyFilter; - a.removeClone = b.removeClone; - a.getWidth = b.getWidth; - a.getHeight = b.getHeight; - a.getInitialEffectValue = b.getInitialEffectValue; -})(Entry.StampEntity.prototype, Entry.EntityObject.prototype); -Entry.JsAstGenerator = function() { -}; -(function(a) { - a.generate = function(b) { - return arcon.parse(b); + return this.BasicIteration(a, h, f); }; -})(Entry.JsAstGenerator.prototype); -Entry.PyAstGenerator = function() { -}; -(function(a) { - a.generate = function(b) { - var a = filbert.parse, c = {locations:!1, ranges:!1}, e; - try { - return e = a(b, c), console.log("astTree", e), e; - } catch (f) { - throw f.message = " \ud30c\uc774\uc36c \ubb38\ubc95\uc744 \ud655\uc778\ud574\uc8fc\uc138\uc694", f; + b.BlockStatement = function(a) { + var b = []; + a = a.body; + for (var c = 0;c < a.length;c++) { + var e = a[c], f = this[e.type](e); + Entry.TextCodingUtil.prototype.hasBlockInfo(e, this._blockInfo) || this._blockCount++; + Entry.TextCodingUtil.prototype.updateBlockInfo(e, this._blockInfo); + if (f) { + if (void 0 === f.type) { + throw {title:"\ube14\ub85d\ubcc0\ud658 \uc624\ub958", message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ube14\ub85d\uc785\ub2c8\ub2e4.", node:e, blockCount:this._blockCount}; + } + Entry.TextCodingUtil.prototype.isParamBlock(f) || f && b.push(f); + } } - }; -})(Entry.PyAstGenerator.prototype); -Entry.Map = function() { - this._map = {repo:{}}; -}; -(function(a) { - a.getKey = function(b) { return b; }; - a.put = function(b, a) { - b = this.getKey(b); - this._map.repo[b] = a; - }; - a.contains = function(b) { - b = this.getKey(b); - return this._map.repo[b] ? !0 : !1; + b.EmptyStatement = function(a) { + throw {message:"empty\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; }; - a.get = function(b) { - b = this.getKey(b); - return this._map.repo[b] ? this._map.repo[b] : null; + b.DebuggerStatement = function(a) { + throw {message:"debugger\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; }; - a.remove = function(b) { - var a = this.getKey(b); - this.contains(b) && (this._map.repo[a] = void 0); + b.WithStatement = function(a) { + throw {message:"with\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; }; - a.clear = function() { - this._map.repo = {}; + b.ReturnStaement = function(a) { + throw {message:"return\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; }; - a.toString = function() { - return this._map.repo; + b.LabeledStatement = function(a) { + throw {message:"label\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; }; -})(Entry.Map.prototype); -Entry.Queue = function() { - this.tail = this.head = null; -}; -function Node(a) { - this.data = a; - this.next = null; -} -(function(a) { - a.enqueue = function(b) { - b = new Node(b); - null === this.head ? this.head = b : this.tail.next = b; - this.tail = b; + b.BreakStatement = function(a) { + throw {message:"break\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; }; - a.dequeue = function() { - var b; - null !== this.head && (b = this.head.data, this.head = this.head.next); - return b; + b.ContinueStatement = function(a) { + throw {message:"continue\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; }; - a.clear = function() { - for (;this.dequeue();) { + b.IfStatement = function(a) { + if (this.syntax.BasicIf) { + return this.BasicIf(a); } + throw {message:"if\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; }; - a.toString = function() { - for (var b = this.head, a = [];b;) { - a.push(b.data), b = b.next; - } - return a.toString(); + b.SwitchStatement = function(a) { + throw {message:"switch\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; }; -})(Entry.Queue.prototype); -Entry.PyHint = function() { - function a(b, a, d) { - b = fuzzy.filter(a, b, d); - return b = b.map(function(b) { - return b.original; - }); - } - CodeMirror.registerHelper("hint", "python", function(c) { - var e = c.getCursor(), f = c.getTokenAt(e); - /^[\w$_]*$/.test(f.string) || (f = {start:e.ch, end:e.ch, string:"", state:f.state, className:":" == f.string ? "python-type" : null}); - var g = [], h = f.string, r; - if ("variable" == f.type) { - r = f.string, null != r && (g = g.concat(a(b, h)), g = g.concat(a(d._global, h, {extract:function(b) { - return b.displayText; - }}))); - } else { - if ("property" == f.type || "variable-2" == f.type || "." == f.state.lastToken) { - r = f.string; - c = c.getLineTokens(e.line); - for (var t = c.shift();"variable" !== t.type && "variable-2" !== t.type;) { - t = c.shift(); - } - c = t.string; - null != r && d[c] && (g = g.concat(a(d[c], h, {extract:function(b) { - return b.displayText; - }}))); - "." == f.state.lastToken && (g = g.concat(d[c])); - } + b.SwitchCase = function(a) { + throw {message:"switch ~ case\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; + }; + b.ThrowStatement = function(a) { + throw {message:"throw\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; + }; + b.TryStatement = function(a) { + throw {message:"try\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; + }; + b.CatchClause = function(a) { + throw {message:"catch\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; + }; + b.WhileStatement = function(a) { + var b = a.body, c = this.syntax.WhileStatement, b = this[b.type](b); + if (c) { + throw {message:"while\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; } - return {list:g.slice(0, 25), from:CodeMirror.Pos(e.line, f.start), to:CodeMirror.Pos(e.line, f.end)}; - }); - var b = "Entry;self;Hw;while True;True;False;break;for i in range;if;if else;len;random.randint".split(";"), d = {_global:[]}, c = Entry.block, e; - for (e in c) { - var f = c[e].syntax; - if (f && f.py) { - f = f.py.join(""); - f = f.split("."); - if (-1 < f[0].indexOf("def ")) { - f = f[0].split(" "); - } else { - if (1 === f.length) { - continue; - } - } - var g = f.shift(); - d[g] || (d[g] = [], d._global.push({displayText:g, text:g})); - var f = f[0].split(","), h = "(" + Array(f.length).join(" , ") + ")", f = f[0].split("(")[0]; - d[g].push({displayText:f, text:f + h}); - "def" == g ? d._global.push({displayText:g + " " + f, text:g + " " + f + h}) : d._global.push({displayText:g + "." + f, text:g + "." + f + h}); + return this.BasicWhile(a, b); + }; + b.DoWhileStatement = function(a) { + throw {message:"do ~ while\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; + }; + b.ForInStatement = function(a) { + throw {message:"for ~ in\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; + }; + 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:a}; } - } -}; -Entry.TextCodingUtil = function() { -}; -(function(a) { - a._funcParamQ; - a.initQueue = function() { - this._funcParamQ = new Entry.Queue; - this._funcNameQ = new Entry.Queue; + return null; }; - a.clearQueue = function() { - this._funcParamQ.clear(); - this._funcNameQ.clear(); + b.VariableDeclaration = function(a) { + throw {message:"var\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; + }; + b.ThisExpression = function(a) { + return this.scope.this; + }; + b.ArrayExpression = function(a) { + throw {message:"array\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; + }; + b.ObjectExpression = function(a) { + throw {message:"object\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; + }; + b.Property = function(a) { + throw {message:"init, get, set\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; + }; + b.FunctionExpression = function(a) { + throw {message:"function\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; + }; + b.UnaryExpression = function(a) { + throw {message:a.operator + "\uc740(\ub294) \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \uba85\ub839\uc5b4 \uc785\ub2c8\ub2e4.", node:a}; + }; + b.UnaryOperator = function() { + return "- + ! ~ typeof void delete".split(" "); }; - a.indent = function(b) { - var a = "\t"; - b = b.split("\n"); - b.pop(); - a += b.join("\n\t"); - return a = "\t" + a.trim(); + b.updateOperator = function() { + return ["++", "--"]; + }; + b.BinaryOperator = function() { + return "== != === !== < <= > >= << >> >>> + - * / % , ^ & in instanceof".split(" "); }; - a.isNumeric = function(b) { - return b.match(/^-?\d+$|^-\d+$/) || b.match(/^-?\d+\.\d+$/) ? !0 : !1; + 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.isBinaryOperator = function(b) { - return "==" == b || ">" == b || "<" == b || ">=" == b || "<=" == b || "+" == b || "-" == b || "*" == b || "/" == b ? !0 : !1; + b.AssignmentOperator = function() { + return "= += -= *= /= %= <<= >>= >>>= ,= ^= &=".split(" "); }; - a.binaryOperatorConvert = function(b) { + b.BinaryExpression = function(a) { + var b = {}, c = {}, b = String(a.operator), e = a.left.name; switch(b) { case "==": - b = "EQUAL"; - break; - case ">": - b = "GREATER"; + var f = "object_up" == e || "object_right" == e || "object_down" == e ? "ai_boolean_object" : "radar_up" == e || "radar_right" == e || "radar_down" == e ? "ai_boolean_distance" : null; break; case "<": - b = "LESS"; - break; - case ">=": - b = "GREATER_OR_EQUAL"; + f = "ai_boolean_distance"; break; case "<=": - b = "LESS_OR_EQUAL"; - break; - case "+": - b = "PLUS"; - break; - case "-": - b = "MINUS"; - break; - case "*": - b = "MULTIFLY"; - break; - case "/": - b = "DIVIDE"; - break; - } - return b; - }; - a.logicalExpressionConvert = function(b) { - switch(b) { - case "&&": - b = null; + f = "ai_boolean_distance"; break; - case "||": - b = null; + case ">": + f = "ai_boolean_distance"; break; + case ">=": + f = "ai_boolean_distance"; } - return b; - }; - a.dropdownDynamicValueConvertor = function(b, a) { - var c = a.options, e; - for (e in c) { - var f = c[e]; - if ("null" == f[1]) { - return c = {}; - } - if ("mouse" == b || "wall" == b || "wall_up" == b || "wall_down" == b || "wall_right" == b || "wall_left" == b) { - return b; + if (f) { + e = []; + b = a.left; + if ("Literal" == b.type || "Identifier" == b.type) { + arguments = []; + arguments.push(b); + var b = Entry.block[f].params, g; + for (g in b) { + var h = b[g].type; + "Indicator" == h ? (h = {raw:null, type:"Literal", value:null}, g < arguments.length && arguments.splice(g, 0, h)) : "Text" == h && (h = {raw:"", type:"Literal", value:""}, g < arguments.length && arguments.splice(g, 0, h)); + } + for (var k in arguments) { + b = arguments[k], h = this[b.type](b), (h = Entry.TextCodingUtil.prototype.radarVariableConvertor(h)) && null != h && e.push(h); + } + } else { + h = this[b.type](b), (h = Entry.TextCodingUtil.prototype.radarVariableConvertor(h)) && e.push(h); } - if (b == f[1]) { - return console.log("dropdownDynamicValueConvertor value", b, f[1]), c = f[0]; + if (b = String(a.operator)) { + (h = b = Entry.TextCodingUtil.prototype.jTobBinaryOperatorConvertor(b)) && e.push(h), c.operator = b; } - } - c = b; - if ("variables" == a.menuName) { - var g = Entry.variableContainer.variables_, h; - for (h in g) { - var k = g[h]; - if (k.id_ == b) { - c = k.name_; - break; + b = a.right; + if ("Literal" == b.type || "Identifier" == b.type) { + arguments = []; + arguments.push(b); + b = Entry.block[f].params; + for (g in b) { + h = b[g].type, "Indicator" == h ? (h = {raw:null, type:"Literal", value:null}, g < arguments.length && arguments.splice(g, 0, h)) : "Text" == h && (h = {raw:"", type:"Literal", value:""}, g < arguments.length && arguments.splice(g, 0, h)); } - } - } else { - if ("lists" == a.menuName) { - for (h in g = Entry.variableContainer.lists, g) { - if (k = g[h], k.id_ == b) { - c = k.name_; - break; + for (k in arguments) { + if (b = arguments[k], h = this[b.type](b), "string" == typeof h && (g = h.split("_"), "radar" == g[0] && (b = {type:"ai_distance_value", params:[]}, b.params.push(g[1].toUpperCase()), h = b)), h && null != h && ("ai_boolean_object" == f && (h = h.params[0], e.splice(1, 1)), h = Entry.TextCodingUtil.prototype.tTobDropdownValueConvertor(h), e.push(h), console.log("rigth param", e), e[2] && "text" != e[2].type && "ai_distance_value" != e[2].type)) { + throw {message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a.test}; } } } else { - if ("pictures" == a.menuName) { - for (g in h = Entry.container.getAllObjects(), h) { - for (k in a = h[g], a = a.pictures, a) { - if (e = a[k], e.id == b) { - return c = e.name; - } - } - } - } else { - if ("sounds" == a.menuName) { - for (g in h = Entry.container.getAllObjects(), h) { - for (k in a = h[g], a = a.sounds, a) { - if (e = a[k], e.id == b) { - return c = e.name; - } - } - } - } - } + h = this[b.type](b), "ai_boolean_object" == f && (h = h.params[0], e.splice(1, 1)), h && e.push(h); } + c.type = f; + c.params = e; + } else { + throw {message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a.test}; } return c; }; - a.binaryOperatorValueConvertor = function(b) { - switch(b) { - case "EQUAL": - b = "=="; - break; - case "GREATER": - b = ">"; - break; - case "LESS": - b = "<"; - break; - case "GREATER_OR_EQUAL": - b = ">="; - break; - case "LESS_OR_EQUAL": - b = "<="; - break; - case "\uadf8\ub9ac\uace0": - b = "&&"; - break; - case "\ub610\ub294": - b = "||"; - break; - case "PLUS": - b = "+"; - break; - case "MINUS": - b = "-"; - break; - case "MULTI": - b = "*"; - break; - case "DIVIDE": - b = "/"; + b.LogicalExpression = function(a) { + var b = {}, c = String(a.operator); + switch(c) { + case "&&": + var e = "ai_boolean_and"; break; + default: + e = "ai_boolean_and"; } - return b; - }; - a.variableFilter = function(b, a, c) { - var e = c; - b = b.data.type; - "change_variable" == b || "set_variable" == b || "get_variable" == b ? 1 == a && (e = eval(c)) : "length_of_list" == b || "is_included_in_list" == b ? 2 == a && (e = eval(c)) : "value_of_index_from_list" == b ? 2 == a ? e = eval(c) : 4 == a && this.isNumeric(c) && (e = c - 1) : "remove_value_from_list" == b ? 2 == a ? e = eval(c) : 1 == a && this.isNumeric(c) && (e = c - 1) : "insert_value_to_list" == b ? 2 == a ? e = eval(c) : 3 == a && this.isNumeric(c) && (e = c - 1) : "change_value_list_index" == - b ? 1 == a ? e = eval(c) : 2 == a && this.isNumeric(c) && (e = c - 1) : "add_value_to_list" == b && 2 == a && (e = eval(c)); - return e; - }; - a.isGlobalVariableExisted = function(b) { - var a = Entry.variableContainer.variables_, c; - for (c in a) { - var e = a[c]; - if (null === e.object_ && e.name_ == b) { - return !0; + var f = [], c = a.left; + if ("Literal" == c.type || "Identifier" == c.type) { + arguments = []; + arguments.push(c); + var c = Entry.block[e].params, g; + for (g in c) { + var h = c[g].type; + "Indicator" == h ? (h = {raw:null, type:"Literal", value:null}, g < arguments.length && arguments.splice(g, 0, h)) : "Text" == h && (h = {raw:"", type:"Literal", value:""}, g < arguments.length && arguments.splice(g, 0, h)); } - } - return !1; - }; - a.updateGlobalVariable = function(b, a) { - var c = Entry.variableContainer.variables_, e; - for (e in c) { - var f = c[e]; - if (null === f.object_ && f.name_ == b) { - variable = {x:f.x_, y:f.y_, id:f.id_, visible:f.visible_, value:a, name:b, isCloud:f.isClud_}; - f.syncModel_(variable); - Entry.variableContainer.updateList(); - break; + for (var k in arguments) { + c = arguments[k], (c = this[c.type](c)) && null != c && f.push(c); } + } else { + (c = this[c.type](c)) && f.push(c); } - }; - a.createGlobalVariable = function(b, a) { - this.isGlobalVariableExisted(b) || (Entry.variableContainer.addVariable({name:b, value:a, variableType:"variable"}), Entry.variableContainer.updateList()); - }; - a.isLocalVariableExisted = function(b, a) { - var c = Entry.variableContainer.variables_, e; - for (e in c) { - var f = c[e]; - if (f.object_ === a.id && f.name_ == b) { - return !0; - } + if (c = String(a.operator)) { + c = Entry.TextCodingUtil.prototype.logicalExpressionConvert(c), f.push(c); } - return !1; - }; - a.updateLocalVariable = function(b, a, c) { - var e = Entry.variableContainer.variables_, f; - for (f in e) { - var g = e[f]; - if (g.object_ === c.id && g.name_ == b) { - g.syncModel_({x:g.x_, y:g.y_, id:g.id_, visible:g.visible_, value:a, name:b, isCloud:g.isClud_}); - Entry.variableContainer.updateList(); - break; + c = a.right; + if ("Literal" == c.type || "Identifier" == c.type) { + arguments = []; + arguments.push(c); + c = Entry.block[e].params; + for (g in c) { + h = c[g].type, "Indicator" == h ? (h = {raw:null, type:"Literal", value:null}, g < arguments.length && arguments.splice(g, 0, h)) : "Text" == h && (h = {raw:"", type:"Literal", value:""}, g < arguments.length && arguments.splice(g, 0, h)); } - } - }; - a.createLocalVariable = function(b, a, c) { - this.isLocalVariableExisted(b, c) || (Entry.variableContainer.addVariable({name:b, value:a, object:c.id, variableType:"variable"}), Entry.variableContainer.updateList()); - }; - a.isLocalVariable = function(b) { - var a = Entry.playground.object, c = Entry.variableContainer.variables_, e; - for (e in c) { - var f = c[e]; - if (f.object_ == a.id && f.id_ == b) { - return !0; + for (k in arguments) { + c = arguments[k], (c = this[c.type](c)) && null != c && f.push(c); } - } - return !1; - }; - a.isGlobalListExisted = function(b) { - var a = Entry.variableContainer.lists_, c; - for (c in a) { - var e = a[c]; - if (null === e.object_ && e.name_ == b) { - return !0; + if ("True" != f[0].type && "ai_boolean_distance" != f[0].type && "ai_boolean_object" != f[0].type && "ai_boolean_and" != f[0].type && "ai_distance_value" != f[0].type) { + throw {message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \uba85\ub801\uc5b4 \uc785\ub2c8\ub2e4.", node:a}; } - } - return !1; - }; - a.updateGlobalList = function(b, a) { - var c = Entry.variableContainer.lists_, e; - for (e in c) { - var f = c[e]; - if (null === f.object_ && f.name_ == b) { - list = {x:f.x_, y:f.y_, id:f.id_, visible:f.visible_, name:b, isCloud:f.isClud_, width:f.width_, height:f.height_, array:a}; - f.syncModel_(list); - f.updateView(); - Entry.variableContainer.updateList(); - break; + if ("True" != f[2].type && "ai_boolean_distance" != f[2].type && "ai_boolean_object" != f[2].type && "ai_boolean_and" != f[2].type && "ai_distance_value" != f[2].type) { + throw {message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \uba85\ub801\uc5b4 \uc785\ub2c8\ub2e4.", node:a}; } + } else { + (c = this[c.type](c)) && f.push(c); } + b.type = e; + b.params = f; + return b; }; - a.createGlobalList = function(b, a) { - this.isGlobalListExisted(b) || (Entry.variableContainer.addList({name:b, array:a, variableType:"list"}), Entry.variableContainer.updateList()); + b.LogicalOperator = function() { + return ["||", "&&"]; }; - a.isLocalListExisted = function(b, a) { - var c = Entry.variableContainer.lists_, e; - for (e in c) { - var f = c[e]; - if (f.object_ === a.id && f.name_ == b) { - return !0; - } + b.MemberExpression = function(a) { + var b = a.object, c = a.property, b = this[b.type](b), c = this[c.type](c, 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}; } - return !1; - }; - a.updateLocalList = function(b, a, c) { - var e = Entry.variableContainer.lists_, f; - for (f in e) { - var g = e[f]; - if (g.object_ === c.id && g.name_ == b) { - g.syncModel_({x:g.x_, y:g.y_, id:g.id_, visible:g.visible_, name:b, isCloud:g.isClud_, width:g.width_, height:g.height_, array:a}); - g.updateView(); - Entry.variableContainer.updateList(); - break; - } + b = c; + if (!b) { + throw {message:c + "\uc774(\uac00) \uc874\uc7ac\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.", node:a}; } + return b; }; - a.createLocalList = function(b, a, c) { - this.isLocalListExisted(b, c) || (Entry.variableContainer.addList({name:b, array:a, object:c.id, variableType:"list"}), Entry.variableContainer.updateList()); + b.ConditionalExpression = function(a) { + throw {message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; }; - a.isLocalList = function(b) { - var a = Entry.playground.object, c = Entry.variableContainer.lists_, e; - for (e in c) { - var f = c[e]; - if (f.object_ == a.id && f.id_ == b) { - return !0; - } - } - return !1; + 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.isLocalType = function(b, a) { - if ("get_variable" == b.data.type || "set_variable" == b.data.type || "change_variable" == b.data.type) { - if (this.isLocalVariable(a)) { - return !0; - } - } else { - if (("value_of_index_from_list" == b.data.type || "add_value_to_list" == b.data.type || "remove_value_from_list" == b.data.type || "insert_value_to_list" == b.data.type || "change_value_list_index" == b.data.type || "length_of_list" == b.data.type || "is_included_in_list" == b.data.type) && this.isLocalList(a)) { - return !0; - } + b.CallExpression = function(a) { + var b = a.callee; + a = a.arguments; + for (var c = [], b = this[b.type](b), b = this.syntax.Scope[b], e = Entry.block[b], f = 0;f < a.length;f++) { + var g = a[f], g = this[g.type](g, b); + "Dropdown" != e.params[f].type && "Block" === e.params[f].type && (g = "string" == typeof g ? {type:"text", params:[g]} : "number" == typeof g ? {type:"number", params:[g]} : g); + c.push(g); } + return {type:b, params:c}; }; - a.isEventBlock = function(b) { - b = b.data.type; - return "when_run_button_click" == b || "when_some_key_pressed" == b || "mouse_clicked" == b || "mouse_click_cancled" == b || "when_object_click" == b || "when_object_click_canceled" == b || "when_message_cast" == b || "when_scene_start" == b || "when_clone_start" == b ? !0 : !1; + b.NewExpression = function(a) { + throw {message:"new\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a}; }; - a.makeDefinition = function(b) { - var a = /(%.)/mi; - b = Entry.block[b.data.type].syntax.py[0].split(a); - for (var c = "", e = 0;e < b.length;e++) { - var f = b[e], c = a.test(f) ? c + "event" : c + f + b.SequenceExpression = function(a) { + throw {message:"SequenceExpression \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; } - return c; + this.scope = new b; + this.scopeChain.push(this.scope); + return this.scanDefinition(a); }; - a.isNoPrintBlock = function(b) { - return !1; + b.unloadScope = function() { + this.scopeChain.pop(); + this.scope = this.scopeChain.length ? this.scopeChain[this.scopeChain.length - 1] : null; }; - a.entryEventFuncFilter = function(b) { - var a = !1; - b = b.split("\n"); - for (var c in b) { - var e = b[c]; - "def entry_event_start():" == e || "def entry_event_mouse_down():" == e || "def entry_event_mouse_up():" == e || "def entry_event_object_down():" == e || "def entry_event_scene_start():" == e || "def entry_event_clone_create():" == e ? (tokens = e.split("def"), e = tokens[1].substring(0, tokens[1].length - 1).trim() + "\n", b[c] = e, a = !0) : (new RegExp(/^def entry_event_key(.+):$/)).test(e) || (new RegExp(/^def entry_event_signal(.+):$/)).test(e) ? (tokens = e.split("def"), e = tokens[1].substring(0, - tokens[1].length - 1).trim() + "\n", b[c] = e, a = !0) : a && (e = b[c], e = e.replace("\t", ""), b[c] = e); + b.scanDefinition = function(a) { + a = a.body; + for (var b = [], c = 0;c < a.length;c++) { + var e = a[c]; + "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.join("\n"); + return b; }; - a.eventBlockSyntaxFilter = function(b) { - return "entry_event_start" == b || "entry_event_key" == b || "entry_event_mouse_down" == b || "entry_event_mouse_up" == b || "entry_event_object_down" == b || "entry_event_signal" == b || "entry_event_scene_start" == b || "entry_event_clone_create" == b ? "def " + b : b; + b.BasicFunction = function(a, b) { + return null; }; - a.isEntryEventFunc = function(b) { - return "def entry_event_start" == b || "def entry_event_key" == b || "def entry_event_mouse_down" == b || "def entry_event_mouse_up" == b || "def entry_event_object_down" == b || "def entry_event_signal" == b || "def entry_event_scene_start" == b || "def entry_event_clone_create" == b ? !0 : !1; + b.BasicIteration = function(a, b, c) { + if (10 < b) { + throw {message:"\ubc18\ubcf5 \uc22b\uc790\uac12\uc774 10\uc744 \ub118\uc73c\uba74 \uc548\ub429\ub2c8\ub2e4.", node:a.test}; + } + 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:[c]}; }; - a.searchFuncDefParam = function(b) { - "function_field_label" == b.data.type && this._funcNameQ.enqueue(b.data.params[0]); - return b && b.data && b.data.params && b.data.params[1] ? ("function_field_string" != b.data.type && "function_field_boolean" != b.data.type || this._funcParamQ.enqueue(b.data.params[0].data.type), this.searchFuncDefParam(b.data.params[1])) : b; + b.BasicWhile = function(a, b) { + var c = a.test.raw; + if (this.syntax.BasicWhile[c]) { + return {type:this.syntax.BasicWhile[c], statements:[b]}; + } + throw {message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a.test}; }; - a.gatherFuncDefParam = function(b) { - if (b && b.data) { - if (b.data.params[0]) { - if (b.data.params[0].data) { - var a = b.data.params[0].data.type; - "function_field_string" != b.data.type && "function_field_boolean" != b.data.type || this._funcParamQ.enqueue(a); + b.BasicIf = function(a) { + var b = {params:[], statements:[]}, c, e = [], f = [], g = [], h = a.consequent; + if (h) { + var k = this[h.type](h) + } + if (h = a.alternate) { + var l = this[h.type](h) + } + try { + var m = a.test.operator ? "===" === a.test.operator ? "==" : a.test.operator : null, n = a.test.left && a.test.right ? a.test.left.name + a.test.right.value : null; + if ("frontwall" == n && "==" == m) { + c = this.syntax.BasicIf["front == 'wall'"]; + } else { + if ("fronthump" == n && "==" == m) { + c = this.syntax.BasicIf["front == 'hump'"]; } else { - "function_field_label" == b.data.type && this._funcNameQ.enqueue(b.data.params[0]); + if ("frontstone" == n && "==" == m) { + c = this.syntax.BasicIf["front == 'stone'"]; + } else { + if ("frontbee" == n && "==" == m) { + c = this.syntax.BasicIf["front == 'bee'"]; + } else { + if (a.test.value || a.test.left && a.test.right) { + c = "ai_if_else"; + var q = this[a.test.type](a.test, this.syntax.Scope); + g.push(q); + } else { + throw {message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a.test}; + } + } + } } } - if (b.data.params[1]) { - var c = this.searchFuncDefParam(b.data.params[1]); - c.data.params[0].data && (a = c.data.params[0].data.type, "function_field_string" != c.data.type && "function_field_boolean" != c.data.type || this._funcParamQ.enqueue(a)); - c.data.params[1] && c.data.params[1].data.params[0].data && (a = c.data.params[1].data.params[0].data.type, "function_field_string" != c.data.params[1].data.type && "function_field_boolean" != c.data.params[1].data.type || this._funcParamQ.enqueue(a)); - } + c ? (k && 0 != k.length && b.statements.push(k), l && 0 != l.length && b.statements.push(l), c && (b.type = c), g && 0 != g.length && (b.params = g)) : (k && 0 != k.length && (e = k), l && 0 != l.length && (f = l), c && (b.type = c), g && 0 != g.length && (b.params = g), b.statements = [e, f]); + return b; + } catch (r) { + throw {message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:a.test}; } - return c; }; - a.getLastParam = function(b) { - b && b.data && b.data.params[1] && (b = this.getLastParam(b.data.params[1])); +})(Entry.JsToBlockParser.prototype); +Entry.PyToBlockParser = function(b) { + this.blockSyntax = b; + this._blockStatmentIndex = 0; + this._blockStatments = []; + this._variableMap = new Entry.Map; + this._funcMap = new Entry.Map; + this._paramQ = new Entry.Queue; +}; +(function(b) { + b.Program = function(a) { + var b = [], c; + for (c in a) { + if ("Program" != a[c].type) { + return; + } + var e = [], f = a[c].body; + console.log("nodes", f); + for (c in f) { + var g = f[c]; + console.log("Program node", g); + g = this[g.type](g); + console.log("result block", g); + g && g.type && e.push(g); + } + console.log("thread", e); + 0 != e.length && b.push(e); + } return b; }; - a.isFuncContentsMatch = function(b, a, c) { - for (var e = !0, f = 0;f < b.length && e;f++) { - var e = !1, g = b[f], h = a[f]; - if (g && !h) { - e = fasle; - break; + b.ExpressionStatement = function(a) { + console.log("ExpressionStatement component", a); + var b = {}; + a = a.expression; + a.type && (a = this[a.type](a), console.log("ExpressionStatement expressionData", a), a.type && a.params ? (b.type = a.type, b.params = a.params, result = b) : a.type ? (b.type = a.type, result = b) : result = a); + console.log("ExpressionStatement result", result); + return result; + }; + b.CallExpression = function(a) { + console.log("CallExpression component", a); + var b = {}, c = [], e, f = a.callee, g = this[f.type](f); + console.log("CallExpression calleeData", g); + arguments = a.arguments; + if ("Identifier" == f.type) { + console.log("CallExpression Identifier calleeData", g), b.callee = g, t = Entry.TextCodingUtil.prototype.eventBlockSyntaxFilter(g.name), e = this.getBlockType(t); + } else { + var h = g.object; + e = g.property; + if (h.statements && "call" == e.name && 0 == e.userCode) { + e = h.statements, console.log("CallExpression statement", e), b.statements = e; + } else { + var k = h.name ? String(h.name).concat(".").concat(String(e.name)) : h.object.name ? String(h.object.name).concat(".").concat(String(h.property.name)).concat(".").concat(String(e.name)) : null } - if (!g && h) { - e = !1; - break; + console.log("CallExpression calleeName", k); + e = this.getBlockType(k); + console.log("CallExpression type before", e); + if (k) { + var l = k.split(".") } - if (h.type == g.data.type) { - var e = !0, k = h.params, l = g.data.params, m = []; - l.map(function(b, a) { - b && m.push(b); - }); - l = m; - if (k.length == l.length) { - for (var e = !0, n = 0;n < k.length && e;n++) { - if (e = !1, k[n].name) { - for (var q in textFuncParams) { - if (k[n].name == textFuncParams[q]) { - for (var r in c) { - if (l[n].data.type == r && c[r] == q) { - e = !0; - break; + console.log("CallExpression calleeTokens", l); + if ("__pythonRuntime.functions.range" == k) { + var m = "%1number#"; + e = this.getBlockType(m); + } else { + if ("__pythonRuntime.ops.add" == k) { + m = "(%1 %2calc_basic# %3)", e = this.getBlockType(m), f = {raw:"PLUS", type:"Literal", value:"PLUS"}, console.log("arguments geniuse", arguments), 2 == arguments.length && arguments.splice(1, 0, f), b.operator = "PLUS"; + } else { + if ("__pythonRuntime.ops.multiply" == k) { + m = "(%1 %2calc_basic# %3)", e = this.getBlockType(m), f = {raw:"MULTI", type:"Literal", value:"MULTI"}, 2 == arguments.length && arguments.splice(1, 0, f), b.operator = "MULTI"; + } else { + if ("__pythonRuntime.ops.in" == k) { + m = "%4 in %2", e = this.getBlockType(m); + } else { + if ("__pythonRuntime.functions.len" == k) { + m = "len", e = this.getBlockType(m); + } else { + if ("Identifier" == f.object.type && "append" == l[1] || "MemberExpression" == f.object.type && "self" == l[0] && "append" == l[2]) { + m = "%2.append", e = this.getBlockType(m); + } else { + if ("Identifier" == f.object.type && "insert" == l[1] || "MemberExpression" == f.object.type && "self" == l[0] && "insert" == l[2]) { + m = "%2.insert", e = this.getBlockType(m); + } else { + if ("Identifier" == f.object.type && "pop" == l[1] || "MemberExpression" == f.object.type && "self" == l[0] && "pop" == l[2]) { + m = "%2.pop", e = this.getBlockType(m); } } - if (e) { - break; - } } } - } else { - "True" == k[n].type || "False" == k[n].type ? k[n].type == l[n].data.type && (e = !0) : k[n].type && k[n].params && k[n].params[0] == l[n].data.params[0] && (e = !0); } } - e && h.statements && 0 != h.statements.length && (e = this.isFuncContentsMatch(g.data.statements[0]._data, h.statements[0])); + } + } + b.callee = k; + } + console.log("CallExpression type after", e); + if (e) { + var n = Entry.block[e], f = n.params, n = n.def.params; + console.log("CallExpression component.arguments", arguments); + console.log("CallExpression paramsMeta", f); + console.log("CallExpression paramsDefMeta", n); + for (var q in f) { + h = f[q].type, "Indicator" == h ? (h = {raw:null, type:"Literal", value:null}, q < arguments.length && arguments.splice(q, 0, h)) : "Text" == h && (h = {raw:"", type:"Literal", value:""}, q < arguments.length && arguments.splice(q, 0, h)); + } + console.log("CallExpression arguments", arguments); + for (var r in arguments) { + if (q = arguments[r]) { + console.log("CallExpression argument", q, "typeof", typeof q), q = this[q.type](q, f[r], n[r], !0), console.log("CallExpression param", q), "__pythonRuntime.functions.range" == k && q.type ? (e = q.type, c = q.params) : c.push(q); + } + } + console.log("CallExpression syntax", m); + console.log("CallExpression argument params", c); + if ("%2.append" == m || "%2.pop" == m) { + if ("self" == l[0]) { + var h = Entry.playground.object, t = l[1]; + if (!Entry.TextCodingUtil.prototype.isLocalListExisted(t, h)) { + return b; + } } else { - e = !1; - break; + if (t = l[0], !Entry.TextCodingUtil.prototype.isGlobalListExisted(t)) { + return b; + } } + console.log("CallExpression append calleeData", g); + r = this.ParamDropdownDynamic(t, f[1], n[1]); + console.log("CallExpression listName", r); + c.push(r); + console.log("CallExpression params[0]", c[0]); + "%2.pop" == m && ("number" == c[0].type ? c[0].params[0] += 1 : "text" == c[0].type && (c[0].params[0] = String(Number(c[0].params[0]) + 1))); } else { - e = !1; - break; + if ("%2.insert" == m) { + if ("self" == l[0]) { + if (h = Entry.playground.object, t = l[1], !Entry.TextCodingUtil.prototype.isLocalListExisted(t, h)) { + return b; + } + } else { + if (t = l[0], !Entry.TextCodingUtil.prototype.isGlobalListExisted(t)) { + return b; + } + } + console.log("CallExpression insert params", c); + c.pop(); + console.log("CallExpression append calleeData", g); + r = this.ParamDropdownDynamic(t, f[1], n[1]); + console.log("CallExpression listName", r); + c.splice(0, 0, r); + console.log("CallExpression check arguments", arguments); + console.log("CallExpression arguments[1] 2", arguments[1]); + q = this[arguments[1].type](arguments[1], f[2], n[2], !0); + console.log("CallExpression check param", q); + c.splice(0, 0, q); + console.log("CallExpression insert params", c); + "number" == c[2].type ? c[2].params[0] += 1 : "text" == c[2].type && (c[2].params[0] = String(Number(c[2].params[0]) + 1)); + } else { + "len" == m ? (r = this.ParamDropdownDynamic(c[1].name, f[1], n[1]), delete c[1], c[1] = r) : "%4 in %2" == m && (q = a.arguments[1], q = this[q.type](q, f[3], n[3], !0), r = a.arguments[3].name, r = this.ParamDropdownDynamic(r, f[1], n[1]), c = [], c.push(""), c.push(r), c.push(""), c.push(q), c.push("")); + } + } + e && (b.type = e); + c && (b.params = c); + } else { + c = []; + for (r in arguments) { + q = arguments[r], console.log("CallExpression argument", q, "typeof", typeof q), f = this[q.type](q), console.log("CallExpression argumentData", f), "__pythonRuntime.utils.createParamsObj" == f.callee ? c = f.arguments : c.push(f); } + console.log("CallExpression args", c); + b.arguments = c; + } + console.log("CallExpression Function Check result", b); + if (b.arguments && b.arguments[0] && "__pythonRuntime.utils.createParamsObj" == b.arguments[0].callee) { + return b; + } + b.callee && (c = b.callee.name + (b.arguments ? b.arguments.length : 0), console.log("funcKey", c), e = this._funcMap.get(c)) && (b = {}, b.type = e); + console.log("CallExpression result", b); + return b; + }; + b.Identifier = function(a, b, c) { + console.log("Identifier component", a, "paramMeta", b, "paramDefMeta", c); + b = {}; + b.name = a.name; + if (!0 === a.userCode || !1 === a.userCode) { + b.userCode = a.userCode; + } + if (c = this.getBlockType("%1")) { + a = a.name; + var e = Entry.block[c], f = e.params, e = e.def.params; + if (!Entry.TextCodingUtil.prototype.isGlobalVariableExisted(a)) { + return b; + } + var g = [], h, k; + for (k in f) { + console.log("Identifiler paramsMeta, paramsDefMeta", f[k], e[k]), "Text" != f[k].type && (h = this["Param" + f[k].type](a, f[k], e[k])); + } + console.log("Identifiler param", h); + h && g.push(h); + b.type = c; + 0 != g.length && (b.params = g); } - return e; + console.log("Identifiler result", b); + return b; }; - a.isParamBlock = function(b) { - b = b.type; - return "ai_boolean_distance" == b || "ai_distance_value" == b || "ai_boolean_object" == b || "ai_boolean_and" == b ? !0 : !1; + b.VariableDeclaration = function(a) { + console.log("VariableDeclaration component", a); + var b = {declarations:[]}, c, e; + a = a.declarations; + for (var f in a) { + var g = a[f], g = this[g.type](g); + console.log("VariableDeclaration declarationData", g); + g && b.declarations.push(g); + g && g.type && (c = g.type); + g && g.params && (e = g.params); + } + c && (b.type = c); + e && (b.params = e); + console.log("VariableDeclaration result", b); + return b; }; - a.hasBlockInfo = function(b, a) { - var c = !1, e; - for (e in a) { - var f = a[e]; - if (e == b.type) { - for (var g in f) { - var h = f[g]; - if (h.start == b.start && h.end == b.end) { - c = !0; - break; - } + b.VariableDeclarator = function(a) { + console.log("VariableDeclarator component", a); + var b = {}, c, e = [], e = a.id, f = a.init; + if ("__params0" != e.name && "__formalsIndex0" != e.name && "__args0" != e.name) { + if (f.callee && "__getParam0" == f.callee.name) { + return b.name = e.name, b; + } + var g; + console.log("VariableDeclarator init", f); + if (f.callee && f.callee.object && f.callee.property) { + if (f.callee.object.object && f.callee.object.object.name) { + var h = f.callee.object.object.name + } + if (f.callee.object.property && f.callee.object.property.name) { + var k = f.callee.object.property.name + } + if (f.callee.property.name) { + var l = f.callee.property.name } + h && k && l && (g = h.concat(".").concat(k).concat(".").concat(l)); } - } - return c; - }; - a.updateBlockInfo = function(b, a) { - var c = a[b.type]; - if (c && Array.isArray(c) && 0 != c.legnth) { - for (var e in c) { - if (a = c[e], a.start == b.start && a.end == b.end) { - break; + if ("__pythonRuntime.objects.list" == g) { + h = this[e.type](e); + console.log("VariableDeclarator idData", h); + b.id = h; + g = this[f.type](f); + console.log("VariableDeclarator initData", g); + b.init = g; + h = e.name; + f = []; + arguments = g.arguments; + for (c in arguments) { + var m = {}; + m.data = String(arguments[c].params[0]); + f.push(m); + } + Entry.TextCodingUtil.prototype.isGlobalListExisted(h) ? Entry.TextCodingUtil.prototype.updateGlobalList(h, f) : Entry.TextCodingUtil.prototype.createGlobalList(h, f); + } else { + h = e.name; + g = "Literal" == f.type ? f.value : "Identifier" == f.type ? f.name : NaN; + console.log("variable name", h, "value", g); + g && NaN != g && (h.includes("__filbert") || (Entry.TextCodingUtil.prototype.isGlobalVariableExisted(h) ? Entry.TextCodingUtil.prototype.updateGlobalVariable(h, g) : Entry.TextCodingUtil.prototype.createGlobalVariable(h, g))); + h = this[e.type](e); + console.log("VariableDeclarator idData", h); + b.id = h; + g = this[f.type](f); + console.log("VariableDeclarator initData", g); + b.init = g; + console.log("VariableDeclarator init.type", f.type); + if ("Literal" == f.type) { + c = e = this.getBlockType("%1 = %2"); } else { - var f = {}; - f.start = b.start; - f.end = b.end; - c.push(f); + if (g.params && g.params[0] && g.params[0].name && h.name == g.params[0].name) { + if (console.log("VariableDeclarator idData.name", h.name, "initData.params[0].name", g.params[0].name), c = e = this.getBlockType("%1 += %2"), "PLUS" != g.operator) { + return b; + } + } else { + c = e = this.getBlockType("%1 = %2"); + } } + k = Entry.block[e]; + e = k.params; + k = k.def.params; + h.name && (m = this.ParamDropdownDynamic(h.name, e[0], k[0])); + e = []; + "Literal" == f.type ? (h.params && h.params[0] ? e.push(h.params[0]) : e.push(m), e.push(g)) : (console.log("VariableDeclarator idData", h, "initData", g), g.params && g.params[0] && h.name == g.params[0].name ? (console.log("in initData.params[0]"), h.params && h.params[0] ? e.push(h.params[0]) : e.push(m), e.push(g.params[2])) : (console.log("in initData"), h.params && h.params[0] ? e.push(h.params[0]) : e.push(m), e.push(g))); + b.type = c; + b.params = e; } - } else { - a[b.type] = [], f = {}, f.start = b.start, f.end = b.end, a[b.type].push(f); - } - }; - a.jsAdjustSyntax = function(b, a) { - if ("ai_boolean_distance" == b.data.type) { - var c = a.split(" "); - b = c[0].split("_"); - b[1] = b[1].substring(1, b[1].length - 1); - b[1] = b[1].toLowerCase(); - b = b.join("_"); - a = c[1]; - a = this.bTojBinaryOperatorConvertor(a); - c = c[2]; - b = b + " " + a + " " + c; - } else { - "ai_boolean_object" == b.data.type ? (c = a.split(" "), b = c[0].split("_"), b[1] = b[1].substring(1, b[1].length - 1), b[1] = b[1].toLowerCase(), b = b.join("_"), a = c[1], c = c[2], b = b + " " + a + " " + c) : "ai_distance_value" == b.data.type ? (c = a.split(" "), b = c[0].split("_"), b[1] = b[1].substring(1, b[1].length - 1), b[1] = b[1].toLowerCase(), b = b.join("_")) : b = a; + console.log("VariableDeclarator result", b); + return b; } - return b; }; - a.bTojBinaryOperatorConvertor = function(b) { - var a; - switch(b) { - case "'BIGGER'": - a = ">"; - break; - case "'BIGGER_EQUAL'": - a = ">="; - break; - case "'EQUAL'": - a = "=="; - break; - case "'SMALLER'": - a = "<"; - break; - case "'SMALLER_EQUAL'": - a = "<="; + b.Literal = function(a, b, c, e) { + console.log("Literal component", a, "paramMeta", b, "paramDefMeta", c, "aflag", e); + e = a.value; + console.log("Literal value", e); + b || (b = {type:"Block"}, c || (c = "number" == typeof e ? {type:"number"} : {type:"text"})); + if ("Indicator" == b.type) { + return null; } - return a; - }; - a.jTobBinaryOperatorConvertor = function(b) { - var a; - switch(b) { - case ">": - a = "BIGGER"; - break; - case ">=": - a = "BIGGER_EQUAL"; - break; - case "==": - a = "EQUAL"; - break; - case "<": - a = "SMALLER"; - break; - case "<=": - a = "SMALLER_EQUAL"; + if ("Text" == b.type) { + return ""; } + console.log("Literal paramMeta", b, "paramDefMeta", c); + null != a.value ? (b = this["Param" + b.type](e, b, c), console.log("Literal param", void 0)) : (b = [], c = this[a.left.type](a.left), b.push(c), b.push(a.operator), a = this[a.right.type](a.right), b.push(a)); + a = b; + console.log("Literal result", a); return a; }; - a.radarVariableConvertor = function(b) { - return b.split("_")[1].toUpperCase(); - }; - a.tTobDropdownValueConvertor = function(b) { - return "stone" == b ? "OBSTACLE" : "wall" == b ? b.toUpperCase() : "item" == b ? b.toUpperCase() : b; - }; -})(Entry.TextCodingUtil.prototype); -Entry.BlockToJsParser = function(a) { - this.syntax = a; - this._iterVariableCount = 0; - this._iterVariableChunk = ["i", "j", "k"]; -}; -(function(a) { - a.Code = function(b, a) { - this._parseMode = a; - if (b instanceof Entry.Block) { - return this.Block(b); - } - a = ""; - b = b._data; - for (var c = 0;c < b.length;c++) { - a += this.Thread(b[c]); - } - return a.trim(); - }; - a.Thread = function(b) { - if (b instanceof Entry.Block) { - return this.Block(b); + b.ParamBlock = function(a, b, c) { + console.log("ParamBlock value", a, "paramMeta", b, "paramDefMeta", c); + b = {}; + var e = a, f = []; + if (!0 === a) { + return b.type = "True", b; } - var a = ""; - b = b.getBlocks(); - for (var c = 0;c < b.length;c++) { - var e = b[c]; - c != b.length - 1 ? (e = this.Block(e), this._parseMode == Entry.Parser.PARSE_GENERAL ? a += e + "\n" : this._parseMode == Entry.Parser.PARSE_SYNTAX && (a = e + "\n")) : (e = this.Block(e), this._parseMode == Entry.Parser.PARSE_GENERAL ? a += e : this._parseMode == Entry.Parser.PARSE_SYNTAX && (a = e)); + if (!1 === a) { + return b.type = "False", b; } - return a + "\n"; - }; - a.Block = function(b) { - var a = b._schema.syntax.js ? b._schema.syntax.js : b._schema.syntax; - return a ? b = this[a[0]](b) : ""; - }; - a.Program = function(b) { - return ""; - }; - a.Scope = function(b) { - var a = !1, c = "", e = /(%.)/mi; - if (b._schema.syntax.js) { - var f = b._schema.syntax.js.concat(), a = !0 + var g = Entry.block[c.type], h = g.params, g = g.def.params; + if (h && 0 != h.length) { + for (var k in h) { + console.log("aaa", h[k], "bbb", g[k]), e = this["Param" + h[k].type](a, h[k], g[k]); + } } else { - f = b._schema.syntax.concat(); + e = a; } - f.shift(); - for (var f = f[0].split(e), g = b._schema.params, h = b.data.params, k = 0;k < f.length;k++) { - var l = f[k]; - 0 !== l.length && "Scope" !== l && ("Judge" === l ? a = !0 : e.test(l) ? (l = l.split("%")[1], l = parseInt(l) - 1, g[l] && "Image" != g[l].type && ("Block" == g[l].type ? (l = this.Block(h[l]), c += l) : c += this[g[l].type](h[l], g[l]))) : c += l); - } - "#" == c.charAt(c.length - 1) && (a = !0, c = c.substring(0, c.length - 1), c = c.trim()); - a || (c += "();"); - return c = Entry.TextCodingUtil.prototype.jsAdjustSyntax(b, c); - }; - a.BasicFunction = function(b) { - b = this.Thread(b.statements[0]); - return "function promise() {\n" + this.indent(b).trim() + "}"; - }; - a.BasicIteration = function(b) { - var a = b.params[0], c = this.publishIterateVariable(); - b = this.Thread(b.statements[0]); - this.unpublishIterateVariable(); - return "for (var " + c + " = 0; " + c + " < " + a + "; " + c + "++) {\n" + this.indent(b) + "}"; + console.log("ParamBlock param", e); + f.push(e); + b.type = c.type; + b.params = f; + console.log("ParamBlock result", b); + return b; }; - a.BasicIf = function(b) { - if (2 == b.data.statements.length) { - var a = this.Thread(b.statements[0]), c = this.Thread(b.statements[1]), e = b._schema.syntax.concat(), e = (b = b.data.params[0]) && "True" == b.data.type ? e[1] : void 0 === b ? e[1] : this.Block(b), a = "if (" + e + ") {\n" + this.indent(a) + "}\nelse {\n" + this.indent(c) + "}\n" - } else { - a = this.Thread(b.statements[0]), e = b._schema.syntax.concat(), e = (b = b.data.params[0]) && "True" == b.data.type ? e[1] : void 0 === b ? e[1] : this.Block(b), a = "if (" + e + ") {\n" + this.indent(a) + "}\n"; - } + b.ParamAngle = function(a, b, c) { + console.log("ParamAngle value, paramMeta, paramDefMeta", a, b, c); return a; }; - a.BasicWhile = function(b) { - var a = this.Thread(b.statements[0]); - return "while (" + b._schema.syntax.concat()[1] + ") {\n" + this.indent(a) + "}\n"; - }; - a.indent = function(b) { - var a = ""; - b = b.split("\n"); - for (var c in b) { - var e = b[c]; - 0 != e.length && (a += "\t" + e + "\n"); - } + b.ParamTextInput = function(a, b, c) { + console.log("ParamTextInput value, paramMeta, paramDefMeta", a, b, c); return a; }; - a.publishIterateVariable = function() { - var b = "", a = this._iterVariableCount; - do { - b = this._iterVariableChunk[a % 3] + b, a = parseInt(a / 3) - 1, 0 === a && (b = this._iterVariableChunk[0] + b); - } while (0 < a); - this._iterVariableCount++; - return b; + b.ParamColor = function(a, b, c) { + console.log("ParamColor value, paramMeta, paramDefMeta", a, b, c); + console.log("ParamColor result", a); + return a; }; - a.unpublishIterateVariable = function() { - this._iterVariableCount && this._iterVariableCount--; + b.ParamDropdown = function(a, b, c) { + console.log("ParamDropdown value, paramMeta, paramDefMeta", a, b, c); + var e; + b = b.options; + console.log("options", b); + for (var f in b) { + if (c = b[f], a == c[1]) { + e = c[1]; + break; + } + } + e && (e = String(e)); + console.log("ParamDropdown result", e); + return e; }; - a.Dropdown = function(b) { - "OBSTACLE" == b ? b = "stone" : "ITEM" == b ? b = b.toLowerCase() : "WALL" == b && (b = b.toLowerCase()); - return "'" + b + "'"; + b.ParamDropdownDynamic = function(a, b, c) { + console.log("ParamDropdownDynamic value, paramMeta, paramDefMeta", a, b, c); + var e; + if ("mouse" == a || "wall" == a || "wall_up" == a || "wall_down" == a || "wall_right" == a || "wall_left" == a) { + return a; + } + b = b.options; + console.log("ParamDropdownDynamic options", b); + for (var f in b) { + if (a == b[f][0]) { + console.log("options[i][0]", b[f][0]); + e = b[f][1]; + break; + } + } + e && (e = String(e)); + console.log("ParamDropdownDynamic result", e); + return e; }; - a.TextInput = function(b) { - return b; + b.ParamKeyboard = function(a, b, c) { + console.log("ParamKeyboard value, paramMeta, paramDefMeta", a, b, c); + a = Entry.KeyboardCode.prototype.keyCharToCode[a]; + console.log("ParamKeyboard result", a); + return a; }; - a.DropdownDynamic = function(b, a) { - return b = "null" == b ? "none" : Entry.TextCodingUtil.prototype.dropdownDynamicValueConvertor(b, a); + b.Indicator = function(a, b, c) { }; -})(Entry.BlockToJsParser.prototype); -Entry.KeyboardCode = function() { -}; -(function(a) { - a.keyCodeToChar = {8:"Backspace", 9:"Tab", 13:"Enter", 16:"Shift", 17:"Ctrl", 18:"Alt", 19:"Pause/Break", 20:"Caps Lock", 27:"Esc", 32:"Space", 33:"Page Up", 34:"Page Down", 35:"End", 36:"Home", 37:"Left", 38:"Up", 39:"Right", 40:"Down", 45:"Insert", 46:"Delete", 48:"0", 49:"1", 50:"2", 51:"3", 52:"4", 53:"5", 54:"6", 55:"7", 56:"8", 57:"9", 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", 91:"Windows", 93:"Right Click", 96:"Numpad 0", 97:"Numpad 1", 98:"Numpad 2", 99:"Numpad 3", 100:"Numpad 4", 101:"Numpad 5", 102:"Numpad 6", 103:"Numpad 7", 104:"Numpad 8", 105:"Numpad 9", 106:"Numpad *", 107:"Numpad +", 109:"Numpad -", 110:"Numpad .", 111:"Numpad /", 112:"F1", 113:"F2", 114:"F3", 115:"F4", 116:"F5", 117:"F6", 118:"F7", 119:"F8", 120:"F9", 121:"F10", 122:"F11", 123:"F12", 144:"Num Lock", 145:"Scroll Lock", 182:"My Computer", 183:"My Calculator", - 186:";", 187:"=", 188:",", 189:"-", 190:".", 191:"/", 192:"`", 219:"[", 220:"\\", 221:"]", 222:"'"}; - a.keyCharToCode = {Backspace:8, Tab:9, Enter:13, Shift:16, Ctrl:17, Alt:18, "Pause/Break":19, "Caps Lock":20, Esc:27, Space:32, "Page Up":33, "Page Down":34, End:35, Home:36, Left:37, Up:38, Right:39, Down:40, Insert:45, Delete:46, 0:48, 1:49, 2:50, 3:51, 4:52, 5:53, 6:54, 7:55, 8:56, 9:57, A:65, B:66, C:67, D:68, E:69, F:70, G:71, H:72, I:73, J:74, K:75, L:76, M:77, N:78, O:79, P:80, Q:81, R:82, S:83, T:84, U:85, V:86, W:87, X:88, Y:89, Z:90, Windows:91, "Right Click":93, "Numpad 0":96, "Numpad 1":97, - "Numpad 2":98, "Numpad 3":99, "Numpad 4":100, "Numpad 5":101, "Numpad 6":102, "Numpad 7":103, "Numpad 8":104, "Numpad 9":105, "Numpad *":106, "Numpad +":107, "Numpad -":109, "Numpad .":110, "Numpad /":111, F1:112, F2:113, F3:114, F4:115, F5:116, F6:117, F7:118, F8:119, F9:120, F10:121, F11:122, F12:123, "Num Lock":144, "Scroll Lock":145, "My Computer":182, "My Calculator":183, ";":186, "=":187, ",":188, "-":189, ".":190, "/":191, "`":192, "[":219, "\\":220, "]":221, "'":222}; -})(Entry.KeyboardCode.prototype); -Entry.BlockToPyParser = function(a) { - this.blockSyntax = a; - this._variableMap = new Entry.Map; - this._funcMap = new Entry.Map; - this._queue = new Entry.Queue; -}; -(function(a) { - a.Code = function(b, a) { - this._parseMode = a; - if (b instanceof Entry.Thread) { - return this.Thread(b); - } - if (b instanceof Entry.Block) { - return this.Block(b); + b.MemberExpression = function(a) { + console.log("MemberExpression component", a); + var b = {}, c, e = a.object, f = a.property; + c = this[e.type](e); + b.object = c; + var g = this[f.type](f); + b.property = g; + console.log("MemberExpression objectData", c); + console.log("MemberExpression propertyData", g); + if ("call" == g.name && 0 == g.userCode) { + return b; } - a = ""; - b = b.getThreads(); - for (var c = 0;c < b.length;c++) { - a += this.Thread(b[c]) + "\n"; + if ("__pythonRuntime.ops.subscriptIndex" == g.callee) { + e = Entry.playground.object; + if (c.object && "self" == c.object.name) { + if (f = c.property.name, !Entry.TextCodingUtil.prototype.isLocalListExisted(f, e)) { + return b; + } + } else { + if (f = c.name, !Entry.TextCodingUtil.prototype.isGlobalListExisted(f)) { + return b; + } + } + c = e = this.getBlockType("%2[%4]"); + var arguments = g.arguments, e = Entry.block[e], h = e.params, k = e.def.params, f = this.ParamDropdownDynamic(f, h[1], k[1]); + console.log("MemberExpression listName", f); + g = []; + g.push(""); + g.push(f); + g.push(""); + "number" == arguments[0].type ? arguments[0].params[0] += 1 : "text" == arguments[0].type && (arguments[0].params[0] = String(Number(arguments[0].params[0]) + 1)); + g.push(arguments[0]); + g.push(""); + b.type = c; + b.params = g; + } else { + if (g = [], "self" == e.name) { + c = e = this.getBlockType("%1"); + e = Entry.block[e]; + h = e.params; + k = e.def.params; + f = f.name; + e = Entry.playground.object; + if (!Entry.TextCodingUtil.prototype.isLocalVariableExisted(f, e)) { + return b; + } + f = this.ParamDropdownDynamic(f, h[0], k[0]); + g.push(f); + b.type = c; + 0 != g.length && (b.params = g); + } else { + return b; + } } - return a = a.trim(); + console.log("MemberExpression result", b); + return b; }; - a.Thread = function(b) { - if (b instanceof Entry.Block) { - return this.Block(b); + b.WhileStatement = function(a) { + console.log("WhileStatement component", a); + var b; + b = {statements:[]}; + var c = a.test; + console.log("WhileStatement test", c); + if (!0 === c.value) { + var e = this.getBlockType("while True:\n$1") } - var a = ""; - b = b.getBlocks(); - for (var c = !1, e = "", f = "", g = 0;g < b.length;g++) { - var h = b[g]; - if (this._parseMode == Entry.Parser.PARSE_GENERAL) { - if (Entry.TextCodingUtil.prototype.isNoPrintBlock(h)) { - continue; - } - 0 == g ? (c = Entry.TextCodingUtil.prototype.isEventBlock(h)) ? e = this.Block(h) + "\n" : f += this.Block(h) + "\n" : 0 != g && (f += this.Block(h) + "\n"); - } else { - this._parseMode == Entry.Parser.PARSE_SYNTAX && (a = (c = Entry.TextCodingUtil.prototype.isEventBlock(h)) ? "" : this.Block(h) + "\n"); + console.log("WhileStatement type", e); + var f = Entry.block[e].params; + console.log("WhileStatement paramsMeta", f); + var g = []; + if ("Literal" == c.type || "Identifier" == c.type) { + arguments = []; + arguments.push(c); + f = Entry.block[e].params; + c = Entry.block[e].def.params; + console.log("WhileStatement paramsMeta", f); + console.log("WhileStatement paramsDefMeta", c); + for (var h in f) { + var k = f[h].type; + "Indicator" == k ? (k = {raw:null, type:"Literal", value:null}, h < arguments.length && arguments.splice(h, 0, k)) : "Text" == k && (k = {raw:"", type:"Literal", value:""}, h < arguments.length && arguments.splice(h, 0, k)); } - this._queue.clear(); - this._variableMap.clear(); + for (var l in arguments) { + h = arguments[l], console.log("WhileStatement argument", h), h = this[h.type](h, f[l], c[l], !0), console.log("WhileStatement Literal param", h), h && null != h && g.push(h); + } + } else { + h = this[c.type](c), console.log("WhileStatement Not Literal param", h), h && null != h && g.push(h); } - this._parseMode == Entry.Parser.PARSE_GENERAL && (a = c ? e + Entry.TextCodingUtil.prototype.indent(f) + "\n" : e + f + "\n"); - return a = a.trim() + "\n"; + f = a.body; + f = this[f.type](f); + console.log("WhileStatement bodyData", f); + "True" == g[0].type && (b.type = e, b.statements.push(f.statements)); + console.log("WhileStatement result", b); + return b; }; - a.Block = function(b) { - var a = "", c; - b._schema && b._schema.syntax && (c = b._schema.syntax.py[0]); - this.isFunc(b) ? (a += this.makeFuncDef(b), this.isRegisteredFunc(b) && (c = this.makeFuncSyntax(b))) : this.isFuncStmtParam(b) && (a += b.data.type); - if (!c || null == c) { - return a; - } - var e = /(%.)/mi, f = /(\$.)/mi; - c = c.split(e); - var g = b._schema.params, h = b.data.params, k = b._schema.skeleton, l = b._schema.paramsKeyMap, m; - if (this._parseMode == Entry.Parser.PARSE_VARIABLE && k == Entry.Parser.BLOCK_SKELETON_BASIC && l) { - var n + b.BlockStatement = function(a) { + console.log("BlockStatement component", a); + var b = {statements:[], data:[]}, c = [], e = [], f = []; + a = a.body; + console.log("BlockStatement bodies", a); + for (var g in a) { + var h = a[g], h = this[h.type](h); + console.log("BlockStatement bodyData", h); + h && null == h || (f.push(h), console.log("BlockStatement data", f)); } - for (var q = 0;q < c.length;q++) { - if (n = c[q], 0 !== n.length) { - if (e.test(n)) { - n = n.split("%")[1]; - var r = Number(n) - 1; - if (g[r] && "Indicator" != g[r].type) { - if ("Block" == g[r].type) { - if (m = this.Block(h[r]).trim(), r = this._funcMap.get(m)) { - a += r; - } else { - var r = m.split("_"), t = r[0]; - 2 == r.length && ("stringParam" == t ? m = "string_param" : "booleanParam" == t && (m = "boolean_param")); - m = Entry.TextCodingUtil.prototype.variableFilter(b, n, m); - a += m; - this._parseMode == Entry.Parser.PARSE_VARIABLE && k == Entry.Parser.BLOCK_SKELETON_BASIC && l && (r = Object.keys(l), n = String(r[n++]), n = n.toLowerCase(), this._variableMap.put(n, m), this._queue.enqueue(n)); - } - } else { - m = this["Field" + g[r].type](h[r], g[r]), null == m && (m = g[r].text ? g[r].text : null), m = Entry.TextCodingUtil.prototype.binaryOperatorValueConvertor(m), m = String(m), Entry.TextCodingUtil.prototype.isNumeric(m) || Entry.TextCodingUtil.prototype.isBinaryOperator(m) || (m = String('"' + m + '"')), m = Entry.TextCodingUtil.prototype.variableFilter(b, n, m), Entry.TextCodingUtil.prototype.isLocalType(b, h[r]) && (m = "self".concat(".").concat(m)), a += m, this._parseMode == Entry.Parser.PARSE_VARIABLE && - k == Entry.Parser.BLOCK_SKELETON_BASIC && l && (r = Object.keys(l), n = String(r[n++]), n = n.toLowerCase(), this._variableMap.put(n, m), this._queue.enqueue(n)); + console.log("BlockStatement final data", f); + b.data = f; + console.log("jhlee data check", f); + for (var k in f) { + if (f[1] && "repeat_basic" == f[1].type) { + if (0 == k) { + if (f[k].declarations) { + a = f[0].declarations; + for (k in a) { + h = a[k], (h = h.init) && c.push(h); } + b.params = c; } } else { - if (f.test(n)) { - for (n = n.split(f), m = 0;m < n.length;m++) { - r = n[m], 0 !== r.length && (f.test(r) ? (r = Number(r.split("$")[1]) - 1, a += Entry.TextCodingUtil.prototype.indent(this.Thread(b.statements[r]))) : a += r); + if (1 == k) { + b.type = f[k].type; + e = []; + a = f[k].statements[0]; + console.log("BlockStatement allStatements", a); + if (a && 0 != a.length) { + for (g in a) { + h = a[g], console.log("BlockStatement(for) statement", h), h.type && e.push(h); + } + } + console.log("BlockStatement(for) statements", e); + b.statements.push(e); + } + } + } else { + if (f) { + if (0 == k) { + if (f[k] && f[k].declarations) { + a = f[k].declarations; + for (k in a) { + h = a[k], (h = h.init) && c.push(h); + } + b.params = c; + } else { + (h = f[k]) && h.type && e.push(h); } } else { - n.search("#"), -1 != n.search("#") && (m = n.indexOf("#"), n = n.substring(m + 1)), a += n; + e = []; + if ((a = f) && 0 != a.length) { + for (g in a) { + h = a[g], console.log("BlockStatement statement", h), h && h.type && e.push(h); + } + } + console.log("BlockStatement statements", e); } + b.statements = e; } } } - this._parseMode == Entry.Parser.PARSE_VARIABLE && k == Entry.Parser.BLOCK_SKELETON_BASIC && l && (b = Object.keys(l).length) && (a = this.makeExpressionWithVariable(a, b)); - return a; - }; - a.FieldAngle = function(b) { - return b; - }; - a.FieldColor = function(b) { - return b; - }; - a.FieldDropdown = function(b) { - return b; - }; - a.FieldDropdownDynamic = function(b, a) { - console.log("FieldDropdownDynamic", b, a); - console.log("FieldDropdownDynamic Object", Entry.playground.object); - return b = "null" == b ? "None" : Entry.TextCodingUtil.prototype.dropdownDynamicValueConvertor(b, a); - }; - a.FieldImage = function(b) { - return b; - }; - a.FieldIndicator = function(b) { - return b; - }; - a.FieldKeyboard = function(b) { - return b; - }; - a.FieldOutput = function(b) { - return b; - }; - a.FieldText = function(b) { - return b; - }; - a.FieldTextInput = function(b) { - return b; - }; - a.FieldNumber = function(b) { - return b; - }; - a.FieldKeyboard = function(b) { - (b = Entry.KeyboardCode.prototype.keyCodeToChar[b]) && null != b || (b = "Q"); + console.log("BlockStatement statement result", b); return b; }; - a.getBlockType = function(b) { - return this.blockSyntax[b]; - }; - a.makeExpressionWithVariable = function(b, a) { - var c = "", e = 0, f = b.indexOf("("); - a = b.substring(0, f).trim().concat("("); - if (this._queue.toString()) { - for (;(variable = this._queue.dequeue()) && !(b = this._variableMap.get(variable), b = variable.concat(" = ").concat(b).concat("\n"), c += b, a = a.concat(variable).concat(",").concat(" "), e++, 10 < e);) { + b.IfStatement = function(a) { + console.log("IfStatement component", a); + var b; + b = {statements:[]}; + var c, e = [], f = a.consequent, g = a.alternate; + c = null != g ? "if_else" : "_if"; + b.type = c; + console.log("IfStatement type", c); + var h = a.test; + console.log("IfStatement test", h); + if ("Literal" == h.type || "Identifier" == h.type) { + arguments = []; + arguments.push(h); + h = Entry.block[c].params; + c = Entry.block[c].def.params; + console.log("IfStatement paramsMeta", h); + console.log("IfStatement paramsDefMeta", c); + for (var k in h) { + var l = h[k].type; + "Indicator" == l ? (l = {raw:null, type:"Literal", value:null}, k < arguments.length && arguments.splice(k, 0, l)) : "Text" == l && (l = {raw:"", type:"Literal", value:""}, k < arguments.length && arguments.splice(k, 0, l)); } - f = a.lastIndexOf(","); - a = a.substring(0, f); - a = a.trim().concat(")"); - a = c.concat(a); - } else { - a = b; - } - return a; - }; - a.isFunc = function(b) { - return "func" == b.data.type.split("_")[0] ? !0 : !1; - }; - a.isRegisteredFunc = function(b) { - b = b.data.type.split("_")[1]; - return Entry.variableContainer.functions_[b] ? !0 : !1; - }; - a.isFuncStmtParam = function(b) { - b = b.data.type.split("_")[0]; - return "stringParam" == b || "booleanParam" == b ? !0 : !1; - }; - a.makeFuncSyntax = function(b) { - var a = b._schema.template.trim(); - b = b._schema.params; - var c = /(%.)/mi, a = a.trim().split(c), e = "", f = "", g; - for (g in a) { - var h = a[g].trim(); - if (c.test(h)) { - var k = h.split("%")[1], k = Number(k) - 1; - "Indicator" != b[k].type && (f += h.concat(", ")); - } else { - h = h.split(" "), e += h.join("__"); + for (var m in arguments) { + k = arguments[m], console.log("IfStatement argument", k), k = this[k.type](k, h[m], c[m], !0), console.log("IfStatement Literal param", k), k && null != k && e.push(k); } - } - k = f.lastIndexOf(","); - f = f.substring(0, k); - return e.trim().concat("(").concat(f.trim()).concat(")"); - }; - a.makeFuncDef = function(b) { - var a = "def ", c = this.getFuncInfo(b); - this.isRegisteredFunc(b) || (c.name = "f"); - if (c.name) { - a += c.name; } else { - return a; + k = this[h.type](h), console.log("IfStatement Not Literal param", k), k && null != k && e.push(k); } - a = a.concat("("); - if (c.params && 0 != c.params.length) { - for (var e in c.params) { - a += c.params[e], a = a.concat(", "); + e && 0 != e.length && (b.params = e); + console.log("IfStatement params result", e); + if (null != f) { + e = []; + console.log("IfStatement consequent", f); + f = this[f.type](f); + console.log("IfStatement consequent data", f); + f = f.data; + console.log("IfStatement consequentsData", f); + for (m in f) { + h = f[m], console.log("IfStatement consData", h), h && (h.init && h.type ? (b.type = h.type, (h = h.statements) && (e = h)) : !h.init && h.type && e.push(h)); } - b = a.lastIndexOf(","); - a = a.substring(0, b); - a = a.trim(); + 0 != e.length && (b.statements[0] = e); } - a = a.concat("):").concat("\n"); - if (c.statements && c.statements.length) { - b = ""; - for (var f in c.statements) { - b += this.Block(c.statements[f]).concat("\n"); + if (null != g) { + f = []; + console.log("IfStatement alternate", g); + g = this[g.type](g); + console.log("IfStatement alternate data", g); + g = g.data; + for (m in g) { + (e = g[m]) && e.type && f.push(e); } - b = b.concat("\n"); - a += Entry.TextCodingUtil.prototype.indent(b).concat("\n"); + 0 != f.length && (b.statements[1] = f); } - this._funcMap.clear(); - return a; + console.log("IfStatement result", b); + return b; }; - a.getFuncInfo = function(b) { - var a = {}; - if (b = b.data.type.split("_")[1]) { - var c = Entry.variableContainer.functions_[b]; - if (!c) { - return a.name = "\ud568\uc218", a; - } - } else { - return a; - } - b = c.block.template; - var e = b.search(/(%.)/); - b = b.substring(0, e).trim().split(" ").join("__"); - Entry.TextCodingUtil.prototype.initQueue(); - Entry.TextCodingUtil.prototype.gatherFuncDefParam(c.content._data[0]._data[0].data.params[0]); - for (var f = [], g = {};m = Entry.TextCodingUtil.prototype._funcParamQ.dequeue();) { - f.push(m); - } - for (var h in f) { - g[f[h]] = h; + b.ForStatement = function(a) { + console.log("ForStatement component", a); + var b = {statements:[]}, c = this.getBlockType("for i in range"); + b.type = c; + if (c = a.init) { + var e = this[c.type](c) } - Entry.TextCodingUtil.prototype.clearQueue(); - if (g) { - var f = {}, k; - for (k in g) { - e = g[k]; - h = k.search("_"); - h = k.substring(0, h); - if ("stringParam" == h) { - var l = "value" + String(e + 1) - } else { - "booleanParam" == h && (l = "boolean" + String(e + 1)); - } - var m = l; - f[e] = m; - this._funcMap.put(k, m); + b.init = e; + console.log("ForStatement init", c); + e = a.body.body; + console.log("ForStatement bodies", e); + if (e) { + for (var f in e) { + 0 != f && (c = e[f], console.log("ForStatement bodyData", c, "index", f), c = this[c.type](c), console.log("ForStatement bodyData result", c, "index", f), b.statements.push(c)); } } - k = c.content._data[0]._data; - l = []; - for (c = 1;c < k.length;c++) { - l.push(k[c]); + console.log("ForStatement bodyData result", b); + if (f = a.test) { + var g = this[f.type](f) } - b && (a.name = b); - 0 != Object.keys(f).length && (a.params = f); - 0 != l.length && (a.statements = l); + b.test = g; + console.log("ForStatement testData", g); + if (a = a.update) { + var h = this[a.type](a) + } + b.update = h; + console.log("ForStatement updateData", h); + console.log("ForStatement result", b); + return b; + }; + b.ForInStatement = function(a) { + console.log("ForInStatement component", a); + console.log("ForInStatement result", null); + return null; + }; + b.BreakStatement = function(a) { + console.log("BreakStatement component", a); + a = {}; + var b = this.getBlockType("break"); + console.log("BreakStatement type", b); + a.type = b; + console.log("BreakStatement result", a); return a; }; -})(Entry.BlockToPyParser.prototype); -Entry.JsToBlockParser = function(a) { - this.syntax = a; - this.scopeChain = []; - this.scope = null; - this._blockCount = 0; - this._blockInfo = {}; -}; -(function(a) { - a.Program = function(b) { - var a = [], c = []; - c.push({type:this.syntax.Program}); - for (var e in b) { - var f = b[e]; - if ("Program" != f.type) { - return; + b.UnaryExpression = function(a) { + console.log("UnaryExpression component", a); + var b; + a.prefix && (b = a.operator, a = a.argument, console.log("UnaryExpression operator", b), a.value = Number(b.concat(a.value)), b = this[a.type](a), console.log("UnaryExpression data", b)); + a = b; + console.log("UnaryExpression result", a); + return a; + }; + b.LogicalExpression = function(a) { + console.log("LogicalExpression component", a); + var b; + b = {}; + var c = String(a.operator); + switch(c) { + case "&&": + var e = "(%1 and %3)"; + break; + case "||": + e = "(%1 or %3)"; + break; + default: + e = "(%1 and %3)"; + } + var e = this.getBlockType(e), f = [], c = a.left; + if ("Literal" == c.type || "Identifier" == c.type) { + arguments = []; + arguments.push(c); + var c = Entry.block[e].params, g = Entry.block[e].def.params; + console.log("LogicalExpression paramsMeta", c); + console.log("LogicalExpression paramsDefMeta", g); + for (var h in c) { + var k = c[h].type; + "Indicator" == k ? (k = {raw:null, type:"Literal", value:null}, h < arguments.length && arguments.splice(h, 0, k)) : "Text" == k && (k = {raw:"", type:"Literal", value:""}, h < arguments.length && arguments.splice(h, 0, k)); } - this.initScope(f); - var f = this.BlockStatement(f), g; - for (g in f) { - c.push(f[g]); + for (var l in arguments) { + var m = arguments[l]; + console.log("LogicalExpression argument", m); + m = this[m.type](m, c[l], g[l], !0); + console.log("LogicalExpression param", m); + m && null != m && f.push(m); } - this.unloadScope(); - 0 != c.length && a.push(c); + } else { + (m = this[c.type](c)) && f.push(m); + } + console.log("LogicalExpression left param", m); + c = String(a.operator); + console.log("LogicalExpression operator", c); + c && (m = c = Entry.TextCodingUtil.prototype.logicalExpressionConvert(c), f.push(m)); + c = a.right; + if ("Literal" == c.type || "Identifier" == c.type) { + arguments = []; + arguments.push(c); + c = Entry.block[e].params; + g = Entry.block[e].def.params; + console.log("LogicalExpression paramsMeta", c); + console.log("LogicalExpression paramsDefMeta", g); + for (h in c) { + k = c[h].type, "Indicator" == k ? (k = {raw:null, type:"Literal", value:null}, h < arguments.length && arguments.splice(h, 0, k)) : "Text" == k && (k = {raw:"", type:"Literal", value:""}, h < arguments.length && arguments.splice(h, 0, k)); + } + for (l in arguments) { + m = arguments[l], console.log("LogicalExpression argument", m), m = this[m.type](m, c[l], g[l], !0), console.log("LogicalExpression param", m), m && null != m && f.push(m); + } + } else { + (m = this[c.type](c)) && f.push(m); } - return a; - }; - a.Identifier = function(b) { - return b.name; - }; - a.Literal = function(b, a) { - return !0 === b.value ? {type:"True"} : !1 === b.value ? {type:"False"} : "ai_distance_value" == a ? b.value : "ai_boolean_object" == a ? b.value : {type:"text", params:[b.value]}; - }; - a.ExpressionStatement = function(b) { - b = b.expression; - return this[b.type](b); + console.log("LogicalExpression right param", m); + b.type = e; + b.params = f; + console.log("LogicalExpression result", b); + return b; }; - a.ForStatement = function(b) { - var a = b.init, c = b.test, e = b.update, f = b.body; - if (this.syntax.ForStatement) { - throw {message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; - } - var f = this[f.type](f), a = a.declarations[0].init.value, g = c.operator, c = c.right.value, h = 0; - "++" != e.operator && (e = a, a = c, c = e); - switch(g) { + b.BinaryExpression = function(a) { + console.log("BinaryExpression component", a); + var b = {}, c = {}, e = String(a.operator); + switch(e) { + case "==": + var f = "(%1 %2boolean_compare# %3)"; + break; + case "!=": + f = "(%2 != True)"; + break; case "<": - h = c - a; + f = "(%1 %2boolean_compare# %3)"; break; case "<=": - h = c + 1 - a; + f = "(%1 %2boolean_compare# %3)"; break; case ">": - h = a - c; + f = "(%1 %2boolean_compare# %3)"; break; case ">=": - h = a + 1 - c; + f = "(%1 %2boolean_compare# %3)"; + break; + case "+": + f = "(%1 %2calc_basic# %3)"; + break; + case "-": + f = "(%1 %2calc_basic# %3)"; + break; + case "*": + f = "(%1 %2calc_basic# %3)"; + break; + case "/": + f = "(%1 %2calc_basic# %3)"; } - return this.BasicIteration(b, h, f); - }; - a.BlockStatement = function(b) { - var a = []; - b = b.body; - for (var c = 0;c < b.length;c++) { - var e = b[c], f = this[e.type](e); - Entry.TextCodingUtil.prototype.hasBlockInfo(e, this._blockInfo) || this._blockCount++; - Entry.TextCodingUtil.prototype.updateBlockInfo(e, this._blockInfo); - if (f) { - if (void 0 === f.type) { - throw {title:"\ube14\ub85d\ubcc0\ud658 \uc624\ub958", message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ube14\ub85d\uc785\ub2c8\ub2e4.", node:e, blockCount:this._blockCount}; + console.log("BinaryExpression operator", e); + console.log("BinaryExpression syntax", f); + if (f = this.getBlockType(f)) { + console.log("BinaryExpression type", f); + b = []; + e = a.left; + console.log("BinaryExpression left", e); + if ("Literal" == e.type || "Identifier" == e.type) { + arguments = []; + arguments.push(e); + var e = Entry.block[f].params, g = Entry.block[f].def.params; + console.log("BinaryExpression paramsMeta", e); + console.log("BinaryExpression paramsDefMeta", g); + for (var h in e) { + var k = e[h].type; + "Indicator" == k ? (k = {raw:null, type:"Literal", value:null}, h < arguments.length && arguments.splice(h, 0, k)) : "Text" == k && (k = {raw:"", type:"Literal", value:""}, h < arguments.length && arguments.splice(h, 0, k)); + } + for (var l in arguments) { + var m = arguments[l]; + console.log("BinaryExpression argument", m); + m = this[m.type](m, e[l], g[l], !0); + console.log("BinaryExpression param", m); + m && null != m && b.push(m); } - Entry.TextCodingUtil.prototype.isParamBlock(f) || f && a.push(f); + } else { + (m = this[e.type](e)) && b.push(m); } + console.log("BinaryExpression left params", b); + if ("boolean_not" == f) { + return b.splice(0, 0, ""), b.splice(2, 0, ""), console.log("BinaryExpression boolean_not params", b), c.type = f, c.params = b, c; + } + if (e = String(a.operator)) { + console.log("BinaryExpression operator", e), (m = e = Entry.TextCodingUtil.prototype.binaryOperatorConvert(e)) && b.push(m), c.operator = e; + } + e = a.right; + if ("Literal" == e.type || "Identifier" == e.type) { + arguments = []; + arguments.push(e); + e = Entry.block[f].params; + g = Entry.block[f].def.params; + console.log("BinaryExpression paramsMeta", e); + console.log("BinaryExpression paramsDefMeta", g); + for (h in e) { + k = e[h].type, "Indicator" == k ? (k = {raw:null, type:"Literal", value:null}, h < arguments.length && arguments.splice(h, 0, k)) : "Text" == k && (k = {raw:"", type:"Literal", value:""}, h < arguments.length && arguments.splice(h, 0, k)); + } + for (l in arguments) { + m = arguments[l], console.log("BinaryExpression argument", m), m = this[m.type](m, e[l], g[l], !0), console.log("BinaryExpression param", m), m && null != m && b.push(m); + } + } else { + (m = this[e.type](e)) && b.push(m); + } + console.log("BinaryExpression right param", m); + c.type = f; + c.params = b; + } else { + return b; } - return a; - }; - a.EmptyStatement = function(b) { - throw {message:"empty\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; - }; - a.DebuggerStatement = function(b) { - throw {message:"debugger\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; - }; - a.WithStatement = function(b) { - throw {message:"with\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; - }; - a.ReturnStaement = function(b) { - throw {message:"return\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; - }; - a.LabeledStatement = function(b) { - throw {message:"label\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; - }; - a.BreakStatement = function(b) { - throw {message:"break\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; - }; - a.ContinueStatement = function(b) { - throw {message:"continue\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; - }; - a.IfStatement = function(b) { - if (this.syntax.BasicIf) { - return this.BasicIf(b); - } - throw {message:"if\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; - }; - a.SwitchStatement = function(b) { - throw {message:"switch\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; - }; - a.SwitchCase = function(b) { - throw {message:"switch ~ case\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; - }; - a.ThrowStatement = function(b) { - throw {message:"throw\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; - }; - a.TryStatement = function(b) { - throw {message:"try\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; - }; - a.CatchClause = function(b) { - throw {message:"catch\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; + console.log("BinaryExpression params", b); + b = c; + console.log("BinaryExpression result", b); + return b; }; - a.WhileStatement = function(b) { - var a = b.body, c = this.syntax.WhileStatement, a = this[a.type](a); + b.UpdateExpression = function(a) { + console.log("UpdateExpression", a); + var b = {}, c = a.argument; if (c) { - throw {message:"while\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; + var e = this[c.type](c) } - return this.BasicWhile(b, a); - }; - a.DoWhileStatement = function(b) { - throw {message:"do ~ while\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; - }; - a.ForInStatement = function(b) { - throw {message:"for ~ in\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; + b.argument = e; + b.operator = a.operator; + b.prefix = a.prefix; + console.log("UpdateExpression result", b); + return b; }; - a.FunctionDeclaration = function(b) { - if (this.syntax.FunctionDeclaration) { - throw {message:"function\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; + b.AssignmentExpression = function(a) { + console.log("AssignmentExpression component", a); + var b = {}, c, e = [], f, g = a.left; + g.type && (f = this[g.type](g), console.log("AssignmentExpression leftData", f)); + console.log("AssignmentExpression leftData", f); + b.left = f; + operator = String(a.operator); + console.log("AssignmentExpression operator", operator); + g = a.right; + if (g.type) { + var h = this[g.type](g); + console.log("AssignmentExpression rightData", h); } - return null; - }; - a.VariableDeclaration = function(b) { - throw {message:"var\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; - }; - a.ThisExpression = function(b) { - 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}; - }; - a.ObjectExpression = function(b) { - throw {message:"object\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; - }; - a.Property = function(b) { - throw {message:"init, get, set\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; - }; - a.FunctionExpression = function(b) { - throw {message:"function\uc740 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; - }; - a.UnaryExpression = function(b) { - throw {message:b.operator + "\uc740(\ub294) \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \uba85\ub839\uc5b4 \uc785\ub2c8\ub2e4.", node:b}; - }; - a.UnaryOperator = function() { - return "- + ! ~ typeof void delete".split(" "); - }; - a.updateOperator = function() { - return ["++", "--"]; - }; - a.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}; - }; - a.AssignmentOperator = function() { - return "= += -= *= /= %= <<= >>= >>>= ,= ^= &=".split(" "); + b.right = h; + switch(operator) { + case "=": + if (h.callee && h.callee.object) { + var k = h.callee.object.object.name.concat(".").concat(h.callee.object.property.name).concat(".").concat(h.callee.property.name) + } + if ("__pythonRuntime.objects.list" == k && "self" == f.object.name) { + var l = f.property.name; + c = []; + var arguments = h.arguments, m; + for (m in arguments) { + var n = {}; + n.data = String(arguments[m].params[0]); + c.push(n); + } + n = Entry.playground.object; + Entry.TextCodingUtil.prototype.isLocalListExisted(l, n) ? Entry.TextCodingUtil.prototype.updateLocalList(l, c, n) : Entry.TextCodingUtil.prototype.createLocalList(l, c, n); + } + if (f.property && "__pythonRuntime.ops.subscriptIndex" == f.property.callee) { + var l = "%1[%2] = %3", q = this.getBlockType(l) + } else { + g.arguments && g.arguments[0] ? (c = a.left.name ? a.left.name : a.left.object.name.concat(a.left.property.name), l = a.right.arguments[0].name ? a.right.arguments[0].name : a.right.arguments[0].object.name.concat(a.right.arguments[0].property.name), console.log("AssignmentExpression leftEx", c, "rightEx", l), l = a.right.arguments && c == l ? "%1 += %2" : "%1 = %2") : l = "%1 = %2", q = this.getBlockType(l); + } + c = q; + } + if (operator) { + var r = Entry.TextCodingUtil.prototype.logicalExpressionConvert(operator) + } + b.operator = r; + console.log("AssignmentExpression syntax", l); + f.object ? n = f.object : f.name && (n = f.name); + if (f.proprty) { + var t = f.property + } else { + f.name && (t = f.name); + } + console.log("AssignmentExpression object property value", n, t); + if ("%1[%2] = %3" == l) { + n = Entry.block[q]; + k = n.params; + r = n.def.params; + t = f.params[1]; + console.log("AssignmentExpression listName", t); + if (!t) { + return b; + } + e.push(t); + f = f.property.arguments[0]; + console.log("AssignmentExpression param 1", f); + console.log("AssignmentExpression param 2", f); + e.push(f); + e.push(h); + } else { + if ("%1 = %2" == l) { + console.log("AssignmentExpression calleeName check", k), n && "self" == n.name && "__pythonRuntime.objects.list" != k ? (n = Entry.block[q], k = n.params, r = n.def.params, l = t.name, (f = "number" == h.type || "text" == h.type ? h.params[0] : NaN) && NaN != f && (n = Entry.playground.object, console.log("final value", f), console.log("final object", n), Entry.TextCodingUtil.prototype.isLocalVariableExisted(l, n) ? Entry.TextCodingUtil.prototype.updateLocalVariable(l, f, n) : Entry.TextCodingUtil.prototype.createLocalVariable(l, + f, n)), l = this.ParamDropdownDynamic(l, k[0], r[0]), e.push(l)) : (n = Entry.block[q], k = n.params, r = n.def.params, console.log("property 123", t), l = t, (f = "number" == h.type || "text" == h.type ? h.params[0] : NaN) && NaN != f && (n = Entry.playground.object, console.log("final object", n), console.log("final value", f), Entry.TextCodingUtil.prototype.isGlobalVariableExisted(l, n) ? Entry.TextCodingUtil.prototype.updateGlobalVariable(l, f, n) : Entry.TextCodingUtil.prototype.createGlobalVariable(l, + f, n)), l = this.ParamDropdownDynamic(l, k[0], r[0]), e.push(l), h.callee && delete h.callee), e.push(h); + } else { + if ("%1 += %2" == l) { + if (n && "self" == n.name) { + if (n = Entry.block[q], k = n.params, r = n.def.params, l = t.name, n = Entry.playground.object, console.log("final object", n), !Entry.TextCodingUtil.prototype.isLocalVariableExisted(l, n)) { + return b; + } + } else { + if (n = Entry.block[q], k = n.params, r = n.def.params, l = t, !Entry.TextCodingUtil.prototype.isGlobalVariableExisted(l)) { + return b; + } + } + l = this.ParamDropdownDynamic(l, k[0], r[0]); + e.push(l); + e.push(h.params[2]); + } + } + } + b.type = c; + b.params = e; + console.log("AssignmentExpression result", b); + return b; }; - a.BinaryExpression = function(b) { - var a, c = {}; - a = String(b.operator); - var e = b.left.name; - switch(a) { - case "==": - var f = "object_up" == e || "object_right" == e || "object_down" == e ? "ai_boolean_object" : "radar_up" == e || "radar_right" == e || "radar_down" == e ? "ai_boolean_distance" : null; - break; - case "<": - f = "ai_boolean_distance"; - break; - case "<=": - f = "ai_boolean_distance"; - break; - case ">": - f = "ai_boolean_distance"; - break; - case ">=": - f = "ai_boolean_distance"; + b.FunctionDeclaration = function(a) { + console.log("FunctionDeclaration component", a); + var b = {}, c = a.body; + a = a.id; + if ("__getParam0" == a.name) { + return b; } - if (f) { - e = []; - a = b.left; - if ("Literal" == a.type || "Identifier" == a.type) { - arguments = []; - arguments.push(a); - a = Entry.block[f].params; - for (var g in a) { - var h = a[g].type; - "Indicator" == h ? (h = {raw:null, type:"Literal", value:null}, g < arguments.length && arguments.splice(g, 0, h)) : "Text" == h && (h = {raw:"", type:"Literal", value:""}, g < arguments.length && arguments.splice(g, 0, h)); + var e = this[c.type](c); + console.log("FunctionDeclaration bodyData", e); + if ("Identifier" == a.type) { + var f = this[a.type](a) + } + console.log("FunctionDeclaration idData", f); + c = []; + a = []; + var f = f.name, e = e.data, g; + for (g in e) { + if (e[g].declarations) { + var h = e[g].declarations; + 0 < h.length && c.push(h[0].name); + } else { + e[g].argument && (h = e[g].argument.statements) && 0 < h.length && (a = h); + } + } + console.log("FunctionDeclaration textFuncName", f); + console.log("FunctionDeclaration textFuncParams", c); + console.log("FunctionDeclaration textFuncStatements", a); + var k, l, m, e = Entry.variableContainer.functions_, n; + for (n in e) { + var q = e[n]; + Entry.TextCodingUtil.prototype.initQueue(); + Entry.TextCodingUtil.prototype.gatherFuncDefParam(q.content._data[0]._data[0].data.params[0]); + console.log("Entry.TextCodingUtil._funcParamQ", Entry.TextCodingUtil.prototype._funcParamQ); + for (var r = [], h = {};g = Entry.TextCodingUtil.prototype._funcParamQ.dequeue();) { + r.push(g), console.log("param", g); + } + console.log("funcParams", r); + for (var t in r) { + h[r[t]] = t; + } + console.log("paramMap", h); + console.log("funcNameQueue", Entry.TextCodingUtil.prototype._funcNameQ); + for (g = [];nameToken = Entry.TextCodingUtil.prototype._funcNameQ.dequeue();) { + g.push(nameToken), console.log("funcNames", nameToken); + } + Entry.TextCodingUtil.prototype.clearQueue(); + blockFuncName = g.join("__").trim(); + console.log("first blockFuncName", blockFuncName); + console.log("first textFuncName", f); + if (f == blockFuncName) { + if (console.log("textFuncName", f), console.log("blockFuncName", blockFuncName), console.log("textFuncParams.length", c.length), console.log("Object.keys(paramMap).length", Object.keys(h).length), c.length == Object.keys(h).length ? (k = !0, console.log("textFuncParams.length", c.length), console.log("Object.keys(paramMap).length", Object.keys(h).length), l = q.content._data[0]._data, g = l.slice(), g.shift(), console.log("blockFuncContents", l), l = Entry.TextCodingUtil.prototype.isFuncContentsMatch(g, + a, h)) : l = k = !1, k && l) { + m = "func".concat("_").concat(n); + break; + } else { + if (k && !l) { + m = n; + break; + } } - for (var k in arguments) { - a = arguments[k], h = this[a.type](a), (h = Entry.TextCodingUtil.prototype.radarVariableConvertor(h)) && null != h && e.push(h); + } + } + console.log("FunctionDeclaration foundFlag", k); + console.log("FunctionDeclaration matchFlag", l); + if (k && l) { + console.log("targetFuncId", m); + var u = c.length; + this._funcMap.put(f + u, m); + console.log("FunctionDeclaration this._funcMap", this._funcMap); + b = m; + } else { + if (k && !l) { + b = Entry.variableContainer.functions_[m]; + n = b.content._data[0]; + n._data.splice(1, n._data.length - 1); + if (0 < a.length) { + for (u in a) { + t = a[u], t = new Entry.Block(t, n), n._data.push(t); + } + } + Entry.variableContainer.saveFunction(b); + Entry.variableContainer.updateList(); + b = m; + console.log("textFuncName", f); + u = c.length; + u = f + u; + n = m; + m = "func".concat("_").concat(n); + this._funcMap.put(u, m); + console.log("FunctionDeclaration result", b); + } else { + console.log("FunctionDeclaration textFuncName", f); + console.log("FunctionDeclaration textFuncParams", c); + console.log("FunctionDeclaration textFuncStatements", a); + k = new Entry.Func; + k.generateBlock(!0); + console.log("FunctionDeclaration newFunc", k); + m = []; + for (g = 1;g <= c.length + 1;g++) { + m.push("%" + g); + } + k.block.template = f + " " + m.join(" "); + console.log("newFunc template", k.block.template); + n = k.content._data[0]; + t = n._data[0].data.params[0]; + m = t.data.params; + k.description = ""; + g = f.split("__"); + if (0 < g.length) { + for (e = 1;e < g.length;e++) { + h = g[e], q = new Entry.Block({type:"function_field_label"}, n), q.data.params = [], q.data.params.push(h), l = Entry.TextCodingUtil.prototype.getLastParam(t), l.data.params[1] = q, k.description += h.concat(" "); + } + k.description += " "; + } else { + m[0] = f, k.description = f + " "; } - } else { - h = this[a.type](a), (h = Entry.TextCodingUtil.prototype.radarVariableConvertor(h)) && e.push(h); - } - if (a = String(b.operator)) { - (h = a = Entry.TextCodingUtil.prototype.jTobBinaryOperatorConvertor(a)) && e.push(h), c.operator = a; - } - a = b.right; - if ("Literal" == a.type || "Identifier" == a.type) { - arguments = []; - arguments.push(a); - a = Entry.block[f].params; - for (g in a) { - h = a[g].type, "Indicator" == h ? (h = {raw:null, type:"Literal", value:null}, g < arguments.length && arguments.splice(g, 0, h)) : "Text" == h && (h = {raw:"", type:"Literal", value:""}, g < arguments.length && arguments.splice(g, 0, h)); + if (0 < c.length) { + for (e = new Entry.Block({type:"function_field_string"}, n), e.data.params = [], h = Entry.Func.requestParamBlock("string"), console.log("FunctionDeclaration stringParam", h), g = new Entry.Block({type:h}, n), e.data.params.push(g), l = Entry.TextCodingUtil.prototype.getLastParam(t), l.data.params[1] = e, k.paramMap[h] = Number(0), console.log("FunctionDeclaration paramBlock", k), t = 1;t < c.length;t++) { + e = new Entry.Block({type:"function_field_string"}, n), e.data.params = [], h = Entry.Func.requestParamBlock("string"), console.log("FunctionDeclaration stringParam", h), g = new Entry.Block({type:h}, n), e.data.params.push(g), l = Entry.TextCodingUtil.prototype.searchFuncDefParam(m[1]), console.log("FunctionDeclaration paramBlock", l), 0 == l.data.params.length ? l.data.params[0] = g : 1 == l.data.params.length && (l.data.params[1] = e), k.paramMap[h] = Number(t), console.log("FunctionDeclaration paramBlock", + k); + } } - for (k in arguments) { - if (a = arguments[k], h = this[a.type](a), "string" == typeof h && (g = h.split("_"), "radar" == g[0] && (a = {type:"ai_distance_value", params:[]}, a.params.push(g[1].toUpperCase()), h = a)), h && null != h && ("ai_boolean_object" == f && (h = h.params[0], e.splice(1, 1)), h = Entry.TextCodingUtil.prototype.tTobDropdownValueConvertor(h), e.push(h), console.log("rigth param", e), e[2] && "text" != e[2].type && "ai_distance_value" != e[2].type)) { - throw {message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b.test}; + if (0 < a.length) { + for (u in a) { + t = a[u], t = new Entry.Block(t, n), n._data.push(t); } } - } else { - h = this[a.type](a), "ai_boolean_object" == f && (h = h.params[0], e.splice(1, 1)), h && e.push(h); + Entry.Func.generateWsBlock(k); + Entry.variableContainer.saveFunction(k); + Entry.variableContainer.updateList(); + u = c.length; + u = f + u; + n = k.id; + m = "func".concat("_").concat(n); + this._funcMap.put(u, m); + console.log("FunctionDeclaration newFunc", k); } - c.type = f; - c.params = e; - } else { - throw {message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b.test}; } - return c; + console.log("FunctionDeclaration result", b); }; - a.LogicalExpression = function(b) { - var a = {}, c = String(b.operator); - switch(c) { - case "&&": - var e = "ai_boolean_and"; - break; - default: - e = "ai_boolean_and"; - } - var f = [], c = b.left; - if ("Literal" == c.type || "Identifier" == c.type) { - arguments = []; - arguments.push(c); - var c = Entry.block[e].params, g; - for (g in c) { - var h = c[g].type; - "Indicator" == h ? (h = {raw:null, type:"Literal", value:null}, g < arguments.length && arguments.splice(g, 0, h)) : "Text" == h && (h = {raw:"", type:"Literal", value:""}, g < arguments.length && arguments.splice(g, 0, h)); - } - for (var k in arguments) { - c = arguments[k], (c = this[c.type](c)) && null != c && f.push(c); - } - } else { - (c = this[c.type](c)) && f.push(c); + b.FunctionExpression = function(a) { + console.log("FunctionExpression component", a); + var b = {}; + a = a.body; + a = this[a.type](a); + console.log("FunctionExpression bodyData", a); + b.statements = a.statements; + console.log("FunctionExpression result", b); + return b; + }; + b.ReturnStatement = function(a) { + console.log("ReturnStatement component", a); + var b = {}; + if (a = a.argument) { + var c = this[a.type](a) } - if (c = String(b.operator)) { - c = Entry.TextCodingUtil.prototype.logicalExpressionConvert(c), f.push(c); + c && (b.argument = c); + console.log("ReturnStaement result", b); + return b; + }; + b.ThisExpression = function(a) { + console.log("ThisExpression component", a); + var b = {}; + if (a = a.userCode) { + b.userCode = a; } - c = b.right; - if ("Literal" == c.type || "Identifier" == c.type) { - arguments = []; - arguments.push(c); - c = Entry.block[e].params; - for (g in c) { - h = c[g].type, "Indicator" == h ? (h = {raw:null, type:"Literal", value:null}, g < arguments.length && arguments.splice(g, 0, h)) : "Text" == h && (h = {raw:"", type:"Literal", value:""}, g < arguments.length && arguments.splice(g, 0, h)); - } - for (k in arguments) { - c = arguments[k], (c = this[c.type](c)) && null != c && f.push(c); - } - if ("True" != f[0].type && "ai_boolean_distance" != f[0].type && "ai_boolean_object" != f[0].type && "ai_boolean_and" != f[0].type && "ai_distance_value" != f[0].type) { - throw {message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \uba85\ub801\uc5b4 \uc785\ub2c8\ub2e4.", node:b}; - } - if ("True" != f[2].type && "ai_boolean_distance" != f[2].type && "ai_boolean_object" != f[2].type && "ai_boolean_and" != f[2].type && "ai_distance_value" != f[2].type) { - throw {message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \uba85\ub801\uc5b4 \uc785\ub2c8\ub2e4.", node:b}; - } - } else { - (c = this[c.type](c)) && f.push(c); + console.log("ThisExpression result", b); + return b; + }; + b.NewExpression = function(a) { + console.log("NewExpression component", a); + var b = {}, c = a.callee, c = this[c.type](c), arguments = a.arguments, e = [], f; + for (f in arguments) { + var g = arguments[f]; + console.log("NewExpression argument", g); + g = this[g.type](g); + e.push(g); } - a.type = e; - a.params = f; + b.callee = c; + b.arguments = e; + console.log("NewExpression result", b); + return b; + }; + b.getBlockType = function(a) { + return this.blockSyntax[a]; + }; + b.RegExp = function(a) { + console.log("RegExp", a); + console.log("RegExp result", a); return a; }; - a.LogicalOperator = function() { - return ["||", "&&"]; + b.Function = function(a) { + console.log("Function component", a); + console.log("Function result", a); + return a; }; - a.MemberExpression = function(b) { - var a = b.object, c = b.property, a = this[a.type](a), c = this[c.type](c, 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 = c; - if (!a) { - throw {message:c + "\uc774(\uac00) \uc874\uc7ac\ud558\uc9c0 \uc54a\uc2b5\ub2c8\ub2e4.", node:b}; - } + b.EmptyStatement = function(a) { + console.log("EmptyStatement component", a); + console.log("EmptyStatement result", a); return a; }; - a.ConditionalExpression = function(b) { - throw {message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; + b.DebuggerStatement = function(a) { + console.log("DebuggerStatement component", a); + console.log("DebuggerStatement result", a); + return 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.WithStatement = function(a) { + console.log("WithStatement component", a); + console.log("WithStatement result", a); + return a; }; - a.CallExpression = function(b) { - var a = b.callee; - b = b.arguments; - for (var c = [], a = this[a.type](a), a = this.syntax.Scope[a], e = Entry.block[a], f = 0;f < b.length;f++) { - var g = b[f], g = this[g.type](g, a); - "Dropdown" != e.params[f].type && "Block" === e.params[f].type && (g = "string" == typeof g ? {type:"text", params:[g]} : "number" == typeof g ? {type:"number", params:[g]} : g); - c.push(g); - } - return {type:a, params:c}; + b.LabeledStatement = function(a) { + console.log("LabeledStatement component", a); + console.log("LabeledStatement result", a); + return a; }; - a.NewExpression = function(b) { - throw {message:"new\ub294 \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; + b.ContinueStatement = function(a) { + console.log("ContinueStatement component", a); + console.log("ContinueStatement result", a); + return a; }; - a.SequenceExpression = function(b) { - throw {message:"SequenceExpression \uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b}; + b.SwitchStatement = function(a) { + console.log("SwitchStatement component", a); + console.log("SwitchStatement result", a); + return a; }; - 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); + b.SwitchCase = function(a) { + console.log("SwitchCase component", a); + console.log("SwitchCase result", a); + return a; }; - a.unloadScope = function() { - this.scopeChain.pop(); - this.scope = this.scopeChain.length ? this.scopeChain[this.scopeChain.length - 1] : null; + b.ThrowStatement = function(a) { + console.log("ThrowStatement component", a); + console.log("ThrowStatement result", a); + return a; }; - a.scanDefinition = function(b) { - b = b.body; - for (var a = [], c = 0;c < b.length;c++) { - var e = b[c]; - "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)]}]))); - } + b.TryStatement = function(a) { + console.log("TryStatement component", a); + console.log("TryStatement result", a); return a; }; - a.BasicFunction = function(b, a) { - return null; + b.CatchClause = function(a) { + console.log("CatchClause component", a); + console.log("CatchClause result", a); + return a; }; - a.BasicIteration = function(b, a, c) { - if (10 < a) { - throw {message:"\ubc18\ubcf5 \uc22b\uc790\uac12\uc774 10\uc744 \ub118\uc73c\uba74 \uc548\ub429\ub2c8\ub2e4.", node:b.test}; - } - 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:[c]}; + b.DoWhileStatement = function(a) { + console.log("DoWhileStatement component", a); + console.log("DoWhileStatement result", a); + return a; }; - a.BasicWhile = function(b, a) { - var c = b.test.raw; - if (this.syntax.BasicWhile[c]) { - return {type:this.syntax.BasicWhile[c], statements:[a]}; - } - throw {message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b.test}; + b.ArrayExpression = function(a) { + console.log("ArrayExpression component", a); + console.log("ArrayExpression result", a); + return a; }; - a.BasicIf = function(b) { - var a = {params:[], statements:[]}, c, e = [], f = [], g = [], h = b.consequent; - if (h) { - var k = this[h.type](h) - } - if (h = b.alternate) { - var l = this[h.type](h) + b.ObjectExpression = function(a) { + console.log("ObjectExpression component", a); + console.log("ObjectExpression result", a); + return a; + }; + b.Property = function(a) { + console.log("Property component", a); + console.log("Property result", a); + return a; + }; + b.ConditionalExpression = function(a) { + console.log("ConditionalExpression component", a); + console.log("ConditionalExpression result", a); + return a; + }; + b.SequenceExpression = function(a) { + console.log("SequenceExpression component", a); + console.log("SequenceExpression result", a); + return a; + }; +})(Entry.PyToBlockParser.prototype); +Entry.Parser = function(b, a, d, c) { + this._mode = b; + this.syntax = {}; + this.codeMirror = d; + this._lang = c || "js"; + this._type = a; + this.availableCode = []; + Entry.Parser.PARSE_GENERAL = 0; + Entry.Parser.PARSE_SYNTAX = 1; + Entry.Parser.PARSE_VARIABLE = 2; + Entry.Parser.BLOCK_SKELETON_BASIC = "basic"; + Entry.Parser.BLOCK_SKELETON_BASIC_LOOP = "basic_loop"; + Entry.Parser.BLOCK_SKELETON_BASIC_DOUBLE_LOOP = "basic_double_loop"; + this._console = new Entry.Console; + switch(this._lang) { + case "js": + this._parser = new Entry.JsToBlockParser(this.syntax); + break; + case "py": + this._parser = new Entry.PyToBlockParser(this.syntax); + c = this.syntax; + var e = {}, f; + for (f in c.Scope) { + e[f + "();\n"] = c.Scope[f]; + } + "BasicIf" in c && (e.front = "BasicIf"); + CodeMirror.commands.javascriptComplete = function(a) { + CodeMirror.showHint(a, null, {globalScope:e}); + }; + d.on("keyup", function(a, b) { + (65 <= b.keyCode && 95 >= b.keyCode || 167 == b.keyCode || 190 == b.keyCode) && CodeMirror.showHint(a, null, {completeSingle:!1, globalScope:e}); + }); + break; + case "blockJs": + this._parser = new Entry.BlockToJsParser(this.syntax); + c = this.syntax; + break; + case "blockPy": + this._parser = new Entry.BlockToPyParser(this.syntax), c = this.syntax; + } +}; +(function(b) { + b.setParser = function(a, b, c) { + this._mode = a; + this._type = b; + this._cm = c; + this.syntax = this.mappingSyntax(a); + switch(b) { + case Entry.Vim.PARSER_TYPE_JS_TO_BLOCK: + this._parser = new Entry.JsToBlockParser(this.syntax); + this._parserType = Entry.Vim.PARSER_TYPE_JS_TO_BLOCK; + break; + case Entry.Vim.PARSER_TYPE_PY_TO_BLOCK: + this._parser = new Entry.PyToBlockParser(this.syntax); + this._parserType = Entry.Vim.PARSER_TYPE_PY_TO_BLOCK; + break; + case Entry.Vim.PARSER_TYPE_BLOCK_TO_JS: + this._parser = new Entry.BlockToJsParser(this.syntax); + a = this.syntax; + var e = {}, f; + for (f in a.Scope) { + e[f + "();\n"] = a.Scope[f]; + } + c.on("keydown", function(a, b) { + var d = b.keyCode; + (65 <= d && 95 >= d || 167 == d || !b.shiftKey && 190 == d) && CodeMirror.showHint(a, null, {completeSingle:!1, globalScope:e}); + }); + this._parserType = Entry.Vim.PARSER_TYPE_JS_TO_BLOCK; + break; + case Entry.Vim.PARSER_TYPE_BLOCK_TO_PY: + this._parser = new Entry.BlockToPyParser(this.syntax), c.setOption("mode", {name:"python", globalVars:!0}), c.markText({line:0, ch:0}, {line:5}, {readOnly:!0}), this._parserType = Entry.Vim.PARSER_TYPE_BLOCK_TO_PY; } - try { - var m = b.test.operator ? "===" === b.test.operator ? "==" : b.test.operator : null, n = b.test.left && b.test.right ? b.test.left.name + b.test.right.value : null; - if ("frontwall" == n && "==" == m) { - c = this.syntax.BasicIf["front == 'wall'"]; - } else { - if ("fronthump" == n && "==" == m) { - c = this.syntax.BasicIf["front == 'hump'"]; - } else { - if ("frontstone" == n && "==" == m) { - c = this.syntax.BasicIf["front == 'stone'"]; - } else { - if ("frontbee" == n && "==" == m) { - c = this.syntax.BasicIf["front == 'bee'"]; + }; + b.parse = function(a, b) { + var c = null; + switch(this._type) { + case Entry.Vim.PARSER_TYPE_JS_TO_BLOCK: + try { + var e = []; + e.push(a); + var f = [], g; + for (g in e) { + var h = e[g], h = h.trim(), k = acorn.parse(h); + f.push(k); + } + c = this._parser.Program(f); + } catch (q) { + if (this.codeMirror) { + q instanceof SyntaxError ? (c = {from:{line:q.loc.line - 1, ch:0}, to:{line:q.loc.line - 1, ch:q.loc.column}}, q.message = "\ubb38\ubc95(Syntax) \uc624\ub958\uc785\ub2c8\ub2e4.", q.type = 1) : (c = this.getLineNumber(q.node.start, q.node.end), c.message = q.message, c.severity = "converting error", q.type = 2); + this.codeMirror.markText(c.from, c.to, {className:"CodeMirror-lint-mark-error", __annotation:c, clearOnEnter:!0}); + c = q.title ? q.title : "\ubb38\ubc95 \uc624\ub958"; + if (2 == q.type && q.message) { + var l = q.message } else { - if (b.test.value || b.test.left && b.test.right) { - c = "ai_if_else"; - var q = this[b.test.type](b.test, this.syntax.Scope); - g.push(q); - } else { - throw {message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b.test}; + 2 != q.type || q.message ? 1 == q.type && (l = "\uc790\ubc14\uc2a4\ud06c\ub9bd\ud2b8 \ubb38\ubc95\uc744 \ud655\uc778\ud574\uc8fc\uc138\uc694.") : l = "\uc790\ubc14\uc2a4\ud06c\ub9bd\ud2b8 \ucf54\ub4dc\ub97c \ud655\uc778\ud574\uc8fc\uc138\uc694."; + } + Entry.toast.alert(c, l); + l = {}; + l.boardType = Entry.Workspace.MODE_BOARD; + l.textType = Entry.Vim.TEXT_TYPE_JS; + l.runType = Entry.Vim.MAZE_MODE; + Ntry.dispatchEvent("textError", l); + throw q; + } + c = []; + } + break; + case Entry.Vim.PARSER_TYPE_PY_TO_BLOCK: + try { + var m = new Entry.PyAstGenerator, e = a.split("\n\n"), n; + for (n in e) { + h = e[n], -1 != h.search("import") ? e[n] = "" : (h = Entry.TextCodingUtil.prototype.entryEventFuncFilter(h), e[n] = h); + } + f = []; + for (g in e) { + h = e[g], k = m.generate(h), "Program" == k.type && 0 != k.body.length && f.push(k); + } + c = this._parser.Program(f); + this._parser._variableMap.clear(); + } catch (q) { + if (this.codeMirror) { + throw q instanceof SyntaxError ? (c = {from:{line:q.loc.line - 1, ch:q.loc.column - 2}, to:{line:q.loc.line - 1, ch:q.loc.column + 1}}, q.message = "\ubb38\ubc95 \uc624\ub958\uc785\ub2c8\ub2e4.") : (c = this.getLineNumber(q.node.start, q.node.end), c.message = q.message, c.severity = "error"), l = parseInt(c.to.line) + 1, c.from.line = l - 1, c.to.line = l, this.codeMirror.markText(c.from, c.to, {className:"CodeMirror-lint-mark-error", __annotation:c, clearOnEnter:!0}), c = q.title ? + q.title : "\ubb38\ubc95 \uc624\ub958", l = q.message && l ? q.message + " (line: " + l + ")" : "\ud30c\uc774\uc36c \ucf54\ub4dc\ub97c \ud655\uc778\ud574\uc8fc\uc138\uc694", Entry.toast.alert(c, l), q; + } + c = []; + } + break; + case Entry.Vim.PARSER_TYPE_BLOCK_TO_JS: + c = l = this._parser.Code(a, b); + break; + case Entry.Vim.PARSER_TYPE_BLOCK_TO_PY: + l = this._parser.Code(a, b), this._pyHinter || (this._pyHinter = new Entry.PyHint), c = l; + } + return c; + }; + b.getLineNumber = function(a, b) { + var c = this.codeMirror.getValue(), e = {from:{}, to:{}}, f = c.substring(0, a).split(/\n/gi); + e.from.line = f.length - 1; + e.from.ch = f[f.length - 1].length; + c = c.substring(0, b).split(/\n/gi); + e.to.line = c.length - 1; + e.to.ch = c[c.length - 1].length; + return e; + }; + b.mappingSyntax = function(a) { + for (var b = Object.keys(Entry.block), c = {}, e = 0;e < b.length;e++) { + var f = b[e], g = Entry.block[f]; + if (a === Entry.Vim.MAZE_MODE) { + if (-1 < this.availableCode.indexOf(f) && (g = g.syntax)) { + for (var h = c, k = 0;k < g.length;k++) { + var l = g[k]; + if (!(-1 < l.indexOf("%"))) { + var m = l.indexOf("("); + -1 < m && (l = l.substring(0, m)); + if (k === g.length - 2 && "function" === typeof g[k + 1]) { + h[l] = g[k + 1]; + break; } + h[l] || (h[l] = {}); + k === g.length - 1 ? h[l] = f : h = h[l]; } } } + } else { + if (a === Entry.Vim.WORKSPACE_MODE) { + for (l in f = Entry.block, f) { + g = f[l], h = null, g.syntax && g.syntax.py && (h = g.syntax.py), h && (h = String(h), g = h.split("("), 0 != g[0].length && (h = g[0]), c[h] = l); + } + } } - c ? (k && 0 != k.length && a.statements.push(k), l && 0 != l.length && a.statements.push(l), c && (a.type = c), g && 0 != g.length && (a.params = g)) : (k && 0 != k.length && (e = k), l && 0 != l.length && (f = l), c && (a.type = c), g && 0 != g.length && (a.params = g), a.statements = [e, f]); - return a; - } catch (r) { - throw {message:"\uc9c0\uc6d0\ud558\uc9c0 \uc54a\ub294 \ud45c\ud604\uc2dd \uc785\ub2c8\ub2e4.", node:b.test}; } + return c; }; -})(Entry.JsToBlockParser.prototype); -Entry.PyToBlockParser = function(a) { - this.blockSyntax = a; + b.setAvailableCode = function(a, b) { + var c = [], e; + a instanceof Entry.Code ? e = a.getBlockList() : a.forEach(function(a, b) { + e.concat(a); + }); + e.forEach(function(a) { + c.push(a.type); + }); + e = []; + b instanceof Entry.Code ? e = b.getBlockList() : b.forEach(function(a, b) { + e.concat(a); + }); + e.forEach(function(a) { + -1 === c.indexOf(a.type) && c.push(a.type); + }); + this.availableCode = this.availableCode.concat(c); + }; + b.findErrorInfo = function(a) { + var b = 0, c = 0, e = this.codeMirror.getValue().split("\n"), f; + for (f in e) { + var g = e[f].trim(); + b++; + if (!(0 == g.length || 1 == g.length || -1 < g.indexOf("else")) && (c++, c == a.blockCount)) { + break; + } + } + return {lineNumber:b - b, location:a.node}; + }; +})(Entry.Parser.prototype); +Entry.PyBlockAssembler = function(b) { + this.blockSyntax = b; this._blockStatmentIndex = 0; this._blockStatments = []; - this._variableMap = new Entry.Map; - this._funcMap = new Entry.Map; - this._paramQ = new Entry.Queue; }; -(function(a) { - a.Program = function(b) { - var a = [], c; - for (c in b) { - if ("Program" != b[c].type) { +(function(b) { + b.Program = function(a) { + var b = [], c; + for (c in a) { + if ("Program" != a[c].type) { return; } - var e = [], f = b[c].body; + var e = [], f = a[c].body; console.log("nodes", f); for (c in f) { - var g = f[c]; - console.log("Program node", g); - g = this[g.type](g); - console.log("result block", g); - g && g.type && e.push(g); + var g = f[c], g = this[g.type](g); + console.log("checkitout", g); + g = this._assembler[g.type](g); + e.push(g); } console.log("thread", e); - 0 != e.length && a.push(e); + b.push(e); } - return a; + return b; }; - a.ExpressionStatement = function(b) { - console.log("ExpressionStatement component", b); - var a = {}; - b = b.expression; - b.type && (b = this[b.type](b), console.log("ExpressionStatement expressionData", b), b.type && b.params ? (a.type = b.type, a.params = b.params, result = a) : b.type ? (a.type = b.type, result = a) : result = b); + b.ExpressionStatement = function(a) { + console.log("ExpressionStatement component", a); + var b = {}; + a = a.expression; + "Literal" == a.type ? (a = this[a.type]({type:"Block", accept:"booleanMagnet"}, a), b.type = a.type, result = b, console.log("ExpressionStatement type literal", result)) : (a = this[a.type](a), b.type = a.type, b.params = a.params, result = b, console.log("ExpressionStatement type not literal", result)); console.log("ExpressionStatement result", result); return result; }; - a.CallExpression = function(b) { - console.log("CallExpression component", b); - var a = {}, c = [], e, f = b.callee, g = this[f.type](f); - console.log("CallExpression calleeData", g); - arguments = b.arguments; - if ("Identifier" == f.type) { - console.log("CallExpression Identifier calleeData", g), a.callee = g, t = Entry.TextCodingUtil.prototype.eventBlockSyntaxFilter(g.name), e = this.getBlockType(t); - } else { - var h = g.object; - e = g.property; - if (h.statements && "call" == e.name && 0 == e.userCode) { - e = h.statements, console.log("CallExpression statement", e), a.statements = e; - } else { - var k = h.name ? String(h.name).concat(".").concat(String(e.name)) : h.object.name ? String(h.object.name).concat(".").concat(String(h.property.name)).concat(".").concat(String(e.name)) : null - } - console.log("CallExpression calleeName", k); - e = this.getBlockType(k); - console.log("CallExpression type before", e); - if (k) { - var l = k.split(".") - } - console.log("CallExpression calleeTokens", l); - if ("__pythonRuntime.functions.range" == k) { - var m = "%1number#"; - e = this.getBlockType(m); - } else { - if ("__pythonRuntime.ops.add" == k) { - m = "(%1 %2calc_basic# %3)", e = this.getBlockType(m), f = {raw:"PLUS", type:"Literal", value:"PLUS"}, console.log("arguments geniuse", arguments), 2 == arguments.length && arguments.splice(1, 0, f), a.operator = "PLUS"; - } else { - if ("__pythonRuntime.ops.multiply" == k) { - m = "(%1 %2calc_basic# %3)", e = this.getBlockType(m), f = {raw:"MULTI", type:"Literal", value:"MULTI"}, 2 == arguments.length && arguments.splice(1, 0, f), a.operator = "MULTI"; - } else { - if ("__pythonRuntime.ops.in" == k) { - m = "%4 in %2", e = this.getBlockType(m); - } else { - if ("__pythonRuntime.functions.len" == k) { - m = "len", e = this.getBlockType(m); - } else { - if ("Identifier" == f.object.type && "append" == l[1] || "MemberExpression" == f.object.type && "self" == l[0] && "append" == l[2]) { - m = "%2.append", e = this.getBlockType(m); - } else { - if ("Identifier" == f.object.type && "insert" == l[1] || "MemberExpression" == f.object.type && "self" == l[0] && "insert" == l[2]) { - m = "%2.insert", e = this.getBlockType(m); - } else { - if ("Identifier" == f.object.type && "pop" == l[1] || "MemberExpression" == f.object.type && "self" == l[0] && "pop" == l[2]) { - m = "%2.pop", e = this.getBlockType(m); - } - } - } - } - } - } - } + b.AssignmentExpression = function(a) { + console.log("AssignmentExpression component", a); + var b = [], c; + c = a.left; + c.type ? ("Literal" == c.type ? (c = this[c.type](paramsMeta[0], c), console.log("AssignmentExpression left Literal param", c)) : c = this[c.type](c), c && b.push(c), console.log("AssignmentExpression left param", c)) : (c = a.left, this[c.type](c)); + operator = String(a.operator); + console.log("AssignmentExpression operator", operator); + operator && (c = operator = Entry.TextCodingUtil.prototype.logicalExpressionConvert(operator), b.push(c)); + c = a.right; + c.type ? ("Literal" == c.type ? (c = this[c.type](paramsMeta[2], c), console.log("AssignmentExpression right Literal param", c)) : c = this[c.type](c), c && b.push(c), console.log("AssignmentExpression right param", c)) : (c = a.right, this[c.type](c)); + console.log("AssignmentExpression params", b); + console.log("AssignmentExpression result", result); + return result; + }; + b.CallExpression = function(a) { + console.log("CallExpression component", a); + var b; + b = {}; + var c = a.callee, c = this[c.type](c); + console.log("CallExpression calleeData", c, "calleeData typeof", typeof c); + var e = "object" != typeof c.object ? String(c.object).concat(".").concat(String(c.property)) : String(c.object.object).concat(".").concat(String(c.object.property)).concat(".").concat(String(c.property)); + console.log("CallExpression syntax", e); + c = this.getBlockType(e); + console.log("CallExpression type1", c); + c || "__pythonRuntime.functions.range" == e && (c = "repeat_basic"); + console.log("CallExpression type2", c); + e = Entry.block[c].params; + console.log("CallExpression paramsMeta", e); + var arguments = a.arguments, f = [], g; + for (g in arguments) { + var h = arguments[g]; + console.log("CallExpression argument", h); + if ("Literal" == h.type) { + var k = e[g]; + "Indicator" == k.type ? (h = null, f.push(h), g--) : (console.log("CallExpression argument index", h.type, g), h = this[h.type](k, h, c, g), f.push(h)); + g == arguments.length - 1 && (console.log("CallExpression in1"), g < e.length && (console.log("CallExpression in2"), f.push(null))); + console.log("CallExpression i", g); } - a.callee = k; } - console.log("CallExpression type after", e); - if (e) { - var n = Entry.block[e], f = n.params, n = n.def.params; - console.log("CallExpression component.arguments", arguments); - console.log("CallExpression paramsMeta", f); - console.log("CallExpression paramsDefMeta", n); - for (var q in f) { - h = f[q].type, "Indicator" == h ? (h = {raw:null, type:"Literal", value:null}, q < arguments.length && arguments.splice(q, 0, h)) : "Text" == h && (h = {raw:"", type:"Literal", value:""}, q < arguments.length && arguments.splice(q, 0, h)); - } - console.log("CallExpression arguments", arguments); - for (var r in arguments) { - if (q = arguments[r]) { - console.log("CallExpression argument", q, "typeof", typeof q), q = this[q.type](q, f[r], n[r], !0), console.log("CallExpression param", q), "__pythonRuntime.functions.range" == k && q.type ? (e = q.type, c = q.params) : c.push(q); - } + console.log("CallExpression params", f); + b.type = c; + b.params = f; + console.log("CallExpression result", b); + return b; + }; + b.Literal = function(a, b, c, e) { + console.log("Literal paramMeta component particularIndex blockType", a, b, c, e); + b = b.value; + a = c ? this["Param" + a.type](a, b, c, e) : this["Param" + a.type](a, b); + console.log("Literal result", a); + return a; + }; + b.ParamColor = function(a, b) { + console.log("ParamColor paramMeta value", a, b); + console.log("ParamColor result", b); + return b; + }; + b.ParamDropdown = function(a, b) { + console.log("ParamDropdown paramMeta value", a, b); + console.log("ParamDropdownDynamic result", b); + return b; + }; + b.ParamDropdownDynamic = function(a, b) { + console.log("ParamDropdownDynamic paramMeta value", a, b); + var c; + if ("mouse" == b) { + return "mouse"; + } + var e = a.options, f; + for (f in e) { + if (console.log("options", e), b == e[f][0]) { + console.log("options[i][0]", e[f][0]); + c = e[f][1]; + break; } - console.log("CallExpression syntax", m); - console.log("CallExpression argument params", c); - if ("%2.append" == m || "%2.pop" == m) { - if ("self" == l[0]) { - var h = Entry.playground.object, t = l[1]; - if (!Entry.TextCodingUtil.prototype.isLocalListExisted(t, h)) { - return a; - } - } else { - if (t = l[0], !Entry.TextCodingUtil.prototype.isGlobalListExisted(t)) { - return a; + } + console.log("ParamDropdownDynamic result", c); + return c; + }; + b.ParamKeyboard = function(a, b) { + console.log("ParamKeyboard paramMeta value", a, b); + var c; + c = Entry.KeyboardCodeMap.prototype.keyCharToCode[b]; + console.log("ParamKeyboard result", c); + return c; + }; + b.ParamBlock = function(a, b, c, e) { + console.log("ParamBlock paramMeta value blockType", a, b, c, e); + var f = {}, g = []; + c = Entry.TextCodingUtil.prototype.particularParam(c); + if (null != c) { + var h = c[e]; + if (h) { + h = c[e]; + console.log("ParamBlock particularType", h); + e = h; + f.type = e; + c = Entry.block[e].params; + console.log("ParamBlock particular block paramsMeta", a); + var k, l; + for (l in c) { + a = c[l]; + a = a.options; + for (var m in a) { + h = a[m], b == h[0] && (k = h[1]); } } - console.log("CallExpression append calleeData", g); - r = this.ParamDropdownDynamic(t, f[1], n[1]); - console.log("CallExpression listName", r); - c.push(r); - console.log("CallExpression params[0]", c[0]); - "%2.pop" == m && ("number" == c[0].type ? c[0].params[0] += 1 : "text" == c[0].type && (c[0].params[0] = String(Number(c[0].params[0]) + 1))); + g.push(k); + f.params = g; } else { - if ("%2.insert" == m) { - if ("self" == l[0]) { - if (h = Entry.playground.object, t = l[1], !Entry.TextCodingUtil.prototype.isLocalListExisted(t, h)) { - return a; - } - } else { - if (t = l[0], !Entry.TextCodingUtil.prototype.isGlobalListExisted(t)) { - return a; - } - } - console.log("CallExpression insert params", c); - c.pop(); - console.log("CallExpression append calleeData", g); - r = this.ParamDropdownDynamic(t, f[1], n[1]); - console.log("CallExpression listName", r); - c.splice(0, 0, r); - console.log("CallExpression check arguments", arguments); - console.log("CallExpression arguments[1] 2", arguments[1]); - q = this[arguments[1].type](arguments[1], f[2], n[2], !0); - console.log("CallExpression check param", q); - c.splice(0, 0, q); - console.log("CallExpression insert params", c); - "number" == c[2].type ? c[2].params[0] += 1 : "text" == c[2].type && (c[2].params[0] = String(Number(c[2].params[0]) + 1)); - } else { - "len" == m ? (r = this.ParamDropdownDynamic(c[1].name, f[1], n[1]), delete c[1], c[1] = r) : "%4 in %2" == m && (q = b.arguments[1], q = this[q.type](q, f[3], n[3], !0), r = b.arguments[3].name, r = this.ParamDropdownDynamic(r, f[1], n[1]), c = [], c.push(""), c.push(r), c.push(""), c.push(q), c.push("")); + switch(e = typeof b, e) { + case "number": + f.type = "number"; + g.push(b); + f.params = g; + break; + case "boolean": + 1 == b ? f.type = "True" : 0 == b && (f.type = "False"); + break; + default: + f.type = "text", g.push(b), f.params = g; } } - e && (a.type = e); - c && (a.params = c); } else { - c = []; - for (r in arguments) { - q = arguments[r], console.log("CallExpression argument", q, "typeof", typeof q), f = this[q.type](q), console.log("CallExpression argumentData", f), "__pythonRuntime.utils.createParamsObj" == f.callee ? c = f.arguments : c.push(f); + switch(e = typeof b, e) { + case "number": + f.type = "number"; + g.push(b); + f.params = g; + break; + case "boolean": + 1 == b ? f.type = "True" : 0 == b && (f.type = "False"); + break; + default: + f.type = "text", g.push(b), f.params = g; + } + } + console.log("ParamBlock valueType", e); + console.log("ParamBlock result", f); + return f; + }; + b.Indicator = function(a, b, c) { + }; + b.MemberExpression = function(a) { + console.log("MemberExpression component", a); + var b = {}, c = a.object; + a = a.property; + c = this[c.type](c); + a = this[a.type](a); + console.log("MemberExpression objectData", c); + console.log("MemberExpression structure", a); + b.object = c; + b.property = a; + console.log("MemberExpression result", b); + return b; + }; + b.Identifier = function(a) { + console.log("Identifiler component", a); + a = a.name; + console.log("Identifiler result", a); + return a; + }; + b.WhileStatement = function(a) { + console.log("WhileStatement component", a); + var b = {}, c = a.test, e; + 1 == c.value && (e = this.getBlockType("while True:\n$1")); + console.log("WhileStatement type", e); + var f = Entry.block[e].params; + console.log("WhileStatement paramsMeta", f); + var g = []; + c && (c.type = "Literal", f = f[0], c = "Indicator" == f.type ? null : this[c.type](f, c), g.push(c)); + c = []; + a = a.body.body; + for (var h in a) { + f = a[h], f = this[f.type](f), c.push(f); + } + b.type = e; + b.params = g; + b.statements = []; + b.statements.push(c); + console.log("WhileStatement result", b); + return b; + }; + b.BlockStatement = function(a) { + console.log("BlockStatement component", a); + this._blockStatmentIndex = 0; + this._blockStatments = []; + var b = {}; + a = a.body; + for (var c in a) { + var e = a[c]; + console.log("BlockStatement body", e, "i", c); + e = this[e.type](e); + console.log("BlockStatement bodyData", e, "i", c); + if (e.declarations) { + console.log("BlockStatement statements type params bodyData", c, e); + var e = e.declarations, f; + for (f in e) { + var g = e[f]; + g.init.type && (b.type = g.init.type); + g.init.params && (console.log("BlockStatement params", g.init.params), b.params = g.init.params); + console.log("BlockStatement structure", b, "j", f); + } + } else { + 0 == this._blockStatmentIndex && this._blockStatments.push(e); } - console.log("CallExpression args", c); - a.arguments = c; - } - console.log("CallExpression Function Check result", a); - if (a.arguments && a.arguments[0] && "__pythonRuntime.utils.createParamsObj" == a.arguments[0].callee) { - return a; } - a.callee && (c = a.callee.name + (a.arguments ? a.arguments.length : 0), console.log("funcKey", c), e = this._funcMap.get(c)) && (a = {}, a.type = e); - console.log("CallExpression result", a); - return a; + b.statements = [this._blockStatments]; + console.log("BlockStatement result", b); + this._blockStatmentIndex++; + return b; }; - a.Identifier = function(b, a, c) { - console.log("Identifier component", b, "paramMeta", a, "paramDefMeta", c); - a = {}; - a.name = b.name; - if (!0 === b.userCode || !1 === b.userCode) { - a.userCode = b.userCode; + b.IfStatement = function(a) { + console.log("IfStatement component", a); + var b = {}, c = [], e = [], f = [], g = [], h = a.test, k = a.alternate, l = a.consequent; + a = this.getBlockType(null == k ? "if %1:\n$1" : "if %1:\n$1\nelse:\n$2"); + if (null != h) { + var m = Entry.block[a].params; + console.log("IfStatement paramsMeta", m); + c = []; + h.type = "Literal"; + m = m[0]; + h = "Indicator" == m.type ? null : this[h.type](m, h); + c.push(h); } - if (c = this.getBlockType("%1")) { - b = b.name; - var e = Entry.block[c], f = e.params, e = e.def.params; - if (!Entry.TextCodingUtil.prototype.isGlobalVariableExisted(b)) { - return a; + if (null != l) { + for (var n in l.body) { + if (h = l.body[n]) { + h = this[h.type](h), console.log("IfStatement consequent bodyData", h), e.push(h); + } } - var g = [], h, k; - for (k in f) { - console.log("Identifiler paramsMeta, paramsDefMeta", f[k], e[k]), "Text" != f[k].type && (h = this["Param" + f[k].type](b, f[k], e[k])); + } + if (null != k) { + for (n in k.body) { + if (h = k.body[n]) { + h = this[h.type](h), console.log("IfStatement alternate bodyData", h), f.push(h); + } } - console.log("Identifiler param", h); - h && g.push(h); - a.type = c; - 0 != g.length && (a.params = g); } - console.log("Identifiler result", a); - return a; + 0 != e.length && g.push(e); + 0 != f.length && g.push(f); + b.type = a; + 0 != c.length && (b.params = c); + 0 != g.length && (b.statements = g); + console.log("IfStatement result", b); + return b; }; - a.VariableDeclaration = function(b) { - console.log("VariableDeclaration component", b); - var a = {declarations:[]}, c, e; - b = b.declarations; - for (var f in b) { - var g = b[f], g = this[g.type](g); - console.log("VariableDeclaration declarationData", g); - g && a.declarations.push(g); - g && g.type && (c = g.type); - g && g.params && (e = g.params); + b.VariableDeclaration = function(a) { + console.log("VariableDeclaration component", a); + var b = {}, c = []; + a = a.declarations; + for (var e in a) { + var f = a[e], f = this[f.type](f); + console.log("VariableDeclaration declarationData", f); + c.push(f); } - c && (a.type = c); - e && (a.params = e); - console.log("VariableDeclaration result", a); + b.declarations = c; + console.log("VariableDeclaration result", b); + return b; + }; + b.VariableDeclarator = function(a) { + console.log("VariableDeclarator component", a); + var b = {}, c = a.id, e = this[c.type](c); + console.log("VariableDeclarator idData", e); + a = a.init; + a = this[a.type](a); + console.log("VariableDeclarator initData", a); + b.id = c; + b.init = a; + console.log("VariableDeclarator result", b); + return b; + }; + b.BreakStatement = function(a) { + console.log("BreakStatement component", a); + a = {}; + var b = this.getBlockType("break"); + a.type = b; + console.log("BreakStatement result", a); return a; }; - a.VariableDeclarator = function(b) { - console.log("VariableDeclarator component", b); - var a = {}, c, e; - e = b.id; - var f = b.init; - if ("__params0" != e.name && "__formalsIndex0" != e.name && "__args0" != e.name) { - if (f.callee && "__getParam0" == f.callee.name) { - return a.name = e.name, a; - } - var g; - console.log("VariableDeclarator init", f); - if (f.callee && f.callee.object && f.callee.property) { - if (f.callee.object.object && f.callee.object.object.name) { - var h = f.callee.object.object.name - } - if (f.callee.object.property && f.callee.object.property.name) { - var k = f.callee.object.property.name - } - if (f.callee.property.name) { - var l = f.callee.property.name - } - h && k && l && (g = h.concat(".").concat(k).concat(".").concat(l)); - } - if ("__pythonRuntime.objects.list" == g) { - h = this[e.type](e); - console.log("VariableDeclarator idData", h); - a.id = h; - g = this[f.type](f); - console.log("VariableDeclarator initData", g); - a.init = g; - h = e.name; - f = []; - arguments = g.arguments; - for (c in arguments) { - var m = {}; - m.data = String(arguments[c].params[0]); - f.push(m); - } - Entry.TextCodingUtil.prototype.isGlobalListExisted(h) ? Entry.TextCodingUtil.prototype.updateGlobalList(h, f) : Entry.TextCodingUtil.prototype.createGlobalList(h, f); - } else { - h = e.name; - g = "Literal" == f.type ? f.value : "Identifier" == f.type ? f.name : NaN; - console.log("variable name", h, "value", g); - g && NaN != g && (h.includes("__filbert") || (Entry.TextCodingUtil.prototype.isGlobalVariableExisted(h) ? Entry.TextCodingUtil.prototype.updateGlobalVariable(h, g) : Entry.TextCodingUtil.prototype.createGlobalVariable(h, g))); - h = this[e.type](e); - console.log("VariableDeclarator idData", h); - a.id = h; - g = this[f.type](f); - console.log("VariableDeclarator initData", g); - a.init = g; - console.log("VariableDeclarator init.type", f.type); - if ("Literal" == f.type) { - c = e = this.getBlockType("%1 = %2"); - } else { - if (g.params && g.params[0] && g.params[0].name && h.name == g.params[0].name) { - if (console.log("VariableDeclarator idData.name", h.name, "initData.params[0].name", g.params[0].name), c = e = this.getBlockType("%1 += %2"), "PLUS" != g.operator) { - return a; - } - } else { - c = e = this.getBlockType("%1 = %2"); - } - } - k = Entry.block[e]; - e = k.params; - k = k.def.params; - h.name && (m = this.ParamDropdownDynamic(h.name, e[0], k[0])); - e = []; - "Literal" == f.type ? (h.params && h.params[0] ? e.push(h.params[0]) : e.push(m), e.push(g)) : (console.log("VariableDeclarator idData", h, "initData", g), g.params && g.params[0] && h.name == g.params[0].name ? (console.log("in initData.params[0]"), h.params && h.params[0] ? e.push(h.params[0]) : e.push(m), e.push(g.params[2])) : (console.log("in initData"), h.params && h.params[0] ? e.push(h.params[0]) : e.push(m), e.push(g))); - a.type = c; - a.params = e; - } - console.log("VariableDeclarator result", a); - return a; - } + b.UnaryExpression = function(a) { + console.log("UnaryExpression component", a); + var b = []; + a.prefix && (a = a.operator.concat(a.argument.value), b.push(a)); + result.params = b; + console.log("UnaryExpression result", result); + return result; }; - a.Literal = function(b, a, c, e) { - console.log("Literal component", b, "paramMeta", a, "paramDefMeta", c, "aflag", e); - e = b.value; - console.log("Literal value", e); - a || (a = {type:"Block"}, c || (c = "number" == typeof e ? {type:"number"} : {type:"text"})); - if ("Indicator" == a.type) { - return null; - } - if ("Text" == a.type) { - return ""; + b.LogicalExpression = function(a) { + console.log("LogicalExpression component", a); + var b = {}, c = String(a.operator); + switch(c) { + case "&&": + var e = "%1 and %3"; + break; + case "||": + e = "%1 or %3"; + break; + default: + e = "%1 and %3"; } - console.log("Literal paramMeta", a, "paramDefMeta", c); - null != b.value ? (a = this["Param" + a.type](e, a, c), console.log("Literal param", void 0)) : (a = [], c = this[b.left.type](b.left), a.push(c), a.push(b.operator), b = this[b.right.type](b.right), a.push(b)); - b = a; - console.log("Literal result", b); + var e = this.getBlockType(e), f = Entry.block[e].params; + console.log("LogicalExpression paramsMeta", f); + var g = [], c = a.left; + c.type ? ("Literal" == c.type ? (c = this[c.type](f[0], c), console.log("LogicalExpression left Literal param", c)) : c = this[c.type](c), c && g.push(c), console.log("LogicalExpression left param", c)) : (c = a.left, this[c.type](c)); + c = String(a.operator); + console.log("LogicalExpression operator", c); + c && (c = Entry.TextCodingUtil.prototype.logicalExpressionConvert(c), g.push(c)); + c = a.right; + c.type ? ("Literal" == c.type ? (c = this[c.type](f[2], c), console.log("LogicalExpression right Literal param", c)) : c = this[c.type](c), c && g.push(c), console.log("LogicalExpression right param", c)) : (c = a.right, this[c.type](c)); + b.type = e; + b.params = g; + console.log("LogicalExpression result", b); return b; }; - a.ParamBlock = function(b, a, c) { - console.log("ParamBlock value", b, "paramMeta", a, "paramDefMeta", c); - a = {}; - var e = b, f = []; - if (!0 === b) { - return a.type = "True", a; + b.BinaryExpression = function(a) { + console.log("BinaryExpression component", a); + var b = {params:[]}, c = String(a.operator); + console.log("BinaryExpression operator", c); + if (c) { + var e = "(%1 %2 %3)" } - if (!1 === b) { - return a.type = "False", a; + console.log("BinaryExpression syntax", e); + e = this.getBlockType(e); + console.log("BinaryExpression type", e); + var f = Entry.block[e].params; + console.log("BinaryExpression paramsMeta", f); + var g = [], c = a.left; + c.type ? ("Literal" == c.type ? (c = this[c.type](f[0], c), console.log("BinaryExpression left Literal param", c)) : c = this[c.type](c), c && g.push(c), console.log("BinaryExpression left param", c)) : (c = a.left, this[c.type](c)); + if (c = String(a.operator)) { + console.log("BinaryExpression operator", c), (c = Entry.TextCodingUtil.prototype.binaryOperatorConvert(c)) && g.push(c); } - var g = Entry.block[c.type], h = g.params, g = g.def.params; - if (h && 0 != h.length) { - for (var k in h) { - console.log("aaa", h[k], "bbb", g[k]), e = this["Param" + h[k].type](b, h[k], g[k]); + c = a.right; + c.type ? ("Literal" == c.type ? (c = this[c.type](f[2], c), console.log("BinaryExpression right Literal param", c)) : c = this[c.type](c), c && g.push(c), console.log("BinaryExpression right param", c)) : (c = a.right, this[c.type](c)); + console.log("BinaryExpression params", g); + b.type = e; + b.params = g; + console.log("BinaryExpression result", b); + return b; + }; + b.getBlockType = function(a) { + return this.blockSyntax[a]; + }; + b.FunctionDeclaration = function(a) { + console.log("FunctionDeclaration component", a); + console.log("FunctionDeclaration result", void 0); + return a; + }; + b.RegExp = function(a) { + console.log("RegExp", a); + console.log("RegExp result", void 0); + return a; + }; + b.Function = function(a) { + console.log("Function", a); + console.log("Function result", void 0); + return a; + }; + b.EmptyStatement = function(a) { + console.log("EmptyStatement", a); + console.log("EmptyStatement result", void 0); + return a; + }; + b.DebuggerStatement = function(a) { + console.log("DebuggerStatement", a); + console.log("DebuggerStatement result", void 0); + return a; + }; + b.WithStatement = function(a) { + console.log("WithStatement", a); + console.log("WithStatement result", void 0); + return a; + }; + b.ReturnStaement = function(a) { + console.log("ReturnStaement", a); + console.log("ReturnStaement result", void 0); + return a; + }; + b.LabeledStatement = function(a) { + console.log("LabeledStatement", a); + console.log("LabeledStatement result", void 0); + return a; + }; + b.BreakStatement = function(a) { + console.log("BreakStatement", a); + console.log("BreakStatement result", void 0); + return a; + }; + b.ContinueStatement = function(a) { + console.log("ContinueStatement", a); + console.log("ContinueStatement result", void 0); + return a; + }; + b.SwitchStatement = function(a) { + console.log("SwitchStatement", a); + console.log("SwitchStatement result", void 0); + return a; + }; + b.SwitchCase = function(a) { + console.log("SwitchCase", a); + console.log("SwitchCase result", void 0); + return a; + }; + b.ThrowStatement = function(a) { + console.log("ThrowStatement", a); + console.log("ThrowStatement result", void 0); + return a; + }; + b.TryStatement = function(a) { + console.log("TryStatement", a); + console.log("TryStatement result", void 0); + return a; + }; + b.CatchClause = function(a) { + console.log("CatchClause", a); + console.log("CatchClause result", void 0); + return a; + }; + b.DoWhileStatement = function(a) { + console.log("DoWhileStatement", a); + console.log("DoWhileStatement result", void 0); + return a; + }; + b.ForInStatement = function(a) { + console.log("ForInStatement", a); + console.log("ForInStatement result", void 0); + return a; + }; + b.FunctionDeclaration = function(a) { + console.log("FunctionDeclaration", a); + console.log("FunctionDeclaration result", void 0); + return a; + }; + b.ThisExpression = function(a) { + console.log("ThisExpression", a); + console.log("ThisExpression result", void 0); + return a; + }; + b.ArrayExpression = function(a) { + console.log("ArrayExpression", a); + console.log("ArrayExpression result", void 0); + return a; + }; + b.ObjectExpression = function(a) { + console.log("ObjectExpression", a); + console.log("ObjectExpression result", void 0); + return a; + }; + b.Property = function(a) { + console.log("Property", a); + console.log("Property result", void 0); + return a; + }; + b.FunctionExpression = function(a) { + console.log("FunctionExpression", a); + console.log("FunctionExpression result", void 0); + return a; + }; + b.UpdateExpression = function(a) { + console.log("UpdateExpression", a); + console.log("UpdateExpression result", void 0); + return a; + }; + b.ConditionalExpression = function(a) { + console.log("ConditionalExpression", a); + console.log("ConditionalExpression result", void 0); + return a; + }; + b.NewExpression = function(a) { + console.log("NewExpression", a); + console.log("NewExpression result", void 0); + return a; + }; + b.SequenceExpression = function(a) { + console.log("SequenceExpression", a); + console.log("SequenceExpression result", void 0); + return a; + }; +})(Entry.PyBlockAssembler.prototype); +Entry.PyToBlockParserTemp = function(b) { + this._assembler = new Entry.PyBlockAssembler(b); +}; +(function(b) { + b.Program = function(a) { + var b = [], c; + for (c in a) { + if ("Program" != a[c].type) { + return; } - } else { - e = b; + var e = [], f = a[c].body; + console.log("nodes", f); + for (c in f) { + var g = f[c], g = this[g.type](g); + console.log("checkitout", g); + g = this._assembler[g.type](g); + e.push(g); + } + console.log("thread", e); + b.push(e); + } + return b; + }; + b.Identifier = function(a) { + console.log("Identifier", a); + return {type:a.type, name:a.name}; + }; + b.FunctionDeclaration = function(a) { + console.log("FunctionDeclaration", a); + var b = this[a.id.type](a.id); + return {type:a.type, id:b}; + }; + b.Literal = function(a) { + console.log("Literal", a); + console.log("typeof node at Literal", typeof a.value); + var b; + "string" === typeof a.value ? b = a.value : "boolean" === typeof a.value ? b = a.value : "number" === typeof a.value ? b = a.value : "RegExp" === typeof a.value ? (b = this[typeof a.value](a), b = b.regex.pattern) : b = null; + console.log("value", b); + return {type:a.type, value:b}; + }; + b.RegExp = function(a) { + console.log("RegExp", a); + return {regex:a.regex}; + }; + b.Function = function(a) { + console.log("Function", a); + var b = this[a.id](a), c = [], e; + for (e in a.params) { + c.push(a.params[e]); + } + a = this[a.body](a); + return {id:b, params:c, body:a}; + }; + b.ExpressionStatement = function(a) { + var b = this[a.expression.type](a.expression); + return {type:a.type, expression:b}; + }; + b.BlockStatement = function(a) { + console.log("BlockStatement", a); + var b = [], c; + for (c in a.body) { + var e = a.body[c]; + console.log("BlockStatement statement", e); + e = this[e.type](e); + console.log("BlockStatement body", e); + b.push(e); } - console.log("ParamBlock param", e); - f.push(e); - a.type = c.type; - a.params = f; - console.log("ParamBlock result", a); - return a; + console.log("bodies", b); + return {type:a.type, body:b}; }; - a.ParamAngle = function(b, a, c) { - console.log("ParamAngle value, paramMeta, paramDefMeta", b, a, c); - return b; + b.EmptyStatement = function(a) { + console.log("EmptyStatement", a); + return {type:a.type}; }; - a.ParamTextInput = function(b, a, c) { - console.log("ParamTextInput value, paramMeta, paramDefMeta", b, a, c); - return b; + b.DebuggerStatement = function(a) { + console.log("DebuggerStatement", a); + return {type:a.type}; }; - a.ParamColor = function(b, a, c) { - console.log("ParamColor value, paramMeta, paramDefMeta", b, a, c); - console.log("ParamColor result", b); - return b; + b.WithStatement = function(a) { + console.log("WithStatement", a); + var b = this[a.object.type](a.object), c = this[a.body.type](a.body); + return {type:a.type, object:b, body:c}; }; - a.ParamDropdown = function(b, a, c) { - console.log("ParamDropdown value, paramMeta, paramDefMeta", b, a, c); - var e; - a = a.options; - console.log("options", a); - for (var f in a) { - if (c = a[f], b == c[1]) { - e = c[1]; - break; - } - } - e && (e = String(e)); - console.log("ParamDropdown result", e); - return e; + b.ReturnStaement = function(a) { + console.log("ReturnStaement", a); + var b; + b = null === a.argument ? null : this[a.argument.type](a.argument); + return {type:a.type, argument:b}; }; - a.ParamDropdownDynamic = function(b, a, c) { - console.log("ParamDropdownDynamic value, paramMeta, paramDefMeta", b, a, c); - var e; - if ("mouse" == b || "wall" == b || "wall_up" == b || "wall_down" == b || "wall_right" == b || "wall_left" == b) { - return b; - } - a = a.options; - console.log("ParamDropdownDynamic options", a); - for (var f in a) { - if (b == a[f][0]) { - console.log("options[i][0]", a[f][0]); - e = a[f][1]; - break; - } - } - e && (e = String(e)); - console.log("ParamDropdownDynamic result", e); - return e; + b.LabeledStatement = function(a) { + console.log("LabeledStatement", a); + var b = this[a.label.type](a.label), c = this[a.body.type](a.body); + return {type:a.type, label:b, body:c}; }; - a.ParamKeyboard = function(b, a, c) { - console.log("ParamKeyboard value, paramMeta, paramDefMeta", b, a, c); - b = Entry.KeyboardCode.prototype.keyCharToCode[b]; - console.log("ParamKeyboard result", b); - return b; + b.BreakStatement = function(a) { + console.log("BreakStatement", a); + var b; + console.log("node.label", a.label); + a.label && null !== a.label ? (console.log("node.label2", a.label), b = this[a.label.type](a.label)) : (console.log("node.lable1", a.label), b = null); + console.log("label", b); + return {type:a.type, label:b}; }; - a.Indicator = function(b, a, c) { + b.ContinueStatement = function(a) { + console.log("ContinueStatement", a); + var b; + b = null === a.label ? null : this[a.label.type](a.label); + return {type:a.type, label:b}; }; - a.MemberExpression = function(b) { - console.log("MemberExpression component", b); - var a = {}, c, e = b.object, f = b.property; - c = this[e.type](e); - a.object = c; - var g = this[f.type](f); - a.property = g; - console.log("MemberExpression objectData", c); - console.log("MemberExpression propertyData", g); - if ("call" == g.name && 0 == g.userCode) { - return a; - } - if ("__pythonRuntime.ops.subscriptIndex" == g.callee) { - e = Entry.playground.object; - if (c.object && "self" == c.object.name) { - if (f = c.property.name, !Entry.TextCodingUtil.prototype.isLocalListExisted(f, e)) { - return a; - } - } else { - if (f = c.name, !Entry.TextCodingUtil.prototype.isGlobalListExisted(f)) { - return a; - } - } - c = e = this.getBlockType("%2[%4]"); - var arguments = g.arguments, e = Entry.block[e], h = e.params, k = e.def.params, f = this.ParamDropdownDynamic(f, h[1], k[1]); - console.log("MemberExpression listName", f); - g = []; - g.push(""); - g.push(f); - g.push(""); - "number" == arguments[0].type ? arguments[0].params[0] += 1 : "text" == arguments[0].type && (arguments[0].params[0] = String(Number(arguments[0].params[0]) + 1)); - g.push(arguments[0]); - g.push(""); - a.type = c; - a.params = g; + b.IfStatement = function(a) { + console.log("IfStatement", a); + var b = this[a.test.type](a.test), c = {body:[]}; + if (null === a.alternate) { + c = null; } else { - if (g = [], "self" == e.name) { - c = e = this.getBlockType("%1"); - e = Entry.block[e]; - h = e.params; - k = e.def.params; - f = f.name; - e = Entry.playground.object; - if (!Entry.TextCodingUtil.prototype.isLocalVariableExisted(f, e)) { - return a; - } - f = this.ParamDropdownDynamic(f, h[0], k[0]); - g.push(f); - a.type = c; - 0 != g.length && (a.params = g); - } else { - return a; + for (var e in a.alternate.body) { + var f = a.alternate.body[e], g = this[f.type](f); + c.body.push(g); } } - console.log("MemberExpression result", a); - return a; - }; - a.WhileStatement = function(b) { - console.log("WhileStatement component", b); - var a; - a = {statements:[]}; - var c = b.test; - console.log("WhileStatement test", c); - if (!0 === c.value) { - var e = this.getBlockType("while True:\n$1") - } - console.log("WhileStatement type", e); - var f = Entry.block[e].params; - console.log("WhileStatement paramsMeta", f); - var g = []; - if ("Literal" == c.type || "Identifier" == c.type) { - arguments = []; - arguments.push(c); - f = Entry.block[e].params; - c = Entry.block[e].def.params; - console.log("WhileStatement paramsMeta", f); - console.log("WhileStatement paramsDefMeta", c); - for (var h in f) { - var k = f[h].type; - "Indicator" == k ? (k = {raw:null, type:"Literal", value:null}, h < arguments.length && arguments.splice(h, 0, k)) : "Text" == k && (k = {raw:"", type:"Literal", value:""}, h < arguments.length && arguments.splice(h, 0, k)); - } - for (var l in arguments) { - h = arguments[l], console.log("WhileStatement argument", h), h = this[h.type](h, f[l], c[l], !0), console.log("WhileStatement Literal param", h), h && null != h && g.push(h); - } - } else { - h = this[c.type](c), console.log("WhileStatement Not Literal param", h), h && null != h && g.push(h); + g = {body:[]}; + for (e in a.consequent.body) { + f = a.consequent.body[e], f = this[f.type](f), g.body.push(f); } - f = b.body; - f = this[f.type](f); - console.log("WhileStatement bodyData", f); - "True" == g[0].type && (a.type = e, a.statements.push(f.statements)); - console.log("WhileStatement result", a); - return a; + console.log("alternate", c); + console.log("consequent", g); + return {type:a.type, test:b, consequent:g, alternate:c}; }; - a.BlockStatement = function(b) { - console.log("BlockStatement component", b); - var a = {statements:[], data:[]}, c = [], e = [], f = []; - b = b.body; - console.log("BlockStatement bodies", b); - for (var g in b) { - var h = b[g], h = this[h.type](h); - console.log("BlockStatement bodyData", h); - h && null == h || (f.push(h), console.log("BlockStatement data", f)); + b.SwitchStatement = function(a) { + console.log("SwitchStatement", a); + var b = this[a.discriminant.type](a.discriminant), c = [], e; + for (e in a.cases) { + var f = a.cases[e], f = this[f.type](f); + c.push(f); } - console.log("BlockStatement final data", f); - a.data = f; - console.log("jhlee data check", f); - for (var k in f) { - if (f[1] && "repeat_basic" == f[1].type) { - if (0 == k) { - if (f[k].declarations) { - b = f[0].declarations; - for (k in b) { - h = b[k], (h = h.init) && c.push(h); - } - a.params = c; - } - } else { - if (1 == k) { - a.type = f[k].type; - e = []; - b = f[k].statements[0]; - console.log("BlockStatement allStatements", b); - if (b && 0 != b.length) { - for (g in b) { - h = b[g], console.log("BlockStatement(for) statement", h), h.type && e.push(h); - } - } - console.log("BlockStatement(for) statements", e); - a.statements.push(e); - } - } - } else { - if (f) { - if (0 == k) { - if (f[k] && f[k].declarations) { - b = f[k].declarations; - for (k in b) { - h = b[k], (h = h.init) && c.push(h); - } - a.params = c; - } else { - (h = f[k]) && h.type && e.push(h); - } - } else { - e = []; - if ((b = f) && 0 != b.length) { - for (g in b) { - h = b[g], console.log("BlockStatement statement", h), h && h.type && e.push(h); - } - } - console.log("BlockStatement statements", e); - } - a.statements = e; - } - } + return {type:a.type, discriminant:b, cases:c}; + }; + b.SwitchCase = function(a) { + console.log("SwitchCase", a); + var b; + b = null === a.test ? null : this[a.test.type](a.test); + for (var c in a.consequent) { + a = this[statment.type](statment), (void 0).push(a); } - console.log("BlockStatement statement result", a); - return a; + return {test:b, consequent:void 0}; }; - a.IfStatement = function(b) { - console.log("IfStatement component", b); - var a; - a = {statements:[]}; - var c, e = [], f = b.consequent, g = b.alternate; - c = null != g ? "if_else" : "_if"; - a.type = c; - console.log("IfStatement type", c); - var h = b.test; - console.log("IfStatement test", h); - if ("Literal" == h.type || "Identifier" == h.type) { - arguments = []; - arguments.push(h); - h = Entry.block[c].params; - c = Entry.block[c].def.params; - console.log("IfStatement paramsMeta", h); - console.log("IfStatement paramsDefMeta", c); - for (var k in h) { - var l = h[k].type; - "Indicator" == l ? (l = {raw:null, type:"Literal", value:null}, k < arguments.length && arguments.splice(k, 0, l)) : "Text" == l && (l = {raw:"", type:"Literal", value:""}, k < arguments.length && arguments.splice(k, 0, l)); - } - for (var m in arguments) { - k = arguments[m], console.log("IfStatement argument", k), k = this[k.type](k, h[m], c[m], !0), console.log("IfStatement Literal param", k), k && null != k && e.push(k); - } + b.ThrowStatement = function(a) { + console.log("ThrowStatement", a); + var b = this[a.argument.type](a.argument); + return {type:a.type, argument:b}; + }; + b.TryStatement = function(a) { + console.log("TryStatement", a); + var b = this[a.block.type](a.block), c; + c = null === a.handler ? null : this[a.handler.type](a.handler); + var e; + e = null === a.finalizer ? null : this[a.finalizer.type](a.finalizer); + return {type:a.type, block:b, handler:c, finalizer:e}; + }; + b.CatchClause = function(a) { + console.log("CatchClause", a); + var b = a.param; + a = this[a.body.type](a.body); + return {param:b, body:a}; + }; + b.WhileStatement = function(a) { + console.log("WhileStatement", a); + var b = this[a.test.type](a.test), c = this[a.body.type](a.body); + console.log("WhileStatement test", b); + console.log("WhileStatement body", c); + return {type:a.type, test:b, body:c}; + }; + b.DoWhileStatement = function(a) { + console.log("DoWhileStatement", a); + var b; + b = this[a.init.type](a.init); + var c; + c = null === a.test ? null : this[a.test.type](a.test); + var e; + e = null === a.update ? null : this[a.update.type](a.update); + var f = this[a.body.type](a.body); + return {type:a.type, init:b, test:c, update:e, body:f}; + }; + b.ForStatement = function(a) { + console.log("ForStatement", a); + var b; + if (null === a.init) { + b = null; } else { - k = this[h.type](h), console.log("IfStatement Not Literal param", k), k && null != k && e.push(k); - } - e && 0 != e.length && (a.params = e); - console.log("IfStatement params result", e); - if (null != f) { - e = []; - console.log("IfStatement consequent", f); - f = this[f.type](f); - console.log("IfStatement consequent data", f); - f = f.data; - console.log("IfStatement consequentsData", f); - for (m in f) { - h = f[m], console.log("IfStatement consData", h), h && (h.init && h.type ? (a.type = h.type, (h = h.statements) && (e = h)) : !h.init && h.type && e.push(h)); - } - 0 != e.length && (a.statements[0] = e); - } - if (null != g) { - f = []; - console.log("IfStatement alternate", g); - g = this[g.type](g); - console.log("IfStatement alternate data", g); - g = g.data; - for (m in g) { - (e = g[m]) && e.type && f.push(e); - } - 0 != f.length && (a.statements[1] = f); + this[a.init.type](a.init); } - console.log("IfStatement result", a); - return a; + var c; + c = null === a.test ? null : this[a.test.type](a.test); + var e; + e = null === a.update ? null : this[a.update.type](a.update); + var f = this[a.body.type](a.body); + console.log("ForStatement body", f); + return {type:a.type, init:b, test:c, update:e, body:f}; }; - a.ForStatement = function(b) { - console.log("ForStatement component", b); - var a = {statements:[]}, c = this.getBlockType("for i in range"); - a.type = c; - if (c = b.init) { - var e = this[c.type](c) + b.ForInStatement = function(a) { + console.log("ForInStatement", a); + var b; + b = this[a.left.type](a.left); + var c = this[a.right.type](a.right), e = this[a.body.type](a.body); + return {type:a.type, left:b, right:c, body:e}; + }; + b.FunctionDeclaration = function(a) { + console.log("FunctionDeclaration", a); + return {id:this[a.id.type](a.id)}; + }; + b.VariableDeclaration = function(a) { + console.log("VariableDeclaration", a); + var b = [], c; + for (c in a.declarations) { + var e = a.declarations[c], e = this[e.type](e); + console.log("declaration", e); + b.push(e); } - a.init = e; - console.log("ForStatement init", c); - e = b.body.body; - console.log("ForStatement bodies", e); - if (e) { - for (var f in e) { - 0 != f && (c = e[f], console.log("ForStatement bodyData", c, "index", f), c = this[c.type](c), console.log("ForStatement bodyData result", c, "index", f), a.statements.push(c)); + console.log("VariableDeclaration declarations", b); + return {type:a.type, declarations:b, kind:"var"}; + }; + b.VariableDeclarator = function(a) { + console.log("VariableDeclarator", a); + var b = this[a.id.type](a.id), c; + c = null === a.init ? null : this[a.init.type](a.init); + console.log("id", b); + console.log("init", c); + return {type:a.type, id:b, init:c}; + }; + b.ThisExpression = function(a) { + console.log("ThisExpression", a); + return {type:a.type}; + }; + b.ArrayExpression = function(a) { + console.log("ArrayExpression", a); + var b; + if (null === a.elements) { + b = null; + } else { + for (var c in a.elements) { + var e = a.elements[c], e = this[e.type](e); + b.push(e); } } - console.log("ForStatement bodyData result", a); - if (f = b.test) { - var g = this[f.type](f) - } - a.test = g; - console.log("ForStatement testData", g); - if (b = b.update) { - var h = this[b.type](b) - } - a.update = h; - console.log("ForStatement updateData", h); - console.log("ForStatement result", a); - return a; + return {type:a.type, elements:b}; }; - a.ForInStatement = function(b) { - console.log("ForInStatement component", b); - console.log("ForInStatement result", null); - return null; + b.ObjectExpression = function(a) { + console.log("ObjectExpression", a); + for (var b in a.properties) { + var c = a.properties[b], c = this[c.type](c); + (void 0).push(c); + } + return {type:a.type, properties:void 0}; }; - a.BreakStatement = function(b) { - console.log("BreakStatement component", b); - b = {}; - var a = this.getBlockType("break"); - console.log("BreakStatement type", a); - b.type = a; - console.log("BreakStatement result", b); - return b; + b.Property = function(a) { + console.log("Property", a); + var b = this[a.key.type](a.key), c = this[a.value.type](a.value); + return {type:a.type, key:b, value:c, kind:a.kind}; }; - a.UnaryExpression = function(b) { - console.log("UnaryExpression component", b); - var a; - b.prefix && (a = b.operator, b = b.argument, console.log("UnaryExpression operator", a), b.value = Number(a.concat(b.value)), a = this[b.type](b), console.log("UnaryExpression data", a)); - b = a; - console.log("UnaryExpression result", b); - return b; + b.FunctionExpression = function(a) { + console.log("FunctionExpression", a); + return {type:a.type}; }; - a.LogicalExpression = function(b) { - console.log("LogicalExpression component", b); - var a; - a = {}; - var c = String(b.operator); - switch(c) { - case "&&": - var e = "(%1 and %3)"; + b.UnaryExpression = function(a) { + console.log("UnaryExpression", a); + var b; + switch(a.operator) { + case "-": + b = a.operator; break; - case "||": - e = "(%1 or %3)"; + case "+": + b = a.operator; + break; + case "!": + b = a.operator; + break; + case "~": + b = a.operator; + break; + case "typeof": + b = a.operator; + break; + case "void": + b = a.operator; + break; + case "delete": + b = a.operator; + break; + default: + b = null; + } + var c = a.prefix, e = this[a.argument.type](a.argument); + return {type:a.type, operator:b, prefix:c, argument:e}; + }; + b.UpdateExpression = function(a) { + console.log("UpdateExpression", a); + var b; + switch(a.operator) { + case "++": + b = a.operator; + break; + case "--": + b = a.operator; break; default: - e = "(%1 and %3)"; - } - var e = this.getBlockType(e), f = [], c = b.left; - if ("Literal" == c.type || "Identifier" == c.type) { - arguments = []; - arguments.push(c); - var c = Entry.block[e].params, g = Entry.block[e].def.params; - console.log("LogicalExpression paramsMeta", c); - console.log("LogicalExpression paramsDefMeta", g); - for (var h in c) { - var k = c[h].type; - "Indicator" == k ? (k = {raw:null, type:"Literal", value:null}, h < arguments.length && arguments.splice(h, 0, k)) : "Text" == k && (k = {raw:"", type:"Literal", value:""}, h < arguments.length && arguments.splice(h, 0, k)); - } - for (var l in arguments) { - var m = arguments[l]; - console.log("LogicalExpression argument", m); - m = this[m.type](m, c[l], g[l], !0); - console.log("LogicalExpression param", m); - m && null != m && f.push(m); - } - } else { - (m = this[c.type](c)) && f.push(m); - } - console.log("LogicalExpression left param", m); - c = String(b.operator); - console.log("LogicalExpression operator", c); - c && (m = c = Entry.TextCodingUtil.prototype.logicalExpressionConvert(c), f.push(m)); - c = b.right; - if ("Literal" == c.type || "Identifier" == c.type) { - arguments = []; - arguments.push(c); - c = Entry.block[e].params; - g = Entry.block[e].def.params; - console.log("LogicalExpression paramsMeta", c); - console.log("LogicalExpression paramsDefMeta", g); - for (h in c) { - k = c[h].type, "Indicator" == k ? (k = {raw:null, type:"Literal", value:null}, h < arguments.length && arguments.splice(h, 0, k)) : "Text" == k && (k = {raw:"", type:"Literal", value:""}, h < arguments.length && arguments.splice(h, 0, k)); - } - for (l in arguments) { - m = arguments[l], console.log("LogicalExpression argument", m), m = this[m.type](m, c[l], g[l], !0), console.log("LogicalExpression param", m), m && null != m && f.push(m); - } - } else { - (m = this[c.type](c)) && f.push(m); + b = null; } - console.log("LogicalExpression right param", m); - a.type = e; - a.params = f; - console.log("LogicalExpression result", a); - return a; + var c = this[a.argument.type](a.argument); + return {type:a.type, operator:b, prefix:a.prefix, argument:c}; }; - a.BinaryExpression = function(b) { - console.log("BinaryExpression component", b); - var a = {}, c = {}, e = String(b.operator); - switch(e) { + b.BinaryExpression = function(a) { + console.log("BinaryExpression", a); + var b; + switch(a.operator) { case "==": - var f = "(%1 %2boolean_compare# %3)"; + b = a.operator; break; case "!=": - f = "(%2 != True)"; + b = a.operator; + break; + case "===": + b = a.operator; + break; + case "!==": + b = a.operator; break; case "<": - f = "(%1 %2boolean_compare# %3)"; + b = a.operator; break; case "<=": - f = "(%1 %2boolean_compare# %3)"; + b = a.operator; break; case ">": - f = "(%1 %2boolean_compare# %3)"; + b = a.operator; break; case ">=": - f = "(%1 %2boolean_compare# %3)"; + b = a.operator; + break; + case "<<": + b = a.operator; + break; + case ">>": + b = a.operator; + break; + case ">>>": + b = a.operator; break; case "+": - f = "(%1 %2calc_basic# %3)"; + b = a.operator; break; case "-": - f = "(%1 %2calc_basic# %3)"; + b = a.operator; break; case "*": - f = "(%1 %2calc_basic# %3)"; + b = a.operator; break; case "/": - f = "(%1 %2calc_basic# %3)"; + b = a.operator; + break; + case "%": + b = a.operator; + break; + case "|": + b = a.operator; + break; + case "^": + b = a.operator; + break; + case "|": + b = a.operator; + break; + case "&": + b = a.operator; + break; + case "in": + b = a.operator; + break; + case "instanceof": + b = a.operator; + break; + default: + b = null; } - console.log("BinaryExpression operator", e); - console.log("BinaryExpression syntax", f); - if (f = this.getBlockType(f)) { - console.log("BinaryExpression type", f); - a = []; - e = b.left; - console.log("BinaryExpression left", e); - if ("Literal" == e.type || "Identifier" == e.type) { - arguments = []; - arguments.push(e); - var e = Entry.block[f].params, g = Entry.block[f].def.params; - console.log("BinaryExpression paramsMeta", e); - console.log("BinaryExpression paramsDefMeta", g); - for (var h in e) { - var k = e[h].type; - "Indicator" == k ? (k = {raw:null, type:"Literal", value:null}, h < arguments.length && arguments.splice(h, 0, k)) : "Text" == k && (k = {raw:"", type:"Literal", value:""}, h < arguments.length && arguments.splice(h, 0, k)); - } - for (var l in arguments) { - var m = arguments[l]; - console.log("BinaryExpression argument", m); - m = this[m.type](m, e[l], g[l], !0); - console.log("BinaryExpression param", m); - m && null != m && a.push(m); - } - } else { - (m = this[e.type](e)) && a.push(m); - } - console.log("BinaryExpression left params", a); - if ("boolean_not" == f) { - return a.splice(0, 0, ""), a.splice(2, 0, ""), console.log("BinaryExpression boolean_not params", a), c.type = f, c.params = a, c; - } - if (e = String(b.operator)) { - console.log("BinaryExpression operator", e), (m = e = Entry.TextCodingUtil.prototype.binaryOperatorConvert(e)) && a.push(m), c.operator = e; - } - e = b.right; - if ("Literal" == e.type || "Identifier" == e.type) { - arguments = []; - arguments.push(e); - e = Entry.block[f].params; - g = Entry.block[f].def.params; - console.log("BinaryExpression paramsMeta", e); - console.log("BinaryExpression paramsDefMeta", g); - for (h in e) { - k = e[h].type, "Indicator" == k ? (k = {raw:null, type:"Literal", value:null}, h < arguments.length && arguments.splice(h, 0, k)) : "Text" == k && (k = {raw:"", type:"Literal", value:""}, h < arguments.length && arguments.splice(h, 0, k)); - } - for (l in arguments) { - m = arguments[l], console.log("BinaryExpression argument", m), m = this[m.type](m, e[l], g[l], !0), console.log("BinaryExpression param", m), m && null != m && a.push(m); - } - } else { - (m = this[e.type](e)) && a.push(m); - } - console.log("BinaryExpression right param", m); - c.type = f; - c.params = a; - } else { - return a; + var c = this[a.left.type](a.left), e = this[a.right.type](a.right); + return {type:a.type, operator:b, left:c, right:e}; + }; + b.AssignmentExpression = function(a) { + console.log("AssignmentExpression", a); + var b; + switch(a.operator) { + case "=": + b = a.operator; + break; + case "+=": + b = a.operator; + break; + case "-=": + b = a.operator; + break; + case "*=": + b = a.operator; + break; + case "/=": + b = a.operator; + break; + case "%=": + b = a.operator; + break; + case "<<=": + b = a.operator; + break; + case ">>=": + b = a.operator; + break; + case "|=": + b = a.operator; + break; + case "^=": + b = a.operator; + break; + case "&=": + b = a.operator; + break; + default: + b = null; } - console.log("BinaryExpression params", a); - a = c; - console.log("BinaryExpression result", a); - return a; + var c; + c = a.left; + var e = this[a.right.type](a.right); + return {type:a.type, operator:b, left:c, right:e}; }; - a.UpdateExpression = function(b) { - console.log("UpdateExpression", b); - var a = {}, c = b.argument; - if (c) { - var e = this[c.type](c) + b.LogicalExpression = function(a) { + console.log("LogicalExpression", a); + var b; + switch(a.operator) { + case "||": + b = a.operator; + break; + case "&&": + b = a.operator; + break; + default: + b = null; } - a.argument = e; - a.operator = b.operator; - a.prefix = b.prefix; - console.log("UpdateExpression result", a); - return a; + var c = this[a.left.type](a.left), e = this[a.right.type](a.right); + return {type:a.type, operator:b, left:c, right:e}; }; - a.AssignmentExpression = function(b) { - console.log("AssignmentExpression component", b); - var a = {}, c, e = [], f, g = b.left; - if (g.type) { - var h = this[g.type](g); - console.log("AssignmentExpression leftData", h); + b.MemberExpression = function(a) { + console.log("MemberExpression", a); + var b = this[a.object.type](a.object), c = this[a.property.type](a.property), e = a.computed; + console.log("object", b); + console.log("property", c); + return {type:a.type, object:b, property:c, computed:e}; + }; + b.ConditionalExpression = function(a) { + console.log("ConditionalExpression", a); + var b = this[a.callee.type](a.callee), c; + for (c in a.arguments) { + var e = a.arguments[c], e = this[e.type](e); + (void 0).push(e); } - console.log("AssignmentExpression leftData", h); - a.left = h; - operator = String(b.operator); - console.log("AssignmentExpression operator", operator); - g = b.right; - if (g.type) { - var k = this[g.type](g); - console.log("AssignmentExpression rightData", k); + return {type:a.type, callee:b, arguments:void 0}; + }; + b.CallExpression = function(a) { + console.log("CallExpression", a); + var b = this[a.callee.type](a.callee), c = [], e; + for (e in a.arguments) { + var f = a.arguments[e], f = this[f.type](f); + c.push(f); } - a.right = k; - switch(operator) { - case "=": - if (k.callee && k.callee.object) { - var l = k.callee.object.object.name.concat(".").concat(k.callee.object.property.name).concat(".").concat(k.callee.property.name) - } - if ("__pythonRuntime.objects.list" == l && "self" == h.object.name) { - var m = h.property.name; - c = []; - var arguments = k.arguments, n; - for (n in arguments) { - var q = {}; - q.data = String(arguments[n].params[0]); - c.push(q); - } - q = Entry.playground.object; - Entry.TextCodingUtil.prototype.isLocalListExisted(m, q) ? Entry.TextCodingUtil.prototype.updateLocalList(m, c, q) : Entry.TextCodingUtil.prototype.createLocalList(m, c, q); - } - if (h.property && "__pythonRuntime.ops.subscriptIndex" == h.property.callee) { - var m = "%1[%2] = %3", r = this.getBlockType(m) - } else { - g.arguments && g.arguments[0] ? (c = b.left.name ? b.left.name : b.left.object.name.concat(b.left.property.name), m = b.right.arguments[0].name ? b.right.arguments[0].name : b.right.arguments[0].object.name.concat(b.right.arguments[0].property.name), console.log("AssignmentExpression leftEx", c, "rightEx", m), m = b.right.arguments && c == m ? "%1 += %2" : "%1 = %2") : m = "%1 = %2", r = this.getBlockType(m); - } - c = r; + console.log("callee", b); + console.log("arguments", c); + return {type:a.type, callee:b, arguments:c}; + }; + b.NewExpression = function(a) { + console.log("NewExpression", a); + return {type:a.type}; + }; + b.SequenceExpression = function(a) { + console.log("SequenceExpression", a); + for (var b in a.expressions) { + var c = a.expressions[b], c = this[c.type](c); + (void 0).push(c); + } + return {type:a.type, expressions:void 0}; + }; +})(Entry.PyToBlockParserTemp.prototype); +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, d) { + var c = Entry.createElement("div", "entryToast"); + c.addClass("entryToast"); + c.addClass("entryToastWarning"); + c.bindOnClick(function() { + Entry.toast.body_.removeChild(this); + }); + var e = Entry.createElement("div", "entryToast"); + e.addClass("entryToastTitle"); + e.innerHTML = b; + c.appendChild(e); + b = Entry.createElement("p", "entryToast"); + b.addClass("entryToastMessage"); + b.innerHTML = a; + c.appendChild(b); + this.toasts_.push(c); + this.body_.appendChild(c); + d || window.setTimeout(function() { + c.style.opacity = 1; + var a = setInterval(function() { + .05 > c.style.opacity && (clearInterval(a), c.style.display = "none", Entry.removeElement(c)); + c.style.opacity *= .9; + }, 20); + }, 1E3); +}; +Entry.Toast.prototype.success = function(b, a, d) { + var c = Entry.createElement("div", "entryToast"); + c.addClass("entryToast"); + c.addClass("entryToastSuccess"); + c.bindOnClick(function() { + Entry.toast.body_.removeChild(this); + }); + var e = Entry.createElement("div", "entryToast"); + e.addClass("entryToastTitle"); + e.innerHTML = b; + c.appendChild(e); + b = Entry.createElement("p", "entryToast"); + b.addClass("entryToastMessage"); + b.innerHTML = a; + c.appendChild(b); + this.toasts_.push(c); + this.body_.appendChild(c); + d || window.setTimeout(function() { + c.style.opacity = 1; + var a = setInterval(function() { + .05 > c.style.opacity && (clearInterval(a), c.style.display = "none", Entry.removeElement(c)); + c.style.opacity *= .9; + }, 20); + }, 1E3); +}; +Entry.Toast.prototype.alert = function(b, a, d) { + var c = Entry.createElement("div", "entryToast"); + c.addClass("entryToast"); + c.addClass("entryToastAlert"); + c.bindOnClick(function() { + Entry.toast.body_.removeChild(this); + }); + var e = Entry.createElement("div", "entryToast"); + e.addClass("entryToastTitle"); + e.innerHTML = b; + c.appendChild(e); + b = Entry.createElement("p", "entryToast"); + b.addClass("entryToastMessage"); + b.innerHTML = a; + c.appendChild(b); + this.toasts_.push(c); + this.body_.appendChild(c); + d || window.setTimeout(function() { + c.style.opacity = 1; + var a = setInterval(function() { + .05 > c.style.opacity && (clearInterval(a), c.style.display = "none", Entry.toast.body_.removeChild(c)); + c.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); } - if (operator) { - var t = Entry.TextCodingUtil.prototype.logicalExpressionConvert(operator) - } - a.operator = t; - console.log("AssignmentExpression syntax", m); - h.object ? q = h.object : h.name && (q = h.name); - h.proprty ? f = h.property : h.name && (f = h.name); - console.log("AssignmentExpression object property value", q, f); - if ("%1[%2] = %3" == m) { - f = h.params[1]; - console.log("AssignmentExpression listName", f); - if (!f) { - return a; + console.log((new Date).getTime() - a.getTime()); + }; + b._convertBlock = function(a) { + function b(a) { + var c = {type:a.getAttribute("type"), index:{}}; + a = $(a).children(); + if (!a) { + return c; } - e.push(f); - f = h.property.arguments[0]; - console.log("AssignmentExpression param 1", f); - console.log("AssignmentExpression param 2", f); - e.push(f); - e.push(k); - } else { - if ("%1 = %2" == m) { - console.log("AssignmentExpression calleeName check", l), q && "self" == q.name && "__pythonRuntime.objects.list" != l ? (q = Entry.block[r], h = q.params, l = q.def.params, m = f.name, (f = "number" == k.type || "text" == k.type ? k.params[0] : NaN) && NaN != f && (q = Entry.playground.object, console.log("final value", f), console.log("final object", q), Entry.TextCodingUtil.prototype.isLocalVariableExisted(m, q) ? Entry.TextCodingUtil.prototype.updateLocalVariable(m, f, q) : Entry.TextCodingUtil.prototype.createLocalVariable(m, - f, q)), m = this.ParamDropdownDynamic(m, h[0], l[0]), e.push(m)) : (q = Entry.block[r], h = q.params, l = q.def.params, console.log("property 123", f), m = f, (f = "number" == k.type || "text" == k.type ? k.params[0] : NaN) && NaN != f && (q = Entry.playground.object, console.log("final object", q), console.log("final value", f), Entry.TextCodingUtil.prototype.isGlobalVariableExisted(m, q) ? Entry.TextCodingUtil.prototype.updateGlobalVariable(m, f, q) : Entry.TextCodingUtil.prototype.createGlobalVariable(m, - f, q)), m = this.ParamDropdownDynamic(m, h[0], l[0]), e.push(m), k.callee && delete k.callee), e.push(k); - } else { - if ("%1 += %2" == m) { - if (q && "self" == q.name) { - if (q = Entry.block[r], h = q.params, l = q.def.params, m = f.name, q = Entry.playground.object, console.log("final object", q), !Entry.TextCodingUtil.prototype.isLocalVariableExisted(m, q)) { - return a; - } - } else { - if (q = Entry.block[r], h = q.params, l = q.def.params, m = f, !Entry.TextCodingUtil.prototype.isGlobalVariableExisted(m)) { - return a; - } - } - m = this.ParamDropdownDynamic(m, h[0], l[0]); - e.push(m); - e.push(k.params[2]); - } + for (var e = 0;e < a.length;e++) { + var f = a[e], g = f.tagName, h = $(f).children()[0], t = f.getAttribute("name"); + "value" === g ? "block" == h.nodeName && (c.params || (c.params = []), c.params.push(b(h)), c.index[t] = c.params.length - 1) : "field" === g && (c.params || (c.params = []), c.params.push(f.textContent), c.index[t] = c.params.length - 1); } + return c; } - a.type = c; - a.params = e; - console.log("AssignmentExpression result", a); - return a; + var c = 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 = b(e.childNodes[0]) + } + c = (new Entry.BlockMockup(c, h, a)).toJSON(); + c.class = f; + c.isNotFor = g; + _.isEmpty(c.paramsKeyMap) && delete c.paramsKeyMap; + _.isEmpty(c.statementsKeyMap) && delete c.statementsKeyMap; + c.func = Entry.block[a]; + -1 < "NUMBER TRUE FALSE TEXT FUNCTION_PARAM_BOOLEAN FUNCTION_PARAM_STRING TRUE_UN".split(" ").indexOf(a.toUpperCase()) && (c.isPrimitive = !0); + Entry.block[a] = c; }; - a.FunctionDeclaration = function(b) { - console.log("FunctionDeclaration component", b); - var a = {}, c = b.body; - b = b.id; - if ("__getParam0" == b.name) { - return a; +})(Entry.BlockDriver.prototype); +Entry.BlockMockup = function(b, a, d) { + this.templates = []; + this.params = []; + this.statements = []; + this.color = ""; + this.output = this.isNext = this.isPrev = !1; + this.fieldCount = 0; + this.events = {}; + this.def = a || {}; + this.paramsKeyMap = {}; + this.statementsKeyMap = {}; + this.definition = {params:[], type:this.def.type}; + this.simulate(b); + this.def = this.definition; +}; +(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)); + }; + b.toJSON = function() { + function a(b) { + if (b && (b = b.params)) { + for (var d = 0;d < b.length;d++) { + var c = b[d]; + c && (delete c.index, a(c)); + } + } } - var e = this[c.type](c); - console.log("FunctionDeclaration bodyData", e); - if ("Identifier" == b.type) { - var f = this[b.type](b) + 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 c = /dummy_/mi, e; + for (e in this.paramsKeyMap) { + c.test(e) && delete this.paramsKeyMap[e]; } - console.log("FunctionDeclaration idData", f); - c = []; - b = []; - var f = f.name, e = e.data, g; - for (g in e) { - if (e[g].declarations) { - var h = e[g].declarations; - 0 < h.length && c.push(h[0].name); - } else { - e[g].argument && (h = e[g].argument.statements) && 0 < h.length && (b = h); - } + for (e in this.statementsKeyMap) { + c.test(e) && delete this.statementsKeyMap[e]; } - console.log("FunctionDeclaration textFuncName", f); - console.log("FunctionDeclaration textFuncParams", c); - console.log("FunctionDeclaration textFuncStatements", b); - var k, l, m, e = Entry.variableContainer.functions_, n; - for (n in e) { - var q = e[n]; - Entry.TextCodingUtil.prototype.initQueue(); - Entry.TextCodingUtil.prototype.gatherFuncDefParam(q.content._data[0]._data[0].data.params[0]); - console.log("Entry.TextCodingUtil._funcParamQ", Entry.TextCodingUtil.prototype._funcParamQ); - for (var r = [], h = {};g = Entry.TextCodingUtil.prototype._funcParamQ.dequeue();) { - r.push(g), console.log("param", g); - } - console.log("funcParams", r); - for (var t in r) { - h[r[t]] = t; - } - console.log("paramMap", h); - console.log("funcNameQueue", Entry.TextCodingUtil.prototype._funcNameQ); - for (g = [];nameToken = Entry.TextCodingUtil.prototype._funcNameQ.dequeue();) { - g.push(nameToken), console.log("funcNames", nameToken); - } - Entry.TextCodingUtil.prototype.clearQueue(); - blockFuncName = g.join("__").trim(); - console.log("first blockFuncName", blockFuncName); - console.log("first textFuncName", f); - if (f == blockFuncName) { - if (console.log("textFuncName", f), console.log("blockFuncName", blockFuncName), console.log("textFuncParams.length", c.length), console.log("Object.keys(paramMap).length", Object.keys(h).length), c.length == Object.keys(h).length ? (k = !0, console.log("textFuncParams.length", c.length), console.log("Object.keys(paramMap).length", Object.keys(h).length), l = q.content._data[0]._data, g = l.slice(), g.shift(), console.log("blockFuncContents", l), l = Entry.TextCodingUtil.prototype.isFuncContentsMatch(g, - b, h)) : l = k = !1, k && l) { - m = "func".concat("_").concat(n); - break; - } else { - if (k && !l) { - m = n; - break; - } - } - } + 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}; + }; + b.appendDummyInput = function() { + return this; + }; + 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; + }; + b.appendStatementInput = function(a) { + this._addToStatementsKeyMap(a); + this.statements.push({accept:"basic"}); + }; + b.setCheck = function(a) { + var b = this.params; + "Boolean" === a && (b[b.length - 1].accept = "boolean"); + }; + b.appendField = function(a, b) { + if (!a) { + return this; } - console.log("FunctionDeclaration foundFlag", k); - console.log("FunctionDeclaration matchFlag", l); - if (k && l) { - console.log("targetFuncId", m); - var u = c.length; - this._funcMap.put(f + u, m); - console.log("FunctionDeclaration this._funcMap", this._funcMap); - a = m; - } else { - if (k && !l) { - a = Entry.variableContainer.functions_[m]; - n = a.content._data[0]; - n._data.splice(1, n._data.length - 1); - if (0 < b.length) { - for (u in b) { - t = b[u], t = new Entry.Block(t, n), n._data.push(t); - } - } - Entry.variableContainer.saveFunction(a); - Entry.variableContainer.updateList(); - a = m; - console.log("textFuncName", f); - u = c.length; - u = f + u; - n = m; - m = "func".concat("_").concat(n); - this._funcMap.put(u, m); - console.log("FunctionDeclaration result", a); - } else { - console.log("FunctionDeclaration textFuncName", f); - console.log("FunctionDeclaration textFuncParams", c); - console.log("FunctionDeclaration textFuncStatements", b); - k = new Entry.Func; - k.generateBlock(!0); - console.log("FunctionDeclaration newFunc", k); - m = []; - for (g = 1;g <= c.length + 1;g++) { - m.push("%" + g); - } - k.block.template = f + " " + m.join(" "); - console.log("newFunc template", k.block.template); - n = k.content._data[0]; - t = n._data[0].data.params[0]; - m = t.data.params; - k.description = ""; - g = f.split("__"); - if (0 < g.length) { - for (e = 1;e < g.length;e++) { - h = g[e], q = new Entry.Block({type:"function_field_label"}, n), q.data.params = [], q.data.params.push(h), l = Entry.TextCodingUtil.prototype.getLastParam(t), l.data.params[1] = q, k.description += h.concat(" "); - } - k.description += " "; + "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.visible = !1; + b._hideEvent = null; + b.createDom = function() { + this.dom = Entry.Dom("ul", {id:"entry-contextmenu", parent:$("body")}); + this.dom.bind("mousedown touchstart", function(a) { + a.stopPropagation(); + }); + Entry.Utils.disableContextmenu(this.dom); + }; + b.show = function(a, b, c) { + this._hideEvent = Entry.documentMousedown.attach(this, function() { + this.hide(); + }); + this.dom || this.createDom(); + if (0 !== a.length) { + var e = this; + void 0 !== b && (this._className = b, this.dom.addClass(b)); + var f = this.dom; + f.empty(); + for (var g = 0, h = a.length;g < h;g++) { + var k = a[g], l = k.text, m = !1 !== k.enable, n = Entry.Dom("li", {parent:f}); + if (k.divider) { + b = "divider"; } else { - m[0] = f, k.description = f + " "; - } - if (0 < c.length) { - for (e = new Entry.Block({type:"function_field_string"}, n), e.data.params = [], h = Entry.Func.requestParamBlock("string"), console.log("FunctionDeclaration stringParam", h), g = new Entry.Block({type:h}, n), e.data.params.push(g), l = Entry.TextCodingUtil.prototype.getLastParam(t), l.data.params[1] = e, k.paramMap[h] = Number(0), console.log("FunctionDeclaration paramBlock", k), t = 1;t < c.length;t++) { - e = new Entry.Block({type:"function_field_string"}, n), e.data.params = [], h = Entry.Func.requestParamBlock("string"), console.log("FunctionDeclaration stringParam", h), g = new Entry.Block({type:h}, n), e.data.params.push(g), l = Entry.TextCodingUtil.prototype.searchFuncDefParam(m[1]), console.log("FunctionDeclaration paramBlock", l), 0 == l.data.params.length ? l.data.params[0] = g : 1 == l.data.params.length && (l.data.params[1] = e), k.paramMap[h] = Number(t), console.log("FunctionDeclaration paramBlock", - k); - } - } - if (0 < b.length) { - for (u in b) { - t = b[u], t = new Entry.Block(t, n), n._data.push(t); - } + b = m ? "menuAble" : "menuDisable"; + var q = Entry.Dom("span", {parent:n}); + q.text(l); + m && k.callback && function(a, b) { + a.mousedown(function(a) { + a.preventDefault(); + e.hide(); + b(a); + }); + }(q, k.callback); } - Entry.Func.generateWsBlock(k); - Entry.variableContainer.saveFunction(k); - Entry.variableContainer.updateList(); - u = c.length; - u = f + u; - n = k.id; - m = "func".concat("_").concat(n); - this._funcMap.put(u, m); - console.log("FunctionDeclaration newFunc", k); + n.addClass(b); } + f.removeClass("entryRemove"); + this.visible = !0; + this.position(c || Entry.mouseCoordinate); } - console.log("FunctionDeclaration result", a); }; - a.FunctionExpression = function(b) { - console.log("FunctionExpression component", b); - var a = {}; - b = b.body; - b = this[b.type](b); - console.log("FunctionExpression bodyData", b); - a.statements = b.statements; - console.log("FunctionExpression result", a); - return a; + b.position = function(a) { + var b = this.dom; + b.css({left:0, top:0}); + var c = b.width(), e = b.height(), f = $(window), g = f.width(), f = f.height(); + a.x + c > g && (a.x -= c + 3); + a.y + e > f && (a.y -= e); + b.css({left:a.x, top:a.y}); + }; + b.hide = function() { + this.visible = !1; + this.dom.empty(); + this.dom.addClass("entryRemove"); + this._className && (this.dom.removeClass(this._className), delete this._className); + this._hideEvent && (Entry.documentMousedown.detach(this._hideEvent), this._hideEvent = null); + }; +})(Entry.ContextMenu); +Entry.Loader = {queueCount:0, totalCount:0, loaded:!1}; +Entry.Loader.addQueue = function(b) { + this.queueCount || Entry.dispatchEvent("loadStart"); + this.queueCount++; + this.totalCount++; +}; +Entry.Loader.removeQueue = function(b) { + this.queueCount--; + this.queueCount || (this.totalCount = 0, this.handleLoad()); +}; +Entry.Loader.getLoadedPercent = function() { + return 0 === this.totalCount ? 1 : this.queueCount / this.totalCount; +}; +Entry.Loader.isLoaded = function() { + return !this.queueCount && !this.totalCount; +}; +Entry.Loader.handleLoad = function() { + this.loaded || (this.loaded = !0, 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, COMMAND_TYPES:{addThread:101, destroyThread:102, destroyBlock:103, recoverBlock:104, insertBlock:105, separateBlock:106, moveBlock:107, cloneBlock:108, uncloneBlock:109, scrollBoard:110, setFieldValue:111, selectObject:201, "do":301, +undo:302, redo:303, editPicture:401, uneditPicture:402, processPicture:403, unprocessPicture:404}}; +Entry.Command = {}; +(function(b) { + b.do = {type:Entry.STATIC.COMMAND_TYPES["do"], log:function(a) { + return [b["do"].type]; + }}; + b.undo = {type:Entry.STATIC.COMMAND_TYPES.undo, log:function(a) { + return [b.undo.type]; + }}; + b.redo = {type:Entry.STATIC.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; +}; +(function(b) { + b.do = function(a) { + var b = this, c = Array.prototype.slice.call(arguments); + c.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, c))); + e = Entry.Command[a].do.apply(this, c); + setTimeout(function() { + b.report("do"); + b.report(a, c); + }, 0); + return {value:e, isPass:this.isPass.bind(this)}; + }; + b.undo = function() { + var a = Array.prototype.slice.call(arguments), b = a.shift(), c = Entry.Command[b]; + this.report("undo"); + Entry.stateManager && Entry.stateManager.addCommand.apply(Entry.stateManager, [b, this, this.do, c.undo].concat(c.state.apply(this, a))); + return {value:Entry.Command[b].do.apply(this, a), isPass:this.isPass.bind(this)}; }; - a.ReturnStatement = function(b) { - console.log("ReturnStatement component", b); - var a = {}; - if (b = b.argument) { - var c = this[b.type](b) - } - c && (a.argument = c); - console.log("ReturnStaement result", a); - return a; + b.redo = function() { + var a = Array.prototype.slice.call(arguments), b = a.shift(), c = Entry.Command[b]; + that.report("redo"); + Entry.stateManager && Entry.stateManager.addCommand.apply(Entry.stateManager, [b, this, this.undo, b].concat(c.state.apply(null, a))); + c.undo.apply(this, a); }; - a.ThisExpression = function(b) { - console.log("ThisExpression component", b); - var a = {}; - if (b = b.userCode) { - a.userCode = b; - } - console.log("ThisExpression result", a); - return a; + b.setCurrentEditor = function(a, b) { + this.editor[a] = b; }; - a.NewExpression = function(b) { - console.log("NewExpression component", b); - var a = {}, c = b.callee, c = this[c.type](c), arguments = b.arguments, e = [], f; - for (f in arguments) { - var g = arguments[f]; - console.log("NewExpression argument", g); - g = this[g.type](g); - e.push(g); + b.isPass = function(a) { + a = void 0 === a ? !0 : a; + if (Entry.stateManager) { + var b = Entry.stateManager.getLastCommand(); + b && (b.isPass = a); } - a.callee = c; - a.arguments = e; - console.log("NewExpression result", a); - return a; - }; - a.getBlockType = function(b) { - return this.blockSyntax[b]; - }; - a.RegExp = function(b) { - console.log("RegExp", b); - console.log("RegExp result", b); - return b; - }; - a.Function = function(b) { - console.log("Function component", b); - console.log("Function result", b); - return b; - }; - a.EmptyStatement = function(b) { - console.log("EmptyStatement component", b); - console.log("EmptyStatement result", b); - return b; - }; - a.DebuggerStatement = function(b) { - console.log("DebuggerStatement component", b); - console.log("DebuggerStatement result", b); - return b; - }; - a.WithStatement = function(b) { - console.log("WithStatement component", b); - console.log("WithStatement result", b); - return b; - }; - a.LabeledStatement = function(b) { - console.log("LabeledStatement component", b); - console.log("LabeledStatement result", b); - return b; - }; - a.ContinueStatement = function(b) { - console.log("ContinueStatement component", b); - console.log("ContinueStatement result", b); - return b; }; - a.SwitchStatement = function(b) { - console.log("SwitchStatement component", b); - console.log("SwitchStatement result", b); - return b; - }; - a.SwitchCase = function(b) { - console.log("SwitchCase component", b); - console.log("SwitchCase result", b); - return b; - }; - a.ThrowStatement = function(b) { - console.log("ThrowStatement component", b); - console.log("ThrowStatement result", b); - return b; - }; - a.TryStatement = function(b) { - console.log("TryStatement component", b); - console.log("TryStatement result", b); - return b; - }; - a.CatchClause = function(b) { - console.log("CatchClause component", b); - console.log("CatchClause result", b); - return b; - }; - a.DoWhileStatement = function(b) { - console.log("DoWhileStatement component", b); - console.log("DoWhileStatement result", b); - return b; + b.addReporter = function(a) { + this.reporters.push(a); }; - a.ArrayExpression = function(b) { - console.log("ArrayExpression component", b); - console.log("ArrayExpression result", b); - return b; + b.removeReporter = function(a) { + a = this.reporters.indexOf(a); + -1 < a && this.reporters.splice(a, 1); }; - a.ObjectExpression = function(b) { - console.log("ObjectExpression component", b); - console.log("ObjectExpression result", b); - return b; + b.report = function(a, b) { + var c = this.reporters; + if (0 !== c.length) { + var e; + e = a && Entry.Command[a] && Entry.Command[a].log ? Entry.Command[a].log.apply(this, b) : b; + c.forEach(function(a) { + a.add(e); + }); + } }; - a.Property = function(b) { - console.log("Property component", b); - console.log("Property result", b); +})(Entry.Commander.prototype); +(function(b) { + b.addThread = {type:Entry.STATIC.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:Entry.STATIC.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:Entry.STATIC.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:Entry.STATIC.COMMAND_TYPES.recoverBlock, do:function(a, b) { + var c = this.editor.board.code.createThread([a]).getFirstBlock(); + "string" === typeof c && (c = this.editor.board.findById(c)); + this.editor.board.insert(c, b); + }, state:function(a) { + "string" !== typeof a && (a = a.id); + return [a]; + }, log:function(a, d) { + a = this.editor.board.findById(a.id); + return [b.recoverBlock.type, ["block", a.stringify()], ["pointer", d], ["code", this.editor.board.code.stringify()]]; + }, undo:"destroyBlock"}; + b.insertBlock = {type:Entry.STATIC.COMMAND_TYPES.insertBlock, do:function(a, b, c) { + "string" === typeof a && (a = this.editor.board.findById(a)); + this.editor.board.insert(a, b, c); + }, state:function(a, b) { + "string" === typeof a && (a = this.editor.board.findById(a)); + var c = [a.id], e = a.targetPointer(); + c.push(e); + "string" !== typeof a && "basic" === a.getBlockType() && c.push(a.thread.getCount(a)); + return c; + }, log:function(a, d, c) { + "string" === typeof a && (a = this.editor.board.findById(a)); + return [b.insertBlock.type, ["blockId", a.id], ["targetPointer", a.targetPointer()], ["count", c], ["code", this.editor.board.code.stringify()]]; + }, undo:"insertBlock"}; + b.separateBlock = {type:Entry.STATIC.COMMAND_TYPES.separateBlock, do:function(a) { + a.view && a.view._toGlobalCoordinate(Entry.DRAG_MODE_DRAG); + a.doSeparate(); + }, state:function(a) { + var b = [a.id], c = a.targetPointer(); + b.push(c); + "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:Entry.STATIC.COMMAND_TYPES.moveBlock, do:function(a, b, c) { + void 0 !== b ? (a = this.editor.board.findById(a), a.moveTo(b, c)) : a._updatePos(); + }, state:function(a) { + "string" === typeof a && (a = this.editor.board.findById(a)); + return [a.id, a.x, a.y]; + }, log:function(a, d, c) { + return [b.moveBlock.type, ["blockId", a.id], ["x", a.x], ["y", a.y], ["code", this.editor.board.code.stringify()]]; + }, undo:"moveBlock"}; + b.cloneBlock = {type:Entry.STATIC.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 d = this.editor.board.code.getThreads().pop(); + return [b.cloneBlock.type, ["blockId", a.id], ["thread", d.stringify()], ["code", this.editor.board.code.stringify()]]; + }, undo:"uncloneBlock"}; + b.uncloneBlock = {type:Entry.STATIC.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:Entry.STATIC.COMMAND_TYPES.scrollBoard, do:function(a, b, c) { + c || this.editor.board.scroller._scroll(a, b); + delete this.editor.board.scroller._diffs; + }, state:function(a, b) { + return [-a, -b]; + }, log:function(a, d) { + return [b.scrollBoard.type, ["dx", a], ["dy", d]]; + }, undo:"scrollBoard"}; + b.setFieldValue = {type:Entry.STATIC.COMMAND_TYPES.setFieldValue, do:function(a, b, c, e, f) { + b.setValue(f, !0); + }, state:function(a, b, c, e, f) { + return [a, b, c, f, e]; + }, log:function(a, d, c, e, f) { + return [b.setFieldValue.type, ["pointer", c], ["newValue", f], ["code", this.editor.board.code.stringify()]]; + }, undo:"setFieldValue"}; +})(Entry.Command); +(function(b) { + b.selectObject = {type:Entry.STATIC.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); +(function(b) { + b.editPicture = {type:Entry.STATIC.COMMAND_TYPES.editPicture, do:function(a, b) { + Entry.playground.painter.lc.canRedo() && Entry.playground.painter.lc.redo(); + }, state:function(a) { + }, log:function(a) { + return [a]; + }, undo:"uneditPicture"}; + b.uneditPicture = {type:Entry.STATIC.COMMAND_TYPES.uneditPicture, do:function(a, b) { + Entry.playground.painter.lc.undo(); + }, state:function(a) { + }, log:function(a) { + return [a]; + }, undo:"editPicture"}; + b.processPicture = {type:Entry.STATIC.COMMAND_TYPES.processPicture, do:function(a, b) { + Entry.playground.painter.lc.canRedo() && Entry.playground.painter.lc.redo(); + }, state:function(a) { + }, log:function(a) { + return [a]; + }, undo:"unprocessPicture", isPass:!0}; + b.unprocessPicture = {type:Entry.STATIC.COMMAND_TYPES.unprocessPicture, do:function(a, b) { + Entry.playground.painter.lc.undo(); + }, state:function(a) { + }, log:function(a) { + return [a]; + }, undo:"processPicture", isPass:!0}; +})(Entry.Command); +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; + "tablet" === this.device ? this.view_.setAttribute("class", "entry tablet") : 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.ConditionalExpression = function(b) { - console.log("ConditionalExpression component", b); - console.log("ConditionalExpression result", b); - return b; + document.onkeyup = function(a) { + Entry.dispatchEvent("keyUpped", a); }; - a.SequenceExpression = function(b) { - console.log("SequenceExpression component", b); - console.log("SequenceExpression result", b); - return b; + window.onresize = function(a) { + Entry.dispatchEvent("windowResized", a); }; -})(Entry.PyToBlockParser.prototype); -Entry.Console = function() { - Entry.propertyPanel && (this.createView(), Entry.propertyPanel.addMode("console", this), Entry.console = this, this._isEditing = !1, this._inputData = null); + window.onbeforeunload = this.beforeUnload; + Entry.addEventListener("saveWorkspace", function(a) { + Entry.addActivity("save"); + }); + Entry.addEventListener("showBlockHelper", function(a) { + Entry.propertyPanel.select("helper"); + }); + "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(); }; -(function(a) { - a.createView = function() { - this.view = new Entry.Dom("div", {id:"entryConsole"}); - this.codeMirror = CodeMirror(this.view[0], {lineNumbers:!1, lineWrapping:!0, value:"", mode:{}, theme:"default", styleActiveLine:!1, lint:!1}); - this._doc = this.codeMirror.getDoc(); - this.codeMirror.on("beforeChange", function(b, a) { - this._isEditing ? "+delete" === a.origin && 0 === a.to.ch && a.cancel() : a.cancel(); - }.bind(this)); - this.codeMirror.on("keyup", function(b, a) { - this._isEditing && 13 === a.keyCode && this.endInput(); - }.bind(this)); - this.codeMirror.on("cursorActivity", function(b, a) { - b.execCommand("goDocEnd"); - }); - Entry.addEventListener("stop", this.clear.bind(this)); - this.clear(); - }; - a.getView = function() { - return this.view; - }; - a.clear = function() { - this.setEditing(!0); - this.codeMirror.setValue("Entry Console \n"); - this.codeMirror.execCommand("goDocEnd"); - this.setEditing(!1); - }; - a.print = function(b, a) { - this.setEditing(!0); - this.codeMirror.execCommand("goDocEnd"); - var c = this._doc.getCursor(); - this._doc.replaceRange(b + "\n", {line:c.line, ch:0}); - this._doc.addLineClass(c.line, "text", a); - "speak" === a && this.setEditing(!1); - this.codeMirror.execCommand("goDocEnd"); - "ask" === a && (this._doc.addLineClass(c.line + 1, "text", "answer"), this.codeMirror.focus()); - }; - a.endInput = function() { - var b = this._doc.getCursor(), a = this.codeMirror.lineInfo(b.line); - "answer" === a.textClass ? (this._inputData = a.text, this._doc.replaceRange("\n", {line:b.line, ch:a.text.length})) : this._inputData = this._doc.getLine(b.line - 1); - Entry.container.setInputValue(this._inputData); - this.setEditing(!1); - }; - a.stopInput = function(b) { - this.setEditing(!1); - }; - a.setEditing = function(b) { - this._isEditing !== b && (this._isEditing = b); - }; -})(Entry.Console.prototype); -Entry.Parser = function(a, b, d, c) { - this._mode = a; - this.syntax = {}; - this.codeMirror = d; - this._lang = c || "js"; - this._type = b; - this.availableCode = []; - Entry.Parser.PARSE_GENERAL = 0; - Entry.Parser.PARSE_SYNTAX = 1; - Entry.Parser.PARSE_VARIABLE = 2; - Entry.Parser.BLOCK_SKELETON_BASIC = "basic"; - Entry.Parser.BLOCK_SKELETON_BASIC_LOOP = "basic_loop"; - Entry.Parser.BLOCK_SKELETON_BASIC_DOUBLE_LOOP = "basic_double_loop"; - this._console = new Entry.Console; - switch(this._lang) { - case "js": - this._parser = new Entry.JsToBlockParser(this.syntax); - break; - case "py": - this._parser = new Entry.PyToBlockParser(this.syntax); - c = this.syntax; - var e = {}, f; - for (f in c.Scope) { - e[f + "();\n"] = c.Scope[f]; - } - "BasicIf" in c && (e.front = "BasicIf"); - CodeMirror.commands.javascriptComplete = function(b) { - CodeMirror.showHint(b, null, {globalScope:e}); - }; - d.on("keyup", function(b, a) { - (65 <= a.keyCode && 95 >= a.keyCode || 167 == a.keyCode || 190 == a.keyCode) && CodeMirror.showHint(b, null, {completeSingle:!1, globalScope:e}); - }); - break; - case "blockJs": - this._parser = new Entry.BlockToJsParser(this.syntax); - c = this.syntax; +Entry.loadAudio_ = function(b, a) { + if (window.Audio && b.length) { + for (;0 < b.length;) { + var d = b[0]; + d.match(/\/([^.]+)./); + Entry.soundQueue.loadFile({id:a, src:d, type:createjs.LoadQueue.SOUND}); break; - case "blockPy": - this._parser = new Entry.BlockToPyParser(this.syntax), c = this.syntax; + } } }; -(function(a) { - a.setParser = function(b, a, c) { - this._mode = b; - this._type = a; - this._cm = c; - this.syntax = this.mappingSyntax(b); - switch(a) { - case Entry.Vim.PARSER_TYPE_JS_TO_BLOCK: - this._parser = new Entry.JsToBlockParser(this.syntax); - this._parserType = Entry.Vim.PARSER_TYPE_JS_TO_BLOCK; - break; - case Entry.Vim.PARSER_TYPE_PY_TO_BLOCK: - this._parser = new Entry.PyToBlockParser(this.syntax); - this._parserType = Entry.Vim.PARSER_TYPE_PY_TO_BLOCK; - break; - case Entry.Vim.PARSER_TYPE_BLOCK_TO_JS: - this._parser = new Entry.BlockToJsParser(this.syntax); - b = this.syntax; - var e = {}, f; - for (f in b.Scope) { - e[f + "();\n"] = b.Scope[f]; - } - c.on("keydown", function(b, a) { - var d = a.keyCode; - (65 <= d && 95 >= d || 167 == d || !a.shiftKey && 190 == d) && CodeMirror.showHint(b, null, {completeSingle:!1, globalScope:e}); - }); - this._parserType = Entry.Vim.PARSER_TYPE_JS_TO_BLOCK; - break; - case Entry.Vim.PARSER_TYPE_BLOCK_TO_PY: - this._parser = new Entry.BlockToPyParser(this.syntax), c.setOption("mode", {name:"python", globalVars:!0}), c.markText({line:0, ch:0}, {line:5}, {readOnly:!0}), this._parserType = Entry.Vim.PARSER_TYPE_BLOCK_TO_PY; +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(b, a) { + if (a && "workspace" != a) { + "minimize" == a ? (d = Entry.createElement("canvas"), d.className = "entryCanvasWorkspace", d.id = "entryCanvas", d.width = 640, d.height = 360, c = Entry.createElement("div", "entryCanvasWrapper"), c.appendChild(d), b.appendChild(c), this.canvas_ = d, this.stage.initStage(this.canvas_), c = Entry.createElement("div"), b.appendChild(c), this.engineView = c, this.engine.generateView(this.engineView, a)) : "phone" == a && (this.stateManagerView = d = Entry.createElement("div"), this.stateManager.generateView(this.stateManagerView, + a), c = Entry.createElement("div"), b.appendChild(c), this.engineView = c, this.engine.generateView(this.engineView, a), d = Entry.createElement("canvas"), d.addClass("entryCanvasPhone"), d.id = "entryCanvas", d.width = 640, d.height = 360, c.insertBefore(d, this.engine.footerView_), this.canvas_ = d, this.stage.initStage(this.canvas_), d = Entry.createElement("div"), b.appendChild(d), this.containerView = d, this.container.generateView(this.containerView, a), d = Entry.createElement("div"), + b.appendChild(d), this.playgroundView = d, this.playground.generateView(this.playgroundView, a)); + } else { + Entry.documentMousedown.attach(this, this.cancelObjectEdit); + var d = Entry.createElement("div"); + b.appendChild(d); + this.sceneView = d; + this.scene.generateView(this.sceneView, a); + d = Entry.createElement("div"); + this.sceneView.appendChild(d); + this.stateManagerView = d; + this.stateManager.generateView(this.stateManagerView, a); + var c = Entry.createElement("div"); + b.appendChild(c); + this.engineView = c; + this.engine.generateView(this.engineView, a); + d = Entry.createElement("canvas"); + d.addClass("entryCanvasWorkspace"); + d.id = "entryCanvas"; + d.width = 640; + d.height = 360; + c.insertBefore(d, this.engine.addButton); + d.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(); + } + }); + this.canvas_ = d; + this.stage.initStage(this.canvas_); + d = Entry.createElement("div"); + this.propertyPanel.generateView(b, a); + this.containerView = d; + this.container.generateView(this.containerView, a); + this.propertyPanel.addMode("object", this.container); + this.helper.generateView(this.containerView, a); + this.propertyPanel.addMode("helper", this.helper); + d = Entry.createElement("div"); + b.appendChild(d); + this.playgroundView = d; + this.playground.generateView(this.playgroundView, a); + this.propertyPanel.select("object"); + this.helper.bindWorkspace(this.playground.mainWorkspace); + } +}; +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; + b.device && (this.device = b.device); + 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.Utils = {}; +Entry.overridePrototype = function() { + Number.prototype.mod = function(b) { + return (this % b + b) % b; }; - a.parse = function(b, a) { - var c = null; - switch(this._type) { - case Entry.Vim.PARSER_TYPE_JS_TO_BLOCK: - try { - var e = []; - e.push(b); - var f = [], g; - for (g in e) { - var h = e[g], h = h.trim(), k = acorn.parse(h); - f.push(k); - } - c = this._parser.Program(f); - } catch (q) { - if (this.codeMirror) { - q instanceof SyntaxError ? (b = {from:{line:q.loc.line - 1, ch:0}, to:{line:q.loc.line - 1, ch:q.loc.column}}, q.message = "\ubb38\ubc95(Syntax) \uc624\ub958\uc785\ub2c8\ub2e4.", q.type = 1) : (b = this.getLineNumber(q.node.start, q.node.end), b.message = q.message, b.severity = "converting error", q.type = 2); - this.codeMirror.markText(b.from, b.to, {className:"CodeMirror-lint-mark-error", __annotation:b, clearOnEnter:!0}); - b = q.title ? q.title : "\ubb38\ubc95 \uc624\ub958"; - if (2 == q.type && q.message) { - var l = q.message - } else { - 2 != q.type || q.message ? 1 == q.type && (l = "\uc790\ubc14\uc2a4\ud06c\ub9bd\ud2b8 \ubb38\ubc95\uc744 \ud655\uc778\ud574\uc8fc\uc138\uc694.") : l = "\uc790\ubc14\uc2a4\ud06c\ub9bd\ud2b8 \ucf54\ub4dc\ub97c \ud655\uc778\ud574\uc8fc\uc138\uc694."; - } - Entry.toast.alert(b, l); - l = {}; - l.boardType = Entry.Workspace.MODE_BOARD; - l.textType = Entry.Vim.TEXT_TYPE_JS; - l.runType = Entry.Vim.MAZE_MODE; - Ntry.dispatchEvent("textError", l); - throw q; - } - c = []; - } +}; +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 d = [], c = 0;c < b.length;c++) { + for (var e = 0;e < a.length;e++) { + if (b[c] == a[e]) { + d.push(b[c]); break; - case Entry.Vim.PARSER_TYPE_PY_TO_BLOCK: - try { - var m = new Entry.PyAstGenerator, e = b.split("\n\n"), n; - for (n in e) { - h = e[n], -1 != h.search("import") ? e[n] = "" : (h = Entry.TextCodingUtil.prototype.entryEventFuncFilter(h), e[n] = h); - } - f = []; - for (g in e) { - h = e[g], k = m.generate(h), "Program" == k.type && 0 != k.body.length && f.push(k); - } - c = this._parser.Program(f); - this._parser._variableMap.clear(); - } catch (q) { - if (this.codeMirror) { - throw q instanceof SyntaxError ? (b = {from:{line:q.loc.line - 1, ch:q.loc.column - 2}, to:{line:q.loc.line - 1, ch:q.loc.column + 1}}, q.message = "\ubb38\ubc95 \uc624\ub958\uc785\ub2c8\ub2e4.") : (b = this.getLineNumber(q.node.start, q.node.end), b.message = q.message, b.severity = "error"), l = parseInt(b.to.line) + 1, b.from.line = l - 1, b.to.line = l, this.codeMirror.markText(b.from, b.to, {className:"CodeMirror-lint-mark-error", __annotation:b, clearOnEnter:!0}), b = q.title ? - q.title : "\ubb38\ubc95 \uc624\ub958", l = q.message && l ? q.message + " (line: " + l + ")" : "\ud30c\uc774\uc36c \ucf54\ub4dc\ub97c \ud655\uc778\ud574\uc8fc\uc138\uc694", Entry.toast.alert(b, l), q; - } - c = []; - } + } + } + } + return d; +}; +Entry.Utils.isPointInMatrix = function(b, a, d) { + d = void 0 === d ? 0 : d; + var c = b.offsetX ? b.x + b.offsetX : b.x, e = b.offsetY ? b.y + b.offsety : b.y; + return c - d <= a.x && c + b.width + d >= a.x && e - d <= a.y && e + b.height + d >= a.y; +}; +Entry.Utils.colorDarken = function(b, a) { + function d(a) { + 2 != a.length && (a = "0" + a); + return a; + } + var c, e, f; + 7 === b.length ? (c = parseInt(b.substr(1, 2), 16), e = parseInt(b.substr(3, 2), 16), f = parseInt(b.substr(5, 2), 16)) : (c = 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; + c = d(Math.floor(c * a).toString(16)); + e = d(Math.floor(e * a).toString(16)); + f = d(Math.floor(f * a).toString(16)); + return "#" + c + e + f; +}; +Entry.Utils.colorLighten = function(b, a) { + a = 0 === a ? 0 : a || 20; + var d = Entry.Utils.hexToHsl(b); + d.l += a / 100; + d.l = Math.min(1, Math.max(0, d.l)); + return Entry.Utils.hslToHex(d); +}; +Entry.Utils.bound01 = function(b, a) { + var d = b; + "string" == typeof d && -1 != d.indexOf(".") && 1 === parseFloat(d) && (b = "100%"); + d = "string" === typeof b && -1 != b.indexOf("%"); + b = Math.min(a, Math.max(0, parseFloat(b))); + d && (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, d; + 7 === b.length ? (a = parseInt(b.substr(1, 2), 16), d = parseInt(b.substr(3, 2), 16), b = parseInt(b.substr(5, 2), 16)) : (a = parseInt(b.substr(1, 2), 16), d = parseInt(b.substr(2, 2), 16), b = parseInt(b.substr(3, 2), 16)); + a = Entry.Utils.bound01(a, 255); + d = Entry.Utils.bound01(d, 255); + b = Entry.Utils.bound01(b, 255); + var c = Math.max(a, d, b), e = Math.min(a, d, b), f, g = (c + e) / 2; + if (c == e) { + f = e = 0; + } else { + var h = c - e, e = .5 < g ? h / (2 - c - e) : h / (c + e); + switch(c) { + case a: + f = (d - b) / h + (d < b ? 6 : 0); break; - case Entry.Vim.PARSER_TYPE_BLOCK_TO_JS: - c = l = this._parser.Code(b, a); + case d: + f = (b - a) / h + 2; break; - case Entry.Vim.PARSER_TYPE_BLOCK_TO_PY: - l = this._parser.Code(b, a), this._pyHinter || (this._pyHinter = new Entry.PyHint), c = l; + case b: + f = (a - d) / h + 4; } - return c; + f /= 6; + } + return {h:360 * f, s:e, l:g}; +}; +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 d(a) { + return 1 == a.length ? "0" + a : "" + a; + } + var c, e; + e = Entry.Utils.bound01(b.h, 360); + c = Entry.Utils.bound01(b.s, 1); + b = Entry.Utils.bound01(b.l, 1); + if (0 === c) { + c = b = e = b; + } else { + var f = .5 > b ? b * (1 + c) : b + c - b * c, g = 2 * b - f; + c = a(g, f, e + 1 / 3); + b = a(g, f, e); + e = a(g, f, e - 1 / 3); + } + b *= 255; + e *= 255; + return "#" + [d(Math.round(255 * c).toString(16)), d(Math.round(b).toString(16)), d(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(" ")); + -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 d; + d = b instanceof HTMLElement ? b : document.createElement(b); + a && (d.id = a); + d.hasClass = function(a) { + return this.className.match(new RegExp("(\\s|^)" + a + "(\\s|$)")); }; - a.getLineNumber = function(b, a) { - var c = this.codeMirror.getValue(), e = {from:{}, to:{}}; - b = c.substring(0, b).split(/\n/gi); - e.from.line = b.length - 1; - e.from.ch = b[b.length - 1].length; - a = c.substring(0, a).split(/\n/gi); - e.to.line = a.length - 1; - e.to.ch = a[a.length - 1].length; - return e; + d.addClass = function(a) { + for (var b = 0;b < arguments.length;b++) { + a = arguments[b], this.hasClass(a) || (this.className += " " + a); + } }; - a.mappingSyntax = function(b) { - for (var a = Object.keys(Entry.block), c = {}, e = 0;e < a.length;e++) { - var f = a[e], g = Entry.block[f]; - if (b === Entry.Vim.MAZE_MODE) { - if (-1 < this.availableCode.indexOf(f) && (g = g.syntax)) { - for (var h = c, k = 0;k < g.length;k++) { - var l = g[k]; - if (!(-1 < l.indexOf("%"))) { - var m = l.indexOf("("); - -1 < m && (l = l.substring(0, m)); - if (k === g.length - 2 && "function" === typeof g[k + 1]) { - h[l] = g[k + 1]; - break; - } - h[l] || (h[l] = {}); - k === g.length - 1 ? h[l] = f : h = h[l]; - } - } - } - } else { - if (b === Entry.Vim.WORKSPACE_MODE) { - for (l in f = Entry.block, f) { - g = f[l], h = null, g.syntax && g.syntax.py && (h = g.syntax.py), h && (h = String(h), g = h.split("("), 0 != g[0].length && (h = g[0]), c[h] = l); - } - } - } + d.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|$)"), " ")); } - return c; }; - a.setAvailableCode = function(b, a) { - var c = [], e; - b instanceof Entry.Code ? e = b.getBlockList() : b.forEach(function(b, a) { - e.concat(b); - }); - e.forEach(function(b) { - c.push(b.type); - }); - e = []; - a instanceof Entry.Code ? e = a.getBlockList() : a.forEach(function(b, a) { - e.concat(b); - }); - e.forEach(function(b) { - -1 === c.indexOf(b.type) && c.push(b.type); + d.bindOnClick = function(a) { + $(this).on("click tab", function(b) { + b.stopImmediatePropagation(); + a.call(this, b); }); - this.availableCode = this.availableCode.concat(c); }; - a.findErrorInfo = function(b) { - var a = 0, c = 0, e = this.codeMirror.getValue().split("\n"), f; - for (f in e) { - var g = e[f].trim(); - a++; - if (!(0 == g.length || 1 == g.length || -1 < g.indexOf("else")) && (c++, c == b.blockCount)) { + return d; +}; +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 d = 0, c = this.events_[b].length;d < c;d++) { + this.events_[b][d].call(window, a); + } + } +}; +Entry.removeEventListener = function(b, a) { + if (this.events_[b]) { + for (var d = 0, c = this.events_[b].length;d < c;d++) { + if (this.events_[b][d] === a) { + this.events_[b].splice(d, 1); break; } } - return {lineNumber:a - a, location:b.node}; - }; -})(Entry.Parser.prototype); -Entry.PyBlockAssembler = function(a) { - this.blockSyntax = a; - this._blockStatmentIndex = 0; - this._blockStatments = []; + } +}; +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 d = b.indexOf("."), c = a.indexOf("."), e = 0, f = 0; + 0 < d && (e = b.length - d - 1); + 0 < c && (f = a.length - c - 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, d) { + return "#" + (16777216 + (b << 16) + (a << 8) + d).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, d) { + return b > d ? d : b < a ? a : b; +}; +Entry.isExist = function(b, a, d) { + for (var c = 0;c < d.length;c++) { + if (d[c][a] == b) { + return d[c]; + } + } + 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.removeElement = function(b) { + b && b.parentNode && b.parentNode.removeChild(b); +}; +Entry.getElementsByClassName = function(b) { + for (var a = [], d = document.getElementsByTagName("*"), c = 0;c < d.length;c++) { + -1 < (" " + d[c].className + " ").indexOf(" " + b + " ") && a.push(d[c]); + } + return a; +}; +Entry.parseNumber = function(b) { + return "string" != typeof b || isNaN(Number(b)) ? "number" != typeof b || isNaN(Number(b)) ? !1 : b : Number(b); +}; +Entry.countStringLength = function(b) { + var a, d = 0; + for (a = 0;a < b.length;a++) { + 255 < b.charCodeAt(a) ? d += 2 : d++; + } + return d; +}; +Entry.cutStringByLength = function(b, a) { + var d, c = 0; + for (d = 0;c < a && d < b.length;d++) { + 255 < b.charCodeAt(d) ? c += 2 : c++; + } + return b.substr(0, d); +}; +Entry.isChild = function(b, a) { + if (!a) { + for (;a.parentNode;) { + if ((a = a.parentNode) == b) { + return !0; + } + } + } + return !1; +}; +Entry.launchFullScreen = function(b) { + b.requestFullscreen ? b.requestFullscreen() : b.mozRequestFulScreen ? b.mozRequestFulScreen() : b.webkitRequestFullscreen ? b.webkitRequestFullscreen() : b.msRequestFullScreen && b.msRequestFullScreen(); +}; +Entry.exitFullScreen = function() { + document.exitFullScreen ? document.exitFullScreen() : document.mozCancelFullScreen ? document.mozCancelFullScreen() : document.webkitExitFullscreen && document.webkitExitFullscreen(); +}; +Entry.isPhone = function() { + return !1; +}; +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.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.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 = {}, d; + for (d in b) { + a[d] = b[d]; + } + return a; +}; +Entry.nodeListToArray = function(b) { + for (var a = Array(b.length), d = -1, c = b.length;++d !== c;a[d] = b[d]) { + } + 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 Number(b + 10) + "px"; +}; +Entry.isArrowOrBackspace = function(b) { + return -1 < [37, 38, 39, 40, 8].indexOf(b); +}; +Entry.hexStringToBin = function(b) { + for (var a = [], d = 0;d < b.length - 1;d += 2) { + a.push(parseInt(b.substr(d, 2), 16)); + } + return String.fromCharCode.apply(String, a); +}; +Entry.findObjsByKey = function(b, a, d) { + for (var c = [], e = 0;e < b.length;e++) { + b[e][a] == d && c.push(b[e]); + } + return c; +}; +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.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.toRadian = function(b) { + return b * Math.PI / 180; +}; +Entry.toDegrees = function(b) { + return 180 * b / Math.PI; +}; +Entry.getPicturesJSON = function(b) { + for (var a = [], d = 0, c = b.length;d < c;d++) { + var e = b[d], 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.getSoundsJSON = function(b) { + for (var a = [], d = 0, c = b.length;d < c;d++) { + var e = b[d], 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; }; -(function(a) { - a.Program = function(b) { - var a = [], c; - for (c in b) { - if ("Program" != b[c].type) { - return; - } - var e = [], f = b[c].body; - console.log("nodes", f); - for (c in f) { - var g = f[c], g = this[g.type](g); - console.log("checkitout", g); - g = this._assembler[g.type](g); - e.push(g); - } - console.log("thread", e); - a.push(e); - } - return a; - }; - a.ExpressionStatement = function(b) { - console.log("ExpressionStatement component", b); - var a = {}; - b = b.expression; - "Literal" == b.type ? (b = this[b.type]({type:"Block", accept:"booleanMagnet"}, b), a.type = b.type, result = a, console.log("ExpressionStatement type literal", result)) : (b = this[b.type](b), a.type = b.type, a.params = b.params, result = a, console.log("ExpressionStatement type not literal", result)); - console.log("ExpressionStatement result", result); - return result; - }; - a.AssignmentExpression = function(b) { - console.log("AssignmentExpression component", b); - var a = [], c; - c = b.left; - c.type ? ("Literal" == c.type ? (c = this[c.type](paramsMeta[0], c), console.log("AssignmentExpression left Literal param", c)) : c = this[c.type](c), c && a.push(c), console.log("AssignmentExpression left param", c)) : (c = b.left, this[c.type](c)); - operator = String(b.operator); - console.log("AssignmentExpression operator", operator); - operator && (c = operator = Entry.TextCodingUtil.prototype.logicalExpressionConvert(operator), a.push(c)); - c = b.right; - c.type ? ("Literal" == c.type ? (c = this[c.type](paramsMeta[2], c), console.log("AssignmentExpression right Literal param", c)) : c = this[c.type](c), c && a.push(c), console.log("AssignmentExpression right param", c)) : (c = b.right, this[c.type](c)); - console.log("AssignmentExpression params", a); - console.log("AssignmentExpression result", result); - return result; - }; - a.CallExpression = function(b) { - console.log("CallExpression component", b); - var a; - a = {}; - var c = b.callee, c = this[c.type](c); - console.log("CallExpression calleeData", c, "calleeData typeof", typeof c); - var e = "object" != typeof c.object ? String(c.object).concat(".").concat(String(c.property)) : String(c.object.object).concat(".").concat(String(c.object.property)).concat(".").concat(String(c.property)); - console.log("CallExpression syntax", e); - c = this.getBlockType(e); - console.log("CallExpression type1", c); - c || "__pythonRuntime.functions.range" == e && (c = "repeat_basic"); - console.log("CallExpression type2", c); - e = Entry.block[c].params; - console.log("CallExpression paramsMeta", e); - var arguments = b.arguments, f = [], g; - for (g in arguments) { - var h = arguments[g]; - console.log("CallExpression argument", h); - if ("Literal" == h.type) { - var k = e[g]; - "Indicator" == k.type ? (h = null, f.push(h), g--) : (console.log("CallExpression argument index", h.type, g), h = this[h.type](k, h, c, g), f.push(h)); - g == arguments.length - 1 && (console.log("CallExpression in1"), g < e.length && (console.log("CallExpression in2"), f.push(null))); - console.log("CallExpression i", g); - } +Entry.cutDecimal = function(b) { + return Math.round(100 * b) / 100; +}; +Entry.getBrowserType = function() { + if (Entry.userAgent) { + return Entry.userAgent; + } + var b = navigator.userAgent, a, d = b.match(/(opera|chrome|safari|firefox|msie|trident(?=\/))\/?\s*(\d+)/i) || []; + if (/trident/i.test(d[1])) { + return a = /\brv[ :]+(\d+)/g.exec(b) || [], "IE " + (a[1] || ""); + } + if ("Chrome" === d[1] && (a = b.match(/\b(OPR|Edge)\/(\d+)/), null != a)) { + return a.slice(1).join(" ").replace("OPR", "Opera"); + } + d = d[2] ? [d[1], d[2]] : [navigator.appName, navigator.appVersion, "-?"]; + null != (a = b.match(/version\/(\d+)/i)) && d.splice(1, 1, a[1]); + b = d.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 d = new createjs.Shape(a); + Entry.stage.selectedObjectContainer.addChild(d); + b.brush && (b.brush = null); + b.brush = a; + b.shape && (b.shape = null); + b.shape = d; +}; +Entry.setCloneBrush = function(b, a) { + var d = new createjs.Graphics; + d.thickness = a.thickness; + d.rgb = a.rgb; + d.opacity = a.opacity; + d.setStrokeStyle(d.thickness); + d.beginStroke("rgba(" + d.rgb.r + "," + d.rgb.g + "," + d.rgb.b + "," + d.opacity / 100 + ")"); + var c = new createjs.Shape(d); + Entry.stage.selectedObjectContainer.addChild(c); + b.brush && (b.brush = null); + b.brush = d; + b.shape && (b.shape = null); + b.shape = c; +}; +Entry.isFloat = function(b) { + return /\d+\.{1}\d+$/.test(b); +}; +Entry.getStringIndex = function(b) { + if (!b) { + return ""; + } + for (var a = {string:b, index:1}, d = 0, c = [], e = b.length - 1;0 < e;--e) { + var f = b.charAt(e); + if (isNaN(f)) { + break; + } else { + c.unshift(f), d = e; } - console.log("CallExpression params", f); - a.type = c; - a.params = f; - console.log("CallExpression result", a); - return a; - }; - a.Literal = function(b, a, c, e) { - console.log("Literal paramMeta component particularIndex blockType", b, a, c, e); - a = a.value; - b = c ? this["Param" + b.type](b, a, c, e) : this["Param" + b.type](b, a); - console.log("Literal result", b); + } + 0 < d && (a.string = b.substring(0, d), a.index = parseInt(c.join("")) + 1); + return a; +}; +Entry.getOrderedName = function(b, a, d) { + if (!b) { + return "untitled"; + } + if (!a || 0 === a.length) { return b; - }; - a.ParamColor = function(b, a) { - console.log("ParamColor paramMeta value", b, a); - console.log("ParamColor result", a); - return a; - }; - a.ParamDropdown = function(b, a) { - console.log("ParamDropdown paramMeta value", b, a); - console.log("ParamDropdownDynamic result", a); - return a; - }; - a.ParamDropdownDynamic = function(b, a) { - console.log("ParamDropdownDynamic paramMeta value", b, a); - var c; - if ("mouse" == a) { - return "mouse"; + } + d || (d = "name"); + for (var c = 0, e = Entry.getStringIndex(b), f = 0, g = a.length;f < g;f++) { + var h = Entry.getStringIndex(a[f][d]); + e.string === h.string && h.index > c && (c = h.index); + } + return 0 < c ? e.string + c : b; +}; +Entry.changeXmlHashId = function(b) { + if (/function_field/.test(b.getAttribute("type"))) { + for (var a = b.getElementsByTagName("mutation"), d = 0, c = a.length;d < c;d++) { + a[d].setAttribute("hashid", Entry.generateHash()); } - b = b.options; - for (var e in b) { - if (console.log("options", b), a == b[e][0]) { - console.log("options[i][0]", b[e][0]); - c = b[e][1]; - break; + } + return b; +}; +Entry.getMaxFloatPoint = function(b) { + for (var a = 0, d = 0, c = b.length;d < c;d++) { + var e = String(b[d]), f = e.indexOf("."); + -1 !== f && (e = e.length - (f + 1), e > a && (a = e)); + } + return Math.min(a, 20); +}; +Entry.convertToRoundedDecimals = function(b, a) { + return isNaN(b) || !this.isFloat(b) ? b : Number(Math.round(b + "e" + a) + "e-" + a); +}; +Entry.attachEventListener = function(b, a, d) { + setTimeout(function() { + b.addEventListener(a, d); + }, 0); +}; +Entry.deAttachEventListener = function(b, a, d) { + b.removeEventListener(a, d); +}; +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 d() { + } + d.prototype = b.prototype; + a.prototype = new d; + 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 d = b.elem("defs"), c = d.elem("filter", {id:"entryTrashcanFilter_" + a}); + 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 = d.elem("filter", {id:"entryBlockShadowFilter_" + a, 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"}); + d = d.elem("filter", {id:"entryBlockHighlightFilter_" + a}); + d.elem("feOffset", {result:"offOut", in:"SourceGraphic", dx:0, dy:0}); + d.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 d = 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"}), c = d.elem("g"), e = c.elem("rect", {x:0, y:0, width:125, height:33}), f = Entry.mediaFilePath + "block_pattern_(order).png", g = 1;5 > g;g++) { + c.elem("image", {class:"pattern" + g, href:f.replace("(order)", g), x:0, y:0, width:125, height:33}); + } + return {pattern:d, rect:e}; +}; +Entry.Utils.COLLISION = {NONE:0, UP:1, RIGHT:2, LEFT:3, DOWN:4}; +Entry.Utils.createMouseEvent = function(b, a) { + var d = document.createEvent("MouseEvent"); + d.initMouseEvent(b, !0, !0, window, 0, 0, 0, a.clientX, a.clientY, !1, !1, !1, !1, 0, null); + return d; +}; +Entry.Utils.xmlToJsonData = function(b) { + b = $.parseXML(b); + var a = []; + b = b.childNodes[0].childNodes; + for (var d in b) { + var c = b[d]; + if (c.tagName) { + var e = {category:c.getAttribute("id"), blocks:[]}, c = c.childNodes; + for (d in c) { + var f = c[d]; + f.tagName && (f = f.getAttribute("type")) && e.blocks.push(f); } + a.push(e); } - console.log("ParamDropdownDynamic result", c); - return c; - }; - a.ParamKeyboard = function(b, a) { - console.log("ParamKeyboard paramMeta value", b, a); - b = Entry.KeyboardCodeMap.prototype.keyCharToCode[a]; - console.log("ParamKeyboard result", b); - return b; - }; - a.ParamBlock = function(b, a, c, e) { - console.log("ParamBlock paramMeta value blockType", b, a, c, e); - var f = {}, g = []; - c = Entry.TextCodingUtil.prototype.particularParam(c); - if (null != c) { - var h = c[e]; - if (h) { - h = c[e]; - console.log("ParamBlock particularType", h); - e = h; - f.type = e; - c = Entry.block[e].params; - console.log("ParamBlock particular block paramsMeta", b); - var k, l; - for (l in c) { - b = c[l]; - b = b.options; - for (var m in b) { - h = b[m], a == h[0] && (k = h[1]); - } - } - g.push(k); - f.params = g; - } else { - switch(e = typeof a, e) { - case "number": - f.type = "number"; - g.push(a); - f.params = g; - break; - case "boolean": - 1 == a ? f.type = "True" : 0 == a && (f.type = "False"); - break; - default: - f.type = "text", g.push(a), f.params = g; + } + return a; +}; +Entry.Utils.stopProjectWithToast = function(b, a, d) { + var c = b.block; + a = a || "\ub7f0\ud0c0\uc784 \uc5d0\ub7ec \ubc1c\uc0dd"; + Entry.toast && !d && Entry.toast.alert(Lang.Msgs.warn, Lang.Workspace.check_runtime_error, !0); + Entry.engine && Entry.engine.toggleStop(); + "workspace" === Entry.type && (b.block && "funcBlock" in b.block ? c = b.block.funcBlock : b.funcExecutor && (c = b.funcExecutor.scope.block, b = b.type.replace("func_", ""), Entry.Func.edit(Entry.variableContainer.functions_[b])), c && (Entry.container.selectObject(c.getCode().object.id, !0), c.view.getBoard().activateBlock(c))); + throw Error(a); +}; +Entry.Utils.AsyncError = function(b) { + this.name = "AsyncError"; + this.message = b || "\ube44\ub3d9\uae30 \ud638\ucd9c \ub300\uae30"; +}; +Entry.Utils.AsyncError.prototype = Error(); +Entry.Utils.AsyncError.prototype.constructor = Entry.Utils.AsyncError; +Entry.Utils.isChrome = function() { + return /chrom(e|ium)/.test(navigator.userAgent.toLowerCase()); +}; +Entry.Utils.waitForWebfonts = function(b, a) { + for (var d = 0, c = 0, e = b.length;c < e;++c) { + (function(c) { + function e() { + h && h.offsetWidth != k && (++d, h.parentNode.removeChild(h), h = null); + if (d >= b.length && (l && clearInterval(l), d == b.length)) { + return a(), !0; } } - } else { - switch(e = typeof a, e) { - case "number": - f.type = "number"; - g.push(a); - f.params = g; - break; - case "boolean": - 1 == a ? f.type = "True" : 0 == a && (f.type = "False"); - break; - default: - f.type = "text", g.push(a), f.params = g; - } - } - console.log("ParamBlock valueType", e); - console.log("ParamBlock result", f); - return f; - }; - a.Indicator = function(b, a, c) { - }; - a.MemberExpression = function(b) { - console.log("MemberExpression component", b); - var a = {}, c = b.object; - b = b.property; - c = this[c.type](c); - b = this[b.type](b); - console.log("MemberExpression objectData", c); - console.log("MemberExpression structure", b); - a.object = c; - a.property = b; - console.log("MemberExpression result", a); - return a; - }; - a.Identifier = function(b) { - console.log("Identifiler component", b); - b = b.name; - console.log("Identifiler result", b); - return b; - }; - a.WhileStatement = function(b) { - console.log("WhileStatement component", b); - var a = {}, c = b.test, e; - 1 == c.value && (e = this.getBlockType("while True:\n$1")); - console.log("WhileStatement type", e); - var f = Entry.block[e].params; - console.log("WhileStatement paramsMeta", f); - var g = []; - c && (c.type = "Literal", f = f[0], c = "Indicator" == f.type ? null : this[c.type](f, c), g.push(c)); - c = []; - b = b.body.body; - for (var h in b) { - f = b[h], f = this[f.type](f), c.push(f); - } - a.type = e; - a.params = g; - a.statements = []; - a.statements.push(c); - console.log("WhileStatement result", a); - return a; + var h = document.createElement("span"); + h.innerHTML = "giItT1WQy@!-/#"; + h.style.position = "absolute"; + h.style.left = "-10000px"; + h.style.top = "-10000px"; + h.style.fontSize = "300px"; + h.style.fontFamily = "sans-serif"; + h.style.fontVariant = "normal"; + h.style.fontStyle = "normal"; + h.style.fontWeight = "normal"; + h.style.letterSpacing = "0"; + document.body.appendChild(h); + var k = h.offsetWidth; + h.style.fontFamily = c; + var l; + e() || (l = setInterval(e, 50)); + })(b[c]); + } +}; +window.requestAnimFrame = function() { + return window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || function(b) { + window.setTimeout(b, 1E3 / 60); }; - a.BlockStatement = function(b) { - console.log("BlockStatement component", b); - this._blockStatmentIndex = 0; - this._blockStatments = []; - var a = {}; - b = b.body; - for (var c in b) { - var e = b[c]; - console.log("BlockStatement body", e, "i", c); - e = this[e.type](e); - console.log("BlockStatement bodyData", e, "i", c); - if (e.declarations) { - console.log("BlockStatement statements type params bodyData", c, e); - var e = e.declarations, f; - for (f in e) { - var g = e[f]; - g.init.type && (a.type = g.init.type); - g.init.params && (console.log("BlockStatement params", g.init.params), a.params = g.init.params); - console.log("BlockStatement structure", a, "j", f); - } - } else { - 0 == this._blockStatmentIndex && this._blockStatments.push(e); +}(); +Entry.isMobile = function() { + if (Entry.device) { + return "tablet" === Entry.device; + } + var b = window.platform; + if (b && b.type && ("tablet" === b.type || "mobile" === b.type)) { + return Entry.device = "tablet", !0; + } + Entry.device = "desktop"; + return !1; +}; +Entry.Utils.convertMouseEvent = function(b) { + return b.originalEvent && b.originalEvent.touches ? b.originalEvent.touches[0] : b; +}; +Entry.Utils.convertIntToHex = function(b) { + return b.toString(16).toUpperCase(); +}; +Entry.Utils.hasSpecialCharacter = function(b) { + return /!|@|#|\$|%|\^|&|\*|\(|\)|\+|=|-|\[|\]|\\|\'|;|,|\.|\/|{|}|\||\"|:|<|>|\?/g.test(b); +}; +Entry.Model = function(b, a) { + var d = Entry.Model; + d.generateSchema(b); + d.generateSetter(b); + d.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 c in b) { + (function(c) { + a.data[c] = b[c]; + Object.defineProperty(a, c, {get:function() { + return a.data[c]; + }}); + })(c); } + a._toJSON = this._toJSON; } - a.statements = [this._blockStatments]; - console.log("BlockStatement result", a); - this._blockStatmentIndex++; - return a; }; - a.IfStatement = function(b) { - console.log("IfStatement component", b); - var a = {}, c = [], e = [], f = [], g = [], h = b.test, k = b.alternate, l = b.consequent; - b = this.getBlockType(null == k ? "if %1:\n$1" : "if %1:\n$1\nelse:\n$2"); - if (null != h) { - var m = Entry.block[b].params; - console.log("IfStatement paramsMeta", m); - c = []; - h.type = "Literal"; - m = m[0]; - h = "Indicator" == m.type ? null : this[h.type](m, h); - c.push(h); - } - if (null != l) { - for (var n in l.body) { - if (h = l.body[n]) { - h = this[h.type](h), console.log("IfStatement consequent bodyData", h), e.push(h); - } - } - } - if (null != k) { - for (n in k.body) { - if (h = k.body[n]) { - h = this[h.type](h), console.log("IfStatement alternate bodyData", h), f.push(h); - } - } - } - 0 != e.length && g.push(e); - 0 != f.length && g.push(f); - a.type = b; - 0 != c.length && (a.params = c); - 0 != g.length && (a.statements = g); - console.log("IfStatement result", a); - return a; + b.generateSetter = function(a) { + a.set = this.set; }; - a.VariableDeclaration = function(b) { - console.log("VariableDeclaration component", b); - var a = {}, c = []; - b = b.declarations; - for (var e in b) { - var f = b[e], f = this[f.type](f); - console.log("VariableDeclaration declarationData", f); - c.push(f); + b.set = function(a, b) { + var c = {}, e; + for (e in this.data) { + void 0 !== a[e] && (a[e] === this.data[e] ? delete a[e] : (c[e] = this.data[e], this.data[e] = a[e] instanceof Array ? a[e].concat() : a[e])); } - a.declarations = c; - console.log("VariableDeclaration result", a); - return a; + b || this.notify(Object.keys(a), c); }; - a.VariableDeclarator = function(b) { - console.log("VariableDeclarator component", b); - var a = {}, c = b.id, e = this[c.type](c); - console.log("VariableDeclarator idData", e); - b = b.init; - b = this[b.type](b); - console.log("VariableDeclarator initData", b); - a.id = c; - a.init = b; - console.log("VariableDeclarator result", a); - return a; + b.generateObserve = function(a) { + a.observers = []; + a.observe = this.observe; + a.unobserve = this.unobserve; + a.notify = this.notify; }; - a.BreakStatement = function(b) { - console.log("BreakStatement component", b); - b = {}; - var a = this.getBlockType("break"); - b.type = a; - console.log("BreakStatement result", b); - return b; + b.observe = function(a, b, c, e) { + c = new Entry.Observer(this.observers, a, b, c); + if (!1 !== e) { + a[b]([]); + } + return c; }; - a.UnaryExpression = function(b) { - console.log("UnaryExpression component", b); - var a = []; - b.prefix && (b = b.operator.concat(b.argument.value), a.push(b)); - result.params = a; - console.log("UnaryExpression result", result); - return result; + b.unobserve = function(a) { + a.destroy(); }; - a.LogicalExpression = function(b) { - console.log("LogicalExpression component", b); - var a = {}, c = String(b.operator); - switch(c) { - case "&&": - var e = "%1 and %3"; - break; - case "||": - e = "%1 or %3"; - break; - default: - e = "%1 and %3"; + b.notify = function(a, b) { + "string" === typeof a && (a = [a]); + var c = this; + c.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:c, oldValue:b[a]}; + })); + } + }); + }; + b._toJSON = function() { + var a = {}, b; + for (b in this.data) { + a[b] = this.data[b]; } - var e = this.getBlockType(e), f = Entry.block[e].params; - console.log("LogicalExpression paramsMeta", f); - var g = [], c = b.left; - c.type ? ("Literal" == c.type ? (c = this[c.type](f[0], c), console.log("LogicalExpression left Literal param", c)) : c = this[c.type](c), c && g.push(c), console.log("LogicalExpression left param", c)) : (c = b.left, this[c.type](c)); - c = String(b.operator); - console.log("LogicalExpression operator", c); - c && (c = Entry.TextCodingUtil.prototype.logicalExpressionConvert(c), g.push(c)); - c = b.right; - c.type ? ("Literal" == c.type ? (c = this[c.type](f[2], c), console.log("LogicalExpression right Literal param", c)) : c = this[c.type](c), c && g.push(c), console.log("LogicalExpression right param", c)) : (c = b.right, this[c.type](c)); - a.type = e; - a.params = g; - console.log("LogicalExpression result", a); return a; }; - a.BinaryExpression = function(b) { - console.log("BinaryExpression component", b); - var a = {params:[]}, c = String(b.operator); - console.log("BinaryExpression operator", c); - if (c) { - var e = "(%1 %2 %3)" +})(Entry.Model); +Entry.Func = function(b) { + this.id = b ? b.id : Entry.generateHash(); + this.content = b ? new Entry.Code(b.content) : new Entry.Code([[{type:"function_create", copyable:!1, deletable:!1, x:40, y:40}]]); + this.blockMenuBlock = this.block = null; + this.hashMap = {}; + this.paramMap = {}; + Entry.generateFunctionSchema(this.id); + if (b) { + b = this.content._blockMap; + for (var a in b) { + Entry.Func.registerParamBlock(b[a].type); } - console.log("BinaryExpression syntax", e); - e = this.getBlockType(e); - console.log("BinaryExpression type", e); - var f = Entry.block[e].params; - console.log("BinaryExpression paramsMeta", f); - var g = [], c = b.left; - c.type ? ("Literal" == c.type ? (c = this[c.type](f[0], c), console.log("BinaryExpression left Literal param", c)) : c = this[c.type](c), c && g.push(c), console.log("BinaryExpression left param", c)) : (c = b.left, this[c.type](c)); - if (c = String(b.operator)) { - console.log("BinaryExpression operator", c), (c = Entry.TextCodingUtil.prototype.binaryOperatorConvert(c)) && g.push(c); + Entry.Func.generateWsBlock(this); + } + Entry.Func.registerFunction(this); + Entry.Func.updateMenu(); +}; +Entry.Func.threads = {}; +Entry.Func.registerFunction = function(b) { + if (Entry.playground) { + var a = Entry.playground.mainWorkspace; + a && (this._targetFuncBlock = a.getBlockMenu().getCategoryCodes("func").createThread([{type:"func_" + b.id}]), b.blockMenuBlock = this._targetFuncBlock); + } +}; +Entry.Func.executeFunction = function(b) { + var a = this.threads[b]; + if (a = Entry.Engine.computeThread(a.entity, a)) { + return this.threads[b] = a, !0; + } + delete this.threads[b]; + return !1; +}; +Entry.Func.clearThreads = function() { + this.threads = {}; +}; +Entry.Func.prototype.init = function(b) { + this.id = b.id; + this.content = Blockly.Xml.textToDom(b.content); + this.block = Blockly.Xml.textToDom("" + b.block + "").childNodes[0]; +}; +Entry.Func.prototype.destroy = function() { + this.blockMenuBlock.destroy(); +}; +Entry.Func.edit = function(b) { + this.cancelEdit(); + this.targetFunc = b; + this.initEditView(b.content); + this.bindFuncChangeEvent(); + this.updateMenu(); +}; +Entry.Func.initEditView = function(b) { + this.menuCode || this.setupMenuCode(); + var a = Entry.playground.mainWorkspace; + a.setMode(Entry.Workspace.MODE_OVERLAYBOARD); + a.changeOverlayBoardCode(b); + b.recreateView(); + a.changeOverlayBoardCode(b); + b.view.board.alignThreads(); + 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, d = [], d = b.split(" "), c = ""; + 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_ && (c += f.fieldRow[0].text_, c += " "); + } + c = c.trim(); + if (c === this.srcFName && this.srcFName.split(" ").length == d.length) { + for (c = 0;c < g.length;c++) { + if (f = g[c], 0 < f.fieldRow.length && f.fieldRow[0] instanceof Blockly.FieldLabel && void 0 != f.fieldRow[0].text_) { + if (void 0 === d[a]) { + g.splice(c, 1); + break; + } else { + f.fieldRow[0].text_ = d[a]; + } + a++; + } + } + } + c = ""; + a = 0; } - c = b.right; - c.type ? ("Literal" == c.type ? (c = this[c.type](f[2], c), console.log("BinaryExpression right Literal param", c)) : c = this[c.type](c), c && g.push(c), console.log("BinaryExpression right param", c)) : (c = b.right, this[c.type](c)); - console.log("BinaryExpression params", g); - a.type = e; - a.params = g; - console.log("BinaryExpression result", a); - return a; - }; - a.getBlockType = function(b) { - return this.blockSyntax[b]; - }; - a.FunctionDeclaration = function(b) { - console.log("FunctionDeclaration component", b); - console.log("FunctionDeclaration result", void 0); - return b; - }; - a.RegExp = function(b) { - console.log("RegExp", b); - console.log("RegExp result", void 0); - return b; - }; - a.Function = function(b) { - console.log("Function", b); - console.log("Function result", void 0); - return b; - }; - a.EmptyStatement = function(b) { - console.log("EmptyStatement", b); - console.log("EmptyStatement result", void 0); - return b; - }; - a.DebuggerStatement = function(b) { - console.log("DebuggerStatement", b); - console.log("DebuggerStatement result", void 0); - return b; - }; - a.WithStatement = function(b) { - console.log("WithStatement", b); - console.log("WithStatement result", void 0); - return b; - }; - a.ReturnStaement = function(b) { - console.log("ReturnStaement", b); - console.log("ReturnStaement result", void 0); - return b; - }; - a.LabeledStatement = function(b) { - console.log("LabeledStatement", b); - console.log("LabeledStatement result", void 0); - return b; - }; - a.BreakStatement = function(b) { - console.log("BreakStatement", b); - console.log("BreakStatement result", void 0); - return b; - }; - a.ContinueStatement = function(b) { - console.log("ContinueStatement", b); - console.log("ContinueStatement result", void 0); - return b; - }; - a.SwitchStatement = function(b) { - console.log("SwitchStatement", b); - console.log("SwitchStatement result", void 0); - return b; - }; - a.SwitchCase = function(b) { - console.log("SwitchCase", b); - console.log("SwitchCase result", void 0); - return b; - }; - a.ThrowStatement = function(b) { - console.log("ThrowStatement", b); - console.log("ThrowStatement result", void 0); - return b; - }; - a.TryStatement = function(b) { - console.log("TryStatement", b); - console.log("TryStatement result", void 0); - return b; - }; - a.CatchClause = function(b) { - console.log("CatchClause", b); - console.log("CatchClause result", void 0); - return b; - }; - a.DoWhileStatement = function(b) { - console.log("DoWhileStatement", b); - console.log("DoWhileStatement result", void 0); - return b; - }; - a.ForInStatement = function(b) { - console.log("ForInStatement", b); - console.log("ForInStatement result", void 0); - return b; - }; - a.FunctionDeclaration = function(b) { - console.log("FunctionDeclaration", b); - console.log("FunctionDeclaration result", void 0); - return b; - }; - a.ThisExpression = function(b) { - console.log("ThisExpression", b); - console.log("ThisExpression result", void 0); - return b; - }; - a.ArrayExpression = function(b) { - console.log("ArrayExpression", b); - console.log("ArrayExpression result", void 0); - return b; - }; - a.ObjectExpression = function(b) { - console.log("ObjectExpression", b); - console.log("ObjectExpression result", void 0); - return b; - }; - a.Property = function(b) { - console.log("Property", b); - console.log("Property result", void 0); - return b; - }; - a.FunctionExpression = function(b) { - console.log("FunctionExpression", b); - console.log("FunctionExpression result", void 0); - return b; - }; - a.UpdateExpression = function(b) { - console.log("UpdateExpression", b); - console.log("UpdateExpression result", void 0); - return b; - }; - a.ConditionalExpression = function(b) { - console.log("ConditionalExpression", b); - console.log("ConditionalExpression result", void 0); - return b; - }; - a.NewExpression = function(b) { - console.log("NewExpression", b); - console.log("NewExpression result", void 0); - return b; - }; - a.SequenceExpression = function(b) { - console.log("SequenceExpression", b); - console.log("SequenceExpression result", void 0); - return b; + } + a = Blockly.Xml.workspaceToDom(Blockly.mainWorkspace); + Blockly.mainWorkspace.clear(); + Blockly.Xml.domToWorkspace(Blockly.mainWorkspace, 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 d in Entry.variableContainer.functions_) { + a = Entry.variableContainer.functions_[d], 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.Func.syncFunc = function() { + var b = Entry.Func; + if (b.targetFunc) { + var a = b.workspace.topBlocks_[0].toString(), d = b.workspace.topBlocks_.length; + (b.fieldText != a || b.workspaceLength != d) && 1 > Blockly.Block.dragMode_ && (b.updateMenu(), b.fieldText = a, b.workspaceLength = d); + } +}; +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.Func.requestParamBlock = function(b) { + var a = Entry.generateHash(), d; + switch(b) { + case "string": + d = Entry.block.function_param_string; + break; + case "boolean": + d = Entry.block.function_param_boolean; + break; + default: + return null; + } + a = b + "Param_" + a; + b = Entry.Func.createParamBlock(a, d, b); + Entry.block[a] = b; + return a; +}; +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.Func.createParamBlock = function(b, a, d) { + var c = function() { }; -})(Entry.PyBlockAssembler.prototype); -Entry.PyToBlockParserTemp = function(a) { - this._assembler = new Entry.PyBlockAssembler(a); + d = "string" === d ? "function_param_string" : "function_param_boolean"; + c.prototype = a; + c = new c; + c.changeEvent = new Entry.Event; + c.template = Lang.template[d]; + return Entry.block[b] = c; }; -(function(a) { - a.Program = function(b) { - var a = [], c; - for (c in b) { - if ("Program" != b[c].type) { - return; - } - var e = [], f = b[c].body; - console.log("nodes", f); - for (c in f) { - var g = f[c], g = this[g.type](g); - console.log("checkitout", g); - g = this._assembler[g.type](g); - e.push(g); - } - console.log("thread", e); - a.push(e); +Entry.Func.updateMenu = function() { + if (Entry.playground && Entry.playground.mainWorkspace) { + var b = Entry.playground.mainWorkspace.getBlockMenu(); + this.targetFunc ? (this.menuCode || this.setupMenuCode(), b.banClass("functionInit"), b.unbanClass("functionEdit")) : (b.unbanClass("functionInit"), b.banClass("functionEdit")); + b.reDraw(); + } +}; +Entry.Func.prototype.edit = function() { + Entry.Func.isEdit || (Entry.Func.isEdit = !0, Entry.Func.svg ? this.parentView.appendChild(this.svg) : Entry.Func.initEditView()); +}; +Entry.Func.generateBlock = function(b) { + b = Entry.block["func_" + b.id]; + var a = {template:b.template, params:b.params}, d = /(%\d)/mi, c = b.template.split(d), e = "", f = 0, g = 0, h; + for (h in c) { + var k = c[h]; + d.test(k) ? (k = Number(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.Func.prototype.generateBlock = function(b) { + b = Entry.Func.generateBlock(this); + this.block = b.block; + this.description = b.description; +}; +Entry.Func.generateWsBlock = function(b) { + this.unbindFuncChangeEvent(); + b = b ? b : this.targetFunc; + for (var a = b.content.getEventMap("funcDef")[0].params[0], d = 0, c = 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 + " " + (d ? d : "")}); + g[k.type] = !1; + h[k.type] = d + c; + d++; + e.push({type:"Block", accept:"boolean"}); + f += " %" + (d + c); + break; + case "function_field_string": + Entry.Mutator.mutate(k.type, {template:Lang.Blocks.FUNCTION_character_variable + " " + (c ? c : "")}), g[k.type] = !1, h[k.type] = d + c, c++, f += " %" + (d + c), e.push({type:"Block", accept:"string"}); } - return a; - }; - a.Identifier = function(b) { - console.log("Identifier", b); - return {type:b.type, name:b.name}; - }; - a.FunctionDeclaration = function(b) { - console.log("FunctionDeclaration", b); - var a = this[b.id.type](b.id); - return {type:b.type, id:a}; + a = a.getOutputBlock(); + } + d++; + f += " %" + (d + c); + 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.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($('')); }; - a.Literal = function(b) { - console.log("Literal", b); - console.log("typeof node at Literal", typeof b.value); - var a; - "string" === typeof b.value ? a = b.value : "boolean" === typeof b.value ? a = b.value : "number" === typeof b.value ? a = b.value : "RegExp" === typeof b.value ? (a = this[typeof b.value](b), a = a.regex.pattern) : a = null; - console.log("value", a); - return {type:b.type, value:a}; - }; - a.RegExp = function(b) { - console.log("RegExp", b); - return {regex:b.regex}; - }; - a.Function = function(b) { - console.log("Function", b); - var a = this[b.id](b), c = [], e; - for (e in b.params) { - c.push(b.params[e]); - } - b = this[b.body](b); - return {id:a, params:c, body:b}; - }; - a.ExpressionStatement = function(b) { - var a = this[b.expression.type](b.expression); - return {type:b.type, expression:a}; - }; - a.BlockStatement = function(b) { - console.log("BlockStatement", b); - var a = [], c; - for (c in b.body) { - var e = b.body[c]; - console.log("BlockStatement statement", e); - e = this[e.type](e); - console.log("BlockStatement body", e); - a.push(e); + 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 = [], c; + for (c in a) { + var e = this.generatePortView(a[c], "_svgGroup"); + this._portViews[c] = e; + b.push(e); } - console.log("bodies", a); - return {type:b.type, body:a}; - }; - a.EmptyStatement = function(b) { - console.log("EmptyStatement", b); - return {type:b.type}; - }; - a.DebuggerStatement = function(b) { - console.log("DebuggerStatement", b); - return {type:b.type}; - }; - a.WithStatement = function(b) { - console.log("WithStatement", b); - var a = this[b.object.type](b.object), c = this[b.body.type](b.body); - return {type:b.type, object:a, body:c}; - }; - a.ReturnStaement = function(b) { - console.log("ReturnStaement", b); - var a; - a = null === b.argument ? null : this[b.argument.type](b.argument); - return {type:b.type, argument:a}; + 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(); }; - a.LabeledStatement = function(b) { - console.log("LabeledStatement", b); - var a = this[b.label.type](b.label), c = this[b.body.type](b.body); - return {type:b.type, label:a, body:c}; + 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()); }; - a.BreakStatement = function(b) { - console.log("BreakStatement", b); - var a; - console.log("node.label", b.label); - b.label && null !== b.label ? (console.log("node.label2", b.label), a = this[b.label.type](b.label)) : (console.log("node.lable1", b.label), a = null); - console.log("label", a); - return {type:b.type, label:a}; + b.setHwmonitor = function(a) { + this._hwmodule = a; }; - a.ContinueStatement = function(b) { - console.log("ContinueStatement", b); - var a; - a = null === b.label ? null : this[b.label.type](b.label); - return {type:b.type, label:a}; + b.changeMode = function(a) { + "both" == this._hwModule.monitorTemplate.mode ? this.toggleMode("list") : "list" == this._hwModule.monitorTemplate.mode && this.toggleMode("both"); }; - a.IfStatement = function(b) { - console.log("IfStatement", b); - var a = this[b.test.type](b.test), c = {body:[]}; - if (null === b.alternate) { - c = null; - } else { - for (var e in b.alternate.body) { - var f = b.alternate.body[e], g = this[f.type](f); - c.body.push(g); - } - } - g = {body:[]}; - for (e in b.consequent.body) { - f = b.consequent.body[e], f = this[f.type](f), g.body.push(f); + b.addPortEle = function(a, b) { + if ("object" != typeof b) { + return a; } - console.log("alternate", c); - console.log("consequent", g); - return {type:b.type, test:a, consequent:g, alternate:c}; - }; - a.SwitchStatement = function(b) { - console.log("SwitchStatement", b); - var a = this[b.discriminant.type](b.discriminant), c = [], e; - for (e in b.cases) { - var f = b.cases[e], f = this[f.type](f); - c.push(f); + for (var c in b) { + a[c] = b[c]; } - return {type:b.type, discriminant:a, cases:c}; + return a; }; - a.SwitchCase = function(b) { - console.log("SwitchCase", b); - var a; - a = null === b.test ? null : this[b.test.type](b.test); - for (var c in b.consequent) { - b = this[statment.type](statment), (void 0).push(b); + b.removePortEle = function(a, b) { + if ("object" != typeof b) { + return a; } - return {test:a, consequent:void 0}; - }; - a.ThrowStatement = function(b) { - console.log("ThrowStatement", b); - var a = this[b.argument.type](b.argument); - return {type:b.type, argument:a}; - }; - a.TryStatement = function(b) { - console.log("TryStatement", b); - var a = this[b.block.type](b.block), c; - c = null === b.handler ? null : this[b.handler.type](b.handler); - var e; - e = null === b.finalizer ? null : this[b.finalizer.type](b.finalizer); - return {type:b.type, block:a, handler:c, finalizer:e}; - }; - a.CatchClause = function(b) { - console.log("CatchClause", b); - var a = b.param; - b = this[b.body.type](b.body); - return {param:a, body:b}; - }; - a.WhileStatement = function(b) { - console.log("WhileStatement", b); - var a = this[b.test.type](b.test), c = this[b.body.type](b.body); - console.log("WhileStatement test", a); - console.log("WhileStatement body", c); - return {type:b.type, test:a, body:c}; - }; - a.DoWhileStatement = function(b) { - console.log("DoWhileStatement", b); - var a; - a = this[b.init.type](b.init); - var c; - c = null === b.test ? null : this[b.test.type](b.test); - var e; - e = null === b.update ? null : this[b.update.type](b.update); - var f = this[b.body.type](b.body); - return {type:b.type, init:a, test:c, update:e, body:f}; - }; - a.ForStatement = function(b) { - console.log("ForStatement", b); - var a; - if (null === b.init) { - a = null; - } else { - this[b.init.type](b.init); + for (var c in b) { + delete a[c]; } - var c; - c = null === b.test ? null : this[b.test.type](b.test); - var e; - e = null === b.update ? null : this[b.update.type](b.update); - var f = this[b.body.type](b.body); - console.log("ForStatement body", f); - return {type:b.type, init:a, test:c, update:e, body:f}; + return a; }; - a.ForInStatement = function(b) { - console.log("ForInStatement", b); - var a; - a = this[b.left.type](b.left); - var c = this[b.right.type](b.right), e = this[b.body.type](b.body); - return {type:b.type, left:a, right:c, body:e}; - }; - a.FunctionDeclaration = function(b) { - console.log("FunctionDeclaration", b); - return {id:this[b.id.type](b.id)}; - }; - a.VariableDeclaration = function(b) { - console.log("VariableDeclaration", b); - var a = [], c; - for (c in b.declarations) { - var e = b.declarations[c], e = this[e.type](e); - console.log("declaration", e); - a.push(e); + 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 = [], c; + for (c in a) { + var e = this.generatePortView(a[c], "_svglistGroup"); + this._listPortViews[c] = e; + b.push(e); } - console.log("VariableDeclaration declarations", a); - return {type:b.type, declarations:a, kind:"var"}; - }; - a.VariableDeclarator = function(b) { - console.log("VariableDeclarator", b); - var a = this[b.id.type](b.id), c; - c = null === b.init ? null : this[b.init.type](b.init); - console.log("id", a); - console.log("init", c); - return {type:b.type, id:a, init:c}; + var f = this._portMapList; + b.map(function(a) { + f.n.push(a); + }); + this.resizeList(); }; - a.ThisExpression = function(b) { - console.log("ThisExpression", b); - return {type:b.type}; + b.generatePortView = function(a, b) { + var c = this[b].elem("g"); + c.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 = c.elem("rect").attr({x:0, y:0, width:150, height:22, rx:4, ry:4, fill:"#fff", stroke:"#a0a1a1"}), g = c.elem("text").attr({x:4, y:12, fill:"#000", "class":"hwComponentName", "alignment-baseline":"central"}); + g.textContent = a.name; + g = g.getComputedTextLength(); + c.elem("rect").attr({x:g + 8, y:2, width:30, height:18, rx:9, ry:9, fill:"input" === a.type ? "#00979d" : "#A751E3"}); + var h = c.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:c, 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; }; - a.ArrayExpression = function(b) { - console.log("ArrayExpression", b); - var a; - if (null === b.elements) { - a = null; + b.update = function() { + var a = Entry.hw.portData, b = Entry.hw.sendQueue, c = this._hwModule.monitorTemplate.mode, e = this._hwModule.monitorTemplate.keys || [], f = []; + if ("list" == c) { + f = this._listPortViews; } else { - for (var c in b.elements) { - var e = b.elements[c], e = this[e.type](e); - a.push(e); + if ("both" == c) { + if (f = this._listPortViews, this._portViews) { + for (var g in this._portViews) { + f[g] = this._portViews[g]; + } + } + } else { + f = this._portViews; } } - return {type:b.type, elements:a}; - }; - a.ObjectExpression = function(b) { - console.log("ObjectExpression", b); - for (var a in b.properties) { - var c = b.properties[a], c = this[c.type](c); - (void 0).push(c); - } - return {type:b.type, properties:void 0}; - }; - a.Property = function(b) { - console.log("Property", b); - var a = this[b.key.type](b.key), c = this[b.value.type](b.value); - return {type:b.type, key:a, value:c, kind:b.kind}; - }; - a.FunctionExpression = function(b) { - console.log("FunctionExpression", b); - return {type:b.type}; - }; - a.UnaryExpression = function(b) { - console.log("UnaryExpression", b); - var a; - switch(b.operator) { - case "-": - a = b.operator; - break; - case "+": - a = b.operator; - break; - case "!": - a = b.operator; - break; - case "~": - a = b.operator; - break; - case "typeof": - a = b.operator; - break; - case "void": - a = b.operator; - break; - case "delete": - a = b.operator; - break; - default: - a = null; - } - var c = b.prefix, e = this[b.argument.type](b.argument); - return {type:b.type, operator:a, prefix:c, argument:e}; - }; - a.UpdateExpression = function(b) { - console.log("UpdateExpression", b); - var a; - switch(b.operator) { - case "++": - a = b.operator; - break; - case "--": - a = b.operator; - break; - default: - a = null; + if (b) { + for (g in b) { + 0 != b[g] && f[g] && (f[g].type = "output"); + } } - var c = this[b.argument.type](b.argument); - return {type:b.type, operator:a, prefix:b.prefix, argument:c}; - }; - a.BinaryExpression = function(b) { - console.log("BinaryExpression", b); - var a; - switch(b.operator) { - case "==": - a = b.operator; - break; - case "!=": - a = b.operator; - break; - case "===": - a = b.operator; - break; - case "!==": - a = b.operator; - break; - case "<": - a = b.operator; - break; - case "<=": - a = b.operator; - break; - case ">": - a = b.operator; - break; - case ">=": - a = b.operator; - break; - case "<<": - a = b.operator; - break; - case ">>": - a = b.operator; - break; - case ">>>": - a = b.operator; - break; - case "+": - a = b.operator; - break; - case "-": - a = b.operator; - break; - case "*": - a = b.operator; - break; - case "/": - a = b.operator; - break; - case "%": - a = b.operator; - break; - case "|": - a = b.operator; - break; - case "^": - a = b.operator; - break; - case "|": - a = b.operator; - break; - case "&": - a = b.operator; - break; - case "in": - a = b.operator; - break; - case "instanceof": - a = b.operator; - break; - default: - a = null; + for (var h in f) { + if (c = f[h], "input" == c.type) { + var k = a[h]; + 0 < e.length && $.each(e, function(a, b) { + if ($.isPlainObject(k)) { + k = k[b] || 0; + } else { + return !1; + } + }); + c.value.textContent = k ? k : 0; + c.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; + } + }), c.value.textContent = k ? k : 0, c.group.getElementsByTagName("rect")[1].attr({fill:"#A751E3"}); + } } - var c = this[b.left.type](b.left), e = this[b.right.type](b.right); - return {type:b.type, operator:a, left:c, right:e}; }; - a.AssignmentExpression = function(b) { - console.log("AssignmentExpression", b); - var a; - switch(b.operator) { - case "=": - a = b.operator; - break; - case "+=": - a = b.operator; - break; - case "-=": - a = b.operator; - break; - case "*=": - a = b.operator; - break; - case "/=": - a = b.operator; - break; - case "%=": - a = b.operator; - break; - case "<<=": - a = b.operator; - break; - case ">>=": - a = b.operator; - break; - case "|=": - a = b.operator; - break; - case "^=": - a = b.operator; - break; - case "&=": - a = b.operator; - break; - default: - a = null; + b.resize = function() { + this.hwView && this.hwView.attr({transform:"scale(" + this.scale + ")"}); + if (this.svgDom) { + var a = this.svgDom.get(0).getBoundingClientRect() } - var c; - c = b.left; - var e = this[b.right.type](b.right); - return {type:b.type, operator:a, left:c, right:e}; + 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()); }; - a.LogicalExpression = function(b) { - console.log("LogicalExpression", b); - var a; - switch(b.operator) { - case "||": - a = b.operator; - break; - case "&&": - a = b.operator; - break; - default: - a = null; - } - var c = this[b.left.type](b.left), e = this[b.right.type](b.right); - return {type:b.type, operator:a, left:c, right:e}; + 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(); }; - a.MemberExpression = function(b) { - console.log("MemberExpression", b); - var a = this[b.object.type](b.object), c = this[b.property.type](b.property), e = b.computed; - console.log("object", a); - console.log("property", c); - return {type:b.type, object:a, property:c, computed:e}; + 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, c = 0;c < a.length;c++) { + a[c].group.attr({transform:"translate(" + this._template.width * (c / 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, c) { + 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 = c; + 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)); }; - a.ConditionalExpression = function(b) { - console.log("ConditionalExpression", b); - var a = this[b.callee.type](b.callee), c; - for (c in b.arguments) { - var e = b.arguments[c], e = this[e.type](e); - (void 0).push(e); + b._alignNS = function(a, b, c) { + 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(), m = e, n = f, q = c; + 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, m); + this._movePort(l, f, b, n); + h -= k.width + l.width + 10; + b += q; } - return {type:b.type, callee:a, arguments:void 0}; + a.length && this._movePort(a[0], (f + e - a[0].width) / 2, b, 100); }; - a.CallExpression = function(b) { - console.log("CallExpression", b); - var a = this[b.callee.type](b.callee), c = [], e; - for (e in b.arguments) { - var f = b.arguments[e], f = this[f.type](f); - c.push(f); + b._alignNSList = function(a, b) { + var c = 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, m = 0, e = 0;e < a.length;e++) { + l = a[e], e != a.length - 1 && (m = a[e + 1]), g += l.width, lP = initX, k = initY + 30 * f, l.group.attr({transform:"translate(" + lP + "," + k + ")"}), initX += l.width + 10, g > c - (l.width + m.width / 2.2) && (f += 1, initX = h, g = 0); } - console.log("callee", a); - console.log("arguments", c); - return {type:b.type, callee:a, arguments:c}; }; - a.NewExpression = function(b) { - console.log("NewExpression", b); - return {type:b.type}; + b._movePort = function(a, b, c, 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 + "," + c + "L" + g + "," + h : "M" + (b + e) / 2 + "," + c + "l0," + (h > c ? 28 : -3) + "H" + g + "L" + g + "," + h) : b = b < g && g < e ? "m" + g + "," + c + "L" + g + "," + h : "m" + (e + b) / 2 + "," + c + "l0," + (h > c ? 28 : -3) + "H" + g + "L" + g + "," + h; + a.group.attr({transform:"translate(" + f + "," + c + ")"}); + a.path.attr({d:b}); }; - a.SequenceExpression = function(b) { - console.log("SequenceExpression", b); - for (var a in b.expressions) { - var c = b.expressions[a], c = this[c.type](c); - (void 0).push(c); +})(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 = {"1.1":Entry.Arduino, "1.9":Entry.ArduinoExt, "1.2":Entry.SensorBoard, "1.3":Entry.CODEino, "1.4":Entry.joystick, "1.5":Entry.dplay, "1.6":Entry.nemoino, "1.7":Entry.Xbot, "1.8":Entry.ardublock, "1.A":Entry.Cobl, "2.4":Entry.Hamster, "2.5":Entry.Albert, "3.1":Entry.Bitbrick, "4.2":Entry.Arduino, "5.1":Entry.Neobot, "7.1":Entry.Robotis_carCont, "7.2":Entry.Robotis_openCM70, "8.1":Entry.Arduino, "10.1":Entry.Roborobo_Roduino, "10.2":Entry.Roborobo_SchoolKit, "12.1":Entry.EV3, "B.1":Entry.Codestar}; +}; +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, d; + this.connected = !1; + this.connectTrial++; + if (-1 < location.protocol.indexOf("https")) { + d = 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 (c) { + } + try { + d = new WebSocket("wss://hardware.play-entry.org:23518"); + } catch (c) { + } + } + d.binaryType = "arraybuffer"; + d.onopen = function() { + b.socketType = "WebSocketSecurity"; + b.initHardware(d); + }; + d.onmessage = function(a) { + a = JSON.parse(a.data); + b.checkDevice(a); + b.updatePortData(a); + }; + d.onclose = function() { + "WebSocketSecurity" === b.socketType && (this.socket = null, b.initSocket()); + }; + Entry.dispatchEvent("hwChanged"); + } + } catch (c) { + } +}; +p.retryConnect = function() { + this.connectTrial = 0; + this.initSocket(); +}; +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.setDigitalPortValue = function(b, a) { + this.sendQueue[b] = a; + this.removePortReadable(b); +}; +p.getAnalogPortValue = function(b) { + return this.connected ? this.portData["a" + b] : 0; +}; +p.getDigitalPortValue = function(b) { + if (!this.connected) { + return 0; + } + 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, d; + for (d in this.sendQueue.readablePorts) { + if (this.sendQueue.readablePorts[d] == b) { + a = !0; + break; + } + } + a || this.sendQueue.readablePorts.push(b); +}; +p.removePortReadable = function(b) { + if (this.sendQueue.readablePorts || Array.isArray(this.sendQueue.readablePorts)) { + var a, d; + for (d in this.sendQueue.readablePorts) { + if (this.sendQueue.readablePorts[d] == b) { + a = Number(d); + break; + } } - return {type:b.type, expressions:void 0}; + this.sendQueue.readablePorts = void 0 != a ? this.sendQueue.readablePorts.slice(0, a).concat(this.sendQueue.readablePorts.slice(a + 1, this.sendQueue.readablePorts.length)) : []; + } +}; +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 && "hw" == Entry.propertyPanel.selected && 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.11_Setup.exe", "_blank").focus(); +}; +p.downloadGuide = function() { + window.open("http://download.play-entry.org/data/%EC%97%94%ED%8A%B8%EB%A6%AC-%ED%95%98%EB%93%9C%EC%9B%A8%EC%96%B4%EC%97%B0%EA%B2%B0%EB%A7%A4%EB%89%B4%EC%96%BC_16_08_17.hwp", "_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(b) { + void 0 !== b.company && (b = [Entry.Utils.convertIntToHex(b.company), ".", Entry.Utils.convertIntToHex(b.model)].join(""), 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.banHW = function() { + var b = this.hwInfo, a; + for (a in b) { + Entry.playground.mainWorkspace.blockMenu.banClass(b[a].name, !0); + } +}; +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(b) { + Entry.Model(this); + this.set(b); +}; +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; + this.background.graphics.beginFill("#ffffff").drawRect(-480, -240, 960, 480); + this.objectContainers = []; + this.selectedObjectContainer = null; + this.variableContainer = new createjs.Container; + this.dialogContainer = new createjs.Container; + this.selectedObject = null; + this.isObjectClick = !1; +}; +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; + createjs.Touch.enable(this.canvas); + this.canvas.enableMouseOver(10); + this.canvas.mouseMoveOutside = !0; + this.canvas.addChild(this.background); + this.canvas.addChild(this.variableContainer); + this.canvas.addChild(this.dialogContainer); + this.inputField = null; + this.initCoordinator(); + this.initHandle(); + this.mouseCoordinate = {x:0, y:0}; + if (Entry.isPhone()) { + b.ontouchstart = function(a) { + Entry.dispatchEvent("canvasClick", a); + Entry.stage.isClick = !0; + }, b.ontouchend = function(a) { + Entry.stage.isClick = !1; + Entry.dispatchEvent("canvasClickCanceled", a); + }; + } else { + var a = function(a) { + Entry.dispatchEvent("canvasClick", a); + Entry.stage.isClick = !0; + }; + b.onmousedown = a; + b.ontouchstart = a; + a = function(a) { + Entry.stage.isClick = !1; + Entry.dispatchEvent("canvasClickCanceled", a); + }; + b.onmouseup = a; + b.ontouchend = a; + $(document).click(function(a) { + Entry.stage.focused = "entryCanvas" === a.target.id ? !0 : !1; + }); + } + Entry.addEventListener("canvasClick", function(a) { + Entry.stage.isObjectClick = !1; + }); + Entry.windowResized.attach(this, function() { + Entry.stage.updateBoundRect(); + }); + $(window).scroll(function() { + Entry.stage.updateBoundRect(); + }); + 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), + a = -270 * ((a.pageY - b.top - document.body.scrollTop) / b.height - .5)); + Entry.stage.mouseCoordinate = {x:e.toFixed(1), y:a.toFixed(1)}; + Entry.dispatchEvent("stageMouseMove"); }; -})(Entry.PyToBlockParserTemp.prototype); -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_); + b.onmousemove = a; + b.ontouchmove = a; + b.onmouseout = function(a) { + Entry.dispatchEvent("stageMouseOut"); + }; + Entry.addEventListener("updateObject", function(a) { + Entry.engine.isState("stop") && Entry.stage.updateObject(); + }); + Entry.addEventListener("canvasInputComplete", function(a) { + try { + var b = Entry.stage.inputField.value(); + Entry.stage.hideInputField(); + if (b) { + var e = Entry.container; + e.setInputValue(b); + e.inputValue.complete = !0; + } + } catch (f) { + } + }); + this.initWall(); + this.render(); +}; +Entry.Stage.prototype.render = function() { + Entry.stage.timer && clearTimeout(Entry.stage.timer); + var b = (new Date).getTime(); + Entry.stage.update(); + 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.requestUpdateTwice ? Entry.requestUpdateTwice = !1 : Entry.requestUpdate = !1) : Entry.requestUpdate = !1; }; -Entry.Toast.prototype.warning = function(a, b, d) { - var c = Entry.createElement("div", "entryToast"); - c.addClass("entryToast"); - c.addClass("entryToastWarning"); - c.bindOnClick(function() { - Entry.toast.body_.removeChild(this); - }); - var e = Entry.createElement("div", "entryToast"); - e.addClass("entryToastTitle"); - e.innerHTML = a; - c.appendChild(e); - a = Entry.createElement("p", "entryToast"); - a.addClass("entryToastMessage"); - a.innerHTML = b; - c.appendChild(a); - this.toasts_.push(c); - this.body_.appendChild(c); - d || window.setTimeout(function() { - c.style.opacity = 1; - var b = setInterval(function() { - .05 > c.style.opacity && (clearInterval(b), c.style.display = "none", Entry.removeElement(c)); - c.style.opacity *= .9; - }, 20); - }, 1E3); +Entry.Stage.prototype.loadObject = function(b) { + var a = b.entity.object; + this.getObjectContainerByScene(b.scene).addChild(a); + this.canvas.update(); }; -Entry.Toast.prototype.success = function(a, b, d) { - var c = Entry.createElement("div", "entryToast"); - c.addClass("entryToast"); - c.addClass("entryToastSuccess"); - c.bindOnClick(function() { - Entry.toast.body_.removeChild(this); - }); - var e = Entry.createElement("div", "entryToast"); - e.addClass("entryToastTitle"); - e.innerHTML = a; - c.appendChild(e); - a = Entry.createElement("p", "entryToast"); - a.addClass("entryToastMessage"); - a.innerHTML = b; - c.appendChild(a); - this.toasts_.push(c); - this.body_.appendChild(c); - d || window.setTimeout(function() { - c.style.opacity = 1; - var b = setInterval(function() { - .05 > c.style.opacity && (clearInterval(b), c.style.display = "none", Entry.removeElement(c)); - c.style.opacity *= .9; - }, 20); - }, 1E3); +Entry.Stage.prototype.loadEntity = function(b) { + Entry.stage.getObjectContainerByScene(b.parent.scene).addChild(b.object); + this.sortZorder(); + Entry.requestUpdate = !0; }; -Entry.Toast.prototype.alert = function(a, b, d) { - var c = Entry.createElement("div", "entryToast"); - c.addClass("entryToast"); - c.addClass("entryToastAlert"); - c.bindOnClick(function() { - Entry.toast.body_.removeChild(this); - }); - var e = Entry.createElement("div", "entryToast"); - e.addClass("entryToastTitle"); - e.innerHTML = a; - c.appendChild(e); - a = Entry.createElement("p", "entryToast"); - a.addClass("entryToastMessage"); - a.innerHTML = b; - c.appendChild(a); - this.toasts_.push(c); - this.body_.appendChild(c); - d || window.setTimeout(function() { - c.style.opacity = 1; - var b = setInterval(function() { - .05 > c.style.opacity && (clearInterval(b), c.style.display = "none", Entry.toast.body_.removeChild(c)); - c.style.opacity *= .9; - }, 20); - }, 5E3); +Entry.Stage.prototype.unloadEntity = function(b) { + Entry.stage.getObjectContainerByScene(b.parent.scene).removeChild(b.object); + Entry.requestUpdate = !0; }; -Entry.TvCast = function(a) { - this.generateView(a); +Entry.Stage.prototype.loadVariable = function(b) { + var a = b.view_; + this.variables[b.id] = a; + this.variableContainer.addChild(a); + Entry.requestUpdate = !0; }; -p = Entry.TvCast.prototype; -p.init = function(a) { - this.tvCastHash = a; +Entry.Stage.prototype.removeVariable = function(b) { + this.variableContainer.removeChild(b.view_); + Entry.requestUpdate = !0; }; -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); +Entry.Stage.prototype.loadDialog = function(b) { + this.dialogContainer.addChild(b.object); }; -p.getView = function() { - return this.movieContainer; +Entry.Stage.prototype.unloadDialog = function(b) { + this.dialogContainer.removeChild(b.object); }; -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.Stage.prototype.sortZorder = function() { + for (var b = Entry.container.getCurrentObjects(), a = this.selectedObjectContainer, d = 0, c = b.length - 1;0 <= c;c--) { + for (var e = b[c], f = e.entity, e = e.clonedEntities, g = 0, h = e.length;g < h;g++) { + e[g].shape && a.setChildIndex(e[g].shape, d++), a.setChildIndex(e[g].object, d++); + } + f.shape && a.setChildIndex(f.shape, d++); + a.setChildIndex(f.object, d++); + } }; -Entry.ContextMenu = {}; -(function(a) { - a.visible = !1; - a._hideEvent = null; - a.createDom = function() { - this.dom = Entry.Dom("ul", {id:"entry-contextmenu", parent:$("body")}); - this.dom.bind("mousedown touchstart", function(b) { - b.stopPropagation(); - }); - Entry.Utils.disableContextmenu(this.dom); - }; - a.show = function(b, a, c) { - this._hideEvent = Entry.documentMousedown.attach(this, function() { - this.hide(); - }); - this.dom || this.createDom(); - if (0 !== b.length) { - var e = this; - void 0 !== a && (this._className = a, this.dom.addClass(a)); - var f = this.dom; - f.empty(); - for (var g = 0, h = b.length;g < h;g++) { - var k = b[g], l = k.text, m = !1 !== k.enable, n = Entry.Dom("li", {parent:f}); - if (k.divider) { - a = "divider"; +Entry.Stage.prototype.initCoordinator = function() { + 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.requestUpdate = !0; +}; +Entry.Stage.prototype.selectObject = function(b) { + this.selectedObject = b ? b : null; + this.updateObject(); +}; +Entry.Stage.prototype.initHandle = function() { + this.handle = new EaselHandle(this.canvas); + this.handle.setChangeListener(this, this.updateHandle); + this.handle.setEditStartListener(this, this.startEdit); + this.handle.setEditEndListener(this, this.endEdit); +}; +Entry.Stage.prototype.updateObject = function() { + Entry.requestUpdate = !0; + this.handle.setDraggable(!0); + if (!this.editEntity) { + 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); + 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 a = b.entity; + this.handle.setWidth(a.getScaleX() * a.getWidth()); + this.handle.setHeight(a.getScaleY() * a.getHeight()); + var d, c; + if ("textBox" == a.type) { + if (a.getLineBreak()) { + d = a.regX * a.scaleX, c = -a.regY * a.scaleY; } else { - a = m ? "menuAble" : "menuDisable"; - var q = Entry.Dom("span", {parent:n}); - q.text(l); - m && k.callback && function(b, a) { - b.mousedown(function(b) { - b.preventDefault(); - e.hide(); - a(b); - }); - }(q, k.callback); + var e = a.getTextAlign(); + c = -a.regY * a.scaleY; + switch(e) { + case Entry.TEXT_ALIGN_LEFT: + d = -a.getWidth() / 2 * a.scaleX; + break; + case Entry.TEXT_ALIGN_CENTER: + d = a.regX * a.scaleX; + break; + case Entry.TEXT_ALIGN_RIGHT: + d = a.getWidth() / 2 * a.scaleX; + } } - n.addClass(a); + } else { + d = (a.regX - a.width / 2) * a.scaleX, c = (a.height / 2 - a.regY) * a.scaleY; + } + e = a.getRotation() / 180 * Math.PI; + this.handle.setX(a.getX() - d * Math.cos(e) - c * Math.sin(e)); + this.handle.setY(-a.getY() - d * Math.sin(e) + c * 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(b.entity.getVisible()); + b.entity.getVisible() && this.handle.render(); + } else { + this.handle.setVisible(!1); + } + } +}; +Entry.Stage.prototype.updateHandle = function() { + this.editEntity = !0; + 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 !== a.width) { + var d = Math.abs(b.width / a.width); + a.flip && (d *= -1); + a.setScaleX(d); + } + 0 !== a.height && a.setScaleY(b.height / a.height); + } + d = b.rotation / 180 * Math.PI; + if ("textBox" == a.type) { + var c = b.regX / a.scaleX, c = b.regY / a.scaleY; + if (a.getLineBreak()) { + a.setX(b.x), a.setY(-b.y); + } else { + switch(a.getTextAlign()) { + case Entry.TEXT_ALIGN_LEFT: + a.setX(b.x - b.width / 2 * Math.cos(d)); + a.setY(-b.y + b.width / 2 * Math.sin(d)); + break; + case Entry.TEXT_ALIGN_CENTER: + a.setX(b.x); + a.setY(-b.y); + break; + case Entry.TEXT_ALIGN_RIGHT: + a.setX(b.x + b.width / 2 * Math.cos(d)), a.setY(-b.y - b.width / 2 * Math.sin(d)); } - f.removeClass("entryRemove"); - this.visible = !0; - this.position(c || Entry.mouseCoordinate); } - }; - a.position = function(b) { - var a = this.dom; - a.css({left:0, top:0}); - var c = a.width(), e = a.height(), f = $(window), g = f.width(), f = f.height(); - b.x + c > g && (b.x -= c + 3); - b.y + e > f && (b.y -= e); - a.css({left:b.x, top:b.y}); - }; - a.hide = function() { - this.visible = !1; - this.dom.empty(); - this.dom.addClass("entryRemove"); - this._className && (this.dom.removeClass(this._className), delete this._className); - this._hideEvent && (Entry.documentMousedown.detach(this._hideEvent), this._hideEvent = null); - }; -})(Entry.ContextMenu); -Entry.Loader = {queueCount:0, totalCount:0, loaded:!1}; -Entry.Loader.addQueue = function(a) { - this.queueCount || Entry.dispatchEvent("loadStart"); - this.queueCount++; - this.totalCount++; + } else { + c = a.width / 2 + b.regX / a.scaleX, a.setX(b.x + b.regX * Math.cos(d) - b.regY * Math.sin(d)), a.setRegX(c), c = a.height / 2 + b.regY / a.scaleY, a.setY(-b.y - b.regX * Math.sin(d) - b.regY * Math.cos(d)), a.setRegY(c); + } + a.setDirection(b.direction); + a.setRotation(b.rotation); + this.selectedObject.entity.doCommand(); + this.editEntity = !1; }; -Entry.Loader.removeQueue = function(a) { - this.queueCount--; - this.queueCount || (this.totalCount = 0, this.handleLoad()); +Entry.Stage.prototype.startEdit = function() { + this.selectedObject.entity.initCommand(); }; -Entry.Loader.getLoadedPercent = function() { - return 0 === this.totalCount ? 1 : this.queueCount / this.totalCount; +Entry.Stage.prototype.endEdit = function() { + this.selectedObject.entity.checkCommand(); }; -Entry.Loader.isLoaded = function() { - return !this.queueCount && !this.totalCount; +Entry.Stage.prototype.initWall = 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"); + }})); + b = new createjs.Container; + var a = new Image; + a.src = Entry.mediaFilePath + "confirm_button.png"; + var d = new createjs.Bitmap; + d.scaleX = .23; + d.scaleY = .23; + d.x = 160; + d.y = 89; + d.cursor = "pointer"; + d.image = a; + b.addChild(d); + b.on("mousedown", function(a) { + Entry.dispatchEvent("canvasInputComplete"); + }); + this.inputSubmitButton || (this.inputField.value(""), this.canvas.addChild(b), this.inputSubmitButton = b); + this.inputField.show(); + Entry.requestUpdateTwice = !0; }; -Entry.Loader.handleLoad = function() { - this.loaded || (this.loaded = !0, Entry.dispatchEvent("loadComplete")); +Entry.Stage.prototype.hideInputField = function() { + this.inputField && this.inputField.value() && this.inputField.value(""); + this.inputSubmitButton && (this.canvas.removeChild(this.inputSubmitButton), this.inputSubmitButton = null); + this.inputField && this.inputField.hide(); + Entry.requestUpdate = !0; +}; +Entry.Stage.prototype.initObjectContainers = function() { + 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 { + b = this.createObjectContainer(Entry.scene.selectedScene), this.objectContainers.push(b), this.selectedObjectContainer = b; + } + this.canvas.addChild(this.selectedObjectContainer); + this.selectObjectContainer(Entry.scene.selectedScene); }; -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.Stage.prototype.selectObjectContainer = function(b) { + if (this.canvas) { + for (var a = this.objectContainers, d = 0;d < a.length;d++) { + this.canvas.removeChild(a[d]); + } + this.selectedObjectContainer = this.getObjectContainerByScene(b); + this.canvas.addChildAt(this.selectedObjectContainer, 2); + } +}; +Entry.Stage.prototype.reAttachToCanvas = function() { + 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(b) { + var a = new createjs.Container; + a.scene = b; + return a; +}; +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(b) { + for (var a = this.objectContainers, d = 0;d < a.length;d++) { + if (a[d].scene.id == b.id) { + return a[d]; + } + } +}; +Entry.Stage.prototype.moveSprite = function(b) { + if (this.selectedObject && Entry.stage.focused && !this.selectedObject.getLock()) { + var a = 5; + b.shiftKey && (a = 1); + var d = this.selectedObject.entity; + switch(b.keyCode) { + case 38: + d.setY(d.getY() + a); + break; + case 40: + d.setY(d.getY() - a); + break; + case 37: + d.setX(d.getX() - a); + break; + case 39: + d.setX(d.getX() + a); + } + this.updateObject(); + } +}; +Entry.Stage.prototype.getBoundRect = function(b) { + return this._boundRect ? this._boundRect : this.updateBoundRect(); +}; +Entry.Stage.prototype.updateBoundRect = function(b) { + return this._boundRect = this.canvas.canvas.getBoundingClientRect(); +}; +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.setMinValue(a.minValue), this.setMaxValue(a.maxValue)) : "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.setMinValue(b.minValue), this.setMaxValue(b.maxValue)) : "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(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()); + "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 d = this; this.view_ = new createjs.Container; this.rect_ = new createjs.Shape; @@ -19483,74 +18239,74 @@ Entry.Variable.prototype.generateView = function(a) { 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("mousedown", function(a) { + "workspace" == Entry.type && (this.offset = {x:this.x - (.75 * a.stageX - 240), y:this.y - (.75 * a.stageY - 135)}); }); - this.view_.on("pressmove", function(b) { - "workspace" != Entry.type || d.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_.on("pressmove", function(a) { + "workspace" != Entry.type || d.isAdjusting || (this.variable.setX(.75 * a.stageX - 240 + this.offset.x), this.variable.setY(.75 * a.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; + 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(b) { - Entry.engine.isState("run") && (d.isAdjusting = !0, this.offsetX = -(this.x - .75 * b.stageX + 240)); + this.valueSetter_.on("mousedown", function(a) { + Entry.engine.isState("run") && (d.isAdjusting = !0, this.offsetX = -(this.x - .75 * a.stageX + 240)); }); - this.valueSetter_.on("pressmove", function(b) { + this.valueSetter_.on("pressmove", function(a) { if (Entry.engine.isState("run")) { - var a = this.offsetX; - this.offsetX = -(this.x - .75 * b.stageX + 240); - a !== this.offsetX && (b = d.getX(), d.setSlideCommandX(b + 10 > this.offsetX ? 0 : b + d.maxWidth + 10 > this.offsetX ? this.offsetX - b : d.maxWidth + 10)); + var b = this.offsetX; + this.offsetX = -(this.x - .75 * a.stageX + 240); + b !== this.offsetX && (a = d.getX(), d.setSlideCommandX(a + 10 > this.offsetX ? 0 : a + d.maxWidth + 10 > this.offsetX ? this.offsetX - a : d.maxWidth + 10)); } }); - this.valueSetter_.on("pressup", function(b) { + this.valueSetter_.on("pressup", function(a) { d.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(b) { + 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(b) { + }), this.resizeHandle_.on("mousedown", function(a) { this.list.isResizing = !0; - this.offset = {x:.75 * b.stageX - this.list.getWidth(), y:.75 * b.stageY - this.list.getHeight()}; + 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(b) { - this.list.setWidth(.75 * b.stageX - this.offset.x); - this.list.setHeight(.75 * b.stageY - this.offset.y); + }), 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(b) { + }), this.view_.on("mouseover", function(a) { 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.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(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.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 ? 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; + 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(b) { + }), 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()); @@ -19563,9 +18319,9 @@ Entry.Variable.prototype.updateView = function() { if ("variable" == this.type) { this.view_.x = this.getX(); this.view_.y = this.getY(); - var a = this.textView_.text, b; - b = this.object_ ? (b = Entry.container.getObject(this.object_)) ? b.name + ":" + this.getName() : this.getName() : this.getName(); - a !== b && (this.textView_.text = b, this._nameWidth = null); + var b = this.textView_.text, a; + a = this.object_ ? (a = Entry.container.getObject(this.object_)) ? a.name + ":" + this.getName() : this.getName() : this.getName(); + b !== a && (this.textView_.text = a, this._nameWidth = null); null === this._nameWidth && (this._nameWidth = this.textView_.getMeasuredWidth()); this.valueView_.x = this._nameWidth + 14; this.valueView_.y = 1; @@ -19575,32 +18331,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(), a = this.textView_.text, b = this.object_ ? (b = Entry.container.getObject(this.object_)) ? b.name + ":" + this.getName() : this.getName() : this.getName(), a !== b && (this.textView_.text = b, this._nameWidth = null), 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(), b = this.textView_.text, a = this.object_ ? (a = Entry.container.getObject(this.object_)) ? a.name + ":" + this.getName() : this.getName() : this.getName(), b !== a && (this.textView_.text = a, this._nameWidth = null), 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; - 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; + 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; 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 d = String(this.array_[b].data), c = Math.floor((this.getWidth() - 50) / 7), d = Entry.cutStringByLength(d, c), d = String(this.array_[b].data).length > d.length ? d + ".." : d; + for (a = this.scrollPosition;a < this.scrollPosition + b && a < this.array_.length;a++) { + this.elementView.indexView.text = a + 1; + var d = String(this.array_[a].data), c = Math.floor((this.getWidth() - 50) / 7), d = Entry.cutStringByLength(d, c), d = String(this.array_[a].data).length > d.length ? d + ".." : d; this.elementView.valueView.text = d; d = this.elementView.clone(!0); - d.y = 20 * (b - this.scrollPosition) + 23; + d.y = 20 * (a - this.scrollPosition) + 23; this.view_.addChild(d); } } else { @@ -19618,9 +18374,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(); Entry.requestUpdateTwice = !0; @@ -19634,8 +18390,8 @@ Entry.Variable.prototype.getValue = function() { 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 = Number(b), this.value_ = b < this.minValue_ ? this.minValue_ : b > this.maxValue_ ? this.maxValue_ : b); this.isCloud_ && Entry.variableContainer.updateCloudVariables(); this._valueWidth = null; this.updateView(); @@ -19644,37 +18400,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 !== a && (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 !== b && (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() { @@ -19686,79 +18442,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_), d = parseFloat(this.maxValue_), a = (b + Number(Math.abs(d - b) * a)).toFixed(2), a = parseFloat(a); - a < b ? a = this.minValue_ : a > d && (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_), d = parseFloat(this.maxValue_), b = (a + Number(Math.abs(d - a) * b)).toFixed(2), b = parseFloat(b); + b < a ? b = this.minValue_ : b > d && (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 = a || 0; - this.value_ < a && this.setValue(a); +Entry.Variable.prototype.setMinValue = function(b) { + this.minValue_ = b = b || 0; + this.value_ < b && this.setValue(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 = a || 100; - this.value_ > a && (this.value_ = a); +Entry.Variable.prototype.setMaxValue = function(b) { + this.maxValue_ = b = b || 100; + this.value_ > b && (this.value_ = b); this.updateView(); this.isMaxFloat = Entry.isFloat(this.maxValue_); }; @@ -19779,9 +18535,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 d = Entry.createElement("table"); d.addClass("entryVariableSelectorWorkspace"); this.view_.appendChild(d); @@ -19807,10 +18563,10 @@ Entry.VariableContainer.prototype.createDom = function(a) { d.innerHTML = "+ " + Lang.Workspace.variable_add; var f = this; this.variableAddButton_ = d; - d.bindOnClick(function(a) { - a = f.variableAddPanel; - var d = a.view.name.value.trim(); - a.isOpen ? d && 0 !== d.length ? b.addVariable() : (a.view.addClass("entryRemove"), a.isOpen = !1) : (a.view.removeClass("entryRemove"), a.view.name.focus(), a.isOpen = !0); + d.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(); @@ -19822,71 +18578,71 @@ Entry.VariableContainer.prototype.createDom = function(a) { d.addClass("entryVariableListElementWorkspace"); d.innerHTML = "+ " + Lang.Workspace.message_create; this.messageAddButton_ = d; - d.bindOnClick(function(a) { - b.addMessage({name:Lang.Workspace.message + " " + (b.messages_.length + 1)}); + d.bindOnClick(function(b) { + a.addMessage({name:Lang.Workspace.message + " " + (a.messages_.length + 1)}); }); d = Entry.createElement("li"); d.addClass("entryVariableAddWorkspace"); d.addClass("entryVariableListElementWorkspace"); d.innerHTML = "+ " + Lang.Workspace.list_create; this.listAddButton_ = d; - d.bindOnClick(function(a) { - a = f.listAddPanel; - var d = a.view.name.value.trim(); - a.isOpen ? d && 0 !== d.length ? b.addList() : (a.view.addClass("entryRemove"), a.isOpen = !1) : (a.view.removeClass("entryRemove"), a.view.name.focus(), a.isOpen = !0); + d.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); }); d = Entry.createElement("li"); d.addClass("entryVariableAddWorkspace"); d.addClass("entryVariableListElementWorkspace"); d.innerHTML = "+ " + Lang.Workspace.function_add; this.functionAddButton_ = d; - d.bindOnClick(function(a) { - a = b._getBlockMenu(); + d.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 d = this; - void 0 === b && (b = !0); + void 0 === a && (a = !0); var c = Entry.createElement("td"); - c.addClass("entryVariableSelectButtonWorkspace", a); - c.innerHTML = Lang.Workspace[a]; - b ? c.bindOnClick(function(b) { - d.selectFilter(a); + c.addClass("entryVariableSelectButtonWorkspace", b); + c.innerHTML = Lang.Workspace[b]; + a ? c.bindOnClick(function(a) { + d.selectFilter(b); this.addClass("selected"); }) : c.addClass("disable"); return c; }; -Entry.VariableContainer.prototype.selectFilter = function(a) { - for (var b = this.view_.getElementsByTagName("td"), d = 0;d < b.length;d++) { - b[d].removeClass("selected"), b[d].hasClass(a) && b[d].addClass("selected"); +Entry.VariableContainer.prototype.selectFilter = function(b) { + for (var a = this.view_.getElementsByTagName("td"), d = 0;d < a.length;d++) { + a[d].removeClass("selected"), a[d].hasClass(b) && a[d].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, d = 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, d = b.view; + b.view.addClass("entryRemove"); d.cloudCheck.removeClass("entryVariableAddChecked"); d.localCheck.removeClass("entryVariableAddChecked"); d.globalCheck.removeClass("entryVariableAddChecked"); d.cloudWrapper.removeClass("entryVariableAddSpaceUnCheckedWorkspace"); - b.isCloud && d.cloudCheck.addClass("entryVariableAddChecked"); - a.isOpen && (d.removeClass("entryRemove"), d.name.focus()); - b.object ? (d.localCheck.addClass("entryVariableAddChecked"), d.cloudWrapper.addClass("entryVariableAddSpaceUnCheckedWorkspace")) : d.globalCheck.addClass("entryVariableAddChecked"); + a.isCloud && d.cloudCheck.addClass("entryVariableAddChecked"); + b.isOpen && (d.removeClass("entryRemove"), d.name.focus()); + a.object ? (d.localCheck.addClass("entryVariableAddChecked"), d.cloudWrapper.addClass("entryVariableAddSpaceUnCheckedWorkspace")) : d.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, d = this._messageRefs, c = a.id, e = [], f = 0;f < d.length;f++) { +Entry.VariableContainer.prototype.renderMessageReference = function(b) { + for (var a = this, d = this._messageRefs, c = b.id, e = [], f = 0;f < d.length;f++) { -1 < d[f].block.params.indexOf(c) && e.push(d[f]); } d = Entry.createElement("ul"); @@ -19900,21 +18656,21 @@ Entry.VariableContainer.prototype.renderMessageReference = function(a) { h.innerHTML = c.object.name + " : " + Lang.Blocks["START_" + c.block.type]; g.appendChild(h); g.caller = c; - 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"); }); d.appendChild(g); } 0 === e.length && (g = Entry.createElement("li"), g.addClass("entryVariableListCallerWorkspace"), g.addClass("entryVariableListCallerNoneWorkspace"), g.innerHTML = Lang.Workspace.no_use, d.appendChild(g)); - a.callerListElement = d; - this.listView_.insertBefore(d, a.listElement); - this.listView_.insertBefore(a.listElement, d); + b.callerListElement = d; + this.listView_.insertBefore(d, b.listElement); + this.listView_.insertBefore(b.listElement, d); }; -Entry.VariableContainer.prototype.renderVariableReference = function(a) { - for (var b = this, d = this._variableRefs, c = a.id_, e = [], f = 0;f < d.length;f++) { +Entry.VariableContainer.prototype.renderVariableReference = function(b) { + for (var a = this, d = this._variableRefs, c = b.id_, e = [], f = 0;f < d.length;f++) { -1 < d[f].block.params.indexOf(c) && e.push(d[f]); } d = Entry.createElement("ul"); @@ -19928,24 +18684,24 @@ Entry.VariableContainer.prototype.renderVariableReference = function(a) { h.innerHTML = c.object.name + " : " + Lang.Blocks["VARIABLE_" + c.block.type]; g.appendChild(h); g.caller = c; - 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"); }); d.appendChild(g); } 0 === e.length && (g = Entry.createElement("li"), g.addClass("entryVariableListCallerWorkspace"), g.addClass("entryVariableListCallerNoneWorkspace"), g.innerHTML = Lang.Workspace.no_use, d.appendChild(g)); - a.callerListElement = d; - this.listView_.insertBefore(d, a.listElement); - this.listView_.insertBefore(a.listElement, d); + b.callerListElement = d; + this.listView_.insertBefore(d, b.listElement); + this.listView_.insertBefore(b.listElement, d); }; -Entry.VariableContainer.prototype.renderFunctionReference = function(a) { - for (var b = this, d = this._functionRefs, c = [], e = 0;e < d.length;e++) { +Entry.VariableContainer.prototype.renderFunctionReference = function(b) { + for (var a = this, d = this._functionRefs, c = [], e = 0;e < d.length;e++) { c.push(d[e]); } d = Entry.createElement("ul"); @@ -19959,19 +18715,19 @@ Entry.VariableContainer.prototype.renderFunctionReference = function(a) { h.innerHTML = f.object.name; g.appendChild(h); g.caller = f; - g.bindOnClick(function(d) { - Entry.playground.object != this.caller.object && (Entry.container.selectObject(), Entry.container.selectObject(this.caller.object.id, !0), b.select(null), b.select(a)); - d = this.caller.block; + g.bindOnClick(function(c) { + 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(); - d.view.getBoard().activateBlock(d); + c.view.getBoard().activateBlock(c); Entry.playground.changeViewMode("variable"); }); d.appendChild(g); } 0 === c.length && (g = Entry.createElement("li"), g.addClass("entryVariableListCallerWorkspace"), g.addClass("entryVariableListCallerNoneWorkspace"), g.innerHTML = Lang.Workspace.no_use, d.appendChild(g)); - a.callerListElement = d; - this.listView_.insertBefore(d, a.listElement); - this.listView_.insertBefore(a.listElement, d); + b.callerListElement = d; + this.listView_.insertBefore(d, b.listElement); + this.listView_.insertBefore(b.listElement, d); }; Entry.VariableContainer.prototype.updateList = function() { if (this.listView_) { @@ -19979,19 +18735,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 d in this.messages_) { var c = this.messages_[d]; - b.push(c); + a.push(c); var e = c.listElement; this.listView_.appendChild(e); c.callerListElement && this.listView_.appendChild(c.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_); @@ -19999,22 +18755,22 @@ Entry.VariableContainer.prototype.updateList = function() { this.variableSplitters.top.innerHTML = Lang.Workspace.Variable_used_at_all_objects; this.listView_.appendChild(this.variableSplitters.top); for (d in this.variables_) { - c = this.variables_[d], c.object_ || (b.push(c), e = c.listElement, this.listView_.appendChild(e), c.callerListElement && this.listView_.appendChild(c.callerListElement)); + c = this.variables_[d], c.object_ || (a.push(c), e = c.listElement, this.listView_.appendChild(e), c.callerListElement && this.listView_.appendChild(c.callerListElement)); } this.variableSplitters.bottom.innerHTML = Lang.Workspace.Variable_used_at_special_object; this.listView_.appendChild(this.variableSplitters.bottom); for (d in this.variables_) { - c = this.variables_[d], c.object_ && (b.push(c), e = c.listElement, this.listView_.appendChild(e), c.callerListElement && this.listView_.appendChild(c.callerListElement)); + c = this.variables_[d], c.object_ && (a.push(c), e = c.listElement, this.listView_.appendChild(e), c.callerListElement && this.listView_.appendChild(c.callerListElement)); } this.updateVariableAddView("variable"); } else { for (d in this.variables_) { - c = this.variables_[d], b.push(c), e = c.listElement, this.listView_.appendChild(e), c.callerListElement && this.listView_.appendChild(c.callerListElement); + c = this.variables_[d], a.push(c), e = c.listElement, this.listView_.appendChild(e), c.callerListElement && this.listView_.appendChild(c.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_); @@ -20023,32 +18779,32 @@ Entry.VariableContainer.prototype.updateList = function() { this.listView_.appendChild(this.variableSplitters.top); this.updateVariableAddView("list"); for (d in this.lists_) { - c = this.lists_[d], c.object_ || (b.push(c), e = c.listElement, this.listView_.appendChild(e), c.callerListElement && this.listView_.appendChild(c.callerListElement)); + c = this.lists_[d], c.object_ || (a.push(c), e = c.listElement, this.listView_.appendChild(e), c.callerListElement && this.listView_.appendChild(c.callerListElement)); } this.variableSplitters.bottom.innerHTML = Lang.Workspace.list_used_specific_objects; this.listView_.appendChild(this.variableSplitters.bottom); for (d in this.lists_) { - c = this.lists_[d], c.object_ && (b.push(c), e = c.listElement, this.listView_.appendChild(e), c.callerListElement && this.listView_.appendChild(c.callerListElement)); + c = this.lists_[d], c.object_ && (a.push(c), e = c.listElement, this.listView_.appendChild(e), c.callerListElement && this.listView_.appendChild(c.callerListElement)); } this.updateVariableAddView("variable"); } else { for (d in this.lists_) { - c = this.lists_[d], b.push(c), e = c.listElement, this.listView_.appendChild(e), c.callerListElement && this.listView_.appendChild(c.callerListElement); + c = this.lists_[d], a.push(c), e = c.listElement, this.listView_.appendChild(e), c.callerListElement && this.listView_.appendChild(c.callerListElement); } } } - if ("all" == a || "func" == a) { - for (d in "func" == a && this.listView_.appendChild(this.functionAddButton_), this.functions_) { - a = this.functions_[d], b.push(a), e = a.listElement, this.listView_.appendChild(e), a.callerListElement && this.listView_.appendChild(a.callerListElement); + if ("all" == b || "func" == b) { + for (d in "func" == b && this.listView_.appendChild(this.functionAddButton_), this.functions_) { + b = this.functions_[d], 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 d = a[b]; +Entry.VariableContainer.prototype.setMessages = function(b) { + for (var a in b) { + var d = b[a]; d.id || (d.id = Entry.generateHash()); this.createMessageView(d); this.messages_.push(d); @@ -20056,9 +18812,9 @@ Entry.VariableContainer.prototype.setMessages = function(a) { Entry.playground.reloadPlayground(); this.updateList(); }; -Entry.VariableContainer.prototype.setVariables = function(a) { - for (var b in a) { - var d = new Entry.Variable(a[b]), c = d.getType(); +Entry.VariableContainer.prototype.setVariables = function(b) { + for (var a in b) { + var d = new Entry.Variable(b[a]), c = d.getType(); "variable" == c || "slide" == c ? (d.generateView(this.variables_.length), this.createVariableView(d), this.variables_.push(d)) : "list" == c ? (d.generateView(this.lists_.length), this.createListView(d), this.lists_.push(d)) : "timer" == c ? this.generateTimer(d) : "answer" == c && this.generateAnswer(d); } Entry.isEmpty(Entry.engine.projectTimer) && Entry.variableContainer.generateTimer(); @@ -20066,258 +18822,258 @@ Entry.VariableContainer.prototype.setVariables = function(a) { Entry.playground.reloadPlayground(); this.updateList(); }; -Entry.VariableContainer.prototype.setFunctions = function(a) { - for (var b in a) { - var d = new Entry.Func(a[b]); +Entry.VariableContainer.prototype.setFunctions = function(b) { + for (var a in b) { + var d = new Entry.Func(b[a]); d.generateBlock(); this.createFunctionView(d); this.functions_[d.id] = d; } 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 d = Entry.findObjsByKey(this.variables_, "id_", a)[0]; - b && b.isClone && d.object_ && (d = Entry.findObjsByKey(b.variables, "id_", a)[0]); +Entry.VariableContainer.prototype.getVariable = function(b, a) { + var d = Entry.findObjsByKey(this.variables_, "id_", b)[0]; + a && a.isClone && d.object_ && (d = Entry.findObjsByKey(a.variables, "id_", b)[0]); return d; }; -Entry.VariableContainer.prototype.getList = function(a, b) { - var d = Entry.findObjsByKey(this.lists_, "id_", a)[0]; - b && b.isClone && d.object_ && (d = Entry.findObjsByKey(b.lists, "id_", a)[0]); +Entry.VariableContainer.prototype.getList = function(b, a) { + var d = Entry.findObjsByKey(this.lists_, "id_", b)[0]; + a && a.isClone && d.object_ && (d = Entry.findObjsByKey(a.lists, "id_", b)[0]); return d; }; 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) { - var b = a.id; - a = this.functions_; - a[b].destroy(); - delete a[b]; - b = "func_" + b; - Entry.container.removeFuncBlocks(b); - for (var d in a) { - a[d].content.removeBlocksByType(b); +Entry.VariableContainer.prototype.removeFunction = function(b) { + var a = b.id; + b = this.functions_; + b[a].destroy(); + delete b[a]; + a = "func_" + a; + Entry.container.removeFuncBlocks(a); + for (var d in b) { + b[d].content.removeBlocksByType(a); } this.updateList(); }; -Entry.VariableContainer.prototype.checkListPosition = function(a, b) { - var d = a.x_ + a.width_, c = -a.y_, e = -a.y_ + -a.height_; - return b.x > a.x_ && b.x < d && b.y < c && b.y > e ? !0 : !1; +Entry.VariableContainer.prototype.checkListPosition = function(b, a) { + var d = b.x_ + b.width_, c = -b.y_, e = -b.y_ + -b.height_; + return a.x > b.x_ && a.x < d && a.y < c && a.y > e ? !0 : !1; }; -Entry.VariableContainer.prototype.getListById = function(a) { - var b = this.lists_, d = []; - if (0 < b.length) { - for (var c = 0;c < b.length;c++) { - this.checkListPosition(b[c], a) && d.push(b[c]); +Entry.VariableContainer.prototype.getListById = function(b) { + var a = this.lists_, d = []; + if (0 < a.length) { + for (var c = 0;c < a.length;c++) { + this.checkListPosition(a[c], b) && d.push(a[c]); } return d; } 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 d = Entry.createElement("li"); d.addClass("entryVariableListElementWorkspace"); d.addClass("entryFunctionElementWorkspace"); - d.bindOnClick(function(d) { - d.stopPropagation(); - b.select(a); + d.bindOnClick(function(c) { + c.stopPropagation(); + a.select(b); }); var c = Entry.createElement("button"); c.addClass("entryVariableListElementDeleteWorkspace"); - c.bindOnClick(function(d) { - d.stopPropagation(); - confirm(Lang.Workspace.will_you_delete_function) && (b.removeFunction(a), b.selected = null); + c.bindOnClick(function(c) { + c.stopPropagation(); + confirm(Lang.Workspace.will_you_delete_function) && (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; d.nameField = g; d.appendChild(g); d.appendChild(e); d.appendChild(c); - a.listElement = d; + b.listElement = d; } }; -Entry.VariableContainer.prototype.checkAllVariableName = function(a, b) { - b = this[b]; - for (var d = 0;d < b.length;d++) { - if (b[d].name_ == a) { +Entry.VariableContainer.prototype.checkAllVariableName = function(b, a) { + a = this[a]; + for (var d = 0;d < a.length;d++) { + if (a[d].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 d = b.info; - a = {name:a, isCloud:d.isCloud, object:d.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 d = a.info; + b = {name:b, isCloud:d.isCloud, object:d.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), d = 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), d = 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, d); Entry.playground.reloadPlayground(); this.updateList(); return new Entry.State(this, this.addVariable, d); }; -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.setName(b), 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.setName(a), 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), d = a.toJSON(); +Entry.VariableContainer.prototype.removeList = function(b) { + var a = this.lists_.indexOf(b), d = b.toJSON(); Entry.stateManager && Entry.stateManager.addCommand("remove list", this, this.addList, d); - 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, d); }; -Entry.VariableContainer.prototype.createVariableView = function(a) { - var b = this, d = Entry.createElement("li"), c = Entry.createElement("div"); +Entry.VariableContainer.prototype.createVariableView = function(b) { + var a = this, d = Entry.createElement("li"), c = Entry.createElement("div"); c.addClass("entryVariableListElementWrapperWorkspace"); d.appendChild(c); d.addClass("entryVariableListElementWorkspace"); - a.object_ ? d.addClass("entryVariableLocalElementWorkspace") : a.isCloud_ ? d.addClass("entryVariableCloudElementWorkspace") : d.addClass("entryVariableGlobalElementWorkspace"); - d.bindOnClick(function(d) { - b.select(a); + b.object_ ? d.addClass("entryVariableLocalElementWorkspace") : b.isCloud_ ? d.addClass("entryVariableCloudElementWorkspace") : d.addClass("entryVariableGlobalElementWorkspace"); + d.bindOnClick(function(c) { + a.select(b); }); var e = Entry.createElement("button"); e.addClass("entryVariableListElementDeleteWorkspace"); - e.bindOnClick(function(d) { - d.stopPropagation(); - b.removeVariable(a); - b.selectedVariable = null; - b.variableSettingView.addClass("entryRemove"); + e.bindOnClick(function(c) { + c.stopPropagation(); + a.removeVariable(b); + a.selectedVariable = null; + a.variableSettingView.addClass("entryRemove"); }); var f = Entry.createElement("button"); f.addClass("entryVariableListElementEditWorkspace"); - f.bindOnClick(function(d) { - d.stopPropagation(); + f.bindOnClick(function(c) { + c.stopPropagation(); h.removeAttribute("disabled"); g.removeClass("entryRemove"); this.addClass("entryRemove"); - b.updateSelectedVariable(a); + a.updateSelectedVariable(b); h.focus(); }); d.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"); }); d.editSaveButton = g; var h = Entry.createElement("input"); h.addClass("entryVariableListElementNameWorkspace"); h.setAttribute("disabled", "disabled"); - h.value = a.name_; - h.bindOnClick(function(b) { - b.stopPropagation(); + h.value = b.name_; + h.bindOnClick(function(a) { + a.stopPropagation(); }); - h.onblur = function(d) { - (d = this.value.trim()) && 0 !== d.length ? b.changeVariableName(a, this.value) : (Entry.toast.alert(Lang.Msgs.warn, Lang.Workspace.variable_can_not_space), this.value = a.getName()); + h.onblur = function(c) { + (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(b) { - 13 == b.keyCode && this.blur(); + h.onkeydown = function(a) { + 13 == a.keyCode && this.blur(); }; d.nameField = h; c.appendChild(h); c.appendChild(f); c.appendChild(g); c.appendChild(e); - a.listElement = d; + b.listElement = d; }; -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, d = Entry.createElement("li"); +Entry.VariableContainer.prototype.createMessageView = function(b) { + var a = this, d = Entry.createElement("li"); d.addClass("entryVariableListElementWorkspace"); d.addClass("entryMessageElementWorkspace"); - d.bindOnClick(function(d) { - b.select(a); + d.bindOnClick(function(c) { + a.select(b); }); var c = Entry.createElement("button"); c.addClass("entryVariableListElementDeleteWorkspace"); - c.bindOnClick(function(d) { - d.stopPropagation(); - b.removeMessage(a); + c.bindOnClick(function(c) { + c.stopPropagation(); + a.removeMessage(b); }); var e = Entry.createElement("button"); e.addClass("entryVariableListElementEditWorkspace"); - e.bindOnClick(function(b) { - b.stopPropagation(); + e.bindOnClick(function(a) { + a.stopPropagation(); g.removeAttribute("disabled"); g.focus(); f.removeClass("entryRemove"); @@ -20326,183 +19082,183 @@ Entry.VariableContainer.prototype.createMessageView = function(a) { var f = Entry.createElement("button"); f.addClass("entryVariableListElementEditWorkspace"); f.addClass("entryRemove"); - f.bindOnClick(function(b) { - b.stopPropagation(); + f.bindOnClick(function(a) { + a.stopPropagation(); g.blur(); e.removeClass("entryRemove"); this.addClass("entryRemove"); }); var g = Entry.createElement("input"); g.addClass("entryVariableListElementNameWorkspace"); - g.value = a.name; - g.bindOnClick(function(b) { - b.stopPropagation(); + g.value = b.name; + g.bindOnClick(function(a) { + a.stopPropagation(); }); - g.onblur = function(d) { - (d = this.value.trim()) && 0 !== d.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); + g.onblur = function(c) { + (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(b) { - 13 == b.keyCode && this.blur(); + g.onkeydown = function(a) { + 13 == a.keyCode && this.blur(); }; d.nameField = g; d.appendChild(g); d.appendChild(e); d.appendChild(f); d.appendChild(c); - a.listElement = d; + b.listElement = d; }; -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 d = 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:d.isCloud, object:d.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 d = 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:d.isCloud, object:d.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, d = Entry.createElement("li"), c = Entry.createElement("div"); +Entry.VariableContainer.prototype.createListView = function(b) { + var a = this, d = Entry.createElement("li"), c = Entry.createElement("div"); c.addClass("entryVariableListElementWrapperWorkspace"); d.appendChild(c); d.addClass("entryVariableListElementWorkspace"); - a.object_ ? d.addClass("entryListLocalElementWorkspace") : a.isCloud_ ? d.addClass("entryListCloudElementWorkspace") : d.addClass("entryListGlobalElementWorkspace"); - d.bindOnClick(function(d) { - b.select(a); + b.object_ ? d.addClass("entryListLocalElementWorkspace") : b.isCloud_ ? d.addClass("entryListCloudElementWorkspace") : d.addClass("entryListGlobalElementWorkspace"); + d.bindOnClick(function(c) { + a.select(b); }); var e = Entry.createElement("button"); e.addClass("entryVariableListElementDeleteWorkspace"); - e.bindOnClick(function(d) { - d.stopPropagation(); - b.removeList(a); - b.selectedList = null; - b.listSettingView.addClass("entryRemove"); + 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(d) { - d.stopPropagation(); + f.bindOnClick(function(c) { + c.stopPropagation(); h.removeAttribute("disabled"); g.removeClass("entryRemove"); this.addClass("entryRemove"); - b.updateSelectedVariable(a); + a.updateSelectedVariable(b); h.focus(); }); d.editButton = f; var g = Entry.createElement("button"); g.addClass("entryVariableListElementEditWorkspace"); g.addClass("entryRemove"); - g.bindOnClick(function(d) { - d.stopPropagation(); + 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"); + a.select(b); + a.updateSelectedVariable(null, "list"); }); d.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.value = b.name_; + h.bindOnClick(function(a) { + a.stopPropagation(); }); - h.onblur = function(d) { - (d = this.value.trim()) && 0 !== d.length ? b.changeListName(a, this.value) : (Entry.toast.alert(Lang.Msgs.warn, Lang.Msgs.list_can_not_space), this.value = a.getName()); + 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(b) { - 13 == b.keyCode && this.blur(); + h.onkeydown = function(a) { + 13 == a.keyCode && this.blur(); }; d.nameField = h; c.appendChild(h); c.appendChild(f); c.appendChild(g); c.appendChild(e); - a.listElement = d; + b.listElement = d; }; -Entry.VariableContainer.prototype.mapVariable = function(a, b) { +Entry.VariableContainer.prototype.mapVariable = function(b, a) { for (var d = this.variables_.length, c = 0;c < d;c++) { - a(this.variables_[c], b); + b(this.variables_[c], a); } }; -Entry.VariableContainer.prototype.mapList = function(a, b) { +Entry.VariableContainer.prototype.mapList = function(b, a) { for (var d = this.lists_.length, c = 0;c < d;c++) { - a(this.lists_[c], b); + b(this.lists_[c], 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.toJSON()); - b = Entry.container.inputValue; - Entry.isEmpty(b) || a.push(b.toJSON()); - return a; + Entry.engine.projectTimer && b.push(Entry.engine.projectTimer.toJSON()); + a = Entry.container.inputValue; + Entry.isEmpty(a) || b.push(a.toJSON()); + 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 d = this.functions_[b], d = {id:d.id, content:JSON.stringify(d.content.toJSON())}; - a.push(d); + var b = [], a; + for (a in this.functions_) { + var d = this.functions_[a], d = {id:d.id, content:JSON.stringify(d.content.toJSON())}; + b.push(d); } - return a; + return b; }; -Entry.VariableContainer.prototype.resetVariableAddPanel = function(a) { - a = a || "variable"; - var b = "variable" == a ? this.variableAddPanel : this.listAddPanel, d = b.info; +Entry.VariableContainer.prototype.resetVariableAddPanel = function(b) { + b = b || "variable"; + var a = "variable" == b ? this.variableAddPanel : this.listAddPanel, d = a.info; d.isCloud = !1; d.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 d = Entry.createElement("div"); d.addClass("entryVariableAddSpaceNameWrapperWorkspace"); - b.appendChild(d); + a.appendChild(d); var c = Entry.createElement("input"); c.addClass("entryVariableAddSpaceInputWorkspace"); c.setAttribute("placeholder", Lang.Workspace.Variable_placeholder_name); c.variableContainer = this; - c.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")); + c.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 = c; d.appendChild(c); d = Entry.createElement("div"); d.addClass("entryVariableAddSpaceGlobalWrapperWorkspace"); - d.bindOnClick(function(b) { - a.variableAddPanel.info.object = null; - a.updateVariableAddView("variable"); + d.bindOnClick(function(a) { + b.variableAddPanel.info.object = null; + b.updateVariableAddView("variable"); }); - b.appendChild(d); + a.appendChild(d); c = Entry.createElement("span"); c.innerHTML = Lang.Workspace.Variable_use_all_objects; d.appendChild(c); @@ -20513,10 +19269,10 @@ Entry.VariableContainer.prototype.generateVariableAddView = function() { d.appendChild(c); d = Entry.createElement("div"); d.addClass("entryVariableAddSpaceLocalWrapperWorkspace"); - d.bindOnClick(function(b) { - Entry.playground.object && (b = a.variableAddPanel.info, b.object = Entry.playground.object.id, b.isCloud = !1, a.updateVariableAddView("variable")); + d.bindOnClick(function(a) { + Entry.playground.object && (a = b.variableAddPanel.info, a.object = Entry.playground.object.id, a.isCloud = !1, b.updateVariableAddView("variable")); }); - b.appendChild(d); + a.appendChild(d); c = Entry.createElement("span"); c.innerHTML = Lang.Workspace.Variable_use_this_object; d.appendChild(c); @@ -20526,13 +19282,13 @@ Entry.VariableContainer.prototype.generateVariableAddView = function() { this.variableAddPanel.info.object && c.addClass("entryVariableAddChecked"); d.appendChild(c); d = Entry.createElement("div"); - b.cloudWrapper = d; + a.cloudWrapper = d; d.addClass("entryVariableAddSpaceCloudWrapperWorkspace"); - d.bindOnClick(function(b) { - b = a.variableAddPanel.info; - b.object || (b.isCloud = !b.isCloud, a.updateVariableAddView("variable")); + d.bindOnClick(function(a) { + a = b.variableAddPanel.info; + a.object || (a.isCloud = !a.isCloud, b.updateVariableAddView("variable")); }); - b.appendChild(d); + a.appendChild(d); c = Entry.createElement("span"); c.addClass("entryVariableAddSpaceCloudSpanWorkspace"); c.innerHTML = Lang.Workspace.Variable_create_cloud; @@ -20545,57 +19301,57 @@ Entry.VariableContainer.prototype.generateVariableAddView = function() { d.appendChild(c); d = Entry.createElement("div"); d.addClass("entryVariableAddSpaceButtonWrapperWorkspace"); - b.appendChild(d); - 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(d); + 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"); }); - d.appendChild(b); - b = Entry.createElement("span"); - b.addClass("entryVariableAddSpaceConfirmWorkspace"); - b.addClass("entryVariableAddSpaceButtonWorkspace"); - b.innerHTML = Lang.Buttons.save; - b.variableContainer = this; - b.bindOnClick(function(b) { + d.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"); }); - d.appendChild(b); + d.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 d = Entry.createElement("div"); d.addClass("entryVariableAddSpaceNameWrapperWorkspace"); d.addClass("entryListAddSpaceNameWrapperWorkspace"); - b.appendChild(d); + a.appendChild(d); var c = Entry.createElement("input"); c.addClass("entryVariableAddSpaceInputWorkspace"); c.setAttribute("placeholder", Lang.Workspace.list_name); this.listAddPanel.view.name = c; c.variableContainer = this; - c.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")); + c.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")); }; d.appendChild(c); d = Entry.createElement("div"); d.addClass("entryVariableAddSpaceGlobalWrapperWorkspace"); - d.bindOnClick(function(b) { - a.listAddPanel.info.object = null; - a.updateVariableAddView("list"); + d.bindOnClick(function(a) { + b.listAddPanel.info.object = null; + b.updateVariableAddView("list"); }); - b.appendChild(d); + a.appendChild(d); c = Entry.createElement("span"); c.innerHTML = Lang.Workspace.use_all_objects; d.appendChild(c); @@ -20606,10 +19362,10 @@ Entry.VariableContainer.prototype.generateListAddView = function() { d.appendChild(c); d = Entry.createElement("div"); d.addClass("entryVariableAddSpaceLocalWrapperWorkspace"); - d.bindOnClick(function(b) { - Entry.playground.object && (b = a.listAddPanel.info, b.object = Entry.playground.object.id, b.isCloud = !1, a.updateVariableAddView("list")); + d.bindOnClick(function(a) { + Entry.playground.object && (a = b.listAddPanel.info, a.object = Entry.playground.object.id, a.isCloud = !1, b.updateVariableAddView("list")); }); - b.appendChild(d); + a.appendChild(d); c = Entry.createElement("span"); c.innerHTML = Lang.Workspace.Variable_use_this_object; d.appendChild(c); @@ -20619,13 +19375,13 @@ Entry.VariableContainer.prototype.generateListAddView = function() { this.variableAddPanel.info.object && addVariableLocalCheck.addClass("entryVariableAddChecked"); d.appendChild(c); d = Entry.createElement("div"); - b.cloudWrapper = d; + a.cloudWrapper = d; d.addClass("entryVariableAddSpaceCloudWrapperWorkspace"); - d.bindOnClick(function(b) { - b = a.listAddPanel.info; - b.object || (b.isCloud = !b.isCloud, a.updateVariableAddView("list")); + d.bindOnClick(function(a) { + a = b.listAddPanel.info; + a.object || (a.isCloud = !a.isCloud, b.updateVariableAddView("list")); }); - b.appendChild(d); + a.appendChild(d); c = Entry.createElement("span"); c.addClass("entryVariableAddSpaceCloudSpanWorkspace"); c.innerHTML = Lang.Workspace.List_create_cloud; @@ -20638,161 +19394,170 @@ Entry.VariableContainer.prototype.generateListAddView = function() { d.appendChild(c); d = Entry.createElement("div"); d.addClass("entryVariableAddSpaceButtonWrapperWorkspace"); - b.appendChild(d); - 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(d); + 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"); }); - d.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"); + d.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"); }); - d.appendChild(b); + d.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 = [], d = 0 !== this.variables_.length, c = 0 !== this.lists_.length, e, f = 0, g;g = a[f];f++) { +Entry.VariableContainer.prototype.getMenuXml = function(b) { + for (var a = [], d = 0 !== this.variables_.length, c = 0 !== this.lists_.length, e, f = 0, g;g = b[f];f++) { var h = g.tagName; - h && "BLOCK" == h.toUpperCase() ? (e = g.getAttribute("bCategory"), !d && "variable" == e || !c && "list" == e || b.push(g)) : !h || "SPLITTER" != h.toUpperCase() && "BTN" != h.toUpperCase() || !d && "variable" == e || (c || "list" != e) && b.push(g); + h && "BLOCK" == h.toUpperCase() ? (e = g.getAttribute("bCategory"), !d && "variable" == e || !c && "list" == e || a.push(g)) : !h || "SPLITTER" != h.toUpperCase() && "BTN" != h.toUpperCase() || !d && "variable" == e || (c || "list" != e) && a.push(g); } - return b; + return a; }; -Entry.VariableContainer.prototype.addCloneLocalVariables = function(a) { - var b = [], d = this; - this.mapVariable(function(a, d) { - a.object_ && a.object_ == d.objectId && (a = a.toJSON(), a.originId = a.id, a.id = Entry.generateHash(), a.object = d.newObjectId, delete a.x, delete a.y, b.push(a), d.json.script = d.json.script.replace(new RegExp(a.originId, "g"), a.id)); - }, a); - b.map(function(b) { - d.addVariable(b); +Entry.VariableContainer.prototype.addCloneLocalVariables = function(b) { + var a = [], d = this; + this.mapVariable(function(b, d) { + if (b.object_ && b.object_ == d.objectId) { + var f = b.toJSON(); + f.originId = f.id; + f.id = Entry.generateHash(); + f.object = d.newObjectId; + delete f.x; + delete f.y; + a.push(f); + d.json.script = d.json.script.replace(new RegExp(f.originId, "g"), f.id); + } + }, b); + a.map(function(a) { + d.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(b) { - b.stopPropagation(); + 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 d = Entry.createElement("div"); d.addClass("entryVariableSettingVisibleWrapperWorkspace"); - d.bindOnClick(function(b) { - b = a.selectedVariable; - var d = a.variableSettingView.visibleCheck; - b.setVisible(!b.isVisible()); - b.isVisible() ? d.addClass("entryVariableSettingChecked") : d.removeClass("entryVariableSettingChecked"); + d.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(d); + a.appendChild(d); var c = Entry.createElement("span"); c.innerHTML = Lang.Workspace.show_variable; d.appendChild(c); c = Entry.createElement("span"); c.addClass("entryVariableSettingCheckWorkspace"); - b.visibleCheck = c; + a.visibleCheck = c; d.appendChild(c); d = Entry.createElement("div"); d.addClass("entryVariableSettingInitValueWrapperWorkspace"); - b.appendChild(d); + a.appendChild(d); c = Entry.createElement("span"); c.innerHTML = Lang.Workspace.default_value; d.appendChild(c); c = Entry.createElement("input"); c.addClass("entryVariableSettingInitValueInputWorkspace"); - b.initValueInput = c; + a.initValueInput = c; c.value = 0; - c.onkeyup = function(b) { - a.selectedVariable.setValue(this.value); + c.onkeyup = function(a) { + b.selectedVariable.setValue(this.value); }; - c.onblur = function(b) { - a.selectedVariable.setValue(this.value); + c.onblur = function(a) { + b.selectedVariable.setValue(this.value); }; - b.initValueInput = c; + a.initValueInput = c; d.appendChild(c); d = Entry.createElement("div"); d.addClass("entryVariableSettingSplitterWorkspace"); - b.appendChild(d); + a.appendChild(d); d = Entry.createElement("div"); d.addClass("entryVariableSettingSlideWrapperWorkspace"); - b.appendChild(d); + a.appendChild(d); c = Entry.createElement("span"); c.innerHTML = Lang.Workspace.slide; d.appendChild(c); c = Entry.createElement("span"); c.addClass("entryVariableSettingCheckWorkspace"); - b.slideCheck = c; + a.slideCheck = c; d.appendChild(c); - d.bindOnClick(function(b) { - var d; - b = a.selectedVariable; - var c = a.variables_, f = b.getType(); - "variable" == f ? (d = b.toJSON(), d.variableType = "slide", d = new Entry.Variable(d), c.splice(c.indexOf(b), 0, d), 0 > d.getValue() && d.setValue(0), 100 < d.getValue() && d.setValue(100), e.removeAttribute("disabled"), g.removeAttribute("disabled")) : "slide" == f && (d = b.toJSON(), d.variableType = "variable", d = new Entry.Variable(d), c.splice(c.indexOf(b), 0, d), e.setAttribute("disabled", "disabled"), g.setAttribute("disabled", "disabled")); - a.createVariableView(d); - a.removeVariable(b); - a.updateSelectedVariable(d); - d.generateView(); + d.bindOnClick(function(a) { + var 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(); }); d = Entry.createElement("div"); - b.minMaxWrapper = d; + a.minMaxWrapper = d; d.addClass("entryVariableSettingMinMaxWrapperWorkspace"); - b.appendChild(d); + a.appendChild(d); c = Entry.createElement("span"); c.innerHTML = Lang.Workspace.min_value; d.appendChild(c); var e = Entry.createElement("input"); e.addClass("entryVariableSettingMinValueInputWorkspace"); - c = a.selectedVariable; + c = b.selectedVariable; e.value = c && "slide" == c.type ? c.minValue_ : 0; - e.onkeypress = function(b) { - 13 === b.keyCode && this.blur(); + e.onkeypress = function(a) { + 13 === a.keyCode && this.blur(); }; - 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; d.appendChild(e); var f = Entry.createElement("span"); f.addClass("entryVariableSettingMaxValueSpanWorkspace"); @@ -20801,49 +19566,49 @@ Entry.VariableContainer.prototype.generateVariableSettingView = function() { var g = Entry.createElement("input"); g.addClass("entryVariableSettingMaxValueInputWorkspace"); g.value = c && "slide" == c.type ? c.maxValue_ : 100; - g.onkeypress = function(b) { - 13 === b.keyCode && this.blur(); + g.onkeypress = function(a) { + 13 === a.keyCode && this.blur(); }; - 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; d.appendChild(g); }; -Entry.VariableContainer.prototype.updateVariableSettingView = function(a) { - var b = this.variableSettingView, d = b.visibleCheck, c = b.initValueInput, e = b.slideCheck, f = b.minValueInput, g = b.maxValueInput, h = b.minMaxWrapper; +Entry.VariableContainer.prototype.updateVariableSettingView = function(b) { + var a = this.variableSettingView, d = a.visibleCheck, c = a.initValueInput, e = a.slideCheck, f = a.minValueInput, g = a.maxValueInput, h = a.minMaxWrapper; d.removeClass("entryVariableSettingChecked"); - a.isVisible() && d.addClass("entryVariableSettingChecked"); + b.isVisible() && d.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")); - c.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")); + c.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(b) { - b.stopPropagation(); + 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 d = Entry.createElement("div"); d.addClass("entryListSettingVisibleWrapperWorkspace"); - d.bindOnClick(function(b) { - b = a.selectedList; - var d = a.listSettingView.visibleCheck; - b.setVisible(!b.isVisible()); - b.isVisible() ? d.addClass("entryListSettingCheckedWorkspace") : d.removeClass("entryListSettingCheckedWorkspace"); + d.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(d); + a.appendChild(d); var c = Entry.createElement("span"); c.innerHTML = Lang.Workspace.show_list_workspace; d.appendChild(c); c = Entry.createElement("span"); c.addClass("entryListSettingCheckWorkspace"); - b.visibleCheck = c; + a.visibleCheck = c; d.appendChild(c); c = Entry.createElement("div"); c.addClass("entryListSettingLengthWrapperWorkspace"); @@ -20851,54 +19616,54 @@ Entry.VariableContainer.prototype.generateListSettingView = function() { d.addClass("entryListSettingLengthSpanWorkspace"); d.innerHTML = Lang.Workspace.number_of_list; c.appendChild(d); - b.appendChild(c); + a.appendChild(c); d = Entry.createElement("div"); d.addClass("entryListSettingLengthControllerWorkspace"); c.appendChild(d); c = Entry.createElement("span"); c.addClass("entryListSettingMinusWorkspace"); - c.bindOnClick(function(b) { - a.selectedList.array_.pop(); - a.updateListSettingView(a.selectedList); + c.bindOnClick(function(a) { + b.selectedList.array_.pop(); + b.updateListSettingView(b.selectedList); }); d.appendChild(c); c = Entry.createElement("input"); c.addClass("entryListSettingLengthInputWorkspace"); c.onblur = function() { - a.setListLength(this.value); + b.setListLength(this.value); }; - c.onkeypress = function(b) { - 13 == b.keyCode && this.blur(); + c.onkeypress = function(a) { + 13 == a.keyCode && this.blur(); }; - b.lengthInput = c; + a.lengthInput = c; d.appendChild(c); c = Entry.createElement("span"); c.addClass("entryListSettingPlusWorkspace"); - c.bindOnClick(function(b) { - a.selectedList.array_.push({data:0}); - a.updateListSettingView(a.selectedList); + c.bindOnClick(function(a) { + b.selectedList.array_.push({data:0}); + b.updateListSettingView(b.selectedList); }); d.appendChild(c); d = Entry.createElement("div"); - b.seperator = d; - b.appendChild(d); + a.seperator = d; + a.appendChild(d); d.addClass("entryListSettingSeperatorWorkspace"); d = Entry.createElement("div"); d.addClass("entryListSettingListValuesWorkspace"); - b.listValues = d; - b.appendChild(d); + a.listValues = d; + a.appendChild(d); }; -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 d = this.listSettingView, c = d.listValues, e = d.visibleCheck, f = d.lengthInput, g = d.seperator; e.removeClass("entryListSettingCheckedWorkspace"); - a.isVisible() && e.addClass("entryListSettingCheckedWorkspace"); - f.value = a.array_.length; - for (a.listElement.appendChild(d);c.firstChild;) { + b.isVisible() && e.addClass("entryListSettingCheckedWorkspace"); + f.value = b.array_.length; + for (b.listElement.appendChild(d);c.firstChild;) { c.removeChild(c.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(d) { @@ -20912,116 +19677,115 @@ Entry.VariableContainer.prototype.updateListSettingView = function(a) { f.value = h[d].data; f.onblur = function() { h[d].data = this.value; - a.updateView(); + b.updateView(); }; - f.onkeypress = function(b) { - 13 == b.keyCode && this.blur(); + f.onkeypress = function(a) { + 13 == a.keyCode && this.blur(); }; f.addClass("entryListSettingEachInputWorkspace"); e.appendChild(f); f = Entry.createElement("span"); f.bindOnClick(function() { h.splice(d, 1); - b.updateListSettingView(); + a.updateListSettingView(); }); f.addClass("entryListSettingValueRemoveWorkspace"); e.appendChild(f); c.appendChild(e); })(e); } - a.updateView(); + b.updateView(); d.removeClass("entryRemove"); }; -Entry.VariableContainer.prototype.setListLength = function(a) { - a = Number(a); - var b = this.selectedList.array_; - if (!isNaN(a)) { - var d = b.length; - if (d < a) { - for (a -= d, d = 0;d < a;d++) { - b.push({data:0}); +Entry.VariableContainer.prototype.setListLength = function(b) { + b = Number(b); + var a = this.selectedList.array_; + if (!isNaN(b)) { + var d = a.length; + if (d < b) { + for (b -= d, d = 0;d < b;d++) { + a.push({data:0}); } } else { - d > a && (b.length = a); + d > b && (a.length = b); } } this.updateListSettingView(); }; Entry.VariableContainer.prototype.updateViews = function() { - var a = this.lists_; - this.variables_.map(function(b) { - b.updateView(); + var b = this.lists_; + this.variables_.map(function(a) { + a.updateView(); }); - a.map(function(b) { - b.updateView(); + 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 = [], d = this; - this.mapVariable(function(a, d) { - a.object_ && a.object_ == d && b.push(a); - }, a); - b.map(function(b) { - d.removeVariable(b); +Entry.VariableContainer.prototype.removeLocalVariables = function(b) { + var a = [], d = this; + this.mapVariable(function(b, d) { + b.object_ && b.object_ == d && a.push(b); + }, b); + a.map(function(a) { + d.removeVariable(a); }); }; 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(); + 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: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 && Entry.playground.mainWorkspace.getMode() === Entry.Workspace.MODE_BOARD) { - var d = {object:b.getCode().object, block:b}; - b.funcBlock && (d.funcBlock = b.funcBlock, delete b.funcBlock); - this[a].push(d); - if ("_functionRefs" == a) { - a = b.type.substr(5); - for (var c = Entry.variableContainer.functions_[a].content.getBlockList(), e = 0;e < c.length;e++) { - b = c[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 = d.object; - a && (b.funcBlock = d.block, a(b)); - }), f && f.dataAdd && f.dataAdd.forEach(function(a) { - b.getCode().object = d.object; - a && (b.funcBlock = d.block, a(b)); + var d = {object:a.getCode().object, block:a}; + a.funcBlock && (d.funcBlock = a.funcBlock, delete a.funcBlock); + this[b].push(d); + if ("_functionRefs" == b) { + for (var c = a.type.substr(5), e = Entry.variableContainer.functions_[c].content.getBlockList(), f = 0;f < e.length;f++) { + a = e[f]; + var g = a.events; + -1 < a.type.indexOf("func_") && a.type.substr(5) == c || (g && g.viewAdd && g.viewAdd.forEach(function(b) { + a.getCode().object = d.object; + b && (a.funcBlock = d.block, b(a)); + }), g && g.dataAdd && g.dataAdd.forEach(function(b) { + a.getCode().object = d.object; + b && (a.funcBlock = d.block, b(a)); })); } } return d; } }; -Entry.VariableContainer.prototype.removeRef = function(a, b) { +Entry.VariableContainer.prototype.removeRef = function(b, a) { if (Entry.playground.mainWorkspace && Entry.playground.mainWorkspace.getMode() === Entry.Workspace.MODE_BOARD) { - for (var d = this[a], c = 0;c < d.length;c++) { - if (d[c].block == b) { + for (var d = this[b], c = 0;c < d.length;c++) { + if (d[c].block == a) { d.splice(c, 1); break; } } - if ("_functionRefs" == a && (a = b.type.substr(5), c = Entry.variableContainer.functions_[a])) { - for (d = c.content.getBlockList(), c = 0;c < d.length;c++) { - b = d[c]; - 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 && (d = a.type.substr(5), c = Entry.variableContainer.functions_[d])) { + for (var e = c.content.getBlockList(), c = 0;c < e.length;c++) { + a = e[c]; + var f = a.events; + -1 < a.type.indexOf("func_") && a.type.substr(5) == d || (f && f.viewDestroy && f.viewDestroy.forEach(function(b) { + b && b(a); + }), f && f.dataDestroy && f.dataDestroy.forEach(function(b) { + b && b(a); })); } } @@ -21030,10 +19794,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() { @@ -21041,9 +19805,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); }}; @@ -21053,9 +19817,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; @@ -21070,10 +19834,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; } @@ -21087,10 +19851,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; } @@ -21104,22 +19868,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, d = function() { + var b = Ntry.STATIC, a = this, d = function() { window.setTimeout(function() { Ntry.dispatchEvent("unitAction", Ntry.STATIC.WALK, function() { - b.isAction = !1; + a.isAction = !1; }); }, 3); }, c; switch(Ntry.unitComp.direction) { case Ntry.STATIC.EAST: - c = a.TURN_LEFT; + c = b.TURN_LEFT; break; case Ntry.STATIC.SOUTH: - c = a.HALF_ROTATION; + c = b.HALF_ROTATION; break; case Ntry.STATIC.WEST: - c = a.TURN_RIGHT; + c = b.TURN_RIGHT; break; default: d(); @@ -21129,7 +19893,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; @@ -21138,22 +19902,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, d = function() { + var a = this, d = function() { window.setTimeout(function() { - Ntry.dispatchEvent("unitAction", a.WALK, function() { - b.isAction = !1; + Ntry.dispatchEvent("unitAction", b.WALK, function() { + a.isAction = !1; }); }, 3); }, c; switch(Ntry.unitComp.direction) { - case a.SOUTH: - c = a.TURN_LEFT; + case b.SOUTH: + c = b.TURN_LEFT; break; - case a.WEST: - c = a.HALF_ROTATION; + case b.WEST: + c = b.HALF_ROTATION; break; - case a.NORTH: - c = a.TURN_RIGHT; + case b.NORTH: + c = b.TURN_RIGHT; break; default: d(); @@ -21171,22 +19935,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, d = function() { + var b = Ntry.STATIC, a = this, d = function() { window.setTimeout(function() { Ntry.dispatchEvent("unitAction", Ntry.STATIC.WALK, function() { - b.isAction = !1; + a.isAction = !1; }); }, 3); }, c; switch(Ntry.unitComp.direction) { - case a.EAST: - c = a.TURN_RIGHT; + case b.EAST: + c = b.TURN_RIGHT; break; - case a.NORTH: - c = a.HALF_ROTATION; + case b.NORTH: + c = b.HALF_ROTATION; break; - case a.WEST: - c = a.TURN_LEFT; + case b.WEST: + c = b.TURN_LEFT; break; default: d(); @@ -21204,22 +19968,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, d = function() { + var b = Ntry.STATIC, a = this, d = function() { window.setTimeout(function() { - Ntry.dispatchEvent("unitAction", a.WALK, function() { - b.isAction = !1; + Ntry.dispatchEvent("unitAction", b.WALK, function() { + a.isAction = !1; }); }, 3); }, c; switch(Ntry.unitComp.direction) { - case a.SOUTH: - c = a.TURN_RIGHT; + case b.SOUTH: + c = b.TURN_RIGHT; break; - case a.EAST: - c = a.HALF_ROTATION; + case b.EAST: + c = b.HALF_ROTATION; break; - case a.NORTH: - c = a.TURN_LEFT; + case b.NORTH: + c = b.TURN_LEFT; break; default: d(); @@ -21229,9 +19993,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); }}; @@ -21244,9 +20008,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; } @@ -21260,9 +20024,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; } @@ -21276,9 +20040,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; } @@ -21292,59 +20056,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, d; - for (d in a) { - b = a[d]; + var b = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT), a, d; + for (d in b) { + a = b[d]; } - 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, d; - for (d in a) { - b = a[d]; + var b = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT), a, d; + for (d in b) { + a = b[d]; } - 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); }}; @@ -21357,9 +20121,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; } @@ -21370,9 +20134,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; @@ -21381,62 +20145,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, d; - for (d in a) { - b = a[d]; - } - 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); - d = 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, d; + for (d in b) { + a = b[d]; + } + 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); + d = Ntry.entityManager.find({type:Ntry.STATIC.GRID, x:a.x, y:a.y}); + b = this.block.statements[0]; if (0 === d.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, d; - for (d in a) { - b = a[d]; + var b = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT), a, d; + for (d in b) { + a = b[d]; } - 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(); @@ -21444,44 +20208,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, d; - for (d in a) { - b = a[d]; + var b = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT), a, d; + for (d in b) { + a = b[d]; } - 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, d; - for (d in a) { - b = a[d]; + var b = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT), a, d; + for (d in b) { + a = b[d]; } - 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; } } }}; @@ -21494,9 +20258,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; } @@ -21510,9 +20274,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; } @@ -21526,9 +20290,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; } @@ -21537,2056 +20301,2756 @@ 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, d) { - this._data = new Entry.Collection; - this._code = b; +Entry.BlockMenu = function(b, a, d, c) { + Entry.Model(this, !1); + this._align = a || "CENTER"; + this.setAlign(this._align); + this._scroll = void 0 !== c ? c : !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 = d; + this._generateView(d); + 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 = d ? d : b; - this.load(a); -}; -(function(a) { - a.load = function(b, a) { - void 0 === b && (b = []); - if (!(b instanceof Array)) { - return console.error("thread must be array"); + d && this._generateCategoryCodes(d); + 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, c = 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) { + c._scroller && c._scroller.setOpacity(1); + a = c.workspace.selectedBlockView; + !Entry.playground || Entry.playground.resizing || a && a.dragMode === Entry.DRAG_MODE_DRAG || (Entry.playground.focusBlockMenu = !0, a = c.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 && (c._scroller && c._scroller.setOpacity(0), (a = this.widthBackup) && $(this).stop().animate({width:a}, 200), delete this.widthBackup, delete Entry.playground.focusBlockMenu); + }); + $(window).scroll(function() { + c.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.workspace.getMode(); + this.workspace.getMode() === Entry.Workspace.MODE_VIMBOARD ? a.mode && "code" !== a.mode || this.renderText() : "text" === a.mode && this.renderBlock(); + 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, c = "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 = c - 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, c = b.getMode(), e = this.dragBlock, f = this._svgWidth, g = b.selectedBoard; + if (!g || c != Entry.Workspace.MODE_BOARD && c != Entry.Workspace.MODE_OVERLAYBOARD) { + Entry.GlobalSvg.setView(e, b.getMode()) && Entry.GlobalSvg.addControl(a); + } else { + if (g.code && (b = e.block, c = b.getThread(), b && c)) { + b = c.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, c = Entry.GlobalSvg.width / 2, a = a.getBoard().offset().left; + return b < a - c; + } } + }; + 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(a) { + var b = this.code.getThreads(); + this.code.mode = "text"; for (var c = 0;c < b.length;c++) { - var e = b[c]; - e instanceof Entry.Block || e.isDummy ? (e.setThread(this), this._data.push(e)) : this._data.push(new Entry.Block(e, this)); + b[c].view.renderText(); } - (b = this._code.view) && this.createView(b.board, a); - }; - a.registerEvent = function(b, a) { - this._event = a; - this._code.registerEvent(b, a); + a && a(); }; - a.unregisterEvent = function(b, a) { - this._code.unregisterEvent(b, a); + b.renderBlock = function(a) { + var b = this.code.getThreads(); + this.code.mode = "code"; + for (var c = 0;c < b.length;c++) { + b[c].view.renderBlock(); + } + a && a(); }; - a.createView = function(b, a) { - this.view || (this.view = new Entry.ThreadView(this, b)); - this._data.getAll().forEach(function(c) { - c.createView(b, a); - }); + 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.destroyView = function() { - this.view = null; - this._data.map(function(b) { - b.destroyView(); + b.updateSplitters = function(a) { + a = void 0 === a ? 0 : a; + var b = this._svgWidth - 20, c; + this._splitters.forEach(function(e) { + c = parseFloat(e.getAttribute("y1")) + a; + e.attr({x2:b, y1:c, y2:c}); }); }; - a.separate = function(b, a) { - this._data.has(b.id) && (b = this._data.splice(this._data.indexOf(b), a), this._code.createThread(b), 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(b) { - b = this._data.indexOf(b); - b = this._data.splice(b); - this.changeEvent.notify(); - return b; + b.setWidth = function() { + this._svgWidth = this.blockMenuContainer.width(); + this.updateSplitters(); }; - a.insertByBlock = function(b, a) { - b = b ? this._data.indexOf(b) : -1; - for (var c = 0;c < a.length;c++) { - a[c].setThread(this); + b.setMenu = function() { + var a = this._categoryCodes, b = this._categoryElems, c; + for (c in a) { + for (var e = a[c], 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[c].addClass("entryRemove") : b[c].removeClass("entryRemove"); } - this._data.splice.apply(this._data, [b + 1, 0].concat(a)); - this.changeEvent.notify(); }; - a.insertToTop = function(b) { - b.setThread(this); - this._data.unshift.apply(this._data, [b]); - 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(b, a) { - b = b || this._code; - b = new Entry.Thread([], b); - for (var c = this._data, e = [], f = 0, g = c.length;f < g;f++) { - e.push(c[f].clone(b)); + b._convertSelector = function(a) { + if (isNaN(a)) { + return a; + } + a = Number(a); + for (var b = this._categories, c = this._categoryElems, e = 0;e < b.length;e++) { + var f = b[e]; + if (!c[f].hasClass("entryRemove") && 0 === a--) { + return f; + } } - b.load(e, a); - return b; }; - a.toJSON = function(b, a) { - var c = []; - for (a = void 0 === a ? 0 : a;a < this._data.length;a++) { - this._data[a] instanceof Entry.Block && c.push(this._data[a].toJSON(b)); + b.selectMenu = function(a, b) { + var c = this._convertSelector(a); + if (c) { + switch(c) { + case "variable": + Entry.playground.checkVariables(); + break; + case "arduino": + this._generateHwCode(); + } + var e = this._categoryElems[c], 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[c], this._selectedCategoryView = e, e.addClass("entrySelectedCategory"), f.constructor !== Entry.Code && (f = this._categoryCodes[c] = new Entry.Code(f)), this.changeCode(f)); + this.lastSelector = c; + } else { + this.align(); } - return c; }; - a.destroy = function(b) { - this._code.destroyThread(this, !1); - this.view && this.view.destroy(b); - for (var a = this._data, c = a.length - 1;0 <= c;c--) { - a[c].destroy(b); + b._generateCategoryCodes = function(a) { + this._categoryCodes = {}; + for (var b = 0;b < a.length;b++) { + var c = a[b], e = []; + c.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}]); + } + }); + c = c.category; + this._categories.push(c); + this._categoryCodes[c] = e; } }; - a.getBlock = function(b) { - return this._data[b]; + 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(b) { - return b; - }); + b.unbanClass = function(a, b) { + var c = this._bannedClass.indexOf(a); + -1 < c && this._bannedClass.splice(c, 1); + this.align(b); }; - a.countBlock = function() { - for (var b = 0, a = 0;a < this._data.length;a++) { - var c = this._data[a]; - if (c.type && (b++, c = c.statements)) { - for (var e = 0;e < c.length;e++) { - b += c[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 b; }; - a.handleChange = function() { - 0 === this._data.length && this.destroy(); + b._addControl = function(a) { + var b = this; + a.on("wheel", function() { + b._mouseWheel.apply(b, arguments); + }); + b._scroller && $(this.svg).bind("mousedown touchstart", function(a) { + b.onMouseDown.apply(b, arguments); + }); }; - a.getCode = function() { - return this._code; + b.onMouseDown = function(a) { + function b(a) { + a.stopPropagation && a.stopPropagation(); + a.preventDefault && a.preventDefault(); + a = Entry.Utils.convertMouseEvent(a); + var c = e.dragInstance; + e._scroller.scroll(-a.pageY + c.offsetY); + c.set({offsetY:a.pageY}); + } + function c(a) { + $(document).unbind(".blockMenu"); + delete e.dragInstance; + } + a.stopPropagation && a.stopPropagation(); + a.preventDefault && a.preventDefault(); + var e = this; + if (0 === a.button || a.originalEvent && a.originalEvent.touches) { + a = Entry.Utils.convertMouseEvent(a); + Entry.documentMousedown && Entry.documentMousedown.notify(a); + var f = $(document); + f.bind("mousemove.blockMenu", b); + f.bind("mouseup.blockMenu", c); + f.bind("touchmove.blockMenu", b); + f.bind("touchend.blockMenu", c); + this.dragInstance = new Entry.DragInstance({startY:a.pageY, offsetY:a.pageY}); + } }; - a.setCode = function(b) { - this._code = b; + 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(b) { - this._data.remove(b); - 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(b) { - b = this._data.indexOf(b); - return this._data.at(b - 1); + b._handleDragBlock = function() { + this._boardBlockView = null; + this._scroller && this._scroller.setOpacity(0); }; - a.getNextBlock = function(b) { - b = this._data.indexOf(b); - return this._data.at(b + 1); + b._captureKeyEvent = function(a) { + var b = a.keyCode, c = Entry.type; + a.ctrlKey && "workspace" == c && 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(b) { - function a(c) { - if (b == c.type) { - return !0; + 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 c = a[b]; + c.constructor == Entry.Code && c.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 < a.length;b++) { + this._generateCategoryElement(a[b].category); } - for (var f = c.params, g = 0;g < f.length;g++) { - var h = f[g]; - if (h && h.constructor == Entry.Block && a(h)) { - return !0; - } + } + }; + b._generateCategoryElement = function(a) { + var b = this; + (function(a, e) { + a.text(Lang.Blocks[e.toUpperCase()]); + b._categoryElems[e] = a; + a.bindOnClick(function(a) { + b.selectMenu(e); + }); + })(Entry.Dom("li", {id:"entryCategory" + a, class:"entryCategoryElementWorkspace", parent:this._categoryCol}), a); + }; + b.updateOffset = function() { + this._offset = this.svgDom.offset(); + }; + b.offset = function() { + (!this._offset || 0 === this._offset.top && 0 === this._offset.left) && this.updateOffset(); + return this._offset; + }; + b._generateHwCode = function() { + var a = this._categoryCodes.arduino; + a instanceof Entry.Code && a.clear(); + for (var b = this._categoryData, c, a = b.length - 1;0 <= a;a--) { + if ("arduino" === b[a].category) { + c = b[a].blocks; + break; } - if (c = c.statements) { - for (f = 0;f < c.length;f++) { - if (c[f].hasBlockType(b)) { - return !0; + } + b = []; + for (a = 0;a < c.length;a++) { + var e = c[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}]); } } - return !1; } - for (var c = 0;c < this._data.length;c++) { - if (a(this._data[c])) { - return !0; - } + this._categoryCodes.arduino = b; + }; + b.setAlign = function(a) { + this._align = a || "CENTER"; + }; +})(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}); } - return !1; }; - a.getCount = function(b) { - var a = this._data.length; - b && (a -= this._data.indexOf(b)); - return a; + b.updateScrollBar = function(a) { + this.vY += a; + this.vScrollbar.attr({y:this.vY}); }; - a.indexOf = function(b) { - return this._data.indexOf(b); + 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.pointer = function(b, a) { - a = this.indexOf(a); - b.unshift(a); - this.parent instanceof Entry.Block && b.unshift(this.parent.indexOfStatements(this)); - return this._code === this.parent ? (b.unshift(this._code.indexOf(this)), a = this._data[0], b.unshift(a.y), b.unshift(a.x), b) : this.parent.pointer(b); + 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.getBlockList = function(b, a) { - for (var c = [], e = 0;e < this._data.length;e++) { - c = c.concat(this._data[e].getBlockList(b, a)); + b.setVisible = function(a) { + a != this.isVisible() && (this._visible = a, this.svgGroup.attr({display:!0 === a ? "block" : "none"})); + }; + b.setOpacity = function(a) { + this._opacity != a && (this.vScrollbar.attr({opacity:a}), this._opacity = a); + }; + b.isVisible = function() { + return this._visible; + }; + b._updateRatio = function() { + var a = this.board, b = a.svgBlockGroup.getBoundingClientRect(), c = a.blockMenuContainer.height(), a = a.offset(); + this.vRatio = b = (b.height + (b.top - a.top) + 10) / c; + 1 >= 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}); } - return c; + function c(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", c); + g.bind("touchmove.scroll", b); + g.bind("touchend.scroll", c); + e.dragInstance = new Entry.DragInstance({startY:f.pageY, offsetY:f.pageY}); + } + a.stopPropagation(); }; - a.stringify = function() { - return JSON.stringify(this.toJSON()); + b._addControl = function() { + $(this.vScrollbar).bind("mousedown touchstart", this.mouseHandler); }; -})(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, d = a.contentHeight, d = Math.max(30, d + 2), b = Math.max(0, b + 9 - d / 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, d).replace(/%w/gi, b).replace(/%bw/gi, b - 8).replace(/%h/gi, d / 2).replace(/%sh/gi, a + 1); -}, magnets:function(a) { - var b = Math.max(a.contentHeight + 2, 30), d = a._statements[0] ? a._statements[0].height : 20, d = Math.max(d, 20); - return {previous:{x:0, y:0}, next:{x:0, y:d + b + 18 + a.offsetY}}; -}, box:function(a) { - var b = a.contentWidth, d = 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:d + 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, d = a.contentHeight, d = Math.max(30, d + 2), b = Math.max(0, b + 9 - d / 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, d).replace(/%w/gi, b).replace(/%h/gi, d / 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), d = a._statements[0] ? a._statements[0].height : 20, d = Math.max(d, 51); - return {previous:{x:0, y:0}, next:{x:0, y:d + b + 13 + a.offsetY}}; -}, box:function(a) { - var b = a.contentWidth, d = 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:d + 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, d = a.contentHeight % 1E6, c = Math.floor(a.contentHeight / 1E6), d = Math.max(30, d + 2), c = Math.max(30, c + 2), b = Math.max(0, b + 5 - d / 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, d).replace(/%wh2/gi, c).replace(/%w/gi, b).replace(/%bw/gi, b - 8).replace(/%h1/gi, d / 2).replace(/%h2/gi, c / 2).replace(/%sh1/gi, a + 1).replace(/%sh2/gi, e + 1); -}, magnets:function(a) { - var b = Math.max(a.contentHeight % 1E6 + 2, 30), d = Math.max(Math.floor(a.contentHeight / 1E6) + 2, 30), c = a._statements[0] ? a._statements[0].height : 20, e = a._statements[1] ? a._statements[1].height : 20, c = Math.max(c, 20), e = Math.max(e, 20); - return {previous:{x:0, y:0}, next:{x:0, y:c + e + b + d + 19 + a.offsetY}}; -}, box:function(a) { - var b = a.contentWidth, d = Math.max(Math.floor(a.contentHeight / 1E6) + 2, 30), c = Math.max(a.contentHeight % 1E6 + 2, 30), e = a._statements[0] ? a._statements[0].height % 1E6 : 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:d + c + e + a + 17, marginBottom:0}; -}, statementPos:function(a) { - var b = Math.max(30, a.contentHeight % 1E6 + 2) + 1; - return [{x:16, y:b}, {x:16, y:b + Math.max(a._statements[0] ? a._statements[0].height % 1E6 : 20, 20) + Math.max(Math.floor(a.contentHeight / 1E6) + 2, 30) + 1}]; -}, contentPos:function(a) { - return {x:14, y:Math.max(a.contentHeight % 1E6, 28) / 2 + 1}; -}}; -Entry.Block = function(a, b) { - var d = this; +})(Entry.BlockMenuScroller.prototype); +Entry.BlockView = function(b, a, d) { + 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(b) { - Entry.Utils.isFunction(b) && b(d); - }); + 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]; + if (void 0 === this._schema) { + this.block.destroy(!1, !1); + } else { + this._schema.changeEvent && (this._schemaChangeEvent = this._schema.changeEvent.attach(this, this._updateSchema)); + var e = this._skeleton = Entry.skeleton[this._schema.skeleton]; + this._contents = []; + this._statements = []; + this.magnet = {}; + this._paramMap = {}; + e.magnets && e.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; + this.mouseHandler = function() { + var a = c.block.events; + a && a.mousedown && a.mousedown.forEach(function(a) { + a(c); + }); + c.onMouseDown.apply(c, arguments); + }; + this._startRender(b, d); + 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; + "workspace" == Entry.type && a && !this.isInBlockMenu && a.forEach(function(a) { + Entry.Utils.isFunction(a) && a(b); + }); + } }; -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(b) { - b.id || (b.id = Entry.Utils.generateId()); - this.set(b); - this.loadSchema(); - }; - a.changeSchema = function(b) { - this.set({params:[]}); - this.loadSchema(); - }; - a.getSchema = function() { - this._schema || this.loadSchema(); - return this._schema; +Entry.BlockView.PARAM_SPACE = 5; +Entry.BlockView.DRAG_RADIUS = 5; +Entry.BlockView.pngMap = {}; +(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 c = this, e = this._skeleton; + this.svgGroup.attr({class:"block"}); + var f = e.classes; + f && 0 !== f.length && f.forEach(function(a) { + c.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) { + c._mouseEnable && c._changeFill(!0); + }), $(this._path).mouseleave(function(a) { + c._mouseEnable && c._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(); }; - 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 b = this._schema.events; - if (b) { - for (var a in b) { - this.events[a] || (this.events[a] = []); - for (var c = b[a], e = 0;e < c.length;e++) { - var f = c[e]; - f && 0 > this.events[a].indexOf(f) && this.events[a].push(f); + 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 c = /(%\d)/mi, e = (b.template ? b.template : Lang.template[this.block.type]).split(c), f = b.params, g = 0;g < e.length;g++) { + var h = e[g].trim(); + if (0 !== h.length) { + if (c.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; + } else { + this._contents.push(new Entry.FieldText({text:h}, this)); + } } } - } - this._schema.event && this.thread.registerEvent(this, this._schema.event); - b = this.params; - a = this._schema.params; - for (e = 0;a && e < a.length;e++) { - c = void 0 === b[e] || null === b[e] ? a[e].value : b[e], f = b[e] || e < b.length, !c || "Output" !== a[e].type && "Block" !== a[e].type || (c = new Entry.Block(c, this.thread)), f ? b.splice(e, 1, c) : b.push(c); - } - if (b = this._schema.statements) { - for (e = 0;e < b.length;e++) { - this.statements.splice(e, 1, new Entry.Thread(this.statements[e], this.getCode(), 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: + if ("basic_button" === this._schema.skeleton) { + this._startContentRender(Entry.Workspace.MODE_BOARD); + return; + } + b = this.getBoard().workspace.getCodeToText(this.block); + a = !1; + /(if)+(.|\n)+(else)+/.test(b) && (g = b.split("\n"), b = g.shift() + " " + g.shift(), a = !0, g = g.join(" ")); + b = {text:b, color:"white"}; + this.block._schema.vimModeFontColor && (b.color = this.block._schema.vimModeFontColor); + this._contents.push(new Entry.FieldText(b, this)); + a && (this._contents.push(new Entry.FieldLineBreak(null, this)), b.text = g, this._contents.push(new Entry.FieldText(b, this))); } + this.alignContent(!1); + }; + b._updateSchema = function() { + this._startContentRender(); }; - a.changeType = function(b) { + b.changeType = function(a) { this._schemaChangeEvent && this._schemaChangeEvent.destroy(); - this.set({type:b}); - this.loadSchema(); - this.view && this.view.changeType(b); + this._schema = Entry.block[a]; + this._schema.changeEvent && (this._schemaChangeEvent = this._schema.changeEvent.attach(this, this._updateSchema)); + this._updateSchema(); + }; + b.alignContent = function(a) { + !0 !== a && (a = !1); + for (var b = 0, c = 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++, c = l.box.y, b = 8) : (l.align(b, c, 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(1E6 * 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.setThread = function(b) { - this.set({thread:b}); + b._alignStatement = function(a, b) { + var c = this._skeleton.statementPos ? this._skeleton.statementPos(this) : [], e = this._statements[b]; + e && (c = c[b]) && e.align(c.x, c.y, a); }; - a.getThread = function() { - return this.thread; + b._render = function() { + this._renderPath(); + this.set(this._skeleton.box(this)); }; - a.insertAfter = function(b) { - this.thread.insertByBlock(this, b); + b._renderPath = function() { + var a = this._skeleton.path(this); + this._path.attr({d:a}); + this.set({animating:!1}); }; - a._updatePos = function() { - this.view && this.set({x:this.view.x, y:this.view.y}); + b._setPosition = function(a) { + this.svgGroup.attr("transform", "translate(" + this.x + "," + this.y + ")"); }; - a.moveTo = function(b, a) { - this.view && this.view._moveTo(b, a); - this._updatePos(); - this.getCode().changeEvent.notify(); + b._toLocalCoordinate = function(a) { + this._moveTo(0, 0, !1); + a.appendChild(this.svgGroup); }; - a.createView = function(b, a) { - this.view || (this.set({view:new Entry.BlockView(this, b, a)}), this._updatePos()); + b._toGlobalCoordinate = function(a) { + a = this.getAbsoluteCoordinate(a); + this._moveTo(a.x, a.y, !1); + this.getBoard().svgBlockGroup.appendChild(this.svgGroup); }; - a.destroyView = function() { - this.set({view:null}); + b._moveTo = function(a, b, c) { + this.set({x:a, y:b}); + this._lazyUpdatePos(); + this.visible && this.display && this._setPosition(c); }; - a.clone = function(b) { - return new Entry.Block(this.toJSON(!0), b); - }; - a.toJSON = function(b) { - var a = this._toJSON(); - delete a.view; - delete a.thread; - delete a.events; - b && delete a.id; - a.params = a.params.map(function(a) { - a instanceof Entry.Block && (a = a.toJSON(b)); - return a; - }); - a.statements = a.statements.map(function(a) { - return a.toJSON(b); + b._moveBy = function(a, b, c) { + return this._moveTo(this.x + a, this.y + b, c); + }; + 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.x = this.x; - a.y = this.y; - a.movable = this.movable; - a.deletable = this.deletable; - a.readOnly = this.readOnly; - return a; }; - a.destroy = function(b, a) { - var c = 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(b)); + b.removeControl = function() { + this._mouseEnable = !1; + $(this.svgGroup).unbind(".blockViewMousedown"); + }; + b.onMouseDown = function(a) { + function d(a) { + a.stopPropagation(); + var c = g.workspace.getMode(), d; + c === Entry.Workspace.MODE_VIMBOARD && b.vimBoardEvent(a, "dragOver"); + d = a.originalEvent && a.originalEvent.touches ? a.originalEvent.touches[0] : a; + var h = f.mouseDownCoordinate, h = Math.sqrt(Math.pow(d.pageX - h.x, 2) + Math.pow(d.pageY - h.y, 2)); + if (f.dragMode == Entry.DRAG_MODE_DRAG || h > Entry.BlockView.DRAG_RADIUS) { + e && (clearTimeout(e), e = null), f.movable && (f.isInBlockMenu ? g.cloneToGlobal(a) : (a = !1, f.dragMode != Entry.DRAG_MODE_DRAG && (f._toGlobalCoordinate(), f.dragMode = Entry.DRAG_MODE_DRAG, f.block.getThread().changeEvent.notify(), Entry.GlobalSvg.setView(f, c), a = !0), this.animating && this.set({animating:!1}), 0 === f.dragInstance.height && f.dragInstance.set({height:-1 + f.height}), c = f.dragInstance, f._moveBy(d.pageX - c.offsetX, d.pageY - c.offsetY, !1), c.set({offsetX:d.pageX, + offsetY:d.pageY}), Entry.GlobalSvg.position(), f.originPos || (f.originPos = {x:f.x, y:f.y}), a && g.generateCodeMagnetMap(), f._updateCloseBlock())); } } - if (e = this.statements) { - for (f = 0;f < e.length;f++) { - e[f].destroy(b); + function c(a) { + e && (clearTimeout(e), e = null); + $(document).unbind(".block"); + f.terminateDrag(a); + g && g.set({dragBlock:null}); + f._changeFill(!1); + Entry.GlobalSvg.remove(); + delete this.mouseDownCoordinate; + delete f.dragInstance; + } + a.stopPropagation && a.stopPropagation(); + a.preventDefault && a.preventDefault(); + var e = null, f = this; + this._changeFill(!1); + var g = this.getBoard(); + Entry.documentMousedown && Entry.documentMousedown.notify(a); + if (!this.readOnly && !g.viewOnly) { + g.setSelectedBlock(this); + this.dominate(); + if (0 === a.button || a.originalEvent && a.originalEvent.touches) { + var h = a.type, k; + k = a.originalEvent && a.originalEvent.touches ? a.originalEvent.touches[0] : a; + this.mouseDownCoordinate = {x:k.pageX, y:k.pageY}; + var l = $(document); + l.bind("mousemove.block touchmove.block", d); + l.bind("mouseup.block touchend.block", c); + this.dragInstance = new Entry.DragInstance({startX:k.pageX, startY:k.pageY, offsetX:k.pageX, offsetY:k.pageY, height:0, mode:!0}); + g.set({dragBlock:this}); + this.addDragging(); + this.dragMode = Entry.DRAG_MODE_MOUSEDOWN; + "touchstart" === h && (e = setTimeout(function() { + e && (e = null, c(), f._rightClick(a)); + }, 1E3)); + } else { + Entry.Utils.isRightButton(a) && this._rightClick(a); } + g.workspace.getMode() === Entry.Workspace.MODE_VIMBOARD && a && (vimBoard = $(".entryVimBoard>.CodeMirror")[0], document.getElementsByClassName("CodeMirror")[0].dispatchEvent(Entry.Utils.createMouseEvent("dragStart", event))); } - g = this.getPrevBlock(); - f = this.getNextBlock(); - this.getCode().unregisterBlock(this); - e = this.getThread(); - this._schema && this._schema.event && e.unregisterEvent(this, this._schema.event); - f && (a ? f.destroy(b, a) : g ? f.view && f.view.bindPrev(g) : (a = this.getThread().view.getParent(), a.constructor === Entry.FieldStatement ? (f.view && f.view.bindPrev(a), a.insertTopBlock(f)) : a.constructor === Entry.FieldStatement ? f.replace(a._valueBlock) : f.view._toGlobalCoordinate())); - !this.doNotSplice && e.spliceBlock ? e.spliceBlock(this) : delete this.doNotSplice; - this.view && this.view.destroy(b); - this._schemaChangeEvent && this._schemaChangeEvent.destroy(); - (b = this.events.dataDestroy) && this.getCode().object && b.forEach(function(b) { - Entry.Utils.isFunction(b) && b(c); - }); }; - a.getView = function() { - return this.view; + b.vimBoardEvent = function(a, b, c) { + a && (a = Entry.Utils.createMouseEvent(b, a), c && (a.block = c), document.getElementsByClassName("CodeMirror")[0].dispatchEvent(a)); + }; + b.terminateDrag = function(a) { + var b = this.getBoard(), c = 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 (c === 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 = c, 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; + c = 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(c.x, c.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.setMovable = function(b) { - this.movable != b && this.set({movable:b}); + b._updateCloseBlock = function() { + var a = this.getBoard(), b; + if (this._skeleton.magnets) { + for (var c in this.magnet) { + if (b = "next" === c ? this.getBoard().getNearestMagnet(this.x, this.y + this.getBelowHeight(), c) : this.getBoard().getNearestMagnet(this.x, this.y, c)) { + return a.setMagnetedBlock(b.view, c); + } + } + a.setMagnetedBlock(null); + } }; - a.setCopyable = function(b) { - this.copyable != b && this.set({copyable:b}); + b.dominate = function() { + this.block.getThread().view.dominate(); }; - a.isMovable = function() { - return this.movable; + b.getSvgRoot = function() { + for (var a = this.getBoard().svgBlockGroup, b = this.svgGroup;b.parentNode !== a;) { + b = b.parentNode; + } + return b; }; - a.isCopyable = function() { - return this.copyable; + b.getBoard = function() { + return this._board; }; - a.setDeletable = function(b) { - this.deletable != b && this.set({deletable:b}); + b._setBoard = function() { + this._board = this._board.code.board; }; - a.isDeletable = function() { - return this.deletable === Entry.Block.DELETABLE_TRUE; + b.destroy = function(a) { + $(this.svgGroup).unbind(".blockViewMousedown"); + 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 c = this.block; + a = c.events.viewDestroy; + "workspace" == Entry.type && a && !this.isInBlockMenu && a.forEach(function(a) { + Entry.Utils.isFunction(a) && a(c); + }); + this._schemaChangeEvent && this._schemaChangeEvent.destroy(); }; - a.isReadOnly = function() { - return this.readOnly; + 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.getCode = function() { - return this.thread.getCode(); + b.destroyShadow = function() { + this._shadow && (this._shadow.remove(), delete this._shadow); }; - a.doAdd = function() { - this.getCode().changeEvent.notify(); + 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(); + } }; - a.doMove = function() { - this._updatePos(); - this.getCode().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(), c = this.getAbsoluteCoordinate(), e; + if ("previous" === a) { + e = this.magnet.next, e = "translate(" + (c.x + e.x) + "," + (c.y + e.y) + ")"; + } else { + if ("next" === a) { + e = this.magnet.previous; + var f = this._board.dragBlock.getBelowHeight(); + e = "translate(" + (c.x + e.x) + "," + (c.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.doSeparate = function() { - this.separate(); + b.addDragging = function() { + this.svgGroup.addClass("dragging"); }; - a.doInsert = function(b) { - "basic" === this.getBlockType() ? this.insert(b) : this.replace(b); + b.removeDragging = function() { + this.svgGroup.removeClass("dragging"); }; - a.doDestroy = function(b) { - this.destroy(b); - this.getCode().changeEvent.notify(); - return this; + b.addSelected = function() { + this.svgGroup.addClass("selected"); }; - a.doDestroyBelow = function(b) { - console.log("destroyBelow", this.id, this.x, this.y); - this.destroy(b, !0); - this.getCode().changeEvent.notify(); - return this; + b.removeSelected = function() { + this.svgGroup.removeClass("selected"); }; - a.copy = function() { - var b = this.getThread(), a = []; - if (b instanceof Entry.Thread) { - for (var c = b.getBlocks().indexOf(this), b = b.toJSON(!0, c), c = 0;c < b.length;c++) { - a.push(b[c]); - } - } else { - a.push(this.toJSON(!0)); - } - b = this.view.getAbsoluteCoordinate(); - c = a[0]; - c.x = b.x + 15; - c.y = b.y + 15; - c.id = Entry.Utils.generateId(); - return a; + b.getSkeleton = function() { + return this._skeleton; }; - a.copyToClipboard = function() { - Entry.clipboard = this.copy(); + b.getContentPos = function() { + return this._skeleton.contentPos(this); }; - a.separate = function(b) { - this.thread.separate(this, b); - this._updatePos(); - this.getCode().changeEvent.notify(); + b.renderText = function() { + this._startContentRender(Entry.Workspace.MODE_VIMBOARD); }; - a.insert = function(b) { - var a = this.thread.cut(this); - b instanceof Entry.Thread ? b.insertByBlock(null, a) : b.insertAfter(a); - this._updatePos(); - this.getCode().changeEvent.notify(); + 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); }; - a.replace = function(b) { - this.thread.cut(this); - b.getThread().replace(this); - this.getCode().changeEvent.notify(); + b._setMovable = function() { + this.movable = null !== this.block.isMovable() ? this.block.isMovable() : void 0 !== this._skeleton.movable ? this._skeleton.movable : !0; }; - a.getPrevBlock = function() { - return this.thread.getPrevBlock(this); + b._setReadOnly = function() { + this.readOnly = null !== this.block.isReadOnly() ? this.block.isReadOnly() : void 0 !== this._skeleton.readOnly ? this._skeleton.readOnly : !1; }; - a.getNextBlock = function() { - return this.thread.getNextBlock(this) || null; + b._setCopyable = function() { + this.copyable = null !== this.block.isCopyable() ? this.block.isCopyable() : void 0 !== this._skeleton.copyable ? this._skeleton.copyable : !0; }; - a.getLastBlock = function() { - return this.thread.getLastBlock(); + b.bumpAway = function(a, b) { + var c = this; + a = a || 15; + b ? window.setTimeout(function() { + c._moveBy(a, a, !1); + }, b) : c._moveBy(a, a, !1); }; - a.getOutputBlock = function() { - for (var b = this._schema.params, a = 0;b && a < b.length;a++) { - if ("Output" === b[a].type) { - return this.params[a]; + 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)); } - } - return null; - }; - a.getTerminateOutputBlock = function() { - for (var b = this;;) { - var a = b.getOutputBlock(); - if (!a) { - return b; + } else { + if (a = this.block.getPrevBlock()) { + this._toLocalCoordinate(a.view._nextGroup), (a = this.block.getNextBlock()) && a.view && a.view._toLocalCoordinate(this._nextGroup); } - b = a; } }; - a.getBlockType = function() { - if (!this.view) { - return null; + b.getAbsoluteCoordinate = function(a) { + a = void 0 !== a ? a : this.dragMode; + if (a === Entry.DRAG_MODE_DRAG) { + return {x:this.x, y:this.y}; } - var b = Entry.skeleton[this._schema.skeleton].magnets(this.view); - return b.next || b.previous ? "basic" : b.boolean || b.string ? "field" : b.output ? "output" : null; + a = this.block.getThread().view.requestAbsoluteCoordinate(this); + a.x += this.x; + a.y += this.y; + return a; }; - a.indexOfStatements = function(b) { - return this.statements.indexOf(b); + b.getBelowHeight = function() { + return this.block.getThread().view.requestPartHeight(this); }; - a.pointer = function(b) { - b || (b = []); - return this.thread.pointer(b, this); + b._updateDisplay = function() { + this.svgGroup.attr({display:!1 === this.display ? "none" : "block"}); + this.display && this._setPosition(); }; - a.targetPointer = function() { - var b = this.thread.pointer([], this); - 4 === b.length && 0 === b[3] && b.pop(); - return b; + 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.getBlockList = function(b, a) { - var c = []; - if (!this._schema) { - return []; + b._updateContents = function() { + for (var a = 0;a < this._contents.length;a++) { + this._contents[a].renderStart(); } - if (b && this._schema.isPrimitive) { - return c; - } - (a || this.type) === this.type && c.push(this); - for (var e = this.params, f = 0;f < e.length;f++) { - var g = e[f]; - g && g.constructor == Entry.Block && (c = c.concat(g.getBlockList(b, a))); + this.alignContent(!1); + }; + b._destroyObservers = function() { + for (var a = this._observers;a.length;) { + a.pop().destroy(); } - if (e = this.statements) { - for (f = 0;f < e.length;f++) { - c = c.concat(e[f].getBlockList(b, a)); - } + }; + b._changeFill = function(a) { + var b = this.getBoard(); + if (b.patternRect && !b.dragBlock) { + var c = this._fillColor, e = this._path, b = this.getBoard(); + a ? (b.setPatternRectFill(c), c = "url(#blockHoverPattern_" + this.getBoard().suffix + ")") : b.disablePattern(); + e.attr({fill:c}); } - return c; }; - a.stringify = function() { - return JSON.stringify(this.toJSON()); + b.addActivated = function() { + this.svgGroup.addClass("activated"); }; -})(Entry.Block.prototype); -Entry.BlockMenu = function(a, b, d, c) { - Entry.Model(this, !1); - this._align = b || "CENTER"; - this.setAlign(this._align); - this._scroll = void 0 !== c ? c : !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 = d; - this._generateView(d); - 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); - d && this._generateCategoryCodes(d); - 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, c = 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) { - c._scroller && c._scroller.setOpacity(1); - b = c.workspace.selectedBlockView; - !Entry.playground || Entry.playground.resizing || b && b.dragMode === Entry.DRAG_MODE_DRAG || (Entry.playground.focusBlockMenu = !0, b = c.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 && (c._scroller && c._scroller.setOpacity(0), (b = this.widthBackup) && $(this).stop().animate({width:b}, 200), delete this.widthBackup, delete Entry.playground.focusBlockMenu); - }); - $(window).scroll(function() { - c.updateOffset(); - }); + b.removeActivated = function() { + this.svgGroup.removeClass("activated"); }; - a.changeCode = function(b) { - if (!(b instanceof Entry.Code)) { - return console.error("You must inject code instance"); + b.reDraw = function() { + if (this.visible) { + var a = this.block; + requestAnimFrame(this._updateContents.bind(this)); + var b = a.params; + if (b) { + for (var c = 0;c < b.length;c++) { + var e = b[c]; + e instanceof Entry.Block && e.view.reDraw(); + } + } + if (a = a.statements) { + for (c = 0;c < a.length;c++) { + a[c].view.reDraw(); + } + } } - 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.workspace.getMode(); - this.workspace.getMode() === Entry.Workspace.MODE_VIMBOARD ? b.mode && "code" !== b.mode || this.renderText() : "text" === b.mode && this.renderBlock(); - 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); + b.getParam = function(a) { + return this._paramMap[a]; }; - 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, c = "LEFT" == this._align ? 10 : this.svgDom.width() / 2, e, f = 0, g = b.length;f < g;f++) { - var h = b[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(a), a += 15), e = h, h = c - k.offsetX, "CENTER" == this._align && (h -= k.width / 2), a -= k.offsetY, k._moveTo(h, a, !1), a += k.height + 15); - } - this.updateSplitters(); - this.changeEvent.notify(); + b.getDataUrl = function(a, b) { + function c() { + g = g.replace("(svgGroup)", (new XMLSerializer).serializeToString(k)).replace("%W", h.width * m).replace("%H", h.height * m).replace("(defs)", (new XMLSerializer).serializeToString(q[0])).replace(/>\s+/g, ">").replace(/\s+ e || c.splice(e, 1); + } + }; + b.raiseEvent = function(a, b, c) { + 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 === c || -1 < g.params.indexOf(c)) { + g = new Entry.Executor(a[f], b), this.executors.push(g), e.push(g); + } } - 0 === f ? a[c].addClass("entryRemove") : a[c].removeClass("entryRemove"); + return e; } }; - a.getCategoryCodes = function(b) { - b = this._convertSelector(b); - var a = this._categoryCodes[b]; - a || (this._generateCategoryElement(b), a = []); - a instanceof Entry.Code || (a = this._categoryCodes[b] = new Entry.Code(a)); - return a; + b.getEventMap = function(a) { + return this._eventMap[a]; }; - a._convertSelector = function(b) { - if (isNaN(b)) { - return b; - } - b = Number(b); - for (var a = this._categories, c = this._categoryElems, e = 0;e < a.length;e++) { - var f = a[e]; - if (!c[f].hasClass("entryRemove") && 0 === b--) { - return f; - } + b.map = function(a) { + this._data.map(a); + }; + b.tick = function() { + for (var a = this.executors, b = 0;b < a.length;b++) { + var c = a[b]; + c.isEnd() ? (a.splice(b--, 1), 0 === a.length && this.executeEndEvent.notify()) : c.execute(); } }; - a.selectMenu = function(b, a) { - if (b = this._convertSelector(b)) { - switch(b) { - case "variable": - Entry.playground.checkVariables(); - break; - case "arduino": - this._generateHwCode(); - } - var c = this._categoryElems[b], e = this._selectedCategoryView, f = !1, g = this.workspace.board, h = g.view; - e && e.removeClass("entrySelectedCategory"); - c != e || a ? e || (this.visible || (f = !0, h.addClass("foldOut"), Entry.playground.showTabs()), h.removeClass("folding"), this.visible = !0) : (h.addClass("folding"), this._selectedCategoryView = null, c.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 && (a = this._categoryCodes[b], this._selectedCategoryView = c, c.addClass("entrySelectedCategory"), a.constructor !== Entry.Code && (a = this._categoryCodes[b] = new Entry.Code(a)), this.changeCode(a)); - this.lastSelector = b; - } else { - this.align(); + b.removeExecutor = function(a) { + a = this.executors.indexOf(a); + -1 < a && this.executors.splice(a, 1); + }; + b.clearExecutors = function() { + this.executors.forEach(function(a) { + a.end(); + }); + this.executors = []; + }; + b.clearExecutorsByEntity = function(a) { + for (var b = this.executors, c = 0;c < b.length;c++) { + var e = b[c]; + e.entity === a && e.end(); } }; - a._generateCategoryCodes = function(b) { - this._categoryCodes = {}; - for (var a = 0;a < b.length;a++) { - var c = b[a], e = []; - c.blocks.forEach(function(b) { - var a = Entry.block[b]; - if (a && a.def) { - if (a.defs) { - for (b = 0;b < a.defs.length;b++) { - e.push([a.defs[b]]); - } - } else { - e.push([a.def]); - } - } else { - e.push([{type:b}]); - } - }); - c = c.category; - this._categories.push(c); - this._categoryCodes[c] = e; + b.addExecutor = function(a) { + this.executors.push(a); + }; + b.createThread = function(a, b) { + if (!(a instanceof Array)) { + return console.error("blocks must be array"); } + var c = new Entry.Thread(a, this); + void 0 === b ? this._data.push(c) : this._data.insert(c, b); + return c; }; - a.banClass = function(b, a) { - 0 > this._bannedClass.indexOf(b) && this._bannedClass.push(b); - this.align(a); + b.cloneThread = function(a, b) { + var c = a.clone(this, b); + this._data.push(c); + return c; }; - a.unbanClass = function(b, a) { - b = this._bannedClass.indexOf(b); - -1 < b && this._bannedClass.splice(b, 1); - this.align(a); + b.destroyThread = function(a, b) { + var c = this._data, e = c.indexOf(a); + 0 > e || c.splice(e, 1); }; - a.checkBanClass = function(b) { - if (b) { - b = b.isNotFor; - for (var a in this._bannedClass) { - if (b && -1 < b.indexOf(this._bannedClass[a])) { - return !0; - } - } - return !1; - } + b.doDestroyThread = function(a, b) { + var c = this._data, e = c.indexOf(a); + 0 > e || c.splice(e, 1); }; - a._addControl = function(b) { - var a = this; - b.on("wheel", function() { - a._mouseWheel.apply(a, arguments); - }); - a._scroller && $(this.svg).bind("mousedown touchstart", function(b) { - a.onMouseDown.apply(a, arguments); + b.getThreads = function() { + return this._data.map(function(a) { + return a; }); }; - a.onMouseDown = function(b) { - function a(b) { - b.stopPropagation && b.stopPropagation(); - b.preventDefault && b.preventDefault(); - b = Entry.Utils.convertMouseEvent(b); - var d = e.dragInstance; - e._scroller.scroll(-b.pageY + d.offsetY); - d.set({offsetY:b.pageY}); - } - function c(b) { - $(document).unbind(".blockMenu"); - delete e.dragInstance; + b.toJSON = function() { + for (var a = this.getThreads(), b = [], c = 0, e = a.length;c < e;c++) { + b.push(a[c].toJSON()); + } + return b; + }; + b.countBlock = function() { + for (var a = this.getThreads(), b = 0, c = 0;c < a.length;c++) { + b += a[c].countBlock(); } - b.stopPropagation && b.stopPropagation(); - b.preventDefault && b.preventDefault(); - var e = this; - if (0 === b.button || b.originalEvent && b.originalEvent.touches) { - b = Entry.Utils.convertMouseEvent(b); - Entry.documentMousedown && Entry.documentMousedown.notify(b); - var f = $(document); - f.bind("mousemove.blockMenu", a); - f.bind("mouseup.blockMenu", c); - f.bind("touchmove.blockMenu", a); - f.bind("touchend.blockMenu", c); - this.dragInstance = new Entry.DragInstance({startY:b.pageY, offsetY:b.pageY}); + return b; + }; + b.moveBy = function(a, b) { + for (var c = this.getThreads(), e = 0, f = c.length;e < f;e++) { + var g = c[e].getFirstBlock(); + g && g.view._moveBy(a, b, !1); } + c = this.board; + c instanceof Entry.BlockMenu && c.updateSplitters(b); }; - a._mouseWheel = function(b) { - b = b.originalEvent; - b.preventDefault(); - var a = Entry.disposeEvent; - a && a.notify(b); - this._scroller.scroll(-b.wheelDeltaY || b.deltaY / 3); + b.stringify = function() { + return JSON.stringify(this.toJSON()); }; - a.dominate = function(b) { - this.svgBlockGroup.appendChild(b.view.svgGroup); + b.dominate = function(a) { + a.view.setZIndex(this._maxZIndex++); }; - a.reDraw = function() { - this.selectMenu(this.lastSelector, !0); + b.indexOf = function(a) { + return this._data.indexOf(a); }; - a._handleDragBlock = function() { - this._boardBlockView = null; - this._scroller && this._scroller.setOpacity(0); + b._handleChange = function() { + Entry.creationChangedEvent && Entry.creationChangedEvent.notify(); }; - a._captureKeyEvent = function(b) { - var a = b.keyCode, c = Entry.type; - b.ctrlKey && "workspace" == c && 48 < a && 58 > a && (b.preventDefault(), this.selectMenu(a - 49)); + b.hasBlockType = function(a) { + for (var b = this.getThreads(), c = 0;c < b.length;c++) { + if (b[c].hasBlockType(a)) { + return !0; + } + } + return !1; }; - a.setPatternRectFill = function(b) { - this.patternRect.attr({fill:b}); - this.pattern.attr({style:""}); + b.findById = function(a) { + return this._blockMap[a]; }; - a.disablePattern = function() { - this.pattern.attr({style:"display: none"}); + b.registerBlock = function(a) { + this._blockMap[a.id] = a; }; - 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 c = b[a]; - c.constructor == Entry.Code && c.clear(); - } - this._categoryCodes = null; + b.unregisterBlock = function(a) { + delete this._blockMap[a.id]; }; - a.setCategoryData = function(b) { - this._clearCategory(); - this._categoryData = b; - this._generateCategoryView(b); - this._generateCategoryCodes(b); + 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 c = a.shift(), e = a.shift(); + -1 < c ? b = b.statements[c].getBlock(e) : -1 === c && (b = b.view.getParam(e)); + } + return b; }; - a._generateCategoryView = function(b) { - if (b) { - for (var a = 0;a < b.length;a++) { - this._generateCategoryElement(b[a].category); + b.getTargetByPointer = function(a) { + a = a.concat(); + a.shift(); + a.shift(); + var b = this._data[a.shift()], c; + if (1 === a.length) { + c = b.getBlock(a.shift() - 1); + } else { + for (c = b.getBlock(a.shift());a.length;) { + c instanceof Entry.Block || (c = c.getValueBlock()); + var e = a.shift(), b = a.shift(); + -1 < e ? (c = c.statements[e], c = a.length ? c.getBlock(b) : 0 === b ? c.view.getParent() : c.getBlock(b - 1)) : -1 === e && (c = c.view.getParam(b)); } } + return c; }; - a._generateCategoryElement = function(b) { - var a = this; - (function(b, e) { - b.text(Lang.Blocks[e.toUpperCase()]); - a._categoryElems[e] = b; - b.bindOnClick(function(b) { - a.selectMenu(e); - }); - })(Entry.Dom("li", {id:"entryCategory" + b, class:"entryCategoryElementWorkspace", parent:this._categoryCol}), b); + b.getBlockList = function(a, b) { + for (var c = this.getThreads(), e = [], f = 0;f < c.length;f++) { + e = e.concat(c[f].getBlockList(a, b)); + } + return e; }; - a.updateOffset = function() { - this._offset = this.svgDom.offset(); + b.removeBlocksByType = function(a) { + this.getBlockList(!1, a).forEach(function(a) { + a.doDestroy(); + }); }; - a.offset = function() { - (!this._offset || 0 === this._offset.top && 0 === this._offset.left) && this.updateOffset(); - return this._offset; +})(Entry.Code.prototype); +Entry.CodeView = function(b, a) { + Entry.Model(this, !1); + 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._data.getAll().forEach(function(b) { + b.createView(a); + }); + b.observe(this, "_setBoard", ["board"]); +}; +(function(b) { + b.schema = {board:null, scrollX:0, scrollY:0}; + b._setBoard = function() { + this.set({board:this.code.board}); }; - a._generateHwCode = function() { - var b = this._categoryCodes.arduino; - b instanceof Entry.Code && b.clear(); - for (var a = this._categoryData, c, b = a.length - 1;0 <= b;b--) { - if ("arduino" === a[b].category) { - c = a[b].blocks; - break; - } - } - a = []; - for (b = 0;b < c.length;b++) { - var e = c[b], f = Entry.block[e]; - if (!this.checkBanClass(f)) { - if (f && f.def) { - if (f.defs) { - for (b = 0;b < f.defs.length;b++) { - a.push([f.defs[b]]); - } + b.reDraw = function() { + this.code.map(function(a) { + a.view.reDraw(); + }); + }; + b.destroy = function() { + this.code.map(function(a) { + a.destroyView(); + }); + }; +})(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, c = a.getBoard().svgGroup; + b.remove(); + a = a.getAbsoluteCoordinate(); + b.attr({cx:a.x, cy:a.y}); + c.appendChild(b); + b._startTime = new Date; + return this; + }; + b.dispose = function() { + var a = this, b = this._ripple, c = (new Date - b._startTime) / 150; + 1 < c ? b.remove() : (b.attr({r:25 * c, opacity:1 - c}), 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 (;;) { + var a = null; + try { + var b = this.scope.block.getSchema(); + b && (a = b.func.call(this.scope, this.entity, this.scope)); + } catch (e) { + if ("AsyncError" === e.name) { + a = Entry.STATIC.BREAK; } else { - a.push([f.def]); + var c = !1; + "\ub7f0\ud0c0\uc784 \uc5d0\ub7ec" != e.message && (c = !0); + Entry.Utils.stopProjectWithToast(this.scope, "\ub7f0\ud0c0\uc784 \uc5d0\ub7ec", c); + } + } + 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) { + if (a = this.scope, this.scope = this._callStack.pop(), this.scope.isLooped !== a.isLooped) { + break; + } + } else { + break; + } } } else { - a.push([{type:e}]); + if (a !== Entry.STATIC.CONTINUE && (a === Entry.STATIC.BREAK || this.scope === a)) { + break; + } } } } - this._categoryCodes.arduino = a; - }; - a.setAlign = function(b) { - this._align = b || "CENTER"; }; -})(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.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; }; - 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.break = function() { + this._callStack.length && (this.scope = this._callStack.pop()); + return Entry.STATIC.PASS; }; - a.resizeScrollBar = function() { - this._updateRatio(); - if (this._visible && 0 !== this.vRatio) { - var b = this.board.blockMenuContainer; - this.vScrollbar.attr({width:9, height:b.height() / this.vRatio, x:b.width() - 9}); + 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(); } + return Entry.STATIC.PASS; }; - a.updateScrollBar = function(b) { - this.vY += b; - this.vScrollbar.attr({y:this.vY}); + b.end = function() { + this.scope.block = null; }; - a.scroll = function(b) { - this.isVisible() && (b = this._adjustValue(b) - this.vY, 0 !== b && (this.board.code.moveBy(0, -b * this.vRatio), this.updateScrollBar(b))); + b.isEnd = function() { + return null === this.scope.block; }; - a._adjustValue = function(b) { - var a = this.board.svgDom.height(), a = a - a / this.vRatio; - b = this.vY + b; - b = Math.max(0, b); - return b = Math.min(a, b); +})(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.setVisible = function(b) { - b != this.isVisible() && (this._visible = b, this.svgGroup.attr({display:!0 === b ? "block" : "none"})); + 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.setOpacity = function(b) { - this._opacity != b && (this.vScrollbar.attr({opacity:b}), this._opacity = b); + b.getParams = function() { + var a = this; + return this.block.params.map(function(b) { + if (b instanceof Entry.Block) { + var c = new Entry.Scope(b, a.executor); + return Entry.block[b.type].func.call(c, a.entity, c); + } + return b; + }); }; - a.isVisible = function() { - return this._visible; + b.getValue = function(a, b) { + var c = this.block.params[this._getParamIndex(a, b)], e = new Entry.Scope(c, this.executor); + return Entry.block[c.type].func.call(e, this.entity, e); }; - a._updateRatio = function() { - var b = this.board, a = b.svgBlockGroup.getBoundingClientRect(), c = b.blockMenuContainer.height(), b = b.offset(); - this.vRatio = a = (a.height + (a.top - b.top) + 10) / c; - 1 >= a ? this.setVisible(!1) : this.setVisible(!0); + b.getStringValue = function(a, b) { + return String(this.getValue(a, b)); }; - a._reset = function() { - this.vY = 0; - this.vScrollbar.attr({y:this.vY}); - this.resizeScrollBar(); + b.getNumberValue = function(a, b) { + return Number(this.getValue(a)); }; - 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 c(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", c); - g.bind("touchmove.scroll", a); - g.bind("touchend.scroll", c); - e.dragInstance = new Entry.DragInstance({startY:f.pageY, offsetY:f.pageY}); - } - b.stopPropagation(); + b.getBooleanValue = function(a, b) { + return Number(this.getValue(a, b)) ? !0 : !1; }; - a._addControl = function() { - $(this.vScrollbar).bind("mousedown touchstart", this.mouseHandler); + b.getField = function(a, b) { + return this.block.params[this._getParamIndex(a)]; }; -})(Entry.BlockMenuScroller.prototype); -Entry.BlockView = function(a, b, d) { - var c = this; - 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]; - if (void 0 === this._schema) { - this.block.destroy(!1, !1); - } else { - this._schema.changeEvent && (this._schemaChangeEvent = this._schema.changeEvent.attach(this, this._updateSchema)); - var e = this._skeleton = Entry.skeleton[this._schema.skeleton]; - this._contents = []; - this._statements = []; - this.magnet = {}; - this._paramMap = {}; - e.magnets && e.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; - this.mouseHandler = function() { - var b = c.block.events; - b && b.mousedown && b.mousedown.forEach(function(b) { - b(c); - }); - c.onMouseDown.apply(c, arguments); - }; - this._startRender(a, d); - 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; - "workspace" == Entry.type && b && !this.isInBlockMenu && b.forEach(function(b) { - Entry.Utils.isFunction(b) && b(a); - }); - } -}; -Entry.BlockView.PARAM_SPACE = 5; -Entry.BlockView.DRAG_RADIUS = 5; -Entry.BlockView.pngMap = {}; -(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 c = this; - b = this._skeleton; - this.svgGroup.attr({class:"block"}); - var e = b.classes; - e && 0 !== e.length && e.forEach(function(b) { - c.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) { - c._mouseEnable && c._changeFill(!0); - }), $(this._path).mouseleave(function(b) { - c._mouseEnable && c._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(); + b.getStringField = function(a, b) { + return String(this.getField(a)); }; - 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 c = /(%\d)/mi, e = (a.template ? a.template : Lang.template[this.block.type]).split(c), f = a.params, g = 0;g < e.length;g++) { - var h = e[g].trim(); - if (0 !== h.length) { - if (c.test(h)) { - var k = Number(h.split("%")[1]) - 1, h = f[k], h = new Entry["Field" + h.type](h, this, k, b, g); - this._contents.push(h); - this._paramMap[k] = h; - } else { - this._contents.push(new Entry.FieldText({text:h}, this)); - } - } - } - if ((b = a.statements) && b.length) { - for (g = 0;g < b.length;g++) { - this._statements.push(new Entry.FieldStatement(b[g], this, g)); - } - } - break; - case Entry.Workspace.MODE_VIMBOARD: - if ("basic_button" === this._schema.skeleton) { - this._startContentRender(Entry.Workspace.MODE_BOARD); - return; - } - a = this.getBoard().workspace.getCodeToText(this.block); - b = !1; - /(if)+(.|\n)+(else)+/.test(a) && (g = a.split("\n"), a = g.shift() + " " + g.shift(), b = !0, g = g.join(" ")); - a = {text:a, color:"white"}; - this.block._schema.vimModeFontColor && (a.color = this.block._schema.vimModeFontColor); - this._contents.push(new Entry.FieldText(a, this)); - b && (this._contents.push(new Entry.FieldLineBreak(null, this)), a.text = g, this._contents.push(new Entry.FieldText(a, this))); - } - this.alignContent(!1); + b.getNumberField = function(a) { + return Number(this.getField(a)); }; - a._updateSchema = function() { - this._startContentRender(); + b.getStatement = function(a, b) { + return this.executor.stepInto(this.block.statements[this._getStatementIndex(a, b)]); }; - a.changeType = function(b) { - this._schemaChangeEvent && this._schemaChangeEvent.destroy(); - this._schema = Entry.block[b]; - this._schema.changeEvent && (this._schemaChangeEvent = this._schema.changeEvent.attach(this, this._updateSchema)); - this._updateSchema(); + 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.svgGroup).unbind("mouseup touchend"); + this.destroyOption(); }; - a.alignContent = function(b) { - !0 !== b && (b = !1); - for (var a = 0, c = 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(b, f), l.align(f), f++, c = l.box.y, a = 8) : (l.align(a, c, b), k === this._contents.length - 1 || l instanceof Entry.FieldText && 0 == l._text.length || (a += Entry.BlockView.PARAM_SPACE)); - l = l.box; - 0 !== f ? h = Math.max(1E6 * Math.round(l.height), h) : e = Math.max(l.height, e); - a += l.width; - g = Math.max(g, a); - this.set({contentWidth:g, contentHeight:e}); - } - this.set({contentHeight:e + h}); - this._statements.length != f && this._alignStatement(b, f); - b = this.getContentPos(); - this.contentSvgGroup.attr("transform", "translate(" + b.x + "," + b.y + ")"); - this.contentPos = b; - this._render(); - this._updateMagnet(); + 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; }; - a._alignStatement = function(b, a) { - var c = this._skeleton.statementPos ? this._skeleton.statementPos(this) : [], e = this._statements[a]; - e && (a = c[a]) && e.align(a.x, a.y, b); + 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(); }; - a._render = function() { - this._renderPath(); - this.set(this._skeleton.box(this)); + b._attachDisposeEvent = function(a) { + var b = this; + b.disposeEvent = Entry.disposeEvent.attach(b, a || function() { + b.destroyOption(); + }); }; - a._renderPath = function() { - var b = this._skeleton.path(this); - this._path.attr({d:b}); - this.set({animating:!1}); + b.align = function(a, b, c) { + 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 === c || c ? e.animate({transform:f}, 300, mina.easeinout) : e.attr({transform:f}); + this.box.set({x:a, y:b}); }; - a._setPosition = function(b) { - this.svgGroup.attr("transform", "translate(" + this.x + "," + this.y + ")"); + 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._toLocalCoordinate = function(b) { - this._moveTo(0, 0, !1); - b.appendChild(this.svgGroup); + b.getAbsolutePosFromDocument = function() { + var a = this._block.view, b = a.getContentPos(), c = a.getAbsoluteCoordinate(), a = a.getBoard().svgDom.offset(); + return {x:c.x + this.box.x + b.x + a.left, y:c.y + this.box.y + b.y + a.top}; }; - a._toGlobalCoordinate = function(b) { - b = this.getAbsoluteCoordinate(b); - this._moveTo(b.x, b.y, !1); - this.getBoard().svgBlockGroup.appendChild(this.svgGroup); + b.getRelativePos = function() { + var a = this._block.view.getContentPos(), b = this.box; + return {x:b.x + a.x, y:b.y + a.y}; }; - a._moveTo = function(b, a, c) { - this.set({x:b, y:a}); - this._lazyUpdatePos(); - this.visible && this.display && this._setPosition(c); + b.truncate = function() { + var a = String(this.getValue()), b = this.TEXT_LIMIT_LENGTH, c = a.substring(0, b); + a.length > b && (c += "..."); + return c; }; - a._moveBy = function(b, a, c) { - return this._moveTo(this.x + b, this.y + a, c); + b.appendSvgOptionGroup = function() { + return this._block.view.getBoard().svgGroup.elem("g"); }; - a._addControl = function() { - var b = this; - this._mouseEnable = !0; - $(this.svgGroup).bind("mousedown.blockViewMousedown touchstart.blockViewMousedown", b.mouseHandler); - var a = b.block.events; - a && a.dblclick && $(this.svgGroup).dblclick(function() { - a.dblclick.forEach(function(a) { - a && a(b); - }); - }); + b.getValue = function() { + return this._block.params[this._index]; }; - a.removeControl = function() { - this._mouseEnable = !1; - $(this.svgGroup).unbind(".blockViewMousedown"); + b.setValue = function(a, b) { + this.value != a && (this.value = a, this._block.params[this._index] = a, b && this._blockView.reDraw()); }; - a.onMouseDown = function(b) { - function d(b) { - b.stopPropagation(); - var c = g.workspace.getMode(), d; - c === Entry.Workspace.MODE_VIMBOARD && a.vimBoardEvent(b, "dragOver"); - d = b.originalEvent && b.originalEvent.touches ? b.originalEvent.touches[0] : b; - var h = f.mouseDownCoordinate, h = Math.sqrt(Math.pow(d.pageX - h.x, 2) + Math.pow(d.pageY - h.y, 2)); - if (f.dragMode == Entry.DRAG_MODE_DRAG || h > Entry.BlockView.DRAG_RADIUS) { - e && (clearTimeout(e), e = null), f.movable && (f.isInBlockMenu ? g.cloneToGlobal(b) : (b = !1, f.dragMode != Entry.DRAG_MODE_DRAG && (f._toGlobalCoordinate(), f.dragMode = Entry.DRAG_MODE_DRAG, f.block.getThread().changeEvent.notify(), Entry.GlobalSvg.setView(f, c), b = !0), this.animating && this.set({animating:!1}), 0 === f.dragInstance.height && f.dragInstance.set({height:-1 + f.height}), c = f.dragInstance, f._moveBy(d.pageX - c.offsetX, d.pageY - c.offsetY, !1), c.set({offsetX:d.pageX, - offsetY:d.pageY}), Entry.GlobalSvg.position(), f.originPos || (f.originPos = {x:f.x, y:f.y}), b && g.generateCodeMagnetMap(), f._updateCloseBlock())); - } + b._isEditable = function() { + if (Entry.ContextMenu.visible || this._block.view.dragMode == Entry.DRAG_MODE_DRAG) { + return !1; } - function c(b) { - e && (clearTimeout(e), e = null); - $(document).unbind(".block"); - f.terminateDrag(b); - g && g.set({dragBlock:null}); - f._changeFill(!1); - Entry.GlobalSvg.remove(); - delete this.mouseDownCoordinate; - delete f.dragInstance; + var a = this._block.view, b = a.getBoard(); + if (!0 === b.disableMouseEvent) { + return !1; } - b.stopPropagation && b.stopPropagation(); - b.preventDefault && b.preventDefault(); - var e = null, f = this; - this._changeFill(!1); - var g = this.getBoard(); - Entry.documentMousedown && Entry.documentMousedown.notify(b); - if (!this.readOnly && !g.viewOnly) { - g.setSelectedBlock(this); - this.dominate(); - if (0 === b.button || b.originalEvent && b.originalEvent.touches) { - var h = b.type, k; - k = b.originalEvent && b.originalEvent.touches ? b.originalEvent.touches[0] : b; - this.mouseDownCoordinate = {x:k.pageX, y:k.pageY}; - var l = $(document); - l.bind("mousemove.block touchmove.block", d); - l.bind("mouseup.block touchend.block", c); - this.dragInstance = new Entry.DragInstance({startX:k.pageX, startY:k.pageY, offsetX:k.pageX, offsetY:k.pageY, height:0, mode:!0}); - g.set({dragBlock:this}); - this.addDragging(); - this.dragMode = Entry.DRAG_MODE_MOUSEDOWN; - "touchstart" === h && (e = setTimeout(function() { - e && (e = null, c(), f._rightClick(b)); - }, 1E3)); - } else { - Entry.Utils.isRightButton(b) && this._rightClick(b); - } - g.workspace.getMode() === Entry.Workspace.MODE_VIMBOARD && b && (vimBoard = $(".entryVimBoard>.CodeMirror")[0], document.getElementsByClassName("CodeMirror")[0].dispatchEvent(Entry.Utils.createMouseEvent("dragStart", event))); + var c = b.workspace.selectedBlockView; + if (!c || b != c.getBoard()) { + return !1; } + b = a.getSvgRoot(); + return b == c.svgGroup || $(b).has($(a.svgGroup)); }; - a.vimBoardEvent = function(b, a, c) { - b && (b = Entry.Utils.createMouseEvent(a, b), c && (b.block = c), document.getElementsByClassName("CodeMirror")[0].dispatchEvent(b)); - }; - a.terminateDrag = function(b) { - var a = this.getBoard(), c = 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 (c === 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 = c, 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; - c = 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(c.x, c.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(); + b._selectBlockView = function() { + var a = this._block.view; + a.getBoard().setSelectedBlock(a); }; - a._updateCloseBlock = function() { - var b = this.getBoard(), a; - if (this._skeleton.magnets) { - for (var c in this.magnet) { - if (a = "next" === c ? this.getBoard().getNearestMagnet(this.x, this.y + this.getBelowHeight(), c) : this.getBoard().getNearestMagnet(this.x, this.y, c)) { - return b.setMagnetedBlock(a.view, c); - } - } - b.setMagnetedBlock(null); - } + b._bindRenderOptions = function() { + var a = this; + $(this.svgGroup).bind("mouseup touchend", function(b) { + a._isEditable() && (a.destroyOption(), a._startValue = a.getValue(), a.renderOptions()); + }); }; - a.dominate = function() { - this.block.getThread().view.dominate(); + b.pointer = function(a) { + a = a || []; + a.unshift(this._index); + a.unshift(Entry.PARAM); + return this._block.pointer(a); }; - a.getSvgRoot = function() { - for (var b = this.getBoard().svgBlockGroup, a = this.svgGroup;a.parentNode !== b;) { - a = a.parentNode; - } - return a; + b.getFontSize = function(a) { + return a = a || this._blockView.getSkeleton().fontSize || 12; }; - a.getBoard = function() { - return this._board; + b.getContentHeight = function() { + return Entry.isMobile() ? 22 : 16; }; - a._setBoard = function() { - this._board = this._board.code.board; +})(Entry.Field.prototype); +Entry.FieldAngle = function(b, a, d) { + this._block = a.block; + this._blockView = a; + this.box = new Entry.BoxModel; + this.svgGroup = null; + this.position = b.position; + this._contents = b; + this._index = d; + b = this.getValue(); + this.setValue(this.modValue(void 0 !== b ? b : 90)); + this._CONTENT_HEIGHT = this.getContentHeight(); + 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":"11px"}); + this.textElement.textContent = this.getText(); + var a = this.getTextWidth(), b = this._CONTENT_HEIGHT, c = this.position && this.position.y ? this.position.y : 0; + this._header = this.svgGroup.elem("rect", {x:0, y:c - b / 2, rx:3, ry:3, width:a, height:b, 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:b}); }; - a.destroy = function(b) { - $(this.svgGroup).unbind(".blockViewMousedown"); - 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(); + b.renderOptions = function() { + var a = this; + this._attachDisposeEvent(function() { + a.applyValue(); + a.destroyOption(); }); - var c = this.block; - b = c.events.viewDestroy; - "workspace" == Entry.type && b && !this.isInBlockMenu && b.forEach(function(b) { - Entry.Utils.isFunction(b) && b(c); + this.optionGroup = Entry.Dom("input", {class:"entry-widget-input-field", parent:$("body")}); + this.optionGroup.val(this.value); + this.optionGroup.on("mousedown touchstart", function(a) { + a.stopPropagation(); }); - this._schemaChangeEvent && this._schemaChangeEvent.destroy(); + this.optionGroup.on("keyup", function(b) { + var d = b.keyCode || b.which; + a.applyValue(b); + -1 < [13, 27].indexOf(d) && a.destroyOption(); + }); + var b = this.getAbsolutePosFromDocument(); + b.y -= this.box.height / 2; + this.optionGroup.css({height:this._CONTENT_HEIGHT, left:b.x, top:b.y, width:a.box.width}); + this.svgOptionGroup = this.appendSvgOptionGroup(); + this.svgOptionGroup.elem("circle", {x:0, y:0, r:49, class:"entry-field-angle-circle"}); + $(this.svgOptionGroup).on("mousedown touchstart", function(b) { + b.stopPropagation(); + a._updateByCoord(b); + }); + 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 + ")"}); + $(this.svgOptionGroup).bind("mousemove touchmove", this._updateByCoord.bind(this)); + $(this.svgOptionGroup).bind("mouseup touchend", this.destroyOption.bind(this)); + this.updateGraph(); + this.optionGroup.focus(); + this.optionGroup.select(); }; - 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._updateByCoord = function(a) { + a.originalEvent && a.originalEvent.touches && (a = a.originalEvent.touches[0]); + a = [a.clientX, a.clientY]; + var b = this.getAbsolutePosFromDocument(); + this.optionGroup.val(this.modValue(function(a, b) { + var d = b[0] - a[0], g = b[1] - a[1] - 49 - 1, h = Math.atan(-g / d), h = Entry.toDegrees(h), h = 90 - h; + 0 > d ? h += 180 : 0 < g && (h += 360); + return 15 * Math.round(h / 15); + }([b.x + this.box.width / 2, b.y + this.box.height / 2 + 1], a))); + this.applyValue(); }; - a.destroyShadow = function() { - this._shadow && (this._shadow.remove(), delete this._shadow); + b.updateGraph = function() { + this._fillPath && this._fillPath.remove(); + var a = Entry.toRadian(this.getValue()), b = 49 * Math.sin(a), c = -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", c).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:c}); + this._indicator.attr({class:"entry-angle-indicator"}); }; - 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(); - } + 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._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(), c = this.getAbsoluteCoordinate(), e; - if ("previous" === b) { - e = this.magnet.next, e = "translate(" + (c.x + e.x) + "," + (c.y + e.y) + ")"; - } else { - if ("next" === b) { - e = this.magnet.previous; - var f = this._board.dragBlock.getBelowHeight(); - e = "translate(" + (c.x + e.x) + "," + (c.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")); - } - } + 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.addDragging = function() { - this.svgGroup.addClass("dragging"); + b.getTextWidth = function() { + return this.textElement ? this.textElement.getComputedTextLength() + 8 : 8; }; - a.removeDragging = function() { - this.svgGroup.removeClass("dragging"); + b.getText = function() { + return this.getValue() + "\u00b0"; }; - a.addSelected = function() { - this.svgGroup.addClass("selected"); + b.modValue = function(a) { + return a % 360; }; - a.removeSelected = function() { - this.svgGroup.removeClass("selected"); + 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(); }; - a.getSkeleton = function() { - return this._skeleton; +})(Entry.FieldAngle.prototype); +Entry.FieldBlock = function(b, a, d, c, 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 = d; + 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(), c); +}; +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 c = this.getValue(); + c && !c.view && (c.setThread(this), c.createView(a, b), c.getThread().view.setParent(this)); + this.updateValueBlock(c); + this._blockView.getBoard().constructor !== Entry.Board && this._valueBlock.view.removeControl(); }; - a.getContentPos = function() { - return this._skeleton.contentPos(this); + b.align = function(a, b, c) { + 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 === c || c ? e.animate({transform:f}, 300, mina.easeinout) : e.attr({transform:f}); + this.box.set({x:a, y:b}); }; - a.renderText = function() { - this._startContentRender(Entry.Workspace.MODE_VIMBOARD); + 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.renderBlock = function() { - this._startContentRender(Entry.Workspace.MODE_BOARD); + b.calcHeight = b.calcWH; + b.destroy = function() { }; - a._updateOpacity = function() { - this.svgGroup.attr({opacity:!1 === this.visible ? 0 : 1}); - this.visible && this._setPosition(); + 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._updateShadow = function() { - this.shadow && Entry.Utils.colorDarken(this._schema.color, .7); + 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._setMovable = function() { - this.movable = null !== this.block.isMovable() ? this.block.isMovable() : void 0 !== this._skeleton.movable ? this._skeleton.movable : !0; + b.getValueBlock = function() { + return this._valueBlock; }; - a._setReadOnly = function() { - this.readOnly = null !== this.block.isReadOnly() ? this.block.isReadOnly() : void 0 !== this._skeleton.readOnly ? this._skeleton.readOnly : !1; + 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._setCopyable = function() { - this.copyable = null !== this.block.isCopyable() ? this.block.isCopyable() : void 0 !== this._skeleton.copyable ? this._skeleton.copyable : !0; + b._destroyObservers = function() { + this._sizeObserver && this._sizeObserver.destroy(); + this._posObserver && this._posObserver.destroy(); }; - a.bumpAway = function(b, a) { - var c = this; - b = b || 15; - a ? window.setTimeout(function() { - c._moveBy(b, b, !1); - }, a) : c._moveBy(b, b, !1); + b.getPrevBlock = function(a) { + return this._valueBlock === a ? this : null; }; - 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); - } - } + b.getNextBlock = function() { + return null; }; - 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; + 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; + }; + b.dominate = function() { + this._blockView.dominate(); + }; + b.isGlobal = function() { + return !1; + }; + b.separate = function(a) { + this.getCode().createThread([a]); + this.calcWH(); + this.changeEvent.notify(); + }; + b.getCode = function() { + return this._block.thread.getCode(); }; - a.getBelowHeight = function() { - return this.block.getThread().view.requestPartHeight(this); + b.cut = function(a) { + return this._valueBlock === a ? [a] : null; }; - a._updateDisplay = function() { - this.svgGroup.attr({display:!1 === this.display ? "none" : "block"}); - this.display && this._setPosition(); + 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._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(); + b.setParent = function(a) { + this._parent = a; }; - a._updateContents = function() { - for (var b = 0;b < this._contents.length;b++) { - this._contents[b].renderStart(); - } - this.alignContent(!1); + b.getParent = function() { + return this._parent; }; - a._destroyObservers = function() { - for (var b = this._observers;b.length;) { - b.pop().destroy(); - } + b._createBlockByType = function(a) { + this._block.getThread(); + var b = this._blockView.getBoard(); + a = new Entry.Block({type:a}, this); + var c = b.workspace, e; + c && (e = c.getMode()); + a.createView(b, e); + return a; }; - a._changeFill = function(b) { - var a = this.getBoard(); - if (a.patternRect && !a.dragBlock) { - var c = this._fillColor, e = this._path, a = this.getBoard(); - b ? (a.setPatternRectFill(c), c = "url(#blockHoverPattern_" + this.getBoard().suffix + ")") : a.disablePattern(); - e.attr({fill:c}); - } + b.spliceBlock = function() { + this.updateValueBlock(); }; - a.addActivated = function() { - this.svgGroup.addClass("activated"); + 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.removeActivated = function() { - this.svgGroup.removeClass("activated"); + b.getThread = function() { + return this; }; - a.reDraw = function() { - if (this.visible) { - var b = this.block; - requestAnimFrame(this._updateContents.bind(this)); - var a = b.params; - if (a) { - for (var c = 0;c < a.length;c++) { - var e = a[c]; - e instanceof Entry.Block && e.view.reDraw(); - } - } - if (b = b.statements) { - for (c = 0;c < b.length;c++) { - b[c].view.reDraw(); - } - } - } + b.pointer = function(a) { + a.unshift(this._index); + a.unshift(Entry.PARAM); + return this._block.pointer(a); }; - a.getParam = function(b) { - return this._paramMap[b]; +})(Entry.FieldBlock.prototype); +Entry.FieldColor = function(b, a, d) { + this._block = a.block; + this._blockView = a; + this.box = new Entry.BoxModel; + this.svgGroup = null; + this._contents = b; + this._index = d; + this._position = b.position; + this.key = b.key; + this.setValue(this.getValue() || "#FF0000"); + this._CONTENT_HEIGHT = this.getContentHeight(); + this._CONTENT_WIDTH = this.getContentWidth(); + 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._CONTENT_HEIGHT, b = this._CONTENT_WIDTH, c = this._position, e; + c ? (e = c.x || 0, c = c.y || 0) : (e = 0, c = -a / 2); + this._header = this.svgGroup.elem("rect", {x:e, y:c, width:b, height:a, fill:this.getValue()}); + this._bindRenderOptions(); + this.box.set({x:e, y:c, width:b, height:a}); }; - a.getDataUrl = function(b, a) { - function c() { - g = g.replace("(svgGroup)", (new XMLSerializer).serializeToString(k)).replace("%W", h.width * l).replace("%H", h.height * l).replace("(defs)", (new XMLSerializer).serializeToString(n[0])).replace(/>\s+/g, ">").replace(/\s+ a && (c += "..."); - return c; + b.getArrow = function() { + var a = Entry.isMobile(); + return {color:this._arrowColor || this._blockView._schema.color, points:a ? "0,0 19,0 9.5,13" : "0,0 6.4,0 3.2,4.2", height:a ? 13 : 4.2, width:a ? 19 : 6.4}; }; - a.appendSvgOptionGroup = function() { - return this._block.view.getBoard().svgGroup.elem("g"); +})(Entry.FieldDropdown.prototype); +Entry.FieldDropdownDynamic = function(b, a, d) { + this._block = a.block; + this._blockView = a; + this.box = new Entry.BoxModel; + this.svgGroup = null; + this._contents = b; + this._index = d; + this._arrowColor = b.arrowColor; + d = this._contents.menuName; + Entry.Utils.isFunction(d) ? this._menuGenerator = d : this._menuName = d; + this._CONTENT_HEIGHT = this.getContentHeight(b.dropdownHeight); + this._FONT_SIZE = this.getFontSize(b.fontSize); + 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 = this._block.getCode().object, b = []; + Entry.container && (b = this._menuName ? Entry.container.getDropdownList(this._menuName, a) : this._menuGenerator()); + this._contents.options = b; + a = this.getValue(); + if (this._blockView.isInBlockMenu || !a || "null" == a) { + a = 0 !== b.length ? b[0][1] : null; + } + this.setValue(a); + }; + 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 c = 0;c < b.length;c++) { + var e = b[c], 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.getValue = function() { - return this._block.params[this._index]; +})(Entry.FieldDropdownDynamic.prototype); +Entry.FieldImage = function(b, a, d) { + 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 = d; + 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.setValue = function(b, a) { - this.value != b && (this.value = b, this._block.params[this._index] = b, a && this._blockView.reDraw()); +})(Entry.FieldImage.prototype); +Entry.FieldIndicator = function(b, a, d) { + 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 = d; + 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._isEditable = function() { - if (Entry.ContextMenu.visible || 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 c = a.workspace.selectedBlockView; - if (!c || a != c.getBoard()) { - return !1; + 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); + }; +})(Entry.FieldIndicator.prototype); +Entry.Keyboard = {}; +Entry.FieldKeyboard = function(b, a, d) { + this._block = a.block; + this._blockView = a; + this.box = new Entry.BoxModel; + this.svgGroup = null; + this.position = b.position; + this._contents = b; + this._index = d; + this.setValue(String(this.getValue())); + this._CONTENT_HEIGHT = this.getContentHeight(); + 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:5, y:4, "font-size":"11px"}); + this.textElement.textContent = Entry.getKeyCodeMap()[this.getValue()]; + var a = this.getTextWidth() + 1, b = this._CONTENT_HEIGHT, c = this.position && this.position.y ? this.position.y : 0; + this._header = this.svgGroup.elem("rect", {x:0, y:c - b / 2, width:a, height:b, 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:b}); + }; + 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}); + }; + 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); + }; + 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 = b.getSvgRoot(); - return a == c.svgGroup || $(a).has($(b.svgGroup)); }; - a._selectBlockView = function() { - var b = this._block.view; - b.getBoard().setSelectedBlock(b); + b.applyValue = function(a, b) { + this.setValue(String(b)); + this.destroyOption(); + this.textElement.textContent = a; + this.resize(); }; - a._bindRenderOptions = function() { - var b = this; - $(this.svgGroup).bind("mouseup touchend", function(a) { - b._isEditable() && (b.destroyOption(), b._startValue = b.getValue(), b.renderOptions()); - }); + b.resize = function() { + var a = this.getTextWidth() + 1; + this._header.attr({width:a}); + this.box.set({width:a}); + this._blockView.alignContent(); }; - a.pointer = function(b) { - b = b || []; - b.unshift(this._index); - b.unshift(Entry.PARAM); - return this._block.pointer(b); + b.getTextWidth = function() { + return this.textElement.getComputedTextLength() + 10; }; - a.getFontSize = function(b) { - return b = b || this._blockView.getSkeleton().fontSize || 12; + b.destroy = function() { + this.destroyOption(); + Entry.keyPressed && this.keyPressed && Entry.keyPressed.detach(this.keyPressed); }; - a.getContentHeight = function() { - return Entry.isMobile() ? 22 : 16; +})(Entry.FieldKeyboard.prototype); +Entry.FieldLineBreak = function(b, a, d) { + this._block = a.block; + this._blockView = a; + this._index = d; + 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, d, c, 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, d, c, 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 = d; 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(), c); + this.renderStart(a.getBoard(), c); }; -Entry.Utils.inherit(Entry.Field, Entry.FieldBlock); -(function(a) { - a.schema = {magneting:!1}; - a.renderStart = function(b, a) { +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 c = this.getValue(); - c && !c.view && (c.setThread(this), c.createView(b, a), c.getThread().view.setParent(this)); - this.updateValueBlock(c); - this._blockView.getBoard().constructor !== Entry.Board && this._valueBlock.view.removeControl(); + c && !c.view && (c.setThread(this), c.createView(a, b)); + this._updateValueBlock(c); + this._blockView.getBoard().constructor == Entry.BlockMenu && this._valueBlock && this._valueBlock.view.removeControl(); }; - a.align = function(b, a, c) { + b.align = function(a, b, c) { var e = this.svgGroup; - this._position && (this._position.x && (b = this._position.x), this._position.y && (a = this._position.y)); + this._position && (this._position.x && (a = this._position.x), this._position.y && (b = this._position.y)); var f = this._valueBlock; - f && (a = -.5 * f.view.height); - f = "translate(" + b + "," + a + ")"; + f && (b = -.5 * f.view.height); + f = "translate(" + a + "," + b + ")"; void 0 === c || c ? 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}); + this.box.set({x:a, y:b}); }; - 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); + b.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}); }; - 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; + b.calcHeight = b.calcWH; + b.destroy = function() { }; - a.getValueBlock = function() { - return this._valueBlock; + b._inspectBlock = function() { }; - 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(); + b._setValueBlock = function(a) { + if (a != this._valueBlock || !this._valueBlock) { + return this._valueBlock = a, this.setValue(a), a && a.setThread(this), this._valueBlock; + } }; - a._destroyObservers = function() { + b._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(); }; - a.getPrevBlock = function(b) { - return this._valueBlock === b ? this : null; + b.getPrevBlock = function(a) { + return this._valueBlock === a ? this : null; }; - a.getNextBlock = function() { + b.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; + 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.dominate = function() { + b.dominate = function() { this._blockView.dominate(); }; - a.isGlobal = function() { + b.isGlobal = function() { return !1; }; - a.separate = function(b) { - this.getCode().createThread([b]); - this.calcWH(); + b.separate = function(a) { + this.getCode().createThread([a]); this.changeEvent.notify(); }; - a.getCode = function() { + b.getCode = function() { return this._block.thread.getCode(); }; - a.cut = function(b) { - return this._valueBlock === b ? [b] : null; + b.cut = function(a) { + return this._valueBlock === a ? (delete this._valueBlock, [a]) : 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); + 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(); - this.changeEvent.notify(); }; - a.setParent = function(b) { - this._parent = b; + b.setParent = function(a) { + this._parent = a; }; - a.getParent = function() { + b.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 c = a.workspace, e; - c && (e = c.getMode()); - b.createView(a, e); + 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, d) { + Entry.Model(this, !1); + this._blockView = a; + this.block = a.block; + this.view = this; + this._index = d; + 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, c) { + c = void 0 === c ? !0 : c; + 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}); + c ? 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; }; - a.spliceBlock = function() { - this.updateValueBlock(); + b.getNextBlock = function() { + return this.firstBlock; }; - 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.checkTopBlock = function() { + var a = this._thread.getFirstBlock(); + a && this.firstBlock !== a ? (this.firstBlock = a, a.view.bindPrev(this), a._updatePos()) : a || (this.firstBlock = null); }; - a.getThread = function() { - return this; +})(Entry.FieldStatement.prototype); +Entry.FieldText = function(b, a, d) { + this._block = a.block; + this._blockView = a; + this._index = d; + 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", "font-family":"nanumBarunRegular", "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, d) { + this._blockView = a; + this._block = a.block; + this.box = new Entry.BoxModel; + this.svgGroup = null; + this.position = b.position; + this._contents = b; + this._index = d; + this.value = this.getValue() || ""; + this._CONTENT_HEIGHT = this.getContentHeight(); + 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":"12px"}); + this.textElement.textContent = this.truncate(); + var a = this.getTextWidth(), b = this.position && this.position.y ? this.position.y : 0, c = this._CONTENT_HEIGHT; + this._header = this.svgGroup.elem("rect", {width:a, height:c, y:b - c / 2, rx:3, ry:3, fill:"transparent"}); + this.svgGroup.appendChild(this.textElement); + this._bindRenderOptions(); + this.box.set({x:0, y:0, width:a, height:c}); }; - a.pointer = function(b) { - b.unshift(this._index); - b.unshift(Entry.PARAM); - return this._block.pointer(b); + 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 d = b.keyCode || b.which; + a.applyValue(b); + -1 < [13, 27].indexOf(d) && a.destroyOption(); + }); + var b = this.getAbsolutePosFromDocument(); + b.y -= this.box.height / 2; + this.optionGroup.css({height:this._CONTENT_HEIGHT, left:b.x, top:b.y, width:a.box.width}); + this.optionGroup.focus(); + b = this.optionGroup[0]; + b.setSelectionRange(0, b.value.length, "backward"); }; -})(Entry.FieldBlock.prototype); -Entry.Scroller = function(a, b, d) { - this._horizontal = void 0 === b ? !0 : b; + 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.getBoundingClientRect().width + 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, c = a.getBoard(), e = c.workspace.blockMenu, f = e.offset().left, g = e.offset().top, h = e.visible ? e.svgDom.width() : 0; + return b.y > c.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({transform:"translate3d(" + d + "px," + f + "px, 0px)"}); + e._startX = c; + e._startY = a; + e.left = d; + e.top = f; + } + function c(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", c); + f.bind("touchmove.block", b); + f.bind("touchend.block", c); + this._startX = a.pageX; + this._startY = a.pageY; + }; +})(Entry.GlobalSvg); +Entry.Mutator = function() { +}; +(function(b) { + b.mutate = function(a, b) { + var c = Entry.block[a]; + void 0 === c.changeEvent && (c.changeEvent = new Entry.Event); + c.template = b.template; + c.params = b.params; + c.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(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}); + }; + 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, c = "LEFT" == this._align ? 20 : this.svgDom.width() / 2, e = 0, f = a.length;e < f;e++) { + var g = a[e].getFirstBlock().view; + g._moveTo(c, b - g.offsetY, !1); + g = g.svgGroup.getBBox().height; + b += g + 15; + } + this._bBox = this.svgGroup.getBBox(); + this.height = this._bBox.height; + } + }; + b.hide = function() { + this.view.addClass("entryRemove"); + }; + b.show = function() { + this.view.removeClass("entryRemove"); + }; + b.setWidth = function() { + this._svgWidth = this.svgDom.width(); + this.offset = this.svgDom.offset(); + }; + 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.resize = function() { + this.svg && this._bBox && $(this.svg).css("height", this._bBox.height + 10); + }; +})(Entry.RenderView.prototype); +Entry.Scroller = function(b, a, d) { + this._horizontal = void 0 === a ? !0 : a; this._vertical = void 0 === d ? !0 : d; - 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; @@ -23597,93 +23061,93 @@ Entry.Scroller = function(a, b, d) { this._scrollCommand = _.debounce(Entry.do, 200); }; Entry.Scroller.RADIUS = 7; -(function(a) { - a.createScrollBar = function() { - var b = Entry.Scroller.RADIUS, a = 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 * 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 c = a.dragInstance; - a.scroll((b.pageX - c.offsetX) / a.hRatio, 0); - c.set({offsetX:b.pageX, offsetY:b.pageY}); - } - function f(b) { + this._horizontal && (this.hScrollbar = this.svgGroup.elem("rect", {height:2 * a, rx:a, ry:a}), this.hScrollbar.mousedown = function(a) { + function e(a) { + a.stopPropagation(); + a.preventDefault(); + a.originalEvent.touches && (a = a.originalEvent.touches[0]); + var c = b.dragInstance; + b.scroll((a.pageX - c.offsetX) / b.hRatio, 0); + c.set({offsetX:a.pageX, offsetY:a.pageY}); + } + function f(a) { $(document).unbind(".scroll"); - delete a.dragInstance; + delete b.dragInstance; } - if (0 === b.button || b instanceof Touch) { - Entry.documentMousedown && Entry.documentMousedown.notify(b); + if (0 === a.button || a instanceof Touch) { + Entry.documentMousedown && Entry.documentMousedown.notify(a); 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.dragInstance = new Entry.DragInstance({startX:a.pageX, startY:a.pageY, offsetX:a.pageX, offsetY:a.pageY}); } - b.stopPropagation(); + a.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 c = a.dragInstance; - a.scroll(0, (b.pageY - c.offsetY) / a.vRatio); - c.set({offsetX:b.pageX, offsetY:b.pageY}); - } - function f(b) { + this._vertical && (this.vScrollbar = this.svgGroup.elem("rect", {width:2 * a, rx:a, ry:a}), this.vScrollbar.mousedown = function(a) { + function e(a) { + a.stopPropagation(); + a.preventDefault(); + a.originalEvent.touches && (a = a.originalEvent.touches[0]); + var c = b.dragInstance; + b.scroll(0, (a.pageY - c.offsetY) / b.vRatio); + c.set({offsetX:a.pageX, offsetY:a.pageY}); + } + function f(a) { $(document).unbind(".scroll"); - delete a.dragInstance; + delete b.dragInstance; } - if (0 === b.button || b instanceof Touch) { - Entry.documentMousedown && Entry.documentMousedown.notify(b); + if (0 === a.button || a instanceof Touch) { + Entry.documentMousedown && Entry.documentMousedown.notify(a); 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.dragInstance = new Entry.DragInstance({startX:a.pageX, startY:a.pageY, offsetX:a.pageX, offsetY:a.pageY}); } - b.stopPropagation(); + a.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})); + b.updateScrollBar = function(a, b) { + this._horizontal && (this.hX += a * this.hRatio, this.hScrollbar.attr({x:this.hX})); + this._vertical && (this.vY += b * this.vRatio, this.vScrollbar.attr({y:this.vY})); }; - a.scroll = function(b, a) { + b.scroll = function(a, b) { if (this.board.code) { var c = this.board.svgBlockGroup.getBoundingClientRect(), e = this.board.svgDom, f = c.left - this.board.offset().left, g = c.top - this.board.offset().top, h = c.height; - b = Math.max(-c.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); + a = Math.max(-c.width + Entry.BOARD_PADDING - f, a); + b = Math.max(-h + Entry.BOARD_PADDING - g, b); + a = Math.min(e.width() - Entry.BOARD_PADDING - f, a); + b = Math.min(e.height() - Entry.BOARD_PADDING - g, b); + this._scroll(a, b); this._diffs || (this._diffs = [0, 0]); - this._diffs[0] += b; - this._diffs[1] += a; + this._diffs[0] += a; + this._diffs[1] += b; 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); + b._scroll = function(a, b) { + this.board.code.moveBy(a, b); + this.updateScrollBar(a, b); }; - a.setVisible = function(b) { - b != this.isVisible() && (this._visible = b, this.svgGroup.attr({display:!0 === b ? "block" : "none"})); + 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(b) { - this._opacity != b && (this.hScrollbar.attr({opacity:b}), this.vScrollbar.attr({opacity:b}), this._opacity = b); + 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 b = this.board, a = b.svgBlockGroup.getBoundingClientRect(), c = b.svgDom, e = c.width(), c = c.height(), f = a.left - b.offset().left, b = a.top - b.offset().top, g = a.width, a = a.height; + var a = this.board, b = a.svgBlockGroup.getBoundingClientRect(), c = a.svgDom, e = c.width(), c = c.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); @@ -23691,19 +23155,19 @@ Entry.Scroller.RADIUS = 7; this.hScrollbar.attr({width:g, x:this.hX, y:c - 2 * Entry.Scroller.RADIUS}); this.hRatio = (e - g - 2 * Entry.Scroller.RADIUS) / (k - h); } - this._vertical && (f = -a + Entry.BOARD_PADDING, g = c - Entry.BOARD_PADDING, a = (c + 2 * Entry.Scroller.RADIUS) * a / (g - f + a), this.vY = (b - f) / (g - f) * (c - a - 2 * Entry.Scroller.RADIUS), this.vScrollbar.attr({height:a, y:this.vY, x:e - 2 * Entry.Scroller.RADIUS}), this.vRatio = (c - a - 2 * Entry.Scroller.RADIUS) / (g - f)); + this._vertical && (f = -b + Entry.BOARD_PADDING, g = c - Entry.BOARD_PADDING, b = (c + 2 * Entry.Scroller.RADIUS) * b / (g - f + b), this.vY = (a - f) / (g - f) * (c - b - 2 * Entry.Scroller.RADIUS), this.vScrollbar.attr({height:b, y:this.vY, x:e - 2 * Entry.Scroller.RADIUS}), this.vRatio = (c - b - 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); + 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 = {}; @@ -23719,18 +23183,18 @@ Entry.Board.OPTION_ALIGN = 1; Entry.Board.OPTION_CLEAR = 2; Entry.Board.OPTION_DOWNLOAD = 3; Entry.Board.DRAG_RADIUS = 5; -(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")) { +(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 = a; + this.view = b; this._svgId = "play" + (new Date).getTime(); - this.workspace = b.workspace; + this.workspace = a.workspace; this._activatedBlockView = null; - this.wrapper = Entry.Dom("div", {parent:a, class:"entryBoardWrapper"}); + this.wrapper = Entry.Dom("div", {parent:b, class:"entryBoardWrapper"}); this.svgDom = Entry.Dom($(''), {parent:this.wrapper}); this.visible = !0; var c = this; @@ -23743,130 +23207,130 @@ Entry.Board.DRAG_RADIUS = 5; 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"; + a.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 = Entry.Utils.addBlockPattern(this.svg, this.suffix); + this.patternRect = a.rect; + this.pattern = a.pattern; }; - a.changeCode = function(b) { + b.changeCode = function(a) { 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.set({code:a}); + var b = this; + a && (this.codeListener = this.code.changeEvent.attach(this, function() { + b.changeEvent.notify(); + }), a.createView(this)); this.scroller.resizeScrollBar(); }; - a.bindCodeView = function(b) { + b.bindCodeView = function(a) { this.svgBlockGroup.remove(); this.svgThreadGroup.remove(); - this.svgBlockGroup = b.svgBlockGroup; - this.svgThreadGroup = b.svgThreadGroup; + this.svgBlockGroup = a.svgBlockGroup; + this.svgThreadGroup = a.svgThreadGroup; this.svgGroup.appendChild(this.svgThreadGroup); this.svgGroup.appendChild(this.svgBlockGroup); }; - a.setMagnetedBlock = function(b, a) { + b.setMagnetedBlock = function(a, b) { if (this.magnetedBlockView) { - if (this.magnetedBlockView === b) { + if (this.magnetedBlockView === a) { return; } this.magnetedBlockView.set({magneting:!1}); } - this.set({magnetedBlockView:b}); - b && (b.set({magneting:a}), b.dominate()); + this.set({magnetedBlockView:a}); + a && (a.set({magneting:b}), a.dominate()); }; - a.getCode = function() { + b.getCode = function() { return this.code; }; - a.findById = function(b) { - return this.code.findById(b); + b.findById = function(a) { + return this.code.findById(a); }; - a._addControl = function() { - var b = this.svgDom, a = this; - b.mousedown(function() { - a.onMouseDown.apply(a, arguments); + b._addControl = function() { + var a = this.svgDom, b = this; + a.mousedown(function() { + b.onMouseDown.apply(b, arguments); }); - b.bind("touchstart", function() { - a.onMouseDown.apply(a, arguments); + a.bind("touchstart", function() { + b.onMouseDown.apply(b, arguments); }); - b.on("wheel", function() { - a.mouseWheel.apply(a, arguments); + a.on("wheel", function() { + b.mouseWheel.apply(b, arguments); }); - var c = a.scroller; - c && (b.mouseenter(function(b) { + var c = b.scroller; + c && (a.mouseenter(function(a) { c.setOpacity(1); - }), b.mouseleave(function(b) { + }), a.mouseleave(function(a) { c.setOpacity(0); })); }; - a.onMouseDown = function(b) { - function a(b) { - b.stopPropagation && b.stopPropagation(); - b.preventDefault && b.preventDefault(); - b = Entry.Utils.convertMouseEvent(b); + b.onMouseDown = function(a) { + function b(a) { + a.stopPropagation && a.stopPropagation(); + a.preventDefault && a.preventDefault(); + a = Entry.Utils.convertMouseEvent(a); var c = e.mouseDownCoordinate; - Math.sqrt(Math.pow(b.pageX - c.x, 2) + Math.pow(b.pageY - c.y, 2)) < Entry.Board.DRAG_RADIUS || (f && (clearTimeout(f), f = null), c = e.dragInstance, e.scroller.scroll(b.pageX - c.offsetX, b.pageY - c.offsetY), c.set({offsetX:b.pageX, offsetY:b.pageY})); + Math.sqrt(Math.pow(a.pageX - c.x, 2) + Math.pow(a.pageY - c.y, 2)) < Entry.Board.DRAG_RADIUS || (f && (clearTimeout(f), f = null), c = e.dragInstance, e.scroller.scroll(a.pageX - c.offsetX, a.pageY - c.offsetY), c.set({offsetX:a.pageX, offsetY:a.pageY})); } - function c(b) { + function c(a) { f && (clearTimeout(f), f = null); $(document).unbind(".entryBoard"); delete e.mouseDownCoordinate; delete e.dragInstance; } if (this.workspace.getMode() != Entry.Workspace.MODE_VIMBOARD) { - b.stopPropagation && b.stopPropagation(); - b.preventDefault && b.preventDefault(); + a.stopPropagation && a.stopPropagation(); + a.preventDefault && a.preventDefault(); var e = this, f = null; - if (0 === b.button || b.originalEvent && b.originalEvent.touches) { - var g = b.type, h = Entry.Utils.convertMouseEvent(b); + if (0 === a.button || a.originalEvent && a.originalEvent.touches) { + var g = a.type, h = Entry.Utils.convertMouseEvent(a); Entry.documentMousedown && Entry.documentMousedown.notify(h); var k = $(document); this.mouseDownCoordinate = {x:h.pageX, y:h.pageY}; - k.bind("mousemove.entryBoard", a); + k.bind("mousemove.entryBoard", b); k.bind("mouseup.entryBoard", c); - k.bind("touchmove.entryBoard", a); + k.bind("touchmove.entryBoard", b); k.bind("touchend.entryBoard", c); this.dragInstance = new Entry.DragInstance({startX:h.pageX, startY:h.pageY, offsetX:h.pageX, offsetY:h.pageY}); "touchstart" === g && (f = setTimeout(function() { - f && (f = null, c(), e._rightClick(b)); + f && (f = null, c(), e._rightClick(a)); }, 1E3)); } else { - Entry.Utils.isRightButton(b) && this._rightClick(b); + Entry.Utils.isRightButton(a) && this._rightClick(a); } } }; - a.mouseWheel = function(b) { - b = b.originalEvent; - b.preventDefault(); - var a = Entry.disposeEvent; - a && a.notify(b); - this.scroller.scroll(b.wheelDeltaX || -b.deltaX, b.wheelDeltaY || -b.deltaY); + b.mouseWheel = function(a) { + a = a.originalEvent; + a.preventDefault(); + var b = Entry.disposeEvent; + b && b.notify(a); + this.scroller.scroll(a.wheelDeltaX || -a.deltaX, a.wheelDeltaY || -a.deltaY); }; - a.setSelectedBlock = function(b) { - var a = this.selectedBlockView; - a && a.removeSelected(); - b instanceof Entry.BlockView ? b.addSelected() : b = null; - this.set({selectedBlockView:b}); + 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(b) { - var a = this.selectedBlockView; - a && 46 == b.keyCode && a.block && !Entry.Utils.isInInput(b) && (Entry.do("destroyBlock", a.block), this.set({selectedBlockView:null})); + b._keyboardControl = function(a) { + var b = this.selectedBlockView; + b && 46 == a.keyCode && b.block && !Entry.Utils.isInInput(a) && (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 b = this.svgDom.height(), a = this.code.getThreads(), c = 15, e = 0, b = b - 30, f = 50, g = 0;g < a.length;g++) { - var h = a[g].getFirstBlock(); + b.alignThreads = function() { + for (var a = this.svgDom.height(), b = this.code.getThreads(), c = 15, e = 0, a = a - 30, f = 50, g = 0;g < b.length;g++) { + var h = b[g].getFirstBlock(); if (h && (h = h.view, h.movable)) { var k = h.svgGroup.getBBox(), l = c + 15; - l > b && (f = f + e + 10, e = 0, c = 15); + l > a && (f = f + e + 10, e = 0, c = 15); e = Math.max(e, k.width); l = c + 15; h._moveTo(f, l, !1); @@ -23875,50 +23339,50 @@ Entry.Board.DRAG_RADIUS = 5; } 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 b = $(window), a = b.scrollTop(), b = b.scrollLeft(), c = this._offset; - this.relativeOffset = {top:c.top - a, left:c.left - b}; + var a = $(window), b = a.scrollTop(), a = a.scrollLeft(), c = this._offset; + this.relativeOffset = {top:c.top - b, left:c.left - a}; this.btnWrapper && this.btnWrapper.attr({transform:"translate(" + (c.width / 2 - 65) + "," + (c.height - 200) + ")"}); }; - a.generateButtons = function() { - var b = this, a = this.svgGroup.elem("g"); - this.btnWrapper = a; - var c = a.elem("text", {x:27, y:33, class:"entryFunctionButtonText"}); + b.generateButtons = function() { + var a = this, b = this.svgGroup.elem("g"); + this.btnWrapper = b; + var c = b.elem("text", {x:27, y:33, class:"entryFunctionButtonText"}); c.textContent = Lang.Buttons.save; - var e = a.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 = 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"}); + 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() { - b.save(); + a.save(); }); $(c).bind("mousedown touchstart", function() { - b.save(); + a.save(); }); - $(a).bind("mousedown touchstart", function() { - b.cancelEdit(); + $(b).bind("mousedown touchstart", function() { + a.cancelEdit(); }); $(e).bind("mousedown touchstart", function() { - b.cancelEdit(); + 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() { - var b = this.code; - if (b && this.dragBlock) { - for (var a in this.dragBlock.magnet) { - var c = this._getCodeBlocks(b, a); - c.sort(function(b, a) { - return b.point - a.point; + b.generateCodeMagnetMap = function() { + var a = this.code; + if (a && this.dragBlock) { + for (var b in this.dragBlock.magnet) { + var c = this._getCodeBlocks(a, b); + c.sort(function(a, b) { + return a.point - b.point; }); c.unshift({point:-Number.MAX_VALUE, blocks:[]}); for (var e = 1;e < c.length;e++) { @@ -23931,84 +23395,83 @@ Entry.Board.DRAG_RADIUS = 5; f.endPoint = Number.MAX_VALUE; c[e - 1].endPoint = f.point; } - this._magnetMap[a] = c; + this._magnetMap[b] = c; } } }; - a._getCodeBlocks = function(b, a) { - b = b.getThreads(); - var c = [], e; - switch(a) { + b._getCodeBlocks = function(a, b) { + var c = 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 < b.length;f++) { - var g = b[f], c = c.concat(e.call(this, g, g.view.zIndex, null, a)) + for (var g = 0;g < c.length;g++) { + var h = c[g], e = e.concat(f.call(this, h, h.view.zIndex, null, b)) } - return c; + return e; }; - a._getNextMagnets = function(b, a, c, e) { - var f = b.getBlocks(), g = [], h = []; + b._getNextMagnets = function(a, b, c, e) { + var f = a.getBlocks(), g = [], h = []; c || (c = {x:0, y:0}); var k = c.x; c = c.y; for (var l = 0;l < f.length;l++) { var m = f[l], n = m.view; - n.zIndex = a; + n.zIndex = b; if (n.dragInstance) { break; } c += n.y; k += n.x; - b = c + 1; - n.magnet.next && (b += n.height, h.push({point:c, endPoint:b, startBlock:m, blocks:[]}), h.push({point:b, blocks:[]}), n.absX = k); - m.statements && (a += .01); + a = c + 1; + n.magnet.next && (a += n.height, h.push({point:c, endPoint:a, startBlock:m, blocks:[]}), h.push({point:a, blocks:[]}), n.absX = k); + m.statements && (b += .01); for (var q = 0;q < m.statements.length;q++) { - b = m.statements[q]; + a = m.statements[q]; var r = m.view._statements[q]; - r.zIndex = a; + r.zIndex = b; r.absX = k + r.x; h.push({point:r.y + c - 30, endPoint:r.y + c, startBlock:r, blocks:[]}); h.push({point:r.y + c + r.height, blocks:[]}); - a += .01; - g = g.concat(this._getNextMagnets(b, a, {x:r.x + k, y:r.y + c}, e)); + b += .01; + g = g.concat(this._getNextMagnets(a, b, {x:r.x + k, y:r.y + c}, e)); } n.magnet.next && (c += n.magnet.next.y, k += n.magnet.next.x); } return g.concat(h); }; - a._getPreviousMagnets = function(b, a, c, e) { - var f = b.getBlocks(); - b = []; + b._getPreviousMagnets = function(a, b, c, e) { + var f = a.getBlocks(); + a = []; c || (c = {x:0, y:0}); e = c.x; c = c.y; var f = f[0], g = f.view; - g.zIndex = a; + g.zIndex = b; if (g.dragInstance) { return []; } c += g.y - 15; e += g.x; - return g.magnet.previous ? (a = c + 1 + g.height, b.push({point:c, endPoint:a, startBlock:f, blocks:[]}), b.push({point:a, blocks:[]}), g.absX = e, b) : []; + return g.magnet.previous ? (b = c + 1 + g.height, a.push({point:c, endPoint:b, startBlock:f, blocks:[]}), a.push({point:b, blocks:[]}), g.absX = e, a) : []; }; - a._getFieldMagnets = function(b, a, c, e) { - var f = b.getBlocks(), g = [], h = []; + b._getFieldMagnets = function(a, b, c, e) { + var f = a.getBlocks(), g = [], h = []; c || (c = {x:0, y:0}); var k = c.x; c = c.y; @@ -24017,28 +23480,28 @@ Entry.Board.DRAG_RADIUS = 5; if (n.dragInstance) { break; } - n.zIndex = a; + n.zIndex = b; c += n.y; k += n.x; - h = h.concat(this._getFieldBlockMetaData(n, k, c, a, e)); - m.statements && (a += .01); + h = h.concat(this._getFieldBlockMetaData(n, k, c, b, e)); + m.statements && (b += .01); for (var q = 0;q < m.statements.length;q++) { - b = m.statements[q]; - var r = m.view._statements[q], g = g.concat(this._getFieldMagnets(b, a, {x:r.x + k, y:r.y + c}, e)); + a = m.statements[q]; + var r = m.view._statements[q], g = g.concat(this._getFieldMagnets(a, b, {x:r.x + k, y:r.y + c}, e)); } n.magnet.next && (c += n.magnet.next.y, k += n.magnet.next.x); } return g.concat(h); }; - a._getFieldBlockMetaData = function(b, a, c, e, f) { - var g = b._contents, h = []; - c += b.contentPos.y; + b._getFieldBlockMetaData = function(a, b, c, e, f) { + var g = a._contents, h = []; + c += a.contentPos.y; for (var k = 0;k < g.length;k++) { var l = g[k]; if (l instanceof Entry.FieldBlock) { var m = l._valueBlock; if (!m.view.dragInstance && (l.acceptType === f || "boolean" === l.acceptType)) { - var n = a + l.box.x, q = c + l.box.y + b.contentHeight % 1E3 * -.5, r = c + l.box.y + l.box.height; + var n = b + l.box.x, q = c + l.box.y + a.contentHeight % 1E3 * -.5, r = c + l.box.y + l.box.height; l.acceptType === f && (h.push({point:q, endPoint:r, startBlock:m, blocks:[]}), h.push({point:r, blocks:[]})); l = m.view; l.absX = n; @@ -24049,8 +23512,8 @@ Entry.Board.DRAG_RADIUS = 5; } return h; }; - a._getOutputMagnets = function(b, a, c, e) { - var f = b.getBlocks(), g = [], h = []; + b._getOutputMagnets = function(a, b, c, e) { + var f = a.getBlocks(), g = [], h = []; c || (c = {x:0, y:0}); var k = c.x; c = c.y; @@ -24059,35 +23522,35 @@ Entry.Board.DRAG_RADIUS = 5; if (n.dragInstance) { break; } - n.zIndex = a; + n.zIndex = b; c += n.y; k += n.x; - h = h.concat(this._getOutputMetaData(n, k, c, a, e)); - m.statements && (a += .01); + h = h.concat(this._getOutputMetaData(n, k, c, b, e)); + m.statements && (b += .01); for (var q = 0;q < m.statements.length;q++) { - b = m.statements[q]; - var r = m.view._statements[q], g = g.concat(this._getOutputMagnets(b, a, {x:r.x + k, y:r.y + c}, e)); + a = m.statements[q]; + var r = m.view._statements[q], g = g.concat(this._getOutputMagnets(a, b, {x:r.x + k, y:r.y + c}, e)); } n.magnet.next && (c += n.magnet.next.y, k += n.magnet.next.x); } return g.concat(h); }; - a._getOutputMetaData = function(b, a, c, e, f) { - var g = b._contents, h = []; - a += b.contentPos.x; - c += b.contentPos.y; - for (b = 0;b < g.length;b++) { - var k = g[b], l = a + k.box.x, m = c - 24, n = c; + b._getOutputMetaData = function(a, b, c, e, f) { + var g = a._contents, h = []; + b += a.contentPos.x; + c += a.contentPos.y; + for (a = 0;a < g.length;a++) { + var k = g[a], l = b + k.box.x, m = c - 24, n = c; k instanceof Entry.FieldBlock ? (k.acceptType === f && (h.push({point:m, endPoint:n, startBlock:k, blocks:[]}), h.push({point:n, blocks:[]}), k.absX = l, k.zIndex = e, k.width = 20), (m = k._valueBlock) && (h = h.concat(this._getOutputMetaData(m.view, l, c + k.box.y, e + .01, f)))) : k instanceof Entry.FieldOutput && k.acceptType === f && (h.push({point:m, endPoint:n, startBlock:k, blocks:[]}), h.push({point:n, blocks:[]}), k.absX = l, k.zIndex = e, k.width = 20, (m = k._valueBlock) && (m.view.dragInstance || - (h = h.concat(this._getOutputMetaData(m.view, a + k.box.x, c + k.box.y, e + .01, f))))); + (h = h.concat(this._getOutputMetaData(m.view, b + k.box.x, c + k.box.y, e + .01, f))))); } return h; }; - a.getNearestMagnet = function(b, a, c) { + b.getNearestMagnet = function(a, b, c) { var e = this._magnetMap[c]; if (e && 0 !== e.length) { - var f = 0, g = e.length - 1, h, k = null, l = "previous" === c ? a - 15 : a; - for (a = -1 < ["previous", "next"].indexOf(c) ? 20 : 0;f <= g;) { + var f = 0, g = e.length - 1, h, k = null, l = "previous" === c ? b - 15 : b; + for (b = -1 < ["previous", "next"].indexOf(c) ? 20 : 0;f <= g;) { if (h = (f + g) / 2 | 0, c = e[h], l < c.point) { g = h - 1; } else { @@ -24096,7 +23559,7 @@ Entry.Board.DRAG_RADIUS = 5; } else { e = c.blocks; for (f = 0;f < e.length;f++) { - if (g = e[f].view, g.absX - a < b && b < g.absX + g.width && (g = c.blocks[f], !k || k.view.zIndex < g.view.zIndex)) { + if (g = e[f].view, g.absX - b < a && a < g.absX + g.width && (g = c.blocks[f], !k || k.view.zIndex < g.view.zIndex)) { k = c.blocks[f]; } } @@ -24107,1758 +23570,2147 @@ Entry.Board.DRAG_RADIUS = 5; return null; } }; - a.dominate = function(b) { - b && (b = b.getFirstBlock()) && (this.svgBlockGroup.appendChild(b.view.svgGroup), this.code.dominate(b.thread)); + b.dominate = function(a) { + a && (a = a.getFirstBlock()) && (this.svgBlockGroup.appendChild(a.view.svgGroup), this.code.dominate(a.thread)); }; - a.setPatternRectFill = function(b) { - this.patternRect.attr({fill:b}); + 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(b) { - b = b.view; - var a = b.getAbsoluteCoordinate(), c = this.svgDom, e = a.x, a = a.y, e = c.width() / 2 - e, c = c.height() / 2 - a - 100; + b.activateBlock = function(a) { + a = a.view; + var b = a.getAbsoluteCoordinate(), c = this.svgDom, e = b.x, b = b.y, e = c.width() / 2 - e, c = c.height() / 2 - b - 100; this.scroller.scroll(e, c); - b.addActivated(); - this._activatedBlockView = b; + a.addActivated(); + this._activatedBlockView = a; }; - a.reDraw = function() { + b.reDraw = function() { this.code.view.reDraw(); }; - a.separate = function(b, a) { - "string" === typeof b && (b = this.findById(b)); - b.view && b.view._toGlobalCoordinate(); - var c = b.getPrevBlock(); - b.separate(a); + b.separate = function(a, b) { + "string" === typeof a && (a = this.findById(a)); + a.view && a.view._toGlobalCoordinate(); + var c = a.getPrevBlock(); + a.separate(b); c && c.getNextBlock() && c.getNextBlock().view.bindPrev(); }; - a.insert = function(b, a, c) { - "string" === typeof b && (b = this.findById(b)); - this.separate(b, c); - 3 === a.length ? b.moveTo(a[0], a[1]) : 4 === a.length && 0 === a[3] ? (a = this.code.getThreads()[a[2]], b.thread.cut(b), a.insertToTop(b), b.getNextBlock().view.bindPrev()) : (a = a instanceof Array ? this.code.getTargetByPointer(a) : a, a instanceof Entry.Block ? ("basic" === b.getBlockType() && b.view.bindPrev(a), b.doInsert(a)) : a instanceof Entry.FieldStatement ? (b.view.bindPrev(a), a.insertTopBlock(b)) : b.doInsert(a)); + b.insert = function(a, b, c) { + "string" === typeof a && (a = this.findById(a)); + this.separate(a, 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() { - var b = this.code; - b && (b = b.getThreads()) && 0 !== b.length && (b = b.sort(function(b, a) { - return b.getFirstBlock().view.x - a.getFirstBlock().view.x; - }), b = b[0].getFirstBlock()) && (b = b.view, b = b.getAbsoluteCoordinate(), this.scroller.scroll(50 - b.x, 30 - b.y)); + 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() { - var b = this; + b._initContextOptions = function() { + var a = this; this._contextOptions = [{activated:!0, option:{text:Lang.Blocks.Paste_blocks, enable:!!Entry.clipboard, callback:function() { Entry.do("addThread", Entry.clipboard).value.getFirstBlock().copyToClipboard(); }}}, {activated:!0, option:{text:Lang.Blocks.tidy_up_block, callback:function() { - b.alignThreads(); + a.alignThreads(); }}}, {activated:!0, option:{text:Lang.Blocks.Clear_all_blocks, callback:function() { - b.code.clear(); + a.code.clear(); }}}, {activated:"workspace" === Entry.type && Entry.Utils.isChrome() && !Entry.isMobile(), option:{text:Lang.Menus.save_as_image_all, enable:!0, callback:function() { - b.code.getThreads().forEach(function(b) { - (b = b.getFirstBlock()) && b.view.downloadAsImage(); + a.code.getThreads().forEach(function(a) { + (a = a.getFirstBlock()) && a.view.downloadAsImage(); }); }}}]; }; - a.activateContextOption = function(b) { - this._contextOptions[b].activated = !0; + b.activateContextOption = function(a) { + this._contextOptions[a].activated = !0; }; - a.deActivateContextOption = function(b) { - this._contextOptions[b].activated = !1; + 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) { - var b = _.debounce(this.updateOffset, 200); - Entry.windowResized.attach(this, b); + var a = _.debounce(this.updateOffset, 200); + 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; }; - a._rightClick = function(b) { - var a = Entry.disposeEvent; - a && a.notify(b); + b._rightClick = function(a) { + var b = Entry.disposeEvent; + b && b.notify(a); if (this.visible) { - var a = [], c = this._contextOptions; + var b = [], c = this._contextOptions; c[Entry.Board.OPTION_PASTE].option.enable = !!Entry.clipboard; c[Entry.Board.OPTION_DOWNLOAD].option.enable = 0 !== this.code.getThreads().length; for (var e = 0;e < this._contextOptions.length;e++) { - c[e].activated && a.push(c[e].option); + c[e].activated && b.push(c[e].option); } - b = Entry.Utils.convertMouseEvent(b); - Entry.ContextMenu.show(a, null, {x:b.clientX, y:b.clientY}); + a = Entry.Utils.convertMouseEvent(a); + Entry.ContextMenu.show(b, null, {x:a.clientX, y:a.clientY}); } }; })(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, d = b.contentHeight, d = Math.max(30, d + 2), a = Math.max(0, a + 9 - d / 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, d).replace(/%w/gi, a).replace(/%bw/gi, a - 8).replace(/%h/gi, d / 2).replace(/%sh/gi, b + 1); +}, magnets:function(b) { + var a = Math.max(b.contentHeight + 2, 30), d = b._statements[0] ? b._statements[0].height : 20, d = Math.max(d, 20); + return {previous:{x:0, y:0}, next:{x:0, y:d + a + 18 + b.offsetY}}; +}, box:function(b) { + var a = b.contentWidth, d = 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:d + 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, d = b.contentHeight, d = Math.max(30, d + 2), a = Math.max(0, a + 9 - d / 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, d).replace(/%w/gi, a).replace(/%h/gi, d / 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), d = b._statements[0] ? b._statements[0].height : 20, d = Math.max(d, 51); + return {previous:{x:0, y:0}, next:{x:0, y:d + a + 13 + b.offsetY}}; +}, box:function(b) { + var a = b.contentWidth, d = 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:d + 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, d = b.contentHeight % 1E6, c = Math.floor(b.contentHeight / 1E6), d = Math.max(30, d + 2), c = Math.max(30, c + 2), a = Math.max(0, a + 5 - d / 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, d).replace(/%wh2/gi, c).replace(/%w/gi, a).replace(/%bw/gi, a - 8).replace(/%h1/gi, d / 2).replace(/%h2/gi, c / 2).replace(/%sh1/gi, b + 1).replace(/%sh2/gi, e + 1); +}, magnets:function(b) { + var a = Math.max(b.contentHeight % 1E6 + 2, 30), d = Math.max(Math.floor(b.contentHeight / 1E6) + 2, 30), c = b._statements[0] ? b._statements[0].height : 20, e = b._statements[1] ? b._statements[1].height : 20, c = Math.max(c, 20), e = Math.max(e, 20); + return {previous:{x:0, y:0}, next:{x:0, y:c + e + a + d + 19 + b.offsetY}}; +}, box:function(b) { + var a = b.contentWidth, d = Math.max(Math.floor(b.contentHeight / 1E6) + 2, 30), c = Math.max(b.contentHeight % 1E6 + 2, 30), e = b._statements[0] ? b._statements[0].height % 1E6 : 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:d + c + e + b + 17, marginBottom:0}; +}, statementPos:function(b) { + var a = Math.max(30, b.contentHeight % 1E6 + 2) + 1; + return [{x:16, y:a}, {x:16, y:a + Math.max(b._statements[0] ? b._statements[0].height % 1E6 : 20, 20) + Math.max(Math.floor(b.contentHeight / 1E6) + 2, 30) + 1}]; +}, contentPos:function(b) { + return {x:14, y:Math.max(b.contentHeight % 1E6, 28) / 2 + 1}; +}}; +Entry.Thread = function(b, a, d) { 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 = d ? d : a; + this.load(b); }; -Entry.STATEMENT = 0; -Entry.PARAM = -1; -(function(a) { - a.schema = {view:null, board:null}; - a.load = function(b) { - b instanceof Array || (b = JSON.parse(b)); - this.clear(); - for (var a = 0;a < b.length;a++) { - this._data.push(new Entry.Thread(b[a], this)); - } - return this; - }; - a.clear = function() { - for (var b = this._data.length - 1;0 <= b;b--) { - this._data[b].destroy(!1); +(function(b) { + b.load = function(a, b) { + void 0 === a && (a = []); + if (!(a instanceof Array)) { + return console.error("thread must be array"); } - this.clearExecutors(); - this._eventMap = {}; - }; - a.createView = function(b) { - null === this.view ? this.set({view:new Entry.CodeView(this, b), board:b}) : (this.set({board:b}), b.bindCodeView(this.view)); - }; - a.destroyView = function() { - this.view && (this.view.destroy(), delete this.view); - }; - a.recreateView = function() { - this.view && (this.destroyView(), this.set({view:new Entry.CodeView(this, this.board), board:this.board})); - }; - a.registerEvent = function(b, a) { - this._eventMap[a] || (this._eventMap[a] = []); - this._eventMap[a].push(b); - }; - a.unregisterEvent = function(b, a) { - (a = this._eventMap[a]) && 0 !== a.length && (b = a.indexOf(b), 0 > b || a.splice(b, 1)); - }; - a.raiseEvent = function(b, a, c) { - b = this._eventMap[b]; - var e = []; - if (void 0 !== b) { - for (var f = 0;f < b.length;f++) { - var g = b[f]; - if (void 0 === c || -1 < g.params.indexOf(c)) { - g = new Entry.Executor(b[f], a), this.executors.push(g), e.push(g); - } - } - return e; + for (var c = 0;c < a.length;c++) { + var e = a[c]; + e instanceof Entry.Block || e.isDummy ? (e.setThread(this), this._data.push(e)) : this._data.push(new Entry.Block(e, this)); } + (c = this._code.view) && this.createView(c.board, b); }; - a.getEventMap = function(b) { - return this._eventMap[b]; + b.registerEvent = function(a, b) { + this._event = b; + this._code.registerEvent(a, b); }; - a.map = function(b) { - this._data.map(b); + b.unregisterEvent = function(a, b) { + this._code.unregisterEvent(a, b); }; - a.tick = function() { - for (var b = this.executors, a = 0;a < b.length;a++) { - var c = b[a]; - c.isEnd() ? (b.splice(a--, 1), 0 === b.length && this.executeEndEvent.notify()) : c.execute(); - } - }; - a.removeExecutor = function(b) { - b = this.executors.indexOf(b); - -1 < b && this.executors.splice(b, 1); + b.createView = function(a, b) { + this.view || (this.view = new Entry.ThreadView(this, a)); + this._data.getAll().forEach(function(c) { + c.createView(a, b); + }); }; - a.clearExecutors = function() { - this.executors.forEach(function(b) { - b.end(); + b.destroyView = function() { + this.view = null; + this._data.map(function(a) { + a.destroyView(); }); - this.executors = []; }; - a.clearExecutorsByEntity = function(b) { - for (var a = this.executors, c = 0;c < a.length;c++) { - var e = a[c]; - e.entity === b && e.end(); + b.separate = function(a, b) { + if (this._data.has(a.id)) { + var c = this._data.splice(this._data.indexOf(a), b); + this._code.createThread(c); + this.changeEvent.notify(); } }; - a.addExecutor = function(b) { - this.executors.push(b); + b.cut = function(a) { + a = this._data.indexOf(a); + a = this._data.splice(a); + this.changeEvent.notify(); + return a; }; - a.createThread = function(b, a) { - if (!(b instanceof Array)) { - return console.error("blocks must be array"); + b.insertByBlock = function(a, b) { + for (var c = a ? this._data.indexOf(a) : -1, e = 0;e < b.length;e++) { + b[e].setThread(this); } - b = new Entry.Thread(b, this); - void 0 === a ? this._data.push(b) : this._data.insert(b, a); - return b; - }; - a.cloneThread = function(b, a) { - b = b.clone(this, a); - this._data.push(b); - return b; - }; - a.destroyThread = function(b, a) { - a = this._data; - b = a.indexOf(b); - 0 > b || a.splice(b, 1); - }; - a.doDestroyThread = function(b, a) { - a = this._data; - b = a.indexOf(b); - 0 > b || a.splice(b, 1); + this._data.splice.apply(this._data, [c + 1, 0].concat(b)); + this.changeEvent.notify(); }; - a.getThreads = function() { - return this._data.map(function(b) { - return b; - }); + b.insertToTop = function(a) { + a.setThread(this); + this._data.unshift.apply(this._data, [a]); + this.changeEvent.notify(); }; - a.toJSON = function() { - for (var b = this.getThreads(), a = [], c = 0, e = b.length;c < e;c++) { - a.push(b[c].toJSON()); + b.clone = function(a, b) { + a = a || this._code; + for (var c = new Entry.Thread([], a), e = this._data, f = [], g = 0, h = e.length;g < h;g++) { + f.push(e[g].clone(c)); } - return a; + c.load(f, b); + return c; }; - a.countBlock = function() { - for (var b = this.getThreads(), a = 0, c = 0;c < b.length;c++) { - a += b[c].countBlock(); + b.toJSON = function(a, b) { + for (var c = [], e = void 0 === b ? 0 : b;e < this._data.length;e++) { + this._data[e] instanceof Entry.Block && c.push(this._data[e].toJSON(a)); } - return a; + return c; }; - a.moveBy = function(b, a) { - for (var c = this.getThreads(), e = 0, f = c.length;e < f;e++) { - var g = c[e].getFirstBlock(); - g && g.view._moveBy(b, a, !1); + b.destroy = function(a) { + this._code.destroyThread(this, !1); + this.view && this.view.destroy(a); + for (var b = this._data, c = b.length - 1;0 <= c;c--) { + b[c].destroy(a); } - b = this.board; - b instanceof Entry.BlockMenu && b.updateSplitters(a); - }; - a.stringify = function() { - return JSON.stringify(this.toJSON()); - }; - a.dominate = function(b) { - b.view.setZIndex(this._maxZIndex++); }; - a.indexOf = function(b) { - return this._data.indexOf(b); + b.getBlock = function(a) { + return this._data[a]; }; - a._handleChange = function() { - Entry.creationChangedEvent && Entry.creationChangedEvent.notify(); + b.getBlocks = function() { + return this._data.map(function(a) { + return a; + }); }; - a.hasBlockType = function(b) { - for (var a = this.getThreads(), c = 0;c < a.length;c++) { - if (a[c].hasBlockType(b)) { - return !0; + b.countBlock = function() { + for (var a = 0, b = 0;b < this._data.length;b++) { + var c = this._data[b]; + if (c.type && (a++, c = c.statements)) { + for (var e = 0;e < c.length;e++) { + a += c[e].countBlock(); + } } } - return !1; - }; - a.findById = function(b) { - return this._blockMap[b]; - }; - a.registerBlock = function(b) { - this._blockMap[b.id] = b; - }; - a.unregisterBlock = function(b) { - delete this._blockMap[b.id]; - }; - a.getByPointer = function(b) { - b = b.concat(); - b.shift(); - b.shift(); - for (var a = this._data[b.shift()].getBlock(b.shift());b.length;) { - a instanceof Entry.Block || (a = a.getValueBlock()); - var c = b.shift(), e = b.shift(); - -1 < c ? a = a.statements[c].getBlock(e) : -1 === c && (a = a.view.getParam(e)); - } return a; }; - a.getTargetByPointer = function(b) { - b = b.concat(); - b.shift(); - b.shift(); - var a = this._data[b.shift()], c; - if (1 === b.length) { - c = a.getBlock(b.shift() - 1); - } else { - for (c = a.getBlock(b.shift());b.length;) { - c instanceof Entry.Block || (c = c.getValueBlock()); - var e = b.shift(), a = b.shift(); - -1 < e ? (c = c.statements[e], c = b.length ? c.getBlock(a) : 0 === a ? c.view.getParent() : c.getBlock(a - 1)) : -1 === e && (c = c.view.getParam(a)); - } - } - return c; + b.handleChange = function() { + 0 === this._data.length && this.destroy(); }; - a.getBlockList = function(b, a) { - for (var c = this.getThreads(), e = [], f = 0;f < c.length;f++) { - e = e.concat(c[f].getBlockList(b, a)); - } - return e; + b.getCode = function() { + return this._code; }; - a.removeBlocksByType = function(b) { - this.getBlockList(!1, b).forEach(function(b) { - b.doDestroy(); - }); + b.setCode = function(a) { + this._code = a; }; -})(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._data.getAll().forEach(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}); + b.spliceBlock = function(a) { + this._data.remove(a); + this.changeEvent.notify(); }; - a.reDraw = function() { - this.code.map(function(b) { - b.view.reDraw(); - }); + b.getFirstBlock = function() { + return this._data[0]; }; - a.destroy = function() { - this.code.map(function(b) { - b.destroyView(); - }); + b.getPrevBlock = function(a) { + a = this._data.indexOf(a); + return this._data.at(a - 1); }; -})(Entry.CodeView.prototype); -Entry.ConnectionRipple = {}; -(function(a) { - a.createDom = function(b) { - this.svgDom || (this._ripple = b.getBoard().svgGroup.elem("circle", {cx:0, cy:0, r:0, stroke:"#888", "stroke-width":10})); - }; - a.setView = function(b) { - this._ripple || this.createDom(b); - var a = this._ripple, c = b.getBoard().svgGroup; - a.remove(); - b = b.getAbsoluteCoordinate(); - a.attr({cx:b.x, cy:b.y}); - c.appendChild(a); - a._startTime = new Date; - return this; + b.getNextBlock = function(a) { + a = this._data.indexOf(a); + return this._data.at(a + 1); }; - a.dispose = function() { - var b = this, a = this._ripple, c = (new Date - a._startTime) / 150; - 1 < c ? a.remove() : (a.attr({r:25 * c, opacity:1 - c}), window.setTimeout(function() { - b.dispose(); - }, 10)); + b.getLastBlock = function() { + return this._data.at(this._data.length - 1); }; -})(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 (;;) { - var b = null; - try { - var a = this.scope.block.getSchema(); - a && (b = a.func.call(this.scope, this.entity, this.scope)); - } catch (e) { - if ("AsyncError" === e.name) { - b = Entry.STATIC.BREAK; - } else { - var c = !1; - "\ub7f0\ud0c0\uc784 \uc5d0\ub7ec" != e.message && (c = !0); - Entry.Utils.stopProjectWithToast(this.scope, "\ub7f0\ud0c0\uc784 \uc5d0\ub7ec", c); - } - } - if (this.isEnd()) { - break; + b.getRootBlock = function() { + return this._data.at(0); + }; + b.hasBlockType = function(a) { + function b(c) { + if (a == c.type) { + return !0; + } + for (var f = c.params, g = 0;g < f.length;g++) { + var h = f[g]; + if (h && h.constructor == Entry.Block && b(h)) { + return !0; } - if (void 0 === b || null === b || b === Entry.STATIC.PASS) { - if (this.scope = new Entry.Scope(this.scope.block.getNextBlock(), this), null === this.scope.block) { - if (this._callStack.length) { - if (b = this.scope, this.scope = this._callStack.pop(), this.scope.isLooped !== b.isLooped) { - break; - } - } else { - break; - } - } - } else { - if (b !== Entry.STATIC.CONTINUE && (b === Entry.STATIC.BREAK || this.scope === b)) { - break; + } + if (c = c.statements) { + for (f = 0;f < c.length;f++) { + if (c[f].hasBlockType(a)) { + return !0; } } } + return !1; } - }; - a.stepInto = function(b) { - b instanceof Entry.Thread || console.error("Must step in to thread"); - b = b.getFirstBlock(); - if (!b) { - return Entry.STATIC.BREAK; - } - this._callStack.push(this.scope); - this.scope = new Entry.Scope(b, this); - return Entry.STATIC.CONTINUE; - }; - a.break = function() { - this._callStack.length && (this.scope = this._callStack.pop()); - return Entry.STATIC.PASS; - }; - 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(); + for (var c = 0;c < this._data.length;c++) { + if (b(this._data[c])) { + return !0; + } } - return Entry.STATIC.PASS; + return !1; }; - a.end = function() { - this.scope.block = null; + b.getCount = function(a) { + var b = this._data.length; + a && (b -= this._data.indexOf(a)); + return b; }; - a.isEnd = function() { - return null === this.scope.block; + b.indexOf = function(a) { + return this._data.indexOf(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.pointer = function(a, b) { + var c = this.indexOf(b); + 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); }; - a.getParam = function(b) { - b = this.block.params[b]; - var a = new Entry.Scope(b, this.executor); - return Entry.block[b.type].func.call(a, this.entity, a); + b.getBlockList = function(a, b) { + for (var c = [], e = 0;e < this._data.length;e++) { + c = c.concat(this._data[e].getBlockList(a, b)); + } + return c; }; - a.getParams = function() { - var b = this; - return this.block.params.map(function(a) { - if (a instanceof Entry.Block) { - var c = new Entry.Scope(a, b.executor); - return Entry.block[a.type].func.call(c, b.entity, c); - } - return a; - }); + b.stringify = function() { + return JSON.stringify(this.toJSON()); }; - a.getValue = function(b, a) { - b = this.block.params[this._getParamIndex(b, a)]; - a = new Entry.Scope(b, this.executor); - return Entry.block[b.type].func.call(a, this.entity, a); +})(Entry.Thread.prototype); +Entry.Block = function(b, a) { + var d = this; + Entry.Model(this, !1); + this._schema = null; + this.setThread(a); + this.load(b); + var c = this.getCode(); + c.registerBlock(this); + var e = this.events.dataAdd; + e && c.object && e.forEach(function(a) { + Entry.Utils.isFunction(a) && a(d); + }); +}; +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.getStringValue = function(b, a) { - return String(this.getValue(b, a)); + b.changeSchema = function(a) { + this.set({params:[]}); + this.loadSchema(); }; - a.getNumberValue = function(b, a) { - return Number(this.getValue(b)); + b.getSchema = function() { + this._schema || this.loadSchema(); + return this._schema; }; - a.getBooleanValue = function(b, a) { - return Number(this.getValue(b, a)) ? !0 : !1; + 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 c = a[b], e = 0;e < c.length;e++) { + var f = c[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++) { + c = void 0 === a[e] || null === a[e] ? b[e].value : a[e], f = a[e] || e < a.length, !c || "Output" !== b[e].type && "Block" !== b[e].type || (c = new Entry.Block(c, this.thread)), f ? a.splice(e, 1, c) : a.push(c); + } + 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.getField = function(b, a) { - return this.block.params[this._getParamIndex(b)]; + b.changeType = function(a) { + this._schemaChangeEvent && this._schemaChangeEvent.destroy(); + this.set({type:a}); + this.loadSchema(); + this.view && this.view.changeType(a); }; - a.getStringField = function(b, a) { - return String(this.getField(b)); + b.setThread = function(a) { + this.set({thread:a}); }; - a.getNumberField = function(b) { - return Number(this.getField(b)); + b.getThread = function() { + return this.thread; }; - a.getStatement = function(b, a) { - return this.executor.stepInto(this.block.statements[this._getStatementIndex(b, a)]); + b.insertAfter = function(a) { + this.thread.insertByBlock(this, a); }; - a._getParamIndex = function(b) { - this._schema || (this._schema = Entry.block[this.type]); - return this._schema.paramsKeyMap[b]; + b._updatePos = function() { + this.view && this.set({x:this.view.x, y:this.view.y}); }; - a._getStatementIndex = function(b) { - this._schema || (this._schema = Entry.block[this.type]); - return this._schema.statementsKeyMap[b]; + b.moveTo = function(a, b) { + this.view && this.view._moveTo(a, b); + this._updatePos(); + this.getCode().changeEvent.notify(); }; - a.die = function() { - this.block = null; - return Entry.STATIC.BREAK; + b.createView = function(a, b) { + this.view || (this.set({view:new Entry.BlockView(this, a, b)}), this._updatePos()); }; -})(Entry.Scope.prototype); -Entry.FieldAngle = function(a, b, d) { - this._block = b.block; - this._blockView = b; - this.box = new Entry.BoxModel; - this.svgGroup = null; - this.position = a.position; - this._contents = a; - this._index = d; - a = this.getValue(); - this.setValue(this.modValue(void 0 !== a ? a : 90)); - this._CONTENT_HEIGHT = this.getContentHeight(); - 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":"11px"}); - this.textElement.textContent = this.getText(); - var b = this.getTextWidth(), a = this._CONTENT_HEIGHT; - this._header = this.svgGroup.elem("rect", {x:0, y:(this.position && this.position.y ? this.position.y : 0) - a / 2, rx:3, ry:3, width:b, height:a, rx:3, ry:3, fill:"#fff", "fill-opacity":.4}); - this.svgGroup.appendChild(this.textElement); - this._bindRenderOptions(); - this.box.set({x:0, y:0, width:b, height:a}); + b.destroyView = function() { + this.set({view:null}); }; - a.renderOptions = function() { - var b = this; - this._attachDisposeEvent(function() { - b.applyValue(); - b.destroyOption(); - }); - this.optionGroup = Entry.Dom("input", {class:"entry-widget-input-field", parent:$("body")}); - this.optionGroup.val(this.value); - this.optionGroup.on("mousedown touchstart", function(b) { - b.stopPropagation(); - }); - this.optionGroup.on("keyup", function(a) { - var d = a.keyCode || a.which; - b.applyValue(a); - -1 < [13, 27].indexOf(d) && b.destroyOption(); + b.clone = function(a) { + return new Entry.Block(this.toJSON(!0), a); + }; + 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; }); - var a = this.getAbsolutePosFromDocument(); - a.y -= this.box.height / 2; - this.optionGroup.css({height:this._CONTENT_HEIGHT, left:a.x, top:a.y, width:b.box.width}); - this.svgOptionGroup = this.appendSvgOptionGroup(); - this.svgOptionGroup.elem("circle", {x:0, y:0, r:49, class:"entry-field-angle-circle"}); - $(this.svgOptionGroup).on("mousedown touchstart", function(a) { - a.stopPropagation(); - b._updateByCoord(a); + b.statements = b.statements.map(function(b) { + return b.toJSON(a); }); - this._dividerGroup = this.svgOptionGroup.elem("g"); - for (a = 0;360 > a;a += 15) { - this._dividerGroup.elem("line", {x1:49, y1:0, x2:49 - (0 === a % 45 ? 10 : 5), y2:0, transform:"rotate(" + a + ", 0, 0)", class:"entry-angle-divider"}); - } - a = this.getAbsolutePosFromBoard(); - a.x += this.box.width / 2; - a.y = a.y + this.box.height / 2 + 49 + 1; - this.svgOptionGroup.attr({class:"entry-field-angle", transform:"translate(" + a.x + "," + a.y + ")"}); - $(this.svgOptionGroup).bind("mousemove touchmove", this._updateByCoord.bind(this)); - $(this.svgOptionGroup).bind("mouseup touchend", this.destroyOption.bind(this)); - this.updateGraph(); - this.optionGroup.focus(); - this.optionGroup.select(); - }; - a._updateByCoord = function(b) { - b.originalEvent && b.originalEvent.touches && (b = b.originalEvent.touches[0]); - b = [b.clientX, b.clientY]; - var a = this.getAbsolutePosFromDocument(); - this.optionGroup.val(this.modValue(function(b, a) { - var d = a[0] - b[0]; - b = a[1] - b[1] - 49 - 1; - a = Math.atan(-b / d); - a = Entry.toDegrees(a); - a = 90 - a; - 0 > d ? a += 180 : 0 < b && (a += 360); - return 15 * Math.round(a / 15); - }([a.x + this.box.width / 2, a.y + this.box.height / 2 + 1], b))); - this.applyValue(); + b.x = this.x; + b.y = this.y; + b.movable = this.movable; + b.deletable = this.deletable; + b.readOnly = this.readOnly; + return b; }; - a.updateGraph = function() { - this._fillPath && this._fillPath.remove(); - var b = Entry.toRadian(this.getValue()), a = 49 * Math.sin(b), c = -49 * Math.cos(b), b = b > 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", a).replace("%Y", c).replace("%LARGE", b), 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:a, y2:c}); - this._indicator.attr({class:"entry-angle-indicator"}); + b.destroy = function(a, b) { + var c = 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)); + } + } + if (e = this.statements) { + for (f = 0;f < e.length;f++) { + e[f].destroy(a); + } + } + g = this.getPrevBlock(); + f = this.getNextBlock(); + this.getCode().unregisterBlock(this); + e = this.getThread(); + this._schema && this._schema.event && e.unregisterEvent(this, this._schema.event); + f && (b ? f.destroy(a, b) : g ? f.view && f.view.bindPrev(g) : (g = this.getThread().view.getParent(), g.constructor === Entry.FieldStatement ? (f.view && f.view.bindPrev(g), g.insertTopBlock(f)) : g.constructor === Entry.FieldStatement ? f.replace(g._valueBlock) : f.view._toGlobalCoordinate())); + !this.doNotSplice && e.spliceBlock ? e.spliceBlock(this) : delete this.doNotSplice; + 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(c); + }); }; - a.applyValue = function() { - var b = this.optionGroup.val(); - isNaN(b) || "" === b || (b = this.modValue(b), this.setValue(b), this.updateGraph(), this.textElement.textContent = this.getValue(), this.optionGroup && this.optionGroup.val(b), this.resize()); + b.getView = function() { + return this.view; }; - a.resize = function() { - var b = this.getTextWidth(); - this._header.attr({width:b}); - this.optionGroup && this.optionGroup.css({width:b}); - this.box.set({width:b}); - this._block.view.alignContent(); + b.setMovable = function(a) { + this.movable != a && this.set({movable:a}); }; - a.getTextWidth = function() { - return this.textElement ? this.textElement.getComputedTextLength() + 8 : 8; + b.setCopyable = function(a) { + this.copyable != a && this.set({copyable:a}); }; - a.getText = function() { - return this.getValue() + "\u00b0"; + b.isMovable = function() { + return this.movable; }; - a.modValue = function(b) { - return b % 360; + b.isCopyable = function() { + return this.copyable; }; - 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.setDeletable = function(a) { + this.deletable != a && this.set({deletable:a}); }; -})(Entry.FieldAngle.prototype); -Entry.FieldColor = function(a, b, d) { - this._block = b.block; - this._blockView = b; - this.box = new Entry.BoxModel; - this.svgGroup = null; - this._contents = a; - this._index = d; - this._position = a.position; - this.key = a.key; - this.setValue(this.getValue() || "#FF0000"); - this._CONTENT_HEIGHT = this.getContentHeight(); - this._CONTENT_WIDTH = this.getContentWidth(); - 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 b = this._CONTENT_HEIGHT, a = this._CONTENT_WIDTH, c = this._position, e; - c ? (e = c.x || 0, c = c.y || 0) : (e = 0, c = -b / 2); - this._header = this.svgGroup.elem("rect", {x:e, y:c, width:a, height:b, fill:this.getValue()}); - this._bindRenderOptions(); - this.box.set({x:e, y:c, width:a, height:b}); + b.isDeletable = function() { + return this.deletable === Entry.Block.DELETABLE_TRUE; }; - a.renderOptions = function() { - var b = this; - this._attachDisposeEvent(); - var a = Entry.FieldColor.getWidgetColorList(); - this.optionGroup = Entry.Dom("table", {class:"entry-widget-color-table", parent:$("body")}); - for (var c = 0;c < a.length;c++) { - for (var e = Entry.Dom("tr", {class:"entry-widget-color-row", parent:this.optionGroup}), f = 0;f < a[c].length;f++) { - var g = Entry.Dom("td", {class:"entry-widget-color-cell", parent:e}), h = a[c][f]; - g.css({"background-color":h}); - g.attr({"data-color-value":h}); - (function(a, c) { - a.mousedown(function(b) { - b.stopPropagation(); - }); - a.mouseup(function(a) { - b.applyValue(c); - b.destroyOption(); - b._selectBlockView(); - }); - })(g, h); - } - } - a = this.getAbsolutePosFromDocument(); - a.y += this.box.height / 2 + 1; - this.optionGroup.css({left:a.x, top:a.y}); + b.isReadOnly = function() { + return this.readOnly; }; - a.applyValue = function(b) { - this.value != b && (this.setValue(b), this._header.attr({fill:b})); + b.getCode = function() { + return this.thread.getCode(); }; - a.getContentWidth = function() { - return Entry.isMobile() ? 20 : 14.5; + b.doAdd = function() { + this.getCode().changeEvent.notify(); }; -})(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, d) { - 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 = d; - this.setValue(this.getValue()); - this._CONTENT_HEIGHT = this.getContentHeight(a.dropdownHeight); - this._FONT_SIZE = this.getFontSize(a.fontSize); - 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 b = this._blockView, a = Entry.isMobile(), c = a ? 33 : 20, a = a ? 24 : 10; - this.svgGroup = b.contentSvgGroup.elem("g", {class:"entry-field-dropdown"}); - this.textElement = this.svgGroup.elem("text", {x:5}); - this.textElement.textContent = this.getTextByValue(this.getValue()); - b = this.textElement.getBBox(); - this.textElement.attr({style:"white-space: pre;", "font-size":+this._FONT_SIZE + "px", y:.23 * b.height}); - c = this.textElement.getBoundingClientRect().width + c; - this._noArrow && (c -= a); - a = this._CONTENT_HEIGHT; - this._header = this.svgGroup.elem("rect", {width:c, height:a, y:-a / 2, rx:this._ROUND, ry:this._ROUND, fill:"#fff", "fill-opacity":.4}); - this.svgGroup.appendChild(this.textElement); - this._noArrow || (b = this.getArrow(), this._arrow = this.svgGroup.elem("polygon", {points:b.points, fill:b.color, stroke:b.color, transform:"translate(" + (c - b.width - 5) + "," + -b.height / 2 + ")"})); - this._bindRenderOptions(); - this.box.set({x:0, y:0, width:c, height:a}); + b.doMove = function() { + this._updatePos(); + this.getCode().changeEvent.notify(); }; - a.resize = function() { - var b = Entry.isMobile(), a = b ? 33 : 20, b = b ? 24 : 10, a = this.textElement.getBoundingClientRect().width + a; - this._noArrow ? a -= b : (b = this.getArrow(), this._arrow.attr({transform:"translate(" + (a - b.width - 5) + "," + -b.height / 2 + ")"})); - this._header.attr({width:a}); - this.box.set({width:a}); - this._block.view.alignContent(); + b.doSeparate = function() { + this.separate(); }; - a.renderOptions = function() { - var b = this; - this._attachDisposeEvent(); - this.optionGroup = Entry.Dom("ul", {class:"entry-widget-dropdown", parent:$("body")}); - this.optionGroup.bind("mousedown touchstart", function(b) { - b.stopPropagation(); - }); - for (var a = this._contents.options, a = this._contents.options, c = 0, e = a.length;c < e;c++) { - var f = a[c], 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(a, c) { - a.bind("mousedown touchstart", function(b) { - b.stopPropagation(); - }); - a.bind("mouseup touchend", function(a) { - a.stopPropagation(); - b.applyValue(c); - b.destroyOption(); - b._selectBlockView(); - }); - })(h, f); - } - this._position(); + b.doInsert = function(a) { + "basic" === this.getBlockType() ? this.insert(a) : this.replace(a); }; - a._position = function() { - var b = this.getAbsolutePosFromDocument(); - b.y += this.box.height / 2; - var a = $(document).height(), c = this.optionGroup.height(), e = this.optionGroup.width() + 30; - if (a < b.y + c + 30) { - var a = this._blockView.getBoard().svgDom.height(), f = this.getAbsolutePosFromBoard(); - this._blockView.y < a / 2 ? (b.x += this.box.width / 2 - e / 2, a -= f.y + 30, this.optionGroup.height(a)) : (b.x += this.box.width + 1, a -= a - f.y, a - 30 < c && this.optionGroup.height(a - a % 30), b.y -= this.optionGroup.height()); - } else { - b.x += this.box.width / 2 - e / 2; - } - this.optionGroup.addClass("rendered"); - this.optionGroup.css({left:b.x, top:b.y, width:e}); - this.optionGroup.find(".right").width(e - 20); + b.doDestroy = function(a) { + this.destroy(a); + this.getCode().changeEvent.notify(); + return this; }; - a.applyValue = function(b) { - this.value != b && this.setValue(b); - this.textElement.textContent = this.getTextByValue(b); - this.resize(); + b.doDestroyBelow = function(a) { + console.log("destroyBelow", this.id, this.x, this.y); + this.destroy(a, !0); + this.getCode().changeEvent.notify(); + return this; }; - a.getTextByValue = function(b) { - if (!b || "null" === b) { - return Lang.Blocks.no_target; - } - for (var a = this._contents.options, c = 0, e = a.length;c < e;c++) { - var f = a[c]; - if (f[1] == b) { - return f[0]; + b.copy = function() { + var a = this.getThread(), b = []; + if (a instanceof Entry.Thread) { + for (var c = a.getBlocks().indexOf(this), a = a.toJSON(!0, c), c = 0;c < a.length;c++) { + b.push(a[c]); } + } else { + b.push(this.toJSON(!0)); } - return Lang.Blocks.no_target; - }; - a.getContentHeight = function(b) { - return b = b || this._blockView.getSkeleton().dropdownHeight || (Entry.isMobile() ? 22 : 16); - }; - a.getArrow = function() { - var b = Entry.isMobile(); - return {color:this._arrowColor || this._blockView._schema.color, points:b ? "0,0 19,0 9.5,13" : "0,0 6.4,0 3.2,4.2", height:b ? 13 : 4.2, width:b ? 19 : 6.4}; - }; -})(Entry.FieldDropdown.prototype); -Entry.FieldDropdownDynamic = function(a, b, d) { - this._block = b.block; - this._blockView = b; - this.box = new Entry.BoxModel; - this.svgGroup = null; - this._contents = a; - this._index = d; - this._arrowColor = a.arrowColor; - d = this._contents.menuName; - Entry.Utils.isFunction(d) ? this._menuGenerator = d : this._menuName = d; - this._CONTENT_HEIGHT = this.getContentHeight(a.dropdownHeight); - this._FONT_SIZE = this.getFontSize(a.fontSize); - 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 b = this._block.getCode().object, a = []; - Entry.container && (a = this._menuName ? Entry.container.getDropdownList(this._menuName, b) : this._menuGenerator()); - this._contents.options = a; - b = this.getValue(); - if (this._blockView.isInBlockMenu || !b || "null" == b) { - b = 0 !== a.length ? a[0][1] : null; - } - this.setValue(b); - }; - a.renderOptions = function() { - var b = this; - this._attachDisposeEvent(); - this.optionGroup = Entry.Dom("ul", {class:"entry-widget-dropdown", parent:$("body")}); - this.optionGroup.bind("mousedown touchstart", function(b) { - b.stopPropagation(); - }); - var a; - a = this._menuName ? Entry.container.getDropdownList(this._contents.menuName) : this._menuGenerator(); - this._contents.options = a; - for (var c = 0;c < a.length;c++) { - var e = a[c], 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(a, c) { - a.mousedown(function(b) { - b.stopPropagation(); - }); - a.mouseup(function(a) { - a.stopPropagation(); - b.applyValue(c); - b.destroyOption(); - b._selectBlockView(); - }); - })(g, e); - } - this._position(); + a = this.view.getAbsoluteCoordinate(); + c = b[0]; + c.x = a.x + 15; + c.y = a.y + 15; + c.id = Entry.Utils.generateId(); + return b; }; -})(Entry.FieldDropdownDynamic.prototype); -Entry.FieldImage = function(a, b, d) { - 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 = d; - 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.copyToClipboard = function() { + Entry.clipboard = this.copy(); }; -})(Entry.FieldImage.prototype); -Entry.FieldIndicator = function(a, b, d) { - 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 = d; - 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 b = "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:b, stroke:"none", fill:"none"}); - this.box.set({width:this._size * this._boxMultiplier + (this._position ? -this._size : 0), height:this._size * this._boxMultiplier}); + b.separate = function(a) { + this.thread.separate(this, a); + this._updatePos(); + this.getCode().changeEvent.notify(); }; - a.enableHighlight = function() { - var b = this._path.getTotalLength(), a = this._path; - this._path.attr({stroke:this._highlightColor, strokeWidth:2, "stroke-linecap":"round", "stroke-dasharray":b + " " + b, "stroke-dashoffset":b}); - setInterval(function() { - a.attr({"stroke-dashoffset":b}).animate({"stroke-dashoffset":0}, 300); - }, 1400, mina.easeout); - setTimeout(function() { - setInterval(function() { - a.animate({"stroke-dashoffset":-b}, 300); - }, 1400, mina.easeout); - }, 500); + 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(); }; -})(Entry.FieldIndicator.prototype); -Entry.Keyboard = {}; -Entry.FieldKeyboard = function(a, b, d) { - this._block = b.block; - this._blockView = b; - this.box = new Entry.BoxModel; - this.svgGroup = null; - this.position = a.position; - this._contents = a; - this._index = d; - this.setValue(String(this.getValue())); - this._CONTENT_HEIGHT = this.getContentHeight(); - 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:5, y:4, "font-size":"11px"}); - this.textElement.textContent = Entry.getKeyCodeMap()[this.getValue()]; - var b = this.getTextWidth() + 1, a = this._CONTENT_HEIGHT; - this._header = this.svgGroup.elem("rect", {x:0, y:(this.position && this.position.y ? this.position.y : 0) - a / 2, width:b, height:a, rx:3, ry:3, fill:"#fff", "fill-opacity":.4}); - this.svgGroup.appendChild(this.textElement); - this._bindRenderOptions(); - this.box.set({x:0, y:0, width:b, height:a}); + b.replace = function(a) { + this.thread.cut(this); + a.getThread().replace(this); + this.getCode().changeEvent.notify(); }; - a.renderOptions = function() { - Entry.keyPressed && (this.keyPressed = Entry.keyPressed.attach(this, this._keyboardControl)); - this._optionVisible = !0; - this._attachDisposeEvent(); - var b = this.getAbsolutePosFromDocument(); - b.x -= this.box.width / 2; - b.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:b.x, top:b.y}); + b.getPrevBlock = function() { + return this.thread.getPrevBlock(this); }; - 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.getNextBlock = function() { + return this.thread.getNextBlock(this) || null; }; - a._keyboardControl = function(b) { - b.stopPropagation(); - if (this._optionVisible) { - b = b.keyCode; - var a = Entry.getKeyCodeMap()[b]; - void 0 !== a && this.applyValue(a, b); + b.getLastBlock = function() { + return this.thread.getLastBlock(); + }; + 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.applyValue = function(b, a) { - this.setValue(String(a)); - this.destroyOption(); - this.textElement.textContent = b; - this.resize(); + b.getTerminateOutputBlock = function() { + for (var a = this;;) { + var b = a.getOutputBlock(); + if (!b) { + return a; + } + a = b; + } }; - a.resize = function() { - var b = this.getTextWidth() + 1; - this._header.attr({width:b}); - this.box.set({width:b}); - this._blockView.alignContent(); + 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.getTextWidth = function() { - return this.textElement.getComputedTextLength() + 10; + b.indexOfStatements = function(a) { + return this.statements.indexOf(a); }; - a.destroy = function() { - this.destroyOption(); - Entry.keyPressed && this.keyPressed && Entry.keyPressed.detach(this.keyPressed); + b.pointer = function(a) { + a || (a = []); + return this.thread.pointer(a, this); }; -})(Entry.FieldKeyboard.prototype); -Entry.FieldLineBreak = function(a, b, d) { - this._block = b.block; - this._blockView = b; - this._index = d; - this.box = new Entry.BoxModel; - this.setValue(null); - this.renderStart(); -}; -Entry.Utils.inherit(Entry.Field, Entry.FieldLineBreak); -(function(a) { - a.renderStart = function() { + b.targetPointer = function() { + var a = this.thread.pointer([], this); + 4 === a.length && 0 === a[3] && a.pop(); + return a; + }; + b.getBlockList = function(a, b) { + var c = []; + if (!this._schema) { + return []; + } + if (a && this._schema.isPrimitive) { + return c; + } + (b || this.type) === this.type && c.push(this); + for (var e = this.params, f = 0;f < e.length;f++) { + var g = e[f]; + g && g.constructor == Entry.Block && (c = c.concat(g.getBlockList(a, b))); + } + if (e = this.statements) { + for (f = 0;f < e.length;f++) { + c = c.concat(e[f].getBlockList(a, b)); + } + } + return c; }; - a.align = function(b) { - var a = this._blockView; - 0 !== a._statements.length && this.box.set({y:(a._statements[b].height || 20) + Math.max(a.contentHeight % 1E3, 30)}); + b.stringify = function() { + return JSON.stringify(this.toJSON()); }; -})(Entry.FieldLineBreak.prototype); -Entry.FieldOutput = function(a, b, d, c, e) { +})(Entry.Block.prototype); +Entry.ThreadView = function(b, a) { 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 = d; - 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(), c); + this.thread = b; + this.svgGroup = a.svgThreadGroup.elem("g"); + this.parent = a; }; -Entry.Utils.inherit(Entry.Field, Entry.FieldOutput); -(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 c = this.getValue(); - c && !c.view && (c.setThread(this), c.createView(b, a)); - this._updateValueBlock(c); - this._blockView.getBoard().constructor == Entry.BlockMenu && this._valueBlock && this._valueBlock.view.removeControl(); +(function(b) { + b.schema = {height:0, zIndex:0}; + b.destroy = function() { + this.svgGroup.remove(); }; - a.align = function(b, a, c) { - 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 === c || c ? e.animate({transform:f}, 300, mina.easeinout) : e.attr({transform:f}); - this.box.set({x:b, y:a}); + b.setParent = function(a) { + this.parent = 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:0, height:20}); + b.getParent = function() { + return this.parent; }; - a.calcHeight = a.calcWH; - a.destroy = function() { + b.renderText = function() { + for (var a = this.thread.getBlocks(), b = 0;b < a.length;b++) { + a[b].view.renderText(); + } }; - a._inspectBlock = function() { + b.renderBlock = function() { + for (var a = this.thread.getBlocks(), b = 0;b < a.length;b++) { + a[b].view.renderBlock(); + } }; - a._setValueBlock = function(b) { - if (b != this._valueBlock || !this._valueBlock) { - return this._valueBlock = b, this.setValue(b), b && b.setThread(this), this._valueBlock; + b.requestAbsoluteCoordinate = function(a) { + var b = this.thread.getBlocks(), c = b.shift(), e = {x:0, y:0}; + for (this.parent instanceof Entry.Board || this.parent instanceof Entry.BlockMenu || (e = this.parent.requestAbsoluteCoordinate());c && c.view !== a && c.view;) { + c = c.view, e.x += c.x + c.magnet.next.x, e.y += c.y + c.magnet.next.y, c = b.shift(); } + return e; }; - a._updateValueBlock = function(b) { - b instanceof Entry.Block || (b = void 0); - this._sizeObserver && this._sizeObserver.destroy(); - this._posObserver && this._posObserver.destroy(); - (b = this._setValueBlock(b)) ? (b = b.view, b.bindPrev(), this._posObserver = b.observe(this, "_updateValueBlock", ["x", "y"], !1), this._sizeObserver = b.observe(this, "calcWH", ["width", "height"])) : this.calcWH(); - this._blockView.alignContent(); - b = this._blockView.getBoard(); - b.constructor === Entry.Board && b.generateCodeMagnetMap(); + b.requestPartHeight = function(a, b) { + for (var c = this.thread.getBlocks(), e = c.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 = c.pop(); + } + return f; }; - a.getPrevBlock = function(b) { - return this._valueBlock === b ? this : null; + b.dominate = function() { + this.parent.dominate(this.thread); }; - a.getNextBlock = function() { - return null; + b.isGlobal = function() { + return this.parent instanceof Entry.Board; }; - 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; + b.reDraw = function() { + for (var a = this.thread._data, b = a.length - 1;0 <= b;b--) { + a[b].view.reDraw(); + } }; - a.dominate = function() { - this._blockView.dominate(); + b.setZIndex = function(a) { + this.set({zIndex:a}); }; - a.isGlobal = function() { - return !1; +})(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(b) { + b._generateView = function() { + this.svgGroup = this.board.svg.elem("g"); + this.renderStart(); + this._addControl(); }; - a.separate = function(b) { - this.getCode().createThread([b]); - this.changeEvent.notify(); + 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.getCode = function() { - return this._block.thread.getCode(); + b._addControl = function() { + $(this.svgGroup).bind("mousedown", function(a) { + Entry.Utils.isRightButton(a) && (a.stopPropagation(), $("#entryWorkspaceBoard").css("background", "white")); + }); }; - a.cut = function(b) { - return this._valueBlock === b ? (delete this._valueBlock, [b]) : null; + 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; }; - 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.checkBlock = function() { + var a = this.dragBlock; + if (a && a.block.isDeletable()) { + var b = this.board.offset(), c = this.getPosition(), e = c.x + b.left, b = c.y + b.top, f, g; + if (a = a.dragInstance) { + f = a.offsetX, g = a.offsetY; + } + this.tAnimation(f >= e && g >= b); + } }; - a.replace = function(b) { - var a = this._valueBlock; - a && (a.view._toGlobalCoordinate(), b.getTerminateOutputBlock().view._contents[1].replace(a)); - this._updateValueBlock(b); - b.view._toLocalCoordinate(this.svgGroup); - this.calcWH(); + b.align = function() { + var a = this.getPosition(); + this.svgGroup.attr({transform:"translate(" + a.x + "," + a.y + ")"}); }; - a.setParent = function(b) { - this._parent = b; + b.setPosition = function() { + if (this.board) { + var a = this.board.svgDom; + this._x = a.width() - 110; + this._y = a.height() - 110; + this.align(); + } }; - a.getParent = function() { - return this._parent; + b.getPosition = function() { + return {x:this._x, y:this._y}; }; - a.getThread = function() { - return this; + b.tAnimation = function(a) { + if (a !== this.isOver) { + a = void 0 === a ? !0 : a; + var b, c = this.trashcanTop; + b = a ? {translateX:15, translateY:-25, rotateZ:30} : {translateX:0, translateY:0, rotateZ:0}; + $(c).velocity(b, {duration:50}); + this.isOver = a; + } }; - a.getValueBlock = function() { - return this._valueBlock; + b.setBoard = function(a) { + this._dragBlockObserver && this._dragBlockObserver.destroy(); + this.board = a; + this.svgGroup || this._generateView(); + var b = a.svg, c = b.firstChild; + c ? b.insertBefore(this.svgGroup, c) : 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, a) { + Entry.Vim.MAZE_MODE = 1; + Entry.Vim.WORKSPACE_MODE = 2; + Entry.Vim.TEXT_TYPE_JS = 0; + Entry.Vim.TEXT_TYPE_PY = 1; + Entry.Vim.PARSER_TYPE_JS_TO_BLOCK = 0; + Entry.Vim.PARSER_TYPE_PY_TO_BLOCK = 1; + Entry.Vim.PARSER_TYPE_BLOCK_TO_JS = 2; + Entry.Vim.PARSER_TYPE_BLOCK_TO_PY = 3; + Entry.Vim.PYTHON_IMPORT_ENTRY = "import Entry"; + Entry.Vim.PYTHON_IMPORT_HW = "import Arduino, Hamster, Albert, Bitbrick, Codeino, Dplay \n\t Neobot, Nemoino, Robotis, Sensorboard, Xbot from Hw"; + b = "string" === typeof b ? $("#" + b) : $(b); + if ("DIV" !== b.prop("tagName")) { + return console.error("Dom is not div element"); + } + this.createDom(b); + this._mode = Entry.Vim.WORKSPACE_MODE; + this._parserType = Entry.Vim.PARSER_TYPE_BLOCK_TO_PY; + this._parser = new Entry.Parser(this._mode, this._parserType, this.codeMirror); + 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 c(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, indentWithTabs:!0, styleActiveLine:!0, extraKeys:{"Ctrl-Space":"autocomplete"}, lint:!0, viewportMargin:10}); + this.doc = this.codeMirror.getDoc(); + e = this; + a = this.view[0]; + a.removeEventListener("dragEnd", b); + a.removeEventListener("dragOver", c); + a.addEventListener("dragEnd", b); + a.addEventListener("dragOver", c); }; - a.pointer = function(b) { - b.unshift(this._index); - b.unshift(Entry.PARAM); - return this._block.pointer(b); + b.hide = function() { + this.view.addClass("entryRemove"); }; -})(Entry.FieldOutput.prototype); -Entry.FieldStatement = function(a, b, d) { + b.show = function() { + this.view.removeClass("entryRemove"); + }; + b.textToCode = function(a) { + a === Entry.Vim.TEXT_TYPE_JS ? (this._parserType = Entry.Vim.PARSER_TYPE_JS_TO_BLOCK, this._parser.setParser(this._mode, this._parserType, this.codeMirror)) : a === Entry.Vim.TEXT_TYPE_PY && (this._parserType = Entry.Vim.PARSER_TYPE_PY_TO_BLOCK, this._parser.setParser(this._mode, this._parserType, this.codeMirror)); + a = this.codeMirror.getValue(); + return this._parser.parse(a); + }; + b.codeToText = function(a, b) { + var c; + b && (this._mode = b.runType); + Entry.playground && (c = Entry.playground.object, c = "# " + c.name + " \uc624\ube0c\uc81d\ud2b8\uc758 \ud30c\uc774\uc36c \ucf54\ub4dc"); + var e = b.textType; + e === Entry.Vim.TEXT_TYPE_JS ? (this._parserType = Entry.Vim.PARSER_TYPE_BLOCK_TO_JS, this._parser.setParser(this._mode, this._parserType, this.codeMirror)) : e === Entry.Vim.TEXT_TYPE_PY && (this._parserType = Entry.Vim.PARSER_TYPE_BLOCK_TO_PY, this._parser.setParser(this._mode, this._parserType, this.codeMirror)); + var f = this._parser.parse(a, Entry.Parser.PARSE_GENERAL); + e === Entry.Vim.TEXT_TYPE_PY && (f = c.concat("\n\n").concat(Entry.Vim.PYTHON_IMPORT_ENTRY).concat("\n\n").concat(f)); + this.codeMirror.setValue(f + "\n"); + e == Entry.Vim.TEXT_TYPE_PY && this.codeMirror.getDoc().markText({line:0, ch:0}, {line:4, ch:0}, {readOnly:!0}); + c = this.codeMirror.getDoc(); + c.setCursor({line:c.lastLine() - 1}); + }; + b.getCodeToText = function(a) { + var b = this.workspace.oldTextType; + b === Entry.Vim.TEXT_TYPE_JS ? (this._parserType = Entry.Vim.PARSER_TYPE_BLOCK_TO_JS, this._parser.setParser(this._mode, this._parserType, this.codeMirror)) : b === Entry.Vim.TEXT_TYPE_PY && (this._parserType = Entry.Vim.PARSER_TYPE_BLOCK_TO_PY, this._parser.setParser(this._mode, this._parserType, this.codeMirror)); + return this._parser.parse(a, Entry.Parser.PARSE_SYNTAX); + }; + b.setParserAvailableCode = function(a, b) { + this._parser.setAvailableCode(a, b); + }; +})(Entry.Vim.prototype); +Entry.Workspace = function(b) { Entry.Model(this, !1); - this._blockView = b; - this.block = b.block; - this.view = this; - this._index = d; - 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()); + 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); + this.textType = Entry.Vim.TEXT_TYPE_PY; }; -(function(a) { - a.schema = {x:0, y:0, width:100, height:20, magneting:!1}; - a.magnet = {next:{x:0, y:0}}; - a.renderStart = function(b) { - this.svgGroup = this._blockView.statementSvgGroup.elem("g"); - this._nextGroup = this.statementSvgGroup = this.svgGroup.elem("g"); - this._initThread(b); - this._board = b; - }; - a._initThread = function(b) { - var a = this.getValue(); - this._thread = a; - a.createView(b); - a.view.setParent(this); - if (b = a.getFirstBlock()) { - b.view._toLocalCoordinate(this.statementSvgGroup), this.firstBlock = b; - } - a.changeEvent.attach(this, this.calcHeight); - a.changeEvent.attach(this, this.checkTopBlock); - this.calcHeight(); +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; + }; + b.getSelectedBoard = function() { + return this.selectedBoard; + }; + b.getBlockMenu = function() { + return this.blockMenu; + }; + b.getVimBoard = function() { + return this.vimBoard; + }; + b.getMode = function() { + return this.mode; + }; + b.setMode = function(a, b) { + "number" === typeof a ? this.mode = a : (this.mode = a.boardType, this.runType = a.runType, this.textType = a.textType); + switch(this.mode) { + case this.oldMode: + return; + case Entry.Workspace.MODE_VIMBOARD: + try { + this.board && this.board.hide(), this.overlayBoard && this.overlayBoard.hide(), this.set({selectedBoard:this.vimBoard}), this.vimBoard.show(), this.codeToText(this.board.code, a), this.blockMenu.renderText(function() { + this.blockMenu.reDraw(); + }.bind(this)), this.board.clear(), this.oldTextType = this.textType; + } catch (c) { + } + break; + case Entry.Workspace.MODE_BOARD: + try { + this.board.show(), this.set({selectedBoard:this.board}), this.textToCode(this.oldMode, this.oldTextType), this.vimBoard && this.vimBoard.hide(), this.overlayBoard && this.overlayBoard.hide(), this.blockMenu.renderBlock(function() { + this.blockMenu.reDraw(); + }.bind(this)), this.oldTextType = this.textType; + } catch (c) { + this.board && this.board.hide(), this.set({selectedBoard:this.vimBoard}), this.mode = Entry.Workspace.MODE_VIMBOARD, this.oldTextType == Entry.Vim.PARSER_TYPE_JS_TO_BLOCK ? (a.boardType = Entry.Workspace.MODE_VIMBOARD, a.textType = Entry.Vim.TEXT_TYPE_JS, a.runType = Entry.Vim.MAZE_MODE, this.oldTextType = Entry.Vim.PARSER_TYPE_JS_TO_BLOCK, Entry.dispatchEvent("changeMode", a), Ntry.dispatchEvent("textError", a)) : this.oldTextType == Entry.Vim.PARSER_TYPE_PY_TO_BLOCK && (a.boardType = + Entry.Workspace.MODE_VIMBOARD, a.textType = Entry.Vim.TEXT_TYPE_PY, a.runType = Entry.Vim.WORKSPACE_MODE, this.oldTextType = Entry.Vim.PARSER_TYPE_PY_TO_BLOCK, Entry.dispatchEvent("changeMode", a)); + } + 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.oldMode = this.mode; + this.changeEvent.notify(b); }; - a.align = function(b, a, c) { - c = void 0 === c ? !0 : c; - var e = this.svgGroup; - this._position && (this._position.x && (b = this._position.x), this._position.y && (a = this._position.y)); - var f = "translate(" + b + "," + a + ")"; - this.set({x:b, y:a}); - c ? e.animate({transform:f}, 300, mina.easeinout) : e.attr({transform:f}); + b.changeBoardCode = function(a) { + this._syncTextCode(); + this.board.changeCode(a); + this.mode === Entry.Workspace.MODE_VIMBOARD && this.codeToText(this.board.code); }; - a.calcHeight = function() { - var b = this._thread.view.requestPartHeight(null); - this.set({height:b}); + b.changeOverlayBoardCode = function(a) { + this.overlayBoard && this.overlayBoard.changeCode(a); }; - a.getValue = function() { - return this.block.statements[this._index]; + b.changeBlockMenuCode = function(a) { + this.blockMenu.changeCode(a); }; - a.requestAbsoluteCoordinate = function() { - var b = this._blockView.getAbsoluteCoordinate(); - b.x += this.x; - b.y += this.y; - return b; + b.textToCode = function(a, b) { + if (a == Entry.Workspace.MODE_VIMBOARD) { + var c = this, e = this.vimBoard.textToCode(b), f = this.board, g = f.code; + g.load(e); + g.createView(f); + this.board.reDraw(); + setTimeout(function() { + c.board.alignThreads(); + }, 0); + } }; - a.dominate = function() { - this._blockView.dominate(); + b.codeToText = function(a, b) { + return this.vimBoard.codeToText(a, b); }; - a.destroy = function() { + b.getCodeToText = function(a) { + return this.vimBoard.getCodeToText(a); }; - a._updateBG = function() { - if (this._board.dragBlock && this._board.dragBlock.dragInstance) { - if (this.magneting) { - var b = this._board.dragBlock.getShadow(), a = this.requestAbsoluteCoordinate(), a = "translate(" + a.x + "," + a.y + ")"; - $(b).attr({transform:a, display:"block"}); - this._clonedShadow = b; - this.background && (this.background.remove(), this.nextBackground.remove(), delete this.background, delete this.nextBackground); - b = this._board.dragBlock.getBelowHeight(); - this.statementSvgGroup.attr({transform:"translate(0," + b + ")"}); - this.set({height:this.height + 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), delete this.originalHeight), this.statementSvgGroup.attr({transform:"translate(0,0)"}), this.calcHeight(); - } - (b = this.block.thread.changeEvent) && b.notify(); + 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, c = 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()) : c && (67 == b ? e.block.copyToClipboard() : 88 == b && (a = e.block, a.copyToClipboard(), a.destroy(!0, !0), e.getBoard().setSelectedBlock(null)))); + c && 86 == b && (b = this.selectedBoard) && b instanceof Entry.Board && Entry.clipboard && Entry.do("addThread", Entry.clipboard).value.getFirstBlock().copyToClipboard(); } }; - a.insertTopBlock = function(b) { - this._posObserver && this._posObserver.destroy(); - var a = this.firstBlock; - (this.firstBlock = b) && b.doInsert(this._thread); - return a; + b._handleChangeBoard = function() { + var a = this.selectedBoard; + a && a.constructor === Entry.Board && this.trashcan.setBoard(a); }; - a.getNextBlock = function() { - return this.firstBlock; + b._syncTextCode = function() { + if (this.mode === Entry.Workspace.MODE_VIMBOARD) { + var a = this.vimBoard.textToCode(this.textType), b = this.board, c = b.code; + c.load(a); + c.createView(b); + this.board.alignThreads(); + } }; - a.checkTopBlock = function() { - var b = this._thread.getFirstBlock(); - b && this.firstBlock !== b ? (this.firstBlock = b, b.view.bindPrev(this), b._updatePos()) : b || (this.firstBlock = null); + b.addVimBoard = function(a) { + this.vimBoard || (this.vimBoard = new Entry.Vim(a), this.vimBoard.workspace = this, this.vimBoard.hide()); }; -})(Entry.FieldStatement.prototype); -Entry.FieldText = function(a, b, d) { - this._block = b.block; - this._blockView = b; - this._index = d; - 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.Workspace.prototype); +Entry.Playground = function() { + this.enableArduino = this.isTextBGMode_ = !1; + this.viewMode_ = "default"; + var b = this; + Entry.addEventListener("textEdited", this.injectText); + Entry.addEventListener("hwChanged", this.updateHW); + Entry.addEventListener("changeMode", function(a) { + b.setMode(a); + }); }; -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", "font-family":"nanumBarunRegular", "class":"dragNone", fill:this._color}); - this.textElement.textContent = this._text; - var b = 0, a = this.textElement.getBoundingClientRect(); - "center" == this._align && (b = -a.width / 2); - this.textElement.attr({x:b, y:.25 * a.height}); - this.box.set({x:0, y:0, width:a.width, height:a.height}); - }; -})(Entry.FieldText.prototype); -Entry.FieldTextInput = function(a, b, d) { - this._blockView = b; - this._block = b.block; - this.box = new Entry.BoxModel; - this.svgGroup = null; - this.position = a.position; - this._contents = a; - this._index = d; - this.value = this.getValue() || ""; - this._CONTENT_HEIGHT = this.getContentHeight(); - this.renderStart(); +Entry.Playground.prototype.setMode = function(b) { + this.mainWorkspace.setMode(b); }; -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":"12px"}); - this.textElement.textContent = this.truncate(); - var b = this.getTextWidth(), a = this._CONTENT_HEIGHT; - this._header = this.svgGroup.elem("rect", {width:b, height:a, y:(this.position && this.position.y ? this.position.y : 0) - a / 2, rx:3, ry:3, fill:"transparent"}); - this.svgGroup.appendChild(this.textElement); - this._bindRenderOptions(); - this.box.set({x:0, y:0, width:b, height:a}); - }; - a.renderOptions = function() { - var b = this; - this._attachDisposeEvent(function() { - b.applyValue(); - b.destroyOption(); +Entry.Playground.prototype.generateView = function(b, a) { + this.view_ = b; + this.view_.addClass("entryPlayground"); + if (a && "workspace" != a) { + "phone" == a && (this.view_.addClass("entryPlaygroundPhone"), d = Entry.createElement("div", "entryCategoryTab"), d.addClass("entryPlaygroundTabPhone"), Entry.view_.insertBefore(d, this.view_), this.generateTabView(d), this.tabView_ = d, d = Entry.createElement("div", "entryCurtain"), d.addClass("entryPlaygroundCurtainPhone"), d.addClass("entryRemove"), d.innerHTML = Lang.Workspace.cannot_edit_click_to_stop, d.bindOnClick(function() { + Entry.engine.toggleStop(); + }), this.view_.appendChild(d), this.curtainView_ = d, Entry.pictureEditable && (d = Entry.createElement("div", "entryPicture"), d.addClass("entryPlaygroundPicturePhone"), d.addClass("entryRemove"), this.view_.appendChild(d), this.generatePictureView(d), this.pictureView_ = d), d = Entry.createElement("div", "entryText"), d.addClass("entryRemove"), this.view_.appendChild(d), this.generateTextView(d), this.textView_ = d, Entry.soundEditable && (d = Entry.createElement("div", "entrySound"), d.addClass("entryPlaygroundSoundWorkspacePhone"), + d.addClass("entryRemove"), this.view_.appendChild(d), this.generateSoundView(d), this.soundView_ = d), d = Entry.createElement("div", "entryDefault"), this.view_.appendChild(d), this.generateDefaultView(d), this.defaultView_ = d, d = Entry.createElement("div", "entryCode"), d.addClass("entryPlaygroundCodePhone"), this.view_.appendChild(d), this.generateCodeView(d), this.codeView_ = this.codeView_ = d, 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 d = Entry.createElement("div", "entryCategoryTab"); + d.addClass("entryPlaygroundTabWorkspace"); + this.view_.appendChild(d); + this.generateTabView(d); + this.tabView_ = d; + d = Entry.createElement("div", "entryCurtain"); + d.addClass("entryPlaygroundCurtainWorkspace"); + d.addClass("entryRemove"); + var c = Lang.Workspace.cannot_edit_click_to_stop.split("."); + d.innerHTML = c[0] + ".
" + c[1]; + d.addEventListener("click", function() { + Entry.engine.toggleStop(); }); - this.optionGroup = Entry.Dom("input", {class:"entry-widget-input-field", parent:$("body")}); - this.optionGroup.val(this.getValue()); - this.optionGroup.on("mousedown", function(b) { - b.stopPropagation(); + this.view_.appendChild(d); + this.curtainView_ = d; + Entry.pictureEditable && (d = Entry.createElement("div", "entryPicture"), d.addClass("entryPlaygroundPictureWorkspace"), d.addClass("entryRemove"), this.view_.appendChild(d), this.generatePictureView(d), this.pictureView_ = d); + d = Entry.createElement("div", "entryText"); + d.addClass("entryPlaygroundTextWorkspace"); + d.addClass("entryRemove"); + this.view_.appendChild(d); + this.generateTextView(d); + this.textView_ = d; + Entry.soundEditable && (d = Entry.createElement("div", "entrySound"), d.addClass("entryPlaygroundSoundWorkspace"), d.addClass("entryRemove"), this.view_.appendChild(d), this.generateSoundView(d), this.soundView_ = d); + d = Entry.createElement("div", "entryDefault"); + d.addClass("entryPlaygroundDefaultWorkspace"); + this.view_.appendChild(d); + this.generateDefaultView(d); + this.defaultView_ = d; + d = Entry.createElement("div", "entryCode"); + d.addClass("entryPlaygroundCodeWorkspace"); + d.addClass("entryRemove"); + this.view_.appendChild(d); + this.generateCodeView(d); + this.codeView_ = d; + c = Entry.createElement("div"); + c.addClass("entryPlaygroundResizeWorkspace", "entryRemove"); + this.resizeHandle_ = c; + this.view_.appendChild(c); + this.initializeResizeHandle(c); + this.codeView_ = d; + Entry.addEventListener("run", function(a) { + Entry.playground.curtainView_.removeClass("entryRemove"); }); - this.optionGroup.on("keyup", function(a) { - var d = a.keyCode || a.which; - b.applyValue(a); - -1 < [13, 27].indexOf(d) && b.destroyOption(); + Entry.addEventListener("stop", function(a) { + Entry.playground.curtainView_.addClass("entryRemove"); }); - var a = this.getAbsolutePosFromDocument(); - a.y -= this.box.height / 2; - this.optionGroup.css({height:this._CONTENT_HEIGHT, left:a.x, top:a.y, width:b.box.width}); - this.optionGroup.focus(); - a = this.optionGroup[0]; - a.setSelectionRange(0, a.value.length, "backward"); - }; - a.applyValue = function(b) { - b = this.optionGroup.val(); - this.setValue(b); - this.textElement.textContent = this.truncate(); - this.resize(); - }; - a.resize = function() { - var b = this.getTextWidth(); - this._header.attr({width:b}); - this.optionGroup.css({width:b}); - this.box.set({width:b}); - this._blockView.alignContent(); - }; - a.getTextWidth = function() { - return this.textElement.getBoundingClientRect().width + 6 + 2; - }; -})(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 b = $("body"); - this._container = Entry.Dom("div", {classes:["globalSvgSurface", "entryRemove"], id:"globalSvgSurface", parent:b}); - this.svgDom = Entry.Dom($(''), {parent:this._container}); - this.svg = Entry.SVG("globalSvg"); - this.top = this.left = 0; - this._inited = !0; - } - }; - a.setView = function(b, a) { - if (b != this._view && !b.block.isReadOnly() && b.movable) { - return this._view = b, this._mode = a, a !== Entry.Workspace.MODE_VIMBOARD && b.set({visible:!1}), this.draw(), this.show(), this.align(), this.position(), !0; - } + } +}; +Entry.Playground.prototype.generateDefaultView = function(b) { + return b; +}; +Entry.Playground.prototype.generateTabView = function(b) { + var a = this, d = Entry.createElement("ul"); + d.addClass("entryTabListWorkspace"); + this.tabList_ = d; + b.appendChild(d); + this.tabViewElements = {}; + b = Entry.createElement("li", "entryCodeTab"); + b.innerHTML = Lang.Workspace.tab_code; + b.addClass("entryTabListItemWorkspace"); + b.addClass("entryTabSelected"); + d.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"), d.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"), d.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"), d.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"), d.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 d = Entry.createElement("div", "entryAddPictureInner"); + d.addClass("entryPlaygroundAddPictureInner"); + d.innerHTML = Lang.Workspace.picture_add; + a.appendChild(d); + 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 d = b.item.data("start_pos"), g = b.item.index(); + Entry.playground.movePicture(d, g); + }, axis:"y"}); + b.appendChild(a); + this.pictureListView_ = a; + a = Entry.createElement("div", "entryPainter"); + a.addClass("entryPlaygroundPainter"); + b.appendChild(a); + this.painter = new Entry.Painter2(a); + } else { + "phone" == Entry.type && (a = Entry.createElement("div", "entryAddPicture"), a.addClass("entryPlaygroundAddPicturePhone"), a.bindOnClick(function(a) { + Entry.dispatchEvent("openPictureManager"); + }), d = Entry.createElement("div", "entryAddPictureInner"), d.addClass("entryPlaygroundAddPictureInnerPhone"), d.innerHTML = Lang.Workspace.picture_add, a.appendChild(d), 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 d = b.item.data("start_pos"), g = b.item.index(); + Entry.playground.movePicture(d, 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 d = Entry.createElement("div"); + d.addClass("entryTextFontSelect"); + b.appendChild(d); + var c = Entry.createElement("select", "entryPainterAttrFontName"); + c.addClass("entryPlaygroundPainterAttrFontName", "entryTextFontSelecter"); + c.size = "1"; + c.onchange = function(a) { + Entry.playground.object.entity.setFontType(a.target.value); }; - a.draw = function() { - var b = this._view; - this._svg && this.remove(); - var a = this._mode == Entry.Workspace.MODE_VIMBOARD; - this.svgGroup = Entry.SVG.createElement(b.svgGroup.cloneNode(!0), {opacity:1}); - this.svg.appendChild(this.svgGroup); - a && (b = $(this.svgGroup), b.find("g").css({filter:"none"}), b.find("path").velocity({opacity:0}, {duration:500}), b.find("text").velocity({fill:"#000000"}, {duration:530})); + 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; + c.appendChild(g); + } + this.fontName_ = c; + d.appendChild(c); + e = Entry.createElement("ul"); + e.addClass("entryPlayground_text_buttons"); + b.appendChild(e); + d = Entry.createElement("li"); + d.addClass("entryPlaygroundTextAlignLeft"); + d.bindOnClick(function(a) { + Entry.playground.setFontAlign(Entry.TEXT_ALIGN_LEFT); + }); + e.appendChild(d); + this.alignLeftBtn = d; + d = Entry.createElement("li"); + d.addClass("entryPlaygroundTextAlignCenter"); + d.bindOnClick(function(a) { + Entry.playground.setFontAlign(Entry.TEXT_ALIGN_CENTER); + }); + e.appendChild(d); + this.alignCenterBtn = d; + d = Entry.createElement("li"); + d.addClass("entryPlaygroundTextAlignRight"); + d.bindOnClick(function(a) { + Entry.playground.setFontAlign(Entry.TEXT_ALIGN_RIGHT); + }); + e.appendChild(d); + this.alignRightBtn = d; + d = Entry.createElement("li"); + e.appendChild(d); + c = Entry.createElement("a"); + d.appendChild(c); + c.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"); + c.appendChild(h); + h.src = Entry.mediaFilePath + "text_button_bold_false.png"; + d = Entry.createElement("li"); + e.appendChild(d); + c = Entry.createElement("a"); + d.appendChild(c); + c.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"); + c.appendChild(k); + k.src = Entry.mediaFilePath + "text_button_underline_false.png"; + d = Entry.createElement("li"); + e.appendChild(d); + c = Entry.createElement("a"); + d.appendChild(c); + c.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"); + c.appendChild(l); + l.src = Entry.mediaFilePath + "text_button_italic_false.png"; + d = Entry.createElement("li"); + e.appendChild(d); + c = Entry.createElement("a"); + d.appendChild(c); + c.bindOnClick(function() { + var a = !Entry.playground.object.entity.getStrike() || !1; + Entry.playground.object.entity.setStrike(a); + m.src = Entry.mediaFilePath + "text_button_strike_" + a + ".png"; + }); + var m = Entry.createElement("img", "entryPlaygroundText_strikeImage"); + c.appendChild(m); + m.src = Entry.mediaFilePath + "text_button_strike_false.png"; + c = Entry.createElement("li"); + e.appendChild(c); + d = Entry.createElement("a"); + c.appendChild(d); + d.bindOnClick(function() { + Entry.playground.toggleColourChooser("foreground"); + }); + c = Entry.createElement("img"); + d.appendChild(c); + c.src = Entry.mediaFilePath + "text_button_color_false.png"; + d = Entry.createElement("li"); + e.appendChild(d); + e = Entry.createElement("a"); + d.appendChild(e); + e.bindOnClick(function() { + Entry.playground.toggleColourChooser("background"); + }); + d = Entry.createElement("img"); + e.appendChild(d); + d.src = Entry.mediaFilePath + "text_button_background_false.png"; + e = Entry.createElement("div"); + e.addClass("entryPlayground_fgColorDiv"); + d = Entry.createElement("div"); + d.addClass("entryPlayground_bgColorDiv"); + b.appendChild(e); + b.appendChild(d); + c = Entry.createElement("div"); + c.addClass("entryPlaygroundTextColoursWrapper"); + this.coloursWrapper = c; + a.appendChild(c); + b = Entry.getColourCodes(); + for (e = 0;e < b.length;e++) { + d = Entry.createElement("div"), d.addClass("modal_colour"), d.setAttribute("colour", b[e]), d.style.backgroundColor = b[e], 0 === e && d.addClass("modalColourTrans"), d.bindOnClick(function(a) { + Entry.playground.setTextColour(a.target.getAttribute("colour")); + }), c.appendChild(d); + } + c.style.display = "none"; + c = Entry.createElement("div"); + c.addClass("entryPlaygroundTextBackgroundsWrapper"); + this.backgroundsWrapper = c; + a.appendChild(c); + for (e = 0;e < b.length;e++) { + d = Entry.createElement("div"), d.addClass("modal_colour"), d.setAttribute("colour", b[e]), d.style.backgroundColor = b[e], 0 === e && d.addClass("modalColourTrans"), d.bindOnClick(function(a) { + Entry.playground.setBackgroundColour(a.target.getAttribute("colour")); + }), c.appendChild(d); + } + c.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 b = this._view.getSkeleton().box(this._view).offsetX || 0, a = this._view.getSkeleton().box(this._view).offsetY || 0, b = -1 * b + 1, a = -1 * a + 1; - this._offsetX = b; - this._offsetY = a; - this.svgGroup.attr({transform:"translate(" + b + "," + a + ")"}); + 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 n = Entry.createElement("div"); + n.addClass("entryPlaygroundFontSizeSlider"); + b.appendChild(n); + var q = Entry.createElement("div"); + q.addClass("entryPlaygroundFontSizeIndicator"); + n.appendChild(q); + this.fontSizeIndiciator = q; + var r = Entry.createElement("div"); + r.addClass("entryPlaygroundFontSizeKnob"); + n.appendChild(r); + this.fontSizeKnob = r; + e = Entry.createElement("div"); + e.addClass("entryPlaygroundFontSizeLabel"); + e.innerHTML = "\uae00\uc790 \ud06c\uae30"; + b.appendChild(e); + var t = !1, u = 0; + r.onmousedown = function(a) { + t = !0; + u = $(n).offset().left; }; - a.position = function() { - var b = this._view; - if (b) { - var a = b.getAbsoluteCoordinate(), b = b.getBoard().offset(); - this.left = a.x + b.left - this._offsetX; - this.top = a.y + b.top - this._offsetY; - this.svgDom.css({transform:"translate3d(" + this.left + "px," + this.top + "px, 0px)"}); + r.addEventListener("touchstart", function(a) { + t = !0; + u = $(n).offset().left; + }); + document.addEventListener("mousemove", function(a) { + t && (a = a.pageX - u, 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("touchmove", function(a) { + t && (a = a.touches[0].pageX - u, 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) { + t = !1; + }); + document.addEventListener("touchend", function(a) { + t = !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 d = Entry.createElement("div", "entryAddSoundInner"); + d.addClass("entryPlaygroundAddSoundInner"); + d.innerHTML = Lang.Workspace.sound_add; + a.appendChild(d); + 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 d = b.item.data("start_pos"), g = b.item.index(); + Entry.playground.moveSound(d, 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"); + }), d = Entry.createElement("div", "entryAddSoundInner"), d.addClass("entryPlaygroundAddSoundInnerPhone"), d.innerHTML = Lang.Workspace.sound_add, a.appendChild(d), 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 d = b.item.data("start_pos"), g = b.item.index(); + Entry.playground.moveSound(d, 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(b) { - var a = Entry.mouseCoordinate, c = b.getBoard(), e = c.workspace.blockMenu, f = e.offset().left, g = e.offset().top, h = e.visible ? e.svgDom.width() : 0; - return a.y > c.offset().top - 20 && a.x > f + h ? this.DONE : a.y > g && a.x > f && e.visible ? b.block.isDeletable() ? this.REMOVE : this.RETURN : this.RETURN; - }; - a.addControl = function(a) { - this.onMouseDown.apply(this, arguments); - }; - a.onMouseDown = function(a) { - function d(a) { - var b = a.pageX; - a = a.pageY; - var c = e.left + (b - e._startX), d = e.top + (a - e._startY); - e.svgDom.css({transform:"translate3d(" + c + "px," + d + "px, 0px)"}); - 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 c(a) { - $(document).unbind(".block"); + if (this.object) { + for (var a = this.object.pictures, d = 0, c = a.length;d < c;d++) { + var e = a[d].view; + e || console.log(e); + e.orderHolder.innerHTML = d + 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", d); - f.bind("mouseup.block", c); - f.bind("touchmove.block", d); - f.bind("touchend.block", c); - this._startX = a.pageX; - this._startY = a.pageY; - }; -})(Entry.GlobalSvg); -Entry.Mutator = function() { + } }; -(function(a) { - a.mutate = function(a, d) { - a = Entry.block[a]; - void 0 === a.changeEvent && (a.changeEvent = new Entry.Event); - a.template = d.template; - a.params = d.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 d = Entry.cloneSimpleObject(b); + delete d.id; + delete d.view; + b = JSON.parse(JSON.stringify(d)); + 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), d = $(a); + if (a) { + b.view = a; + a.picture = b; + a = d.find("#t_" + b.id)[0]; + if (b.fileurl) { + a.style.backgroundImage = 'url("' + b.fileurl + '")'; + } else { + var c = b.filename; + a.style.backgroundImage = 'url("' + Entry.defaultPath + "/uploads/" + c.substring(0, 2) + "/" + c.substring(2, 4) + "/thumb/" + c + '.png")'; + } + d.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.downloadPicture = function(b) { + b = Entry.playground.object.getPicture(b); + b.fileurl ? window.open(b.fileurl) : window.open("/api/sprite/download/image/" + encodeURIComponent(b.filename) + "/" + encodeURIComponent(b.name) + ".png"); +}; +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, d = 0, c = a.length;d < c;d++) { + var e = a[d]; + 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 d = 0, c = "LEFT" == this._align ? 20 : this.svgDom.width() / 2, e = 0, f = a.length;e < f;e++) { - var g = a[e].getFirstBlock().view; - g._moveTo(c, d - g.offsetY, !1); - g = g.svgGroup.getBBox().height; - d += g + 15; + if (this.object) { + for (var a = this.object.sounds, d = 0, c = a.length;d < c;d++) { + var e = a[d].view; + e.orderHolder.innerHTML = d + 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 d = Entry.cloneSimpleObject(b); + delete d.view; + delete d.id; + b = JSON.parse(JSON.stringify(d)); + 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 d = this.view_.children; + for (a = 0;a < d.length;a++) { + var c = d[a]; + -1 < c.id.toUpperCase().indexOf(b.toUpperCase()) ? c.removeClass("entryRemove") : c.addClass("entryRemove"); + } + Entry.pictureEditable && ("picture" == b ? (this.painter.show(), this.pictureView_.object && this.pictureView_.object == this.object || (this.pictureView_.object = this.object, this.injectPicture())) : this.painter.hide()); + 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()); }; -(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(), d = 0;d < a.length;d++) { - a[d].view.renderText(); - } - }; - a.renderBlock = function() { - for (var a = this.thread.getBlocks(), d = 0;d < a.length;d++) { - a[d].view.renderBlock(); - } - }; - a.requestAbsoluteCoordinate = function(a) { - var d = this.thread.getBlocks(), c = d.shift(), e = {x:0, y:0}; - for (this.parent instanceof Entry.Board || this.parent instanceof Entry.BlockMenu || (e = this.parent.requestAbsoluteCoordinate());c && c.view !== a && c.view;) { - c = c.view, e.x += c.x + c.magnet.next.x, e.y += c.y + c.magnet.next.y, c = d.shift(); +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())); + } +}; +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).bind("mousedown touchstart", 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).bind("mouseup touchend", 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, d) { - d = this.thread.getBlocks(); - for (var c = d.pop(), e = a ? a.magnet.next ? a.magnet.next.y : a.height : 0;c && c.view !== a && c.view;) { - c = c.view, e = c.magnet.next ? e + c.magnet.next.y : e + c.height, c.dragMode === Entry.DRAG_MODE_DRAG && (e = 0), c = d.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, d = b.length;a < d;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 d = Entry.createElement("li", b.id); + b.view = d; + d.addClass("entryPlaygroundPictureElement"); + d.picture = b; + d.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(d), 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() { + Entry.playground.downloadPicture(b.id); + }}], "workspace-contextmenu"); + }); + var c = Entry.createElement("div"); + c.addClass("entryPlaygroundPictureOrder"); + d.orderHolder = c; + d.appendChild(c); + c = Entry.createElement("div", "t_" + b.id); + c.addClass("entryPlaygroundPictureThumbnail"); + if (b.fileurl) { + c.style.backgroundImage = 'url("' + b.fileurl + '")'; + } else { + var e = b.filename; + c.style.backgroundImage = 'url("' + Entry.defaultPath + "/uploads/" + e.substring(0, 2) + "/" + e.substring(2, 4) + "/thumb/" + e + '.png")'; + } + d.appendChild(c); + 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, d = a.length - 1;0 <= d;d--) { - a[d].view.reDraw(); + d.appendChild(f); + c = Entry.createElement("div", "s_" + b.id); + c.addClass("entryPlaygroundPictureSize"); + c.innerHTML = b.dimension.width + " X " + b.dimension.height; + d.appendChild(c); +}; +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 d = Entry.createElement("div"); + d.addClass("entryPlaygroundSoundOrder"); + a.orderHolder = d; + a.appendChild(d); + var c = Entry.createElement("div"); + c.addClass("entryPlaygroundSoundThumbnail"); + c.addClass("entryPlaygroundSoundPlay"); + var e = !1, f; + c.addEventListener("click", function() { + e ? (e = !1, c.removeClass("entryPlaygroundSoundStop"), c.addClass("entryPlaygroundSoundPlay"), f.stop()) : (e = !0, c.removeClass("entryPlaygroundSoundPlay"), c.addClass("entryPlaygroundSoundStop"), f = createjs.Sound.play(b.id), f.addEventListener("complete", function(a) { + c.removeClass("entryPlaygroundSoundStop"); + c.addClass("entryPlaygroundSoundPlay"); + e = !1; + }), f.addEventListener("loop", function(a) { + }), f.addEventListener("failed", function(a) { + })); + }); + a.appendChild(c); + 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, b) { - Entry.Vim.MAZE_MODE = 1; - Entry.Vim.WORKSPACE_MODE = 2; - Entry.Vim.TEXT_TYPE_JS = 0; - Entry.Vim.TEXT_TYPE_PY = 1; - Entry.Vim.PARSER_TYPE_JS_TO_BLOCK = 0; - Entry.Vim.PARSER_TYPE_PY_TO_BLOCK = 1; - Entry.Vim.PARSER_TYPE_BLOCK_TO_JS = 2; - Entry.Vim.PARSER_TYPE_BLOCK_TO_PY = 3; - Entry.Vim.PYTHON_IMPORT_ENTRY = "import Entry"; - Entry.Vim.PYTHON_IMPORT_HW = "import Arduino, Hamster, Albert, Bitbrick, Codeino, Dplay \n\t Neobot, Nemoino, Robotis, Sensorboard, Xbot from Hw"; - a = "string" === typeof a ? $("#" + a) : $(a); - if ("DIV" !== a.prop("tagName")) { - return console.error("Dom is not div element"); + a.appendChild(g); + d = Entry.createElement("div"); + d.addClass("entryPlaygroundSoundLength"); + d.innerHTML = b.duration + " \ucd08"; + a.appendChild(d); +}; +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._mode = Entry.Vim.WORKSPACE_MODE; - this._parserType = Entry.Vim.PARSER_TYPE_BLOCK_TO_PY; - this._parser = new Entry.Parser(this._mode, this._parserType, this.codeMirror); - Entry.Model(this, !1); - window.eventset = []; }; -(function(a) { - a.createDom = function(a) { - function d(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 c(a) { - e.codeMirror.display.dragFunctions.over(a); +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"); } - 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, indentWithTabs:!0, styleActiveLine:!0, extraKeys:{"Ctrl-Space":"autocomplete"}, lint:!0, viewportMargin:10}); - this.doc = this.codeMirror.getDoc(); - e = this; - a = this.view[0]; - a.removeEventListener("dragEnd", d); - a.removeEventListener("dragOver", c); - a.addEventListener("dragEnd", d); - a.addEventListener("dragOver", c); - }; - a.hide = function() { - this.view.addClass("entryRemove"); - }; - a.show = function() { - this.view.removeClass("entryRemove"); - }; - a.textToCode = function(a) { - a === Entry.Vim.TEXT_TYPE_JS ? (this._parserType = Entry.Vim.PARSER_TYPE_JS_TO_BLOCK, this._parser.setParser(this._mode, this._parserType, this.codeMirror)) : a === Entry.Vim.TEXT_TYPE_PY && (this._parserType = Entry.Vim.PARSER_TYPE_PY_TO_BLOCK, this._parser.setParser(this._mode, this._parserType, this.codeMirror)); - a = this.codeMirror.getValue(); - return this._parser.parse(a); - }; - a.codeToText = function(a, d) { - var c; - d && (this._mode = d.runType); - Entry.playground && (c = Entry.playground.object, c = "# " + c.name + " \uc624\ube0c\uc81d\ud2b8\uc758 \ud30c\uc774\uc36c \ucf54\ub4dc"); - d = d.textType; - d === Entry.Vim.TEXT_TYPE_JS ? (this._parserType = Entry.Vim.PARSER_TYPE_BLOCK_TO_JS, this._parser.setParser(this._mode, this._parserType, this.codeMirror)) : d === Entry.Vim.TEXT_TYPE_PY && (this._parserType = Entry.Vim.PARSER_TYPE_BLOCK_TO_PY, this._parser.setParser(this._mode, this._parserType, this.codeMirror)); - a = this._parser.parse(a, Entry.Parser.PARSE_GENERAL); - d === Entry.Vim.TEXT_TYPE_PY && (a = c.concat("\n\n").concat(Entry.Vim.PYTHON_IMPORT_ENTRY).concat("\n\n").concat(a)); - this.codeMirror.setValue(a + "\n"); - d == Entry.Vim.TEXT_TYPE_PY && this.codeMirror.getDoc().markText({line:0, ch:0}, {line:4, ch:0}, {readOnly:!0}); - a = this.codeMirror.getDoc(); - a.setCursor({line:a.lastLine() - 1}); - }; - a.getCodeToText = function(a) { - var d = this.workspace.oldTextType; - d === Entry.Vim.TEXT_TYPE_JS ? (this._parserType = Entry.Vim.PARSER_TYPE_BLOCK_TO_JS, this._parser.setParser(this._mode, this._parserType, this.codeMirror)) : d === Entry.Vim.TEXT_TYPE_PY && (this._parserType = Entry.Vim.PARSER_TYPE_BLOCK_TO_PY, this._parser.setParser(this._mode, this._parserType, this.codeMirror)); - return this._parser.parse(a, Entry.Parser.PARSE_SYNTAX); - }; - a.setParserAvailableCode = function(a, d) { - this._parser.setAvailableCode(a, d); - }; -})(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 d = b.getElementsByTagName("statement"); +Entry.Xml.getStatementBlock = function(b, a) { + var d = a.getElementsByTagName("statement"); if (!d.length) { - return b; + return a; } for (var c in d) { - if (d[c].getAttribute("name") == a) { + if (d[c].getAttribute("name") == b) { return d[c].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 d = a.childNodes; + if (!d.length) { return null; } - for (var d in b) { - if ("VALUE" == b[d].tagName.toUpperCase() && b[d].getAttribute("name") == a) { - return b[d].children[0]; + for (var c in d) { + if ("VALUE" == d[c].tagName.toUpperCase() && d[c].getAttribute("name") == b) { + return d[c].children[0]; } } return null; }; -Entry.Xml.getNumberValue = function(a, b, d) { +Entry.Xml.getNumberValue = function(b, a, d) { d = d.childNodes; if (!d.length) { return null; } for (var c in d) { - if (d[c].tagName && "VALUE" == d[c].tagName.toUpperCase() && d[c].getAttribute("name") == b) { - return Number(Entry.Xml.operate(a, d[c].children[0])); + if (d[c].tagName && "VALUE" == d[c].tagName.toUpperCase() && d[c].getAttribute("name") == a) { + return Number(Entry.Xml.operate(b, d[c].children[0])); } } return null; }; -Entry.Xml.getField = function(a, b) { - b = b.childNodes; - if (!b.length) { +Entry.Xml.getField = function(b, a) { + var d = a.childNodes; + if (!d.length) { return null; } - for (var d in b) { - if (b[d].tagName && "FIELD" == b[d].tagName.toUpperCase() && b[d].getAttribute("name") == a) { - return b[d].textContent; + for (var c in d) { + if (d[c].tagName && "FIELD" == d[c].tagName.toUpperCase() && d[c].getAttribute("name") == b) { + return d[c].textContent; } } }; -Entry.Xml.getNumberField = function(a, b) { - b = b.childNodes; - if (!b.length) { +Entry.Xml.getNumberField = function(b, a) { + var d = a.childNodes; + if (!d.length) { return null; } - for (var d in b) { - if ("FIELD" == b[d].tagName.toUpperCase() && b[d].getAttribute("name") == a) { - return Number(b[d].textContent); + for (var c in d) { + if ("FIELD" == d[c].tagName.toUpperCase() && d[c].getAttribute("name") == b) { + return Number(d[c].textContent); } } }; -Entry.Xml.getBooleanValue = function(a, b, d) { +Entry.Xml.getBooleanValue = function(b, a, d) { d = d.getElementsByTagName("value"); if (!d.length) { return null; } for (var c in d) { - if (d[c].getAttribute("name") == b) { - return Entry.Xml.operate(a, d[c].children[0]); + if (d[c].getAttribute("name") == a) { + return Entry.Xml.operate(b, d[c].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, d) { - var c = a.cloneNode(); - a.parentNode && "xml" != a.parentNode.tagName && Entry.Xml.cloneBlock(a.parentNode, c, "parent"); - for (var e = 0;e < a.childNodes.length;e++) { - var f = a.childNodes[e]; - f instanceof Text ? c.textContent = f.textContent : "parent" == d ? c.appendChild(b) : c.appendChild(Entry.Xml.cloneBlock(f, c, "child")); +Entry.Xml.cloneBlock = function(b, a, d) { + var c = b.cloneNode(); + b.parentNode && "xml" != b.parentNode.tagName && Entry.Xml.cloneBlock(b.parentNode, c, "parent"); + for (var e = 0;e < b.childNodes.length;e++) { + var f = b.childNodes[e]; + f instanceof Text ? c.textContent = f.textContent : "parent" == d ? c.appendChild(a) : c.appendChild(Entry.Xml.cloneBlock(f, c, "child")); } return c; }; -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 ef1357f08e..5fe2b36467 100644 --- a/dist/entry.min.js +++ b/dist/entry.min.js @@ -1,7 +1,7 @@ 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();Entry.Loader.isLoaded()&&Entry.Loader.handleLoad();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){b=[];a=jQuery.parseXML(a).getElementsByTagName("category");for(var d=0;da?a=325:720c*this.prevDirectionFine&&5<++this.directionFineCount)return!1; -this.prevDirectionFine=c;0-this.MINIMUM_WHEEL_SPEED&&(b=-this.MINIMUM_WHEEL_SPEED));b=parseInt(b);d.leftWheel=-b;d.rightWheel=b;return!0},controlAngle:function(b,a){var d=Entry.hw.sendQueue;b=this.validateRadian(a-b);a=Math.abs(b);if(ac*this.prevDirection)return!1; -this.prevDirection=c;0-this.MINIMUM_WHEEL_SPEED&&(b=-this.MINIMUM_WHEEL_SPEED));b=parseInt(b);d.leftWheel=-b;d.rightWheel=b;return!0},controlPositionFine:function(b,a,d,c,e){var f=Entry.hw.sendQueue;d=this.validateRadian(Math.atan2(e-a,c-b)-d);var g=Math.abs(d);b=c-b;a=e-a;a=Math.sqrt(b*b+a*a);if(ag?(f.leftWheel=this.STRAIGHT_SPEED,f.rightWheel=this.STRAIGHT_SPEED):(a=(this.MINIMUM_WHEEL_SPEED+.5/g)*this.GAIN_BASE_SPEED,a>this.MAX_BASE_SPEED&&(a=this.MAX_BASE_SPEED),d=0this.PI?b-this.PI2:b<-this.PI?b+this.PI2:b},toRadian:function(b){return 3.14159265* -b/180}},name:"albert"};Blockly.Blocks.albert_hand_found={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.ALBERT_hand_found);this.setOutput(!0,"Boolean");this.setInputsInline(!0)}};Entry.block.albert_hand_found=function(b,a){b=Entry.hw.portData;return 40f*this.prevDirectionFine&&5<++this.directionFineCount)return!1; +this.prevDirectionFine=f;f=0;0-this.MINIMUM_WHEEL_SPEED&&(f=-this.MINIMUM_WHEEL_SPEED));f=parseInt(f);d.leftWheel=-f;d.rightWheel=f;return!0},controlAngle:function(b,a){var d=Entry.hw.sendQueue,c=this.validateRadian(a-b),e=Math.abs(c);if(ef*this.prevDirection)return!1; +this.prevDirection=f;f=0;0-this.MINIMUM_WHEEL_SPEED&&(f=-this.MINIMUM_WHEEL_SPEED));f=parseInt(f);d.leftWheel=-f;d.rightWheel=f;return!0},controlPositionFine:function(b,a,d,c,e){var f=Entry.hw.sendQueue;d=this.validateRadian(Math.atan2(e-a,c-b)-d);var g=Math.abs(d);b=c-b;a=e-a;a=Math.sqrt(b*b+a*a);if(ag?(f.leftWheel=this.STRAIGHT_SPEED,f.rightWheel=this.STRAIGHT_SPEED):(a=(this.MINIMUM_WHEEL_SPEED+.5/g)*this.GAIN_BASE_SPEED,a>this.MAX_BASE_SPEED&&(a=this.MAX_BASE_SPEED),e=0,e=0this.PI?b-this.PI2:b<-this.PI?b+this.PI2:b},toRadian:function(b){return 3.14159265* +b/180}},name:"albert"};Blockly.Blocks.albert_hand_found={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.ALBERT_hand_found);this.setOutput(!0,"Boolean");this.setInputsInline(!0)}};Entry.block.albert_hand_found=function(b,a){var d=Entry.hw.portData;return 40a.x||0>a.y){d.leftWheel=20;d.rightWheel=-20;break}a.initialized=!0}d=b.toRadian(a.theta);0==b.controlAngle(d,Math.atan2(a.targetY-a.y,a.targetX-a.x))&&(a.boardState=2);break;case 2:0==b.controlPosition(a.x, -a.y,b.toRadian(a.theta),a.targetX,a.targetY)&&(a.boardState=3);break;case 3:0==b.controlPositionFine(a.x,a.y,b.toRadian(a.theta),a.targetX,a.targetY)&&(d.leftWheel=0,d.rightWheel=0,a.isMoving=!1)}return a}delete a.isStart;delete a.isMoving;delete a.initialized;delete a.boardState;delete a.x;delete a.y;delete a.theta;delete a.targetX;delete a.targetY;Entry.engine.isContinue=!1;d.leftWheel=0;d.rightWheel=0;return a.callReturn()}a.isStart=!0;a.isMoving=!0;a.initialized=!1;a.boardState=1;a.x=-1;a.y=-1; -a.theta=-200;a.targetX=a.getNumberValue("X");a.targetY=a.getNumberValue("Y");b.clear();d.leftWheel=0;d.rightWheel=0;return a}; +Entry.block.albert_move_to_x_y_on_board=function(b,a){var d=Entry.hw.sendQueue,c=Entry.hw.portData,e=Entry.Albert.controller;if(a.isStart){if(a.isMoving){0<=c.positionX&&(a.x=c.positionX);0<=c.positionY&&(a.y=c.positionY);a.theta=c.orientation;switch(a.boardState){case 1:if(0==a.initialized){if(0>a.x||0>a.y){d.leftWheel=20;d.rightWheel=-20;break}a.initialized=!0}d=e.toRadian(a.theta);0==e.controlAngle(d,Math.atan2(a.targetY-a.y,a.targetX-a.x))&&(a.boardState=2);break;case 2:0==e.controlPosition(a.x, +a.y,e.toRadian(a.theta),a.targetX,a.targetY)&&(a.boardState=3);break;case 3:0==e.controlPositionFine(a.x,a.y,e.toRadian(a.theta),a.targetX,a.targetY)&&(d.leftWheel=0,d.rightWheel=0,a.isMoving=!1)}return a}delete a.isStart;delete a.isMoving;delete a.initialized;delete a.boardState;delete a.x;delete a.y;delete a.theta;delete a.targetX;delete a.targetY;Entry.engine.isContinue=!1;d.leftWheel=0;d.rightWheel=0;return a.callReturn()}a.isStart=!0;a.isMoving=!0;a.initialized=!1;a.boardState=1;a.x=-1;a.y=-1; +a.theta=-200;a.targetX=a.getNumberValue("X");a.targetY=a.getNumberValue("Y");e.clear();d.leftWheel=0;d.rightWheel=0;return a}; Blockly.Blocks.albert_set_orientation_on_board={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.ALBERT_set_orientation_to_1);this.appendValueInput("ORIENTATION").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.ALBERT_set_orientation_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_orientation_on_board=function(b,a){b=Entry.hw.sendQueue;var d=Entry.hw.portData,c=Entry.Albert.controller;if(a.isStart){if(a.isMoving){a.theta=d.orientation;switch(a.boardState){case 1:var d=c.toRadian(a.theta),e=c.toRadian(a.targetTheta);0==c.controlAngle(d,e)&&(a.boardState=2);break;case 2:d=c.toRadian(a.theta),e=c.toRadian(a.targetTheta),0==c.controlAngleFine(d,e)&&(b.leftWheel=0,b.rightWheel=0,a.isMoving=!1)}return a}delete a.isStart;delete a.isMoving;delete a.boardState; -delete a.theta;delete a.targetTheta;Entry.engine.isContinue=!1;b.leftWheel=0;b.rightWheel=0;return a.callReturn()}a.isStart=!0;a.isMoving=!0;a.boardState=1;a.theta=-200;a.targetTheta=a.getNumberValue("ORIENTATION");c.clear();b.leftWheel=0;b.rightWheel=0;return a}; +Entry.block.albert_set_orientation_on_board=function(b,a){var d=Entry.hw.sendQueue,c=Entry.hw.portData,e=Entry.Albert.controller;if(a.isStart){if(a.isMoving){a.theta=c.orientation;switch(a.boardState){case 1:var c=e.toRadian(a.theta),f=e.toRadian(a.targetTheta);0==e.controlAngle(c,f)&&(a.boardState=2);break;case 2:c=e.toRadian(a.theta),f=e.toRadian(a.targetTheta),0==e.controlAngleFine(c,f)&&(d.leftWheel=0,d.rightWheel=0,a.isMoving=!1)}return a}delete a.isStart;delete a.isMoving;delete a.boardState; +delete a.theta;delete a.targetTheta;Entry.engine.isContinue=!1;d.leftWheel=0;d.rightWheel=0;return a.callReturn()}a.isStart=!0;a.isMoving=!0;a.boardState=1;a.theta=-200;a.targetTheta=a.getNumberValue("ORIENTATION");e.clear();d.leftWheel=0;d.rightWheel=0;return a}; Blockly.Blocks.albert_set_eye_to={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.ALBERT_set_eye_to_1).appendField(new Blockly.FieldDropdown([[Lang.Blocks.ALBERT_left_eye,"LEFT"],[Lang.Blocks.ALBERT_right_eye,"RIGHT"],[Lang.Blocks.ALBERT_both_eyes,"BOTH"]]),"DIRECTION").appendField(Lang.Blocks.ALBERT_set_eye_to_2).appendField(new Blockly.FieldDropdown([[Lang.General.red,"4"],[Lang.General.yellow,"6"],[Lang.General.green,"2"],[Lang.Blocks.ALBERT_color_cyan, "3"],[Lang.General.blue,"1"],[Lang.Blocks.ALBERT_color_magenta,"5"],[Lang.Blocks.ALBERT_color_white,"7"]]),"COLOR").appendField(Lang.Blocks.ALBERT_set_eye_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_eye_to=function(b,a){b=Entry.hw.sendQueue;var d=a.getField("DIRECTION",a),c=Number(a.getField("COLOR",a));"LEFT"==d?b.leftEye=c:("RIGHT"!=d&&(b.leftEye=c),b.rightEye=c);return a.callReturn()}; +Entry.block.albert_set_eye_to=function(b,a){var d=Entry.hw.sendQueue,c=a.getField("DIRECTION",a),e=Number(a.getField("COLOR",a));"LEFT"==c?d.leftEye=e:("RIGHT"!=c&&(d.leftEye=e),d.rightEye=e);return a.callReturn()}; Blockly.Blocks.albert_clear_eye={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.ALBERT_clear_eye_1).appendField(new Blockly.FieldDropdown([[Lang.Blocks.ALBERT_left_eye,"LEFT"],[Lang.Blocks.ALBERT_right_eye,"RIGHT"],[Lang.Blocks.ALBERT_both_eyes,"BOTH"]]),"DIRECTION").appendField(Lang.Blocks.ALBERT_clear_eye_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_eye=function(b,a){b=Entry.hw.sendQueue;var d=a.getField("DIRECTION",a);"LEFT"==d?b.leftEye=0:("RIGHT"!=d&&(b.leftEye=0),b.rightEye=0);return a.callReturn()}; +Entry.block.albert_clear_eye=function(b,a){var d=Entry.hw.sendQueue,c=a.getField("DIRECTION",a);"LEFT"==c?d.leftEye=0:("RIGHT"!=c&&(d.leftEye=0),d.rightEye=0);return a.callReturn()}; Blockly.Blocks.albert_body_led={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.ALBERT_turn_body_led_1).appendField(new Blockly.FieldDropdown([[Lang.Blocks.ALBERT_turn_on,"ON"],[Lang.Blocks.ALBERT_turn_off,"OFF"]]),"STATE").appendField(Lang.Blocks.ALBERT_turn_body_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_body_led=function(b,a){b=Entry.hw.sendQueue;"ON"==a.getField("STATE",a)?b.bodyLed=1:b.bodyLed=0;return a.callReturn()}; +Entry.block.albert_body_led=function(b,a){var d=Entry.hw.sendQueue;"ON"==a.getField("STATE",a)?d.bodyLed=1:d.bodyLed=0;return a.callReturn()}; Blockly.Blocks.albert_front_led={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.ALBERT_turn_front_led_1).appendField(new Blockly.FieldDropdown([[Lang.Blocks.ALBERT_turn_on,"ON"],[Lang.Blocks.ALBERT_turn_off,"OFF"]]),"STATE").appendField(Lang.Blocks.ALBERT_turn_front_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_front_led=function(b,a){b=Entry.hw.sendQueue;"ON"==a.getField("STATE",a)?b.frontLed=1:b.frontLed=0;return a.callReturn()};Blockly.Blocks.albert_beep={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.ALBERT_beep).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.albert_beep=function(b,a){b=Entry.hw.sendQueue;if(a.isStart){if(1==a.timeFlag)return a;delete a.isStart;delete a.timeFlag;Entry.engine.isContinue=!1;b.buzzer=0;return a.callReturn()}a.isStart=!0;a.timeFlag=1;b.buzzer=440;b.note=0;var d=setTimeout(function(){a.timeFlag=0;Entry.Albert.removeTimeout(d)},200);Entry.Albert.timeouts.push(d);return a}; +Entry.block.albert_front_led=function(b,a){var d=Entry.hw.sendQueue;"ON"==a.getField("STATE",a)?d.frontLed=1:d.frontLed=0;return a.callReturn()};Blockly.Blocks.albert_beep={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.ALBERT_beep).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; +Entry.block.albert_beep=function(b,a){var d=Entry.hw.sendQueue;if(a.isStart){if(1==a.timeFlag)return a;delete a.isStart;delete a.timeFlag;Entry.engine.isContinue=!1;d.buzzer=0;return a.callReturn()}a.isStart=!0;a.timeFlag=1;d.buzzer=440;d.note=0;var c=setTimeout(function(){a.timeFlag=0;Entry.Albert.removeTimeout(c)},200);Entry.Albert.timeouts.push(c);return a}; Blockly.Blocks.albert_change_buzzer_by={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.ALBERT_change_buzzer_by_1);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.ALBERT_change_buzzer_by_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.albert_change_buzzer_by=function(b,a){b=Entry.hw.sendQueue;var d=a.getNumberValue("VALUE");b.buzzer=void 0!=b.buzzer?b.buzzer+d:d;b.note=0;return a.callReturn()}; +Entry.block.albert_change_buzzer_by=function(b,a){var d=Entry.hw.sendQueue,c=a.getNumberValue("VALUE");d.buzzer=void 0!=d.buzzer?d.buzzer+c:c;d.note=0;return a.callReturn()}; Blockly.Blocks.albert_set_buzzer_to={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.ALBERT_set_buzzer_to_1);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.ALBERT_set_buzzer_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_buzzer_to=function(b,a){b=Entry.hw.sendQueue;b.buzzer=a.getNumberValue("VALUE");b.note=0;return a.callReturn()};Blockly.Blocks.albert_clear_buzzer={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.ALBERT_clear_buzzer).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.albert_clear_buzzer=function(b,a){b=Entry.hw.sendQueue;b.buzzer=0;b.note=0;return a.callReturn()}; +Entry.block.albert_set_buzzer_to=function(b,a){var d=Entry.hw.sendQueue;d.buzzer=a.getNumberValue("VALUE");d.note=0;return a.callReturn()};Blockly.Blocks.albert_clear_buzzer={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.ALBERT_clear_buzzer).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; +Entry.block.albert_clear_buzzer=function(b,a){var d=Entry.hw.sendQueue;d.buzzer=0;d.note=0;return a.callReturn()}; Blockly.Blocks.albert_play_note_for={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.ALBERT_play_note_for_1).appendField(new Blockly.FieldDropdown([[Lang.General.note_c+"","4"],[Lang.General.note_c+"#","5"],[Lang.General.note_d+"","6"],[Lang.General.note_e+"b","7"],[Lang.General.note_e+"","8"],[Lang.General.note_f+"","9"],[Lang.General.note_f+"#","10"],[Lang.General.note_g+"","11"],[Lang.General.note_g+"#","12"],[Lang.General.note_a+"","13"],[Lang.General.note_b+ "b","14"],[Lang.General.note_b+"","15"]]),"NOTE").appendField(Lang.Blocks.ALBERT_play_note_for_2).appendField(new Blockly.FieldDropdown([["1","1"],["2","2"],["3","3"],["4","4"],["5","5"],["6","6"],["7","7"]]),"OCTAVE").appendField(Lang.Blocks.ALBERT_play_note_for_3);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.ALBERT_play_note_for_4).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*"));this.setInputsInline(!0); this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.albert_play_note_for=function(b,a){var d=Entry.hw.sendQueue;if(a.isStart){if(1==a.timeFlag)return a;delete a.isStart;delete a.timeFlag;Entry.engine.isContinue=!1;d.note=0;return a.callReturn()}b=a.getNumberField("NOTE",a);var c=a.getNumberField("OCTAVE",a),e=6E4*a.getNumberValue("VALUE",a)/Entry.Albert.tempo;a.isStart=!0;a.timeFlag=1;d.buzzer=0;d.note=b+12*(c-1);if(100Entry.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)}}; @@ -92,24 +93,24 @@ Entry.CODEino.getSensorKey()}):Entry.hw.sendQueue={SET:{0:{type:Entry.CODEino.se 9:{type:Entry.CODEino.sensorTypes.DIGITAL,data:0},10:{type:Entry.CODEino.sensorTypes.DIGITAL,data:0},11:{type:Entry.CODEino.sensorTypes.DIGITAL,data:0},12:{type:Entry.CODEino.sensorTypes.DIGITAL,data:0},13:{type:Entry.CODEino.sensorTypes.DIGITAL,data:0}},TIME:Entry.CODEino.getSensorTime(Entry.CODEino.sensorTypes.DIGITAL),KEY:Entry.CODEino.getSensorKey()};Entry.hw.update()},sensorTypes:{ALIVE:0,DIGITAL:1,ANALOG:2,PWM:3,RGBLED_PIN:4,TONE:5,PULSEIN:6,ULTRASONIC:7,TIMER:8,ADDCOLOR:9},BlockState:{}}; 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(b,a){b=a.getValue("VALUE",a);var d=new XMLHttpRequest;d.open("POST","http://localhost:23518/arduino/",!1);d.send(String(b));Entry.assert(200==d.status,"arduino is not connected");return a.callReturn()}; +Entry.block.arduino_send=function(b,a){var d=a.getValue("VALUE",a),c=new XMLHttpRequest;c.open("POST","http://localhost:23518/arduino/",!1);c.send(String(d));Entry.assert(200==c.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(b,a){b=a.getValue("VALUE",a);a=new XMLHttpRequest;a.open("POST","http://localhost:23518/arduino/",!1);a.send(String(b));Entry.assert(200==a.status,"arduino is not connected");return Number(a.responseText)}; +Entry.block.arduino_get_number=function(b,a){var d=a.getValue("VALUE",a),c=new XMLHttpRequest;c.open("POST","http://localhost:23518/arduino/",!1);c.send(String(d));Entry.assert(200==c.status,"arduino is not connected");return Number(c.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(b,a){b=a.getValue("VALUE",a);a=new XMLHttpRequest;a.open("POST","http://localhost:23518/arduino/",!1);a.send(String(b));Entry.assert(200==a.status,"arduino is not connected");return a.responseText}; +Entry.block.arduino_get_string=function(b,a){var d=a.getValue("VALUE",a),c=new XMLHttpRequest;c.open("POST","http://localhost:23518/arduino/",!1);c.send(String(d));Entry.assert(200==c.status,"arduino is not connected");return c.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(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){b=a.getValue("VALUE",a);return Entry.hw.getAnalogPortValue(b[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){b=a.getNumberValue("VALUE",a);return Entry.hw.getDigitalPortValue(b)}; +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 d=a.getValue("VALUE",a);return Entry.hw.getAnalogPortValue(d[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 d=a.getNumberValue("VALUE",a);return Entry.hw.getDigitalPortValue(d)}; Blockly.Blocks.arduino_toggle_led={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.ARDUINO_num_pin_1);this.appendValueInput("VALUE").setCheck(["Number","String",null]);this.appendDummyInput().appendField(Lang.Blocks.ARDUINO_num_pin_2);this.appendDummyInput().appendField(new Blockly.FieldDropdown([[Lang.Blocks.ARDUINO_on,"on"],[Lang.Blocks.ARDUINO_off,"off"]]),"OPERATOR").appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png","*")); -this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.arduino_toggle_led=function(b,a){b=a.getNumberValue("VALUE");var d=a.getField("OPERATOR");Entry.hw.setDigitalPortValue(b,"on"==d?255:0);return a.callReturn()}; +this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.arduino_toggle_led=function(b,a){var d=a.getNumberValue("VALUE"),c=a.getField("OPERATOR");Entry.hw.setDigitalPortValue(d,"on"==c?255:0);return a.callReturn()}; Blockly.Blocks.arduino_toggle_pwm={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.ARDUINO_toggle_pwm_1);this.appendValueInput("PORT").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.ARDUINO_toggle_pwm_2);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.ARDUINO_toggle_pwm_3);this.appendDummyInput().appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/hardware_03.png", -"*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.arduino_toggle_pwm=function(b,a){b=a.getNumberValue("PORT");var d=a.getNumberValue("VALUE"),d=Math.round(d),d=Math.max(d,0),d=Math.min(d,255);Entry.hw.setDigitalPortValue(b,d);return a.callReturn()}; +"*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.arduino_toggle_pwm=function(b,a){var d=a.getNumberValue("PORT"),c=a.getNumberValue("VALUE"),c=Math.round(c),c=Math.max(c,0),c=Math.min(c,255);Entry.hw.setDigitalPortValue(d,c);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(b,a){var d=a.getNumberValue("VALUE1",a),c=a.getNumberValue("VALUE2",a),e=a.getNumberValue("VALUE3",a);b=a.getNumberValue("VALUE4",a);a=a.getNumberValue("VALUE5",a);if(c>e)var f=c,c=e,e=f;b>a&&(f=b,b=a,a=f);d=(a-b)/(e-c)*(d-c);d+=b;d=Math.min(a,d);d=Math.max(b,d);return Math.round(d)}; +Entry.block.arduino_convert_scale=function(b,a){var d=a.getNumberValue("VALUE1",a),c=a.getNumberValue("VALUE2",a),e=a.getNumberValue("VALUE3",a),f=a.getNumberValue("VALUE4",a),g=a.getNumberValue("VALUE5",a);if(c>e)var h=c,c=e,e=h;f>g&&(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)}; 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(b,a){return Entry.hw.getDigitalPortValue(a.getNumberField("PORT",a))}; @@ -126,52 +127,52 @@ Entry.block.CODEino_get_sound_status=function(b,a){return"GREAT"==a.getField("ST 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(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(b,a){b=a.getNumberField("PORT",a);return 14a?1:0;if("RIGHT"==b||"FRONT"==b)return 30a?1:0}; +Entry.block.CODEino_get_accelerometer_direction=function(b,a){var d=a.getField("DIRECTION",a),c=0;"LEFT"==d||"RIGHT"==d?c=3:"FRONT"==d||"REAR"==d?c=4:"REVERSE"==d&&(c=5);c=Entry.hw.getAnalogPortValue(c);c=180/137*(c-265);c+=-90;c=Math.min(90,c);c=Math.max(-90,c);c=Math.round(c);if("LEFT"==d||"REAR"==d)return-30>c?1:0;if("RIGHT"==d||"FRONT"==d)return 30c?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(b,a){var d=Entry.hw.getAnalogPortValue(a.getField("PORT",a)),c=265,e=402;b=-90;a=90;if(c>e)var f=c,c=e,e=f;b>a&&(f=b,b=a,a=f);d=(a-b)/(e-c)*(d-c);d+=b;d=Math.min(a,d);d=Math.max(b,d);return Math.round(d)}; +Entry.block.CODEino_get_accelerometer_value=function(b,a){var d=265,c=402,e=-90,f=90,g=Entry.hw.getAnalogPortValue(a.getField("PORT",a));if(d>c)var h=d,d=c,c=h;e>f&&(h=e,e=f,f=h);g=(f-e)/(c-d)*(g-d);g+=e;g=Math.min(f,g);g=Math.max(e,g);return Math.round(g)}; Blockly.Blocks.dplay_select_led={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.ARDUINO_num_pin_1);this.appendDummyInput().appendField(new Blockly.FieldDropdown([["7","7"],["8","8"],["9","9"],["10","10"]]),"PORT");this.appendDummyInput().appendField(Lang.Blocks.dplay_num_pin_1);this.appendDummyInput().appendField(new Blockly.FieldDropdown([[Lang.Blocks.ARDUINO_on,"on"],[Lang.Blocks.ARDUINO_off,"off"]]),"OPERATOR").appendField(new Blockly.FieldIcon(Entry.mediaFilePath+ -"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.dplay_select_led=function(b,a){var d=a.getField("PORT");b=7;"7"==d?b=7:"8"==d?b=8:"9"==d?b=9:"10"==d&&(b=10);d=a.getField("OPERATOR");Entry.hw.setDigitalPortValue(b,"on"==d?255:0);return a.callReturn()}; +"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.dplay_select_led=function(b,a){var d=a.getField("PORT"),c=7;"7"==d?c=7:"8"==d?c=8:"9"==d?c=9:"10"==d&&(c=10);d=a.getField("OPERATOR");Entry.hw.setDigitalPortValue(c,"on"==d?255:0);return a.callReturn()}; Blockly.Blocks.dplay_get_switch_status={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("\ub514\uc9c0\ud138 ");this.appendDummyInput().appendField(new Blockly.FieldDropdown([["2","2"],["4","4"]]),"PORT");this.appendDummyInput().appendField(Lang.Blocks.dplay_num_pin_2).appendField(new Blockly.FieldDropdown([[Lang.Blocks.dplay_string_5,"ON"],[Lang.Blocks.dplay_string_6,"OFF"]]),"STATUS").appendField(" ");this.setInputsInline(!0);this.setOutput(!0,"Boolean")}}; -Entry.block.dplay_get_switch_status=function(b,a){b=a.getField("PORT");var d=2;"2"==b?d=2:"4"==b&&(d=4);return"OFF"==a.getField("STATUS")?1==Entry.hw.getDigitalPortValue(d)?1:0:0==Entry.hw.getDigitalPortValue(d)?1:0}; +Entry.block.dplay_get_switch_status=function(b,a){var d=a.getField("PORT"),c=2;"2"==d?c=2:"4"==d&&(c=4);return"OFF"==a.getField("STATUS")?1==Entry.hw.getDigitalPortValue(c)?1:0:0==Entry.hw.getDigitalPortValue(c)?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(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(b,a){b=a.getValue("VALUE",a);return Entry.hw.getAnalogPortValue(b[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 d=a.getValue("VALUE",a);return Entry.hw.getAnalogPortValue(d[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(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(b,a){b=a.getField("PORT");var d=0;"3"==b?d=5:"6"==b&&(d=11);var c=a.getField("OPERATOR"),e=0,f=0;"FRONT"==c?(e=255,f=0):"REAR"==c?(e=0,f=255):"OFF"==c&&(f=e=0);Entry.hw.setDigitalPortValue(b,e);Entry.hw.setDigitalPortValue(d,f);return a.callReturn()}; +"*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.dplay_DCmotor=function(b,a){var d=a.getField("PORT"),c=0;"3"==d?c=5:"6"==d&&(c=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(d,f);Entry.hw.setDigitalPortValue(c,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(b,a){var d=a.getField("PORT");b=2;"1"==d?b=2:"2"==d?b=4:"3"==d&&(b=7);d=a.getNumberValue("VALUE");d=Math.round(d);d=Math.max(d,0);d=Math.min(d,100);Entry.hw.setDigitalPortValue(b,d);return a.callReturn()}; +"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.dplay_buzzer=function(b,a){var d=a.getField("PORT"),c=2;"1"==d?c=2:"2"==d?c=4:"3"==d&&(c=7);d=a.getNumberValue("VALUE");d=Math.round(d);d=Math.max(d,0);d=Math.min(d,100);Entry.hw.setDigitalPortValue(c,d);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(b,a){b=a.getNumberValue("VALUE");b=Math.round(b);b=Math.max(b,0);b=Math.min(b,180);Entry.hw.setDigitalPortValue(9,b);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,d=1;5>d;d++){var c=a[d];c&&(c.value||0===c.value)&&b.push([d+" - "+Lang.Blocks["BITBRICK_"+c.type],d.toString()])}return 0==b.length?[[Lang.Blocks.no_target,"null"]]:b},touchList:function(){for(var b=[],a=Entry.hw.portData,d=1;5>d;d++){var c=a[d]; +Entry.block.dplay_servo=function(b,a){var d=a.getNumberValue("VALUE"),d=Math.round(d),d=Math.max(d,0),d=Math.min(d,180);Entry.hw.setDigitalPortValue(9,d);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,d=1;5>d;d++){var c=a[d];c&&(c.value||0===c.value)&&b.push([d+" - "+Lang.Blocks["BITBRICK_"+c.type],d.toString()])}return 0==b.length?[[Lang.Blocks.no_target,"null"]]:b},touchList:function(){for(var b=[],a=Entry.hw.portData,d=1;5>d;d++){var c=a[d]; c&&"touch"===c.type&&b.push([d.toString(),d.toString()])}return 0==b.length?[[Lang.Blocks.no_target,"null"]]:b},servoList:function(){for(var b=[],a=Entry.hw.portData,d=5;9>d;d++){var c=a[d];c&&"SERVO"===c.type&&b.push(["ABCD"[d-5],d.toString()])}return 0==b.length?[[Lang.Blocks.no_target,"null"]]:b},dcList:function(){for(var b=[],a=Entry.hw.portData,d=5;9>d;d++){var c=a[d];c&&"DC"===c.type&&b.push(["ABCD"[d-5],d.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(b,a){b=a.getStringField("PORT");return Entry.hw.portData[b].value}; +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 d=a.getStringField("PORT");return Entry.hw.portData[d].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(b,a){b=a.getNumberValue("rValue");var d=a.getNumberValue("gValue"),c=a.getNumberValue("bValue"),e=Entry.adjustValueWithMaxMin,f=Entry.hw.sendQueue;f.LEDR=e(b,0,255);f.LEDG=e(d,0,255);f.LEDB=e(c,0,255);return a.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 d=a.getNumberValue("rValue"),c=a.getNumberValue("gValue"),e=a.getNumberValue("bValue"),f=Entry.adjustValueWithMaxMin,g=Entry.hw.sendQueue;g.LEDR=f(d,0,255);g.LEDG=f(c,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(b,a){b=a.getStringField("VALUE");Entry.hw.sendQueue.LEDR=parseInt(b.substr(1,2),16);Entry.hw.sendQueue.LEDG=parseInt(b.substr(3,2),16);Entry.hw.sendQueue.LEDB=parseInt(b.substr(5,2),16);return a.callReturn()}; +Entry.block.bitbrick_turn_on_color_led_by_picker=function(b,a){var d=a.getStringField("VALUE");Entry.hw.sendQueue.LEDR=parseInt(d.substr(1,2),16);Entry.hw.sendQueue.LEDG=parseInt(d.substr(3,2),16);Entry.hw.sendQueue.LEDB=parseInt(d.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(b,a){b=a.getNumberValue("VALUE");var d,c,e;b%=200;67>b?(d=200-3*b,c=3*b,e=0):134>b?(b-=67,d=0,c=200-3*b,e=3*b):201>b&&(b-=134,d=3*b,c=0,e=200-3*b);Entry.hw.sendQueue.LEDR=d;Entry.hw.sendQueue.LEDG=c;Entry.hw.sendQueue.LEDB=e;return a.callReturn()}; +Entry.block.bitbrick_turn_on_color_led_by_value=function(b,a){var d=a.getNumberValue("VALUE"),c,e,f,d=d%200;67>d?(c=200-3*d,e=3*d,f=0):134>d?(d-=67,c=0,e=200-3*d,f=3*d):201>d&&(d-=134,c=3*d,e=0,f=200-3*d);Entry.hw.sendQueue.LEDR=c;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(b,a){if(a.isStart)return Entry.hw.sendQueue.buzzer=0,delete a.isStart,a.callReturn();b=a.getNumberValue("VALUE");Entry.hw.sendQueue.buzzer=b;a.isStart=!0;return a}; +Entry.block.bitbrick_buzzer=function(b,a){if(a.isStart)return Entry.hw.sendQueue.buzzer=0,delete a.isStart,a.callReturn();var d=a.getNumberValue("VALUE");Entry.hw.sendQueue.buzzer=d;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(b,a){var d=Entry.hw.sendQueue;b=Entry.Bitbrick;b.servoList().map(function(a){d[a[1]]=0});b.dcList().map(function(a){d[a[1]]=128});return a.callReturn()}; +Entry.block.bitbrick_turn_off_all_motors=function(b,a){var d=Entry.hw.sendQueue,c=Entry.Bitbrick;c.servoList().map(function(a){d[a[1]]=0});c.dcList().map(function(a){d[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(b,a){b=a.getNumberValue("VALUE");b=Math.min(b,Entry.Bitbrick.dcMaxValue);b=Math.max(b,Entry.Bitbrick.dcMinValue);Entry.hw.sendQueue[a.getStringField("PORT")]=b+128;return a.callReturn()}; +Entry.block.bitbrick_dc_speed=function(b,a){var d=a.getNumberValue("VALUE"),d=Math.min(d,Entry.Bitbrick.dcMaxValue),d=Math.max(d,Entry.Bitbrick.dcMinValue);Entry.hw.sendQueue[a.getStringField("PORT")]=d+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(b,a){b="CW"===a.getStringField("DIRECTION");var d=a.getNumberValue("VALUE"),d=Math.min(d,Entry.Bitbrick.dcMaxValue),d=Math.max(d,0);Entry.hw.sendQueue[a.getStringField("PORT")]=b?d+128:128-d;return a.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 d="CW"===a.getStringField("DIRECTION"),c=a.getNumberValue("VALUE"),c=Math.min(c,Entry.Bitbrick.dcMaxValue),c=Math.max(c,0);Entry.hw.sendQueue[a.getStringField("PORT")]=d?c+128:128-c;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(b,a){b=a.getNumberValue("VALUE")+1;b=Math.min(b,Entry.Bitbrick.servoMaxValue);b=Math.max(b,Entry.Bitbrick.servoMinValue);Entry.hw.sendQueue[a.getStringField("PORT")]=b;return a.callReturn()}; +this.setInputsInline(!0)}};Entry.block.bitbrick_servomotor_angle=function(b,a){var d=a.getNumberValue("VALUE")+1,d=Math.min(d,Entry.Bitbrick.servoMaxValue),d=Math.max(d,Entry.Bitbrick.servoMinValue);Entry.hw.sendQueue[a.getStringField("PORT")]=d;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(b,a){b=a.getNumberField("PORT");var d=Entry.hw.portData[b].value,c=a.getNumberValue("VALUE2",a),e=a.getNumberValue("VALUE3",a);b=a.getNumberValue("VALUE4",a);a=a.getNumberValue("VALUE5",a);if(b>a){var f=b;b=a;a=f}d=(a-b)/(e-c)*(d-c);d+=b;d=Math.min(a,d);d=Math.max(b,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()}; +Entry.block.bitbrick_convert_scale=function(b,a){var d=a.getNumberField("PORT"),c=Entry.hw.portData[d].value,d=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;c-=d;c*=(g-f)/(e-d);c+=f;c=Math.min(g,c);c=Math.max(f,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(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(b,a){var d=a.getField("VALUE",a);b.brush||(Entry.setBasicBrush(b),b.brush.stop=!0);b.brush&&(d=Entry.hex2rgb(d),b.brush.rgb=d,b.brush.endStroke(),b.brush.beginStroke("rgba("+d.r+","+d.g+","+d.b+","+b.brush.opacity/100+")"),b.brush.moveTo(b.getX(),-1*b.getY()));return a.callReturn()}; @@ -186,7 +187,7 @@ Entry.block.change_opacity=function(b,a){var d=a.getNumberValue("VALUE",a);b.bru 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(b,a){var d=a.getNumberValue("VALUE",a);b.brush||(Entry.setBasicBrush(b),b.brush.stop=!0);b.brush&&(b.brush.opacity=Entry.adjustValueWithMaxMin(d,0,100),b.brush.endStroke(),d=b.brush.rgb,b.brush.beginStroke("rgba("+d.r+","+d.g+","+d.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(b,a){var d=b.brush;if(d){var c=d._stroke.style,e=d._strokeStyle.width;d.clear().setStrokeStyle(e).beginStroke(c);d.moveTo(b.getX(),-1*b.getY())}b=b.parent.getStampEntities();b.map(function(a){a.removeClone()});b=null;return a.callReturn()}; +Entry.block.brush_erase_all=function(b,a){var d=b.brush;if(d){var c=d._stroke.style,e=d._strokeStyle.width;d.clear().setStrokeStyle(e).beginStroke(c);d.moveTo(b.getX(),-1*b.getY())}d=b.parent.getStampEntities();d.map(function(a){a.removeClone()});d=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(b,a){var d=a.getNumberValue("VALUE",a);b.brush||(Entry.setBasicBrush(b),b.brush.stop=!0);d=Entry.adjustValueWithMaxMin(b.brush.opacity-d,0,100);b.brush&&(b.brush.opacity=d,b.brush.endStroke(),d=b.brush.rgb,b.brush.beginStroke("rgba("+d.r+","+d.g+","+d.b+","+b.brush.opacity/100+")"),b.brush.moveTo(b.getX(),-1*b.getY()));return a.callReturn()}; @@ -198,57 +199,57 @@ Blockly.Blocks.get_angle={init:function(){this.setColour(calcBlockColor);this.ap 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(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(b,a){a=a.getField("VALUE",a);if("mouse"==a)return a=Entry.stage.mouseCoordinate,Math.sqrt(Math.pow(b.getX()-a.x,2)+Math.pow(b.getY()-a.y,2));a=Entry.container.getEntity(a);return Math.sqrt(Math.pow(b.getX()-a.getX(),2)+Math.pow(b.getY()-a.getY(),2))}; +Entry.block.distance_something=function(b,a){var d=a.getField("VALUE",a);if("mouse"==d)return d=Entry.stage.mouseCoordinate,Math.sqrt(Math.pow(b.getX()-d.x,2)+Math.pow(b.getY()-d.y,2));d=Entry.container.getEntity(d);return Math.sqrt(Math.pow(b.getX()-d.getX(),2)+Math.pow(b.getY()-d.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)?Number(Entry.stage.mouseCoordinate.x):Number(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(b,a){var d=a.getField("VALUE",a);b="self"==d?b:Entry.container.getEntity(d);switch(a.getField("COORDINATE",a)){case "x":return b.getX();case "y":return b.getY();case "rotation":return b.getRotation();case "direction":return b.getDirection();case "picture_index":return a=b.parent,a=a.pictures,a.indexOf(b.picture)+1;case "size":return Number(b.getSize().toFixed(1));case "picture_name":return a=b.parent,a=a.pictures,a[a.indexOf(b.picture)].name}}; +Entry.block.coordinate_object=function(b,a){var d=a.getField("VALUE",a),d="self"==d?b:Entry.container.getEntity(d);switch(a.getField("COORDINATE",a)){case "x":return d.getX();case "y":return d.getY();case "rotation":return d.getRotation();case "direction":return d.getDirection();case "picture_index":var c=d.parent,c=c.pictures;return c.indexOf(d.picture)+1;case "size":return Number(d.getSize().toFixed(1));case "picture_name":return c=d.parent,c=c.pictures,c[c.indexOf(d.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(b,a){b=a.getField("OPERATOR",a);var d=a.getNumberValue("LEFTHAND",a);a=a.getNumberValue("RIGHTHAND",a);return"PLUS"==b?d+a:"MINUS"==b?d-a:"MULTI"==b?d*a:d/a};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){b=a.getNumberValue("LEFTHAND",a);a=a.getNumberValue("RIGHTHAND",a);return b+a};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){b=a.getNumberValue("LEFTHAND",a);a=a.getNumberValue("RIGHTHAND",a);return b-a};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){b=a.getNumberValue("LEFTHAND",a);a=a.getNumberValue("RIGHTHAND",a);return b*a};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){b=a.getNumberValue("LEFTHAND",a);a=a.getNumberValue("RIGHTHAND",a);return b/a}; +Entry.block.calc_basic=function(b,a){var d=a.getField("OPERATOR",a),c=a.getNumberValue("LEFTHAND",a),e=a.getNumberValue("RIGHTHAND",a);return"PLUS"==d?c+e:"MINUS"==d?c-e:"MULTI"==d?c*e:c/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 d=a.getNumberValue("LEFTHAND",a),c=a.getNumberValue("RIGHTHAND",a);return d+c};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 d=a.getNumberValue("LEFTHAND",a),c=a.getNumberValue("RIGHTHAND",a);return d-c};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 d=a.getNumberValue("LEFTHAND",a),c=a.getNumberValue("RIGHTHAND",a);return d*c};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 d=a.getNumberValue("LEFTHAND",a),c=a.getNumberValue("RIGHTHAND",a);return d/c}; 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(b,a){b=a.getNumberValue("LEFTHAND",a);a=a.getNumberValue("RIGHTHAND",a);return b%a}; +Entry.block.calc_mod=function(b,a){var d=a.getNumberValue("LEFTHAND",a),c=a.getNumberValue("RIGHTHAND",a);return d%c}; 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(b,a){b=a.getNumberValue("LEFTHAND",a);a=a.getNumberValue("RIGHTHAND",a);return Math.floor(b/a)}; +Entry.block.calc_share=function(b,a){var d=a.getNumberValue("LEFTHAND",a),c=a.getNumberValue("RIGHTHAND",a);return Math.floor(d/c)}; 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(b,a){b=a.getNumberValue("LEFTHAND",a);a=a.getField("VALUE",a);if(-1<["asin_radian","acos_radian"].indexOf(a)&&(1b))throw Error("x range exceeded");a.indexOf("_")&&(a=a.split("_")[0]);-1<["sin","cos","tan"].indexOf(a)&&(b=Entry.toRadian(b));switch(a){case "square":a=b*b;break;case "factorial":a=Entry.factorial(b);break;case "root":a=Math.sqrt(b);break;case "log":a=Math.log(b)/Math.LN10;break;case "ln":a=Math.log(b);break;case "asin":case "acos":case "atan":a= -Entry.toDegrees(Math[a](b));break;case "unnatural":a=b-Math.floor(b);0>b&&(a=1-a);break;default:a=Math[a](b)}return Math.round(1E3*a)/1E3}; +Entry.block.calc_operation=function(b,a){var d=a.getNumberValue("LEFTHAND",a),c=a.getField("VALUE",a);if(-1<["asin_radian","acos_radian"].indexOf(c)&&(1d))throw Error("x range exceeded");c.indexOf("_")&&(c=c.split("_")[0]);-1<["sin","cos","tan"].indexOf(c)&&(d=Entry.toRadian(d));var e=0;switch(c){case "square":e=d*d;break;case "factorial":e=Entry.factorial(d);break;case "root":e=Math.sqrt(d);break;case "log":e=Math.log(d)/Math.LN10;break;case "ln":e=Math.log(d);break;case "asin":case "acos":case "atan":e= +Entry.toDegrees(Math[c](d));break;case "unnatural":e=d-Math.floor(d);0>d&&(e=1-e);break;default:e=Math[c](d)}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(b,a){b=a.getStringValue("LEFTHAND",a);a=a.getStringValue("RIGHTHAND",a);var d=Math.min(b,a),c=Math.max(b,a);b=Entry.isFloat(b);return Entry.isFloat(a)||b?(Math.random()*(c-d)+d).toFixed(2):Math.floor(Math.random()*(c-d+1)+d)}; +Entry.block.calc_rand=function(b,a){var d=a.getStringValue("LEFTHAND",a),c=a.getStringValue("RIGHTHAND",a),e=Math.min(d,c),f=Math.max(d,c),d=Entry.isFloat(d);return Entry.isFloat(c)||d?(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(b,a){b=a.getField("VALUE",a);a=new Date;return"YEAR"==b?a.getFullYear():"MONTH"==b?a.getMonth()+1:"DAY"==b?a.getDate():"HOUR"==b?a.getHours():"MINUTE"==b?a.getMinutes():a.getSeconds()}; +calcFontColor);this.setOutput(!0,"Number");this.setInputsInline(!0)}};Entry.block.get_date=function(b,a){var d=a.getField("VALUE",a),c=new Date;return"YEAR"==d?c.getFullYear():"MONTH"==d?c.getMonth()+1:"DAY"==d?c.getDate():"HOUR"==d?c.getHours():"MINUTE"==d?c.getMinutes():c.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(b,a){a=a.getField("VALUE",a);b=b.parent.sounds;for(var d=0;da||a>b.length-1)throw Error();return b[a]}; +Entry.block.char_at=function(b,a){var d=a.getStringValue("LEFTHAND",a),c=a.getNumberValue("RIGHTHAND",a)-1;if(0>c||c>d.length-1)throw Error();return d[c]}; 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(b,a){b=a.getStringValue("STRING",a);var d=a.getNumberValue("START",a)-1;a=a.getNumberValue("END",a)-1;var c=b.length-1;if(0>d||0>a||d>c||a>c)throw Error();return b.substring(Math.min(d,a),Math.max(d,a)+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 d=a.getStringValue("STRING",a),c=a.getNumberValue("START",a)-1,e=a.getNumberValue("END",a)-1,f=d.length-1;if(0>c||0>e||c>f||e>f)throw Error();return d.substring(Math.min(c,e),Math.max(c,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(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(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(b,a){b=a.getStringValue("LEFTHAND",a);a=a.getStringValue("RIGHTHAND",a);a=b.indexOf(a);return-1b;b++)Entry.hw.sendQueue[b]=0;Entry.hw.update()}};Blockly.Blocks.cobl_read_ultrason={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("\ucd08\uc74c\ud30c \uac70\ub9ac\uc7ac\uae30(0~400)");this.setInputsInline(!0);this.setOutput(!0,"Number")}};Entry.block.cobl_read_ultrason=function(b,a){return Entry.hw.getAnalogPortValue("ultrason")}; +Entry.block.choose_project_timer_action=function(b,a){var d=a.getField("ACTION"),c=Entry.engine,e=c.projectTimer;"START"==d?e.isInit?e.isInit&&e.isPaused&&(e.pauseStart&&(e.pausedTime+=(new Date).getTime()-e.pauseStart),delete e.pauseStart,e.isPaused=!1):c.startProjectTimer():"STOP"==d?e.isInit&&!e.isPaused&&(e.isPaused=!0,e.pauseStart=(new Date).getTime()):"RESET"==d&&e.isInit&&(e.setValue(0),e.start=(new Date).getTime(),e.pausedTime=0,delete e.pauseStart);return a.callReturn()};Entry.Cobl={name:"cobl",setZero:function(){for(var b=0;14>b;b++)Entry.hw.sendQueue[b]=0;Entry.hw.update()}};Blockly.Blocks.cobl_read_ultrason={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("\ucd08\uc74c\ud30c \uac70\ub9ac\uc7ac\uae30(0~400)");this.setInputsInline(!0);this.setOutput(!0,"Number")}};Entry.block.cobl_read_ultrason=function(b,a){return Entry.hw.getAnalogPortValue("ultrason")}; Blockly.Blocks.cobl_read_potenmeter={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("\uac00\ubcc0\uc800\ud56d \uc77d\uae30(0~1023)");this.setInputsInline(!0);this.setOutput(!0,"Number")}};Entry.block.cobl_read_potenmeter=function(b,a){console.log("cobl_read_potenmeter");return Entry.hw.getAnalogPortValue("potenmeter")}; Blockly.Blocks.cobl_read_irread1={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("IR1 \uc77d\uae30(0~1023)");this.setInputsInline(!0);this.setOutput(!0,"Number")}};Entry.block.cobl_read_irread1=function(b,a){return Entry.hw.getAnalogPortValue("potenmeter")};Blockly.Blocks.cobl_read_irread2={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("IR2 \uc77d\uae30(0~1023)");this.setInputsInline(!0);this.setOutput(!0,"Number")}}; Entry.block.cobl_read_irread2=function(b,a){a.getValue("irread2",a);return Entry.hw.getAnalogPortValue("irread2")};Blockly.Blocks.cobl_read_joyx={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("\uc870\uc774\uc2a4\ud2f1X\ucd95 \uc77d\uae30(1,0,-1)");this.setInputsInline(!0);this.setOutput(!0,"Number")}};Entry.block.cobl_read_joyx=function(b,a){return Entry.hw.getAnalogPortValue("joyx")}; @@ -256,44 +257,44 @@ Blockly.Blocks.cobl_read_joyy={init:function(){this.setColour("#00979D");this.ap Entry.block.cobl_read_sens1=function(b,a){return Entry.hw.getAnalogPortValue("sens1")};Blockly.Blocks.cobl_read_sens2={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("\uc13c\uc11c2 \uc77d\uae30(0~1023)");this.setInputsInline(!0);this.setOutput(!0,"Number")}};Entry.block.cobl_read_sens2=function(b,a){return Entry.hw.getAnalogPortValue("sens2")}; Blockly.Blocks.cobl_read_tilt={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("\uae30\uc6b8\uae30\uc13c\uc11c \uc77d\uae30(0~4)");this.setInputsInline(!0);this.setOutput(!0,"Number")}};Entry.block.cobl_read_tilt=function(b,a){return Entry.hw.getAnalogPortValue("tilt")}; Blockly.Blocks.cobl_get_port_number={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(new Blockly.FieldDropdown([["1","1"],["2","2"]]),"PORT");this.appendDummyInput().appendField(" ");this.setOutput(!0,"Number");this.setInputsInline(!0)}};Entry.block.cobl_get_port_number=function(b,a){return a.getStringField("PORT")}; -Blockly.Blocks.cobl_read_temps={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("\uc628\ub3c4\uc13c\uc11c \uc77d\uae30@\ud3ec\ud2b8");this.appendValueInput("VALUE").setCheck("Number");this.setInputsInline(!0);this.setOutput(!0,"Number")}};Entry.block.cobl_read_temps=function(b,a){b=a.getValue("VALUE",a);if(1==b)return Entry.hw.getAnalogPortValue("temps1");if(2==b)return Entry.hw.getAnalogPortValue("temps2")}; -Blockly.Blocks.cobl_read_light={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("\ubc1d\uae30\uc13c\uc11c \uc77d\uae30@\ud3ec\ud2b8");this.appendValueInput("VALUE").setCheck("Number");this.setInputsInline(!0);this.setOutput(!0,"Number")}};Entry.block.cobl_read_light=function(b,a){b=a.getValue("VALUE",a);if(1==b)return Entry.hw.getAnalogPortValue("light1");if(2==b)return Entry.hw.getAnalogPortValue("light2")}; -Blockly.Blocks.cobl_read_btn={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("\ubc84\ud2bc\uc13c\uc11c \uc77d\uae30@\ud3ec\ud2b8");this.appendValueInput("VALUE").setCheck("Number");this.setInputsInline(!0);this.setOutput(!0,"Boolean")}};Entry.block.cobl_read_btn=function(b,a){b=a.getValue("VALUE",a);if(1==b)return Entry.hw.getDigitalPortValue("btn1");if(2==b)return Entry.hw.getDigitalPortValue("btn2")}; +Blockly.Blocks.cobl_read_temps={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("\uc628\ub3c4\uc13c\uc11c \uc77d\uae30@\ud3ec\ud2b8");this.appendValueInput("VALUE").setCheck("Number");this.setInputsInline(!0);this.setOutput(!0,"Number")}};Entry.block.cobl_read_temps=function(b,a){var d=a.getValue("VALUE",a);if(1==d)return Entry.hw.getAnalogPortValue("temps1");if(2==d)return Entry.hw.getAnalogPortValue("temps2")}; +Blockly.Blocks.cobl_read_light={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("\ubc1d\uae30\uc13c\uc11c \uc77d\uae30@\ud3ec\ud2b8");this.appendValueInput("VALUE").setCheck("Number");this.setInputsInline(!0);this.setOutput(!0,"Number")}};Entry.block.cobl_read_light=function(b,a){var d=a.getValue("VALUE",a);if(1==d)return Entry.hw.getAnalogPortValue("light1");if(2==d)return Entry.hw.getAnalogPortValue("light2")}; +Blockly.Blocks.cobl_read_btn={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("\ubc84\ud2bc\uc13c\uc11c \uc77d\uae30@\ud3ec\ud2b8");this.appendValueInput("VALUE").setCheck("Number");this.setInputsInline(!0);this.setOutput(!0,"Boolean")}};Entry.block.cobl_read_btn=function(b,a){var d=a.getValue("VALUE",a);if(1==d)return Entry.hw.getDigitalPortValue("btn1");if(2==d)return Entry.hw.getDigitalPortValue("btn2")}; Blockly.Blocks.cobl_led_control={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("Rainbow LED");this.appendDummyInput().appendField(new Blockly.FieldDropdown([["1","1"],["2","2"],["3","3"]]),"PORT");this.appendDummyInput().appendField(" ");this.appendDummyInput().appendField(new Blockly.FieldDropdown([["OFF","OFF"],["Red","Red"],["Orange","Orange"],["Yellow","Yellow"],["Green","Green"],["Blue","Blue"],["Dark Blue","Dark Blue"],["Purple","Purple"],["White","White"]]), -"OPERATOR");this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.cobl_led_control=function(b,a){b=a.getStringField("PORT");var d=a.getStringField("OPERATOR");Entry.hw.setDigitalPortValue("RainBowLED_IDX",b);Entry.hw.setDigitalPortValue("RainBowLED_COL",d);return a.callReturn()};Blockly.Blocks.cobl_text={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(new Blockly.FieldTextInput("cobl"),"NAME");this.setOutput(!0,"String");this.setInputsInline(!0)}}; +"OPERATOR");this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.cobl_led_control=function(b,a){var d=a.getStringField("PORT"),c=a.getStringField("OPERATOR");Entry.hw.setDigitalPortValue("RainBowLED_IDX",d);Entry.hw.setDigitalPortValue("RainBowLED_COL",c);return a.callReturn()};Blockly.Blocks.cobl_text={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(new Blockly.FieldTextInput("cobl"),"NAME");this.setOutput(!0,"String");this.setInputsInline(!0)}}; Entry.block.cobl_text=function(b,a){return a.getStringField("NAME")};Blockly.Blocks.cobl_servo_angle_control={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("Servo");this.appendValueInput("PORT").setCheck(["Number","String"]);this.appendDummyInput().appendField("Angle-");this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField("(15~165)");this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.cobl_servo_angle_control=function(b,a){console.log("servo - test");b=a.getNumberValue("PORT");var d=a.getNumberValue("VALUE"),d=Math.round(d),d=Math.max(d,15),d=Math.min(d,165);1==b&&(console.log("servo 1 degree "+d),Entry.hw.setDigitalPortValue("Servo1",d));2==b&&(console.log("servo 2 degree "+d),Entry.hw.setDigitalPortValue("Servo2",d));return a.callReturn()}; +Entry.block.cobl_servo_angle_control=function(b,a){console.log("servo - test");var d=a.getNumberValue("PORT"),c=a.getNumberValue("VALUE"),c=Math.round(c),c=Math.max(c,15),c=Math.min(c,165);1==d&&(console.log("servo 1 degree "+c),Entry.hw.setDigitalPortValue("Servo1",c));2==d&&(console.log("servo 2 degree "+c),Entry.hw.setDigitalPortValue("Servo2",c));return a.callReturn()}; Blockly.Blocks.cobl_melody={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("Melody");this.appendDummyInput().appendField(new Blockly.FieldDropdown([["(Low)So","L_So"],["(Low)So#","L_So#"],["(Low)La","L_La"],["(Low)La#","L_La#"],["(Low)Ti","L_Ti"],["Do","Do"],["Do#","Do#"],["Re","Re"],["Re#","Re#"],["Mi","Mi"],["Fa","Fa"],["Fa#","Fa#"],["So","So"],["So#","So#"],["La","La"],["La#","La#"],["Ti","Ti"],["(High)Do","H_Do"],["(High)Do#","H_Do#"],["(High)Re","H_Re"],["(High)R2#", -"H_Re#"],["(High)Mi","H_Mi"],["(High)Fa","H_Fa"]]),"MELODY");this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.cobl_melody=function(b,a){b=a.getStringField("MELODY");console.log("cobl_melody"+b);Entry.hw.setDigitalPortValue("Melody",b);return a.callReturn()}; +"H_Re#"],["(High)Mi","H_Mi"],["(High)Fa","H_Fa"]]),"MELODY");this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.cobl_melody=function(b,a){var d=a.getStringField("MELODY");console.log("cobl_melody"+d);Entry.hw.setDigitalPortValue("Melody",d);return a.callReturn()}; Blockly.Blocks.cobl_dcmotor={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("DcMotor");this.appendDummyInput().appendField(new Blockly.FieldDropdown([["1","1"],["2","2"]]),"MOTOR");this.appendDummyInput().appendField(" ");this.appendDummyInput().appendField(new Blockly.FieldDropdown([["1.Clockwise","1"],["2.Counter Clockwise","2"],["3.Stop","3"]]),"DIRECTION");this.appendDummyInput().appendField(" Speed");this.appendDummyInput().appendField(new Blockly.FieldDropdown([["1", "1"],["2","2"],["3","3"],["4","4"],["5","5"]]),"SPEED");this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.cobl_dcmotor=function(b,a){b=a.getStringField("MOTOR");var d=a.getStringField("DIRECTION"),c=a.getStringField("SPEED");console.log("MOTOR"+b+" Direction"+d+" speed"+c);1==b&&(Entry.hw.setDigitalPortValue("DC1_DIR",d),Entry.hw.setDigitalPortValue("DC1_SPEED",c));2==b&&(Entry.hw.setDigitalPortValue("DC2_DIR",d),Entry.hw.setDigitalPortValue("DC2_SPEED",c));return a.callReturn()}; +Entry.block.cobl_dcmotor=function(b,a){var d=a.getStringField("MOTOR"),c=a.getStringField("DIRECTION"),e=a.getStringField("SPEED");console.log("MOTOR"+d+" Direction"+c+" speed"+e);1==d&&(Entry.hw.setDigitalPortValue("DC1_DIR",c),Entry.hw.setDigitalPortValue("DC1_SPEED",e));2==d&&(Entry.hw.setDigitalPortValue("DC2_DIR",c),Entry.hw.setDigitalPortValue("DC2_SPEED",e));return a.callReturn()}; Blockly.Blocks.cobl_extention_port={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("Extention Port");this.appendDummyInput().appendField(new Blockly.FieldDropdown([["1","1"],["2","2"]]),"PORT");this.appendDummyInput().appendField(" Level");this.appendDummyInput().appendField(new Blockly.FieldDropdown([["1","1"],["2","2"],["3","3"],["4","4"],["5","5"]]),"LEVEL");this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.cobl_extention_port=function(b,a){b=a.getStringField("PORT");var d=a.getStringField("LEVEL");1==b&&Entry.hw.setDigitalPortValue("EXUSB1",d);2==b&&Entry.hw.setDigitalPortValue("EXUSB2",d);return a.callReturn()}; +Entry.block.cobl_extention_port=function(b,a){var d=a.getStringField("PORT"),c=a.getStringField("LEVEL");1==d&&Entry.hw.setDigitalPortValue("EXUSB1",c);2==d&&Entry.hw.setDigitalPortValue("EXUSB2",c);return a.callReturn()}; Blockly.Blocks.cobl_external_led={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("External LED ");this.appendValueInput("LED").setCheck(["Number","String"]);this.appendDummyInput().appendField(" (1~64)");this.appendDummyInput().appendField(" R ");this.appendDummyInput().appendField(new Blockly.FieldDropdown([["1","1"],["2","2"],["3","3"],["4","4"],["5","5"],["6","6"],["7","7"],["8","8"],["9","9"],["10","10"]]),"RED");this.appendDummyInput().appendField(" G ");this.appendDummyInput().appendField(new Blockly.FieldDropdown([["1", "1"],["2","2"],["3","3"],["4","4"],["5","5"],["6","6"],["7","7"],["8","8"],["9","9"],["10","10"]]),"GREEN");this.appendDummyInput().appendField(" B ");this.appendDummyInput().appendField(new Blockly.FieldDropdown([["1","1"],["2","2"],["3","3"],["4","4"],["5","5"],["6","6"],["7","7"],["8","8"],["9","9"],["10","10"]]),"BLUE");this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.cobl_external_led=function(b,a){b=a.getNumberValue("LED");var d=a.getStringField("RED"),c=a.getStringField("GREEN"),e=a.getStringField("BLUE");Entry.hw.setDigitalPortValue("ELED_IDX",b);Entry.hw.setDigitalPortValue("ELED_R",d);Entry.hw.setDigitalPortValue("ELED_G",c);Entry.hw.setDigitalPortValue("ELED_B",e);return a.callReturn()}; -Blockly.Blocks.cobl_7_segment={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("7 Segment");this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField("(0~9999)");this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.cobl_7_segment=function(b,a){b=a.getNumberValue("VALUE");Entry.hw.setDigitalPortValue("7SEG",b);return a.callReturn()};Entry.Codestar={name:"codestar",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/codestar.png",width:333,height:409,listPorts:{13:{name:"\uc9c4\ub3d9\ubaa8\ud130",type:"output",pos:{x:0,y:0}},6:{name:"\uc9c4\ub3d9\uc13c\uc11c",type:"input",pos:{x:0,y:0}}},ports:{7:{name:"\ube68\uac04\uc0c9",type:"output",pos:{x:238,y:108}},8:{name:"\ud30c\ub780\uc0c9",type:"output", +Entry.block.cobl_external_led=function(b,a){var d=a.getNumberValue("LED"),c=a.getStringField("RED"),e=a.getStringField("GREEN"),f=a.getStringField("BLUE");Entry.hw.setDigitalPortValue("ELED_IDX",d);Entry.hw.setDigitalPortValue("ELED_R",c);Entry.hw.setDigitalPortValue("ELED_G",e);Entry.hw.setDigitalPortValue("ELED_B",f);return a.callReturn()}; +Blockly.Blocks.cobl_7_segment={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("7 Segment");this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField("(0~9999)");this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.cobl_7_segment=function(b,a){var d=a.getNumberValue("VALUE");Entry.hw.setDigitalPortValue("7SEG",d);return a.callReturn()};Entry.Codestar={name:"codestar",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/codestar.png",width:333,height:409,listPorts:{13:{name:"\uc9c4\ub3d9\ubaa8\ud130",type:"output",pos:{x:0,y:0}},6:{name:"\uc9c4\ub3d9\uc13c\uc11c",type:"input",pos:{x:0,y:0}}},ports:{7:{name:"\ube68\uac04\uc0c9",type:"output",pos:{x:238,y:108}},8:{name:"\ud30c\ub780\uc0c9",type:"output", pos:{x:265,y:126}},9:{name:"3\uc0c9 \ube68\uac04\uc0c9",type:"output",pos:{x:292,y:34}},10:{name:"3\uc0c9 \ub179\uc0c9",type:"output",pos:{x:292,y:34}},11:{name:"3\uc0c9 \ud30c\ub780\uc0c9",type:"output",pos:{x:292,y:34}},12:{name:"\ubc84\ud2bc",type:"input",pos:{x:248,y:142}},a0:{name:"\uc67c\ucabd \ubcbd\uac10\uc9c0",type:"input",pos:{x:24,y:231}},a2:{name:"\ub9c8\uc774\ud06c",type:"input",pos:{x:225,y:67}},a3:{name:"\ubd80\uc800",type:"output",pos:{x:283,y:105}},a4:{name:"\uc67c\ucabd \ub77c\uc778\uac10\uc9c0", type:"input",pos:{x:37,y:353}},a5:{name:"\uc624\ub978\ucabd \ub77c\uc778\uac10\uc9c0",type:"input",pos:{x:50,y:368}},a6:{name:"\uc870\ub3c4\uc13c\uc11c",type:"input",pos:{x:273,y:22}},a7:{name:"\uc624\ub978\ucabd \ubcbd\uac10\uc9c0",type:"input",pos:{x:103,y:381}},temperature:{name:"\uc628\ub3c4\uc13c\uc11c",type:"input",pos:{x:311,y:238}},sonar:{name:"\ucd08\uc74c\ud30c",type:"input",pos:{x:7,y:277}},leftwheel:{name:"\uc67c\ucabd \ubc14\ud034",type:"output",pos:{x:177,y:370}},rightwheel:{name:"\uc624\ub978\ucabd \ubc14\ud034", type:"output",pos:{x:83,y:218}}},mode:"both"}};Entry.EV3={PORT_MAP:{A:0,B:0,C:0,D:0,1:void 0,2:void 0,3:void 0,4:void 0},motorMovementTypes:{Degrees:0,Power:1},deviceTypes:{NxtTouch:1,NxtLight:2,NxtSound:3,NxtColor:4,NxtUltrasonic:5,NxtTemperature:6,LMotor:7,MMotor:8,Touch:16,Color:29,Ultrasonic:30,Gyroscope:32,Infrared:33,Initializing:125,Empty:126,WrongPort:127,Unknown:255},colorSensorValue:" 000000 0000FF 00FF00 FFFF00 FF0000 FFFFFF A52A2A".split(" "),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=[]},setZero:function(){var b=this.PORT_MAP;Object.keys(b).forEach(function(a){/[A-D]/i.test(a)?Entry.hw.sendQueue[a]={type:Entry.EV3.motorMovementTypes.Power,power:0}:Entry.hw.sendQueue[a]=b[a]});Entry.hw.update()},name:"EV3"}; -Blockly.Blocks.ev3_get_sensor_value={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("").appendField(new Blockly.FieldDropdown([["1","1"],["2","2"],["3","3"],["4","4"]]),"PORT").appendField("\uc758 \uac12");this.setOutput(!0,"Number");this.setInputsInline(!0)}};Entry.block.ev3_get_sensor_value=function(b,a){a.getStringField("PORT",a);b=Entry.hw.getDigitalPortValue(a.getNumberField("PORT",a));var d;$.isPlainObject(b)&&(d=b.siValue||0);return d}; +Blockly.Blocks.ev3_get_sensor_value={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("").appendField(new Blockly.FieldDropdown([["1","1"],["2","2"],["3","3"],["4","4"]]),"PORT").appendField("\uc758 \uac12");this.setOutput(!0,"Number");this.setInputsInline(!0)}};Entry.block.ev3_get_sensor_value=function(b,a){a.getStringField("PORT",a);var d=Entry.hw.getDigitalPortValue(a.getNumberField("PORT",a)),c;$.isPlainObject(d)&&(c=d.siValue||0);return c}; Blockly.Blocks.ev3_touch_sensor={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("").appendField(new Blockly.FieldDropdown([["1","1"],["2","2"],["3","3"],["4","4"]]),"PORT").appendField("\uc758 \ud130\uce58\uc13c\uc11c\uac00 \uc791\ub3d9\ub418\uc5c8\ub294\uac00?");this.setOutput(!0,"Boolean");this.setInputsInline(!0)}}; -Entry.block.ev3_touch_sensor=function(b,a){a.getStringField("PORT",a);b=Entry.hw.getDigitalPortValue(a.getNumberField("PORT",a));a=!1;b.type==Entry.EV3.deviceTypes.Touch&&1<=Number(b.siValue)&&(a=!0);return a}; +Entry.block.ev3_touch_sensor=function(b,a){a.getStringField("PORT",a);var d=Entry.hw.getDigitalPortValue(a.getNumberField("PORT",a)),c=!1;d.type==Entry.EV3.deviceTypes.Touch&&1<=Number(d.siValue)&&(c=!0);return c}; Blockly.Blocks.ev3_color_sensor={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("").appendField(new Blockly.FieldDropdown([["1","1"],["2","2"],["3","3"],["4","4"]]),"PORT").appendField("\uc758 ").appendField(new Blockly.FieldDropdown([["RGB","RGB"],["R","R"],["G","G"],["B","B"]]),"RGB").appendField("\uac12");this.setOutput(!0,"String");this.setInputsInline(!0)}}; -Entry.block.ev3_color_sensor=function(b,a){a.getStringField("PORT",a);b=a.getStringField("RGB",a);a=Entry.hw.getDigitalPortValue(a.getNumberField("PORT",a));var d="";if(a.type==Entry.EV3.deviceTypes.Color)if(0==a.siValue)d="";else switch(b){case "RGB":d=Entry.EV3.colorSensorValue[a.siValue];break;case "R":d=Entry.EV3.colorSensorValue[a.siValue].substring(0,2);break;case "G":d=Entry.EV3.colorSensorValue[a.siValue].substring(2,4);break;case "B":d=Entry.EV3.colorSensorValue[a.siValue].substring(4,6)}else d= -"\uceec\ub7ec \uc13c\uc11c \uc544\ub2d8";return d};Blockly.Blocks.ev3_motor_power={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("").appendField(new Blockly.FieldDropdown([["A","A"],["B","B"],["C","C"],["D","D"]]),"PORT").appendField("\uc758 \uac12\uc744");this.appendValueInput("VALUE").setCheck(["Number"]);this.appendDummyInput().appendField("\uc73c\ub85c \ucd9c\ub825");this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.ev3_motor_power=function(b,a){b=a.getStringField("PORT",a);var d=a.getValue("VALUE",a);Entry.hw.sendQueue[b]={id:Math.floor(1E5*Math.random(),0),type:Entry.EV3.motorMovementTypes.Power,power:d};return a.callReturn()}; +Entry.block.ev3_color_sensor=function(b,a){a.getStringField("PORT",a);var d=a.getStringField("RGB",a),c=Entry.hw.getDigitalPortValue(a.getNumberField("PORT",a)),e="";if(c.type==Entry.EV3.deviceTypes.Color)if(0==c.siValue)e="";else switch(d){case "RGB":e=Entry.EV3.colorSensorValue[c.siValue];break;case "R":e=Entry.EV3.colorSensorValue[c.siValue].substring(0,2);break;case "G":e=Entry.EV3.colorSensorValue[c.siValue].substring(2,4);break;case "B":e=Entry.EV3.colorSensorValue[c.siValue].substring(4,6)}else e= +"\uceec\ub7ec \uc13c\uc11c \uc544\ub2d8";return e};Blockly.Blocks.ev3_motor_power={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("").appendField(new Blockly.FieldDropdown([["A","A"],["B","B"],["C","C"],["D","D"]]),"PORT").appendField("\uc758 \uac12\uc744");this.appendValueInput("VALUE").setCheck(["Number"]);this.appendDummyInput().appendField("\uc73c\ub85c \ucd9c\ub825");this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; +Entry.block.ev3_motor_power=function(b,a){var d=a.getStringField("PORT",a),c=a.getValue("VALUE",a);Entry.hw.sendQueue[d]={id:Math.floor(1E5*Math.random(),0),type:Entry.EV3.motorMovementTypes.Power,power:c};return a.callReturn()}; Blockly.Blocks.ev3_motor_power_on_time={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("").appendField(new Blockly.FieldDropdown([["A","A"],["B","B"],["C","C"],["D","D"]]),"PORT").appendField("\uc758 \uac12\uc744");this.appendValueInput("TIME").setCheck(["Number"]);this.appendDummyInput().appendField("\ucd08 \ub3d9\uc548");this.appendValueInput("VALUE").setCheck(["Number"]);this.appendDummyInput().appendField("\uc73c\ub85c \ucd9c\ub825");this.setInputsInline(!0);this.setPreviousStatement(!0); this.setNextStatement(!0)}}; -Entry.block.ev3_motor_power_on_time=function(b,a){b=a.getStringField("PORT",a);if(a.isStart){if(1==a.timeFlag)return a;delete a.isStart;delete a.timeFlag;Entry.engine.isContinue=!1;Entry.hw.sendQueue[b]={id:Math.floor(1E5*Math.random(),0),type:Entry.EV3.motorMovementTypes.Power,power:0};return a.callReturn()}var d=a.getValue("TIME",a),c=a.getValue("VALUE",a);a.isStart=!0;a.timeFlag=1;Entry.hw.sendQueue[b]={id:Math.floor(1E5*Math.random(),0),type:Entry.EV3.motorMovementTypes.Power,power:c};var e=setTimeout(function(){a.timeFlag= -0;Entry.EV3.removeTimeout(e)},1E3*d);Entry.EV3.timeouts.push(e);return a}; +Entry.block.ev3_motor_power_on_time=function(b,a){var d=a.getStringField("PORT",a);if(a.isStart){if(1==a.timeFlag)return a;delete a.isStart;delete a.timeFlag;Entry.engine.isContinue=!1;Entry.hw.sendQueue[d]={id:Math.floor(1E5*Math.random(),0),type:Entry.EV3.motorMovementTypes.Power,power:0};return a.callReturn()}var c=a.getValue("TIME",a),e=a.getValue("VALUE",a);a.isStart=!0;a.timeFlag=1;Entry.hw.sendQueue[d]={id:Math.floor(1E5*Math.random(),0),type:Entry.EV3.motorMovementTypes.Power,power:e};var f= +setTimeout(function(){a.timeFlag=0;Entry.EV3.removeTimeout(f)},1E3*c);Entry.EV3.timeouts.push(f);return a}; Blockly.Blocks.ev3_motor_degrees={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField("").appendField(new Blockly.FieldDropdown([["A","A"],["B","B"],["C","C"],["D","D"]]),"PORT").appendField("\uc758 \uac12\uc744").appendField(new Blockly.FieldDropdown([["\uc2dc\uacc4\ubc29\ud5a5","CW"],["\ubc18\uc2dc\uacc4\ubc29\ud5a5","CCW"]]),"DIRECTION").appendField("\uc73c\ub85c ");this.appendValueInput("DEGREE").setCheck(["Number"]);this.appendDummyInput().appendField("\ub3c4 \ub9cc\ud07c \ud68c\uc804"); -this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.ev3_motor_degrees=function(b,a){b=a.getStringField("PORT",a);var d=a.getValue("DEGREE",a);0>=d?d=0:720<=d&&(d=720);var c=a.getStringField("DIRECTION",a);Entry.hw.sendQueue[b]={id:Math.floor(1E5*Math.random(),0),type:Entry.EV3.motorMovementTypes.Degrees,degree:d,power:"CW"==c?50:-50};return a.callReturn()};Blockly.Blocks.wait_second={init:function(){this.setColour("#498deb");this.appendDummyInput().appendField(Lang.Blocks.FLOW_wait_second_1);this.appendValueInput("SECOND").setCheck(["Number","String",null]);this.appendDummyInput().appendField(Lang.Blocks.FLOW_wait_second_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/flow_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.wait_second=function(b,a){if(a.isStart){if(1==a.timeFlag)return a;delete a.timeFlag;delete a.isStart;Entry.engine.isContinue=!1;return a.callReturn()}a.isStart=!0;a.timeFlag=1;b=a.getNumberValue("SECOND",a);setTimeout(function(){a.timeFlag=0},60/(Entry.FPS||60)*b*1E3);return a}; +this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.ev3_motor_degrees=function(b,a){var d=a.getStringField("PORT",a),c=a.getValue("DEGREE",a);0>=c?c=0:720<=c&&(c=720);var e=a.getStringField("DIRECTION",a);Entry.hw.sendQueue[d]={id:Math.floor(1E5*Math.random(),0),type:Entry.EV3.motorMovementTypes.Degrees,degree:c,power:"CW"==e?50:-50};return a.callReturn()};Blockly.Blocks.wait_second={init:function(){this.setColour("#498deb");this.appendDummyInput().appendField(Lang.Blocks.FLOW_wait_second_1);this.appendValueInput("SECOND").setCheck(["Number","String",null]);this.appendDummyInput().appendField(Lang.Blocks.FLOW_wait_second_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/flow_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; +Entry.block.wait_second=function(b,a){if(a.isStart){if(1==a.timeFlag)return a;delete a.timeFlag;delete a.isStart;Entry.engine.isContinue=!1;return a.callReturn()}a.isStart=!0;a.timeFlag=1;var d=a.getNumberValue("SECOND",a);setTimeout(function(){a.timeFlag=0},60/(Entry.FPS||60)*d*1E3);return a}; Blockly.Blocks.repeat_basic={init:function(){this.setColour("#498deb");this.appendDummyInput().appendField(Lang.Blocks.FLOW_repeat_basic_1);this.appendValueInput("VALUE").setCheck(["Number","String"]);this.appendDummyInput().appendField(Lang.Blocks.FLOW_repeat_basic_2).appendField(new Blockly.FieldIcon(Entry.mediaFilePath+"block_icon/flow_03.png","*"));this.appendStatementInput("DO");this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}}; -Entry.block.repeat_basic=function(b,a){if(!a.isLooped){a.isLooped=!0;b=a.getNumberValue("VALUE",a);if(0>b)throw Error(Lang.Blocks.FLOW_repeat_basic_errorMsg);a.iterCount=Math.floor(b)}if(0==a.iterCount||0>a.iterCount)return delete a.isLooped,delete a.iterCount,a.callReturn();a.iterCount--;return a.getStatement("DO",a)}; +Entry.block.repeat_basic=function(b,a){var d;if(!a.isLooped){a.isLooped=!0;d=a.getNumberValue("VALUE",a);if(0>d)throw Error(Lang.Blocks.FLOW_repeat_basic_errorMsg);a.iterCount=Math.floor(d)}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)}}; @@ -301,18 +302,18 @@ Entry.block.wait_until_true=function(b,a){return a.getBooleanValue("BOOL",a)?a.c 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(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(b,a){if(a.isLooped)return delete a.isLooped,a.callReturn();b=a.getBooleanValue("BOOL",a);a.isLooped=!0;return b?a.getStatement("STACK_IF",a):a.getStatement("STACK_ELSE",a)}; +this.setNextStatement(!0)}};Entry.block.if_else=function(b,a){if(a.isLooped)return delete a.isLooped,a.callReturn();var d=a.getBooleanValue("BOOL",a);a.isLooped=!0;return d?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(b,a){var d=a.getField("VALUE",a);a=a.callReturn();"self"==d?b.parent.addCloneEntity(b.parent,b,null):Entry.container.getObject(d).addCloneEntity(b.parent,null,null);return a};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.create_clone=function(b,a){var d=a.getField("VALUE",a),c=a.callReturn();"self"==d?b.parent.addCloneEntity(b.parent,b,null):Entry.container.getObject(d).addCloneEntity(b.parent,null,null);return c};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(b,a){b=a.getBooleanValue("BOOL",a);"until"==a.getField("OPTION",a)&&(b=!b);return(a.isLooped=b)?a.getStatement("DO",a):a.callReturn()}; +this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.repeat_while_true=function(b,a){var d=a.getBooleanValue("BOOL",a);"until"==a.getField("OPTION",a)&&(d=!d);return(a.isLooped=d)?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(b,a){a=a.getField("TARGET",a);var d=Entry.container;switch(a){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)}}; +"block_icon/flow_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.stop_object=function(b,a){var d=a.getField("TARGET",a),c=Entry.container;switch(d){case "all":return c.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){b=b.parent.getClonedEntities();b.map(function(a){a.removeClone()});b=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.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 d=b.parent.getClonedEntities();d.map(function(a){a.removeClone()});d=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"}]}; @@ -325,92 +326,92 @@ Entry.block.function_create={skeleton:"basic",color:"#cc7337",event:"funcDef",te Blockly.Blocks.function_general={init:function(){this.setColour("#cc7337");this.setInputsInline(!0);this.setNextStatement(!0);this.setPreviousStatement(!0)},domToMutation:function(b){var a=b.getElementsByTagName("field");this.appendDummyInput().appendField("");a.length||this.appendDummyInput().appendField(Lang.Blocks.FUNCTION_function);for(var d=0;da.count?(50>d.leftFloor&&50>d.rightFloor?a.count++:a.count=0,d=d.leftFloor-d.rightFloor,b.leftWheel=45+.25*d,b.rightWheel=45-.25*d):(a.count=0,a.boardState=2);break;case 2:d=d.leftFloor-d.rightFloor;b.leftWheel=45+.25*d;b.rightWheel=45-.25*d;a.boardState=3;var c=setTimeout(function(){a.boardState=4;Entry.Hamster.removeTimeout(c)},250);Entry.Hamster.timeouts.push(c); -break;case 3:d=d.leftFloor-d.rightFloor;b.leftWheel=45+.25*d;b.rightWheel=45-.25*d;break;case 4:b.leftWheel=0,b.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;b.leftWheel=0;b.rightWheel=0;return a.callReturn()}a.isStart=!0;a.isMoving=!0;a.count=0;a.boardState=1;b.leftWheel=45;b.rightWheel=45;Entry.Hamster.setLineTracerMode(b,0);return a}; +Entry.block.hamster_move_forward_once=function(b,a){var d=Entry.hw.sendQueue,c=Entry.hw.portData;if(a.isStart){if(a.isMoving){switch(a.boardState){case 1:2>a.count?(50>c.leftFloor&&50>c.rightFloor?a.count++:a.count=0,c=c.leftFloor-c.rightFloor,d.leftWheel=45+.25*c,d.rightWheel=45-.25*c):(a.count=0,a.boardState=2);break;case 2:c=c.leftFloor-c.rightFloor;d.leftWheel=45+.25*c;d.rightWheel=45-.25*c;a.boardState=3;var e=setTimeout(function(){a.boardState=4;Entry.Hamster.removeTimeout(e)},250);Entry.Hamster.timeouts.push(e); +break;case 3:c=c.leftFloor-c.rightFloor;d.leftWheel=45+.25*c;d.rightWheel=45-.25*c;break;case 4:d.leftWheel=0,d.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;d.leftWheel=0;d.rightWheel=0;return a.callReturn()}a.isStart=!0;a.isMoving=!0;a.count=0;a.boardState=1;d.leftWheel=45;d.rightWheel=45;Entry.Hamster.setLineTracerMode(d,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.Blocks.HAMSTER_turn_once_left,"LEFT"],[Lang.Blocks.HAMSTER_turn_once_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(b,a){b=Entry.hw.sendQueue;var 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: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:50a.count?50c.leftFloor&&(a.boardState=3);break;case 3:2>a.count?20>c.leftFloor&&a.count++:(a.count=0,a.boardState=4);break;case 4:50a.count?50c.rightFloor&&(a.boardState=3);break;case 3:2>a.count?20>c.rightFloor&&a.count++:(a.count=0,a.boardState=4);break;case 4:50Entry.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(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_a_b,"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(b,a){b=Entry.hw.sendQueue;var d=a.getField("PORT",a),c=Number(a.getField("MODE",a));"A"==d?b.ioModeA=c:("B"!=d&&(b.ioModeA=c),b.ioModeB=c);return a.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 d=Entry.hw.sendQueue,c=a.getField("PORT",a),e=Number(a.getField("MODE",a));"A"==c?d.ioModeA=e:("B"!=c&&(d.ioModeA=e),d.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_a_b,"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(b,a){b=Entry.hw.sendQueue;var d=a.getField("PORT"),c=a.getNumberValue("VALUE");"A"==d?b.outputA=void 0!=b.outputA?b.outputA+c:c:("B"!=d&&(b.outputA=void 0!=b.outputA?b.outputA+c:c),b.outputB=void 0!=b.outputB?b.outputB+c:c);return a.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 d=Entry.hw.sendQueue,c=a.getField("PORT"),e=a.getNumberValue("VALUE");"A"==c?d.outputA=void 0!=d.outputA?d.outputA+e:e:("B"!=c&&(d.outputA=void 0!=d.outputA?d.outputA+e:e),d.outputB=void 0!=d.outputB?d.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_a_b,"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(b,a){b=Entry.hw.sendQueue;var d=a.getField("PORT"),c=a.getNumberValue("VALUE");"A"==d?b.outputA=c:("B"!=d&&(b.outputA=c),b.outputB=c);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){b=Number(a.getField("VALUE",a));return 0<=Entry.pressedKeys.indexOf(b)}; +"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.hamster_set_output_to=function(b,a){var d=Entry.hw.sendQueue,c=a.getField("PORT"),e=a.getNumberValue("VALUE");"A"==c?d.outputA=e:("B"!=c&&(d.outputA=e),d.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 d=Number(a.getField("VALUE",a));return 0<=Entry.pressedKeys.indexOf(d)}; 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(b,a){if(!b.getVisible())return!1;var d=a.getField("VALUE",a);a=b.object;var c=/wall/.test(d),e=ndgmr.checkPixelCollision;if(c)switch(b=Entry.stage.wall,d){case "wall":if(e(a,b.up,.2,!0)||e(a,b.down,.2,!0)||e(a,b.left,.2,!0)||e(a,b.right,.2,!0))return!0;break;case "wall_up":if(e(a,b.up,.2,!0))return!0;break;case "wall_down":if(e(a,b.down,.2,!0))return!0;break;case "wall_right":if(e(a,b.right,.2,!0))return!0;break;case "wall_left":if(e(a,b.left,.2,!0))return!0}else{if("mouse"== -d)return e=Entry.stage.canvas,e=a.globalToLocal(e.mouseX,e.mouseY),a.hitTest(e.x,e.y);d=Entry.container.getEntity(d);if("textBox"==d.type||"textBox"==b.type){e=d.object.getTransformedBounds();a=a.getTransformedBounds();if(Entry.checkCollisionRect(a,e))return!0;b=d.parent.clonedEntities;d=0;for(c=b.length;d","BIGGER"]]),"OPERATOR");this.appendValueInput("RIGHTHAND").setCheck(["String","Number"]);this.setOutput(!0,"Boolean");this.setInputsInline(!0)}}; -Entry.block.boolean_comparison=function(b,a){b=a.getField("OPERATOR",a);var d=a.getNumberValue("LEFTHAND",a);a=a.getNumberValue("RIGHTHAND",a);return"EQUAL"==b?d==a:"BIGGER"==b?d>a:d","#3D3D3D");this.appendValueInput("RIGHTHAND").setCheck(["Number","String"]);this.setOutput(!0,"Boolean");this.setInputsInline(!0)}}; -Entry.block.boolean_bigger=function(b,a){b=a.getNumberValue("LEFTHAND",a);a=a.getNumberValue("RIGHTHAND",a);return b>a};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){b=a.getNumberValue("LEFTHAND",a);a=a.getNumberValue("RIGHTHAND",a);return b","BIGGER"]]),"OPERATOR");this.appendValueInput("RIGHTHAND").setCheck(["String","Number"]);this.setOutput(!0,"Boolean");this.setInputsInline(!0)}}; +Entry.block.boolean_comparison=function(b,a){var d=a.getField("OPERATOR",a),c=a.getNumberValue("LEFTHAND",a),e=a.getNumberValue("RIGHTHAND",a);return"EQUAL"==d?c==e:"BIGGER"==d?c>e:c","#3D3D3D");this.appendValueInput("RIGHTHAND").setCheck(["Number","String"]);this.setOutput(!0,"Boolean");this.setInputsInline(!0)}}; +Entry.block.boolean_bigger=function(b,a){var d=a.getNumberValue("LEFTHAND",a),c=a.getNumberValue("RIGHTHAND",a);return d>c};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 d=a.getNumberValue("LEFTHAND",a),c=a.getNumberValue("RIGHTHAND",a);return d","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(b,a){b=a.getField("OPERATOR",a);var d=a.getStringValue("LEFTHAND",a);a=a.getStringValue("RIGHTHAND",a);switch(b){case "EQUAL":return d==a;case "GREATER":return Number(d)>Number(a);case "LESS":return Number(d)=Number(a);case "LESS_OR_EQUAL":return Number(d)<=Number(a)}};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()}; +Entry.block.boolean_basic_operator=function(b,a){var d=a.getField("OPERATOR",a),c=a.getStringValue("LEFTHAND",a),e=a.getStringValue("RIGHTHAND",a);switch(d){case "EQUAL":return c==e;case "GREATER":return Number(c)>Number(e);case "LESS":return Number(c)=Number(e);case "LESS_OR_EQUAL":return Number(c)<=Number(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)}}; @@ -437,7 +438,7 @@ Blockly.Blocks.set_scale_size={init:function(){this.setColour("#EC4466");this.ap Entry.block.set_scale_size=function(b,a){var d=a.getNumberValue("VALUE",a);b.setSize(d);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(b,a){var d=a.getField("VALUE",a);b=Entry.container.getCurrentObjects().indexOf(b.parent);if(-1b)throw Error("object is not available for current scene");switch(c){case "FRONT":d=0;break;case "FORWARD":d=Math.max(0,b-1);break;case "BACKWARD":d=Math.min(e,b+1);break;case "BACK":d=e}Entry.container.moveElementByBlock(b,d);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)}}; +"block_icon/looks_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.change_object_index=function(b,a){var d,c=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(c){case "FRONT":d=0;break;case "FORWARD":d=Math.max(0,f-1);break;case "BACKWARD":d=Math.min(e,f+1);break;case "BACK":d=e}Entry.container.moveElementByBlock(f,d);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 d=a.getNumberValue("VALUE",a);b.setX(b.getX()+d*Math.cos((b.getRotation()+b.getDirection()-90)/180*Math.PI));b.setY(b.getY()-d*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(b,a){var d=a.getNumberValue("VALUE",a);b.setX(b.getX()+d);b.brush&&!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY());return a.callReturn()}; @@ -484,9 +485,9 @@ Blockly.Blocks.rotate_by_angle_time={init:function(){this.setColour("#A751E3");t "*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.rotate_by_angle_time=function(b,a){if(!a.isStart){var d;d=a.getNumberValue("VALUE",a);var c=a.getNumberField("VALUE",a);a.isStart=!0;a.frameCount=Math.floor(d*Entry.FPS);a.dAngle=c/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(b,a){var d=b.parent.getRotateMethod(),c="free"==d?(b.getRotation()+b.getDirection()).mod(360):b.getDirection(),e;if(90>c&&0<=c||360>c&&270<=c){e=b.collision==Entry.Utils.COLLISION.UP;var 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"==d?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"==d?b.setRotation(-b.getRotation()-2*b.getDirection()+180):b.setDirection(-b.getDirection()+180),b.collision=Entry.Utils.COLLISION.DOWN))}else 270>c&&90<=c&&(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"==d? -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"==d?b.setRotation(-b.getRotation()-2*b.getDirection()+180):b.setDirection(-b.getDirection()+180),b.collision=Entry.Utils.COLLISION.UP)));360>c&&180<=c?(e=b.collision==Entry.Utils.COLLISION.LEFT, +Entry.block.bounce_wall=function(b,a){var d=b.parent.getRotateMethod(),c="free"==d?(b.getRotation()+b.getDirection()).mod(360):b.getDirection(),e=Entry.Utils.COLLISION.NONE;if(90>c&&0<=c||360>c&&270<=c){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"==d?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"==d?b.setRotation(-b.getRotation()-2*b.getDirection()+180):b.setDirection(-b.getDirection()+180),b.collision=Entry.Utils.COLLISION.DOWN))}else 270>c&&90<=c&&(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"==d?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"==d?b.setRotation(-b.getRotation()-2*b.getDirection()+180):b.setDirection(-b.getDirection()+180),b.collision=Entry.Utils.COLLISION.UP)));360>c&&180<=c?(e=b.collision==Entry.Utils.COLLISION.LEFT, c=ndgmr.checkPixelCollision(Entry.stage.wall.left,b.object,0,!1),!c&&e&&(b.collision=Entry.Utils.COLLISION.NONE),c&&e&&(c=!1),c?("free"==d?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,c=ndgmr.checkPixelCollision(Entry.stage.wall.right,b.object,0,!1),!c&&e&&(b.collision=Entry.Utils.COLLISION.NONE),c&&e&&(c=!1),c&&("free"==d?b.setRotation(-b.getRotation()-2*b.getDirection()): b.setDirection(-b.getDirection()+360),b.collision=Entry.Utils.COLLISION.RIGHT))):180>c&&0<=c&&(e=b.collision==Entry.Utils.COLLISION.RIGHT,c=ndgmr.checkPixelCollision(Entry.stage.wall.right,b.object,0,!1),!c&&e&&(b.collision=Entry.Utils.COLLISION.NONE),c&&e&&(c=!1),c?("free"==d?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,c=ndgmr.checkPixelCollision(Entry.stage.wall.left, b.object,0,!1),!c&&e&&(b.collision=Entry.Utils.COLLISION.NONE),c&&e&&(c=!1),c&&("free"==d?b.setRotation(-b.getRotation()-2*b.getDirection()):b.setDirection(-b.getDirection()+360),b.collision=Entry.Utils.COLLISION.LEFT)));return a.callReturn()}; @@ -517,137 +518,137 @@ Blockly.Blocks.rotate_by_time={init:function(){this.setColour("#A751E3");this.ap 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(b,a){if(!a.isStart){var d;d=a.getNumberValue("DURATION",a);var c=a.getNumberValue("AMOUNT",a);a.isStart=!0;a.frameCount=Math.floor(d*Entry.FPS);a.dDirection=c/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(b,a){b=a.getStringField("PORT");return Entry.hw.portData[b]}; +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 d=a.getStringField("PORT");return Entry.hw.portData[d]}; 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(b,a){b=a.getNumberField("SPEED");var d=a.getNumberField("DIRECTION");Entry.hw.sendQueue.DCL=b+d;return a.callReturn()}; +"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.neobot_left_motor=function(b,a){var d=a.getNumberField("SPEED"),c=a.getNumberField("DIRECTION");Entry.hw.sendQueue.DCL=d+c;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(b,a){b=a.getNumberField("SPEED");var d=a.getNumberField("DIRECTION");Entry.hw.sendQueue.DCR=b+d;return a.callReturn()}; +"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.neobot_right_motor=function(b,a){var d=a.getNumberField("SPEED"),c=a.getNumberField("DIRECTION");Entry.hw.sendQueue.DCR=d+c;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(b,a){a.getNumberField("TYPE");b=a.getNumberField("SPEED");switch(a.getNumberField("DIRECTION")){case 1:Entry.hw.sendQueue.DCL=16+b;Entry.hw.sendQueue.DCR=16+b;break;case 2:Entry.hw.sendQueue.DCL=32+b;Entry.hw.sendQueue.DCR=32+b;break;case 3:Entry.hw.sendQueue.DCL=32+b;Entry.hw.sendQueue.DCR=16+b;break;case 4:Entry.hw.sendQueue.DCL=16+b;Entry.hw.sendQueue.DCR=32+b;break;case 5:Entry.hw.sendQueue.DCL=0;Entry.hw.sendQueue.DCR=16+b;break;case 6:Entry.hw.sendQueue.DCL= -16+b,Entry.hw.sendQueue.DCR=0}return a.callReturn()}; +Entry.block.neobot_all_motor=function(b,a){a.getNumberField("TYPE");var d=a.getNumberField("SPEED");switch(a.getNumberField("DIRECTION")){case 1:Entry.hw.sendQueue.DCL=16+d;Entry.hw.sendQueue.DCR=16+d;break;case 2:Entry.hw.sendQueue.DCL=32+d;Entry.hw.sendQueue.DCR=32+d;break;case 3:Entry.hw.sendQueue.DCL=32+d;Entry.hw.sendQueue.DCR=16+d;break;case 4:Entry.hw.sendQueue.DCL=16+d;Entry.hw.sendQueue.DCR=32+d;break;case 5:Entry.hw.sendQueue.DCL=0;Entry.hw.sendQueue.DCR=16+d;break;case 6:Entry.hw.sendQueue.DCL= +16+d,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(b,a){b=a.getNumberField("PORT");var d=a.getNumberField("DEGREE");Entry.hw.sendQueue["OUT"+b]=d;3===b&&(b=4);Entry.hw.sendQueue.OPT|=b;return a.callReturn()}; +Entry.block.neobot_set_servo=function(b,a){var d=a.getNumberField("PORT"),c=a.getNumberField("DEGREE");Entry.hw.sendQueue["OUT"+d]=c;3===d&&(d=4);Entry.hw.sendQueue.OPT|=d;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(b,a){b=a.getStringField("PORT",a);var d=a.getNumberValue("VALUE",a),c=b;0>d?d=0:255c?c=0:255b&&(b=0);Entry.hw.sendQueue.FND=b;return a.callReturn()}; +Entry.block.neobot_set_fnd=function(b,a){var d=a.getNumberValue("VALUE",a);255d&&(d=0);Entry.hw.sendQueue.FND=d;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(b,a){b=Entry.hw.sendQueue;if(a.isStart){if(1==a.timeFlag)return a;delete a.timeFlag;delete a.isStart;Entry.hw.sendQueue.SND=0;Entry.engine.isContinue=!1;return a.callReturn()}var d=a.getNumberField("NOTE",a),c=a.getNumberField("OCTAVE",a),e=a.getNumberField("DURATION",a),d=d+12*c;a.isStart=!0;a.timeFlag=1;65b;b++)Entry.hw.sendQueue[b]=0;this.ColorPin=[0,0,0];Entry.hw.update()},setSendData:function(b){Entry.hw.sendQueue=b;Entry.hw.update();this.wait(32)},wait:function(b){for(var a=(new Date).getTime(),d=a;db;b++)Entry.hw.sendQueue[b]=0;this.ColorPin=[0,0,0];Entry.hw.update()},setSendData:function(b){Entry.hw.sendQueue=b;Entry.hw.update();this.wait(32)},wait:function(b){for(var a=(new Date).getTime(),d=a;db;b++)Entry.hw.sendQueue[b]=0;this.ColorPin=[0,0,0];Entry.hw.update()},setSendData:function(b){Entry.hw.sendQueue=b;Entry.hw.update();this.wait(32)},wait:function(b){for(var a=(new Date).getTime(),d=a;dc&&(c=0);"cw"==b?Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.MOTOR,1,d,c]):"ccw"==b?Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.MOTOR,2,d,c]):"stop"==b&&Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.MOTOR,0,d,c]);return a.callReturn()}; +Entry.block.schoolkit_motor=function(b,a){var d=0,d=a.getField("MODE"),c=a.getField("OPERATOR"),e=a.getNumberValue("VALUE"),d="motor1"==d?7:8;255e&&(e=0);"cw"==c?Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.MOTOR,1,d,e]):"ccw"==c?Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.MOTOR,2,d,e]):"stop"==c&&Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.MOTOR,0,d,e]);return a.callReturn()}; Blockly.Blocks.schoolkit_set_servo_value={init:function(){this.setColour("#00979D");this.appendDummyInput().appendField(Lang.Blocks.roborobo_num_pin_1);this.appendValueInput("PIN").setCheck(["Number","String",null]);this.appendDummyInput().appendField(Lang.Blocks.roborobo_num_pin_2);this.appendDummyInput().appendField(" : ");this.appendValueInput("VALUE").setCheck(["Number","String",null]);this.appendDummyInput().appendField(Lang.Blocks.roborobo_degree);this.appendDummyInput().appendField(new Blockly.FieldIcon(Entry.mediaFilePath+ -"block_icon/hardware_03.png","*"));this.setInputsInline(!0);this.setPreviousStatement(!0);this.setNextStatement(!0)}};Entry.block.schoolkit_set_servo_value=function(b,a){b=a.getNumberValue("PIN");var d=a.getNumberValue("VALUE");0>d?d=0:180c?c=0:180=d)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},d);return b},wait:function(b,a){Entry.hw.socket.send(JSON.stringify(b));for(var d=b=(new Date).getTime();dd&&(d=0);return Entry.Robotis_carCont.postCallReturn(a,[[c,e+(b-1)*f,f,d]],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 d=a.getField("PORT",a),c=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];1023c&&(c=0);return Entry.Robotis_carCont.postCallReturn(a,[[e,f+(d-1)*g,g,c]],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(b,a){b=a.getField("PORT",a);var d=a.getField("LED_MODULE",a),c=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(a,[[c,e+(b-1)*f,f,d]],Entry.Robotis_openCM70.delay)}; +Entry.block.robotis_openCM70_aux_led_module=function(b,a){var d=a.getField("PORT",a),c=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+(d-1)*g,g,c]],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(b,a){b=a.getField("PORT",a);var d=a.getNumberValue("VALUE"),c=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(a,[[c,e+(b-1)*f,f,d]],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 d=a.getField("PORT",a),c=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+(d-1)*g,g,c]],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(b,a){b=Entry.Robotis_openCM70.INSTRUCTION.WRITE;var d,c;d=a.getNumberValue("ADDRESS");c=a.getNumberValue("VALUE");return Entry.Robotis_carCont.postCallReturn(a,[[b,d,65535b&&(b=0);createjs.Sound.setVolume(b);return a.callReturn()}; +Entry.block.sound_volume_change=function(b,a){var d=a.getNumberValue("VALUE",a)/100,d=d+createjs.Sound.getVolume();1d&&(d=0);createjs.Sound.setVolume(d);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(b,a){b=a.getNumberValue("VALUE",a)/100;1b&&(b=0);createjs.Sound.setVolume(b);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_volume_set=function(b,a){var d=a.getNumberValue("VALUE",a)/100;1d&&(d=0);createjs.Sound.setVolume(d);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(b,a){var d=a.getStringValue("VALUE",a);(b=b.parent.getSound(d))&&createjs.Sound.play(b.id);return a.callReturn()}; +Entry.block.sound_something_with_block=function(b,a){var d=a.getStringValue("VALUE",a);(d=b.parent.getSound(d))&&createjs.Sound.play(d.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(b,a){var d=a.getStringValue("VALUE",a),c=a.getNumberValue("SECOND",a);(b=b.parent.getSound(d))&&createjs.Sound.play(b.id,{startTime:0,duration:1E3*c});return a.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 d=a.getStringValue("VALUE",a),c=a.getNumberValue("SECOND",a);(d=b.parent.getSound(d))&&createjs.Sound.play(d.id,{startTime:0,duration:1E3*c});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(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 d=a.getStringValue("VALUE",a);if(b=b.parent.getSound(d))createjs.Sound.play(b.id),setTimeout(function(){a.playState=0},1E3*b.duration);return a}; +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 d=a.getStringValue("VALUE",a);if(d=b.parent.getSound(d))createjs.Sound.play(d.id),setTimeout(function(){a.playState=0},1E3*d.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(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 d=a.getStringValue("VALUE",a);if(b=b.parent.getSound(d)){var c=createjs.Sound.play(b.id);b=a.getNumberValue("SECOND",a);setTimeout(function(){c.stop();a.playState=0},1E3*b);c.addEventListener("complete",function(a){})}return a}; +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 d=a.getStringValue("VALUE",a);if(d=b.parent.getSound(d)){var c=createjs.Sound.play(d.id),d=a.getNumberValue("SECOND",a);setTimeout(function(){c.stop();a.playState=0},1E3*d);c.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(b,a){var d=a.getStringValue("VALUE",a);if(b=b.parent.getSound(d)){var d=1E3*a.getNumberValue("START",a),c=1E3*a.getNumberValue("END",a);createjs.Sound.play(b.id,{startTime:Math.min(d,c),duration:Math.max(d,c)-Math.min(d,c)})}return a.callReturn()}; +"block_icon/sound_03.png","*"));this.setInputsInline(!0);this.setNextStatement(!0);this.setPreviousStatement(!0)}};Entry.block.sound_from_to=function(b,a){var d=a.getStringValue("VALUE",a);if(d=b.parent.getSound(d)){var c=1E3*a.getNumberValue("START",a),e=1E3*a.getNumberValue("END",a);createjs.Sound.play(d.id,{startTime:Math.min(c,e),duration:Math.max(c,e)-Math.min(c,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(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 d=a.getStringValue("VALUE",a);if(b=b.parent.getSound(d)){var c=1E3*a.getNumberValue("START",a),e=1E3*a.getNumberValue("END",a),d=Math.min(c,e),c=Math.max(c,e)-d;createjs.Sound.play(b.id,{startTime:d,duration:c});setTimeout(function(){a.playState=0},c)}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()}; +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 d=a.getStringValue("VALUE",a);if(d=b.parent.getSound(d)){var c=1E3*a.getNumberValue("START",a),e=1E3*a.getNumberValue("END",a),f=Math.min(c,e),c=Math.max(c,e)-f;createjs.Sound.play(d.id,{startTime:f,duration:c});setTimeout(function(){a.playState=0},c)}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(b,a){return a.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(b,a){return a.callReturn()}; @@ -686,11 +687,11 @@ Blockly.Blocks.when_some_key_click={init:function(){this.setColour("#3BBD70");th 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(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(b,a){return a.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(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){b=a.getField("VALUE",a);var d=Entry.isExist(b,"id",Entry.variableContainer.messages_);if("null"==b||!d)throw Error("value can not be null or undefined");Entry.container.mapEntityIncludeCloneOnScene(Entry.engine.raiseKeyEvent,["when_message_cast",b]);return a.callReturn()}; +b)},whenRemove:function(b){var a=Entry.variableContainer;a&&a.removeRef("_messageRefs",b)}};Entry.block.message_cast=function(b,a){var d=a.getField("VALUE",a),c=Entry.isExist(d,"id",Entry.variableContainer.messages_);if("null"==d||!c)throw Error("value can not be null or undefined");Entry.container.mapEntityIncludeCloneOnScene(Entry.engine.raiseKeyEvent,["when_message_cast",d]);return a.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(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){b=a.runningScript;for(var d=b.length,c=0;cb.array_.length)throw Error("can not remove value from array");b.array_.splice(c-1,1);b.updateView();return a.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 d=a.getField("LIST",a),c=a.getValue("VALUE",a),d=Entry.variableContainer.getList(d,b);if(!d.array_||isNaN(c)||c>d.array_.length)throw Error("can not remove value from array");d.array_.splice(c-1,1);d.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(b,a){var d=a.getField("LIST",a),c=a.getValue("DATA",a),e=a.getValue("INDEX",a);b=Entry.variableContainer.getList(d,b);if(!b.array_||isNaN(e)||0==e||e>b.array_.length+1)throw Error("can not insert value to array");b.array_.splice(e-1,0,{data:c});b.updateView();return a.callReturn()}; +Entry.block.insert_value_to_list=function(b,a){var d=a.getField("LIST",a),c=a.getValue("DATA",a),e=a.getValue("INDEX",a),d=Entry.variableContainer.getList(d,b);if(!d.array_||isNaN(e)||0==e||e>d.array_.length+1)throw Error("can not insert value to array");d.array_.splice(e-1,0,{data:c});d.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(b,a){var d=a.getField("LIST",a),c=a.getValue("DATA",a),e=a.getValue("INDEX",a);b=Entry.variableContainer.getList(d,b);if(!b.array_||isNaN(e)||e>b.array_.length)throw Error("can not insert value to array");b.array_[e-1].data=c;b.updateView();return a.callReturn()}; +Entry.block.change_value_list_index=function(b,a){var d=a.getField("LIST",a),c=a.getValue("DATA",a),e=a.getValue("INDEX",a),d=Entry.variableContainer.getList(d,b);if(!d.array_||isNaN(e)||e>d.array_.length)throw Error("can not insert value to array");d.array_[e-1].data=c;d.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(b,a){var d=a.getField("LIST",a);a=a.getValue("INDEX",a);b=Entry.variableContainer.getList(d,b);a=Entry.getListRealIndex(a,b);if(!b.array_||isNaN(a)||a>b.array_.length)throw Error("can not insert value to array");return b.array_[a-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){b=a.getField("LIST",a);return Entry.variableContainer.getList(b).array_.length}; +"String");this.setInputsInline(!0)}};Entry.block.value_of_index_from_list=function(b,a){var d=a.getField("LIST",a),c=a.getValue("INDEX",a),d=Entry.variableContainer.getList(d,b),c=Entry.getListRealIndex(c,d);if(!d.array_||isNaN(c)||c>d.array_.length)throw Error("can not insert value to array");return d.array_[c-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 d=a.getField("LIST",a);return Entry.variableContainer.getList(d).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(b,a){b=a.getField("LIST",a);Entry.variableContainer.getList(b).setVisible(!0);return a.callReturn()}; +Entry.block.show_list=function(b,a){var d=a.getField("LIST",a);Entry.variableContainer.getList(d).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(b,a){b=a.getField("LIST",a);Entry.variableContainer.getList(b).setVisible(!1);return a.callReturn()}; +Entry.block.hide_list=function(b,a){var d=a.getField("LIST",a);Entry.variableContainer.getList(d).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(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(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(b,a){b=a.getField("LIST",a);a=a.getStringValue("DATA",a);b=Entry.variableContainer.getList(b);if(!b)return!1;b=b.array_;for(var d=0,c=b.length;db||0>c||b>e||c>e||a.splice.call(this,c,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=a.x&&e-d<=a.y&&e+b.height+d>=a.y}; -Entry.Utils.colorDarken=function(b,a){function d(a){2!=a.length&&(a="0"+a);return a}var c,e;7===b.length?(c=parseInt(b.substr(1,2),16),e=parseInt(b.substr(3,2),16),b=parseInt(b.substr(5,2),16)):(c=parseInt(b.substr(1,2),16),e=parseInt(b.substr(2,2),16),b=parseInt(b.substr(3,2),16));a=void 0===a?.7:a;c=d(Math.floor(c*a).toString(16));e=d(Math.floor(e*a).toString(16));b=d(Math.floor(b*a).toString(16));return"#"+c+e+b}; -Entry.Utils.colorLighten=function(b,a){a=0===a?0:a||20;b=Entry.Utils.hexToHsl(b);b.l+=a/100;b.l=Math.min(1,Math.max(0,b.l));return Entry.Utils.hslToHex(b)};Entry.Utils.bound01=function(b,a){var d=b;"string"==typeof d&&-1!=d.indexOf(".")&&1===parseFloat(d)&&(b="100%");d="string"===typeof b&&-1!=b.indexOf("%");b=Math.min(a,Math.max(0,parseFloat(b)));d&&(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,d;7===b.length?(a=parseInt(b.substr(1,2),16),d=parseInt(b.substr(3,2),16),b=parseInt(b.substr(5,2),16)):(a=parseInt(b.substr(1,2),16),d=parseInt(b.substr(2,2),16),b=parseInt(b.substr(3,2),16));a=Entry.Utils.bound01(a,255);d=Entry.Utils.bound01(d,255);b=Entry.Utils.bound01(b,255);var c=Math.max(a,d,b),e=Math.min(a,d,b),f,g=(c+e)/2;if(c==e)f=e=0;else{var h=c-e,e=.5d&&(d+=1);1d?b:d<2/3?a+(b-a)*(2/3-d)*6:a}function d(a){return 1==a.length?"0"+a:""+a}var c,e;e=Entry.Utils.bound01(b.h,360);c=Entry.Utils.bound01(b.s,1);b=Entry.Utils.bound01(b.l,1);if(0===c)c=b=e=b;else{var f=.5>b?b*(1+c):b+c-b*c,g=2*b-f;c=a(g,f,e+1/3);b=a(g,f,e);e=a(g,f,e-1/3)}b*=255;e*=255;return"#"+[d(Math.round(255*c).toString(16)),d(Math.round(b).toString(16)),d(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 d=0,c=this.events_[b].length;d=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,d){return"#"+(16777216+(b<<16)+(a<<8)+d).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,d){return b>d?d: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={},d;for(d in b)a[d]=b[d];return a};Entry.nodeListToArray=function(b){for(var a=Array(b.length),d=-1,c=b.length;++d!==c;a[d]=b[d]);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 Number(b+10)+"px"};Entry.isArrowOrBackspace=function(b){return-1<[37,38,39,40,8].indexOf(b)};Entry.hexStringToBin=function(b){for(var a=[],d=0;dc&&(c=h.index)}return 0a&&(a=e))}return Math.min(a,20)};Entry.convertToRoundedDecimals=function(b,a){return isNaN(b)||!this.isFloat(b)?b:Number(Math.round(b+"e"+a)+"e-"+a)};Entry.attachEventListener=function(b,a,d){setTimeout(function(){b.addEventListener(a,d)},0)};Entry.deAttachEventListener=function(b,a,d){b.removeEventListener(a,d)}; -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 d(){}d.prototype=b.prototype;a.prototype=new d;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){b=b.elem("defs");var d=b.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=b.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"});a=b.elem("filter",{id:"entryBlockHighlightFilter_"+a});a.elem("feOffset",{result:"offOut",in:"SourceGraphic",dx:0,dy:0});a.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){b=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"});a=b.elem("g");for(var d=a.elem("rect",{x:0,y:0,width:125,height:33}),c=Entry.mediaFilePath+"block_pattern_(order).png",e=1;5>e;e++)a.elem("image",{class:"pattern"+e,href:c.replace("(order)",e),x:0,y:0,width:125,height:33});return{pattern:b,rect:d}}; -Entry.Utils.COLLISION={NONE:0,UP:1,RIGHT:2,LEFT:3,DOWN:4};Entry.Utils.createMouseEvent=function(b,a){var d=document.createEvent("MouseEvent");d.initMouseEvent(b,!0,!0,window,0,0,0,a.clientX,a.clientY,!1,!1,!1,!1,0,null);return d};Entry.Utils.xmlToJsonData=function(b){b=$.parseXML(b);var a=[];b=b.childNodes[0].childNodes;for(var d in b){var c=b[d];if(c.tagName){var e={category:c.getAttribute("id"),blocks:[]},c=c.childNodes;for(d in c){var f=c[d];f.tagName&&(f=f.getAttribute("type"))&&e.blocks.push(f)}a.push(e)}}return a}; -Entry.Utils.stopProjectWithToast=function(b,a,d){var c=b.block;a=a||"\ub7f0\ud0c0\uc784 \uc5d0\ub7ec \ubc1c\uc0dd";Entry.toast&&!d&&Entry.toast.alert(Lang.Msgs.warn,Lang.Workspace.check_runtime_error,!0);Entry.engine&&Entry.engine.toggleStop();"workspace"===Entry.type&&(b.block&&"funcBlock"in b.block?c=b.block.funcBlock:b.funcExecutor&&(c=b.funcExecutor.scope.block,b=b.type.replace("func_",""),Entry.Func.edit(Entry.variableContainer.functions_[b])),c&&(Entry.container.selectObject(c.getCode().object.id, -!0),c.view.getBoard().activateBlock(c)));throw Error(a);};Entry.Utils.AsyncError=function(b){this.name="AsyncError";this.message=b||"\ube44\ub3d9\uae30 \ud638\ucd9c \ub300\uae30"};Entry.Utils.AsyncError.prototype=Error();Entry.Utils.AsyncError.prototype.constructor=Entry.Utils.AsyncError;Entry.Utils.isChrome=function(){return/chrom(e|ium)/.test(navigator.userAgent.toLowerCase())}; -Entry.Utils.waitForWebfonts=function(b,a){for(var d=0,c=0,e=b.length;c=b.length&&(l&&clearInterval(l),d==b.length))return a(),!0}var h=document.createElement("span");h.innerHTML="giItT1WQy@!-/#";h.style.position="absolute";h.style.left="-10000px";h.style.top="-10000px";h.style.fontSize="300px";h.style.fontFamily="sans-serif";h.style.fontVariant="normal";h.style.fontStyle="normal";h.style.fontWeight= -"normal";h.style.letterSpacing="0";document.body.appendChild(h);var k=h.offsetWidth;h.style.fontFamily=c;var l;e()||(l=setInterval(e,50))})(b[c])};window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(b){window.setTimeout(b,1E3/60)}}(); -Entry.isMobile=function(){if(Entry.device)return"tablet"===Entry.device;var b=window.platform;if(b&&b.type&&("tablet"===b.type||"mobile"===b.type))return Entry.device="tablet",!0;Entry.device="desktop";return!1};Entry.Utils.convertMouseEvent=function(b){return b.originalEvent&&b.originalEvent.touches?b.originalEvent.touches[0]:b};Entry.Utils.convertIntToHex=function(b){return b.toString(16).toUpperCase()};Entry.Utils.hasSpecialCharacter=function(b){return/!|@|#|\$|%|\^|&|\*|\(|\)|\+|=|-|\[|\]|\\|\'|;|,|\.|\/|{|}|\||\"|:|<|>|\?/g.test(b)};Entry.Model=function(b,a){var d=Entry.Model;d.generateSchema(b);d.generateSetter(b);d.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 c in b)(function(c){a.data[c]=b[c];Object.defineProperty(a,c,{get:function(){return a.data[c]}})})(c);a._toJSON=this._toJSON}};b.generateSetter=function(a){a.set=this.set};b.set=function(a,b){var c={},e;for(e in this.data)void 0!==a[e]&&(a[e]===this.data[e]?delete a[e]:(c[e]=this.data[e],this.data[e]=a[e]instanceof Array?a[e].concat():a[e]));b||this.notify(Object.keys(a),c)};b.generateObserve= -function(a){a.observers=[];a.observe=this.observe;a.unobserve=this.unobserve;a.notify=this.notify};b.observe=function(a,b,c,e){c=new Entry.Observer(this.observers,a,b,c);if(!1!==e)a[b]([]);return c};b.unobserve=function(a){a.destroy()};b.notify=function(a,b){"string"===typeof a&&(a=[a]);var c=this;c.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:c,oldValue:b[a]}}))})};b._toJSON=function(){var a= -{},b;for(b in this.data)a[b]=this.data[b];return a}})(Entry.Model);Entry.Observer=function(b,a,d,c){this.parent=b;this.object=a;this.funcName=d;this.attrs=c;b.push(this)};(function(b){b.destroy=function(){var a=this.parent,b=a.indexOf(this);-1b||0>c||b>e||c>e||a.splice.call(this,c,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/,c;c=b instanceof HTMLElement?$(b):b instanceof jQuery?b:d.test(b)?$(b):$("<"+b+">");if(void 0===a)return c;a.id&&c.attr("id",a.id);a.class&&c.addClass(a.class);a.classes&&a.classes.map(function(a){c.addClass(a)});a.src&&c.attr("src",a.src);a.parent&&a.parent.append(c);c.bindOnClick=function(){var a,b,d=function(a){a.stopImmediatePropagation();a.handled||(a.handled=!0,b.call(this,a))};1a||4a||(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(b=!1;a&&Entry.engine.isContinue&&!b;){Entry.engine.isContinue=!a.isRepeat;var d=a.run();b=d&&d===a;a=d}return a};Entry.Engine.prototype.isState=function(b){return-1"+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);b.recreateView();a.changeOverlayBoardCode(b);b.view.board.alignThreads();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;b=b.split(" ");var d="",c;c=Blockly.mainWorkspace.getAllBlocks();for(var e=0;eBlockly.Block.dragMode_&&(b.updateMenu(),b.fieldText=a,b.workspaceLength=d)}}; -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=[],c;for(c in a){var e=this.generatePortView(a[c],"_svgGroup");this._portViews[c]=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 c in b)a[c]= -b[c];return a};b.removePortEle=function(a,b){if("object"!=typeof b)return a;for(var c in b)delete a[c];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=[],c;for(c in a){var e=this.generatePortView(a[c],"_svglistGroup");this._listPortViews[c]=e;b.push(e)}var f=this._portMapList; -b.map(function(a){f.n.push(a)});this.resizeList()};b.generatePortView=function(a,b){b=this[b].elem("g");b.addClass("hwComponent");var c;c=this.pathGroup.elem("path").attr({d:"m0,0",fill:"none",stroke:"input"===a.type?"#00979d":"#A751E3","stroke-width":3});var e=b.elem("rect").attr({x:0,y:0,width:150,height:22,rx:4,ry:4,fill:"#fff",stroke:"#a0a1a1"}),f=b.elem("text").attr({x:4,y:12,fill:"#000","class":"hwComponentName","alignment-baseline":"central"});f.textContent=a.name;f=f.getComputedTextLength(); -b.elem("rect").attr({x:f+8,y:2,width:30,height:18,rx:9,ry:9,fill:"input"===a.type?"#00979d":"#A751E3"});var g=b.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:b,value:g,type:a.type,path:c,box:{x:a.pos.x-this._template.width/2,y:a.pos.y-this._template.height/2,width:f},width:f}};b.getView=function(){return this.svgDom};b.update=function(){var a=Entry.hw.portData,b=Entry.hw.sendQueue,c=this._hwModule.monitorTemplate.mode, -e=this._hwModule.monitorTemplate.keys||[],f=[];if("list"==c)f=this._listPortViews;else if("both"==c){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(c=f[h],"input"==c.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(){var a;a=this._hwModule.monitorTemplate.listPorts;for(var b=a.length,c=0;cb-(k.width+l.width/2.2)&&(e+=1,initX=g,f=0)};b._movePort=function(a,b,c,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+","+c+"L"+g+","+h:"M"+(b+e)/2+","+c+"l0,"+(h>c?28:-3)+"H"+g+"L"+g+","+h):b=bc?28:-3)+"H"+g+"L"+g+","+h;a.group.attr({transform:"translate("+f+","+c+")"});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={"1.1":Entry.Arduino,"1.9":Entry.ArduinoExt,"1.2":Entry.SensorBoard,"1.3":Entry.CODEino,"1.4":Entry.joystick,"1.5":Entry.dplay,"1.6":Entry.nemoino,"1.7":Entry.Xbot,"1.8":Entry.ardublock,"1.A":Entry.Cobl,"2.4":Entry.Hamster, -"2.5":Entry.Albert,"3.1":Entry.Bitbrick,"4.2":Entry.Arduino,"5.1":Entry.Neobot,"7.1":Entry.Robotis_carCont,"7.2":Entry.Robotis_openCM70,"8.1":Entry.Arduino,"10.1":Entry.Roborobo_Roduino,"10.2":Entry.Roborobo_SchoolKit,"12.1":Entry.EV3,"B.1":Entry.Codestar}};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,d;this.connected=!1;this.connectTrial++;if(-1"+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:c};"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 c=this.modes[b];c.tabDom.removeClass("selected");c.contentDom.addClass("entryRemove");c.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;"tablet"=== -this.device?this.view_.setAttribute("class","entry tablet"):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")});Entry.addEventListener("showBlockHelper",function(a){Entry.propertyPanel.select("helper")});"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(;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,d=a.length,c=0;c=b&&0=b.keyCode&&CodeMirror.showHint(a,null,{completeSingle:!1,globalScope:c})});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 c=acorn.parse(a),b=this._parser.Program(c)}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,d){1===d&&(a+="\n");return(-1=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,c=this.trashcanTop;b=a?{translateX:15,translateY:-25, -rotateZ:30}:{translateX:0,translateY:0,rotateZ:0};$(c).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,c=b.firstChild;c?b.insertBefore(this.svgGroup,c):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.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);this.textType=Entry.Vim.TEXT_TYPE_PY};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};b.getSelectedBoard=function(){return this.selectedBoard};b.getBlockMenu=function(){return this.blockMenu};b.getVimBoard=function(){return this.vimBoard};b.getMode=function(){return this.mode};b.setMode=function(a,b){"number"===typeof a?this.mode=a:(this.mode=a.boardType,this.runType=a.runType,this.textType=a.textType);switch(this.mode){case this.oldMode:return;case Entry.Workspace.MODE_VIMBOARD:try{this.board&& -this.board.hide(),this.overlayBoard&&this.overlayBoard.hide(),this.set({selectedBoard:this.vimBoard}),this.vimBoard.show(),this.codeToText(this.board.code,a),this.blockMenu.renderText(function(){this.blockMenu.reDraw()}.bind(this)),this.board.clear(),this.oldTextType=this.textType}catch(c){}break;case Entry.Workspace.MODE_BOARD:try{this.board.show(),this.set({selectedBoard:this.board}),this.textToCode(this.oldMode,this.oldTextType),this.vimBoard&&this.vimBoard.hide(),this.overlayBoard&&this.overlayBoard.hide(), -this.blockMenu.renderBlock(function(){this.blockMenu.reDraw()}.bind(this)),this.oldTextType=this.textType}catch(c){this.board&&this.board.hide(),this.set({selectedBoard:this.vimBoard}),this.mode=Entry.Workspace.MODE_VIMBOARD,this.oldTextType==Entry.Vim.PARSER_TYPE_JS_TO_BLOCK?(a.boardType=Entry.Workspace.MODE_VIMBOARD,a.textType=Entry.Vim.TEXT_TYPE_JS,a.runType=Entry.Vim.MAZE_MODE,this.oldTextType=Entry.Vim.PARSER_TYPE_JS_TO_BLOCK,Entry.dispatchEvent("changeMode",a),Ntry.dispatchEvent("textError", -a)):this.oldTextType==Entry.Vim.PARSER_TYPE_PY_TO_BLOCK&&(a.boardType=Entry.Workspace.MODE_VIMBOARD,a.textType=Entry.Vim.TEXT_TYPE_PY,a.runType=Entry.Vim.WORKSPACE_MODE,this.oldTextType=Entry.Vim.PARSER_TYPE_PY_TO_BLOCK,Entry.dispatchEvent("changeMode",a))}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.oldMode=this.mode;this.changeEvent.notify(b)};b.changeBoardCode=function(a){this._syncTextCode();this.board.changeCode(a);this.mode===Entry.Workspace.MODE_VIMBOARD&&this.codeToText(this.board.code)};b.changeOverlayBoardCode=function(a){this.overlayBoard&&this.overlayBoard.changeCode(a)};b.changeBlockMenuCode=function(a){this.blockMenu.changeCode(a)};b.textToCode=function(a,b){if(a==Entry.Workspace.MODE_VIMBOARD){var c=this;a=this.vimBoard.textToCode(b);b=this.board;var e=b.code; -e.load(a);e.createView(b);this.board.reDraw();setTimeout(function(){c.board.alignThreads()},0)}};b.codeToText=function(a,b){return this.vimBoard.codeToText(a,b)};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,c=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()):c&&(67==b?e.block.copyToClipboard():88==b&&(a=e.block,a.copyToClipboard(), -a.destroy(!0,!0),e.getBoard().setSelectedBlock(null))));c&&86==b&&(b=this.selectedBoard)&&b instanceof Entry.Board&&Entry.clipboard&&Entry.do("addThread",Entry.clipboard).value.getFirstBlock().copyToClipboard()}};b._handleChangeBoard=function(){var a=this.selectedBoard;a&&a.constructor===Entry.Board&&this.trashcan.setBoard(a)};b._syncTextCode=function(){if(this.mode===Entry.Workspace.MODE_VIMBOARD){var a=this.vimBoard.textToCode(this.textType),b=this.board,c=b.code;c.load(a);c.createView(b);this.board.alignThreads()}}; -b.addVimBoard=function(a){this.vimBoard||(this.vimBoard=new Entry.Vim(a),this.vimBoard.workspace=this,this.vimBoard.hide())}})(Entry.Workspace.prototype);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 c={type:a.getAttribute("type"),index:{}};a=$(a).children();if(!a)return c;for(var e=0;e"+a[1], -b.addEventListener("click",function(){Entry.engine.toggleStop()}),this.view_.appendChild(b),this.curtainView_=b,Entry.pictureEditable&&(b=Entry.createElement("div","entryPicture"),b.addClass("entryPlaygroundPictureWorkspace"),b.addClass("entryRemove"),this.view_.appendChild(b),this.generatePictureView(b),this.pictureView_=b),b=Entry.createElement("div","entryText"),b.addClass("entryPlaygroundTextWorkspace"),b.addClass("entryRemove"),this.view_.appendChild(b),this.generateTextView(b),this.textView_= -b,Entry.soundEditable&&(b=Entry.createElement("div","entrySound"),b.addClass("entryPlaygroundSoundWorkspace"),b.addClass("entryRemove"),this.view_.appendChild(b),this.generateSoundView(b),this.soundView_=b),b=Entry.createElement("div","entryDefault"),b.addClass("entryPlaygroundDefaultWorkspace"),this.view_.appendChild(b),this.generateDefaultView(b),this.defaultView_=b,b=Entry.createElement("div","entryCode"),b.addClass("entryPlaygroundCodeWorkspace"),b.addClass("entryRemove"),this.view_.appendChild(b), -this.generateCodeView(b),this.codeView_=b,a=Entry.createElement("div"),a.addClass("entryPlaygroundResizeWorkspace","entryRemove"),this.resizeHandle_=a,this.view_.appendChild(a),this.initializeResizeHandle(a),this.codeView_=b,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,d=Entry.createElement("ul");d.addClass("entryTabListWorkspace");this.tabList_=d;b.appendChild(d);this.tabViewElements={};b=Entry.createElement("li","entryCodeTab");b.innerHTML=Lang.Workspace.tab_code;b.addClass("entryTabListItemWorkspace");b.addClass("entryTabSelected");d.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"),d.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"),d.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"),d.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"),d.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 d=Entry.createElement("div","entryAddPictureInner");d.addClass("entryPlaygroundAddPictureInner");d.innerHTML=Lang.Workspace.picture_add;a.appendChild(d);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){a=b.item.data("start_pos");b=b.item.index();Entry.playground.movePicture(a,b)},axis:"y"});b.appendChild(a);this.pictureListView_=a;a=Entry.createElement("div","entryPainter");a.addClass("entryPlaygroundPainter");b.appendChild(a);this.painter=new Entry.Painter2(a)}else"phone"==Entry.type&&(a=Entry.createElement("div","entryAddPicture"),a.addClass("entryPlaygroundAddPicturePhone"),a.bindOnClick(function(a){Entry.dispatchEvent("openPictureManager")}), -d=Entry.createElement("div","entryAddPictureInner"),d.addClass("entryPlaygroundAddPictureInnerPhone"),d.innerHTML=Lang.Workspace.picture_add,a.appendChild(d),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){a=b.item.data("start_pos");b=b.item.index();Entry.playground.movePicture(a,b)},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 d=Entry.createElement("div");d.addClass("entryTextFontSelect");b.appendChild(d);var c=Entry.createElement("select","entryPainterAttrFontName");c.addClass("entryPlaygroundPainterAttrFontName","entryTextFontSelecter");c.size="1";c.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,d=0,c=a.length;d"+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:c};"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 c=this.modes[b];c.tabDom.removeClass("selected");c.contentDom.addClass("entryRemove");c.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.Reporter=function(b){this.projectId=this.userId=null;this.isRealTime=b;this.activities=[]};Entry.Reporter.prototype.start=function(b,a,d){this.isRealTime&&(-1f+55)&&a>40+b*(g-f)&&(g=d.getNextScene())&&(g=$(g.view),$(document).trigger("mouseup"), -g.trigger("mousedown"))}),b=Entry.createElement("ul"),b.addClass("entrySceneListWorkspace"),Entry.sceneEditable&&$&&$(b).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(b),this.listView_=b,Entry.sceneEditable&&(b=Entry.createElement("span"),b.addClass("entrySceneElementWorkspace"),b.addClass("entrySceneAddButtonWorkspace"), -b.bindOnClick(function(a){Entry.engine.isState("run")||Entry.scene.addScene()}),this.view_.appendChild(b),this.addButton_=b))}; +Entry.Scene.prototype.generateView=function(b,a){var d=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(),c=$(window),h=a.pageX-b.left+c.scrollLeft();a=a.pageY-b.top+c.scrollTop();a=40-a;b=-40/55;c=$(d.selectedScene.view).find(".entrySceneRemoveButtonCoverWorkspace").offset().left;!(hc+55)&&a>40+b*(h-c)&&(h=d.getNextScene())&&(h=$(h.view),$(document).trigger("mouseup"), +h.trigger("mousedown"))});var c=Entry.createElement("ul");c.addClass("entrySceneListWorkspace");Entry.sceneEditable&&$&&$(c).sortable({start:function(a,b){b.item.data("start_pos",b.item.index());$(b.item[0]).clone(!0)},stop:function(a,b){var d=b.item.data("start_pos"),c=b.item.index();Entry.scene.moveScene(d,c)},axis:"x",tolerance:"pointer"});this.view_.appendChild(c);this.listView_=c;Entry.sceneEditable&&(c=Entry.createElement("span"),c.addClass("entrySceneElementWorkspace"),c.addClass("entrySceneAddButtonWorkspace"), +c.bindOnClick(function(a){Entry.engine.isState("run")||Entry.scene.addScene()}),this.view_.appendChild(c),this.addButton_=c)}}; Entry.Scene.prototype.generateElement=function(b){var a=this,d=Entry.createElement("li",b.id);d.addClass("entrySceneElementWorkspace");d.addClass("entrySceneButtonWorkspace");d.addClass("minValue");$(d).on("mousedown",function(a){Entry.engine.isState("run")?a.preventDefault():Entry.scene.selectScene(b)});var c=Entry.createElement("input");c.addClass("entrySceneFieldWorkspace");c.value=b.name;Entry.sceneEditable||(c.disabled="disabled");var e=Entry.createElement("span");e.addClass("entrySceneLeftWorkspace"); d.appendChild(e);var f=Entry.createElement("span");f.addClass("entrySceneInputCover");f.style.width=Entry.computeInputWidth(b.name);d.appendChild(f);b.inputWrapper=f;c.onkeyup=function(d){d=d.keyCode;Entry.isArrowOrBackspace(d)||(b.name=this.value,f.style.width=Entry.computeInputWidth(b.name),a.resize(),13==d&&this.blur(),10"==a||"<"==a||">="==a||"<="==a||"+"==a||"-"==a||"*"==a||"/"==a?!0:!1};b.binaryOperatorConvert= -function(a){switch(a){case "==":a="EQUAL";break;case ">":a="GREATER";break;case "<":a="LESS";break;case ">=":a="GREATER_OR_EQUAL";break;case "<=":a="LESS_OR_EQUAL";break;case "+":a="PLUS";break;case "-":a="MINUS";break;case "*":a="MULTIFLY";break;case "/":a="DIVIDE";break}return a};b.logicalExpressionConvert=function(a){switch(a){case "&&":a=null;break;case "||":a=null;break}return a};b.dropdownDynamicValueConvertor=function(a,b){var c=b.options,e;for(e in c){var f=c[e];if("null"==f[1])return c={}; -if("mouse"==a||"wall"==a||"wall_up"==a||"wall_down"==a||"wall_right"==a||"wall_left"==a)return a;if(a==f[1])return console.log("dropdownDynamicValueConvertor value",a,f[1]),c=f[0]}c=a;if("variables"==b.menuName){var g=Entry.variableContainer.variables_,h;for(h in g){var k=g[h];if(k.id_==a){c=k.name_;break}}}else if("lists"==b.menuName)for(h in g=Entry.variableContainer.lists,g){if(k=g[h],k.id_==a){c=k.name_;break}}else if("pictures"==b.menuName)for(g in h=Entry.container.getAllObjects(),h)for(k in b= -h[g],b=b.pictures,b){if(e=b[k],e.id==a)return c=e.name}else if("sounds"==b.menuName)for(g in h=Entry.container.getAllObjects(),h)for(k in b=h[g],b=b.sounds,b)if(e=b[k],e.id==a)return c=e.name;return c};b.binaryOperatorValueConvertor=function(a){switch(a){case "EQUAL":a="==";break;case "GREATER":a=">";break;case "LESS":a="<";break;case "GREATER_OR_EQUAL":a=">=";break;case "LESS_OR_EQUAL":a="<=";break;case "\uadf8\ub9ac\uace0":a="&&";break;case "\ub610\ub294":a="||";break;case "PLUS":a="+";break;case "MINUS":a= +function(a){switch(a){case "==":a="EQUAL";break;case ">":a="GREATER";break;case "<":a="LESS";break;case ">=":a="GREATER_OR_EQUAL";break;case "<=":a="LESS_OR_EQUAL";break;case "+":a="PLUS";break;case "-":a="MINUS";break;case "*":a="MULTIFLY";break;case "/":a="DIVIDE";break}return a};b.logicalExpressionConvert=function(a){switch(a){case "&&":a=null;break;case "||":a=null;break}return a};b.dropdownDynamicValueConvertor=function(a,b){var c=b.options,e=null,f;for(f in c){e=c[f];if("null"==e[1])return e= +{};if("mouse"==a||"wall"==a||"wall_up"==a||"wall_down"==a||"wall_right"==a||"wall_left"==a)return a;if(a==e[1])return console.log("dropdownDynamicValueConvertor value",a,e[1]),e=e[0]}e=a;if("variables"==b.menuName){var g=Entry.variableContainer.variables_,h;for(h in g){var k=g[h];if(k.id_==a){e=k.name_;break}}}else if("lists"==b.menuName)for(h in g=Entry.variableContainer.lists,g){if(k=g[h],k.id_==a){e=k.name_;break}}else if("pictures"==b.menuName)for(g in h=Entry.container.getAllObjects(),h)for(k in c= +h[g],c=c.pictures,c){if(f=c[k],f.id==a)return e=f.name}else if("sounds"==b.menuName)for(g in h=Entry.container.getAllObjects(),h)for(k in c=h[g],c=c.sounds,c)if(f=c[k],f.id==a)return e=f.name;return e};b.binaryOperatorValueConvertor=function(a){switch(a){case "EQUAL":a="==";break;case "GREATER":a=">";break;case "LESS":a="<";break;case "GREATER_OR_EQUAL":a=">=";break;case "LESS_OR_EQUAL":a="<=";break;case "\uadf8\ub9ac\uace0":a="&&";break;case "\ub610\ub294":a="||";break;case "PLUS":a="+";break;case "MINUS":a= "-";break;case "MULTI":a="*";break;case "DIVIDE":a="/";break}return a};b.variableFilter=function(a,b,c){var e=c;a=a.data.type;"change_variable"==a||"set_variable"==a||"get_variable"==a?1==b&&(e=eval(c)):"length_of_list"==a||"is_included_in_list"==a?2==b&&(e=eval(c)):"value_of_index_from_list"==a?2==b?e=eval(c):4==b&&this.isNumeric(c)&&(e=c-1):"remove_value_from_list"==a?2==b?e=eval(c):1==b&&this.isNumeric(c)&&(e=c-1):"insert_value_to_list"==a?2==b?e=eval(c):3==b&&this.isNumeric(c)&&(e=c-1):"change_value_list_index"== a?1==b?e=eval(c):2==b&&this.isNumeric(c)&&(e=c-1):"add_value_to_list"==a&&2==b&&(e=eval(c));return e};b.isGlobalVariableExisted=function(a){var b=Entry.variableContainer.variables_,c;for(c in b){var e=b[c];if(null===e.object_&&e.name_==a)return!0}return!1};b.updateGlobalVariable=function(a,b){var c=Entry.variableContainer.variables_,e;for(e in c){var f=c[e];if(null===f.object_&&f.name_==a){variable={x:f.x_,y:f.y_,id:f.id_,visible:f.visible_,value:b,name:a,isCloud:f.isClud_};f.syncModel_(variable); Entry.variableContainer.updateList();break}}};b.createGlobalVariable=function(a,b){this.isGlobalVariableExisted(a)||(Entry.variableContainer.addVariable({name:a,value:b,variableType:"variable"}),Entry.variableContainer.updateList())};b.isLocalVariableExisted=function(a,b){var c=Entry.variableContainer.variables_,e;for(e in c){var f=c[e];if(f.object_===b.id&&f.name_==a)return!0}return!1};b.updateLocalVariable=function(a,b,c){var e=Entry.variableContainer.variables_,f;for(f in e){var g=e[f];if(g.object_=== @@ -1421,30 +1181,26 @@ a?!0:!1};b.searchFuncDefParam=function(a){"function_field_label"==a.data.type&&t "function_field_boolean"!=a.data.type||this._funcParamQ.enqueue(b)}else"function_field_label"==a.data.type&&this._funcNameQ.enqueue(a.data.params[0]);if(a.data.params[1]){var c=this.searchFuncDefParam(a.data.params[1]);c.data.params[0].data&&(b=c.data.params[0].data.type,"function_field_string"!=c.data.type&&"function_field_boolean"!=c.data.type||this._funcParamQ.enqueue(b));c.data.params[1]&&c.data.params[1].data.params[0].data&&(b=c.data.params[1].data.params[0].data.type,"function_field_string"!= c.data.params[1].data.type&&"function_field_boolean"!=c.data.params[1].data.type||this._funcParamQ.enqueue(b))}}return c};b.getLastParam=function(a){a&&a.data&&a.data.params[1]&&(a=this.getLastParam(a.data.params[1]));return a};b.isFuncContentsMatch=function(a,b,c){for(var e=!0,f=0;f":b="BIGGER";break;case ">=":b="BIGGER_EQUAL";break;case "==":b="EQUAL";break;case "<":b="SMALLER"; +a.type;return"ai_boolean_distance"==a||"ai_distance_value"==a||"ai_boolean_object"==a||"ai_boolean_and"==a?!0:!1};b.hasBlockInfo=function(a,b){var c=!1,e;for(e in b){var f=b[e];if(e==a.type)for(var g in f){var h=f[g];if(h.start==a.start&&h.end==a.end){c=!0;break}}}return c};b.updateBlockInfo=function(a,b){var c=b[a.type];if(c&&Array.isArray(c)&&0!=c.legnth)for(var e in c){var f=c[e];if(f.start==a.start&&f.end==a.end)break;else f={},f.start=a.start,f.end=a.end,c.push(f)}else b[a.type]=[],f={},f.start= +a.start,f.end=a.end,b[a.type].push(f)};b.jsAdjustSyntax=function(a,b){var c="";if("ai_boolean_distance"==a.data.type){var e=b.split(" "),c=e[0].split("_");c[1]=c[1].substring(1,c[1].length-1);c[1]=c[1].toLowerCase();var c=c.join("_"),f=e[1],f=this.bTojBinaryOperatorConvertor(f),e=e[2],c=c+" "+f+" "+e}else"ai_boolean_object"==a.data.type?(e=b.split(" "),c=e[0].split("_"),c[1]=c[1].substring(1,c[1].length-1),c[1]=c[1].toLowerCase(),c=c.join("_"),f=e[1],e=e[2],c=c+" "+f+" "+e):"ai_distance_value"==a.data.type? +(e=b.split(" "),c=e[0].split("_"),c[1]=c[1].substring(1,c[1].length-1),c[1]=c[1].toLowerCase(),c=c.join("_")):c=b;return c};b.bTojBinaryOperatorConvertor=function(a){var b;switch(a){case "'BIGGER'":b=">";break;case "'BIGGER_EQUAL'":b=">=";break;case "'EQUAL'":b="==";break;case "'SMALLER'":b="<";break;case "'SMALLER_EQUAL'":b="<="}return b};b.jTobBinaryOperatorConvertor=function(a){var b;switch(a){case ">":b="BIGGER";break;case ">=":b="BIGGER_EQUAL";break;case "==":b="EQUAL";break;case "<":b="SMALLER"; break;case "<=":b="SMALLER_EQUAL"}return b};b.radarVariableConvertor=function(a){return a.split("_")[1].toUpperCase()};b.tTobDropdownValueConvertor=function(a){return"stone"==a?"OBSTACLE":"wall"==a?a.toUpperCase():"item"==a?a.toUpperCase():a}})(Entry.TextCodingUtil.prototype);Entry.BlockToJsParser=function(b){this.syntax=b;this._iterVariableCount=0;this._iterVariableChunk=["i","j","k"]}; -(function(b){b.Code=function(a,b){this._parseMode=b;if(a instanceof Entry.Block)return this.Block(a);b="";a=a._data;for(var c=0;c >= << >> >>> + - * / % , ^ & 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.BinaryExpression=function(a){var b,c={};b=String(a.operator);var e=a.left.name;switch(b){case "==":var f="object_up"==e||"object_right"==e||"object_down"==e?"ai_boolean_object":"radar_up"==e||"radar_right"==e||"radar_down"==e?"ai_boolean_distance": -null;break;case "<":f="ai_boolean_distance";break;case "<=":f="ai_boolean_distance";break;case ">":f="ai_boolean_distance";break;case ">=":f="ai_boolean_distance"}if(f){e=[];b=a.left;if("Literal"==b.type||"Identifier"==b.type){arguments=[];arguments.push(b);b=Entry.block[f].params;for(var g in b){var h=b[g].type;"Indicator"==h?(h={raw:null,type:"Literal",value:null},g>= >>>= ,= ^= &=".split(" ")};b.BinaryExpression=function(a){var b={},c={},b=String(a.operator),e=a.left.name;switch(b){case "==":var f="object_up"==e||"object_right"==e||"object_down"==e?"ai_boolean_object":"radar_up"==e||"radar_right"==e||"radar_down"==e?"ai_boolean_distance": +null;break;case "<":f="ai_boolean_distance";break;case "<=":f="ai_boolean_distance";break;case ">":f="ai_boolean_distance";break;case ">=":f="ai_boolean_distance"}if(f){e=[];b=a.left;if("Literal"==b.type||"Identifier"==b.type){arguments=[];arguments.push(b);var b=Entry.block[f].params,g;for(g in b){var h=b[g].type;"Indicator"==h?(h={raw:null,type:"Literal",value:null},g=b.keyCode||167==b.keyCode||190==b.keyCode)&&CodeMirror.showHint(a,null,{completeSingle:!1,globalScope:e})});break;case "blockJs":this._parser=new Entry.BlockToJsParser(this.syntax);c=this.syntax;break;case "blockPy":this._parser= new Entry.BlockToPyParser(this.syntax),c=this.syntax}}; (function(b){b.setParser=function(a,b,c){this._mode=a;this._type=b;this._cm=c;this.syntax=this.mappingSyntax(a);switch(b){case Entry.Vim.PARSER_TYPE_JS_TO_BLOCK:this._parser=new Entry.JsToBlockParser(this.syntax);this._parserType=Entry.Vim.PARSER_TYPE_JS_TO_BLOCK;break;case Entry.Vim.PARSER_TYPE_PY_TO_BLOCK:this._parser=new Entry.PyToBlockParser(this.syntax);this._parserType=Entry.Vim.PARSER_TYPE_PY_TO_BLOCK;break;case Entry.Vim.PARSER_TYPE_BLOCK_TO_JS:this._parser=new Entry.BlockToJsParser(this.syntax); a=this.syntax;var e={},f;for(f in a.Scope)e[f+"();\n"]=a.Scope[f];c.on("keydown",function(a,b){var d=b.keyCode;(65<=d&&95>=d||167==d||!b.shiftKey&&190==d)&&CodeMirror.showHint(a,null,{completeSingle:!1,globalScope:e})});this._parserType=Entry.Vim.PARSER_TYPE_JS_TO_BLOCK;break;case Entry.Vim.PARSER_TYPE_BLOCK_TO_PY:this._parser=new Entry.BlockToPyParser(this.syntax),c.setOption("mode",{name:"python",globalVars:!0}),c.markText({line:0,ch:0},{line:5},{readOnly:!0}),this._parserType=Entry.Vim.PARSER_TYPE_BLOCK_TO_PY}}; -b.parse=function(a,b){var c=null;switch(this._type){case Entry.Vim.PARSER_TYPE_JS_TO_BLOCK:try{var e=[];e.push(a);var f=[],g;for(g in e){var h=e[g],h=h.trim(),k=acorn.parse(h);f.push(k)}c=this._parser.Program(f)}catch(q){if(this.codeMirror){q instanceof SyntaxError?(a={from:{line:q.loc.line-1,ch:0},to:{line:q.loc.line-1,ch:q.loc.column}},q.message="\ubb38\ubc95(Syntax) \uc624\ub958\uc785\ub2c8\ub2e4.",q.type=1):(a=this.getLineNumber(q.node.start,q.node.end),a.message=q.message,a.severity="converting error", -q.type=2);this.codeMirror.markText(a.from,a.to,{className:"CodeMirror-lint-mark-error",__annotation:a,clearOnEnter:!0});a=q.title?q.title:"\ubb38\ubc95 \uc624\ub958";if(2==q.type&&q.message)var l=q.message;else 2!=q.type||q.message?1==q.type&&(l="\uc790\ubc14\uc2a4\ud06c\ub9bd\ud2b8 \ubb38\ubc95\uc744 \ud655\uc778\ud574\uc8fc\uc138\uc694."):l="\uc790\ubc14\uc2a4\ud06c\ub9bd\ud2b8 \ucf54\ub4dc\ub97c \ud655\uc778\ud574\uc8fc\uc138\uc694.";Entry.toast.alert(a,l);l={};l.boardType=Entry.Workspace.MODE_BOARD; +b.parse=function(a,b){var c=null;switch(this._type){case Entry.Vim.PARSER_TYPE_JS_TO_BLOCK:try{var e=[];e.push(a);var f=[],g;for(g in e){var h=e[g],h=h.trim(),k=acorn.parse(h);f.push(k)}c=this._parser.Program(f)}catch(q){if(this.codeMirror){q instanceof SyntaxError?(c={from:{line:q.loc.line-1,ch:0},to:{line:q.loc.line-1,ch:q.loc.column}},q.message="\ubb38\ubc95(Syntax) \uc624\ub958\uc785\ub2c8\ub2e4.",q.type=1):(c=this.getLineNumber(q.node.start,q.node.end),c.message=q.message,c.severity="converting error", +q.type=2);this.codeMirror.markText(c.from,c.to,{className:"CodeMirror-lint-mark-error",__annotation:c,clearOnEnter:!0});c=q.title?q.title:"\ubb38\ubc95 \uc624\ub958";if(2==q.type&&q.message)var l=q.message;else 2!=q.type||q.message?1==q.type&&(l="\uc790\ubc14\uc2a4\ud06c\ub9bd\ud2b8 \ubb38\ubc95\uc744 \ud655\uc778\ud574\uc8fc\uc138\uc694."):l="\uc790\ubc14\uc2a4\ud06c\ub9bd\ud2b8 \ucf54\ub4dc\ub97c \ud655\uc778\ud574\uc8fc\uc138\uc694.";Entry.toast.alert(c,l);l={};l.boardType=Entry.Workspace.MODE_BOARD; l.textType=Entry.Vim.TEXT_TYPE_JS;l.runType=Entry.Vim.MAZE_MODE;Ntry.dispatchEvent("textError",l);throw q;}c=[]}break;case Entry.Vim.PARSER_TYPE_PY_TO_BLOCK:try{var m=new Entry.PyAstGenerator,e=a.split("\n\n"),n;for(n in e)h=e[n],-1!=h.search("import")?e[n]="":(h=Entry.TextCodingUtil.prototype.entryEventFuncFilter(h),e[n]=h);f=[];for(g in e)h=e[g],k=m.generate(h),"Program"==k.type&&0!=k.body.length&&f.push(k);c=this._parser.Program(f);this._parser._variableMap.clear()}catch(q){if(this.codeMirror)throw q instanceof -SyntaxError?(a={from:{line:q.loc.line-1,ch:q.loc.column-2},to:{line:q.loc.line-1,ch:q.loc.column+1}},q.message="\ubb38\ubc95 \uc624\ub958\uc785\ub2c8\ub2e4."):(a=this.getLineNumber(q.node.start,q.node.end),a.message=q.message,a.severity="error"),l=parseInt(a.to.line)+1,a.from.line=l-1,a.to.line=l,this.codeMirror.markText(a.from,a.to,{className:"CodeMirror-lint-mark-error",__annotation:a,clearOnEnter:!0}),a=q.title?q.title:"\ubb38\ubc95 \uc624\ub958",l=q.message&&l?q.message+" (line: "+l+")":"\ud30c\uc774\uc36c \ucf54\ub4dc\ub97c \ud655\uc778\ud574\uc8fc\uc138\uc694", -Entry.toast.alert(a,l),q;c=[]}break;case Entry.Vim.PARSER_TYPE_BLOCK_TO_JS:c=l=this._parser.Code(a,b);break;case Entry.Vim.PARSER_TYPE_BLOCK_TO_PY:l=this._parser.Code(a,b),this._pyHinter||(this._pyHinter=new Entry.PyHint),c=l}return c};b.getLineNumber=function(a,b){var c=this.codeMirror.getValue(),e={from:{},to:{}};a=c.substring(0,a).split(/\n/gi);e.from.line=a.length-1;e.from.ch=a[a.length-1].length;b=c.substring(0,b).split(/\n/gi);e.to.line=b.length-1;e.to.ch=b[b.length-1].length;return e};b.mappingSyntax= +SyntaxError?(c={from:{line:q.loc.line-1,ch:q.loc.column-2},to:{line:q.loc.line-1,ch:q.loc.column+1}},q.message="\ubb38\ubc95 \uc624\ub958\uc785\ub2c8\ub2e4."):(c=this.getLineNumber(q.node.start,q.node.end),c.message=q.message,c.severity="error"),l=parseInt(c.to.line)+1,c.from.line=l-1,c.to.line=l,this.codeMirror.markText(c.from,c.to,{className:"CodeMirror-lint-mark-error",__annotation:c,clearOnEnter:!0}),c=q.title?q.title:"\ubb38\ubc95 \uc624\ub958",l=q.message&&l?q.message+" (line: "+l+")":"\ud30c\uc774\uc36c \ucf54\ub4dc\ub97c \ud655\uc778\ud574\uc8fc\uc138\uc694", +Entry.toast.alert(c,l),q;c=[]}break;case Entry.Vim.PARSER_TYPE_BLOCK_TO_JS:c=l=this._parser.Code(a,b);break;case Entry.Vim.PARSER_TYPE_BLOCK_TO_PY:l=this._parser.Code(a,b),this._pyHinter||(this._pyHinter=new Entry.PyHint),c=l}return c};b.getLineNumber=function(a,b){var c=this.codeMirror.getValue(),e={from:{},to:{}},f=c.substring(0,a).split(/\n/gi);e.from.line=f.length-1;e.from.ch=f[f.length-1].length;c=c.substring(0,b).split(/\n/gi);e.to.line=c.length-1;e.to.ch=c[c.length-1].length;return e};b.mappingSyntax= function(a){for(var b=Object.keys(Entry.block),c={},e=0;ec.style.opacity&&(clearInterval(a),c.style.display="none",Entry.removeElement(c));c.style.opacity*=.9},20)},1E3)}; Entry.Toast.prototype.alert=function(b,a,d){var c=Entry.createElement("div","entryToast");c.addClass("entryToast");c.addClass("entryToastAlert");c.bindOnClick(function(){Entry.toast.body_.removeChild(this)});var e=Entry.createElement("div","entryToast");e.addClass("entryToastTitle");e.innerHTML=b;c.appendChild(e);b=Entry.createElement("p","entryToast");b.addClass("entryToastMessage");b.innerHTML=a;c.appendChild(b);this.toasts_.push(c);this.body_.appendChild(c);d||window.setTimeout(function(){c.style.opacity= 1;var a=setInterval(function(){.05>c.style.opacity&&(clearInterval(a),c.style.display="none",Entry.toast.body_.removeChild(c));c.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.ContextMenu={}; +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 c={type:a.getAttribute("type"),index:{}};a=$(a).children();if(!a)return c;for(var e=0;eg&&(a.x-=c+3);a.y+e>f&&(a.y-=e);b.css({left:a.x,top:a.y})};b.hide=function(){this.visible=!1;this.dom.empty();this.dom.addClass("entryRemove");this._className&&(this.dom.removeClass(this._className),delete this._className);this._hideEvent&&(Entry.documentMousedown.detach(this._hideEvent),this._hideEvent=null)}})(Entry.ContextMenu);Entry.Loader={queueCount:0,totalCount:0,loaded:!1};Entry.Loader.addQueue=function(b){this.queueCount||Entry.dispatchEvent("loadStart");this.queueCount++;this.totalCount++};Entry.Loader.removeQueue=function(b){this.queueCount--;this.queueCount||(this.totalCount=0,this.handleLoad())};Entry.Loader.getLoadedPercent=function(){return 0===this.totalCount?1:this.queueCount/this.totalCount};Entry.Loader.isLoaded=function(){return!this.queueCount&&!this.totalCount}; -Entry.Loader.handleLoad=function(){this.loaded||(this.loaded=!0,Entry.dispatchEvent("loadComplete"))};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 a=Entry.parseNumber(b.value);this.value_="number"==typeof a?a:b.value?b.value:0;"slide"==this.type?(this.setMinValue(b.minValue),this.setMaxValue(b.maxValue)):"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",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"==a){var d=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(a){"workspace"==Entry.type&&(this.offset={x:this.x-(.75*a.stageX-240),y:this.y-(.75*a.stageY-135)})});this.view_.on("pressmove",function(a){"workspace"!=Entry.type||d.isAdjusting||(this.variable.setX(.75*a.stageX-240+this.offset.x),this.variable.setY(.75*a.stageY-135+this.offset.y),this.variable.updateView())}); -this.view_.visible=this.visible_;this.view_.addChild(this.valueView_);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_);a=this.getSlidePosition(this.maxWidth);this.valueSetter_=new createjs.Shape;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")&&(d.isAdjusting=!0,this.offsetX=-(this.x-.75*a.stageX+240))});this.valueSetter_.on("pressmove",function(a){if(Entry.engine.isState("run")){var b=this.offsetX;this.offsetX=-(this.x-.75*a.stageX+240);b!==this.offsetX&&(a=d.getX(),d.setSlideCommandX(a+10>this.offsetX?0:a+d.maxWidth+10>this.offsetX?this.offsetX-a:d.maxWidth+10))}});this.valueSetter_.on("pressup",function(a){d.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();var b=this.textView_.text,a;a=this.object_?(a=Entry.container.getObject(this.object_))?a.name+":"+this.getName():this.getName():this.getName();b!==a&&(this.textView_.text=a,this._nameWidth=null);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(), -b=this.textView_.text,a=this.object_?(a=Entry.container.getObject(this.object_))?a.name+":"+this.getName():this.getName():this.getName(),b!==a&&(this.textView_.text=a,this._nameWidth=null),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;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-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;ad.length?d+"..":d;this.elementView.valueView.text=d;d=this.elementView.clone(!0);d.y=20*(a-this.scrollPosition)+23;this.view_.addChild(d)}}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(b){Entry.assert("string"==typeof b,"Variable name must be string");this.name_=b;this._nameWidth=null;this.updateView();Entry.requestUpdateTwice=!0};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(b){"slide"!=this.type?this.value_=b:(b=Number(b),this.value_=bthis.maxValue_?this.maxValue_:b);this.isCloud_&&Entry.variableContainer.updateCloudVariables();this._valueWidth=null;this.updateView();Entry.requestUpdateTwice=!0};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!==b&&(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.Loader.handleLoad=function(){this.loaded||(this.loaded=!0,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,COMMAND_TYPES:{addThread:101,destroyThread:102,destroyBlock:103,recoverBlock:104,insertBlock:105,separateBlock:106,moveBlock:107,cloneBlock:108,uncloneBlock:109,scrollBoard:110,setFieldValue:111,selectObject:201,"do":301,undo:302,redo:303,editPicture:401, +uneditPicture:402,processPicture:403,unprocessPicture:404}};Entry.Command={};(function(b){b.do={type:Entry.STATIC.COMMAND_TYPES["do"],log:function(a){return[b["do"].type]}};b.undo={type:Entry.STATIC.COMMAND_TYPES.undo,log:function(a){return[b.undo.type]}};b.redo={type:Entry.STATIC.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}; +(function(b){b.do=function(a){var b=this,c=Array.prototype.slice.call(arguments);c.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,c)));e=Entry.Command[a].do.apply(this,c);setTimeout(function(){b.report("do");b.report(a,c)},0);return{value:e,isPass:this.isPass.bind(this)}};b.undo=function(){var a=Array.prototype.slice.call(arguments),b=a.shift(),c=Entry.Command[b];this.report("undo");Entry.stateManager&& +Entry.stateManager.addCommand.apply(Entry.stateManager,[b,this,this.do,c.undo].concat(c.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(),c=Entry.Command[b];that.report("redo");Entry.stateManager&&Entry.stateManager.addCommand.apply(Entry.stateManager,[b,this,this.undo,b].concat(c.state.apply(null,a)));c.undo.apply(this,a)};b.setCurrentEditor=function(a,b){this.editor[a]=b}; +b.isPass=function(a){a=void 0===a?!0:a;if(Entry.stateManager){var b=Entry.stateManager.getLastCommand();b&&(b.isPass=a)}};b.addReporter=function(a){this.reporters.push(a)};b.removeReporter=function(a){a=this.reporters.indexOf(a);-1=a.x&&e-d<=a.y&&e+b.height+d>=a.y}; +Entry.Utils.colorDarken=function(b,a){function d(a){2!=a.length&&(a="0"+a);return a}var c,e,f;7===b.length?(c=parseInt(b.substr(1,2),16),e=parseInt(b.substr(3,2),16),f=parseInt(b.substr(5,2),16)):(c=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;c=d(Math.floor(c*a).toString(16));e=d(Math.floor(e*a).toString(16));f=d(Math.floor(f*a).toString(16));return"#"+c+e+f}; +Entry.Utils.colorLighten=function(b,a){a=0===a?0:a||20;var d=Entry.Utils.hexToHsl(b);d.l+=a/100;d.l=Math.min(1,Math.max(0,d.l));return Entry.Utils.hslToHex(d)};Entry.Utils.bound01=function(b,a){var d=b;"string"==typeof d&&-1!=d.indexOf(".")&&1===parseFloat(d)&&(b="100%");d="string"===typeof b&&-1!=b.indexOf("%");b=Math.min(a,Math.max(0,parseFloat(b)));d&&(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,d;7===b.length?(a=parseInt(b.substr(1,2),16),d=parseInt(b.substr(3,2),16),b=parseInt(b.substr(5,2),16)):(a=parseInt(b.substr(1,2),16),d=parseInt(b.substr(2,2),16),b=parseInt(b.substr(3,2),16));a=Entry.Utils.bound01(a,255);d=Entry.Utils.bound01(d,255);b=Entry.Utils.bound01(b,255);var c=Math.max(a,d,b),e=Math.min(a,d,b),f,g=(c+e)/2;if(c==e)f=e=0;else{var h=c-e,e=.5d&&(d+=1);1d?b:d<2/3?a+(b-a)*(2/3-d)*6:a}function d(a){return 1==a.length?"0"+a:""+a}var c,e;e=Entry.Utils.bound01(b.h,360);c=Entry.Utils.bound01(b.s,1);b=Entry.Utils.bound01(b.l,1);if(0===c)c=b=e=b;else{var f=.5>b?b*(1+c):b+c-b*c,g=2*b-f;c=a(g,f,e+1/3);b=a(g,f,e);e=a(g,f,e-1/3)}b*=255;e*=255;return"#"+[d(Math.round(255*c).toString(16)),d(Math.round(b).toString(16)),d(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 d=0,c=this.events_[b].length;d=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,d){return"#"+(16777216+(b<<16)+(a<<8)+d).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,d){return b>d?d: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={},d;for(d in b)a[d]=b[d];return a};Entry.nodeListToArray=function(b){for(var a=Array(b.length),d=-1,c=b.length;++d!==c;a[d]=b[d]);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 Number(b+10)+"px"};Entry.isArrowOrBackspace=function(b){return-1<[37,38,39,40,8].indexOf(b)};Entry.hexStringToBin=function(b){for(var a=[],d=0;dc&&(c=h.index)}return 0a&&(a=e))}return Math.min(a,20)};Entry.convertToRoundedDecimals=function(b,a){return isNaN(b)||!this.isFloat(b)?b:Number(Math.round(b+"e"+a)+"e-"+a)};Entry.attachEventListener=function(b,a,d){setTimeout(function(){b.addEventListener(a,d)},0)};Entry.deAttachEventListener=function(b,a,d){b.removeEventListener(a,d)}; +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 d(){}d.prototype=b.prototype;a.prototype=new d;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 d=b.elem("defs"),c=d.elem("filter",{id:"entryTrashcanFilter_"+a});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=d.elem("filter",{id:"entryBlockShadowFilter_"+a,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"});d=d.elem("filter",{id:"entryBlockHighlightFilter_"+a});d.elem("feOffset",{result:"offOut",in:"SourceGraphic",dx:0,dy:0});d.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 d=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"}),c=d.elem("g"),e=c.elem("rect",{x:0,y:0,width:125,height:33}),f=Entry.mediaFilePath+"block_pattern_(order).png",g=1;5>g;g++)c.elem("image",{class:"pattern"+g,href:f.replace("(order)",g),x:0,y:0,width:125,height:33});return{pattern:d,rect:e}}; +Entry.Utils.COLLISION={NONE:0,UP:1,RIGHT:2,LEFT:3,DOWN:4};Entry.Utils.createMouseEvent=function(b,a){var d=document.createEvent("MouseEvent");d.initMouseEvent(b,!0,!0,window,0,0,0,a.clientX,a.clientY,!1,!1,!1,!1,0,null);return d};Entry.Utils.xmlToJsonData=function(b){b=$.parseXML(b);var a=[];b=b.childNodes[0].childNodes;for(var d in b){var c=b[d];if(c.tagName){var e={category:c.getAttribute("id"),blocks:[]},c=c.childNodes;for(d in c){var f=c[d];f.tagName&&(f=f.getAttribute("type"))&&e.blocks.push(f)}a.push(e)}}return a}; +Entry.Utils.stopProjectWithToast=function(b,a,d){var c=b.block;a=a||"\ub7f0\ud0c0\uc784 \uc5d0\ub7ec \ubc1c\uc0dd";Entry.toast&&!d&&Entry.toast.alert(Lang.Msgs.warn,Lang.Workspace.check_runtime_error,!0);Entry.engine&&Entry.engine.toggleStop();"workspace"===Entry.type&&(b.block&&"funcBlock"in b.block?c=b.block.funcBlock:b.funcExecutor&&(c=b.funcExecutor.scope.block,b=b.type.replace("func_",""),Entry.Func.edit(Entry.variableContainer.functions_[b])),c&&(Entry.container.selectObject(c.getCode().object.id, +!0),c.view.getBoard().activateBlock(c)));throw Error(a);};Entry.Utils.AsyncError=function(b){this.name="AsyncError";this.message=b||"\ube44\ub3d9\uae30 \ud638\ucd9c \ub300\uae30"};Entry.Utils.AsyncError.prototype=Error();Entry.Utils.AsyncError.prototype.constructor=Entry.Utils.AsyncError;Entry.Utils.isChrome=function(){return/chrom(e|ium)/.test(navigator.userAgent.toLowerCase())}; +Entry.Utils.waitForWebfonts=function(b,a){for(var d=0,c=0,e=b.length;c=b.length&&(l&&clearInterval(l),d==b.length))return a(),!0}var h=document.createElement("span");h.innerHTML="giItT1WQy@!-/#";h.style.position="absolute";h.style.left="-10000px";h.style.top="-10000px";h.style.fontSize="300px";h.style.fontFamily="sans-serif";h.style.fontVariant="normal";h.style.fontStyle="normal";h.style.fontWeight= +"normal";h.style.letterSpacing="0";document.body.appendChild(h);var k=h.offsetWidth;h.style.fontFamily=c;var l;e()||(l=setInterval(e,50))})(b[c])};window.requestAnimFrame=function(){return window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||function(b){window.setTimeout(b,1E3/60)}}(); +Entry.isMobile=function(){if(Entry.device)return"tablet"===Entry.device;var b=window.platform;if(b&&b.type&&("tablet"===b.type||"mobile"===b.type))return Entry.device="tablet",!0;Entry.device="desktop";return!1};Entry.Utils.convertMouseEvent=function(b){return b.originalEvent&&b.originalEvent.touches?b.originalEvent.touches[0]:b};Entry.Utils.convertIntToHex=function(b){return b.toString(16).toUpperCase()};Entry.Utils.hasSpecialCharacter=function(b){return/!|@|#|\$|%|\^|&|\*|\(|\)|\+|=|-|\[|\]|\\|\'|;|,|\.|\/|{|}|\||\"|:|<|>|\?/g.test(b)};Entry.Model=function(b,a){var d=Entry.Model;d.generateSchema(b);d.generateSetter(b);d.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 c in b)(function(c){a.data[c]=b[c];Object.defineProperty(a,c,{get:function(){return a.data[c]}})})(c);a._toJSON=this._toJSON}};b.generateSetter=function(a){a.set=this.set};b.set=function(a,b){var c={},e;for(e in this.data)void 0!==a[e]&&(a[e]===this.data[e]?delete a[e]:(c[e]=this.data[e],this.data[e]=a[e]instanceof Array?a[e].concat():a[e]));b||this.notify(Object.keys(a),c)};b.generateObserve= +function(a){a.observers=[];a.observe=this.observe;a.unobserve=this.unobserve;a.notify=this.notify};b.observe=function(a,b,c,e){c=new Entry.Observer(this.observers,a,b,c);if(!1!==e)a[b]([]);return c};b.unobserve=function(a){a.destroy()};b.notify=function(a,b){"string"===typeof a&&(a=[a]);var c=this;c.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:c,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={};Entry.generateFunctionSchema(this.id);if(b){b=this.content._blockMap;for(var a in b)Entry.Func.registerParamBlock(b[a].type);Entry.Func.generateWsBlock(this)}Entry.Func.registerFunction(this);Entry.Func.updateMenu()};Entry.Func.threads={}; +Entry.Func.registerFunction=function(b){if(Entry.playground){var a=Entry.playground.mainWorkspace;a&&(this._targetFuncBlock=a.getBlockMenu().getCategoryCodes("func").createThread([{type:"func_"+b.id}]),b.blockMenuBlock=this._targetFuncBlock)}};Entry.Func.executeFunction=function(b){var a=this.threads[b];if(a=Entry.Engine.computeThread(a.entity,a))return this.threads[b]=a,!0;delete this.threads[b];return!1};Entry.Func.clearThreads=function(){this.threads={}}; +Entry.Func.prototype.init=function(b){this.id=b.id;this.content=Blockly.Xml.textToDom(b.content);this.block=Blockly.Xml.textToDom(""+b.block+"").childNodes[0]};Entry.Func.prototype.destroy=function(){this.blockMenuBlock.destroy()};Entry.Func.edit=function(b){this.cancelEdit();this.targetFunc=b;this.initEditView(b.content);this.bindFuncChangeEvent();this.updateMenu()}; +Entry.Func.initEditView=function(b){this.menuCode||this.setupMenuCode();var a=Entry.playground.mainWorkspace;a.setMode(Entry.Workspace.MODE_OVERLAYBOARD);a.changeOverlayBoardCode(b);b.recreateView();a.changeOverlayBoardCode(b);b.view.board.alignThreads();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,d=[],d=b.split(" "),c="";b=[];b=Blockly.mainWorkspace.getAllBlocks();for(var e=0;eBlockly.Block.dragMode_&&(b.updateMenu(),b.fieldText=a,b.workspaceLength=d)}}; +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=[],c;for(c in a){var e=this.generatePortView(a[c],"_svgGroup");this._portViews[c]=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 c in b)a[c]= +b[c];return a};b.removePortEle=function(a,b){if("object"!=typeof b)return a;for(var c in b)delete a[c];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=[],c;for(c in a){var e=this.generatePortView(a[c],"_svglistGroup");this._listPortViews[c]=e;b.push(e)}var f=this._portMapList; +b.map(function(a){f.n.push(a)});this.resizeList()};b.generatePortView=function(a,b){var c=this[b].elem("g");c.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=c.elem("rect").attr({x:0,y:0,width:150,height:22,rx:4,ry:4,fill:"#fff",stroke:"#a0a1a1"}),g=c.elem("text").attr({x:4,y:12,fill:"#000","class":"hwComponentName","alignment-baseline":"central"});g.textContent=a.name;g=g.getComputedTextLength(); +c.elem("rect").attr({x:g+8,y:2,width:30,height:18,rx:9,ry:9,fill:"input"===a.type?"#00979d":"#A751E3"});var h=c.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:c,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,c=this._hwModule.monitorTemplate.mode, +e=this._hwModule.monitorTemplate.keys||[],f=[];if("list"==c)f=this._listPortViews;else if("both"==c){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(c=f[h],"input"==c.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,c=0;cc-(l.width+m.width/2.2)&&(f+=1,initX=h,g=0)};b._movePort=function(a,b,c,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+","+c+"L"+g+","+h:"M"+(b+e)/2+","+c+"l0,"+(h>c?28:-3)+"H"+g+"L"+g+","+h):b=bc?28:-3)+"H"+g+"L"+g+","+h;a.group.attr({transform:"translate("+f+","+c+")"});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={"1.1":Entry.Arduino,"1.9":Entry.ArduinoExt,"1.2":Entry.SensorBoard,"1.3":Entry.CODEino,"1.4":Entry.joystick,"1.5":Entry.dplay,"1.6":Entry.nemoino,"1.7":Entry.Xbot,"1.8":Entry.ardublock,"1.A":Entry.Cobl,"2.4":Entry.Hamster, +"2.5":Entry.Albert,"3.1":Entry.Bitbrick,"4.2":Entry.Arduino,"5.1":Entry.Neobot,"7.1":Entry.Robotis_carCont,"7.2":Entry.Robotis_openCM70,"8.1":Entry.Arduino,"10.1":Entry.Roborobo_Roduino,"10.2":Entry.Roborobo_SchoolKit,"12.1":Entry.EV3,"B.1":Entry.Codestar}};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,d;this.connected=!1;this.connectTrial++;if(-1this.offsetX?0:a+d.maxWidth+10>this.offsetX?this.offsetX-a:d.maxWidth+10))}});this.valueSetter_.on("pressup",function(a){d.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();var b=this.textView_.text,a;a=this.object_?(a=Entry.container.getObject(this.object_))?a.name+":"+this.getName():this.getName():this.getName();b!==a&&(this.textView_.text=a,this._nameWidth=null);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(), +b=this.textView_.text,a=this.object_?(a=Entry.container.getObject(this.object_))?a.name+":"+this.getName():this.getName():this.getName(),b!==a&&(this.textView_.text=a,this._nameWidth=null),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;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-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;ad.length?d+"..":d;this.elementView.valueView.text=d;d=this.elementView.clone(!0);d.y=20*(a-this.scrollPosition)+23;this.view_.addChild(d)}}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(b){Entry.assert("string"==typeof b,"Variable name must be string");this.name_=b;this._nameWidth=null;this.updateView();Entry.requestUpdateTwice=!0};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(b){"slide"!=this.type?this.value_=b:(b=Number(b),this.value_=bthis.maxValue_?this.maxValue_:b);this.isCloud_&&Entry.variableContainer.updateCloudVariables();this._valueWidth=null;this.updateView();Entry.requestUpdateTwice=!0};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!==b&&(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)}; @@ -1725,7 +1636,7 @@ a.innerHTML=Lang.Buttons.save;a.variableContainer=this;a.bindOnClick(function(a) Entry.VariableContainer.prototype.generateVariableSplitterView=function(){var b=Entry.createElement("li");b.addClass("entryVariableSplitterWorkspace");var a=Entry.createElement("li");a.addClass("entryVariableSplitterWorkspace");this.variableSplitters={top:b,bottom:a}}; Entry.VariableContainer.prototype.openVariableAddPanel=function(b){b=b?b:"variable";Entry.playground.toggleOnVariableView();Entry.playground.changeViewMode("variable");"variable"==b?this.variableAddPanel.isOpen=!0:this.listAddPanel.isOpen=!0;this.selectFilter(b);this.updateVariableAddView(b)}; Entry.VariableContainer.prototype.getMenuXml=function(b){for(var a=[],d=0!==this.variables_.length,c=0!==this.lists_.length,e,f=0,g;g=b[f];f++){var h=g.tagName;h&&"BLOCK"==h.toUpperCase()?(e=g.getAttribute("bCategory"),!d&&"variable"==e||!c&&"list"==e||a.push(g)):!h||"SPLITTER"!=h.toUpperCase()&&"BTN"!=h.toUpperCase()||!d&&"variable"==e||(c||"list"!=e)&&a.push(g)}return a}; -Entry.VariableContainer.prototype.addCloneLocalVariables=function(b){var a=[],d=this;this.mapVariable(function(b,d){b.object_&&b.object_==d.objectId&&(b=b.toJSON(),b.originId=b.id,b.id=Entry.generateHash(),b.object=d.newObjectId,delete b.x,delete b.y,a.push(b),d.json.script=d.json.script.replace(new RegExp(b.originId,"g"),b.id))},b);a.map(function(a){d.addVariable(a)})}; +Entry.VariableContainer.prototype.addCloneLocalVariables=function(b){var a=[],d=this;this.mapVariable(function(b,d){if(b.object_&&b.object_==d.objectId){var f=b.toJSON();f.originId=f.id;f.id=Entry.generateHash();f.object=d.newObjectId;delete f.x;delete f.y;a.push(f);d.json.script=d.json.script.replace(new RegExp(f.originId,"g"),f.id)}},b);a.map(function(a){d.addVariable(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(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 b=this,a=Entry.createElement("div");a.bindOnClick(function(a){a.stopPropagation()});this.variableSettingView=a;a.addClass("entryVariableSettingWorkspace");this.listView_.appendChild(a);a.addClass("entryRemove");var d=Entry.createElement("div");d.addClass("entryVariableSettingVisibleWrapperWorkspace");d.bindOnClick(function(a){a=b.selectedVariable;var d=b.variableSettingView.visibleCheck;a.setVisible(!a.isVisible());a.isVisible()? @@ -1747,10 +1658,10 @@ f.addClass("entryListSettingValueRemoveWorkspace");e.appendChild(f);c.appendChil 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=[],d=this;this.mapVariable(function(b,d){b.object_&&b.object_==d&&a.push(b)},b);a.map(function(a){d.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&&Entry.playground.mainWorkspace.getMode()===Entry.Workspace.MODE_BOARD){var d={object:a.getCode().object,block:a};a.funcBlock&&(d.funcBlock=a.funcBlock,delete a.funcBlock);this[b].push(d);if("_functionRefs"==b){b=a.type.substr(5);for(var c=Entry.variableContainer.functions_[b].content.getBlockList(),e=0;ethis.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&&ea.x||0>a.y){d.leftWheel=20;d.rightWheel= --20;break}a.initialized=!0}d=b.toRadian(a.theta);0==b.controlAngle(d,Math.atan2(a.targetY-a.y,a.targetX-a.x))&&(a.boardState=2);break;case 2:0==b.controlPosition(a.x,a.y,b.toRadian(a.theta),a.targetX,a.targetY)&&(a.boardState=3);break;case 3:0==b.controlPositionFine(a.x,a.y,b.toRadian(a.theta),a.targetX,a.targetY)&&(d.leftWheel=0,d.rightWheel=0,a.isMoving=!1)}return a}delete a.isStart;delete a.isMoving;delete a.initialized;delete a.boardState;delete a.x;delete a.y;delete a.theta;delete a.targetX; -delete a.targetY;Entry.engine.isContinue=!1;d.leftWheel=0;d.rightWheel=0;return a.callReturn()}a.isStart=!0;a.isMoving=!0;a.initialized=!1;a.boardState=1;a.x=-1;a.y=-1;a.theta=-200;a.targetX=a.getNumberValue("X");a.targetY=a.getNumberValue("Y");b.clear();d.leftWheel=0;d.rightWheel=0;return a}},albert_set_orientation_on_board:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[{type:"number", -params:["0"]},null],type:"albert_set_orientation_on_board"},paramsKeyMap:{ORIENTATION:0},"class":"albert_wheel",isNotFor:["albert"],func:function(b,a){b=Entry.hw.sendQueue;var d=Entry.hw.portData,c=Entry.Albert.controller;if(a.isStart){if(a.isMoving){a.theta=d.orientation;switch(a.boardState){case 1:var d=c.toRadian(a.theta),e=c.toRadian(a.targetTheta);0==c.controlAngle(d,e)&&(a.boardState=2);break;case 2:d=c.toRadian(a.theta),e=c.toRadian(a.targetTheta),0==c.controlAngleFine(d,e)&&(b.leftWheel=0, -b.rightWheel=0,a.isMoving=!1)}return a}delete a.isStart;delete a.isMoving;delete a.boardState;delete a.theta;delete a.targetTheta;Entry.engine.isContinue=!1;b.leftWheel=0;b.rightWheel=0;return a.callReturn()}a.isStart=!0;a.isMoving=!0;a.boardState=1;a.theta=-200;a.targetTheta=a.getNumberValue("ORIENTATION");c.clear();b.leftWheel=0;b.rightWheel=0;return a}},albert_set_eye_to:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.ALBERT_left_eye,"LEFT"],[Lang.Blocks.ALBERT_right_eye, -"RIGHT"],[Lang.Blocks.ALBERT_both_eyes,"BOTH"]],value:"LEFT",fontSize:11},{type:"Dropdown",options:[[Lang.Blocks.ALBERT_color_red,"4"],[Lang.Blocks.ALBERT_color_yellow,"6"],[Lang.Blocks.ALBERT_color_green,"2"],[Lang.Blocks.ALBERT_color_cyan,"3"],[Lang.Blocks.ALBERT_color_blue,"1"],[Lang.Blocks.ALBERT_color_magenta,"5"],[Lang.Blocks.ALBERT_color_white,"7"]],value:"4",fontSize:11},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,null,null],type:"albert_set_eye_to"}, -paramsKeyMap:{DIRECTION:0,COLOR:1},"class":"albert_led",isNotFor:["albert"],func:function(b,a){b=Entry.hw.sendQueue;var d=a.getField("DIRECTION",a),c=Number(a.getField("COLOR",a));"LEFT"==d?b.leftEye=c:("RIGHT"!=d&&(b.leftEye=c),b.rightEye=c);return a.callReturn()},syntax:{js:[],py:["Albert.set_eye(%1, %2)"]}},albert_clear_eye:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.ALBERT_left_eye,"LEFT"],[Lang.Blocks.ALBERT_right_eye,"RIGHT"],[Lang.Blocks.ALBERT_both_eyes, -"BOTH"]],value:"LEFT",fontSize:11},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,null],type:"albert_clear_eye"},paramsKeyMap:{DIRECTION:0},"class":"albert_led",isNotFor:["albert"],func:function(b,a){b=Entry.hw.sendQueue;var d=a.getField("DIRECTION",a);"LEFT"==d?b.leftEye=0:("RIGHT"!=d&&(b.leftEye=0),b.rightEye=0);return a.callReturn()},syntax:{js:[],py:["Albert.clear_eye(%1)"]}},albert_body_led:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown", -options:[[Lang.Blocks.ALBERT_turn_on,"ON"],[Lang.Blocks.ALBERT_turn_off,"OFF"]],value:"ON",fontSize:11},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,null],type:"albert_body_led"},paramsKeyMap:{STATE:0},"class":"albert_led",isNotFor:["albert"],func:function(b,a){b=Entry.hw.sendQueue;"ON"==a.getField("STATE",a)?b.bodyLed=1:b.bodyLed=0;return a.callReturn()},syntax:{js:[],py:["Albert.body_led(%1)"]}},albert_front_led:{color:"#00979D",skeleton:"basic",statements:[], -params:[{type:"Dropdown",options:[[Lang.Blocks.ALBERT_turn_on,"ON"],[Lang.Blocks.ALBERT_turn_off,"OFF"]],value:"ON",fontSize:11},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,null],type:"albert_front_led"},paramsKeyMap:{STATE:0},"class":"albert_led",isNotFor:["albert"],func:function(b,a){b=Entry.hw.sendQueue;"ON"==a.getField("STATE",a)?b.frontLed=1:b.frontLed=0;return a.callReturn()},syntax:{js:[],py:["Albert.front_led(%1)"]}},albert_beep:{color:"#00979D", -skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null],type:"albert_beep"},"class":"albert_buzzer",isNotFor:["albert"],func:function(b,a){b=Entry.hw.sendQueue;if(a.isStart){if(1==a.timeFlag)return a;delete a.isStart;delete a.timeFlag;Entry.engine.isContinue=!1;b.buzzer=0;return a.callReturn()}a.isStart=!0;a.timeFlag=1;b.buzzer=440;b.note=0;var d=setTimeout(function(){a.timeFlag=0;Entry.Albert.removeTimeout(d)},200);Entry.Albert.timeouts.push(d); -return a},syntax:{js:[],py:["Albert.beep()"]}},albert_change_buzzer_by:{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:["10"]},null],type:"albert_change_buzzer_by"},paramsKeyMap:{VALUE:0},"class":"albert_buzzer",isNotFor:["albert"],func:function(b,a){b=Entry.hw.sendQueue;var d=a.getNumberValue("VALUE");b.buzzer=void 0!=b.buzzer?b.buzzer+d:d;b.note=0;return a.callReturn()}, -syntax:{js:[],py:["Albert.change_buzzer(%1)"]}},albert_set_buzzer_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:["1000"]},null],type:"albert_set_buzzer_to"},paramsKeyMap:{VALUE:0},"class":"albert_buzzer",isNotFor:["albert"],func:function(b,a){b=Entry.hw.sendQueue;b.buzzer=a.getNumberValue("VALUE");b.note=0;return a.callReturn()},syntax:{js:[],py:["Albert.set_buzzer(%1)"]}}, -albert_clear_buzzer:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null],type:"albert_clear_buzzer"},"class":"albert_buzzer",isNotFor:["albert"],func:function(b,a){b=Entry.hw.sendQueue;b.buzzer=0;b.note=0;return a.callReturn()},syntax:{js:[],py:["Albert.clear_buzzer()"]}},albert_play_note_for:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.ALBERT_note_c+"","4"], -[Lang.Blocks.ALBERT_note_c+"#","5"],[Lang.Blocks.ALBERT_note_d+"","6"],[Lang.Blocks.ALBERT_note_e+"b","7"],[Lang.Blocks.ALBERT_note_e+"","8"],[Lang.Blocks.ALBERT_note_f+"","9"],[Lang.Blocks.ALBERT_note_f+"#","10"],[Lang.Blocks.ALBERT_note_g+"","11"],[Lang.Blocks.ALBERT_note_g+"#","12"],[Lang.Blocks.ALBERT_note_a+"","13"],[Lang.Blocks.ALBERT_note_b+"b","14"],[Lang.Blocks.ALBERT_note_b+"","15"]],value:"4",fontSize:11},{type:"Dropdown",options:[["1","1"],["2","2"],["3","3"],["4","4"],["5","5"],["6", -"6"],["7","7"]],value:"1",fontSize:11},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,"4",{type:"text",params:["0.5"]},null],type:"albert_play_note_for"},paramsKeyMap:{NOTE:0,OCTAVE:1,VALUE:2},"class":"albert_buzzer",isNotFor:["albert"],func:function(b,a){var d=Entry.hw.sendQueue;if(a.isStart){if(1==a.timeFlag)return a;delete a.isStart;delete a.timeFlag;Entry.engine.isContinue=!1;d.note=0;return a.callReturn()}b=a.getNumberField("NOTE", -a);var c=a.getNumberField("OCTAVE",a),e=6E4*a.getNumberValue("VALUE",a)/Entry.Albert.tempo;a.isStart=!0;a.timeFlag=1;d.buzzer=0;d.note=b+12*(c-1);if(100Entry.Albert.tempo&&(Entry.Albert.tempo=1);return a.callReturn()},syntax:{js:[],py:["Albert.change_tempo(%1)"]}},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()},syntax:{js:[],py:["Albert.set_tempo(%1)"]}},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){b=Entry.hw.sendQueue;if(a.isStart){if(1==a.timeFlag)return a;delete a.timeFlag;delete a.isStart;Entry.engine.isContinue=!1;b.leftWheel=0;b.rightWheel=0;return a.callReturn()}a.isStart=!0;a.timeFlag=1;b.leftWheel= -30;b.rightWheel=30;setTimeout(function(){a.timeFlag=0},1E3);return a},syntax:{js:[],py:["Albert.move_forward()"]}},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){b=Entry.hw.sendQueue;if(a.isStart){if(1==a.timeFlag)return b.leftWheel=-30,b.rightWheel=-30,a;delete a.timeFlag;delete a.isStart;Entry.engine.isContinue=!1;b.leftWheel=0;b.rightWheel=0;return a.callReturn()}a.isStart= -!0;a.timeFlag=1;setTimeout(function(){a.timeFlag=0},1E3);return a},syntax:{js:[],py:["Albert.move_backward()"]}},albert_turn_around:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.ALBERT_turn_left,"LEFT"],[Lang.Blocks.ALBERT_turn_right,"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){b=Entry.hw.sendQueue;if(a.isStart){if(1== -a.timeFlag)return b.leftWheel=a.leftValue,b.rightWheel=a.rightValue,a;delete a.timeFlag;delete a.isStart;delete a.leftValue;delete a.rightValue;Entry.engine.isContinue=!1;b.leftWheel=0;b.rightWheel=0;return a.callReturn()}b="LEFT"==a.getField("DIRECTION",a);a.leftValue=b?-30:30;a.rightValue=b?30:-30;a.isStart=!0;a.timeFlag=1;setTimeout(function(){a.timeFlag=0},1E3);return a},syntax:{js:[],py:["Albert.turn_around()"]}},albert_set_led_to:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown", -options:[[Lang.Blocks.HAMSTER_left_led,"LEFT"],[Lang.Blocks.HAMSTER_right_led,"RIGHT"],[Lang.Blocks.HAMSTER_both_leds,"FRONT"]],value:"LEFT",fontSize:11},{type:"Dropdown",options:[[Lang.Blocks.HAMSTER_color_red,"4"],[Lang.Blocks.HAMSTER_color_yellow,"6"],[Lang.Blocks.HAMSTER_color_green,"2"],[Lang.Blocks.HAMSTER_color_cyan,"3"],[Lang.Blocks.HAMSTER_color_blue,"1"],[Lang.Blocks.HAMSTER_color_magenta,"5"],[Lang.Blocks.HAMSTER_color_white,"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){b=Entry.hw.sendQueue;var d=a.getField("DIRECTION",a),c=Number(a.getField("COLOR",a));"FRONT"==d?(b.leftEye=c,b.rightEye=c):"LEFT"==d?b.leftEye=c:b.rightEye=c;return a.callReturn()},syntax:{js:[],py:["Albert.set_led(%1, %2)"]}},albert_clear_led:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.HAMSTER_left_led,"LEFT"],[Lang.Blocks.HAMSTER_right_led,"RIGHT"], -[Lang.Blocks.HAMSTER_both_leds,"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){b=Entry.hw.sendQueue;var d=a.getField("DIRECTION",a);"FRONT"==d?(b.leftEye=0,b.rightEye=0):"LEFT"==d?b.leftEye=0:b.rightEye=0;return a.callReturn()},syntax:{js:[],py:["Albert.clear_led(%1)"]}},albert_change_wheels_by:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.ALBERT_left_wheel, -"LEFT"],[Lang.Blocks.ALBERT_right_wheel,"RIGHT"],[Lang.Blocks.ALBERT_both_wheels,"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){b=Entry.hw.sendQueue;var d=Entry.hw.portData,c=a.getField("DIRECTION"),e=a.getNumberValue("VALUE");"LEFT"==c?b.leftWheel=void 0!=b.leftWheel?b.leftWheel+e:d.leftWheel+e:("RIGHT"!=c&&(b.leftWheel=void 0!= -b.leftWheel?b.leftWheel+e:d.leftWheel+e),b.rightWheel=void 0!=b.rightWheel?b.rightWheel+e:d.rightWheel+e);return a.callReturn()},syntax:{js:[],py:["Albert.change_wheels(%1, %2)"]}},albert_set_wheels_to:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.ALBERT_left_wheel,"LEFT"],[Lang.Blocks.ALBERT_right_wheel,"RIGHT"],[Lang.Blocks.ALBERT_both_wheels,"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){b=Entry.hw.sendQueue;var d=a.getField("DIRECTION"),c=a.getNumberValue("VALUE");"LEFT"==d?b.leftWheel=c:("RIGHT"!=d&&(b.leftWheel=c),b.rightWheel=c);return a.callReturn()},syntax:{js:[],py:["Albert.set_wheels(%1, %2)"]}},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")}, -syntax:{js:[],py:["%1arduino_text#"]}},arduino_send:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"}],events:{},def:{params:[]},paramsKeyMap:{VALUE:0},func:function(b,a){b=a.getValue("VALUE",a);var d=new XMLHttpRequest;d.open("POST","http://localhost:23518/arduino/",!1);d.send(String(b));Entry.assert(200==d.status,"arduino is not connected");return a.callReturn()},syntax:{js:[],py:["Arduino.send(%1)"]}},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){b=a.getValue("VALUE",a);a=new XMLHttpRequest;a.open("POST","http://localhost:23518/arduino/",!1);a.send(String(b));Entry.assert(200==a.status,"arduino is not connected");return Number(a.responseText)},syntax:{js:[],py:["Arduino.number(%1)"]}},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){b=a.getValue("VALUE",a);a=new XMLHttpRequest;a.open("POST","http://localhost:23518/arduino/",!1);a.send(String(b));Entry.assert(200==a.status,"arduino is not connected");return a.responseText},syntax:{js:[],py:["Arduino.string(%1)"]}},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")},syntax:{js:[],py:["%1arduino_get_sensor_number#"]}},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")},syntax:{js:[],py:["%1arduino_get_sensor_number#"]}},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")},syntax:{js:[],py:["%1arduino_get_pwm_port_number#"]}}, -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){b=a.getValue("VALUE",a);return Entry.hw.getAnalogPortValue(b[1])},syntax:{js:[],py:["Arduino.sensor_value(%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){b=a.getNumberValue("VALUE",a);return Entry.hw.getDigitalPortValue(b)},syntax:{js:[],py:["Arduino.digital_value(%1)"]}},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){b=a.getNumberValue("VALUE");var d=a.getField("OPERATOR");Entry.hw.setDigitalPortValue(b,"on"==d?255:0);return a.callReturn()}, -syntax:{js:[],py:["Arduino.toggle_led(%1, %2)"]}},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){b=a.getNumberValue("PORT");var d= -a.getNumberValue("VALUE"),d=Math.round(d),d=Math.max(d,0),d=Math.min(d,255);Entry.hw.setDigitalPortValue(b,d);return a.callReturn()},syntax:{js:[],py:["Arduino.toggle_pwm(%1, %2)"]}},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 d=a.getNumberValue("VALUE1",a),c=a.getNumberValue("VALUE2",a),e=a.getNumberValue("VALUE3",a);b=a.getNumberValue("VALUE4",a);a=a.getNumberValue("VALUE5",a);if(c>e)var f=c,c= -e,e=f;b>a&&(f=b,b=a,a=f);d=(a-b)/(e-c)*(d-c);d+=b;d=Math.min(a,d);d=Math.max(b,d);return Math.round(d)},syntax:{js:[],py:["Arduino.convert_scale(%1, %2, %3, %4, %5)"]}},arduino_ext_get_analog_value:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],params:[{type:"Dropdown",options:[["A0","0"],["A1","1"],["A2","2"],["A3","3"],["A4","4"],["A5","5"]],value:"0",fontSize:11}],events:{},def:{params:[null],type:"arduino_ext_get_analog_value"},paramsKeyMap:{PORT:0},"class":"ArduinoExtGet", -isNotFor:["ArduinoExt"],func:function(b,a){b=a.getField("PORT",a);var d=Entry.ArduinoExt.getSensorTime(Entry.ArduinoExt.sensorTypes.ANALOG),c=Entry.hw.portData.TIME||0;a=a.executor.scope;var e=Entry.hw.portData.ANALOG;if(a.isStart){if(c&&c===a.stamp||64=e[0]?1:0;throw new Entry.Utils.AsyncError;}a.isStart=!0;a.stamp=d;Entry.hw.sendQueue.TIME=d;Entry.hw.sendQueue.KEY=Entry.ArduinoExt.getSensorKey();Entry.hw.sendQueue.GET={type:Entry.ArduinoExt.sensorTypes.ANALOG,port:0};throw new Entry.Utils.AsyncError;}},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_sensor",isNotFor:["CODEino"],func:function(b,a){b=a.getField("STATUS",a);var d=Entry.ArduinoExt.getSensorTime(Entry.ArduinoExt.sensorTypes.ANALOG),c=Entry.hw.portData.TIME||0;a=a.executor.scope;var e=Entry.hw.portData.ANALOG;if(a.isStart){if(c&&c===a.stamp||64e[1]?1:0:800>=e[1]?1:0;throw new Entry.Utils.AsyncError; -}a.isStart=!0;a.stamp=d;Entry.hw.sendQueue.TIME=d;Entry.hw.sendQueue.KEY=Entry.ArduinoExt.getSensorKey();Entry.hw.sendQueue.GET={type:Entry.ArduinoExt.sensorTypes.ANALOG,port:1};throw new Entry.Utils.AsyncError;}},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_sensor",isNotFor:["CODEino"],func:function(b,a){b=a.getNumberField("PORT",a);if(10>b){var d=Entry.ArduinoExt.getSensorTime(Entry.ArduinoExt.sensorTypes.DIGITAL),c=Entry.hw.portData.TIME||0;a=a.executor.scope;var e=Entry.hw.portData.DIGITAL;if(a.isStart){if(c&&c===a.stamp||64e[b-14]?1:0;throw new Entry.Utils.AsyncError;}a.isStart= -!0;a.stamp=d;Entry.hw.sendQueue.TIME=d;Entry.hw.sendQueue.KEY=Entry.ArduinoExt.getSensorKey();Entry.hw.sendQueue.GET={type:Entry.ArduinoExt.sensorTypes.ANALOG,port:b-14};throw new Entry.Utils.AsyncError;}},CODEino_get_accelerometer_direction:{color:"#00979D",fontColor:"#fff",skeleton:"basic_boolean_field",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.CODEino_string_16,"LEFT"],[Lang.Blocks.CODEino_string_17,"RIGHT"],[Lang.Blocks.CODEino_string_18,"FRONT"],[Lang.Blocks.CODEino_string_19, -"REAR"],[Lang.Blocks.CODEino_string_20,"REVERSE"]],value:"LEFT",fontSize:11}],events:{},def:{params:[null],type:"CODEino_get_accelerometer_direction"},paramsKeyMap:{DIRECTION:0},"class":"CODEino_sensor",isNotFor:["CODEino"],func:function(b,a){b=a.getField("DIRECTION",a);var d=0,c=Entry.ArduinoExt.getSensorTime(Entry.ArduinoExt.sensorTypes.ANALOG),e=Entry.hw.portData.TIME||0;a=a.executor.scope;var f=Entry.hw.portData.ANALOG;"LEFT"==b||"RIGHT"==b?d=3:"FRONT"==b||"REAR"==b?d=4:"REVERSE"==b&&(d=5);if(a.isStart)if(e&& -e===a.stamp){delete a.isStart;delete a.stamp;d=f[d];d=Math.min(90,180/137*(d-265)+-90);d=Math.max(-90,d);d=Math.round(d);if("LEFT"==b||"REAR"==b)return-30>d?1:0;if("RIGHT"==b||"FRONT"==b)return 30d?1:0}else if(64d?1:0;if("RIGHT"==b||"FRONT"==b)return 30d?1:0}else throw new Entry.Utils.AsyncError; -else throw a.isStart=!0,a.stamp=c,Entry.hw.sendQueue.TIME=c,Entry.hw.sendQueue.KEY=Entry.ArduinoExt.getSensorKey(),Entry.hw.sendQueue.GET={type:Entry.ArduinoExt.sensorTypes.ANALOG,port:d},new Entry.Utils.AsyncError;}},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_sensor",isNotFor:["CODEino"],func:function(b,a){b=a.getNumberField("PORT",a);var d=Entry.ArduinoExt.getSensorTime(Entry.ArduinoExt.sensorTypes.ANALOG),c=Entry.hw.portData.TIME||0;a=a.executor.scope;var e=Entry.hw.portData.ANALOG;if(a.isStart){if(c&&c===a.stamp||64e)var f=c,c=e,e=f;b>a&&(f=b,b=a,a=f);d=(a-b)/(e-c)*(d-c);d+=b;d=Math.min(a,d);d=Math.max(b,d);return Math.round(d)}},CODEino_set_rgb_value:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[["\ube68\uac15","17"],["\ucd08\ub85d","18"],["\ud30c\ub791", -"19"]],value:"17",fontSize:11},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{type:"CODEino_set_rgb_value"},paramsKeyMap:{PORT:0,VALUE:1},"class":"CODEino_RGBLED_mode",isNotFor:["CODEino"],func:function(b,a){b=Entry.hw.sendQueue;var d=a.getNumberField("PORT",a),c=a.getNumberValue("VALUE",a),c=Math.min(255,c),c=Math.max(0,c);17==d?CODEINO_RED=c:18==d?CODEINO_GREEN=c:CODEINO_BLUE=c;b.TIME=Entry.ArduinoExt.getSensorTime(4);b.KEY=Entry.ArduinoExt.getSensorKey(); -b.SET||(b.SET={});b.SET[d]={type:4,data:c};return a.callReturn()}},CODEino_set_rgb_add_value:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[["\ube68\uac15","17"],["\ucd08\ub85d","18"],["\ud30c\ub791","19"]],value:"17",fontSize:11},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{type:"CODEino_set_rgb_add_value"},paramsKeyMap:{PORT:0,VALUE:1},"class":"CODEino_RGBLED_mode",isNotFor:["CODEino"],func:function(b, -a){b=Entry.hw.sendQueue;var d=a.getNumberField("PORT",a),c=a.getNumberValue("VALUE",a),c=Math.min(255,c),c=Math.max(0,c);17==d&&(CODEINO_RED+=c,CODEINO_RED=Math.min(255,CODEINO_RED),c=CODEINO_RED=Math.max(0,CODEINO_RED));18==d&&(CODEINO_GREEN+=c,CODEINO_GREEN=Math.min(255,CODEINO_GREEN),c=CODEINO_GREEN=Math.max(0,CODEINO_GREEN));19==d&&(CODEINO_BLUE+=c,CODEINO_BLUE=Math.min(255,CODEINO_BLUE),c=CODEINO_BLUE=Math.max(0,CODEINO_BLUE));b.TIME=Entry.ArduinoExt.getSensorTime(4);b.KEY=Entry.ArduinoExt.getSensorKey(); -b.SET||(b.SET={});b.SET[d]={type:4,data:c};return a.callReturn()}},CODEino_rgb_set_color:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Color"},{type:"Indicator",img:"block_icon/brush_03.png",size:12}],events:{},def:{params:[null],type:"CODEino_rgb_set_color"},paramsKeyMap:{VALUE:0},"class":"CODEino_RGBLED_mode",isNotFor:["CODEino"],func:function(b,a){b=a.getStringField("VALUE");CODEINO_RED=parseInt(b.substr(1,2),16);CODEINO_GREEN=parseInt(b.substr(3,2),16);CODEINO_BLUE=parseInt(b.substr(5, -2),16);b=Entry.hw.sendQueue;var d=17;b.TIME=Entry.ArduinoExt.getSensorTime(4);b.KEY=Entry.ArduinoExt.getSensorKey();b.SET||(b.SET={});b.SET[d]={type:4,data:CODEINO_RED};b=Entry.hw.sendQueue;d=18;b.TIME=Entry.ArduinoExt.getSensorTime(4);b.KEY=Entry.ArduinoExt.getSensorKey();b.SET||(b.SET={});b.SET[d]={type:4,data:CODEINO_GREEN};b=Entry.hw.sendQueue;d=19;b.TIME=Entry.ArduinoExt.getSensorTime(4);b.KEY=Entry.ArduinoExt.getSensorKey();b.SET||(b.SET={});b.SET[d]={type:4,data:CODEINO_BLUE};return a.callReturn()}}, -CODEino_set_rgb_off:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null],type:"CODEino_set_rgb_off"},"class":"CODEino_RGBLED_mode",isNotFor:["CODEino"],func:function(b,a){b=Entry.hw.sendQueue;CODEINO_GREEN=CODEINO_BLUE=CODEINO_RED=0;var d=17;b.TIME=Entry.ArduinoExt.getSensorTime(4);b.KEY=Entry.ArduinoExt.getSensorKey();b.SET||(b.SET={});b.SET[d]={type:4,data:0};b=Entry.hw.sendQueue;d=18;b.TIME=Entry.ArduinoExt.getSensorTime(4); -b.KEY=Entry.ArduinoExt.getSensorKey();b.SET||(b.SET={});b.SET[d]={type:4,data:0};b=Entry.hw.sendQueue;d=19;b.TIME=Entry.ArduinoExt.getSensorTime(4);b.KEY=Entry.ArduinoExt.getSensorKey();b.SET||(b.SET={});b.SET[d]={type:4,data:0};return a.callReturn()}},CODEino_set__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:"CODEino_set__led_by_rgb"},paramsKeyMap:{rValue:0,gValue:1,bValue:2},"class":"CODEino_RGBLED_mode",isNotFor:["CODEino"],func:function(b,a){CODEINO_RED=a.getNumberValue("rValue");CODEINO_GREEN=a.getNumberValue("gValue");CODEINO_BLUE=a.getNumberValue("bValue");b=Entry.hw.sendQueue;var d=17;b.TIME=Entry.ArduinoExt.getSensorTime(4);b.KEY=Entry.ArduinoExt.getSensorKey();b.SET||(b.SET={});b.SET[d]={type:4,data:CODEINO_RED}; -b=Entry.hw.sendQueue;d=18;b.TIME=Entry.ArduinoExt.getSensorTime(4);b.KEY=Entry.ArduinoExt.getSensorKey();b.SET||(b.SET={});b.SET[d]={type:4,data:CODEINO_GREEN};b=Entry.hw.sendQueue;d=19;b.TIME=Entry.ArduinoExt.getSensorTime(4);b.KEY=Entry.ArduinoExt.getSensorKey();b.SET||(b.SET={});b.SET[d]={type:4,data:CODEINO_BLUE};return a.callReturn()}},CODEino_led_by_value:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null], -type:"CODEino_led_by_value"},"class":"CODEino_RGBLED_mode",isNotFor:["CODEino"],func:function(b,a){b=Entry.hw.sendQueue;var d=17;CODEINO_BLUE=CODEINO_GREEN=CODEINO_RED=100;b.TIME=Entry.ArduinoExt.getSensorTime(4);b.KEY=Entry.ArduinoExt.getSensorKey();b.SET||(b.SET={});b.SET[d]={type:4,data:100};b=Entry.hw.sendQueue;d=18;b.TIME=Entry.ArduinoExt.getSensorTime(4);b.KEY=Entry.ArduinoExt.getSensorKey();b.SET||(b.SET={});b.SET[d]={type:4,data:100};b=Entry.hw.sendQueue;d=19;b.TIME=Entry.ArduinoExt.getSensorTime(4); -b.KEY=Entry.ArduinoExt.getSensorKey();b.SET||(b.SET={});b.SET[d]={type:4,data:100};return a.callReturn()}},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",syntax:{js:[],py:["hw.CODEino_get_number_sensor_value(%1)"]}},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",syntax:{js:[],py:["hw.CODEino_toggle_led(%1)"]}},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",syntax:{js:[],py:["hw.CODEino_toggle_pwm(%1, %2)"]}},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){b=a.getNumberField("PORT",a);return 14a?1:0;if("RIGHT"==b||"FRONT"==b)return 30a?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 d=Entry.hw.getAnalogPortValue(a.getField("PORT",a)),c=265,e=402;b=-90;a=90;if(c>e)var f=c,c=e,e=f;b>a&&(f=b,b=a,a=f);d=(a-b)/(e-c)* -(d-c);d+=b;d=Math.min(a,d);d=Math.max(b,d);return Math.round(d)}},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){b=a.getStringField("PORT");return Entry.hw.portData[b].value},syntax:{js:[], -py:["Bitbrick.sensor_value(%1)"]}},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},syntax:{js:[],py:["Bitbrick.is_touch_pressed(%1)"]}},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()},syntax:{js:[],py:["Bitbrick.turn_off_color_led()"]}},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){b=a.getNumberValue("rValue");var d=a.getNumberValue("gValue"),c=a.getNumberValue("bValue"),e=Entry.adjustValueWithMaxMin, -f=Entry.hw.sendQueue;f.LEDR=e(b,0,255);f.LEDG=e(d,0,255);f.LEDB=e(c,0,255);return a.callReturn()},syntax:{js:[],py:["Bitbrick.color_led_by_rgb(%1, %2, %3)"]}},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){b=a.getStringField("VALUE"); -Entry.hw.sendQueue.LEDR=parseInt(b.substr(1,2),16);Entry.hw.sendQueue.LEDG=parseInt(b.substr(3,2),16);Entry.hw.sendQueue.LEDB=parseInt(b.substr(5,2),16);return a.callReturn()},syntax:{js:[],py:["Bitbrick.color_led_by_picker(%1)"]}},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){b=a.getNumberValue("VALUE");var d,c,e;b%=200;67>b?(d=200-3*b,c=3*b,e=0):134>b?(b-=67,d=0,c=200-3*b,e=3*b):201>b&&(b-=134,d=3*b,c=0,e=200-3*b);Entry.hw.sendQueue.LEDR=d;Entry.hw.sendQueue.LEDG=c;Entry.hw.sendQueue.LEDB=e;return a.callReturn()},syntax:{js:[],py:["Bitbrick.color_led_by_value(%1)"]}},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();b=a.getNumberValue("VALUE");Entry.hw.sendQueue.buzzer=b;a.isStart=!0;return a},syntax:{js:[],py:["Bitbrick.buzzer(%1)"]}},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 d=Entry.hw.sendQueue;b=Entry.Bitbrick;b.servoList().map(function(a){d[a[1]]=0});b.dcList().map(function(a){d[a[1]]=128});return a.callReturn()},syntax:{js:[],py:["Bitbrick.turn_off_all_motors()"]}},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){b=a.getNumberValue("VALUE");b=Math.min(b,Entry.Bitbrick.dcMaxValue);b=Math.max(b,Entry.Bitbrick.dcMinValue);Entry.hw.sendQueue[a.getStringField("PORT")]=b+128;return a.callReturn()},syntax:{js:[],py:["Bitbrick.dc_speed(%1, %2)"]}}, -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){b="CW"===a.getStringField("DIRECTION");var d=a.getNumberValue("VALUE"),d=Math.min(d,Entry.Bitbrick.dcMaxValue),d=Math.max(d,0);Entry.hw.sendQueue[a.getStringField("PORT")]=b?d+128:128-d;return a.callReturn()},syntax:{js:[],py:["Bitbrick.dc_direction_speed(%1, %2, %3)"]}},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){b=Entry.Bitbrick.servoMaxValue-(a.getNumberValue("VALUE")+1);b=Math.min(b,Entry.Bitbrick.servoMaxValue);b=Math.max(b,Entry.Bitbrick.servoMinValue);Entry.hw.sendQueue[a.getStringField("PORT")]=b;return a.callReturn()},syntax:{js:[], -py:["Bitbrick.servomotor_angle(%1, %2)"]}},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){b=a.getNumberField("PORT");var d=Entry.hw.portData[b].value,c=a.getNumberValue("VALUE2",a),e=a.getNumberValue("VALUE3",a);b=a.getNumberValue("VALUE4",a);a=a.getNumberValue("VALUE5",a);if(b>a){var f=b;b=a;a=f}d=(a-b)/(e-c)*(d-c);d+=b;d=Math.min(a,d);d=Math.max(b,d);return Math.round(d)},syntax:{js:[],py:["Bitbrick.convert_scale(%1, %2, %3, %4, %5)"]}}, -cobl_read_ultrason:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",template:"1. \ucd08\uc74c\ud30c\uac70\ub9ac(0~400)",def:{type:"cobl_read_ultrason"},class:"cobl",isNotFor:["cobl"],func:function(b,a){return Entry.hw.getAnalogPortValue("ultrason")}},cobl_read_potenmeter:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",template:"2.\uac00\ubcc0\uc800\ud56d(0~1023)",def:{type:"cobl_read_potenmeter"},class:"cobl",isNotFor:["cobl"],func:function(b,a){return Entry.hw.getAnalogPortValue("potenmeter")}}, -cobl_read_irread1:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",template:"3.\uc801\uc678\uc120\uc13c\uc11c1(0~1023)",def:{type:"cobl_read_irread1"},class:"cobl",isNotFor:["cobl"],func:function(b,a){return Entry.hw.getAnalogPortValue("irread1")}},cobl_read_irread2:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",template:"4.\uc801\uc678\uc120\uc13c\uc11c2(0~1023)",def:{type:"cobl_read_irread2"},class:"cobl",isNotFor:["cobl"],func:function(b,a){return Entry.hw.getAnalogPortValue("irread2")}}, -cobl_read_joyx:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",template:"5.\uc870\uc774\uc2a4\ud2f1X\ucd95(1, 0, -1)",def:{type:"cobl_read_joyx"},class:"cobl",isNotFor:["cobl"],func:function(b,a){return Entry.hw.getAnalogPortValue("joyx")}},cobl_read_joyy:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",template:"6.\uc870\uc774\uc2a4\ud2f1Y\ucd95(1, 0, -1)",def:{type:"cobl_read_joyy"},class:"cobl",isNotFor:["cobl"],func:function(b,a){return Entry.hw.getAnalogPortValue("joyy")}}, -cobl_read_tilt:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",template:"7.\uae30\uc6b8\uae30\uc13c\uc11c(0~4)",def:{type:"cobl_read_tilt"},class:"cobl",isNotFor:["cobl"],func:function(b,a){return Entry.hw.getAnalogPortValue("tilt")}},cobl_read_temps:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",template:"8.\uc628\ub3c4\uc13c\uc11c@\ud3ec\ud2b8%1",params:[{type:"Dropdown",options:[["1","1"],["2","2"]],fontSize:11}],def:{params:["1"],type:"cobl_read_temps"},paramsKeyMap:{VALUE:0}, -class:"cobl",isNotFor:["cobl"],func:function(b,a){b=a.getValue("VALUE",a);if(1==b)return Entry.hw.getAnalogPortValue("temps1");if(2==b)return Entry.hw.getAnalogPortValue("temps2")}},cobl_read_light:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",template:"9.\ube5b\uc13c\uc11c@\ud3ec\ud2b8%1",params:[{type:"Dropdown",options:[["1","1"],["2","2"]],fontSize:11}],def:{params:["1"],type:"cobl_read_light"},paramsKeyMap:{VALUE:0},class:"cobl",isNotFor:["cobl"],func:function(b,a){b=a.getValue("VALUE", -a);if(1==b)return Entry.hw.getAnalogPortValue("light1");if(2==b)return Entry.hw.getAnalogPortValue("light2")}},cobl_read_btn:{color:"#00979D",fontColor:"#fff",skeleton:"basic_boolean_field",template:"10.\ubc84\ud2bc\uc2a4\uc704\uce58@\ud3ec\ud2b8%1",params:[{type:"Dropdown",options:[["1","1"],["2","2"]],fontSize:11}],def:{params:["1"],type:"cobl_read_btn"},paramsKeyMap:{VALUE:0},class:"cobl",isNotFor:["cobl"],func:function(b,a){b=a.getValue("VALUE",a);if(1==b)return Entry.hw.getDigitalPortValue("btn1"); -if(2==b)return Entry.hw.getDigitalPortValue("btn2")}},cobl_led_control:{color:"#00979D",fontColor:"#fff",skeleton:"basic",template:"11.\ubb34\uc9c0\uac1cLED%1%2 %3",params:[{type:"Dropdown",options:[["1","1"],["2","2"],["3","3"]],fontSize:11},{type:"Dropdown",options:[["OFF","OFF"],["\ube68\uac15","Red"],["\uc8fc\ud669","Orange"],["\ub178\ub791","Yellow"],["\ucd08\ub85d","Green"],["\ud30c\ub791","Blue"],["\ub0a8\uc0c9","Dark Blue"],["\ubcf4\ub77c","Purple"],["\ud770\uc0c9","White"]],fontSize:11}, -{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],def:{params:["1","OFF"],type:"cobl_led_control"},paramsKeyMap:{PORT:0,OPERATOR:1},class:"cobl",isNotFor:["cobl"],func:function(b,a){b=a.getStringField("PORT");var d=a.getStringField("OPERATOR");Entry.hw.setDigitalPortValue("RainBowLED_"+b,d);Entry.hw.update();delete Entry.hw.sendQueue["RainBowLED_"+b];return a.callReturn()}},cobl_servo_angle_control:{color:"#00979D",fontColor:"#fff",skeleton:"basic",template:"12.\uac01\ub3c4\ubaa8\ud130 \uac01\ub3c4%1(15~165) %2", -params:[{type:"TextInput",value:0},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],def:{type:"cobl_servo_angle_control"},paramsKeyMap:{VALUE:0},class:"cobl",isNotFor:["cobl"],func:function(b,a){b=a.getNumberField("VALUE");b=Math.round(b);b=Math.max(b,15);b=Math.min(b,165);Entry.hw.setDigitalPortValue("Servo1",b);Entry.hw.update();delete Entry.hw.sendQueue.Servo1;return a.callReturn()}},cobl_melody:{color:"#00979D",fontColor:"#fff",skeleton:"basic",template:"13.\uba5c\ub85c\ub514%1 ,%2", -params:[{type:"Dropdown",options:[["((\ub0ae\uc740)\uc194","L_So"],["(\ub0ae\uc740)\uc194#","L_So#"],["(\ub0ae\uc740)\ub77c","L_La"],["(\ub0ae\uc740)\ub77c#","L_La#"],["(\ub0ae\uc740)\uc2dc","L_Ti"],["\ub3c4","Do"],["\ub3c4#","Do#"],["\ub808","Re"],["\ub808#","Re#"],["\ubbf8","Mi"],["\ud30c","Fa"],["\ud30c#","Fa#"],["\uc194","So"],["\uc194#","So#"],["\ub77c","La"],["\ub77c#","La#"],["\uc2dc","Ti"],["(\ub192\uc740)\ub3c4","H_Do"],["(\ub192\uc740)\ub3c4#","H_Do#"],["(\ub192\uc740)\ub808","H_Re"],["(\ub192\uc740)\ub808#", -"H_Re#"],["(\ub192\uc740)\ubbf8#","H_Mi"],["(\ub192\uc740)\ud30c","H_Fa"]],fontSize:11},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],def:{params:["Do"],type:"cobl_melody"},paramsKeyMap:{MELODY:0},class:"cobl",isNotFor:["cobl"],func:function(b,a){b=a.getStringField("MELODY");Entry.hw.setDigitalPortValue("Melody",b);Entry.hw.update();delete Entry.hw.sendQueue.Melody;return a.callReturn()}},cobl_dcmotor:{color:"#00979D",fontColor:"#fff",skeleton:"basic",template:"14.\ud68c\uc804\ubaa8\ud130%1%2\uc18d\ub3c4%3 %4", -params:[{type:"Dropdown",options:[["1","1"],["2","2"]],fontSize:11},{type:"Dropdown",options:[["1.\uc2dc\uacc4\ubc29\ud5a5","1"],["2.\ubc18\uc2dc\uacc4\ubc29\ud5a5","2"],["3.\uc815\uc9c0","3"]],fontSize:11},{type:"Dropdown",options:[["1","1"],["2","2"],["3","3"],["4","4"],["5","5"]],fontSize:11},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],def:{params:["1","1","1"],type:"cobl_dcmotor"},paramsKeyMap:{MOTOR:0,DIRECTION:1,SPEED:2},class:"cobl",isNotFor:["cobl"],func:function(b,a){b=a.getStringField("MOTOR"); -var d=a.getStringField("DIRECTION"),c=a.getStringField("SPEED");1==b&&(Entry.hw.setDigitalPortValue("DC1_DIR",d),Entry.hw.setDigitalPortValue("DC1_SPEED",c),Entry.hw.update(),delete Entry.hw.sendQueue.DC1_DIR,delete Entry.hw.sendQueue.DC1_SPEED);2==b&&(Entry.hw.setDigitalPortValue("DC2_DIR",d),Entry.hw.setDigitalPortValue("DC2_SPEED",c),Entry.hw.update(),delete Entry.hw.sendQueue.DC2_DIR,delete Entry.hw.sendQueue.DC2_SPEED);return a.callReturn()}},cobl_extention_port:{color:"#00979D",fontColor:"#fff", -skeleton:"basic",template:"15.USB\ud3ec\ud2b8%1\ub2e8\uacc4%2 %3",params:[{type:"Dropdown",options:[["1","1"],["2","2"]],fontSize:11},{type:"Dropdown",options:[["0","0"],["1","1"],["2","2"],["3","3"],["4","4"],["5","5"]],fontSize:11},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],def:{params:["1","0"],type:"cobl_extention_port"},paramsKeyMap:{PORT:0,LEVEL:1},class:"cobl",isNotFor:["cobl"],func:function(b,a){b=a.getStringField("PORT");var d=a.getStringField("LEVEL");1==b&&(Entry.hw.setDigitalPortValue("EXUSB1", -d),Entry.hw.update(),delete Entry.hw.sendQueue.EXUSB1);2==b&&(Entry.hw.setDigitalPortValue("EXUSB2",d),Entry.hw.update(),delete Entry.hw.sendQueue.EXUSB2);return a.callReturn()}},cobl_external_led:{color:"#00979D",fontColor:"#fff",skeleton:"basic",template:"16.\uc678\ubd80LED%1(1~64)R%2G%3B%4 %5",params:[{type:"TextInput",value:0,fontSize:11},{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"]],fontSize:11},{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"]],fontSize:11},{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"]],fontSize:11},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],def:{params:["1","1","1","1"],type:"cobl_external_led"},paramsKeyMap:{LED:0,RED:1,GREEN:2,BLUE:3},class:"cobl",isNotFor:["cobl"],func:function(b,a){b=a.getNumberField("LED"); -var d=a.getStringField("RED"),c=a.getStringField("GREEN"),e=a.getStringField("BLUE");Entry.hw.setDigitalPortValue("ELED_IDX",b);Entry.hw.setDigitalPortValue("ELED_R",d);Entry.hw.setDigitalPortValue("ELED_G",c);Entry.hw.setDigitalPortValue("ELED_B",e);Entry.hw.update();delete Entry.hw.sendQueue.ELED_IDX;delete Entry.hw.sendQueue.ELED_R;delete Entry.hw.sendQueue.ELED_G;delete Entry.hw.sendQueue.ELED_B;return a.callReturn()}},cobl_7_segment:{color:"#00979D",fontColor:"#fff",skeleton:"basic",template:"17.\uc22b\uc790\uc804\uad11\ud310%1(0~9999) %2", -params:[{type:"TextInput",value:0},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],def:{type:"cobl_7_segment"},paramsKeyMap:{VALUE:0},class:"cobl",isNotFor:["cobl"],func:function(b,a){b=a.getNumberField("VALUE");Entry.hw.setDigitalPortValue("7SEG",b);Entry.hw.update();delete Entry.hw.sendQueue["7SEG"];return a.callReturn()}},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()},syntax:{js:[],py:["Entry.start_drawing()"]}},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()},syntax:{js:[],py:["Entry.stop_drawing()"]}},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 d=a.getField("VALUE",a);b.brush||(Entry.setBasicBrush(b),b.brush.stop=!0);b.brush&&(d=Entry.hex2rgb(d),b.brush.rgb=d,b.brush.endStroke(),b.brush.beginStroke("rgba("+ -d.r+","+d.g+","+d.b+","+b.brush.opacity/100+")"),b.brush.moveTo(b.getX(),-1*b.getY()));return a.callReturn()},syntax:{js:[],py:["Entry.set_brush_color(%1)"]}},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 d=Entry.generateRgb();b.brush.rgb= -d;b.brush.endStroke();b.brush.beginStroke("rgba("+d.r+","+d.g+","+d.b+","+b.brush.opacity/100+")");b.brush.moveTo(b.getX(),-1*b.getY())}return a.callReturn()},syntax:{js:[],py:["Entry.set_brush_color_random()"]}},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 d=a.getNumberValue("VALUE",a);b.brush||(Entry.setBasicBrush(b),b.brush.stop=!0);b.brush&&(b.brush.thickness+=d,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()},syntax:{js:[],py:["Entry.add_brush_size(%1)"]}},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 d=a.getNumberValue("VALUE",a);b.brush||(Entry.setBasicBrush(b),b.brush.stop=!0);b.brush&&(b.brush.thickness=d,b.brush.setStrokeStyle(b.brush.thickness),b.brush.moveTo(b.getX(),-1*b.getY()));return a.callReturn()},syntax:{js:[],py:["Entry.set_brush_size(%1)"]}},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 d=a.getNumberValue("VALUE",a);b.brush||(Entry.setBasicBrush(b),b.brush.stop=!0);d=Entry.adjustValueWithMaxMin(b.brush.opacity+d,0,100);b.brush&&(b.brush.opacity=d,b.brush.endStroke(),d=b.brush.rgb,b.brush.beginStroke("rgba("+d.r+","+d.g+","+d.b+","+b.brush.opacity/ -100+")"),b.brush.moveTo(b.getX(),-1*b.getY()));return a.callReturn()},syntax:{js:[],py:[""]}},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 d=a.getNumberValue("VALUE",a);b.brush||(Entry.setBasicBrush(b),b.brush.stop=!0); -b.brush&&(b.brush.opacity=Entry.adjustValueWithMaxMin(d,0,100),b.brush.endStroke(),d=b.brush.rgb,b.brush.beginStroke("rgba("+d.r+","+d.g+","+d.b+","+b.brush.opacity/100+")"),b.brush.moveTo(b.getX(),-1*b.getY()));return a.callReturn()},syntax:{js:[],py:[""]}},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 d=b.brush;if(d){var c=d._stroke.style,e=d._strokeStyle.width;d.clear().setStrokeStyle(e).beginStroke(c);d.moveTo(b.getX(),-1*b.getY())}b=b.parent.getStampEntities();b.map(function(a){a.removeClone()});b=null;return a.callReturn()},syntax:{js:[],py:["Entry.clear_drawing()"]}},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()},syntax:{js:[],py:["Entry.stamp()"]}},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 d=a.getNumberValue("VALUE",a);b.brush||(Entry.setBasicBrush(b), -b.brush.stop=!0);d=Entry.adjustValueWithMaxMin(b.brush.opacity-d,0,100);b.brush&&(b.brush.opacity=d,b.brush.endStroke(),d=b.brush.rgb,b.brush.beginStroke("rgba("+d.r+","+d.g+","+d.b+","+b.brush.opacity/100+")"),b.brush.moveTo(b.getX(),-1*b.getY()));return a.callReturn()},syntax:{js:[],py:["Entry.add_brush_transparency(%1)"]}},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 d=a.getNumberValue("VALUE",a);b.brush||(Entry.setBasicBrush(b),b.brush.stop=!0);b.brush&&(b.brush.opacity=Entry.adjustValueWithMaxMin(d,0,100),b.brush.endStroke(),d=b.brush.rgb,b.brush.beginStroke("rgba("+d.r+","+d.g+","+d.b+","+(1-b.brush.opacity/100)+")"),b.brush.moveTo(b.getX(),-1*b.getY()));return a.callReturn()},syntax:{js:[], -py:["Entry.set_brush_transparency(%1)"]}},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,syntax:{js:["Scope","%1"],py:["%1number#"]}},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")}, -syntax:{js:[],py:["%1angle#"]}},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()},syntax:{js:[],py:[""]}},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()},syntax:{js:[],py:[""]}},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))},syntax:{js:[],py:[""]}},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))},syntax:{js:[],py:[""]}},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){a=a.getField("VALUE",a);if("mouse"==a)return a=Entry.stage.mouseCoordinate,Math.sqrt(Math.pow(b.getX()-a.x,2)+Math.pow(b.getY()-a.y,2));a=Entry.container.getEntity(a); -return Math.sqrt(Math.pow(b.getX()-a.getX(),2)+Math.pow(b.getY()-a.getY(),2))},syntax:{js:[],py:["Entry.value_of_distance(%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)?Number(Entry.stage.mouseCoordinate.x):Number(Entry.stage.mouseCoordinate.y)},syntax:{js:[],py:["Entry.coordinate_of_mouse(%2)"]}},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 d=a.getField("VALUE",a);b="self"==d?b:Entry.container.getEntity(d);switch(a.getField("COORDINATE",a)){case "x":return b.getX();case "y":return b.getY();case "rotation":return b.getRotation();case "direction":return b.getDirection();case "picture_index":return a=b.parent,a=a.pictures,a.indexOf(b.picture)+1;case "size":return Number(b.getSize().toFixed(1)); -case "picture_name":return a=b.parent,a=a.pictures,a[a.indexOf(b.picture)].name}},syntax:{js:[],py:["Entry.value_of(%2, %4)"]}},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){b=a.getField("OPERATOR", -a);var d=a.getNumberValue("LEFTHAND",a);a=a.getNumberValue("RIGHTHAND",a);return"PLUS"==b?d+a:"MINUS"==b?d-a:"MULTI"==b?d*a:d/a},syntax:{js:[],py:["(%1 %2calc_basic# %3)"]}},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){b=a.getNumberValue("LEFTHAND",a);a=a.getNumberValue("RIGHTHAND", -a);return b+a},syntax:{js:[],py:[""]}},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){b=a.getNumberValue("LEFTHAND",a);a=a.getNumberValue("RIGHTHAND",a);return b-a},syntax:{js:[],py:[""]}},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){b=a.getNumberValue("LEFTHAND",a);a=a.getNumberValue("RIGHTHAND",a);return b*a},syntax:{js:[],py:[""]}},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){b=a.getNumberValue("LEFTHAND",a);a=a.getNumberValue("RIGHTHAND",a);return b/a},syntax:{js:[],py:[""]}},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){b=a.getNumberValue("LEFTHAND",a);a=a.getNumberValue("RIGHTHAND",a);return b%a},syntax:{js:[],py:["Entry.get_remainder(%1, %3)"]}},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){b=a.getNumberValue("LEFTHAND",a);a=a.getNumberValue("RIGHTHAND",a);return Math.floor(b/a)},syntax:{js:[],py:[""]}},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){b=a.getNumberValue("LEFTHAND",a);a=a.getField("VALUE",a); -if(-1<["asin_radian","acos_radian"].indexOf(a)&&(1b))throw Error("x range exceeded");a.indexOf("_")&&(a=a.split("_")[0]);-1<["sin","cos","tan"].indexOf(a)&&(b=Entry.toRadian(b));switch(a){case "square":a=b*b;break;case "factorial":a=Entry.factorial(b);break;case "root":a=Math.sqrt(b);break;case "log":a=Math.log(b)/Math.LN10;break;case "ln":a=Math.log(b);break;case "asin":case "acos":case "atan":a=Entry.toDegrees(Math[a](b));break;case "unnatural":a=b-Math.floor(b);0>b&&(a=1-a);break;default:a= -Math[a](b)}return a},syntax:{js:[],py:["Entry.value_of_math_operation(%2, %4)"]}},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){b=a.getStringValue("LEFTHAND",a);a=a.getStringValue("RIGHTHAND",a);var d=Math.min(b,a),c=Math.max(b,a);b=Entry.isFloat(b);return Entry.isFloat(a)||b?(Math.random()*(c-d)+d).toFixed(2):Math.floor(Math.random()*(c-d+1)+d)},syntax:{js:[],py:["random.randint(%2, %4)"]}},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){b=a.getField("VALUE",a);a=new Date;return"YEAR"==b?a.getFullYear():"MONTH"==b?a.getMonth()+1:"DAY"==b?a.getDate():"HOUR"==b?a.getHours():"MINUTE"==b?a.getMinutes():a.getSeconds()},syntax:{js:[],py:["Entry.value_of_date_time(%2)"]}},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){a=a.getField("VALUE",a);b=b.parent.sounds;for(var d=0;da||a>b.length-1)throw Error();return b[a]},syntax:{js:[],py:["Entry.string_index_of(%2, %4)"]}},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},syntax:{js:[],py:["Entry.string_length(%2)"]}},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){b=a.getStringValue("STRING",a);var d=a.getNumberValue("START",a)-1;a=a.getNumberValue("END",a)-1;var c=b.length-1;if(0>d||0>a||d>c||a>c)throw Error();return b.substring(Math.min(d,a),Math.max(d,a)+1)},syntax:{js:[],py:["Entry.string_substring(%2, %4, %6)"]}},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))},syntax:{js:[],py:["Entry.string_replace(%2, %4, %6)"]}},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)]()},syntax:{js:[],py:["Entry.string_case(%2, %4)"]}}, -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){b=a.getStringValue("LEFTHAND",a);a=a.getStringValue("RIGHTHAND",a);a=b.indexOf(a);return-1b)throw Error(Lang.Blocks.FLOW_repeat_basic_errorMsg);a.iterCount=Math.floor(b)}if(0==a.iterCount||0>a.iterCount)return delete a.isLooped,delete a.iterCount,a.callReturn();a.iterCount--;return a.getStatement("DO",a)},syntax:{js:[],py:["for i in range(%1):\n$1"]}},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")},syntax:{js:[],py:["while True:\n$1"]}},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()},syntax:{js:[],py:["break"]}},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},syntax:{js:[],py:["Entry.wait_until(%1)"]}},_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()},syntax:{js:[],py:["if %1:\n$1"]}},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();b=a.getBooleanValue("BOOL",a);a.isCondition=!0;return b?a.getStatement("STACK_IF",a):a.getStatement("STACK_ELSE", -a)},syntax:{js:[],py:["if %1:\n$1\nelse:\n$2"]}},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 d=a.getField("VALUE",a);a=a.callReturn();"self"==d?b.parent.addCloneEntity(b.parent,b,null): -Entry.container.getObject(d).addCloneEntity(b.parent,null,null);return a},syntax:{js:[],py:["Entry.create_clone(%1)"]}},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()},syntax:{js:[],py:["Entry.remove_clone()"]}},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",syntax:{js:[],py:["def entry_event_clone_create():"]}},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()},syntax:{js:[],py:[""]}},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){b=a.getBooleanValue("BOOL",a);"until"==a.getField("OPTION",a)&&(b=!b);return(a.isLooped=b)?a.getStatement("DO",a):a.callReturn()},syntax:{js:[],py:["not yet supported in textcoding"]}},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 d=a.getField("TARGET",a),c=Entry.container;switch(d){case "all":return c.mapObject(function(a){a.script.clearExecutors()},null),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":d=this.executor;b=b.parent.script;for(var c=b.executors,e=0;ea.count?(50>d.leftFloor&&50>d.rightFloor?a.count++:a.count=0,d=d.leftFloor-d.rightFloor,b.leftWheel=45+.25*d,b.rightWheel=45-.25*d):(a.count=0,a.boardState=2);break;case 2:d=d.leftFloor-d.rightFloor;b.leftWheel=45+.25*d;b.rightWheel=45-.25*d;a.boardState=3;var c=setTimeout(function(){a.boardState=4;Entry.Hamster.removeTimeout(c)},250);Entry.Hamster.timeouts.push(c);break;case 3:d= -d.leftFloor-d.rightFloor;b.leftWheel=45+.25*d;b.rightWheel=45-.25*d;break;case 4:b.leftWheel=0,b.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;b.leftWheel=0;b.rightWheel=0;return a.callReturn()}a.isStart=!0;a.isMoving=!0;a.count=0;a.boardState=1;b.leftWheel=45;b.rightWheel=45;Entry.Hamster.setLineTracerMode(b,0);return a},syntax:{js:[],py:["Hamster.move_forward()"]}},hamster_turn_once:{color:"#00979D", -skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.HAMSTER_turn_once_left,"LEFT"],[Lang.Blocks.HAMSTER_turn_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){b=Entry.hw.sendQueue;var 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: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 a.callReturn()},syntax:{js:[],py:["Hamster.add_tempo(%1)"]}},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()},syntax:{js:[],py:["Hamster.set_tempo(%1)"]}},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){b=Entry.hw.sendQueue;var d=a.getField("PORT",a),c=Number(a.getField("MODE",a));"A"==d?b.ioModeA=c:("B"!=d&&(b.ioModeA=c),b.ioModeB=c);return a.callReturn()},syntax:{js:[],py:["Hamster.set_port(%1, %2)"]}}, -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){b=Entry.hw.sendQueue;var d=a.getField("PORT"),c=a.getNumberValue("VALUE");"A"==d?b.outputA=void 0!=b.outputA?b.outputA+c:c:("B"!=d&&(b.outputA=void 0!=b.outputA?b.outputA+c:c),b.outputB=void 0!=b.outputB?b.outputB+c:c);return a.callReturn()},syntax:{js:[],py:["Hamster.add_output(%1, %2)"]}},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){b=Entry.hw.sendQueue;var d=a.getField("PORT"),c=a.getNumberValue("VALUE");"A"==d?b.outputA=c:("B"!=d&&(b.outputA=c),b.outputB=c);return a.callReturn()},syntax:{js:[],py:["Hamster.set_output(%1, %2)"]}}, -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},syntax:{js:[],py:["Entry.is_mouse_clicked()"]}},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){b=Number(a.getField("VALUE",a));return 0<=Entry.pressedKeys.indexOf(b)},syntax:{js:[],py:["Entry.is_pressed(%1)"]}},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 d=a.getField("VALUE",a);a=b.object;var c=/wall/.test(d),e=ndgmr.checkPixelCollision;if(c)switch(b=Entry.stage.wall,d){case "wall":return!!(e(a,b.up,.2,!0)||e(a,b.down,.2,!0)||e(a,b.left,.2,!0)||e(a,b.right, -.2,!0));case "wall_up":return!!e(a,b.up,.2,!0);case "wall_down":return!!e(a,b.down,.2,!0);case "wall_right":return!!e(a,b.right,.2,!0);case "wall_left":return!!e(a,b.left,.2,!0)}else{if("mouse"==d)return e=Entry.stage.canvas,e=a.globalToLocal(e.mouseX,e.mouseY),a.hitTest(e.x,e.y);d=Entry.container.getEntity(d);if("textBox"==d.type||"textBox"==b.type){e=d.object.getTransformedBounds();a=a.getTransformedBounds();if(Entry.checkCollisionRect(a,e))return!0;b=d.parent.clonedEntities;d=0;for(c=b.length;d< -c;d++){var f=b[d];if(!f.isStamp&&f.getVisible()&&Entry.checkCollisionRect(a,f.object.getTransformedBounds()))return!0}}else{if(d.getVisible()&&e(a,d.object,.2,!0))return!0;b=d.parent.clonedEntities;d=0;for(c=b.length;d","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){b=a.getField("OPERATOR",a);var d=a.getNumberValue("LEFTHAND",a);a=a.getNumberValue("RIGHTHAND",a);return"EQUAL"==b?d==a:"BIGGER"==b?d>a: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){b=a.getNumberValue("LEFTHAND",a);a=a.getNumberValue("RIGHTHAND",a);return b>a},syntax:{js:[],py:[""]}},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){b=a.getNumberValue("LEFTHAND",a);a=a.getNumberValue("RIGHTHAND",a);return b","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){b=a.getField("OPERATOR",a);var d=a.getStringValue("LEFTHAND",a);a=a.getStringValue("RIGHTHAND",a);switch(b){case "EQUAL":return d==a;case "GREATER":return Number(d)>Number(a);case "LESS":return Number(d)=Number(a);case "LESS_OR_EQUAL":return Number(d)<= -Number(a)}},syntax:{js:[],py:["(%1 %2boolean_compare# %3)"]}},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()},syntax:{js:[],py:["Entry.show()"]}},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()},syntax:{js:[],py:["Entry.hide()"]}},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 d=a.getNumberValue("SECOND",a),c=a.getStringValue("VALUE",a),e=a.getField("OPTION",a);a.isStart=!0;a.timeFlag=1;c||"number"==typeof c||(c=" ");c=Entry.convertToRoundedDecimals(c,3);new Entry.Dialog(b,c,e);b.syncDialogVisible(b.getVisible());setTimeout(function(){a.timeFlag=0},1E3*d)}if(0==a.timeFlag)return delete a.timeFlag, -delete a.isStart,b.dialog&&b.dialog.remove(),a.callReturn();b.dialog||(c=a.getStringValue("VALUE",a),e=a.getField("OPTION",a),c||"number"==typeof c||(c=" "),c=Entry.convertToRoundedDecimals(c,3),new Entry.Dialog(b,c,e),b.syncDialogVisible(b.getVisible()));return a},syntax:{js:[],py:["Entry.print_for_seconds(%1, %2, %3)"]}},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 d=a.getStringValue("VALUE",a);d||"number"==typeof d||(d=" ");var c=a.getField("OPTION",a),d=Entry.convertToRoundedDecimals(d,3);new Entry.Dialog(b,d,c);b.syncDialogVisible(b.getVisible());return a.callReturn()},syntax:{js:[], -py:["Entry.print(%1)"]}},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()},syntax:{js:[],py:["Entry.print_remove()"]}},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 d=a.getField("VALUE",a),d=b.parent.getPicture(d);b.setImage(d);return a.callReturn()},syntax:{js:[],py:[""]}},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 d;d="prev"!==a.getStringField("DRIECTION")?b.parent.getNextPicture(b.picture.id):b.parent.getPrevPicture(b.picture.id);b.setImage(d);return a.callReturn()},syntax:{js:[],py:["Entry.set_shape_of(%1)"]}},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 d=a.getField("EFFECT",a),c=a.getNumberValue("VALUE",a); -"color"==d?b.effect.hue=c+b.effect.hue:"lens"!=d&&"swriling"!=d&&"pixel"!=d&&"mosaic"!=d&&("brightness"==d?b.effect.brightness=c+b.effect.brightness:"blur"!=d&&"opacity"==d&&(b.effect.alpha+=c/100));b.applyFilter(!0);return a.callReturn()},syntax:{js:[],py:["Entry.add_effect(%1, %2)"]}},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 d=a.getField("EFFECT",a),c=a.getNumberValue("VALUE",a);"color"==d?b.effect.hue=c:"lens"!=d&&"swriling"!=d&&"pixel"!=d&&"mosaic"!=d&&("brightness"==d?b.effect.brightness=c:"blur"!=d&&"opacity"==d&&(b.effect.alpha=c/100));b.applyFilter(!0); -return a.callReturn()},syntax:{js:[],py:["Entry.set_effect(%1, %2)"]}},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()},syntax:{js:[],py:["Entry.clear_effect()"]}},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 d=(a.getNumberValue("VALUE",a)+100)/100;b.setScaleX(b.getScaleX()*d);b.setScaleY(b.getScaleY()*d);return a.callReturn()},syntax:{js:[],py:[""]}},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 d=a.getNumberValue("VALUE",a)/100,c=b.snapshot_;b.setScaleX(d*c.scaleX);b.setScaleY(d*c.scaleY);return a.callReturn()},syntax:{js:[],py:[""]}},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 d=a.getNumberValue("VALUE",a);b.setSize(b.getSize()+d);return a.callReturn()},syntax:{js:[],py:["Entry.add_size(%1)"]}},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 d=a.getNumberValue("VALUE",a);b.setSize(d);return a.callReturn()},syntax:{js:[],py:["Entry.set_size(%1)"]}},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()},syntax:{js:[],py:["Entry.flip_vertical()"]}},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()},syntax:{js:[],py:["Entry.flip_horizontal()"]}},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 d=a.getField("VALUE",a);b=Entry.container.getCurrentObjects().indexOf(b.parent);if(-1b)throw Error("object is not available for current scene");switch(c){case "FRONT":d= -0;break;case "FORWARD":d=Math.max(0,b-1);break;case "BACKWARD":d=Math.min(e,b+1);break;case "BACK":d=e}Entry.container.moveElementByBlock(b,d);return a.callReturn()},syntax:{js:[],py:["Entry.set_layer(%1)"]}},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 d=a.getNumberValue("VALUE",a);b.setX(b.getX()+d*Math.cos((b.getRotation()+b.getDirection()-90)/180*Math.PI));b.setY(b.getY()-d*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()},syntax:{js:[],py:["Entry.move(%1)"]}},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 d=a.getNumberValue("VALUE",a);b.setX(b.getX()+d);b.brush&&!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY());return a.callReturn()},syntax:{js:[],py:["Entry.set_x(%1)"]}},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 d=a.getNumberValue("VALUE",a);b.setY(b.getY()+d);b.brush&&!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY());return a.callReturn()},syntax:{js:[],py:["Entry.set_y(%1)"]}},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 d(){var d=a.x-b.getX(),c=a.y-b.getY(),d=d/a.frameCount,c=c/a.frameCount;b.setX(b.getX()+d);b.setY(b.getY()+c);a.frameCount--;b.brush&&!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY())}if(!a.isStart){var c;c=a.getNumberValue("VALUE1",a);a.isStart=!0;a.frameCount= -Math.max(Math.floor(c*Entry.FPS),1);a.x=a.getNumberValue("VALUE2",a);a.y=a.getNumberValue("VALUE3",a);1==a.frameCount&&d()}if(0!=a.frameCount)return d(),a;delete a.isStart;delete a.frameCount;return a.callReturn()},syntax:{js:[],py:["Entry.set_xy_for_seconds(%1, %2, %3)"]}},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 d=a.getNumberValue("VALUE",a);b.setRotation(b.getRotation()+d);return a.callReturn()},syntax:{js:[],py:[""]}},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 d=a.getField("VALUE",a);b.setRotation(b.getRotation()+Number(d));return a.callReturn()},syntax:{js:[],py:[""]}},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 d=a.getNumberValue("VALUE",a);b.setDirection(d); -return a.callReturn()},syntax:{js:[],py:[""]}},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 d=a.getField("VALUE",a),c=Entry.container.getEntity(d),d=c.getX()-b.getX(),c=c.getY()-b.getY();0<=d?b.setRotation(Math.atan(c/d)/Math.PI*180+90):b.setRotation(Math.atan(c/d)/Math.PI* -180+270);return a.callReturn()},syntax:{js:[],py:[""]}},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 d=a.getNumberValue("VALUE1",a),c=a.getNumberValue("VALUE2",a); -b.setX(d);b.setY(c);b.brush&&!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY());return a.callReturn()},syntax:{js:[],py:["Entry.set_xy(%1, %2)"]}},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 d=a.getNumberValue("VALUE",a);b.setX(d); -b.brush&&!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY());return a.callReturn()},syntax:{js:[],py:["Entry.move_x(%1)"]}},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 d=a.getNumberValue("VALUE",a);b.setY(d);b.brush&&!b.brush.stop&& -b.brush.lineTo(b.getX(),-1*b.getY());return a.callReturn()},syntax:{js:[],py:["Entry.move_y(%1)"]}},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 d=a.getField("VALUE",a),c;"mouse"== -d?(d=Entry.stage.mouseCoordinate.x,c=Entry.stage.mouseCoordinate.y):(c=Entry.container.getEntity(d),d=c.getX(),c=c.getY());b.setX(Number(d));b.setY(Number(c));b.brush&&!b.brush.stop&&b.brush.lineTo(d,-1*c);return a.callReturn()},syntax:{js:[],py:["Entry.set_location(%1)"]}},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 d(){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 c;c=a.getNumberValue("VALUE1",a);var e=a.getNumberValue("VALUE2",a),f=a.getNumberValue("VALUE3",a);a.isStart=!0;a.frameCount= -Math.max(Math.floor(c*Entry.FPS),1);a.dX=e/a.frameCount;a.dY=f/a.frameCount;1==a.frameCount&&d()}if(0!=a.frameCount)return d(),a;delete a.isStart;delete a.frameCount;return a.callReturn()},syntax:{js:[],py:["Entry.add_xy_for_seconds(%1, %2, %3)"]}},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 d;d=a.getNumberValue("VALUE",a);var c=a.getNumberField("VALUE",a);a.isStart=!0;a.frameCount=Math.floor(d*Entry.FPS);a.dAngle=c/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()},syntax:{js:[],py:[""]}},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 d=b.parent.getRotateMethod(),c="free"==d?(b.getRotation()+b.getDirection()).mod(360):b.getDirection(),e;if(90>c&&0<=c||360>c&&270<=c){e=b.collision==Entry.Utils.COLLISION.UP;var 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"==d?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"==d?b.setRotation(-b.getRotation()-2*b.getDirection()+180):b.setDirection(-b.getDirection()+180),b.collision=Entry.Utils.COLLISION.DOWN))}else 270>c&&90<=c&&(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"==d?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"==d?b.setRotation(-b.getRotation()-2*b.getDirection()+180):b.setDirection(-b.getDirection()+180),b.collision=Entry.Utils.COLLISION.UP)));360> -c&&180<=c?(e=b.collision==Entry.Utils.COLLISION.LEFT,c=ndgmr.checkPixelCollision(Entry.stage.wall.left,b.object,0,!1),!c&&e&&(b.collision=Entry.Utils.COLLISION.NONE),c&&e&&(c=!1),c?("free"==d?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,c=ndgmr.checkPixelCollision(Entry.stage.wall.right,b.object,0,!1),!c&&e&&(b.collision=Entry.Utils.COLLISION.NONE),c&&e&&(c=!1),c&&("free"== -d?b.setRotation(-b.getRotation()-2*b.getDirection()):b.setDirection(-b.getDirection()+360),b.collision=Entry.Utils.COLLISION.RIGHT))):180>c&&0<=c&&(e=b.collision==Entry.Utils.COLLISION.RIGHT,c=ndgmr.checkPixelCollision(Entry.stage.wall.right,b.object,0,!1),!c&&e&&(b.collision=Entry.Utils.COLLISION.NONE),c&&e&&(c=!1),c?("free"==d?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, -c=ndgmr.checkPixelCollision(Entry.stage.wall.left,b.object,0,!1),!c&&e&&(b.collision=Entry.Utils.COLLISION.NONE),c&&e&&(c=!1),c&&("free"==d?b.setRotation(-b.getRotation()-2*b.getDirection()):b.setDirection(-b.getDirection()+360),b.collision=Entry.Utils.COLLISION.LEFT)));return a.callReturn()},syntax:{js:[],py:["Entry.bounce_wall()"]}},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()},syntax:{js:[],py:[""]}},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()},syntax:{js:[],py:[""]}},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 d=a.getField("VALUE",a),c=b.getX(),e=b.getY();if(b.parent.id==d)return a.callReturn();"mouse"==d?(d=Entry.stage.mouseCoordinate.y,c=Entry.stage.mouseCoordinate.x-c,e=d-e):(d=Entry.container.getEntity(d),c=d.getX()-c,e=d.getY()-e);e=0===c&&0===e? -b.getDirection()+b.getRotation():0<=c?-Math.atan(e/c)/Math.PI*180+90:-Math.atan(e/c)/Math.PI*180+270;c=b.getDirection()+b.getRotation();b.setRotation(b.getRotation()+e-c);return a.callReturn()},syntax:{js:[],py:["Entry.look_at_object(%1)"]}},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 d=a.getNumberValue("VALUE",a),c=b.getDirection()+b.getRotation();b.setRotation(b.getRotation()+d-c);return a.callReturn()},syntax:{js:[],py:[""]}},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 d=a.getNumberValue("VALUE",a);b.setDirection(d+b.getDirection());return a.callReturn()},syntax:{js:[],py:[""]}},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 d,c,e;c=a.getField("TARGET",a);d=a.getNumberValue("VALUE",a);d=Math.floor(d*Entry.FPS);e=Entry.stage.mouseCoordinate;if(0!=d)"mouse"==c?(c=e.x-b.getX(),e=e.y-b.getY()):(e=Entry.container.getEntity(c),c=e.getX()-b.getX(),e=e.getY()-b.getY()),a.isStart=!0,a.frameCount=d,a.dX=c/a.frameCount,a.dY=e/a.frameCount;else return"mouse"==c?(c=Number(e.x),e=Number(e.y)):(e=Entry.container.getEntity(c),c=e.getX(),e=e.getY()),b.setX(c), -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()},syntax:{js:[],py:["Entry.set_location_for_seconds(%1, %2)"]}},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 d=a.getNumberValue("VALUE",a);b.setRotation(d);return a.callReturn()},syntax:{js:[],py:["Entry.set_rotation(%1)"]}},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 d=a.getNumberValue("VALUE",a);b.setRotation(d+b.getRotation());return a.callReturn()},syntax:{js:[],py:["Entry.add_rotation(%1)"]}},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 d=a.getNumberValue("VALUE",a);b.setDirection(d);return a.callReturn()},syntax:{js:[],py:["Entry.set_direction(%1)"]}},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 d=a.getNumberValue("VALUE",a);b.setDirection(d+b.getDirection()); -return a.callReturn()},syntax:{js:[],py:["Entry.add_direction(%1)"]}},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 d=a.getNumberValue("VALUE",a),c=a.getNumberValue("ANGLE", -a);b.setX(b.getX()+d*Math.cos((c-90)/180*Math.PI));b.setY(b.getY()-d*Math.sin((c-90)/180*Math.PI));b.brush&&!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY());return a.callReturn()},syntax:{js:[],py:["Entry.move_degree(%1, %2)"]}},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 d(){b.setRotation(b.getRotation()+a.dAngle);a.frameCount--}if(!a.isStart){var c;c=a.getNumberValue("VALUE",a);var e=a.getNumberValue("ANGLE",a);a.isStart=!0;a.frameCount=Math.max(Math.floor(c*Entry.FPS),1);a.dAngle=e/a.frameCount;1==a.frameCount&&d()}if(0!=a.frameCount)return d(),a;delete a.isStart;delete a.frameCount;return a.callReturn()},syntax:{js:[],py:["Entry.add_rotation_for_seconds(%1, %2)"]}},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 d(){b.setDirection(b.getDirection()+a.dDirection);a.frameCount--}if(!a.isStart){var c;c=a.getNumberValue("DURATION",a);var e=a.getNumberValue("AMOUNT", -a);a.isStart=!0;a.frameCount=Math.max(Math.floor(c*Entry.FPS),1);a.dDirection=e/a.frameCount;1==a.frameCount&&d()}if(0!=a.frameCount)return d(),a;delete a.isStart;delete a.frameCount;delete a.dDirection;return a.callReturn()},syntax:{js:[],py:["Entry.add_direction_for_seconds(%1, %2)"]}},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){b=a.getStringField("PORT");return Entry.hw.portData[b]},syntax:{js:[],py:["Neobot.sensor_value(%1)"]}},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){b=a.getStringField("PORT");b=Entry.hw.portData[b];var d=a.getNumberValue("OMIN",a),c=a.getNumberValue("OMAX",a),e=a.getNumberValue("MIN",a);a=a.getNumberValue("MAX",a);if(d>c)var f=d,d=c,c=f;e>a&&(f=e,e=a,a=f);b=Math.min(a,(a-e)/(c-d)*(b-d)+e);b=Math.max(e,b);return Math.round(b)}},neobot_left_motor:{color:"#00979D",skeleton:"basic",statements:[],template:"\uc67c\ucabd \ubaa8\ud130\ub97c %1 %2 \uc758 \uc18d\ub3c4\ub85c \ud68c\uc804 %3", +[Lang.Blocks.ALBERT_sensor_orientation,"orientation"],[Lang.Blocks.ALBERT_sensor_light,"light"],[Lang.Blocks.ALBERT_sensor_temperature,"temperature"],[Lang.Blocks.ALBERT_sensor_battery,"battery"],[Lang.Blocks.ALBERT_sensor_signal_strength,"signalStrength"]],value:"leftProximity",fontSize:11}],events:{},def:{params:[null],type:"albert_value"},paramsKeyMap:{DEVICE:0},"class":"albert_sensor",isNotFor:["albert"],func:function(b,a){var d=Entry.hw.portData,c=a.getField("DEVICE");return d[c]},syntax:{js:[], +py:["Albert.value(%1)"]}},albert_move_forward_for_secs:{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:["1"]},null],type:"albert_move_forward_for_secs"},paramsKeyMap:{VALUE:0},"class":"albert_wheel",isNotFor:["albert"],func:function(b,a){var d=Entry.hw.sendQueue;if(a.isStart){if(1==a.timeFlag)return a;delete a.isStart;delete a.timeFlag;Entry.engine.isContinue= +!1;d.leftWheel=0;d.rightWheel=0;return a.callReturn()}a.isStart=!0;a.timeFlag=1;d.leftWheel=30;d.rightWheel=30;var d=1E3*a.getNumberValue("VALUE"),c=setTimeout(function(){a.timeFlag=0;Entry.Albert.removeTimeout(c)},d);Entry.Albert.timeouts.push(c);return a},syntax:{js:[],py:["Albert.move_forward_for_secs(%1)"]}},albert_move_backward_for_secs:{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:["1"]},null],type:"albert_move_backward_for_secs"},paramsKeyMap:{VALUE:0},"class":"albert_wheel",isNotFor:["albert"],func:function(b,a){var d=Entry.hw.sendQueue;if(a.isStart){if(1==a.timeFlag)return a;delete a.isStart;delete a.timeFlag;Entry.engine.isContinue=!1;d.leftWheel=0;d.rightWheel=0;return a.callReturn()}a.isStart=!0;a.timeFlag=1;d.leftWheel=-30;d.rightWheel=-30;var d=1E3*a.getNumberValue("VALUE"),c=setTimeout(function(){a.timeFlag=0;Entry.Albert.removeTimeout(c)}, +d);Entry.Albert.timeouts.push(c);return a},syntax:{js:[],py:["Albert.move_backward_for_secs(%1)"]}},albert_turn_for_secs:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.ALBERT_turn_left,"LEFT"],[Lang.Blocks.ALBERT_turn_right,"RIGHT"]],value:"LEFT",fontSize:11},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,{type:"text",params:["1"]},null],type:"albert_turn_for_secs",id:"como"},paramsKeyMap:{DIRECTION:0, +VALUE:1},"class":"albert_wheel",isNotFor:["albert"],func:function(b,a){var d=Entry.hw.sendQueue;if(a.isStart){if(1==a.timeFlag)return a;delete a.isStart;delete a.timeFlag;Entry.engine.isContinue=!1;d.leftWheel=0;d.rightWheel=0;return a.callReturn()}a.isStart=!0;a.timeFlag=1;"LEFT"==a.getField("DIRECTION",a)?(d.leftWheel=-30,d.rightWheel=30):(d.leftWheel=30,d.rightWheel=-30);var d=1E3*a.getNumberValue("VALUE"),c=setTimeout(function(){a.timeFlag=0;Entry.Albert.removeTimeout(c)},d);Entry.Albert.timeouts.push(c); +return a},syntax:{js:[],py:["Albert.turn_for_secs(%1, %2)"]}},albert_change_both_wheels_by:{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:"text",params:["10"]},{type:"text",params:["10"]},null],type:"albert_change_both_wheels_by"},paramsKeyMap:{LEFT:0,RIGHT:1},"class":"albert_wheel",isNotFor:["albert"],func:function(b,a){var d=Entry.hw.sendQueue, +c=a.getNumberValue("LEFT"),e=a.getNumberValue("RIGHT");d.leftWheel=void 0!=d.leftWheel?d.leftWheel+c:c;d.rightWheel=void 0!=d.rightWheel?d.rightWheel+e:e;return a.callReturn()},syntax:{js:[],py:["Albert.change_both_wheels(%1, %2)"]}},albert_set_both_wheels_to:{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:"text",params:["30"]},{type:"text", +params:["30"]},null],type:"albert_set_both_wheels_to"},paramsKeyMap:{LEFT:0,RIGHT:1},"class":"albert_wheel",isNotFor:["albert"],func:function(b,a){var d=Entry.hw.sendQueue;d.leftWheel=a.getNumberValue("LEFT");d.rightWheel=a.getNumberValue("RIGHT");return a.callReturn()},syntax:{js:[],py:["Albert.set_both_wheels(%1, %2)"]}},albert_change_wheel_by:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.ALBERT_left_wheel,"LEFT"],[Lang.Blocks.ALBERT_right_wheel, +"RIGHT"],[Lang.Blocks.ALBERT_both_wheels,"BOTH"]],value:"LEFT",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:"albert_change_wheel_by"},paramsKeyMap:{DIRECTION:0,VALUE:1},"class":"albert_wheel",isNotFor:["albert"],func:function(b,a){var d=Entry.hw.sendQueue,c=a.getField("DIRECTION"),e=a.getNumberValue("VALUE");"LEFT"==c?d.leftWheel=void 0!=d.leftWheel?d.leftWheel+e:e:("RIGHT"!= +c&&(d.leftWheel=void 0!=d.leftWheel?d.leftWheel+e:e),d.rightWheel=void 0!=d.rightWheel?d.rightWheel+e:e);return a.callReturn()},syntax:{js:[],py:["Albert.change_wheel(%1, %2)"]}},albert_set_wheel_to:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.ALBERT_left_wheel,"LEFT"],[Lang.Blocks.ALBERT_right_wheel,"RIGHT"],[Lang.Blocks.ALBERT_both_wheels,"BOTH"]],value:"LEFT",fontSize:11},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png", +size:12}],events:{},def:{params:[null,{type:"text",params:["30"]},null],type:"albert_set_wheel_to"},paramsKeyMap:{DIRECTION:0,VALUE:1},"class":"albert_wheel",isNotFor:["albert"],func:function(b,a){var d=Entry.hw.sendQueue,c=a.getField("DIRECTION"),e=a.getNumberValue("VALUE");"LEFT"==c?d.leftWheel=e:("RIGHT"!=c&&(d.leftWheel=e),d.rightWheel=e);return a.callReturn()},syntax:{js:[],py:["Albert.set_wheel(%1, %2)"]}},albert_stop:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Indicator", +img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null],type:"albert_stop",id:"4adb"},"class":"albert_wheel",isNotFor:["albert"],func:function(b,a){var d=Entry.hw.sendQueue;d.leftWheel=0;d.rightWheel=0;return a.callReturn()},syntax:{js:[],py:["Albert.stop()"]}},albert_set_pad_size_to:{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:"text", +params:["108"]},{type:"text",params:["76"]},null],type:"albert_set_pad_size_to",id:"5mhg"},paramsKeyMap:{WIDTH:0,HEIGHT:1},"class":"albert_wheel",isNotFor:["albert"],func:function(b,a){var d=Entry.hw.sendQueue;d.padWidth=a.getNumberValue("WIDTH");d.padHeight=a.getNumberValue("HEIGHT");return a.callReturn()},syntax:{js:[],py:["Albert.set_pad_size(%1, %2)"]}},albert_move_to_x_y_on_board:{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:"albert_move_to_x_y_on_board"},paramsKeyMap:{X:0,Y:1},"class":"albert_wheel",isNotFor:["albert"],func:function(b,a){var d=Entry.hw.sendQueue,c=Entry.hw.portData,e=Entry.Albert.controller;if(a.isStart){if(a.isMoving){0<=c.positionX&&(a.x=c.positionX);0<=c.positionY&&(a.y=c.positionY);a.theta=c.orientation;switch(a.boardState){case 1:if(0==a.initialized){if(0> +a.x||0>a.y){d.leftWheel=20;d.rightWheel=-20;break}a.initialized=!0}d=e.toRadian(a.theta);0==e.controlAngle(d,Math.atan2(a.targetY-a.y,a.targetX-a.x))&&(a.boardState=2);break;case 2:0==e.controlPosition(a.x,a.y,e.toRadian(a.theta),a.targetX,a.targetY)&&(a.boardState=3);break;case 3:0==e.controlPositionFine(a.x,a.y,e.toRadian(a.theta),a.targetX,a.targetY)&&(d.leftWheel=0,d.rightWheel=0,a.isMoving=!1)}return a}delete a.isStart;delete a.isMoving;delete a.initialized;delete a.boardState;delete a.x;delete a.y; +delete a.theta;delete a.targetX;delete a.targetY;Entry.engine.isContinue=!1;d.leftWheel=0;d.rightWheel=0;return a.callReturn()}a.isStart=!0;a.isMoving=!0;a.initialized=!1;a.boardState=1;a.x=-1;a.y=-1;a.theta=-200;a.targetX=a.getNumberValue("X");a.targetY=a.getNumberValue("Y");e.clear();d.leftWheel=0;d.rightWheel=0;return a}},albert_set_orientation_on_board:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}], +events:{},def:{params:[{type:"number",params:["0"]},null],type:"albert_set_orientation_on_board"},paramsKeyMap:{ORIENTATION:0},"class":"albert_wheel",isNotFor:["albert"],func:function(b,a){var d=Entry.hw.sendQueue,c=Entry.hw.portData,e=Entry.Albert.controller;if(a.isStart){if(a.isMoving){a.theta=c.orientation;switch(a.boardState){case 1:var c=e.toRadian(a.theta),f=e.toRadian(a.targetTheta);0==e.controlAngle(c,f)&&(a.boardState=2);break;case 2:c=e.toRadian(a.theta),f=e.toRadian(a.targetTheta),0==e.controlAngleFine(c, +f)&&(d.leftWheel=0,d.rightWheel=0,a.isMoving=!1)}return a}delete a.isStart;delete a.isMoving;delete a.boardState;delete a.theta;delete a.targetTheta;Entry.engine.isContinue=!1;d.leftWheel=0;d.rightWheel=0;return a.callReturn()}a.isStart=!0;a.isMoving=!0;a.boardState=1;a.theta=-200;a.targetTheta=a.getNumberValue("ORIENTATION");e.clear();d.leftWheel=0;d.rightWheel=0;return a}},albert_set_eye_to:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.ALBERT_left_eye, +"LEFT"],[Lang.Blocks.ALBERT_right_eye,"RIGHT"],[Lang.Blocks.ALBERT_both_eyes,"BOTH"]],value:"LEFT",fontSize:11},{type:"Dropdown",options:[[Lang.Blocks.ALBERT_color_red,"4"],[Lang.Blocks.ALBERT_color_yellow,"6"],[Lang.Blocks.ALBERT_color_green,"2"],[Lang.Blocks.ALBERT_color_cyan,"3"],[Lang.Blocks.ALBERT_color_blue,"1"],[Lang.Blocks.ALBERT_color_magenta,"5"],[Lang.Blocks.ALBERT_color_white,"7"]],value:"4",fontSize:11},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null, +null,null],type:"albert_set_eye_to"},paramsKeyMap:{DIRECTION:0,COLOR:1},"class":"albert_led",isNotFor:["albert"],func:function(b,a){var d=Entry.hw.sendQueue,c=a.getField("DIRECTION",a),e=Number(a.getField("COLOR",a));"LEFT"==c?d.leftEye=e:("RIGHT"!=c&&(d.leftEye=e),d.rightEye=e);return a.callReturn()},syntax:{js:[],py:["Albert.set_eye(%1, %2)"]}},albert_clear_eye:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.ALBERT_left_eye,"LEFT"],[Lang.Blocks.ALBERT_right_eye, +"RIGHT"],[Lang.Blocks.ALBERT_both_eyes,"BOTH"]],value:"LEFT",fontSize:11},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,null],type:"albert_clear_eye"},paramsKeyMap:{DIRECTION:0},"class":"albert_led",isNotFor:["albert"],func:function(b,a){var d=Entry.hw.sendQueue,c=a.getField("DIRECTION",a);"LEFT"==c?d.leftEye=0:("RIGHT"!=c&&(d.leftEye=0),d.rightEye=0);return a.callReturn()},syntax:{js:[],py:["Albert.clear_eye(%1)"]}},albert_body_led:{color:"#00979D",skeleton:"basic", +statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.ALBERT_turn_on,"ON"],[Lang.Blocks.ALBERT_turn_off,"OFF"]],value:"ON",fontSize:11},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,null],type:"albert_body_led"},paramsKeyMap:{STATE:0},"class":"albert_led",isNotFor:["albert"],func:function(b,a){var d=Entry.hw.sendQueue;"ON"==a.getField("STATE",a)?d.bodyLed=1:d.bodyLed=0;return a.callReturn()},syntax:{js:[],py:["Albert.body_led(%1)"]}},albert_front_led:{color:"#00979D", +skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.ALBERT_turn_on,"ON"],[Lang.Blocks.ALBERT_turn_off,"OFF"]],value:"ON",fontSize:11},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,null],type:"albert_front_led"},paramsKeyMap:{STATE:0},"class":"albert_led",isNotFor:["albert"],func:function(b,a){var d=Entry.hw.sendQueue;"ON"==a.getField("STATE",a)?d.frontLed=1:d.frontLed=0;return a.callReturn()},syntax:{js:[],py:["Albert.front_led(%1)"]}}, +albert_beep:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null],type:"albert_beep"},"class":"albert_buzzer",isNotFor:["albert"],func:function(b,a){var d=Entry.hw.sendQueue;if(a.isStart){if(1==a.timeFlag)return a;delete a.isStart;delete a.timeFlag;Entry.engine.isContinue=!1;d.buzzer=0;return a.callReturn()}a.isStart=!0;a.timeFlag=1;d.buzzer=440;d.note=0;var c=setTimeout(function(){a.timeFlag=0;Entry.Albert.removeTimeout(c)}, +200);Entry.Albert.timeouts.push(c);return a},syntax:{js:[],py:["Albert.beep()"]}},albert_change_buzzer_by:{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:["10"]},null],type:"albert_change_buzzer_by"},paramsKeyMap:{VALUE:0},"class":"albert_buzzer",isNotFor:["albert"],func:function(b,a){var d=Entry.hw.sendQueue,c=a.getNumberValue("VALUE");d.buzzer=void 0!=d.buzzer? +d.buzzer+c:c;d.note=0;return a.callReturn()},syntax:{js:[],py:["Albert.change_buzzer(%1)"]}},albert_set_buzzer_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:["1000"]},null],type:"albert_set_buzzer_to"},paramsKeyMap:{VALUE:0},"class":"albert_buzzer",isNotFor:["albert"],func:function(b,a){var d=Entry.hw.sendQueue;d.buzzer=a.getNumberValue("VALUE");d.note= +0;return a.callReturn()},syntax:{js:[],py:["Albert.set_buzzer(%1)"]}},albert_clear_buzzer:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null],type:"albert_clear_buzzer"},"class":"albert_buzzer",isNotFor:["albert"],func:function(b,a){var d=Entry.hw.sendQueue;d.buzzer=0;d.note=0;return a.callReturn()},syntax:{js:[],py:["Albert.clear_buzzer()"]}},albert_play_note_for:{color:"#00979D",skeleton:"basic",statements:[], +params:[{type:"Dropdown",options:[[Lang.Blocks.ALBERT_note_c+"","4"],[Lang.Blocks.ALBERT_note_c+"#","5"],[Lang.Blocks.ALBERT_note_d+"","6"],[Lang.Blocks.ALBERT_note_e+"b","7"],[Lang.Blocks.ALBERT_note_e+"","8"],[Lang.Blocks.ALBERT_note_f+"","9"],[Lang.Blocks.ALBERT_note_f+"#","10"],[Lang.Blocks.ALBERT_note_g+"","11"],[Lang.Blocks.ALBERT_note_g+"#","12"],[Lang.Blocks.ALBERT_note_a+"","13"],[Lang.Blocks.ALBERT_note_b+"b","14"],[Lang.Blocks.ALBERT_note_b+"","15"]],value:"4",fontSize:11},{type:"Dropdown", +options:[["1","1"],["2","2"],["3","3"],["4","4"],["5","5"],["6","6"],["7","7"]],value:"1",fontSize:11},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,"4",{type:"text",params:["0.5"]},null],type:"albert_play_note_for"},paramsKeyMap:{NOTE:0,OCTAVE:1,VALUE:2},"class":"albert_buzzer",isNotFor:["albert"],func:function(b,a){var d=Entry.hw.sendQueue;if(a.isStart){if(1==a.timeFlag)return a;delete a.isStart;delete a.timeFlag;Entry.engine.isContinue= +!1;d.note=0;return a.callReturn()}var c=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;d.buzzer=0;d.note=c+12*(e-1);if(100Entry.Albert.tempo&&(Entry.Albert.tempo=1);return a.callReturn()},syntax:{js:[],py:["Albert.change_tempo(%1)"]}},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()},syntax:{js:[],py:["Albert.set_tempo(%1)"]}},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 d=Entry.hw.sendQueue;if(a.isStart){if(1==a.timeFlag)return a;delete a.timeFlag;delete a.isStart;Entry.engine.isContinue=!1;d.leftWheel= +0;d.rightWheel=0;return a.callReturn()}a.isStart=!0;a.timeFlag=1;d.leftWheel=30;d.rightWheel=30;setTimeout(function(){a.timeFlag=0},1E3);return a},syntax:{js:[],py:["Albert.move_forward()"]}},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 d=Entry.hw.sendQueue;if(a.isStart){if(1==a.timeFlag)return d.leftWheel=-30,d.rightWheel=-30,a;delete a.timeFlag;delete a.isStart; +Entry.engine.isContinue=!1;d.leftWheel=0;d.rightWheel=0;return a.callReturn()}a.isStart=!0;a.timeFlag=1;setTimeout(function(){a.timeFlag=0},1E3);return a},syntax:{js:[],py:["Albert.move_backward()"]}},albert_turn_around:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.ALBERT_turn_left,"LEFT"],[Lang.Blocks.ALBERT_turn_right,"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 d=Entry.hw.sendQueue;if(a.isStart){if(1==a.timeFlag)return d.leftWheel=a.leftValue,d.rightWheel=a.rightValue,a;delete a.timeFlag;delete a.isStart;delete a.leftValue;delete a.rightValue;Entry.engine.isContinue=!1;d.leftWheel=0;d.rightWheel=0;return a.callReturn()}d="LEFT"==a.getField("DIRECTION",a);a.leftValue=d?-30:30;a.rightValue=d?30:-30;a.isStart=!0;a.timeFlag=1;setTimeout(function(){a.timeFlag=0},1E3);return a},syntax:{js:[],py:["Albert.turn_around()"]}}, +albert_set_led_to:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.HAMSTER_left_led,"LEFT"],[Lang.Blocks.HAMSTER_right_led,"RIGHT"],[Lang.Blocks.HAMSTER_both_leds,"FRONT"]],value:"LEFT",fontSize:11},{type:"Dropdown",options:[[Lang.Blocks.HAMSTER_color_red,"4"],[Lang.Blocks.HAMSTER_color_yellow,"6"],[Lang.Blocks.HAMSTER_color_green,"2"],[Lang.Blocks.HAMSTER_color_cyan,"3"],[Lang.Blocks.HAMSTER_color_blue,"1"],[Lang.Blocks.HAMSTER_color_magenta,"5"],[Lang.Blocks.HAMSTER_color_white, +"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 d=Entry.hw.sendQueue,c=a.getField("DIRECTION",a),e=Number(a.getField("COLOR",a));"FRONT"==c?(d.leftEye=e,d.rightEye=e):"LEFT"==c?d.leftEye=e:d.rightEye=e;return a.callReturn()},syntax:{js:[],py:["Albert.set_led(%1, %2)"]}},albert_clear_led:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown", +options:[[Lang.Blocks.HAMSTER_left_led,"LEFT"],[Lang.Blocks.HAMSTER_right_led,"RIGHT"],[Lang.Blocks.HAMSTER_both_leds,"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 d=Entry.hw.sendQueue,c=a.getField("DIRECTION",a);"FRONT"==c?(d.leftEye=0,d.rightEye=0):"LEFT"==c?d.leftEye=0:d.rightEye=0;return a.callReturn()},syntax:{js:[],py:["Albert.clear_led(%1)"]}},albert_change_wheels_by:{color:"#00979D", +skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.ALBERT_left_wheel,"LEFT"],[Lang.Blocks.ALBERT_right_wheel,"RIGHT"],[Lang.Blocks.ALBERT_both_wheels,"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 d=Entry.hw.sendQueue,c=Entry.hw.portData,e=a.getField("DIRECTION"),f=a.getNumberValue("VALUE");"LEFT"== +e?d.leftWheel=void 0!=d.leftWheel?d.leftWheel+f:c.leftWheel+f:("RIGHT"!=e&&(d.leftWheel=void 0!=d.leftWheel?d.leftWheel+f:c.leftWheel+f),d.rightWheel=void 0!=d.rightWheel?d.rightWheel+f:c.rightWheel+f);return a.callReturn()},syntax:{js:[],py:["Albert.change_wheels(%1, %2)"]}},albert_set_wheels_to:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.ALBERT_left_wheel,"LEFT"],[Lang.Blocks.ALBERT_right_wheel,"RIGHT"],[Lang.Blocks.ALBERT_both_wheels,"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 d=Entry.hw.sendQueue,c=a.getField("DIRECTION"),e=a.getNumberValue("VALUE");"LEFT"==c?d.leftWheel=e:("RIGHT"!=c&&(d.leftWheel=e),d.rightWheel=e);return a.callReturn()},syntax:{js:[],py:["Albert.set_wheels(%1, %2)"]}},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")},syntax:{js:[],py:["%1arduino_text#"]}},arduino_send:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"}],events:{},def:{params:[]},paramsKeyMap:{VALUE:0},func:function(b,a){var d=a.getValue("VALUE",a),c=new XMLHttpRequest;c.open("POST","http://localhost:23518/arduino/",!1);c.send(String(d));Entry.assert(200==c.status,"arduino is not connected"); +return a.callReturn()},syntax:{js:[],py:["Arduino.send(%1)"]}},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 d=a.getValue("VALUE",a),c=new XMLHttpRequest;c.open("POST","http://localhost:23518/arduino/",!1);c.send(String(d));Entry.assert(200==c.status,"arduino is not connected");return Number(c.responseText)},syntax:{js:[],py:["Arduino.number(%1)"]}},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 d=a.getValue("VALUE",a),c=new XMLHttpRequest;c.open("POST","http://localhost:23518/arduino/",!1);c.send(String(d));Entry.assert(200==c.status,"arduino is not connected");return c.responseText},syntax:{js:[],py:["Arduino.string(%1)"]}},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")},syntax:{js:[],py:["%1arduino_get_sensor_number#"]}},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")},syntax:{js:[],py:["%1arduino_get_sensor_number#"]}},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")},syntax:{js:[],py:["%1arduino_get_pwm_port_number#"]}},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 d=a.getValue("VALUE", +a);return Entry.hw.getAnalogPortValue(d[1])},syntax:{js:[],py:["Arduino.sensor_value(%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 d=a.getNumberValue("VALUE",a);return Entry.hw.getDigitalPortValue(d)},syntax:{js:[], +py:["Arduino.digital_value(%1)"]}},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 d=a.getNumberValue("VALUE"),c=a.getField("OPERATOR");Entry.hw.setDigitalPortValue(d,"on"==c?255:0);return a.callReturn()},syntax:{js:[],py:["Arduino.toggle_led(%1, %2)"]}},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 d=a.getNumberValue("PORT"),c=a.getNumberValue("VALUE"),c=Math.round(c),c=Math.max(c,0),c=Math.min(c,255);Entry.hw.setDigitalPortValue(d,c);return a.callReturn()},syntax:{js:[],py:["Arduino.toggle_pwm(%1, %2)"]}},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 d=a.getNumberValue("VALUE1", +a),c=a.getNumberValue("VALUE2",a),e=a.getNumberValue("VALUE3",a),f=a.getNumberValue("VALUE4",a),g=a.getNumberValue("VALUE5",a);if(c>e)var h=c,c=e,e=h;f>g&&(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)},syntax:{js:[],py:["Arduino.convert_scale(%1, %2, %3, %4, %5)"]}},arduino_ext_get_analog_value:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],params:[{type:"Dropdown",options:[["A0","0"],["A1","1"],["A2","2"],["A3","3"],["A4", +"4"],["A5","5"]],value:"0",fontSize:11}],events:{},def:{params:[null],type:"arduino_ext_get_analog_value"},paramsKeyMap:{PORT:0},"class":"ArduinoExtGet",isNotFor:["ArduinoExt"],func:function(b,a){var d=a.getField("PORT",a),c=Entry.ArduinoExt.getSensorTime(Entry.ArduinoExt.sensorTypes.ANALOG),e=Entry.hw.portData.TIME||0,f=a.executor.scope,g=Entry.hw.portData.ANALOG;if(f.isStart){if(e&&e===f.stamp||64=g[0]?1:0;throw new Entry.Utils.AsyncError;}f.isStart=!0;f.stamp=c;Entry.hw.sendQueue.TIME=c;Entry.hw.sendQueue.KEY=Entry.ArduinoExt.getSensorKey();Entry.hw.sendQueue.GET={type:Entry.ArduinoExt.sensorTypes.ANALOG,port:0};throw new Entry.Utils.AsyncError;}},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_sensor",isNotFor:["CODEino"],func:function(b,a){var d=a.getField("STATUS",a),c=Entry.ArduinoExt.getSensorTime(Entry.ArduinoExt.sensorTypes.ANALOG),e=Entry.hw.portData.TIME||0,f=a.executor.scope,g=Entry.hw.portData.ANALOG;if(f.isStart){if(e&&e===f.stamp|| +64g[1]?1:0:800>=g[1]?1:0;throw new Entry.Utils.AsyncError;}f.isStart=!0;f.stamp=c;Entry.hw.sendQueue.TIME=c;Entry.hw.sendQueue.KEY=Entry.ArduinoExt.getSensorKey();Entry.hw.sendQueue.GET={type:Entry.ArduinoExt.sensorTypes.ANALOG,port:1};throw new Entry.Utils.AsyncError;}},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_sensor",isNotFor:["CODEino"],func:function(b,a){var d=a.getNumberField("PORT",a);if(10>d){var c=Entry.ArduinoExt.getSensorTime(Entry.ArduinoExt.sensorTypes.DIGITAL),e=Entry.hw.portData.TIME||0,f=a.executor.scope,g=Entry.hw.portData.DIGITAL; +if(f.isStart){if(e&&e===f.stamp||64g[d-14]?1:0;throw new Entry.Utils.AsyncError;}f.isStart=!0;f.stamp=c;Entry.hw.sendQueue.TIME=c;Entry.hw.sendQueue.KEY=Entry.ArduinoExt.getSensorKey();Entry.hw.sendQueue.GET={type:Entry.ArduinoExt.sensorTypes.ANALOG,port:d-14};throw new Entry.Utils.AsyncError;}},CODEino_get_accelerometer_direction:{color:"#00979D",fontColor:"#fff",skeleton:"basic_boolean_field",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.CODEino_string_16, +"LEFT"],[Lang.Blocks.CODEino_string_17,"RIGHT"],[Lang.Blocks.CODEino_string_18,"FRONT"],[Lang.Blocks.CODEino_string_19,"REAR"],[Lang.Blocks.CODEino_string_20,"REVERSE"]],value:"LEFT",fontSize:11}],events:{},def:{params:[null],type:"CODEino_get_accelerometer_direction"},paramsKeyMap:{DIRECTION:0},"class":"CODEino_sensor",isNotFor:["CODEino"],func:function(b,a){var d=a.getField("DIRECTION",a),c=0,e=Entry.ArduinoExt.getSensorTime(Entry.ArduinoExt.sensorTypes.ANALOG),f=Entry.hw.portData.TIME||0,g=a.executor.scope, +h=Entry.hw.portData.ANALOG;"LEFT"==d||"RIGHT"==d?c=3:"FRONT"==d||"REAR"==d?c=4:"REVERSE"==d&&(c=5);if(g.isStart)if(f&&f===g.stamp){delete g.isStart;delete g.stamp;c=h[c];c=180/137*(c-265);c+=-90;c=Math.min(90,c);c=Math.max(-90,c);c=Math.round(c);if("LEFT"==d||"REAR"==d)return-30>c?1:0;if("RIGHT"==d||"FRONT"==d)return 30c?1:0}else if(64c?1:0;if("RIGHT"==d||"FRONT"==d)return 30c?1:0}else throw new Entry.Utils.AsyncError;else throw g.isStart=!0,g.stamp=e,Entry.hw.sendQueue.TIME=e,Entry.hw.sendQueue.KEY=Entry.ArduinoExt.getSensorKey(),Entry.hw.sendQueue.GET={type:Entry.ArduinoExt.sensorTypes.ANALOG,port:c},new Entry.Utils.AsyncError;}},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_sensor",isNotFor:["CODEino"],func:function(b,a){var d=a.getNumberField("PORT",a),c=Entry.ArduinoExt.getSensorTime(Entry.ArduinoExt.sensorTypes.ANALOG),e=Entry.hw.portData.TIME||0,f=a.executor.scope,g=Entry.hw.portData.ANALOG,h=0;if(f.isStart){if(e&&e===f.stamp||64e)var h=c,c=e,e=h;f>g&&(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)}},CODEino_set_rgb_value:{color:"#00979D", +skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[["\ube68\uac15","17"],["\ucd08\ub85d","18"],["\ud30c\ub791","19"]],value:"17",fontSize:11},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{type:"CODEino_set_rgb_value"},paramsKeyMap:{PORT:0,VALUE:1},"class":"CODEino_RGBLED_mode",isNotFor:["CODEino"],func:function(b,a){var d=Entry.hw.sendQueue,c=a.getNumberField("PORT",a),e=a.getNumberValue("VALUE",a),e=Math.min(255,e),e=Math.max(0, +e);17==c?CODEINO_RED=e:18==c?CODEINO_GREEN=e:CODEINO_BLUE=e;d.TIME=Entry.ArduinoExt.getSensorTime(4);d.KEY=Entry.ArduinoExt.getSensorKey();d.SET||(d.SET={});d.SET[c]={type:4,data:e};return a.callReturn()}},CODEino_set_rgb_add_value:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[["\ube68\uac15","17"],["\ucd08\ub85d","18"],["\ud30c\ub791","19"]],value:"17",fontSize:11},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{}, +def:{type:"CODEino_set_rgb_add_value"},paramsKeyMap:{PORT:0,VALUE:1},"class":"CODEino_RGBLED_mode",isNotFor:["CODEino"],func:function(b,a){var d=Entry.hw.sendQueue,c=a.getNumberField("PORT",a),e=a.getNumberValue("VALUE",a),e=Math.min(255,e),e=Math.max(0,e);17==c&&(CODEINO_RED+=e,CODEINO_RED=Math.min(255,CODEINO_RED),e=CODEINO_RED=Math.max(0,CODEINO_RED));18==c&&(CODEINO_GREEN+=e,CODEINO_GREEN=Math.min(255,CODEINO_GREEN),e=CODEINO_GREEN=Math.max(0,CODEINO_GREEN));19==c&&(CODEINO_BLUE+=e,CODEINO_BLUE= +Math.min(255,CODEINO_BLUE),e=CODEINO_BLUE=Math.max(0,CODEINO_BLUE));d.TIME=Entry.ArduinoExt.getSensorTime(4);d.KEY=Entry.ArduinoExt.getSensorKey();d.SET||(d.SET={});d.SET[c]={type:4,data:e};return a.callReturn()}},CODEino_rgb_set_color:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Color"},{type:"Indicator",img:"block_icon/brush_03.png",size:12}],events:{},def:{params:[null],type:"CODEino_rgb_set_color"},paramsKeyMap:{VALUE:0},"class":"CODEino_RGBLED_mode",isNotFor:["CODEino"],func:function(b, +a){var d=a.getStringField("VALUE");CODEINO_RED=parseInt(d.substr(1,2),16);CODEINO_GREEN=parseInt(d.substr(3,2),16);CODEINO_BLUE=parseInt(d.substr(5,2),16);var d=Entry.hw.sendQueue,c=17;d.TIME=Entry.ArduinoExt.getSensorTime(4);d.KEY=Entry.ArduinoExt.getSensorKey();d.SET||(d.SET={});d.SET[c]={type:4,data:CODEINO_RED};d=Entry.hw.sendQueue;c=18;d.TIME=Entry.ArduinoExt.getSensorTime(4);d.KEY=Entry.ArduinoExt.getSensorKey();d.SET||(d.SET={});d.SET[c]={type:4,data:CODEINO_GREEN};d=Entry.hw.sendQueue;c=19; +d.TIME=Entry.ArduinoExt.getSensorTime(4);d.KEY=Entry.ArduinoExt.getSensorKey();d.SET||(d.SET={});d.SET[c]={type:4,data:CODEINO_BLUE};return a.callReturn()}},CODEino_set_rgb_off:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null],type:"CODEino_set_rgb_off"},"class":"CODEino_RGBLED_mode",isNotFor:["CODEino"],func:function(b,a){var d=Entry.hw.sendQueue;CODEINO_GREEN=CODEINO_BLUE=CODEINO_RED=0;var c=17;d.TIME= +Entry.ArduinoExt.getSensorTime(4);d.KEY=Entry.ArduinoExt.getSensorKey();d.SET||(d.SET={});d.SET[c]={type:4,data:0};d=Entry.hw.sendQueue;c=18;d.TIME=Entry.ArduinoExt.getSensorTime(4);d.KEY=Entry.ArduinoExt.getSensorKey();d.SET||(d.SET={});d.SET[c]={type:4,data:0};d=Entry.hw.sendQueue;c=19;d.TIME=Entry.ArduinoExt.getSensorTime(4);d.KEY=Entry.ArduinoExt.getSensorKey();d.SET||(d.SET={});d.SET[c]={type:4,data:0};return a.callReturn()}},CODEino_set__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:"CODEino_set__led_by_rgb"},paramsKeyMap:{rValue:0,gValue:1,bValue:2},"class":"CODEino_RGBLED_mode",isNotFor:["CODEino"],func:function(b,a){CODEINO_RED=a.getNumberValue("rValue");CODEINO_GREEN=a.getNumberValue("gValue"); +CODEINO_BLUE=a.getNumberValue("bValue");var d=Entry.hw.sendQueue,c=17;d.TIME=Entry.ArduinoExt.getSensorTime(4);d.KEY=Entry.ArduinoExt.getSensorKey();d.SET||(d.SET={});d.SET[c]={type:4,data:CODEINO_RED};d=Entry.hw.sendQueue;c=18;d.TIME=Entry.ArduinoExt.getSensorTime(4);d.KEY=Entry.ArduinoExt.getSensorKey();d.SET||(d.SET={});d.SET[c]={type:4,data:CODEINO_GREEN};d=Entry.hw.sendQueue;c=19;d.TIME=Entry.ArduinoExt.getSensorTime(4);d.KEY=Entry.ArduinoExt.getSensorKey();d.SET||(d.SET={});d.SET[c]={type:4, +data:CODEINO_BLUE};return a.callReturn()}},CODEino_led_by_value:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null],type:"CODEino_led_by_value"},"class":"CODEino_RGBLED_mode",isNotFor:["CODEino"],func:function(b,a){var d=Entry.hw.sendQueue,c=17;CODEINO_BLUE=CODEINO_GREEN=CODEINO_RED=100;d.TIME=Entry.ArduinoExt.getSensorTime(4);d.KEY=Entry.ArduinoExt.getSensorKey();d.SET||(d.SET={});d.SET[c]={type:4,data:100}; +d=Entry.hw.sendQueue;c=18;d.TIME=Entry.ArduinoExt.getSensorTime(4);d.KEY=Entry.ArduinoExt.getSensorKey();d.SET||(d.SET={});d.SET[c]={type:4,data:100};d=Entry.hw.sendQueue;c=19;d.TIME=Entry.ArduinoExt.getSensorTime(4);d.KEY=Entry.ArduinoExt.getSensorKey();d.SET||(d.SET={});d.SET[c]={type:4,data:100};return a.callReturn()}},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",syntax:{js:[],py:["hw.CODEino_get_number_sensor_value(%1)"]}},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",syntax:{js:[],py:["hw.CODEino_toggle_led(%1)"]}},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", +syntax:{js:[],py:["hw.CODEino_toggle_pwm(%1, %2)"]}},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 d=a.getNumberField("PORT",a);return 14c?1:0;if("RIGHT"==d||"FRONT"==d)return 30c?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 d=265,c=402,e=-90,f=90,g=Entry.hw.getAnalogPortValue(a.getField("PORT",a));if(d>c)var h=d,d=c,c=h;e>f&&(h=e,e=f,f=h);g=(f-e)/(c-d)*(g-d);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 d=a.getStringField("PORT");return Entry.hw.portData[d].value},syntax:{js:[],py:["Bitbrick.sensor_value(%1)"]}},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},syntax:{js:[],py:["Bitbrick.is_touch_pressed(%1)"]}},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()},syntax:{js:[],py:["Bitbrick.turn_off_color_led()"]}},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 d=a.getNumberValue("rValue"),c=a.getNumberValue("gValue"),e=a.getNumberValue("bValue"),f=Entry.adjustValueWithMaxMin,g=Entry.hw.sendQueue;g.LEDR=f(d,0,255);g.LEDG=f(c,0,255);g.LEDB=f(e,0,255);return a.callReturn()},syntax:{js:[],py:["Bitbrick.color_led_by_rgb(%1, %2, %3)"]}},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 d=a.getStringField("VALUE");Entry.hw.sendQueue.LEDR=parseInt(d.substr(1,2),16);Entry.hw.sendQueue.LEDG=parseInt(d.substr(3,2),16);Entry.hw.sendQueue.LEDB=parseInt(d.substr(5,2),16);return a.callReturn()},syntax:{js:[],py:["Bitbrick.color_led_by_picker(%1)"]}},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 d=a.getNumberValue("VALUE"),c,e,f,d=d%200;67>d?(c=200-3*d,e=3*d,f=0):134>d?(d-=67,c=0,e=200-3*d,f=3*d):201>d&&(d-=134,c=3*d,e=0,f=200-3*d);Entry.hw.sendQueue.LEDR=c;Entry.hw.sendQueue.LEDG= +e;Entry.hw.sendQueue.LEDB=f;return a.callReturn()},syntax:{js:[],py:["Bitbrick.color_led_by_value(%1)"]}},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 d=a.getNumberValue("VALUE");Entry.hw.sendQueue.buzzer=d;a.isStart=!0;return a},syntax:{js:[],py:["Bitbrick.buzzer(%1)"]}},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 d=Entry.hw.sendQueue,c=Entry.Bitbrick;c.servoList().map(function(a){d[a[1]]=0});c.dcList().map(function(a){d[a[1]]= +128});return a.callReturn()},syntax:{js:[],py:["Bitbrick.turn_off_all_motors()"]}},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 d=a.getNumberValue("VALUE"),d=Math.min(d,Entry.Bitbrick.dcMaxValue),d=Math.max(d,Entry.Bitbrick.dcMinValue);Entry.hw.sendQueue[a.getStringField("PORT")]=d+128;return a.callReturn()},syntax:{js:[],py:["Bitbrick.dc_speed(%1, %2)"]}},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 d="CW"===a.getStringField("DIRECTION"),c=a.getNumberValue("VALUE"),c=Math.min(c,Entry.Bitbrick.dcMaxValue),c=Math.max(c,0);Entry.hw.sendQueue[a.getStringField("PORT")]= +d?c+128:128-c;return a.callReturn()},syntax:{js:[],py:["Bitbrick.dc_direction_speed(%1, %2, %3)"]}},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 d=Entry.Bitbrick.servoMaxValue-(a.getNumberValue("VALUE")+1),d=Math.min(d,Entry.Bitbrick.servoMaxValue),d=Math.max(d,Entry.Bitbrick.servoMinValue);Entry.hw.sendQueue[a.getStringField("PORT")]=d;return a.callReturn()},syntax:{js:[],py:["Bitbrick.servomotor_angle(%1, %2)"]}},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 d=a.getNumberField("PORT"),c=Entry.hw.portData[d].value,d=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;c-=d;c*=(g-f)/(e-d);c+=f;c=Math.min(g,c);c=Math.max(f,c);return Math.round(c)},syntax:{js:[],py:["Bitbrick.convert_scale(%1, %2, %3, %4, %5)"]}},cobl_read_ultrason:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",template:"1. \ucd08\uc74c\ud30c\uac70\ub9ac(0~400)",def:{type:"cobl_read_ultrason"},class:"cobl",isNotFor:["cobl"],func:function(b,a){return Entry.hw.getAnalogPortValue("ultrason")}}, +cobl_read_potenmeter:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",template:"2.\uac00\ubcc0\uc800\ud56d(0~1023)",def:{type:"cobl_read_potenmeter"},class:"cobl",isNotFor:["cobl"],func:function(b,a){return Entry.hw.getAnalogPortValue("potenmeter")}},cobl_read_irread1:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",template:"3.\uc801\uc678\uc120\uc13c\uc11c1(0~1023)",def:{type:"cobl_read_irread1"},class:"cobl",isNotFor:["cobl"],func:function(b,a){return Entry.hw.getAnalogPortValue("irread1")}}, +cobl_read_irread2:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",template:"4.\uc801\uc678\uc120\uc13c\uc11c2(0~1023)",def:{type:"cobl_read_irread2"},class:"cobl",isNotFor:["cobl"],func:function(b,a){return Entry.hw.getAnalogPortValue("irread2")}},cobl_read_joyx:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",template:"5.\uc870\uc774\uc2a4\ud2f1X\ucd95(1, 0, -1)",def:{type:"cobl_read_joyx"},class:"cobl",isNotFor:["cobl"],func:function(b,a){return Entry.hw.getAnalogPortValue("joyx")}}, +cobl_read_joyy:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",template:"6.\uc870\uc774\uc2a4\ud2f1Y\ucd95(1, 0, -1)",def:{type:"cobl_read_joyy"},class:"cobl",isNotFor:["cobl"],func:function(b,a){return Entry.hw.getAnalogPortValue("joyy")}},cobl_read_tilt:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",template:"7.\uae30\uc6b8\uae30\uc13c\uc11c(0~4)",def:{type:"cobl_read_tilt"},class:"cobl",isNotFor:["cobl"],func:function(b,a){return Entry.hw.getAnalogPortValue("tilt")}}, +cobl_read_temps:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",template:"8.\uc628\ub3c4\uc13c\uc11c@\ud3ec\ud2b8%1",params:[{type:"Dropdown",options:[["1","1"],["2","2"]],fontSize:11}],def:{params:["1"],type:"cobl_read_temps"},paramsKeyMap:{VALUE:0},class:"cobl",isNotFor:["cobl"],func:function(b,a){var d=a.getValue("VALUE",a);if(1==d)return Entry.hw.getAnalogPortValue("temps1");if(2==d)return Entry.hw.getAnalogPortValue("temps2")}},cobl_read_light:{color:"#00979D",fontColor:"#fff", +skeleton:"basic_string_field",template:"9.\ube5b\uc13c\uc11c@\ud3ec\ud2b8%1",params:[{type:"Dropdown",options:[["1","1"],["2","2"]],fontSize:11}],def:{params:["1"],type:"cobl_read_light"},paramsKeyMap:{VALUE:0},class:"cobl",isNotFor:["cobl"],func:function(b,a){var d=a.getValue("VALUE",a);if(1==d)return Entry.hw.getAnalogPortValue("light1");if(2==d)return Entry.hw.getAnalogPortValue("light2")}},cobl_read_btn:{color:"#00979D",fontColor:"#fff",skeleton:"basic_boolean_field",template:"10.\ubc84\ud2bc\uc2a4\uc704\uce58@\ud3ec\ud2b8%1", +params:[{type:"Dropdown",options:[["1","1"],["2","2"]],fontSize:11}],def:{params:["1"],type:"cobl_read_btn"},paramsKeyMap:{VALUE:0},class:"cobl",isNotFor:["cobl"],func:function(b,a){var d=a.getValue("VALUE",a);if(1==d)return Entry.hw.getDigitalPortValue("btn1");if(2==d)return Entry.hw.getDigitalPortValue("btn2")}},cobl_led_control:{color:"#00979D",fontColor:"#fff",skeleton:"basic",template:"11.\ubb34\uc9c0\uac1cLED%1%2 %3",params:[{type:"Dropdown",options:[["1","1"],["2","2"],["3","3"]],fontSize:11}, +{type:"Dropdown",options:[["OFF","OFF"],["\ube68\uac15","Red"],["\uc8fc\ud669","Orange"],["\ub178\ub791","Yellow"],["\ucd08\ub85d","Green"],["\ud30c\ub791","Blue"],["\ub0a8\uc0c9","Dark Blue"],["\ubcf4\ub77c","Purple"],["\ud770\uc0c9","White"]],fontSize:11},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],def:{params:["1","OFF"],type:"cobl_led_control"},paramsKeyMap:{PORT:0,OPERATOR:1},class:"cobl",isNotFor:["cobl"],func:function(b,a){var d=a.getStringField("PORT"),c=a.getStringField("OPERATOR"); +Entry.hw.setDigitalPortValue("RainBowLED_"+d,c);Entry.hw.update();delete Entry.hw.sendQueue["RainBowLED_"+d];return a.callReturn()}},cobl_servo_angle_control:{color:"#00979D",fontColor:"#fff",skeleton:"basic",template:"12.\uac01\ub3c4\ubaa8\ud130 \uac01\ub3c4%1(15~165) %2",params:[{type:"TextInput",value:0},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],def:{type:"cobl_servo_angle_control"},paramsKeyMap:{VALUE:0},class:"cobl",isNotFor:["cobl"],func:function(b,a){var d=a.getNumberField("VALUE"), +d=Math.round(d),d=Math.max(d,15),d=Math.min(d,165);Entry.hw.setDigitalPortValue("Servo1",d);Entry.hw.update();delete Entry.hw.sendQueue.Servo1;return a.callReturn()}},cobl_melody:{color:"#00979D",fontColor:"#fff",skeleton:"basic",template:"13.\uba5c\ub85c\ub514%1 ,%2",params:[{type:"Dropdown",options:[["((\ub0ae\uc740)\uc194","L_So"],["(\ub0ae\uc740)\uc194#","L_So#"],["(\ub0ae\uc740)\ub77c","L_La"],["(\ub0ae\uc740)\ub77c#","L_La#"],["(\ub0ae\uc740)\uc2dc","L_Ti"],["\ub3c4","Do"],["\ub3c4#","Do#"], +["\ub808","Re"],["\ub808#","Re#"],["\ubbf8","Mi"],["\ud30c","Fa"],["\ud30c#","Fa#"],["\uc194","So"],["\uc194#","So#"],["\ub77c","La"],["\ub77c#","La#"],["\uc2dc","Ti"],["(\ub192\uc740)\ub3c4","H_Do"],["(\ub192\uc740)\ub3c4#","H_Do#"],["(\ub192\uc740)\ub808","H_Re"],["(\ub192\uc740)\ub808#","H_Re#"],["(\ub192\uc740)\ubbf8#","H_Mi"],["(\ub192\uc740)\ud30c","H_Fa"]],fontSize:11},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],def:{params:["Do"],type:"cobl_melody"},paramsKeyMap:{MELODY:0}, +class:"cobl",isNotFor:["cobl"],func:function(b,a){var d=a.getStringField("MELODY");Entry.hw.setDigitalPortValue("Melody",d);Entry.hw.update();delete Entry.hw.sendQueue.Melody;return a.callReturn()}},cobl_dcmotor:{color:"#00979D",fontColor:"#fff",skeleton:"basic",template:"14.\ud68c\uc804\ubaa8\ud130%1%2\uc18d\ub3c4%3 %4",params:[{type:"Dropdown",options:[["1","1"],["2","2"]],fontSize:11},{type:"Dropdown",options:[["1.\uc2dc\uacc4\ubc29\ud5a5","1"],["2.\ubc18\uc2dc\uacc4\ubc29\ud5a5","2"],["3.\uc815\uc9c0", +"3"]],fontSize:11},{type:"Dropdown",options:[["1","1"],["2","2"],["3","3"],["4","4"],["5","5"]],fontSize:11},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],def:{params:["1","1","1"],type:"cobl_dcmotor"},paramsKeyMap:{MOTOR:0,DIRECTION:1,SPEED:2},class:"cobl",isNotFor:["cobl"],func:function(b,a){var d=a.getStringField("MOTOR"),c=a.getStringField("DIRECTION"),e=a.getStringField("SPEED");1==d&&(Entry.hw.setDigitalPortValue("DC1_DIR",c),Entry.hw.setDigitalPortValue("DC1_SPEED",e),Entry.hw.update(), +delete Entry.hw.sendQueue.DC1_DIR,delete Entry.hw.sendQueue.DC1_SPEED);2==d&&(Entry.hw.setDigitalPortValue("DC2_DIR",c),Entry.hw.setDigitalPortValue("DC2_SPEED",e),Entry.hw.update(),delete Entry.hw.sendQueue.DC2_DIR,delete Entry.hw.sendQueue.DC2_SPEED);return a.callReturn()}},cobl_extention_port:{color:"#00979D",fontColor:"#fff",skeleton:"basic",template:"15.USB\ud3ec\ud2b8%1\ub2e8\uacc4%2 %3",params:[{type:"Dropdown",options:[["1","1"],["2","2"]],fontSize:11},{type:"Dropdown",options:[["0","0"], +["1","1"],["2","2"],["3","3"],["4","4"],["5","5"]],fontSize:11},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],def:{params:["1","0"],type:"cobl_extention_port"},paramsKeyMap:{PORT:0,LEVEL:1},class:"cobl",isNotFor:["cobl"],func:function(b,a){var d=a.getStringField("PORT"),c=a.getStringField("LEVEL");1==d&&(Entry.hw.setDigitalPortValue("EXUSB1",c),Entry.hw.update(),delete Entry.hw.sendQueue.EXUSB1);2==d&&(Entry.hw.setDigitalPortValue("EXUSB2",c),Entry.hw.update(),delete Entry.hw.sendQueue.EXUSB2); +return a.callReturn()}},cobl_external_led:{color:"#00979D",fontColor:"#fff",skeleton:"basic",template:"16.\uc678\ubd80LED%1(1~64)R%2G%3B%4 %5",params:[{type:"TextInput",value:0,fontSize:11},{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"]],fontSize:11},{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"]],fontSize:11},{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"]],fontSize:11},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],def:{params:["1","1","1","1"],type:"cobl_external_led"},paramsKeyMap:{LED:0,RED:1,GREEN:2,BLUE:3},class:"cobl",isNotFor:["cobl"],func:function(b,a){var d=a.getNumberField("LED"),c=a.getStringField("RED"),e=a.getStringField("GREEN"),f=a.getStringField("BLUE");Entry.hw.setDigitalPortValue("ELED_IDX",d);Entry.hw.setDigitalPortValue("ELED_R", +c);Entry.hw.setDigitalPortValue("ELED_G",e);Entry.hw.setDigitalPortValue("ELED_B",f);Entry.hw.update();delete Entry.hw.sendQueue.ELED_IDX;delete Entry.hw.sendQueue.ELED_R;delete Entry.hw.sendQueue.ELED_G;delete Entry.hw.sendQueue.ELED_B;return a.callReturn()}},cobl_7_segment:{color:"#00979D",fontColor:"#fff",skeleton:"basic",template:"17.\uc22b\uc790\uc804\uad11\ud310%1(0~9999) %2",params:[{type:"TextInput",value:0},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],def:{type:"cobl_7_segment"}, +paramsKeyMap:{VALUE:0},class:"cobl",isNotFor:["cobl"],func:function(b,a){var d=a.getNumberField("VALUE");Entry.hw.setDigitalPortValue("7SEG",d);Entry.hw.update();delete Entry.hw.sendQueue["7SEG"];return a.callReturn()}},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()},syntax:{js:[],py:["Entry.start_drawing()"]}},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()},syntax:{js:[],py:["Entry.stop_drawing()"]}},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 d=a.getField("VALUE",a);b.brush||(Entry.setBasicBrush(b),b.brush.stop=!0);b.brush&&(d=Entry.hex2rgb(d),b.brush.rgb=d,b.brush.endStroke(),b.brush.beginStroke("rgba("+d.r+","+d.g+","+d.b+","+b.brush.opacity/100+")"),b.brush.moveTo(b.getX(),-1*b.getY()));return a.callReturn()}, +syntax:{js:[],py:["Entry.set_brush_color(%1)"]}},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 d=Entry.generateRgb();b.brush.rgb=d;b.brush.endStroke();b.brush.beginStroke("rgba("+d.r+","+d.g+","+d.b+","+b.brush.opacity/100+")");b.brush.moveTo(b.getX(), +-1*b.getY())}return a.callReturn()},syntax:{js:[],py:["Entry.set_brush_color_random()"]}},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 d=a.getNumberValue("VALUE",a);b.brush||(Entry.setBasicBrush(b),b.brush.stop= +!0);b.brush&&(b.brush.thickness+=d,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()},syntax:{js:[],py:["Entry.add_brush_size(%1)"]}},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 d=a.getNumberValue("VALUE",a);b.brush||(Entry.setBasicBrush(b),b.brush.stop=!0);b.brush&&(b.brush.thickness=d,b.brush.setStrokeStyle(b.brush.thickness),b.brush.moveTo(b.getX(),-1*b.getY()));return a.callReturn()},syntax:{js:[],py:["Entry.set_brush_size(%1)"]}},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 d=a.getNumberValue("VALUE",a);b.brush||(Entry.setBasicBrush(b),b.brush.stop=!0);d=Entry.adjustValueWithMaxMin(b.brush.opacity+d,0,100);b.brush&&(b.brush.opacity=d,b.brush.endStroke(),d=b.brush.rgb,b.brush.beginStroke("rgba("+d.r+","+d.g+","+d.b+","+b.brush.opacity/100+")"),b.brush.moveTo(b.getX(),-1*b.getY()));return a.callReturn()},syntax:{js:[],py:[""]}},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 d=a.getNumberValue("VALUE",a);b.brush||(Entry.setBasicBrush(b),b.brush.stop=!0);b.brush&&(b.brush.opacity=Entry.adjustValueWithMaxMin(d,0,100),b.brush.endStroke(),d=b.brush.rgb,b.brush.beginStroke("rgba("+ +d.r+","+d.g+","+d.b+","+b.brush.opacity/100+")"),b.brush.moveTo(b.getX(),-1*b.getY()));return a.callReturn()},syntax:{js:[],py:[""]}},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 d=b.brush;if(d){var c=d._stroke.style,e=d._strokeStyle.width;d.clear().setStrokeStyle(e).beginStroke(c);d.moveTo(b.getX(), +-1*b.getY())}d=b.parent.getStampEntities();d.map(function(a){a.removeClone()});d=null;return a.callReturn()},syntax:{js:[],py:["Entry.clear_drawing()"]}},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()},syntax:{js:[],py:["Entry.stamp()"]}},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 d=a.getNumberValue("VALUE",a);b.brush||(Entry.setBasicBrush(b),b.brush.stop=!0);d=Entry.adjustValueWithMaxMin(b.brush.opacity-d,0,100);b.brush&&(b.brush.opacity=d,b.brush.endStroke(),d=b.brush.rgb, +b.brush.beginStroke("rgba("+d.r+","+d.g+","+d.b+","+b.brush.opacity/100+")"),b.brush.moveTo(b.getX(),-1*b.getY()));return a.callReturn()},syntax:{js:[],py:["Entry.add_brush_transparency(%1)"]}},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 d=a.getNumberValue("VALUE",a);b.brush||(Entry.setBasicBrush(b),b.brush.stop=!0);b.brush&&(b.brush.opacity=Entry.adjustValueWithMaxMin(d,0,100),b.brush.endStroke(),d=b.brush.rgb,b.brush.beginStroke("rgba("+d.r+","+d.g+","+d.b+","+(1-b.brush.opacity/100)+")"),b.brush.moveTo(b.getX(),-1*b.getY()));return a.callReturn()},syntax:{js:[],py:["Entry.set_brush_transparency(%1)"]}},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,syntax:{js:["Scope","%1"],py:["%1number#"]}},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")},syntax:{js:[],py:["%1angle#"]}},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()},syntax:{js:[],py:[""]}},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()},syntax:{js:[],py:[""]}},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))},syntax:{js:[],py:[""]}},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))},syntax:{js:[],py:[""]}},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 d=a.getField("VALUE",a);if("mouse"==d)return d=Entry.stage.mouseCoordinate,Math.sqrt(Math.pow(b.getX()-d.x,2)+Math.pow(b.getY()-d.y,2));d=Entry.container.getEntity(d);return Math.sqrt(Math.pow(b.getX()-d.getX(),2)+Math.pow(b.getY()-d.getY(),2))},syntax:{js:[],py:["Entry.value_of_distance(%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)?Number(Entry.stage.mouseCoordinate.x):Number(Entry.stage.mouseCoordinate.y)},syntax:{js:[],py:["Entry.coordinate_of_mouse(%2)"]}},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 d=a.getField("VALUE",a),d="self"==d?b:Entry.container.getEntity(d);switch(a.getField("COORDINATE",a)){case "x":return d.getX();case "y":return d.getY();case "rotation":return d.getRotation();case "direction":return d.getDirection();case "picture_index":var c=d.parent,c=c.pictures;return c.indexOf(d.picture)+1;case "size":return Number(d.getSize().toFixed(1));case "picture_name":return c=d.parent,c=c.pictures,c[c.indexOf(d.picture)].name}},syntax:{js:[],py:["Entry.value_of(%2, %4)"]}}, +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 d=a.getField("OPERATOR",a),c=a.getNumberValue("LEFTHAND",a),e=a.getNumberValue("RIGHTHAND",a);return"PLUS"==d?c+e:"MINUS"==d?c-e:"MULTI"==d?c*e:c/e}, +syntax:{js:[],py:["(%1 %2calc_basic# %3)"]}},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 d=a.getNumberValue("LEFTHAND",a),c=a.getNumberValue("RIGHTHAND",a);return d+c},syntax:{js:[],py:[""]}},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 d=a.getNumberValue("LEFTHAND",a),c=a.getNumberValue("RIGHTHAND",a);return d-c},syntax:{js:[],py:[""]}},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 d=a.getNumberValue("LEFTHAND",a),c=a.getNumberValue("RIGHTHAND",a);return d*c},syntax:{js:[],py:[""]}},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 d=a.getNumberValue("LEFTHAND",a),c=a.getNumberValue("RIGHTHAND",a);return d/c},syntax:{js:[], +py:[""]}},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 d=a.getNumberValue("LEFTHAND",a),c=a.getNumberValue("RIGHTHAND", +a);return d%c},syntax:{js:[],py:["Entry.get_remainder(%1, %3)"]}},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 d= +a.getNumberValue("LEFTHAND",a),c=a.getNumberValue("RIGHTHAND",a);return Math.floor(d/c)},syntax:{js:[],py:[""]}},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 d=a.getNumberValue("LEFTHAND",a),c=a.getField("VALUE",a);if(-1<["asin_radian","acos_radian"].indexOf(c)&&(1d))throw Error("x range exceeded"); +c.indexOf("_")&&(c=c.split("_")[0]);-1<["sin","cos","tan"].indexOf(c)&&(d=Entry.toRadian(d));var e=0;switch(c){case "square":e=d*d;break;case "factorial":e=Entry.factorial(d);break;case "root":e=Math.sqrt(d);break;case "log":e=Math.log(d)/Math.LN10;break;case "ln":e=Math.log(d);break;case "asin":case "acos":case "atan":e=Entry.toDegrees(Math[c](d));break;case "unnatural":e=d-Math.floor(d);0>d&&(e=1-e);break;default:e=Math[c](d)}return e},syntax:{js:[],py:["Entry.value_of_math_operation(%2, %4)"]}}, +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 d=a.getStringValue("LEFTHAND",a),c=a.getStringValue("RIGHTHAND",a),e=Math.min(d,c),f=Math.max(d,c),d=Entry.isFloat(d);return Entry.isFloat(c)||d?(Math.random()*(f-e)+e).toFixed(2):Math.floor(Math.random()*(f-e+1)+e)},syntax:{js:[],py:["random.randint(%2, %4)"]}},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 d=a.getField("VALUE",a),c= +new Date;return"YEAR"==d?c.getFullYear():"MONTH"==d?c.getMonth()+1:"DAY"==d?c.getDate():"HOUR"==d?c.getHours():"MINUTE"==d?c.getMinutes():c.getSeconds()},syntax:{js:[],py:["Entry.value_of_date_time(%2)"]}},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 d=a.getField("VALUE",a),c=b.parent.sounds,e=0;ec||c>d.length-1)throw Error();return d[c]},syntax:{js:[],py:["Entry.string_index_of(%2, %4)"]}},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},syntax:{js:[],py:["Entry.string_length(%2)"]}},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 d=a.getStringValue("STRING",a),c=a.getNumberValue("START",a)-1,e= +a.getNumberValue("END",a)-1,f=d.length-1;if(0>c||0>e||c>f||e>f)throw Error();return d.substring(Math.min(c,e),Math.max(c,e)+1)},syntax:{js:[],py:["Entry.string_substring(%2, %4, %6)"]}},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))},syntax:{js:[],py:["Entry.string_replace(%2, %4, %6)"]}},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)]()},syntax:{js:[],py:["Entry.string_case(%2, %4)"]}},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 d=a.getStringValue("LEFTHAND",a),c=a.getStringValue("RIGHTHAND",a),d=d.indexOf(c);return-1d)throw Error(Lang.Blocks.FLOW_repeat_basic_errorMsg);a.iterCount=Math.floor(d)}if(0==a.iterCount||0>a.iterCount)return delete a.isLooped,delete a.iterCount,a.callReturn();a.iterCount--;return a.getStatement("DO",a)},syntax:{js:[],py:["for i in range(%1):\n$1"]}},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")},syntax:{js:[],py:["while True:\n$1"]}},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()},syntax:{js:[],py:["break"]}},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},syntax:{js:[],py:["Entry.wait_until(%1)"]}},_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()},syntax:{js:[],py:["if %1:\n$1"]}},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 d=a.getBooleanValue("BOOL",a);a.isCondition=!0;return d?a.getStatement("STACK_IF",a):a.getStatement("STACK_ELSE",a)},syntax:{js:[],py:["if %1:\n$1\nelse:\n$2"]}},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 d=a.getField("VALUE",a),c=a.callReturn();"self"==d?b.parent.addCloneEntity(b.parent,b,null):Entry.container.getObject(d).addCloneEntity(b.parent,null,null);return c},syntax:{js:[],py:["Entry.create_clone(%1)"]}}, +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()},syntax:{js:[],py:["Entry.remove_clone()"]}},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",syntax:{js:[],py:["def entry_event_clone_create():"]}},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()},syntax:{js:[],py:[""]}},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 d=a.getBooleanValue("BOOL", +a);"until"==a.getField("OPTION",a)&&(d=!d);return(a.isLooped=d)?a.getStatement("DO",a):a.callReturn()},syntax:{js:[],py:["not yet supported in textcoding"]}},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 d=a.getField("TARGET",a),c=Entry.container;switch(d){case "all":return c.mapObject(function(a){a.script.clearExecutors()},null),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 d=this.executor,c=b.parent.script,e=c.executors,f=0;fa.count?(50>c.leftFloor&& +50>c.rightFloor?a.count++:a.count=0,c=c.leftFloor-c.rightFloor,d.leftWheel=45+.25*c,d.rightWheel=45-.25*c):(a.count=0,a.boardState=2);break;case 2:c=c.leftFloor-c.rightFloor;d.leftWheel=45+.25*c;d.rightWheel=45-.25*c;a.boardState=3;var e=setTimeout(function(){a.boardState=4;Entry.Hamster.removeTimeout(e)},250);Entry.Hamster.timeouts.push(e);break;case 3:c=c.leftFloor-c.rightFloor;d.leftWheel=45+.25*c;d.rightWheel=45-.25*c;break;case 4:d.leftWheel=0,d.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;d.leftWheel=0;d.rightWheel=0;return a.callReturn()}a.isStart=!0;a.isMoving=!0;a.count=0;a.boardState=1;d.leftWheel=45;d.rightWheel=45;Entry.Hamster.setLineTracerMode(d,0);return a},syntax:{js:[],py:["Hamster.move_forward()"]}},hamster_turn_once:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.HAMSTER_turn_once_left,"LEFT"],[Lang.Blocks.HAMSTER_turn_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 d=Entry.hw.sendQueue,c=Entry.hw.portData;if(a.isStart){if(a.isMoving){if(a.isLeft)switch(a.boardState){case 1:2>a.count?50c.leftFloor&&(a.boardState=3);break;case 3:2>a.count?20>c.leftFloor&&a.count++:(a.count= +0,a.boardState=4);break;case 4:50a.count?50c.rightFloor&&(a.boardState=3);break;case 3:2>a.count?20>c.rightFloor&&a.count++:(a.count=0,a.boardState=4);break;case 4:50Entry.Hamster.tempo&&(Entry.Hamster.tempo=1);return a.callReturn()},syntax:{js:[],py:["Hamster.add_tempo(%1)"]}},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()},syntax:{js:[],py:["Hamster.set_tempo(%1)"]}},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 d=Entry.hw.sendQueue,c=a.getField("PORT",a),e=Number(a.getField("MODE",a));"A"==c?d.ioModeA=e:("B"!=c&&(d.ioModeA=e),d.ioModeB=e);return a.callReturn()},syntax:{js:[],py:["Hamster.set_port(%1, %2)"]}},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 d=Entry.hw.sendQueue,c=a.getField("PORT"),e=a.getNumberValue("VALUE");"A"==c?d.outputA=void 0!=d.outputA?d.outputA+e:e:("B"!=c&&(d.outputA=void 0!=d.outputA? +d.outputA+e:e),d.outputB=void 0!=d.outputB?d.outputB+e:e);return a.callReturn()},syntax:{js:[],py:["Hamster.add_output(%1, %2)"]}},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 d=Entry.hw.sendQueue,c=a.getField("PORT"),e=a.getNumberValue("VALUE");"A"==c?d.outputA=e:("B"!=c&&(d.outputA=e),d.outputB=e);return a.callReturn()},syntax:{js:[],py:["Hamster.set_output(%1, %2)"]}},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},syntax:{js:[],py:["Entry.is_mouse_clicked()"]}},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 d=Number(a.getField("VALUE", +a));return 0<=Entry.pressedKeys.indexOf(d)},syntax:{js:[],py:["Entry.is_pressed(%1)"]}},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 d=a.getField("VALUE",a),c=b.object,e=/wall/.test(d),f=ndgmr.checkPixelCollision;if(e)switch(e=Entry.stage.wall,d){case "wall":return!!(f(c,e.up,.2,!0)||f(c,e.down,.2,!0)||f(c,e.left,.2,!0)||f(c,e.right,.2,!0));case "wall_up":return!!f(c,e.up,.2,!0);case "wall_down":return!!f(c,e.down,.2,!0);case "wall_right":return!!f(c,e.right,.2,!0);case "wall_left":return!!f(c,e.left,.2,!0)}else{if("mouse"==d)return f=Entry.stage.canvas, +f=c.globalToLocal(f.mouseX,f.mouseY),c.hitTest(f.x,f.y);d=Entry.container.getEntity(d);if("textBox"==d.type||"textBox"==b.type){f=d.object.getTransformedBounds();c=c.getTransformedBounds();if(Entry.checkCollisionRect(c,f))return!0;for(var d=d.parent.clonedEntities,e=0,g=d.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 d= +a.getField("OPERATOR",a),c=a.getNumberValue("LEFTHAND",a),e=a.getNumberValue("RIGHTHAND",a);return"EQUAL"==d?c==e:"BIGGER"==d?c>e: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(b,a){var d=a.getNumberValue("LEFTHAND",a),c=a.getNumberValue("RIGHTHAND",a);return d>c},syntax:{js:[],py:[""]}},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 d=a.getNumberValue("LEFTHAND",a),c=a.getNumberValue("RIGHTHAND",a);return d","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 d=a.getField("OPERATOR",a),c=a.getStringValue("LEFTHAND",a),e=a.getStringValue("RIGHTHAND",a);switch(d){case "EQUAL":return c==e;case "GREATER":return Number(c)>Number(e);case "LESS":return Number(c)=Number(e);case "LESS_OR_EQUAL":return Number(c)<=Number(e)}},syntax:{js:[],py:["(%1 %2boolean_compare# %3)"]}},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()},syntax:{js:[],py:["Entry.show()"]}},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()},syntax:{js:[],py:["Entry.hide()"]}},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 d= +a.getNumberValue("SECOND",a),c=a.getStringValue("VALUE",a),e=a.getField("OPTION",a);a.isStart=!0;a.timeFlag=1;c||"number"==typeof c||(c=" ");c=Entry.convertToRoundedDecimals(c,3);new Entry.Dialog(b,c,e);b.syncDialogVisible(b.getVisible());setTimeout(function(){a.timeFlag=0},1E3*d)}if(0==a.timeFlag)return delete a.timeFlag,delete a.isStart,b.dialog&&b.dialog.remove(),a.callReturn();b.dialog||(c=a.getStringValue("VALUE",a),e=a.getField("OPTION",a),c||"number"==typeof c||(c=" "),c=Entry.convertToRoundedDecimals(c, +3),new Entry.Dialog(b,c,e),b.syncDialogVisible(b.getVisible()));return a},syntax:{js:[],py:["Entry.print_for_seconds(%1, %2, %3)"]}},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 d=a.getStringValue("VALUE",a);d||"number"==typeof d||(d=" ");var c=a.getField("OPTION",a),d=Entry.convertToRoundedDecimals(d,3);new Entry.Dialog(b,d,c);b.syncDialogVisible(b.getVisible());return a.callReturn()},syntax:{js:[],py:["Entry.print(%1)"]}},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()},syntax:{js:[],py:["Entry.print_remove()"]}},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 d=a.getField("VALUE", +a),d=b.parent.getPicture(d);b.setImage(d);return a.callReturn()},syntax:{js:[],py:[""]}},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 d;d="prev"!==a.getStringField("DRIECTION")?b.parent.getNextPicture(b.picture.id):b.parent.getPrevPicture(b.picture.id);b.setImage(d);return a.callReturn()},syntax:{js:[],py:["Entry.set_shape_of(%1)"]}},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 d=a.getField("EFFECT",a),c=a.getNumberValue("VALUE",a);"color"==d?b.effect.hue=c+b.effect.hue:"lens"!=d&&"swriling"!=d&&"pixel"!=d&&"mosaic"!=d&&("brightness"==d?b.effect.brightness=c+b.effect.brightness:"blur"!=d&&"opacity"==d&&(b.effect.alpha+=c/100));b.applyFilter(!0); +return a.callReturn()},syntax:{js:[],py:["Entry.add_effect(%1, %2)"]}},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 d=a.getField("EFFECT",a),c=a.getNumberValue("VALUE",a);"color"==d?b.effect.hue=c:"lens"!=d&&"swriling"!=d&&"pixel"!=d&&"mosaic"!=d&&("brightness"==d?b.effect.brightness=c:"blur"!=d&&"opacity"==d&&(b.effect.alpha=c/100));b.applyFilter(!0);return a.callReturn()},syntax:{js:[],py:["Entry.set_effect(%1, %2)"]}},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()},syntax:{js:[],py:["Entry.clear_effect()"]}},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 d=(a.getNumberValue("VALUE", +a)+100)/100;b.setScaleX(b.getScaleX()*d);b.setScaleY(b.getScaleY()*d);return a.callReturn()},syntax:{js:[],py:[""]}},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 d=a.getNumberValue("VALUE",a)/100,c=b.snapshot_;b.setScaleX(d* +c.scaleX);b.setScaleY(d*c.scaleY);return a.callReturn()},syntax:{js:[],py:[""]}},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 d=a.getNumberValue("VALUE",a);b.setSize(b.getSize()+d);return a.callReturn()},syntax:{js:[],py:["Entry.add_size(%1)"]}}, +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 d=a.getNumberValue("VALUE",a);b.setSize(d);return a.callReturn()},syntax:{js:[],py:["Entry.set_size(%1)"]}},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()},syntax:{js:[],py:["Entry.flip_vertical()"]}},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()},syntax:{js:[], +py:["Entry.flip_horizontal()"]}},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 d=a.getField("VALUE",a),c=Entry.container.getCurrentObjects().indexOf(b.parent);if(-1f)throw Error("object is not available for current scene");switch(c){case "FRONT":d=0;break;case "FORWARD":d=Math.max(0,f-1);break;case "BACKWARD":d=Math.min(e,f+1);break;case "BACK":d=e}Entry.container.moveElementByBlock(f,d);return a.callReturn()},syntax:{js:[],py:["Entry.set_layer(%1)"]}},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 d=a.getNumberValue("VALUE",a);b.setX(b.getX()+d*Math.cos((b.getRotation()+b.getDirection()-90)/180*Math.PI));b.setY(b.getY()-d*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()},syntax:{js:[],py:["Entry.move(%1)"]}}, +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 d=a.getNumberValue("VALUE",a);b.setX(b.getX()+d);b.brush&&!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY());return a.callReturn()},syntax:{js:[],py:["Entry.set_x(%1)"]}},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 d=a.getNumberValue("VALUE",a);b.setY(b.getY()+d);b.brush&&!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY());return a.callReturn()},syntax:{js:[],py:["Entry.set_y(%1)"]}},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 d(){var d=a.x-b.getX(),c=a.y-b.getY(),d=d/a.frameCount,c=c/a.frameCount;b.setX(b.getX()+ +d);b.setY(b.getY()+c);a.frameCount--;b.brush&&!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY())}if(!a.isStart){var c;c=a.getNumberValue("VALUE1",a);a.isStart=!0;a.frameCount=Math.max(Math.floor(c*Entry.FPS),1);a.x=a.getNumberValue("VALUE2",a);a.y=a.getNumberValue("VALUE3",a);1==a.frameCount&&d()}if(0!=a.frameCount)return d(),a;delete a.isStart;delete a.frameCount;return a.callReturn()},syntax:{js:[],py:["Entry.set_xy_for_seconds(%1, %2, %3)"]}},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 d=a.getNumberValue("VALUE",a);b.setRotation(b.getRotation()+d);return a.callReturn()},syntax:{js:[],py:[""]}},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 d=a.getField("VALUE",a);b.setRotation(b.getRotation()+Number(d));return a.callReturn()},syntax:{js:[],py:[""]}},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 d=a.getNumberValue("VALUE",a);b.setDirection(d);return a.callReturn()},syntax:{js:[],py:[""]}},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 d=a.getField("VALUE",a),c=Entry.container.getEntity(d),d=c.getX()-b.getX(),c=c.getY()-b.getY();0<=d?b.setRotation(Math.atan(c/d)/Math.PI*180+90):b.setRotation(Math.atan(c/d)/Math.PI*180+270);return a.callReturn()},syntax:{js:[],py:[""]}},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 d=a.getNumberValue("VALUE1",a),c=a.getNumberValue("VALUE2",a);b.setX(d);b.setY(c);b.brush&&!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY());return a.callReturn()},syntax:{js:[],py:["Entry.set_xy(%1, %2)"]}},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 d=a.getNumberValue("VALUE",a);b.setX(d);b.brush&&!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY());return a.callReturn()},syntax:{js:[],py:["Entry.move_x(%1)"]}},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 d=a.getNumberValue("VALUE",a);b.setY(d);b.brush&&!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY());return a.callReturn()},syntax:{js:[],py:["Entry.move_y(%1)"]}},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 d=a.getField("VALUE",a),c;"mouse"==d?(d=Entry.stage.mouseCoordinate.x,c=Entry.stage.mouseCoordinate.y):(c=Entry.container.getEntity(d),d=c.getX(),c=c.getY());b.setX(Number(d));b.setY(Number(c));b.brush&&!b.brush.stop&&b.brush.lineTo(d,-1*c);return a.callReturn()},syntax:{js:[],py:["Entry.set_location(%1)"]}},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 d(){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 c;c=a.getNumberValue("VALUE1",a);var e=a.getNumberValue("VALUE2",a),f=a.getNumberValue("VALUE3",a);a.isStart=!0;a.frameCount=Math.max(Math.floor(c*Entry.FPS),1);a.dX=e/a.frameCount;a.dY=f/a.frameCount;1==a.frameCount&&d()}if(0!=a.frameCount)return d(),a;delete a.isStart;delete a.frameCount;return a.callReturn()},syntax:{js:[],py:["Entry.add_xy_for_seconds(%1, %2, %3)"]}},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 d;d=a.getNumberValue("VALUE",a);var c=a.getNumberField("VALUE",a);a.isStart=!0;a.frameCount=Math.floor(d*Entry.FPS);a.dAngle=c/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()},syntax:{js:[],py:[""]}},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 d=b.parent.getRotateMethod(),c="free"==d?(b.getRotation()+b.getDirection()).mod(360):b.getDirection(),e=Entry.Utils.COLLISION.NONE;if(90>c&&0<=c||360>c&&270<=c){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"==d?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"==d?b.setRotation(-b.getRotation()-2*b.getDirection()+180):b.setDirection(-b.getDirection()+180),b.collision= +Entry.Utils.COLLISION.DOWN))}else 270>c&&90<=c&&(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"==d?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"==d?b.setRotation(-b.getRotation()-2*b.getDirection()+180):b.setDirection(-b.getDirection()+180),b.collision=Entry.Utils.COLLISION.UP)));360>c&&180<=c?(e=b.collision==Entry.Utils.COLLISION.LEFT,c=ndgmr.checkPixelCollision(Entry.stage.wall.left,b.object,0,!1),!c&&e&&(b.collision=Entry.Utils.COLLISION.NONE),c&&e&&(c=!1),c?("free"==d?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,c=ndgmr.checkPixelCollision(Entry.stage.wall.right,b.object,0,!1),!c&&e&&(b.collision=Entry.Utils.COLLISION.NONE),c&&e&&(c=!1),c&&("free"==d?b.setRotation(-b.getRotation()-2*b.getDirection()):b.setDirection(-b.getDirection()+360),b.collision=Entry.Utils.COLLISION.RIGHT))):180>c&&0<=c&&(e=b.collision==Entry.Utils.COLLISION.RIGHT,c=ndgmr.checkPixelCollision(Entry.stage.wall.right,b.object,0,!1),!c&&e&&(b.collision=Entry.Utils.COLLISION.NONE),c&&e&&(c=!1),c?("free"==d?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,c=ndgmr.checkPixelCollision(Entry.stage.wall.left,b.object,0,!1),!c&&e&&(b.collision=Entry.Utils.COLLISION.NONE),c&&e&&(c=!1),c&&("free"==d?b.setRotation(-b.getRotation()-2*b.getDirection()):b.setDirection(-b.getDirection()+360),b.collision=Entry.Utils.COLLISION.LEFT)));return a.callReturn()},syntax:{js:[],py:["Entry.bounce_wall()"]}},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()},syntax:{js:[],py:[""]}},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()},syntax:{js:[],py:[""]}},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 d=a.getField("VALUE",a),c=b.getX(),e=b.getY();if(b.parent.id==d)return a.callReturn();"mouse"==d?(d=Entry.stage.mouseCoordinate.y,c=Entry.stage.mouseCoordinate.x- +c,e=d-e):(d=Entry.container.getEntity(d),c=d.getX()-c,e=d.getY()-e);e=0===c&&0===e?b.getDirection()+b.getRotation():0<=c?-Math.atan(e/c)/Math.PI*180+90:-Math.atan(e/c)/Math.PI*180+270;c=b.getDirection()+b.getRotation();b.setRotation(b.getRotation()+e-c);return a.callReturn()},syntax:{js:[],py:["Entry.look_at_object(%1)"]}},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 d=a.getNumberValue("VALUE",a),c=b.getDirection()+b.getRotation();b.setRotation(b.getRotation()+d-c);return a.callReturn()},syntax:{js:[],py:[""]}},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 d=a.getNumberValue("VALUE",a);b.setDirection(d+b.getDirection());return a.callReturn()},syntax:{js:[],py:[""]}},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 d,c,e;c=a.getField("TARGET",a);d=a.getNumberValue("VALUE",a);d=Math.floor(d*Entry.FPS);e=Entry.stage.mouseCoordinate;if(0!=d)"mouse"==c?(c=e.x-b.getX(),e=e.y-b.getY()):(e=Entry.container.getEntity(c),c=e.getX()-b.getX(),e=e.getY()-b.getY()),a.isStart=!0,a.frameCount=d,a.dX=c/a.frameCount,a.dY=e/a.frameCount; +else return"mouse"==c?(c=Number(e.x),e=Number(e.y)):(e=Entry.container.getEntity(c),c=e.getX(),e=e.getY()),b.setX(c),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()},syntax:{js:[],py:["Entry.set_location_for_seconds(%1, %2)"]}},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 d=a.getNumberValue("VALUE",a);b.setRotation(d);return a.callReturn()},syntax:{js:[],py:["Entry.set_rotation(%1)"]}},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 d=a.getNumberValue("VALUE",a);b.setRotation(d+b.getRotation());return a.callReturn()},syntax:{js:[],py:["Entry.add_rotation(%1)"]}},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 d=a.getNumberValue("VALUE",a);b.setDirection(d);return a.callReturn()},syntax:{js:[],py:["Entry.set_direction(%1)"]}},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 d=a.getNumberValue("VALUE",a);b.setDirection(d+b.getDirection());return a.callReturn()},syntax:{js:[],py:["Entry.add_direction(%1)"]}},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 d=a.getNumberValue("VALUE",a),c=a.getNumberValue("ANGLE",a);b.setX(b.getX()+d*Math.cos((c-90)/180*Math.PI));b.setY(b.getY()-d*Math.sin((c-90)/180*Math.PI));b.brush&&!b.brush.stop&&b.brush.lineTo(b.getX(),-1*b.getY());return a.callReturn()},syntax:{js:[],py:["Entry.move_degree(%1, %2)"]}},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 d(){b.setRotation(b.getRotation()+a.dAngle);a.frameCount--}if(!a.isStart){var c;c=a.getNumberValue("VALUE",a);var e=a.getNumberValue("ANGLE",a);a.isStart=!0;a.frameCount=Math.max(Math.floor(c*Entry.FPS),1);a.dAngle=e/a.frameCount;1==a.frameCount&&d()}if(0!=a.frameCount)return d(),a;delete a.isStart;delete a.frameCount; +return a.callReturn()},syntax:{js:[],py:["Entry.add_rotation_for_seconds(%1, %2)"]}},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 d(){b.setDirection(b.getDirection()+ +a.dDirection);a.frameCount--}if(!a.isStart){var c;c=a.getNumberValue("DURATION",a);var e=a.getNumberValue("AMOUNT",a);a.isStart=!0;a.frameCount=Math.max(Math.floor(c*Entry.FPS),1);a.dDirection=e/a.frameCount;1==a.frameCount&&d()}if(0!=a.frameCount)return d(),a;delete a.isStart;delete a.frameCount;delete a.dDirection;return a.callReturn()},syntax:{js:[],py:["Entry.add_direction_for_seconds(%1, %2)"]}},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 d=a.getStringField("PORT");return Entry.hw.portData[d]},syntax:{js:[],py:["Neobot.sensor_value(%1)"]}},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 d=a.getStringField("PORT"),d=Entry.hw.portData[d],c=a.getNumberValue("OMIN",a),e=a.getNumberValue("OMAX",a),f=a.getNumberValue("MIN",a),g=a.getNumberValue("MAX",a);if(c>e)var h=c,c=e,e=h;f>g&&(h=f,f=g,g=h);d=(g-f)/ +(e-c)*(d-c);d+=f;d=Math.min(g,d);d=Math.max(f,d);return Math.round(d)}},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 d=a.getNumberField("SPEED"),c=a.getNumberField("DIRECTION");Entry.hw.sendQueue.DCL=d+c;return a.callReturn()},syntax:{js:[],py:["Neobot.turn_left(%1, %2)"]}}, +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()},syntax:{js:[],py:["Neobot.stop_left()"]}},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_left_motor"},paramsKeyMap:{DIRECTION:0,SPEED:1},"class":"neobot_motor",isNotFor:["neobot"],func:function(b,a){b=a.getNumberField("SPEED");var d=a.getNumberField("DIRECTION");Entry.hw.sendQueue.DCL=b+d;return a.callReturn()},syntax:{js:[],py:["Neobot.turn_left(%1, %2)"]}},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()},syntax:{js:[],py:["Neobot.stop_left()"]}},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){b=a.getNumberField("SPEED");var d= -a.getNumberField("DIRECTION");Entry.hw.sendQueue.DCR=b+d;return a.callReturn()},syntax:{js:[],py:["Neobot.turn_right(%1, %2)"]}},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()}, -syntax:{js:[],py:["Neobot.stop_right()"]}},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()}b=a.getNumberField("SPEED");var d=a.getNumberField("DIRECTION"),c=a.getNumberValue("DURATION");0>c&&(c=0);switch(d){case 1:Entry.hw.sendQueue.DCL=16+b;Entry.hw.sendQueue.DCR=16+b;break;case 2:Entry.hw.sendQueue.DCL=32+b; -Entry.hw.sendQueue.DCR=32+b;break;case 3:Entry.hw.sendQueue.DCL=32+b;Entry.hw.sendQueue.DCR=16+b;break;case 4:Entry.hw.sendQueue.DCL=16+b;Entry.hw.sendQueue.DCR=32+b;break;case 5:Entry.hw.sendQueue.DCL=0;Entry.hw.sendQueue.DCR=16+b;break;case 6:Entry.hw.sendQueue.DCL=16+b,Entry.hw.sendQueue.DCR=0}if(0===c)return a.callReturn();a.isStart=!0;a.timeFlag=1;setTimeout(function(){a.timeFlag=0},1E3*c);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()},syntax:{js:[],py:["Neobot.run_motor(%1, %2, %3, %4)"]}},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){b=a.getNumberField("PORT");var d=a.getNumberValue("DEGREE");0>d?d=0:180d?d=0:255b.count)throw b.count++,new Entry.Utils.AsyncError;b.isStart=!1;a=Entry.hw.portData[b.data_default_address];b.data_default_address= -void 0;return a},syntax:{js:[],py:["Robotis.opencm70_cm_custom_value(%1, %2)"]}},robotis_openCM70_sensor_value:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.robotis_cm_sound_detected,"CM_SOUND_DETECTED"],[Lang.Blocks.robotis_cm_sound_detecting,"CM_SOUND_DETECTING"],[Lang.Blocks.robotis_cm_user_button,"CM_USER_BUTTON"]],value:"CM_SOUND_DETECTED",fontSize:11}],events:{},def:{params:[null],type:"robotis_openCM70_sensor_value"}, -paramsKeyMap:{SENSOR:0},"class":"robotis_openCM70_cm",isNotFor:["robotis_openCM70"],func:function(b,a){b=a.executor.scope;if(!b.isStart){b.isStart=!0;b.count=0;var d=Entry.Robotis_openCM70.INSTRUCTION.READ,c=0,e=0,f=0,g=0;a=a.getStringField("SENSOR");"CM_SOUND_DETECTED"==a?(f=Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTED[0],g=Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTED[1],c=Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTED[0],e=Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTED[1]): -"CM_SOUND_DETECTING"==a?(f=Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTING[0],g=Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTING[1],c=Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTING[0],e=Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTING[1]):"CM_USER_BUTTON"==a&&(f=Entry.Robotis_openCM70.CONTROL_TABLE.CM_USER_BUTTON[0],g=Entry.Robotis_openCM70.CONTROL_TABLE.CM_USER_BUTTON[1],c=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([[d,c,e,0,g]]);Entry.Robotis_carCont.update();b.data_default_address=f;throw new Entry.Utils.AsyncError;}if(2>b.count)throw b.count++,new Entry.Utils.AsyncError;b.isStart=!1;a=Entry.hw.portData[b.data_default_address];b.data_default_address=void 0;return a},syntax:{js:[],py:["Robotis.opencm70_sensor_value(%1)"]}},robotis_openCM70_aux_sensor_value:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],params:[{type:"Dropdown",options:[["3", -"PORT_3"],["4","PORT_4"],["5","PORT_5"],["6","PORT_6"]],value:"PORT_3",fontSize:11},{type:"Dropdown",options:[[Lang.Blocks.robotis_aux_servo_position,"AUX_SERVO_POSITION"],[Lang.Blocks.robotis_aux_ir,"AUX_IR"],[Lang.Blocks.robotis_aux_touch,"AUX_TOUCH"],[Lang.Blocks.robotis_aux_brightness,"AUX_BRIGHTNESS"],[Lang.Blocks.robotis_aux_hydro_themo_humidity,"AUX_HYDRO_THEMO_HUMIDITY"],[Lang.Blocks.robotis_aux_hydro_themo_temper,"AUX_HYDRO_THEMO_TEMPER"],[Lang.Blocks.robotis_aux_temperature,"AUX_TEMPERATURE"], -[Lang.Blocks.robotis_aux_ultrasonic,"AUX_ULTRASONIC"],[Lang.Blocks.robotis_aux_magnetic,"AUX_MAGNETIC"],[Lang.Blocks.robotis_aux_motion_detection,"AUX_MOTION_DETECTION"],[Lang.Blocks.robotis_aux_color,"AUX_COLOR"],[Lang.Blocks.robotis_aux_custom,"AUX_CUSTOM"]],value:"AUX_SERVO_POSITION",fontSize:11}],events:{},def:{params:[null,null],type:"robotis_openCM70_aux_sensor_value"},paramsKeyMap:{PORT:0,SENSOR:1},"class":"robotis_openCM70_cm",isNotFor:["robotis_openCM70"],func:function(b,a){b=a.executor.scope; -if(!b.isStart){b.isStart=!0;b.count=0;var d=Entry.Robotis_openCM70.INSTRUCTION.READ,c=0,e=0,f=0,g=a.getStringField("PORT");a=a.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"==a?(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[1]):"AUX_IR"==a?(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[1]):"AUX_TOUCH"==a?(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[1]):"AUX_TEMPERATURE"==a?(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[1]):"AUX_BRIGHTNESS"==a?(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[1]):"AUX_HYDRO_THEMO_HUMIDITY"==a?(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[1]):"AUX_HYDRO_THEMO_TEMPER"==a?(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[1]): -"AUX_ULTRASONIC"==a?(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[1]):"AUX_MAGNETIC"==a?(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[1]):"AUX_MOTION_DETECTION"==a?(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[1]):"AUX_COLOR"==a?(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[1]):"AUX_CUSTOM"==a&&(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[1]);e+=h*f;Entry.Robotis_carCont.setRobotisData([[d,e,c,0,f]]);Entry.Robotis_carCont.update(); -b.data_default_address=e;console.log(e);throw new Entry.Utils.AsyncError;}if(2>b.count)throw b.count++,new Entry.Utils.AsyncError;b.isStart=!1;d=Entry.hw.portData[b.data_default_address];b.data_default_address=void 0;return d},syntax:{js:[],py:["Robotis.opencm70_aux_sensor_value(%1, %2)"]}},robotis_openCM70_cm_buzzer_index:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.General.note_a+"(0)","0"],[Lang.General.note_a+"#(1)","1"],[Lang.General.note_b+"(2)","2"], -[Lang.General.note_c+"(3)","3"],[Lang.General.note_c+"#(4)","4"],[Lang.General.note_d+"(5)","5"],[Lang.General.note_d+"#(6)","6"],[Lang.General.note_e+"(7)","7"],[Lang.General.note_f+"(8)","8"],[Lang.General.note_f+"#(9)","9"],[Lang.General.note_g+"(10)","10"],[Lang.General.note_g+"#(11)","11"],[Lang.General.note_a+"(12)","12"],[Lang.General.note_a+"#(13)","13"],[Lang.General.note_b+"(14)","14"],[Lang.General.note_c+"(15)","15"],[Lang.General.note_c+"#(16)","16"],[Lang.General.note_d+"(17)","17"], -[Lang.General.note_d+"#(18)","18"],[Lang.General.note_e+"(19)","19"],[Lang.General.note_f+"(20)","20"],[Lang.General.note_f+"#(21)","21"],[Lang.General.note_g+"(22)","22"],[Lang.General.note_g+"#(23)","23"],[Lang.General.note_a+"(24)","24"],[Lang.General.note_a+"#(25)","25"],[Lang.General.note_b+"(26)","26"],[Lang.General.note_c+"(27)","27"],[Lang.General.note_c+"#(28)","28"],[Lang.General.note_d+"(29)","29"],[Lang.General.note_d+"#(30)","30"],[Lang.General.note_e+"(31)","31"],[Lang.General.note_f+ -"(32)","32"],[Lang.General.note_f+"#(33)","33"],[Lang.General.note_g+"(34)","34"],[Lang.General.note_g+"#(35)","35"],[Lang.General.note_a+"(36)","36"],[Lang.General.note_a+"#(37)","37"],[Lang.General.note_b+"(38)","38"],[Lang.General.note_c+"(39)","39"],[Lang.General.note_c+"#(40)","40"],[Lang.General.note_d+"(41)","41"],[Lang.General.note_d+"#(42)","42"],[Lang.General.note_e+"(43)","43"],[Lang.General.note_f+"(44)","44"],[Lang.General.note_f+"#(45)","45"],[Lang.General.note_g+"(46)","46"],[Lang.General.note_g+ -"#(47)","47"],[Lang.General.note_a+"(48)","48"],[Lang.General.note_a+"#(49)","49"],[Lang.General.note_b+"(50)","50"],[Lang.General.note_c+"(51)","51"]],value:"0",fontSize:11},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",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){b= -a.getField("CM_BUZZER_INDEX",a);var d=a.getNumberValue("CM_BUZZER_TIME",a),c=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*d);50d&&(d=0);return Entry.Robotis_carCont.postCallReturn(a,[[c,e+(b-1)*f,f,d]],Entry.Robotis_openCM70.delay)},syntax:{js:[],py:["Robotis.opencm70_aux_servo_position(%1, %2)"]}},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){b=a.getField("PORT",a);var d=a.getField("LED_MODULE",a),c=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(a,[[c,e+(b-1)*f,f,d]],Entry.Robotis_openCM70.delay)},syntax:{js:[],py:["Robotis.opencm70_aux_led_module(%1, %2)"]}},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){b=a.getField("PORT",a);var d=a.getNumberValue("VALUE"),c=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(a, -[[c,e+(b-1)*f,f,d]],Entry.Robotis_openCM70.delay)},syntax:{js:[],py:["Robotis.opencm70_aux_custom(%1, %2)"]}},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){b=Entry.Robotis_openCM70.INSTRUCTION.WRITE;var d,c;d=a.getNumberValue("ADDRESS");c=a.getNumberValue("VALUE");return Entry.Robotis_carCont.postCallReturn(a,[[b,d,65535b&&(b=0);createjs.Sound.setVolume(b);return a.callReturn()},syntax:{js:[],py:["Entry.add_volume(%1)"]}},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){b=a.getNumberValue("VALUE",a)/100;1b&&(b=0);createjs.Sound.setVolume(b);return a.callReturn()},syntax:{js:[],py:["Entry.set_volume(%1)"]}},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()}, -syntax:{js:[],py:["Entry.stop_sound()"]}},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")},syntax:{js:[],py:["%1get_sounds#"]}},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 d=a.getStringValue("VALUE",a);(b=b.parent.getSound(d))&&createjs.Sound.play(b.id);return a.callReturn()},syntax:{js:[],py:["Entry.play_sound(%1)"]}},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 d=a.getStringValue("VALUE",a),c=a.getNumberValue("SECOND",a);(b=b.parent.getSound(d))&&createjs.Sound.play(b.id,{startTime:0,duration:1E3*c});return a.callReturn()},syntax:{js:[],py:["Entry.play_sound_for_seconds(%1, %2)"]}}, -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 d=a.getStringValue("VALUE",a);if(b= -b.parent.getSound(d))createjs.Sound.play(b.id),setTimeout(function(){a.playState=0},1E3*b.duration);return a},syntax:{js:[],py:["Entry.play_sound_and_wait(%1)"]}},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 d=a.getStringValue("VALUE",a);if(b=b.parent.getSound(d)){var c=createjs.Sound.play(b.id);b=a.getNumberValue("SECOND",a);setTimeout(function(){c.stop();a.playState=0},1E3*b);c.addEventListener("complete",function(a){})}return a},syntax:{js:[],py:["Entry.play_sound_for_seconds_and_wait(%1, %2)"]}}, -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 d=a.getStringValue("VALUE",a);if(b=b.parent.getSound(d)){var d= -1E3*a.getNumberValue("START",a),c=1E3*a.getNumberValue("END",a);createjs.Sound.play(b.id,{startTime:Math.min(d,c),duration:Math.max(d,c)-Math.min(d,c)})}return a.callReturn()},syntax:{js:[],py:["Entry.play_sound_from_to_seconds(%1, %2, %3)"]}},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 d=a.getStringValue("VALUE",a);if(b=b.parent.getSound(d)){var c=1E3*a.getNumberValue("START",a),e=1E3*a.getNumberValue("END",a),d=Math.min(c,e),c=Math.max(c,e)-d;createjs.Sound.play(b.id,{startTime:d, -duration:c});setTimeout(function(){a.playState=0},c)}return a},syntax:{js:[],py:["Entry.play_sound_from_to_seconds_and_wait(%1, %2, %3)"]}},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",syntax:{js:[],py:["def entry_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()},syntax:{js:[],py:[""]}},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",syntax:{js:[],py:["def entry_event_key(%2):"]}},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",syntax:{js:[],py:["def entry_event_mouse_down():"]}},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",syntax:{js:[],py:["def entry_event_mouse_up():"]}},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",syntax:{js:[],py:["def entry_event_object_down():"]}},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", -syntax:{js:[],py:["def entry_event_object_up():"]}},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",syntax:{js:[],py:["Entry.on_key_press_down(%1)"]}},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",syntax:{js:[], -py:["def entry_event_signal(%2):"]}},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){b=a.getField("VALUE",a);var d=Entry.isExist(b,"id",Entry.variableContainer.messages_);if("null"==b||!d)throw Error("value can not be null or undefined");Entry.container.mapEntityIncludeCloneOnScene(Entry.engine.raiseKeyEvent,["when_message_cast",b]);return a.callReturn()},syntax:{js:[],py:["Entry.send_signal(%1)"]}},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){b=a.runningScript;for(var d=b.length,c=0;cb.array_.length)throw Error("can not remove value from array");b.array_.splice(c-1,1);b.updateView();return a.callReturn()},syntax:{js:[],py:["%2.pop(%1)"]}},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 d=a.getField("LIST",a),c=a.getValue("DATA",a),e=a.getValue("INDEX",a);b=Entry.variableContainer.getList(d,b);if(!b.array_||isNaN(e)||0== -e||e>b.array_.length+1)throw Error("can not insert value to array");b.array_.splice(e-1,0,{data:c});b.updateView();return a.callReturn()},syntax:{js:[],py:["%2.insert(%3, %1)"]}},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 d=a.getField("LIST",a),c=a.getValue("DATA",a),e=a.getValue("INDEX",a);b=Entry.variableContainer.getList(d,b);if(!b.array_||isNaN(e)|| -e>b.array_.length)throw Error("can not insert value to array");b.array_[e-1].data=c;b.updateView();return a.callReturn()},syntax:{js:[],py:["%1[%2] = %3"]}},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 d=a.getField("LIST",a);a=a.getValue("INDEX",a);b=Entry.variableContainer.getList(d,b);a=Entry.getListRealIndex(a,b);if(!b.array_||isNaN(a)||a>b.array_.length)throw Error("can not insert value to array");return b.array_[a-1].data},syntax:{js:[],py:["%2[%4]"]}},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){a=a.getField("LIST",a);return Entry.variableContainer.getList(a,b).array_.length},syntax:{js:[],py:["len(%2)"]}}, -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){b=a.getField("LIST",a);Entry.variableContainer.getList(b).setVisible(!0);return a.callReturn()},syntax:{js:[],py:["Entry.show_list(%1)"]}},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){b=a.getField("LIST",a);Entry.variableContainer.getList(b).setVisible(!1);return a.callReturn()},syntax:{js:[],py:["Entry.hide_list(%1)"]}},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)},syntax:{js:[],py:[""]}},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()},syntax:{js:[],py:["Entry.answer_mode(%1)"]}}, -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 d=a.getField("LIST",a);a=a.getStringValue("DATA",a);b=Entry.variableContainer.getList(d,b);if(!b)return!1;b=b.array_;for(var d=0,c=b.length;de&&(e=0);switch(c){case 1:Entry.hw.sendQueue.DCL=16+d;Entry.hw.sendQueue.DCR=16+d;break;case 2:Entry.hw.sendQueue.DCL=32+d;Entry.hw.sendQueue.DCR=32+d;break;case 3:Entry.hw.sendQueue.DCL=32+d;Entry.hw.sendQueue.DCR=16+d;break;case 4:Entry.hw.sendQueue.DCL=16+d;Entry.hw.sendQueue.DCR=32+d;break;case 5:Entry.hw.sendQueue.DCL=0;Entry.hw.sendQueue.DCR=16+d;break;case 6:Entry.hw.sendQueue.DCL=16+d,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()},syntax:{js:[],py:["Neobot.run_motor(%1, %2, %3, %4)"]}}, +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 d=a.getNumberField("PORT"),c=a.getNumberValue("DEGREE");0>c?c=0:180c?c=0:255d.count)throw d.count++,new Entry.Utils.AsyncError;d.isStart=!1;c=Entry.hw.portData[d.data_default_address];d.data_default_address=void 0;return c},syntax:{js:[],py:["Robotis.opencm70_cm_custom_value(%1, %2)"]}},robotis_openCM70_sensor_value:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.robotis_cm_sound_detected,"CM_SOUND_DETECTED"],[Lang.Blocks.robotis_cm_sound_detecting,"CM_SOUND_DETECTING"],[Lang.Blocks.robotis_cm_user_button, +"CM_USER_BUTTON"]],value:"CM_SOUND_DETECTED",fontSize:11}],events:{},def:{params:[null],type:"robotis_openCM70_sensor_value"},paramsKeyMap:{SENSOR:0},"class":"robotis_openCM70_cm",isNotFor:["robotis_openCM70"],func:function(b,a){var d=a.executor.scope;if(!d.isStart){d.isStart=!0;d.count=0;var c=Entry.Robotis_openCM70.INSTRUCTION.READ,e=0,f=0,g=0,h=0,k=a.getStringField("SENSOR");"CM_SOUND_DETECTED"==k?(g=Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTED[0],h=Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTED[1], +e=Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTED[0],f=Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTED[1]):"CM_SOUND_DETECTING"==k?(g=Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTING[0],h=Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTING[1],e=Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTING[0],f=Entry.Robotis_openCM70.CONTROL_TABLE.CM_SOUND_DETECTING[1]):"CM_USER_BUTTON"==k&&(g=Entry.Robotis_openCM70.CONTROL_TABLE.CM_USER_BUTTON[0],h=Entry.Robotis_openCM70.CONTROL_TABLE.CM_USER_BUTTON[1], +e=Entry.Robotis_openCM70.CONTROL_TABLE.CM_USER_BUTTON[0],f=Entry.Robotis_openCM70.CONTROL_TABLE.CM_USER_BUTTON[1]);g+=0*h;Entry.Robotis_carCont.setRobotisData([[c,e,f,0,h]]);Entry.Robotis_carCont.update();d.data_default_address=g;throw new Entry.Utils.AsyncError;}if(2>d.count)throw d.count++,new Entry.Utils.AsyncError;d.isStart=!1;c=Entry.hw.portData[d.data_default_address];d.data_default_address=void 0;return c},syntax:{js:[],py:["Robotis.opencm70_sensor_value(%1)"]}},robotis_openCM70_aux_sensor_value:{color:"#00979D", +fontColor:"#fff",skeleton:"basic_string_field",statements:[],params:[{type:"Dropdown",options:[["3","PORT_3"],["4","PORT_4"],["5","PORT_5"],["6","PORT_6"]],value:"PORT_3",fontSize:11},{type:"Dropdown",options:[[Lang.Blocks.robotis_aux_servo_position,"AUX_SERVO_POSITION"],[Lang.Blocks.robotis_aux_ir,"AUX_IR"],[Lang.Blocks.robotis_aux_touch,"AUX_TOUCH"],[Lang.Blocks.robotis_aux_brightness,"AUX_BRIGHTNESS"],[Lang.Blocks.robotis_aux_hydro_themo_humidity,"AUX_HYDRO_THEMO_HUMIDITY"],[Lang.Blocks.robotis_aux_hydro_themo_temper, +"AUX_HYDRO_THEMO_TEMPER"],[Lang.Blocks.robotis_aux_temperature,"AUX_TEMPERATURE"],[Lang.Blocks.robotis_aux_ultrasonic,"AUX_ULTRASONIC"],[Lang.Blocks.robotis_aux_magnetic,"AUX_MAGNETIC"],[Lang.Blocks.robotis_aux_motion_detection,"AUX_MOTION_DETECTION"],[Lang.Blocks.robotis_aux_color,"AUX_COLOR"],[Lang.Blocks.robotis_aux_custom,"AUX_CUSTOM"]],value:"AUX_SERVO_POSITION",fontSize:11}],events:{},def:{params:[null,null],type:"robotis_openCM70_aux_sensor_value"},paramsKeyMap:{PORT:0,SENSOR:1},"class":"robotis_openCM70_cm", +isNotFor:["robotis_openCM70"],func:function(b,a){var d=a.executor.scope;if(!d.isStart){d.isStart=!0;d.count=0;var c=Entry.Robotis_openCM70.INSTRUCTION.READ,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],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],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],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],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],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],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],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],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],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],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],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], +e=Entry.Robotis_openCM70.CONTROL_TABLE.AUX_CUSTOM[1]);f+=l*g;Entry.Robotis_carCont.setRobotisData([[c,f,e,0,g]]);Entry.Robotis_carCont.update();d.data_default_address=f;console.log(f);throw new Entry.Utils.AsyncError;}if(2>d.count)throw d.count++,new Entry.Utils.AsyncError;d.isStart=!1;c=Entry.hw.portData[d.data_default_address];d.data_default_address=void 0;return c},syntax:{js:[],py:["Robotis.opencm70_aux_sensor_value(%1, %2)"]}},robotis_openCM70_cm_buzzer_index:{color:"#00979D",skeleton:"basic", +statements:[],params:[{type:"Dropdown",options:[[Lang.General.note_a+"(0)","0"],[Lang.General.note_a+"#(1)","1"],[Lang.General.note_b+"(2)","2"],[Lang.General.note_c+"(3)","3"],[Lang.General.note_c+"#(4)","4"],[Lang.General.note_d+"(5)","5"],[Lang.General.note_d+"#(6)","6"],[Lang.General.note_e+"(7)","7"],[Lang.General.note_f+"(8)","8"],[Lang.General.note_f+"#(9)","9"],[Lang.General.note_g+"(10)","10"],[Lang.General.note_g+"#(11)","11"],[Lang.General.note_a+"(12)","12"],[Lang.General.note_a+"#(13)", +"13"],[Lang.General.note_b+"(14)","14"],[Lang.General.note_c+"(15)","15"],[Lang.General.note_c+"#(16)","16"],[Lang.General.note_d+"(17)","17"],[Lang.General.note_d+"#(18)","18"],[Lang.General.note_e+"(19)","19"],[Lang.General.note_f+"(20)","20"],[Lang.General.note_f+"#(21)","21"],[Lang.General.note_g+"(22)","22"],[Lang.General.note_g+"#(23)","23"],[Lang.General.note_a+"(24)","24"],[Lang.General.note_a+"#(25)","25"],[Lang.General.note_b+"(26)","26"],[Lang.General.note_c+"(27)","27"],[Lang.General.note_c+ +"#(28)","28"],[Lang.General.note_d+"(29)","29"],[Lang.General.note_d+"#(30)","30"],[Lang.General.note_e+"(31)","31"],[Lang.General.note_f+"(32)","32"],[Lang.General.note_f+"#(33)","33"],[Lang.General.note_g+"(34)","34"],[Lang.General.note_g+"#(35)","35"],[Lang.General.note_a+"(36)","36"],[Lang.General.note_a+"#(37)","37"],[Lang.General.note_b+"(38)","38"],[Lang.General.note_c+"(39)","39"],[Lang.General.note_c+"#(40)","40"],[Lang.General.note_d+"(41)","41"],[Lang.General.note_d+"#(42)","42"],[Lang.General.note_e+ +"(43)","43"],[Lang.General.note_f+"(44)","44"],[Lang.General.note_f+"#(45)","45"],[Lang.General.note_g+"(46)","46"],[Lang.General.note_g+"#(47)","47"],[Lang.General.note_a+"(48)","48"],[Lang.General.note_a+"#(49)","49"],[Lang.General.note_b+"(50)","50"],[Lang.General.note_c+"(51)","51"]],value:"0",fontSize:11},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",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 d=a.getField("CM_BUZZER_INDEX",a),c=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*c);50c&&(c=0);return Entry.Robotis_carCont.postCallReturn(a,[[e,f+(d-1)*g,g,c]],Entry.Robotis_openCM70.delay)},syntax:{js:[],py:["Robotis.opencm70_aux_servo_position(%1, %2)"]}},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 d=a.getField("PORT",a),c=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+(d-1)*g,g,c]],Entry.Robotis_openCM70.delay)},syntax:{js:[],py:["Robotis.opencm70_aux_led_module(%1, %2)"]}},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 d=a.getField("PORT",a),c=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+(d-1)*g,g,c]],Entry.Robotis_openCM70.delay)},syntax:{js:[],py:["Robotis.opencm70_aux_custom(%1, %2)"]}},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 d=Entry.Robotis_openCM70.INSTRUCTION.WRITE,c=0,e=0,c=a.getNumberValue("ADDRESS"),e=a.getNumberValue("VALUE");return Entry.Robotis_carCont.postCallReturn(a,[[d,c,65535d&&(d=0);createjs.Sound.setVolume(d);return a.callReturn()},syntax:{js:[],py:["Entry.add_volume(%1)"]}},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 d=a.getNumberValue("VALUE",a)/100;1d&&(d=0);createjs.Sound.setVolume(d); +return a.callReturn()},syntax:{js:[],py:["Entry.set_volume(%1)"]}},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()},syntax:{js:[],py:["Entry.stop_sound()"]}},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")},syntax:{js:[],py:["%1get_sounds#"]}},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 d=a.getStringValue("VALUE",a);(d=b.parent.getSound(d))&&createjs.Sound.play(d.id);return a.callReturn()},syntax:{js:[],py:["Entry.play_sound(%1)"]}},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 d=a.getStringValue("VALUE",a),c=a.getNumberValue("SECOND",a);(d=b.parent.getSound(d))&&createjs.Sound.play(d.id,{startTime:0,duration:1E3*c});return a.callReturn()},syntax:{js:[],py:["Entry.play_sound_for_seconds(%1, %2)"]}},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 d=a.getStringValue("VALUE",a);if(d=b.parent.getSound(d))createjs.Sound.play(d.id),setTimeout(function(){a.playState=0},1E3*d.duration);return a},syntax:{js:[],py:["Entry.play_sound_and_wait(%1)"]}},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 d=a.getStringValue("VALUE", +a);if(d=b.parent.getSound(d)){var c=createjs.Sound.play(d.id),d=a.getNumberValue("SECOND",a);setTimeout(function(){c.stop();a.playState=0},1E3*d);c.addEventListener("complete",function(a){})}return a},syntax:{js:[],py:["Entry.play_sound_for_seconds_and_wait(%1, %2)"]}},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 d=a.getStringValue("VALUE",a);if(d=b.parent.getSound(d)){var c=1E3*a.getNumberValue("START",a),e=1E3*a.getNumberValue("END",a);createjs.Sound.play(d.id,{startTime:Math.min(c,e),duration:Math.max(c,e)-Math.min(c,e)})}return a.callReturn()},syntax:{js:[],py:["Entry.play_sound_from_to_seconds(%1, %2, %3)"]}}, +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 d=a.getStringValue("VALUE",a);if(d=b.parent.getSound(d)){var c=1E3*a.getNumberValue("START",a),e=1E3*a.getNumberValue("END",a),f=Math.min(c,e),c=Math.max(c,e)-f;createjs.Sound.play(d.id,{startTime:f,duration:c});setTimeout(function(){a.playState=0},c)}return a},syntax:{js:[],py:["Entry.play_sound_from_to_seconds_and_wait(%1, %2, %3)"]}},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",syntax:{js:[],py:["def entry_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()},syntax:{js:[],py:[""]}},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",syntax:{js:[],py:["def entry_event_key(%2):"]}},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",syntax:{js:[],py:["def entry_event_mouse_down():"]}},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",syntax:{js:[],py:["def entry_event_mouse_up():"]}},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",syntax:{js:[],py:["def entry_event_object_down():"]}},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",syntax:{js:[],py:["def entry_event_object_up():"]}},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",syntax:{js:[],py:["Entry.on_key_press_down(%1)"]}},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",syntax:{js:[],py:["def entry_event_signal(%2):"]}},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 d=a.getField("VALUE",a),c=Entry.isExist(d,"id",Entry.variableContainer.messages_);if("null"==d||!c)throw Error("value can not be null or undefined");Entry.container.mapEntityIncludeCloneOnScene(Entry.engine.raiseKeyEvent, +["when_message_cast",d]);return a.callReturn()},syntax:{js:[],py:["Entry.send_signal(%1)"]}},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 d=a.runningScript,c=d.length,e=0;ed.array_.length)throw Error("can not remove value from array");d.array_.splice(c-1,1);d.updateView();return a.callReturn()},syntax:{js:[],py:["%2.pop(%1)"]}},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 d=a.getField("LIST",a),c=a.getValue("DATA",a),e=a.getValue("INDEX",a),d=Entry.variableContainer.getList(d,b);if(!d.array_||isNaN(e)||0==e||e>d.array_.length+1)throw Error("can not insert value to array");d.array_.splice(e-1,0,{data:c});d.updateView();return a.callReturn()},syntax:{js:[],py:["%2.insert(%3, %1)"]}},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 d=a.getField("LIST",a),c=a.getValue("DATA",a),e=a.getValue("INDEX",a),d=Entry.variableContainer.getList(d,b);if(!d.array_||isNaN(e)||e>d.array_.length)throw Error("can not insert value to array");d.array_[e-1].data=c;d.updateView();return a.callReturn()},syntax:{js:[],py:["%1[%2] = %3"]}},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 d=a.getField("LIST",a),c=a.getValue("INDEX",a),d=Entry.variableContainer.getList(d,b),c=Entry.getListRealIndex(c,d);if(!d.array_||isNaN(c)||c>d.array_.length)throw Error("can not insert value to array");return d.array_[c-1].data},syntax:{js:[],py:["%2[%4]"]}},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 d=a.getField("LIST",a);return Entry.variableContainer.getList(d,b).array_.length},syntax:{js:[],py:["len(%2)"]}},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 d=a.getField("LIST",a);Entry.variableContainer.getList(d).setVisible(!0);return a.callReturn()},syntax:{js:[],py:["Entry.show_list(%1)"]}},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 d=a.getField("LIST",a);Entry.variableContainer.getList(d).setVisible(!1); +return a.callReturn()},syntax:{js:[],py:["Entry.hide_list(%1)"]}},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)},syntax:{js:[],py:[""]}},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()},syntax:{js:[],py:["Entry.answer_mode(%1)"]}},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 d=a.getField("LIST", +a),c=a.getStringValue("DATA",a),d=Entry.variableContainer.getList(d,b);if(!d)return!1;for(var d=d.array_,e=0,f=d.length;eh&&(h=Math.round(h-155),f=-h,g=0,Entry.dplay.vel_value=f);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(b,f),Entry.hw.setDigitalPortValue(d,g),Entry.hw.setDigitalPortValue(c,f),Entry.hw.setDigitalPortValue(e,g),delete a.isStart,delete a.timeFlag,Entry.engine.isContinue=!1,a.callReturn()}else{a.isStart=!0;a.timeFlag=1;var k=setTimeout(function(){a.timeFlag=2;Entry.dplay.removeTimeout(k)},50);Entry.dplay.timeouts.push(k);return a}},syntax:{js:[],py:["Dplay.dc_motor_speed(%1, %2)"]}}, +VALUE:1},"class":"dplay_set",isNotFor:["dplay"],func:function(b,a){var d=0,c=0,e=0,f=0,g=0,h=0,k=0,k=a.getField("PORT");"1"==k?(d=3,c=5):"2"==k?(d=11,c=6):"3"==k&&(d=3,c=5,e=11,f=6);k=a.getNumberValue("VALUE",a);k=Math.max(k,-100);k=Math.min(k,100);0==k?(h=g=0,Entry.dplay.vel_value=h):0k&&(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(d,g),Entry.hw.setDigitalPortValue(c,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}},syntax:{js:[],py:["Dplay.dc_motor_speed(%1, %2)"]}}, 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()}b=a.getNumberField("NOTE",a);var d=a.getNumberField("OCTAVE",a),c=a.getNumberValue("VALUE"),d=b+12*(d-1),c=6E4*c/60;a.isStart=!0;a.timeFlag=1;100==b?Entry.hw.setDigitalPortValue(10,100):Entry.hw.setDigitalPortValue(10,d);if(100n?(l=Math.round(n-155),f=-l,g=0,Entry.dplay.Left_value=f):0==n&&(g=f=0,Entry.dplay.Left_value=0));"2"==m&&(c=6,e=11,0n?(l=Math.round(n-155),h=-l,k=0,Entry.dplay.Right_value=h):0==n&&(k=h=0,Entry.dplay.Right_value=h));"3"==m&&(b=3,d=5,c=6,e=11,0n?(l=Math.round(n-155),f=-l,g=0,h=-l,k=0,Entry.dplay.Left_value=f,Entry.dplay.Right_value=h):0==n&&(k=h=g=f=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(b,f),Entry.hw.setDigitalPortValue(d,g),Entry.hw.setDigitalPortValue(c,k),Entry.hw.setDigitalPortValue(e, -h),delete a.isStart,delete a.timeFlag,Entry.engine.isContinue=!1,a.callReturn()}else{a.isStart=!0;a.timeFlag=1;var q=setTimeout(function(){a.timeFlag=2;Entry.dplay.removeTimeout(q)},50);Entry.dplay.timeouts.push(q);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 d=b=0,c=0,e=0,f=0,f=0,f=a.getNumberValue("L_VALUE",a),f=Math.max(f,-100),f=Math.min(f,100);0f?(f=Math.round(f-155),b=-f,d=0,Entry.dplay.Left_value=b):0==f&&(d=b=0,Entry.dplay.Left_value= -0);f=a.getNumberValue("R_VALUE",a);f=Math.max(f,-100);f=Math.min(f,100);0f?(f=Math.round(f-155),c=-f,e=0,Entry.dplay.Right_value=c):0==f&&(e=c=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,b),Entry.hw.setDigitalPortValue(5,d), -Entry.hw.setDigitalPortValue(6,e),Entry.hw.setDigitalPortValue(11,c),delete a.isStart,delete a.timeFlag,Entry.engine.isContinue=!1,a.callReturn()}else{a.isStart=!0;a.timeFlag=1;var g=setTimeout(function(){a.timeFlag=2;Entry.dplay.removeTimeout(g)},50);Entry.dplay.timeouts.push(g);return a}},syntax:{js:[],py:["Dplay.robot_speed_sel(%1, %2)"]}},dplay_robot_stop:{color:"#00979D",fontColor:"#FFF",skeleton:"basic",statements:[],template:"\ub85c\ubd07\uc744 \uc815\uc9c0\ud558\uae30 %1",params:[{type:"Indicator", +params:["1"]},null,null],type:"dplay_Robot_run_sec"},paramsKeyMap:{VALUE:0,PORT:1},"class":"dplay_robot",isNotFor:["dplay"],func:function(b,a){var d=0,c=0,e=0,f=0,g=Entry.dplay.Left_value,h=Entry.dplay.Right_value,k=a.getField("PORT");if(a.isStart){if(1==a.timeFlag)return"1"==k?(d=0,c=g,e=h,f=0):"2"==k?(d=g,e=c=0,f=h):"3"==k?(d=0,c=g,f=e=0):"4"==k&&(c=d=0,e=h,f=0),Entry.hw.setDigitalPortValue(3,d),Entry.hw.setDigitalPortValue(5,c),Entry.hw.setDigitalPortValue(6,e),Entry.hw.setDigitalPortValue(11, +f),a;delete a.isStart;delete a.timeFlag;Entry.engine.isContinue=!1;f=e=c=d=0;return a.callReturn()}a.isStart=!0;a.timeFlag=1;var d=1E3*a.getNumberValue("VALUE"),l=setTimeout(function(){a.timeFlag=0;Entry.dplay.removeTimeout(l)},d);Entry.dplay.timeouts.push(l);return a},syntax:{js:[],py:["Dplay.robot_run_sec(%1, %2)"]}},dplay_robot_speed_sel:{color:"#00979D",fontColor:"#FFF",skeleton:"basic",statements:[],template:"%1 \ubc14\ud034 \uc18d\ub3c4\ub97c %2(\uc73c)\ub85c \uc815\ud558\uae30 %3",params:[{type:"Dropdown", +options:[["\uc67c\ucabd","1"],["\uc624\ub978\ucabd","2"],["\uc591\ucabd","3"]],value:"1",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,{type:"text",params:["100"]},null],type:"dplay_robot_speed_sel"},paramsKeyMap:{PORT:0,VALUE:1},"class":"dplay_robot",isNotFor:["dplay"],func:function(b,a){var d=0,c=0,e=0,f=0,g=0,h=0,k=0,l=0,m=0,n=a.getField("PORT"),q=a.getNumberValue("VALUE", +a),q=Math.max(q,-100),q=Math.min(q,100);"1"==n&&(d=3,c=5,0q?(m=Math.round(q-155),g=-m,h=0,Entry.dplay.Left_value=g):0==q&&(h=g=0,Entry.dplay.Left_value=0));"2"==n&&(e=6,f=11,0q?(m=Math.round(q-155),k=-m,l=0,Entry.dplay.Right_value=k):0==q&&(l=k=0,Entry.dplay.Right_value=k));"3"==n&&(d=3,c=5,e=6,f=11,0q?(m=Math.round(q-155),g=-m,h=0,k=-m,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(d,g),Entry.hw.setDigitalPortValue(c,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 d=0,c=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);0g?(g=Math.round(g-155),d=-g,c=0,Entry.dplay.Left_value=d):0==g&&(c=d=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,d),Entry.hw.setDigitalPortValue(5,c), +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}},syntax:{js:[],py:["Dplay.robot_speed_sel(%1, %2)"]}},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()},syntax:{js:[],py:["Dplay.robot_stop()"]}},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",syntax:{js:[],py:["Nemoino.sensor_value(%1)"]}},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",syntax:{js:[],py:["Nemoino.digital_value(%1)"]}},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",syntax:{js:[],py:["Nemoino.toggle_led(%1)"]}},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",syntax:{js:[],py:["Nemoino.toggle_pwm(%1, %2)"]}},nemoino_convert_scale:{parent:"arduino_convert_scale",isNotFor:["nemoino"],def:{params:[{type:"arduino_get_number_sensor_value",params:[{type:"arduino_get_sensor_number"}]}, @@ -2437,60 +2306,60 @@ Ntry.STATIC.SPACE_SHIP).direction=Ntry.STATIC.EAST;var d=Ntry.entityManager.getC return a.callReturn()}a.isStart=!0;a.isAction=!0;Ntry.dispatchEvent("gridChange",function(){a.isAction=!1});Ntry.entityManager.getComponent(b.id,Ntry.STATIC.SPACE_SHIP).direction=Ntry.STATIC.NORTH;var d=Ntry.entityManager.getComponent(b.id,Ntry.STATIC.GRID);Ntry.entityManager.addComponent(b.id,{type:Ntry.STATIC.ANIMATE,animateType:Ntry.STATIC.ROTATE_TO,animateValue:-45});d.x++;d.y--;return a}},ai_move_down:{skeleton:"basic",mode:"maze",color:"#A751E3",syntax:["Scope","down"],params:[{type:"Image", img:"/img/assets/week/blocks/ai_move_down.png",size:24}],func:function(b,a){if(a.isStart){if(a.isAction)return a;delete a.isAction;delete a.isStart;return a.callReturn()}a.isStart=!0;a.isAction=!0;Ntry.dispatchEvent("gridChange",function(){a.isAction=!1});Ntry.entityManager.getComponent(b.id,Ntry.STATIC.SPACE_SHIP).direction=Ntry.STATIC.SOUTH;var d=Ntry.entityManager.getComponent(b.id,Ntry.STATIC.GRID);Ntry.entityManager.addComponent(b.id,{type:Ntry.STATIC.ANIMATE,animateType:Ntry.STATIC.ROTATE_TO, animateValue:45});d.x++;d.y++;return a}},ai_repeat_until_reach:{skeleton:"basic_loop",mode:"maze",color:"#498DEB",syntax:["BasicWhile","true"],statements:[{accept:"basic"}],params:[{type:"Image",img:"/img/assets/week/blocks/for.png",size:24}],func:function(){var b=this.block.statements[0];if(0!==b.getBlocks().length)return this.executor.stepInto(b)}},ai_if_else_1:{skeleton:"basic_double_loop",mode:"maze",color:"#498DEB",syntax:["BasicIf","front == 'stone'"],statements:[{accept:"basic"},{accept:"basic"}], -params:[{type:"Image",img:"/img/assets/ntry/bitmap/ai/obstacle_1.png",size:24},{type:"Image",img:"/img/assets/week/blocks/for.png",size:24},{type:"LineBreak"}],func:function(b,a){if(a.isLooped)return delete a.isLooped,a.callReturn();b=Ntry.entityManager.getComponent(b.id,Ntry.STATIC.RADAR);var d=this.block.statements,c=1;a.isLooped=!0;b.center.type==Ntry.STATIC.AI_METEO&&1==b.center.distance&&(c=0);this.executor.stepInto(d[c]);return Entry.STATIC.BREAK}},ai_boolean_distance:{skeleton:"basic_boolean_field", -mode:"maze",color:"#2fc9f0",fontColor:"#fff",syntax:["Scope","radar_%1 %2 %3#"],params:[{type:"Dropdown",options:[[Lang.Menus.ai_above,"UP"],[Lang.Menus.ai_front,"RIGHT"],[Lang.Menus.ai_under,"DOWN"]],value:"RIGHT",fontSize:11},{type:"Dropdown",options:[[">","BIGGER"],[">=","BIGGER_EQUAL"],["=","EQUAL"],["<","SMALLER"],["<=","SMALLER_EQUAL"]],value:"BIGGER",fontSize:11},{type:"Block",accept:"string"}],func:function(b,a){b=Ntry.entityManager.getComponent(b.id,Ntry.STATIC.RADAR);var d=this.block.params; -a=d[0];var d=d[1],c=this.getParam(2),e;switch(a){case "UP":e=b.left;break;case "RIGHT":e=b.center;break;case "DOWN":e=b.right}e=e.type==Ntry.STATIC.AI_GOAL?Number.MAX_VALUE:e.distance;switch(d){case "BIGGER":return e>c;case "BIGGER_EQUAL":return e>=c;case "EQUAL":return e==c;case "SMALLER":return e","BIGGER"],[">=","BIGGER_EQUAL"],["=","EQUAL"],["<","SMALLER"],["<=","SMALLER_EQUAL"]],value:"BIGGER",fontSize:11},{type:"Block",accept:"string"}],func:function(b,a){var d=Ntry.entityManager.getComponent(b.id,Ntry.STATIC.RADAR),c=this.block.params, +e=c[0],c=c[1],f=this.getParam(2),g;switch(e){case "UP":g=d.left;break;case "RIGHT":g=d.center;break;case "DOWN":g=d.right}g=g.type==Ntry.STATIC.AI_GOAL?Number.MAX_VALUE:g.distance;switch(c){case "BIGGER":return g>f;case "BIGGER_EQUAL":return g>=f;case "EQUAL":return g==f;case "SMALLER":return g=d?d=0:720<=d&&(d=720);var c=a.getStringField("DIRECTION",a);Entry.hw.sendQueue[b]={id:Math.floor(1E5*Math.random(),0),type:Entry.EV3.motorMovementTypes.Degrees,degree:d,power:"CW"==c?50:-50};return a.callReturn()}},ev3_motor_power:{color:"#00979D",skeleton:"basic",statements:[],template:"%1 \uc758 \uac12\uc744 %2 \uc73c\ub85c \ucd9c\ub825 %3",params:[{type:"Dropdown",options:[["A","A"],["B","B"],["C","C"],["D","D"]],value:"A",fontSize:11},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png", -size:12}],events:{},def:{params:[null,{type:"number",params:["50"]}],type:"ev3_motor_power"},paramsKeyMap:{PORT:0,VALUE:1},"class":"ev3_output",isNotFor:["EV3"],func:function(b,a){b=a.getStringField("PORT",a);var d=a.getValue("VALUE",a);Entry.hw.sendQueue[b]={id:Math.floor(1E5*Math.random(),0),type:Entry.EV3.motorMovementTypes.Power,power:d};return a.callReturn()}},ev3_motor_power_on_time:{color:"#00979D",skeleton:"basic",statements:[],template:"%1 \uc758 \uac12\uc744 %2 \ucd08 \ub3d9\uc548 %3 \uc73c\ub85c \ucd9c\ub825 %4", -params:[{type:"Dropdown",options:[["A","A"],["B","B"],["C","C"],["D","D"]],value:"A",fontSize:11},{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,{type:"number",params:["2"]},{type:"number",params:["50"]}],type:"ev3_motor_power_on_time"},paramsKeyMap:{PORT:0,TIME:1,VALUE:2},"class":"ev3_output",isNotFor:["EV3"],func:function(b,a){b=a.getStringField("PORT",a);if(a.isStart){if(1==a.timeFlag)return a; -delete a.isStart;delete a.timeFlag;Entry.engine.isContinue=!1;Entry.hw.sendQueue[b]={id:Math.floor(1E5*Math.random(),0),type:Entry.EV3.motorMovementTypes.Power,power:0};return a.callReturn()}var d=a.getValue("TIME",a),c=a.getValue("VALUE",a);a.isStart=!0;a.timeFlag=1;Entry.hw.sendQueue[b]={id:Math.floor(1E5*Math.random(),0),type:Entry.EV3.motorMovementTypes.Power,power:c};var e=setTimeout(function(){a.timeFlag=0;Entry.EV3.removeTimeout(e)},1E3*d);Entry.EV3.timeouts.push(e);return a}},ev3_touch_sensor:{color:"#00979D", -fontColor:"#fff",skeleton:"basic_boolean_field",statements:[],template:"%1 \uc758 \ud130\uce58\uc13c\uc11c\uac00 \uc791\ub3d9\ub418\uc5c8\ub294\uac00?",params:[{type:"Dropdown",options:[["1","1"],["2","2"],["3","3"],["4","4"]],value:"1",fontSize:11}],events:{},def:{params:[null],type:"ev3_touch_sensor"},paramsKeyMap:{PORT:0},"class":"ev3_sensor",isNotFor:["EV3"],func:function(b,a){a.getStringField("PORT",a);b=Entry.hw.getDigitalPortValue(a.getNumberField("PORT",a));a=!1;b.type==Entry.EV3.deviceTypes.Touch&& -1<=Number(b.siValue)&&(a=!0);return a}},roduino_on_block:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],params:[{type:"Block",accept:"string"}],events:{},def:{params:[null],type:"roduino_on_block"},paramsKeyMap:{},"class":"roduino_value",isNotFor:["roborobo_roduino"],func:function(b,a){return"1"}},roduino_off_block:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],params:[{type:"Block",accept:"string"}],events:{},def:{params:[null],type:"roduino_off_block"}, +params:[{type:"Block",accept:"boolean"},{type:"Indicator",img:"block_icon/if.png",size:12},{type:"LineBreak"}],func:function(b,a){if(a.isCondition)return delete a.isCondition,a.callReturn();var d=this.getParam(0);a.isCondition=!0;return d?this.executor.stepInto(this.block.statements[0]):this.executor.stepInto(this.block.statements[1])},syntax:["BasicIf","true"]},ev3_color_sensor:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],template:"%1 \uc758 %2 \uac12",params:[{type:"Dropdown", +options:[["1","1"],["2","2"],["3","3"],["4","4"]],value:"1",fontSize:11},{type:"Dropdown",options:[["RGB","RGB"],["R","R"],["G","G"],["B","B"]],value:"RGB",fontSize:11}],events:{},def:{params:[null,null],type:"ev3_color_sensor"},paramsKeyMap:{PORT:0,RGB:1},"class":"ev3_sensor",isNotFor:["EV3"],func:function(b,a){a.getStringField("PORT",a);var d=a.getStringField("RGB",a),c=Entry.hw.getDigitalPortValue(a.getNumberField("PORT",a)),e="";if(c.type==Entry.EV3.deviceTypes.Color)if(0==c.siValue)e="";else switch(d){case "RGB":e= +Entry.EV3.colorSensorValue[c.siValue];break;case "R":e=Entry.EV3.colorSensorValue[c.siValue].substring(0,2);break;case "G":e=Entry.EV3.colorSensorValue[c.siValue].substring(2,4);break;case "B":e=Entry.EV3.colorSensorValue[c.siValue].substring(4,6)}else e="\uceec\ub7ec \uc13c\uc11c \uc544\ub2d8";return e}},ev3_get_sensor_value:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],template:"%1 \uc758 \uac12",params:[{type:"Dropdown",options:[["1","1"],["2","2"],["3","3"],["4", +"4"]],value:"1",fontSize:11}],events:{},def:{params:[null],type:"ev3_get_sensor_value"},paramsKeyMap:{PORT:0},"class":"ev3_sensor",isNotFor:["EV3"],func:function(b,a){a.getStringField("PORT",a);var d=Entry.hw.getDigitalPortValue(a.getNumberField("PORT",a)),c;$.isPlainObject(d)&&(c=d.siValue||0);return c}},ev3_motor_degrees:{color:"#00979D",skeleton:"basic",statements:[],template:"%1 \uc758 \uac12\uc744 %2 \uc73c\ub85c %3 \ub3c4 \ub9cc\ud07c \ud68c\uc804 %4",params:[{type:"Dropdown",options:[["A", +"A"],["B","B"],["C","C"],["D","D"]],value:"A",fontSize:11},{type:"Dropdown",options:[["\uc2dc\uacc4\ubc29\ud5a5","CW"],["\ubc18\uc2dc\uacc4\ubc29\ud5a5","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:"angle"}],type:"ev3_motor_degrees"},paramsKeyMap:{PORT:0,DIRECTION:1,DEGREE:2},"class":"ev3_output",isNotFor:["EV3"],func:function(b,a){var d=a.getStringField("PORT",a),c=a.getValue("DEGREE", +a);0>=c?c=0:720<=c&&(c=720);var e=a.getStringField("DIRECTION",a);Entry.hw.sendQueue[d]={id:Math.floor(1E5*Math.random(),0),type:Entry.EV3.motorMovementTypes.Degrees,degree:c,power:"CW"==e?50:-50};return a.callReturn()}},ev3_motor_power:{color:"#00979D",skeleton:"basic",statements:[],template:"%1 \uc758 \uac12\uc744 %2 \uc73c\ub85c \ucd9c\ub825 %3",params:[{type:"Dropdown",options:[["A","A"],["B","B"],["C","C"],["D","D"]],value:"A",fontSize:11},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png", +size:12}],events:{},def:{params:[null,{type:"number",params:["50"]}],type:"ev3_motor_power"},paramsKeyMap:{PORT:0,VALUE:1},"class":"ev3_output",isNotFor:["EV3"],func:function(b,a){var d=a.getStringField("PORT",a),c=a.getValue("VALUE",a);Entry.hw.sendQueue[d]={id:Math.floor(1E5*Math.random(),0),type:Entry.EV3.motorMovementTypes.Power,power:c};return a.callReturn()}},ev3_motor_power_on_time:{color:"#00979D",skeleton:"basic",statements:[],template:"%1 \uc758 \uac12\uc744 %2 \ucd08 \ub3d9\uc548 %3 \uc73c\ub85c \ucd9c\ub825 %4", +params:[{type:"Dropdown",options:[["A","A"],["B","B"],["C","C"],["D","D"]],value:"A",fontSize:11},{type:"Block",accept:"string"},{type:"Block",accept:"string"},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,{type:"number",params:["2"]},{type:"number",params:["50"]}],type:"ev3_motor_power_on_time"},paramsKeyMap:{PORT:0,TIME:1,VALUE:2},"class":"ev3_output",isNotFor:["EV3"],func:function(b,a){var d=a.getStringField("PORT",a);if(a.isStart){if(1==a.timeFlag)return a; +delete a.isStart;delete a.timeFlag;Entry.engine.isContinue=!1;Entry.hw.sendQueue[d]={id:Math.floor(1E5*Math.random(),0),type:Entry.EV3.motorMovementTypes.Power,power:0};return a.callReturn()}var c=a.getValue("TIME",a),e=a.getValue("VALUE",a);a.isStart=!0;a.timeFlag=1;Entry.hw.sendQueue[d]={id:Math.floor(1E5*Math.random(),0),type:Entry.EV3.motorMovementTypes.Power,power:e};var f=setTimeout(function(){a.timeFlag=0;Entry.EV3.removeTimeout(f)},1E3*c);Entry.EV3.timeouts.push(f);return a}},ev3_touch_sensor:{color:"#00979D", +fontColor:"#fff",skeleton:"basic_boolean_field",statements:[],template:"%1 \uc758 \ud130\uce58\uc13c\uc11c\uac00 \uc791\ub3d9\ub418\uc5c8\ub294\uac00?",params:[{type:"Dropdown",options:[["1","1"],["2","2"],["3","3"],["4","4"]],value:"1",fontSize:11}],events:{},def:{params:[null],type:"ev3_touch_sensor"},paramsKeyMap:{PORT:0},"class":"ev3_sensor",isNotFor:["EV3"],func:function(b,a){a.getStringField("PORT",a);var d=Entry.hw.getDigitalPortValue(a.getNumberField("PORT",a)),c=!1;d.type==Entry.EV3.deviceTypes.Touch&& +1<=Number(d.siValue)&&(c=!0);return c}},roduino_on_block:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],params:[{type:"Block",accept:"string"}],events:{},def:{params:[null],type:"roduino_on_block"},paramsKeyMap:{},"class":"roduino_value",isNotFor:["roborobo_roduino"],func:function(b,a){return"1"}},roduino_off_block:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],params:[{type:"Block",accept:"string"}],events:{},def:{params:[null],type:"roduino_off_block"}, paramsKeyMap:{},"class":"roduino_value",isNotFor:["roborobo_roduino"],func:function(b,a){return"0"}},roduino_get_analog_number:{color:"#00979D",skeleton:"basic_string_field",statements:[],params:[{type:"Dropdown",options:[["0","0"],["1","1"],["2","2"],["3","3"],["4","4"],["5","5"]],value:"0",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW}],events:{},def:{params:[null]},paramsKeyMap:{PORT:0},func:function(b,a){return a.getStringField("PORT")}},roduino_get_port_number:{color:"#00979D",skeleton:"basic_string_field", statements:[],params:[{type:"Dropdown",options:[["2","2"],["3","3"],["4","4"],["5","5"],["6","6"],["7","7"],["8","8"]],value:"2",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW}],events:{},def:{params:[null]},paramsKeyMap:{PORT:0},func:function(b,a){return a.getStringField("PORT")}},roduino_get_analog_value:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],params:[{type:"Block",accept:"string"}],events:{},def:{params:[{type:"roduino_get_analog_number"}],type:"roduino_get_analog_value"}, -paramsKeyMap:{VALUE:0},"class":"roduino_value",isNotFor:["roborobo_roduino"],func:function(b,a){b=parseInt(a.getValue("VALUE",a));Entry.Roborobo_Roduino.setSendData([Entry.Roborobo_Roduino.INSTRUCTION.ANALOG_READ,b]);return Entry.hw.getAnalogPortValue(b)}},roduino_get_digital_value:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],params:[{type:"Block",accept:"string"}],events:{},def:{params:[{type:"roduino_get_port_number"}],type:"roduino_get_digital_value"},paramsKeyMap:{VALUE:0}, -"class":"roduino_value",isNotFor:["roborobo_roduino"],func:function(b,a){b=a.getNumberValue("VALUE",a);Entry.Roborobo_Roduino.setSendData([Entry.Roborobo_Roduino.INSTRUCTION.DIGITAL_READ,b]);return Entry.hw.portData[b-2]}},roduino_get_color:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.roborobo_color_red,"red"],[Lang.Blocks.roborobo_color_green,"green"],[Lang.Blocks.roborobo_color_blue,"blue"],[Lang.Blocks.roborobo_color_yellow, -"yellow"]],value:"red",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW}],events:{},def:{params:[null],type:"roduino_get_color"},paramsKeyMap:{VALUE:0},"class":"roduino_value",isNotFor:["roborobo_roduino"],func:function(b,a){b=0;a=a.getField("VALUE",a);var d=[Entry.hw.portData[Entry.Roborobo_Roduino.ColorPin[0]-2],Entry.hw.portData[Entry.Roborobo_Roduino.ColorPin[1]-2],Entry.hw.portData[Entry.Roborobo_Roduino.ColorPin[2]-2]];switch(a){case "red":1==d[0]&&0==d[1]&&0==d[2]&&(b=1);break;case "green":0== -d[0]&&1==d[1]&&0==d[2]&&(b=1);break;case "blue":0==d[0]&&0==d[1]&&1==d[2]&&(b=1);break;case "yellow":1==d[0]&&1==d[1]&&1==d[2]&&(b=1)}return b}},roduino_set_digital:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Dropdown",options:[[Lang.Blocks.roborobo_on,"on"],[Lang.Blocks.roborobo_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:"roduino_get_port_number"}, -null,null],type:"roduino_set_digital"},paramsKeyMap:{VALUE:0,OPERATOR:1},"class":"roduino_set",isNotFor:["roborobo_roduino"],func:function(b,a){b=a.getNumberValue("VALUE",a);var d=a.getField("OPERATOR");Entry.Roborobo_Roduino.setSendData([Entry.Roborobo_Roduino.INSTRUCTION.DIGITAL_WRITE,b,"on"==d?1:0]);return a.callReturn()}},roduino_motor:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.roborobo_motor1,"motor1"],[Lang.Blocks.roborobo_motor2,"motor2"]], -value:"motor1",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW},{type:"Dropdown",options:[[Lang.Blocks.roborobo_motor_CW,"cw"],[Lang.Blocks.roborobo_motor_CCW,"ccw"],[Lang.Blocks.roborobo_motor_stop,"stop"]],value:"cw",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,null,null],type:"roduino_motor"},paramsKeyMap:{MODE:0,OPERATOR:1},"class":"roduino_set",isNotFor:["roborobo_roduino"],func:function(b,a){pin2= -0;var d;value2=0;b=a.getField("MODE");d=a.getField("OPERATOR");"motor1"==b?(b=9,pin2=10):(b=11,pin2=12);"cw"==d?(d=1,value2=0):"ccw"==d?(d=0,value2=1):value2=d=0;Entry.Roborobo_Roduino.setSendData([Entry.Roborobo_Roduino.INSTRUCTION.MOTOR,b,d,pin2,value2]);return a.callReturn()}},roduino_set_color_pin:{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:"number",params:["2"]},{type:"number",params:["3"]},{type:"number",params:["4"]},null],type:"roduino_set_color_pin"},paramsKeyMap:{RED:0,GREEN:1,BLUE:2},"class":"roduino_set",isNotFor:["roborobo_roduino"],func:function(b,a){b=a.getNumberValue("RED",a);var d=a.getNumberValue("GREEN",a),c=a.getNumberValue("BLUE",a);Entry.Roborobo_Roduino.ColorPin=[b,d,c];Entry.Roborobo_Roduino.setSendData([Entry.Roborobo_Roduino.INSTRUCTION.COLOR,b,d,c]);return a.callReturn()}}, +paramsKeyMap:{VALUE:0},"class":"roduino_value",isNotFor:["roborobo_roduino"],func:function(b,a){var d=parseInt(a.getValue("VALUE",a));Entry.Roborobo_Roduino.setSendData([Entry.Roborobo_Roduino.INSTRUCTION.ANALOG_READ,d]);return Entry.hw.getAnalogPortValue(d)}},roduino_get_digital_value:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],params:[{type:"Block",accept:"string"}],events:{},def:{params:[{type:"roduino_get_port_number"}],type:"roduino_get_digital_value"},paramsKeyMap:{VALUE:0}, +"class":"roduino_value",isNotFor:["roborobo_roduino"],func:function(b,a){var d=a.getNumberValue("VALUE",a);Entry.Roborobo_Roduino.setSendData([Entry.Roborobo_Roduino.INSTRUCTION.DIGITAL_READ,d]);return Entry.hw.portData[d-2]}},roduino_get_color:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.roborobo_color_red,"red"],[Lang.Blocks.roborobo_color_green,"green"],[Lang.Blocks.roborobo_color_blue,"blue"],[Lang.Blocks.roborobo_color_yellow, +"yellow"]],value:"red",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW}],events:{},def:{params:[null],type:"roduino_get_color"},paramsKeyMap:{VALUE:0},"class":"roduino_value",isNotFor:["roborobo_roduino"],func:function(b,a){var d=0,c=a.getField("VALUE",a),e=[Entry.hw.portData[Entry.Roborobo_Roduino.ColorPin[0]-2],Entry.hw.portData[Entry.Roborobo_Roduino.ColorPin[1]-2],Entry.hw.portData[Entry.Roborobo_Roduino.ColorPin[2]-2]];switch(c){case "red":1==e[0]&&0==e[1]&&0==e[2]&&(d=1);break;case "green":0== +e[0]&&1==e[1]&&0==e[2]&&(d=1);break;case "blue":0==e[0]&&0==e[1]&&1==e[2]&&(d=1);break;case "yellow":1==e[0]&&1==e[1]&&1==e[2]&&(d=1)}return d}},roduino_set_digital:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Dropdown",options:[[Lang.Blocks.roborobo_on,"on"],[Lang.Blocks.roborobo_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:"roduino_get_port_number"}, +null,null],type:"roduino_set_digital"},paramsKeyMap:{VALUE:0,OPERATOR:1},"class":"roduino_set",isNotFor:["roborobo_roduino"],func:function(b,a){var d=a.getNumberValue("VALUE",a),c=a.getField("OPERATOR");Entry.Roborobo_Roduino.setSendData([Entry.Roborobo_Roduino.INSTRUCTION.DIGITAL_WRITE,d,"on"==c?1:0]);return a.callReturn()}},roduino_motor:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.roborobo_motor1,"motor1"],[Lang.Blocks.roborobo_motor2,"motor2"]], +value:"motor1",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW},{type:"Dropdown",options:[[Lang.Blocks.roborobo_motor_CW,"cw"],[Lang.Blocks.roborobo_motor_CCW,"ccw"],[Lang.Blocks.roborobo_motor_stop,"stop"]],value:"cw",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[null,null,null],type:"roduino_motor"},paramsKeyMap:{MODE:0,OPERATOR:1},"class":"roduino_set",isNotFor:["roborobo_roduino"],func:function(b,a){var d= +pin2=0,c=value2=0,d=a.getField("MODE"),c=a.getField("OPERATOR");"motor1"==d?(d=9,pin2=10):(d=11,pin2=12);"cw"==c?(c=1,value2=0):"ccw"==c?(c=0,value2=1):value2=c=0;Entry.Roborobo_Roduino.setSendData([Entry.Roborobo_Roduino.INSTRUCTION.MOTOR,d,c,pin2,value2]);return a.callReturn()}},roduino_set_color_pin:{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:"number",params:["2"]},{type:"number",params:["3"]},{type:"number",params:["4"]},null],type:"roduino_set_color_pin"},paramsKeyMap:{RED:0,GREEN:1,BLUE:2},"class":"roduino_set",isNotFor:["roborobo_roduino"],func:function(b,a){var d=a.getNumberValue("RED",a),c=a.getNumberValue("GREEN",a),e=a.getNumberValue("BLUE",a);Entry.Roborobo_Roduino.ColorPin=[d,c,e];Entry.Roborobo_Roduino.setSendData([Entry.Roborobo_Roduino.INSTRUCTION.COLOR,d,c,e]);return a.callReturn()}}, schoolkit_on_block:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],params:[{type:"Block",accept:"string"}],events:{},def:{params:[null],type:"schoolkit_on_block"},paramsKeyMap:{},"class":"schoolkit_value",isNotFor:["roborobo_schoolkit"],func:function(b,a){return"1"}},schoolkit_off_block:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],params:[{type:"Block",accept:"string"}],events:{},def:{params:[null],type:"schoolkit_off_block"},paramsKeyMap:{}, "class":"schoolkit_value",isNotFor:["roborobo_schoolkit"],func:function(b,a){return"0"}},schoolkit_get_out_port_number:{color:"#00979D",skeleton:"basic_string_field",statements:[],params:[{type:"Dropdown",options:[["OUT1",2],["OUT2",3],["OUT3",4],["OUT4",5],["OUT5",6]],value:2,fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW}],events:{},def:{params:[null]},paramsKeyMap:{PORT:0},func:function(b,a){return a.getNumberField("PORT")}},schoolkit_get_in_port_number:{color:"#00979D",skeleton:"basic_string_field", statements:[],params:[{type:"Dropdown",options:[["IN1",7],["IN2",8],["IN3",9],["IN4",10],["IN5",11],["IN6",12],["IN7",13]],value:7,fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW}],events:{},def:{params:[null]},paramsKeyMap:{PORT:0},func:function(b,a){return a.getNumberField("PORT")}},schoolkit_set_output:{color:"#00979D",skeleton:"basic",statements:[],params:[{type:"Block",accept:"string"},{type:"Dropdown",options:[[Lang.Blocks.roborobo_on,"on"],[Lang.Blocks.roborobo_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:"schoolkit_get_out_port_number"},null,null],type:"schoolkit_set_output"},paramsKeyMap:{VALUE:0,OPERATOR:1},"class":"schoolkit_set",isNotFor:["roborobo_schoolkit"],func:function(b,a){b=a.getNumberValue("VALUE",a);var d=a.getField("OPERATOR");Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.DIGITAL_WRITE,b,"on"==d?1:0]);return a.callReturn()}},schoolkit_get_input_value:{color:"#00979D", -fontColor:"#fff",skeleton:"basic_string_field",statements:[],params:[{type:"Block",accept:"string"}],events:{},def:{params:[{type:"schoolkit_get_in_port_number"}],type:"schoolkit_get_input_value"},paramsKeyMap:{VALUE:0},"class":"schoolkit_value",isNotFor:["roborobo_schoolkit"],func:function(b,a){b=a.getNumberValue("VALUE",a);Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.DIGITAL_READ,b]);return Entry.hw.portData[b-7]}},schoolkit_motor:{color:"#00979D",skeleton:"basic", +arrowColor:EntryStatic.ARROW_COLOR_HW},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{},def:{params:[{type:"schoolkit_get_out_port_number"},null,null],type:"schoolkit_set_output"},paramsKeyMap:{VALUE:0,OPERATOR:1},"class":"schoolkit_set",isNotFor:["roborobo_schoolkit"],func:function(b,a){var d=a.getNumberValue("VALUE",a),c=a.getField("OPERATOR");Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.DIGITAL_WRITE,d,"on"==c?1:0]);return a.callReturn()}},schoolkit_get_input_value:{color:"#00979D", +fontColor:"#fff",skeleton:"basic_string_field",statements:[],params:[{type:"Block",accept:"string"}],events:{},def:{params:[{type:"schoolkit_get_in_port_number"}],type:"schoolkit_get_input_value"},paramsKeyMap:{VALUE:0},"class":"schoolkit_value",isNotFor:["roborobo_schoolkit"],func:function(b,a){var d=a.getNumberValue("VALUE",a);Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.DIGITAL_READ,d]);return Entry.hw.portData[d-7]}},schoolkit_motor:{color:"#00979D",skeleton:"basic", statements:[],params:[{type:"Dropdown",options:[[Lang.Blocks.roborobo_motor1,"motor1"],[Lang.Blocks.roborobo_motor2,"motor2"]],value:"motor1",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW},{type:"Block",accept:"string"},{type:"Dropdown",options:[[Lang.Blocks.roborobo_motor_CW,"cw"],[Lang.Blocks.roborobo_motor_CCW,"ccw"],[Lang.Blocks.roborobo_motor_stop,"stop"]],value:"cw",fontSize:11,arrowColor:EntryStatic.ARROW_COLOR_HW},{type:"Indicator",img:"block_icon/hardware_03.png",size:12}],events:{}, -def:{params:[null,{type:"number",params:["0"]},null,null],type:"schoolkit_motor"},paramsKeyMap:{MODE:0,VALUE:1,OPERATOR:2},"class":"schoolkit_set",isNotFor:["roborobo_schoolkit"],func:function(b,a){var d;d=a.getField("MODE");b=a.getField("OPERATOR");var c=a.getNumberValue("VALUE");d="motor1"==d?7:8;255c&&(c=0);"cw"==b?Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.MOTOR,1,d,c]):"ccw"==b?Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.MOTOR, -2,d,c]):"stop"==b&&Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.MOTOR,0,d,c]);return a.callReturn()}},schoolkit_set_servo_value:{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:"schoolkit_get_out_port_number"},{type:"number",params:["0"]},null],type:"schoolkit_set_servo_value"},paramsKeyMap:{PIN:0,VALUE:1},"class":"schoolkit_set", -isNotFor:["roborobo_schoolkit"],func:function(b,a){b=a.getNumberValue("PIN",a);var d=a.getNumberValue("VALUE");0>d?d=0:180b&& -(c=0);255b&&(d=2+d,b*=-1);b=Math.round(b/30);Entry.hw.setDigitalPortValue(14,128+(d<<5)+b);return a.callReturn()}},codestar_light:{color:"#00979D", +def:{params:[null,{type:"number",params:["0"]},null,null],type:"schoolkit_motor"},paramsKeyMap:{MODE:0,VALUE:1,OPERATOR:2},"class":"schoolkit_set",isNotFor:["roborobo_schoolkit"],func:function(b,a){var d=0,d=a.getField("MODE"),c=a.getField("OPERATOR"),e=a.getNumberValue("VALUE"),d="motor1"==d?7:8;255e&&(e=0);"cw"==c?Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.MOTOR,1,d,e]):"ccw"==c?Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.MOTOR, +2,d,e]):"stop"==c&&Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.MOTOR,0,d,e]);return a.callReturn()}},schoolkit_set_servo_value:{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:"schoolkit_get_out_port_number"},{type:"number",params:["0"]},null],type:"schoolkit_set_servo_value"},paramsKeyMap:{PIN:0,VALUE:1},"class":"schoolkit_set", +isNotFor:["roborobo_schoolkit"],func:function(b,a){var d=a.getNumberValue("PIN",a),c=a.getNumberValue("VALUE");0>c?c=0:180d&& +(e=0);255d&&(c=2+c,d*=-1);d=Math.round(d/30);Entry.hw.setDigitalPortValue(14,128+(c<<5)+d);return a.callReturn()}},codestar_light:{color:"#00979D", fontColor:"#fff",skeleton:"basic_string_field",statements:[],template:"\ubc1d\uae30\uc13c\uc11c",params:[],events:{},def:{params:[],type:"codestar_light"},paramsKeyMap:{},class:"codestar_input_sensor",isNotFor:["codestar"],func:function(b,a){return Entry.hw.getAnalogPortValue("6")}},codestar_button:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],template:"\ubc84\ud2bc",params:[],events:{},def:{params:[],type:"codestar_button"},paramsKeyMap:{},class:"codestar_input_sensor", -isNotFor:["codestar"],func:function(b,a){return Entry.hw.getDigitalPortValue("12")}},codestar_ir:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],template:"IR %1",params:[{type:"Dropdown",options:[["A0","0"],["A1","1"],["A4","4"],["A5","5"]]}],events:{},def:{params:["0"],type:"codestar_ir"},paramsKeyMap:{PORT:0},class:"codestar_input_sensor",isNotFor:["codestar"],func:function(b,a){b=a.getField("PORT");return Entry.hw.getAnalogPortValue(b)}},codestar_sonar:{color:"#00979D", +isNotFor:["codestar"],func:function(b,a){return Entry.hw.getDigitalPortValue("12")}},codestar_ir:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],template:"IR %1",params:[{type:"Dropdown",options:[["A0","0"],["A1","1"],["A4","4"],["A5","5"]]}],events:{},def:{params:["0"],type:"codestar_ir"},paramsKeyMap:{PORT:0},class:"codestar_input_sensor",isNotFor:["codestar"],func:function(b,a){var d=a.getField("PORT");return Entry.hw.getAnalogPortValue(d)}},codestar_sonar:{color:"#00979D", fontColor:"#fff",skeleton:"basic_string_field",statements:[],template:"\ucd08\uc74c\ud30c",params:[],events:{},def:{params:[],type:"codestar_sonar"},paramsKeyMap:{},class:"codestar_input_sensor",isNotFor:["codestar"],func:function(b,a){return Entry.hw.portData.sonar}},codestar_variable_R:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],template:"\uac00\ubcc0\uc800\ud56d %1",params:[{type:"Dropdown",options:[["A0","0"],["A1","1"],["A4","4"],["A5","5"]]}],events:{},def:{params:["1"], -type:"codestar_variable_R"},paramsKeyMap:{PORT:0},class:"codestar_input_sensor",isNotFor:["codestar"],func:function(b,a){b=a.getField("PORT");return Entry.hw.getAnalogPortValue(b)}},codestar_mic:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],template:"\ub9c8\uc774\ud06c",params:[],events:{},def:{params:[],type:"codestar_mic"},paramsKeyMap:{},class:"codestar_input_sensor",isNotFor:["codestar"],func:function(b,a){return Entry.hw.getAnalogPortValue("2")}},codestar_temperature:{color:"#00979D", +type:"codestar_variable_R"},paramsKeyMap:{PORT:0},class:"codestar_input_sensor",isNotFor:["codestar"],func:function(b,a){var d=a.getField("PORT");return Entry.hw.getAnalogPortValue(d)}},codestar_mic:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],template:"\ub9c8\uc774\ud06c",params:[],events:{},def:{params:[],type:"codestar_mic"},paramsKeyMap:{},class:"codestar_input_sensor",isNotFor:["codestar"],func:function(b,a){return Entry.hw.getAnalogPortValue("2")}},codestar_temperature:{color:"#00979D", fontColor:"#fff",skeleton:"basic_string_field",statements:[],template:"\uc628\ub3c4",params:[],events:{},def:{params:[],type:"codestar_temperature"},paramsKeyMap:{},class:"codestar_input_sensor",isNotFor:["codestar"],func:function(b,a){return Entry.hw.portData.temperature}},codestar_gyroscope:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],template:"3\ucd95 \uc790\uc774\ub85c %1 \ucd95 %2",params:[{type:"Dropdown",options:[["x","x"],["y","y"],["z","z"]]},{type:"Indicator", size:11}],events:{},def:{params:["x",null],type:"codestar_gyroscope"},paramsKeyMap:{AXIS:0},class:"codestar_input_sensor",isNotFor:["codestar"],func:function(b,a){return Entry.hw.getAnalogPortValue("gyro_"+axis)}},codestar_geomagnetic:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],template:"3\ucd95 \uc9c0\uc790\uae30 %1 \ucd95 %2",params:[{type:"Dropdown",options:[["x","x"],["y","y"],["z","z"]]},{type:"Indicator",size:11}],events:{},def:{params:["x",null],type:"codestar_geomagnetic"}, -paramsKeyMap:{AXIS:0},class:"codestar_input_sensor",isNotFor:["codestar"],func:function(b,a){b=a.getField("AXIS");return Entry.hw.getAnalogPortValue("geo_"+b)}},codestar_irR:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],template:"IR \ub9ac\ubaa8\ucf58",params:[],events:{},def:{params:[],type:"codestar_irR"},paramsKeyMap:{},class:"codestar_input_sensor",isNotFor:["codestar"],func:function(b,a){return Entry.hw.getDigitalPortValue("4")}},codestar_tilt:{color:"#00979D", +paramsKeyMap:{AXIS:0},class:"codestar_input_sensor",isNotFor:["codestar"],func:function(b,a){var d=a.getField("AXIS");return Entry.hw.getAnalogPortValue("geo_"+d)}},codestar_irR:{color:"#00979D",fontColor:"#fff",skeleton:"basic_string_field",statements:[],template:"IR \ub9ac\ubaa8\ucf58",params:[],events:{},def:{params:[],type:"codestar_irR"},paramsKeyMap:{},class:"codestar_input_sensor",isNotFor:["codestar"],func:function(b,a){return Entry.hw.getDigitalPortValue("4")}},codestar_tilt:{color:"#00979D", fontColor:"#fff",skeleton:"basic_string_field",statements:[],template:"\ud2f8\ud2b8",params:[],events:{},def:{params:[],type:"codestar_tilt"},paramsKeyMap:{},class:"codestar_input_sensor",isNotFor:["codestar"],func:function(b,a){return Entry.hw.getDigitalPortValue("6")}}};(function(){for(var b in Entry.block){var a=Entry.block[b];if(a.parent){var d=function(){};d.prototype=Entry.block[a.parent];var d=new d,c;for(c in a)d[c]=a[c];Entry.block[b]=d}}})();"object"==typeof exports&&(exports.block=Entry.block);Entry.BlockMenu=function(b,a,d,c){Entry.Model(this,!1);this._align=a||"CENTER";this.setAlign(this._align);this._scroll=void 0!==c?c:!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=d;this._generateView(d);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);d&&this._generateCategoryCodes(d);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))}; @@ -2504,14 +2373,14 @@ f+(h||0),e.y+g+(k||0),!1);this._boardBlockView.onMouseDown.call(this._boardBlock 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(a){var b=this.code.getThreads();this.code.mode="text";for(var c=0;cthis._bannedClass.indexOf(a)&& -this._bannedClass.push(a);this.align(b)};b.unbanClass=function(a,b){a=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 c=a[b];c.constructor==Entry.Code&&c.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;bthis._bannedClass.indexOf(a)&& +this._bannedClass.push(a);this.align(b)};b.unbanClass=function(a,b){var c=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 c=a[b];c.constructor==Entry.Code&&c.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;bEntry.BlockView.DRAG_RADIUS)e&&(clearTimeout(e),e=null),f.movable&&(f.isInBlockMenu?g.cloneToGlobal(a):(a=!1,f.dragMode!=Entry.DRAG_MODE_DRAG&&(f._toGlobalCoordinate(),f.dragMode=Entry.DRAG_MODE_DRAG,f.block.getThread().changeEvent.notify(),Entry.GlobalSvg.setView(f,d),a= @@ -2537,8 +2406,8 @@ b.vimBoardEvent(a,"dragOver");c=a.originalEvent&&a.originalEvent.touches?a.origi delete this.mouseDownCoordinate;delete f.dragInstance}a.stopPropagation&&a.stopPropagation();a.preventDefault&&a.preventDefault();var e=null,f=this;this._changeFill(!1);var g=this.getBoard();Entry.documentMousedown&&Entry.documentMousedown.notify(a);if(!this.readOnly&&!g.viewOnly){g.setSelectedBlock(this);this.dominate();if(0===a.button||a.originalEvent&&a.originalEvent.touches){var h=a.type,k;k=a.originalEvent&&a.originalEvent.touches?a.originalEvent.touches[0]:a;this.mouseDownCoordinate={x:k.pageX, y:k.pageY};var l=$(document);l.bind("mousemove.block touchmove.block",d);l.bind("mouseup.block touchend.block",c);this.dragInstance=new Entry.DragInstance({startX:k.pageX,startY:k.pageY,offsetX:k.pageX,offsetY:k.pageY,height:0,mode:!0});g.set({dragBlock:this});this.addDragging();this.dragMode=Entry.DRAG_MODE_MOUSEDOWN;"touchstart"===h&&(e=setTimeout(function(){e&&(e=null,c(),f._rightClick(a))},1E3))}else Entry.Utils.isRightButton(a)&&this._rightClick(a);g.workspace.getMode()===Entry.Workspace.MODE_VIMBOARD&& a&&(vimBoard=$(".entryVimBoard>.CodeMirror")[0],document.getElementsByClassName("CodeMirror")[0].dispatchEvent(Entry.Utils.createMouseEvent("dragStart",event)))}};b.vimBoardEvent=function(a,b,c){a&&(a=Entry.Utils.createMouseEvent(b,a),c&&(a.block=c),document.getElementsByClassName("CodeMirror")[0].dispatchEvent(a))};b.terminateDrag=function(a){var b=this.getBoard(),c=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(c===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=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=c, -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;c=this.originPos;h?(this.set({animating:!1}),createjs.Sound.play("entryMagneting"),this.bindPrev(h),e.insert(h)):(f=e.getThread().view.getParent(), +if(f===Entry.Workspace.MODE_VIMBOARD)b instanceof Entry.BlockMenu?(b.terminateDrag(),this.vimBoardEvent(a,"dragEnd",e)):b.clear();else if(c===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= +c,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;c=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(c.x,c.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 c in this.magnet)if(b="next"===c?this.getBoard().getNearestMagnet(this.x, this.y+this.getBelowHeight(),c):this.getBoard().getNearestMagnet(this.x,this.y,c))return a.setMagnetedBlock(b.view,c);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.svgGroup).unbind(".blockViewMousedown");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 c=this.block;a=c.events.viewDestroy;"workspace"==Entry.type&&a&&!this.isInBlockMenu&&a.forEach(function(a){Entry.Utils.isFunction(a)&&a(c)});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)); @@ -2551,20 +2420,45 @@ this.block.isReadOnly():void 0!==this._skeleton.readOnly?this._skeleton.readOnly 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;a\s+/g, +function(){if(this.visible){var a=this.block;requestAnimFrame(this._updateContents.bind(this));var b=a.params;if(b)for(var c=0;c\s+/g, ">").replace(/\s+(svgGroup)(defs)',h=this.svgGroup.getBoundingClientRect(),k=a?this.svgGroup:this.svgGroup.cloneNode(!0); -a=this._skeleton.box(this);var l=b?1:1.5,m=function(){var a=window.platform;return a&&"windows"===a.name.toLowerCase()&&"7"===a.version[0]?!0:!1}()?.9:.95;-1<=+-x/".split(""),u= -0;u(svgGroup)(defs)',h=this.svgGroup.getBoundingClientRect(),k=a?this.svgGroup:this.svgGroup.cloneNode(!0), +l=this._skeleton.box(this),m=b?1:1.5,n=function(){var a=window.platform;return a&&"windows"===a.name.toLowerCase()&&"7"===a.version[0]?!0:!1}()?.9:.95;-1<=+-x/".split(""),v=0;ve||c.splice(e,1)}};b.raiseEvent=function(a,b,c){a=this._eventMap[a];var e=[];if(void 0!==a){for(var f=0;fe||c.splice(e,1)};b.doDestroyThread=function(a,b){var c=this._data,e=c.indexOf(a);0>e||c.splice(e,1)};b.getThreads=function(){return this._data.map(function(a){return a})};b.toJSON=function(){for(var a=this.getThreads(),b=[],c=0,e=a.length;cb&&(c+="...");return c};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(Entry.ContextMenu.visible||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 c=b.workspace.selectedBlockView;if(!c||b!=c.getBoard())return!1;b=a.getSvgRoot();return b==c.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)};b.getFontSize=function(a){return a=a||this._blockView.getSkeleton().fontSize||12};b.getContentHeight=function(){return Entry.isMobile()?22:16}})(Entry.Field.prototype);Entry.FieldBlock=function(b,a,d,c,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=d;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(),c)}; +[];a.unshift(this._index);a.unshift(Entry.PARAM);return this._block.pointer(a)};b.getFontSize=function(a){return a=a||this._blockView.getSkeleton().fontSize||12};b.getContentHeight=function(){return Entry.isMobile()?22:16}})(Entry.Field.prototype);Entry.FieldAngle=function(b,a,d){this._block=a.block;this._blockView=a;this.box=new Entry.BoxModel;this.svgGroup=null;this.position=b.position;this._contents=b;this._index=d;b=this.getValue();this.setValue(this.modValue(void 0!==b?b:90));this._CONTENT_HEIGHT=this.getContentHeight();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":"11px"});this.textElement.textContent=this.getText();var a=this.getTextWidth(),b=this._CONTENT_HEIGHT,c=this.position&&this.position.y?this.position.y:0;this._header=this.svgGroup.elem("rect",{x:0,y:c-b/2,rx:3,ry:3,width:a,height:b,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:b})};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 touchstart",function(a){a.stopPropagation()});this.optionGroup.on("keyup",function(b){var d=b.keyCode||b.which;a.applyValue(b);-1< +[13,27].indexOf(d)&&a.destroyOption()});var b=this.getAbsolutePosFromDocument();b.y-=this.box.height/2;this.optionGroup.css({height:this._CONTENT_HEIGHT,left:b.x,top:b.y,width:a.box.width});this.svgOptionGroup=this.appendSvgOptionGroup();this.svgOptionGroup.elem("circle",{x:0,y:0,r:49,class:"entry-field-angle-circle"});$(this.svgOptionGroup).on("mousedown touchstart",function(b){b.stopPropagation();a._updateByCoord(b)});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+")"});$(this.svgOptionGroup).bind("mousemove touchmove",this._updateByCoord.bind(this));$(this.svgOptionGroup).bind("mouseup touchend",this.destroyOption.bind(this));this.updateGraph();this.optionGroup.focus();this.optionGroup.select()}; +b._updateByCoord=function(a){a.originalEvent&&a.originalEvent.touches&&(a=a.originalEvent.touches[0]);a=[a.clientX,a.clientY];var b=this.getAbsolutePosFromDocument();this.optionGroup.val(this.modValue(function(a,b){var d=b[0]-a[0],g=b[1]-a[1]-49-1,h=Math.atan(-g/d),h=Entry.toDegrees(h),h=90-h;0>d?h+=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",c).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:c});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,d,c,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=d;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(),c)}; 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 c=this.getValue();c&&!c.view&&(c.setThread(this),c.createView(a,b),c.getThread().view.setParent(this));this.updateValueBlock(c);this._blockView.getBoard().constructor!==Entry.Board&&this._valueBlock.view.removeControl()};b.align=function(a,b,c){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===c||c?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, @@ -2573,67 +2467,7 @@ Entry.Block||(a=void 0);this._destroyObservers();a=this._setValueBlock(a).view;a a?this:null};b.getNextBlock=function(){return null};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};b.dominate=function(){this._blockView.dominate()};b.isGlobal=function(){return!1};b.separate=function(a){this.getCode().createThread([a]);this.calcWH();this.changeEvent.notify()};b.getCode=function(){return this._block.thread.getCode()};b.cut=function(a){return this._valueBlock===a?[a]:null};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()};b.setParent= function(a){this._parent=a};b.getParent=function(){return this._parent};b._createBlockByType=function(a){this._block.getThread();var b=this._blockView.getBoard();a=new Entry.Block({type:a},this);var c=b.workspace,e;c&&(e=c.getMode());a.createView(b,e);return a};b.spliceBlock=function(){this.updateValueBlock()};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)};b.getThread=function(){return this};b.pointer=function(a){a.unshift(this._index);a.unshift(Entry.PARAM);return this._block.pointer(a)}})(Entry.FieldBlock.prototype);Entry.Scroller=function(b,a,d){this._horizontal=void 0===a?!0:a;this._vertical=void 0===d?!0:d;this.board=b;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(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 e(a){a.stopPropagation();a.preventDefault();a.originalEvent.touches&&(a=a.originalEvent.touches[0]);var c=b.dragInstance;b.scroll((a.pageX-c.offsetX)/b.hRatio,0);c.set({offsetX:a.pageX,offsetY:a.pageY})}function f(a){$(document).unbind(".scroll"); -delete b.dragInstance}if(0===a.button||a instanceof Touch){Entry.documentMousedown&&Entry.documentMousedown.notify(a);var g=$(document);g.bind("mousemove.scroll",e);g.bind("mouseup.scroll",f);g.bind("touchmove.scroll",e);g.bind("touchend.scroll",f);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 e(a){a.stopPropagation(); -a.preventDefault();a.originalEvent.touches&&(a=a.originalEvent.touches[0]);var c=b.dragInstance;b.scroll(0,(a.pageY-c.offsetY)/b.vRatio);c.set({offsetX:a.pageX,offsetY:a.pageY})}function f(a){$(document).unbind(".scroll");delete b.dragInstance}if(0===a.button||a instanceof Touch){Entry.documentMousedown&&Entry.documentMousedown.notify(a);var g=$(document);g.bind("mousemove.scroll",e);g.bind("mouseup.scroll",f);g.bind("touchmove.scroll",e);g.bind("touchend.scroll",f);b.dragInstance=new Entry.DragInstance({startX:a.pageX, -startY:a.pageY,offsetX:a.pageX,offsetY:a.pageY})}a.stopPropagation()})};b.updateScrollBar=function(a,b){this._horizontal&&(this.hX+=a*this.hRatio,this.hScrollbar.attr({x:this.hX}));this._vertical&&(this.vY+=b*this.vRatio,this.vScrollbar.attr({y:this.vY}))};b.scroll=function(a,b){if(this.board.code){var c=this.board.svgBlockGroup.getBoundingClientRect(),e=this.board.svgDom,f=c.left-this.board.offset().left,g=c.top-this.board.offset().top,h=c.height;a=Math.max(-c.width+Entry.BOARD_PADDING-f,a);b=Math.max(-h+ -Entry.BOARD_PADDING-g,b);a=Math.min(e.width()-Entry.BOARD_PADDING-f,a);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]+=b;this._scrollCommand("scrollBoard",this._diffs[0],this._diffs[1],!0)}};b._scroll=function(a,b){this.board.code.moveBy(a,b);this.updateScrollBar(a,b)};b.setVisible=function(a){a!=this.isVisible()&&(this._visible=a,this.svgGroup.attr({display:!0===a?"block":"none"}))};b.isVisible=function(){return this._visible}; -b.setOpacity=function(a){this._opacity!=a&&(this.hScrollbar.attr({opacity:a}),this.vScrollbar.attr({opacity:a}),this._opacity=a)};b.resizeScrollBar=function(){if(this._visible){var a=this.board,b=a.svgBlockGroup.getBoundingClientRect(),c=a.svgDom,e=c.width(),c=c.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);this.hX=(f-h)/(k-h)*(e-g-2*Entry.Scroller.RADIUS); -this.hScrollbar.attr({width:g,x:this.hX,y:c-2*Entry.Scroller.RADIUS});this.hRatio=(e-g-2*Entry.Scroller.RADIUS)/(k-h)}this._vertical&&(f=-b+Entry.BOARD_PADDING,g=c-Entry.BOARD_PADDING,b=(c+2*Entry.Scroller.RADIUS)*b/(g-f+b),this.vY=(a-f)/(g-f)*(c-b-2*Entry.Scroller.RADIUS),this.vScrollbar.attr({height:b,y:this.vY,x:e-2*Entry.Scroller.RADIUS}),this.vRatio=(c-b-2*Entry.Scroller.RADIUS)/(g-f))}};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(b){Entry.Model(this,!1);this.changeEvent=new Entry.Event(this);this.createView(b);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;Entry.Board.OPTION_DOWNLOAD=3;Entry.Board.DRAG_RADIUS=5; -(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=b;this._svgId="play"+(new Date).getTime();this.workspace=a.workspace;this._activatedBlockView=null;this.wrapper=Entry.Dom("div",{parent:b,class:"entryBoardWrapper"});this.svgDom=Entry.Dom($(''), -{parent:this.wrapper});this.visible=!0;var c=this;this.svg=Entry.SVG(this._svgId);$(window).scroll(function(){c.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 c=b.scroller;c&&(a.mouseenter(function(a){c.setOpacity(1)}),a.mouseleave(function(a){c.setOpacity(0)}))};b.onMouseDown=function(a){function b(a){a.stopPropagation&&a.stopPropagation();a.preventDefault&&a.preventDefault();a=Entry.Utils.convertMouseEvent(a);var d=e.mouseDownCoordinate;Math.sqrt(Math.pow(a.pageX-d.x,2)+Math.pow(a.pageY-d.y,2))a&&(f=f+e+10,e=0,c=15);e=Math.max(e,k.width);l=c+15;h._moveTo(f,l,!1);c=c+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(),c=this._offset;this.relativeOffset={top:c.top-b,left:c.left-a};this.btnWrapper&&this.btnWrapper.attr({transform:"translate("+(c.width/2-65)+","+(c.height-200)+")"})};b.generateButtons=function(){var a=this,b=this.svgGroup.elem("g");this.btnWrapper=b;var c=b.elem("text",{x:27,y:33,class:"entryFunctionButtonText"});c.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()});$(c).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 c=this._getCodeBlocks(a,b);c.sort(function(a,b){return a.point-b.point});c.unshift({point:-Number.MAX_VALUE,blocks:[]});for(var e=1;eg.point&&(g.blocks.push(h),l++,g=c[l],g););delete f.startBlock}f.endPoint=Number.MAX_VALUE; -c[e-1].endPoint=f.point}this._magnetMap[b]=c}};b._getCodeBlocks=function(a,b){a=a.getThreads();var c=[],e;switch(b){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;fc.endPoint)f=h+1;else{e=c.blocks;for(f=0;fa||b.splice(a,1))};b.raiseEvent=function(a,b,c){a=this._eventMap[a];var e=[];if(void 0!==a){for(var f=0;fa||b.splice(a,1)};b.doDestroyThread=function(a,b){b=this._data;a=b.indexOf(a);0>a||b.splice(a,1)};b.getThreads=function(){return this._data.map(function(a){return a})};b.toJSON=function(){for(var a=this.getThreads(),b=[],c=0,e=a.length;cb;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+")"});$(this.svgOptionGroup).bind("mousemove touchmove",this._updateByCoord.bind(this));$(this.svgOptionGroup).bind("mouseup touchend",this.destroyOption.bind(this));this.updateGraph();this.optionGroup.focus();this.optionGroup.select()};b._updateByCoord= -function(a){a.originalEvent&&a.originalEvent.touches&&(a=a.originalEvent.touches[0]);a=[a.clientX,a.clientY];var b=this.getAbsolutePosFromDocument();this.optionGroup.val(this.modValue(function(a,b){var d=b[0]-a[0];a=b[1]-a[1]-49-1;b=Math.atan(-a/d);b=Entry.toDegrees(b);b=90-b;0>d?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",b).replace("%Y",c).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:c});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.FieldColor=function(b,a,d){this._block=a.block;this._blockView=a;this.box=new Entry.BoxModel;this.svgGroup=null;this._contents=b;this._index=d;this._position=b.position;this.key=b.key;this.setValue(this.getValue()||"#FF0000");this._CONTENT_HEIGHT=this.getContentHeight();this._CONTENT_WIDTH=this.getContentWidth();this.renderStart(a)};Entry.Utils.inherit(Entry.Field,Entry.FieldColor); +transform:"translate(0,12)"}):this._bg&&(this._bg.remove(),delete this._bg)};b.getThread=function(){return this};b.pointer=function(a){a.unshift(this._index);a.unshift(Entry.PARAM);return this._block.pointer(a)}})(Entry.FieldBlock.prototype);Entry.FieldColor=function(b,a,d){this._block=a.block;this._blockView=a;this.box=new Entry.BoxModel;this.svgGroup=null;this._contents=b;this._index=d;this._position=b.position;this.key=b.key;this.setValue(this.getValue()||"#FF0000");this._CONTENT_HEIGHT=this.getContentHeight();this._CONTENT_WIDTH=this.getContentWidth();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._CONTENT_HEIGHT,b=this._CONTENT_WIDTH,c=this._position,e;c?(e=c.x||0,c=c.y||0):(e=0,c=-a/2);this._header=this.svgGroup.elem("rect",{x:e,y:c,width:b,height:a,fill:this.getValue()});this._bindRenderOptions();this.box.set({x:e,y:c,width:b,height:a})};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 c=0;c'),{parent:this._container});this.svg=Entry.SVG("globalSvg");this.top=this.left=0;this._inited=!0}}; @@ -2678,25 +2512,192 @@ b.setView=function(a,b){if(a!=this._view&&!a.block.isReadOnly()&&a.movable)retur {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,c=a.getBoard(),e=c.workspace.blockMenu,f=e.offset().left,g=e.offset().top, h=e.visible?e.svgDom.width():0;return b.y>c.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({transform:"translate3d("+d+"px,"+f+"px, 0px)"});e._startX=c;e._startY=a;e.left=d;e.top=f}function c(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",c);f.bind("touchmove.block",b);f.bind("touchend.block",c);this._startX=a.pageX;this._startY=a.pageY}})(Entry.GlobalSvg);Entry.Mutator=function(){};(function(b){b.mutate=function(a,b){a=Entry.block[a];void 0===a.changeEvent&&(a.changeEvent=new Entry.Event);a.template=b.template;a.params=b.params;a.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= +var e=this;a.stopPropagation();a.preventDefault();var f=$(document);f.bind("mousemove.block",b);f.bind("mouseup.block",c);f.bind("touchmove.block",b);f.bind("touchend.block",c);this._startX=a.pageX;this._startY=a.pageY}})(Entry.GlobalSvg);Entry.Mutator=function(){};(function(b){b.mutate=function(a,b){var c=Entry.block[a];void 0===c.changeEvent&&(c.changeEvent=new Entry.Event);c.template=b.template;c.params=b.params;c.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(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})};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,c="LEFT"==this._align?20:this.svgDom.width()/2,e=0,f=a.length;e'), +{parent:this.wrapper});this.visible=!0;var c=this;this.svg=Entry.SVG(this._svgId);$(window).scroll(function(){c.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 c=b.scroller;c&&(a.mouseenter(function(a){c.setOpacity(1)}),a.mouseleave(function(a){c.setOpacity(0)}))};b.onMouseDown=function(a){function b(a){a.stopPropagation&&a.stopPropagation();a.preventDefault&&a.preventDefault();a=Entry.Utils.convertMouseEvent(a);var c=e.mouseDownCoordinate;Math.sqrt(Math.pow(a.pageX-c.x,2)+Math.pow(a.pageY-c.y,2))a&&(f=f+e+10,e=0,c=15);e=Math.max(e,k.width);l=c+15;h._moveTo(f,l,!1);c=c+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(),c=this._offset;this.relativeOffset={top:c.top-b,left:c.left-a};this.btnWrapper&&this.btnWrapper.attr({transform:"translate("+(c.width/2-65)+","+(c.height-200)+")"})};b.generateButtons=function(){var a=this,b=this.svgGroup.elem("g");this.btnWrapper=b;var c=b.elem("text",{x:27,y:33,class:"entryFunctionButtonText"});c.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()});$(c).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 c=this._getCodeBlocks(a,b);c.sort(function(a,b){return a.point-b.point});c.unshift({point:-Number.MAX_VALUE,blocks:[]});for(var e=1;eg.point&&(g.blocks.push(h),l++,g=c[l],g););delete f.startBlock}f.endPoint=Number.MAX_VALUE; +c[e-1].endPoint=f.point}this._magnetMap[b]=c}};b._getCodeBlocks=function(a,b){var c=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;gc.endPoint)f=h+1;else{e=c.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,c=this.trashcanTop;b=a?{translateX:15,translateY:-25, +rotateZ:30}:{translateX:0,translateY:0,rotateZ:0};$(c).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,c=b.firstChild;c?b.insertBefore(this.svgGroup,c):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,a){Entry.Vim.MAZE_MODE=1;Entry.Vim.WORKSPACE_MODE=2;Entry.Vim.TEXT_TYPE_JS=0;Entry.Vim.TEXT_TYPE_PY=1;Entry.Vim.PARSER_TYPE_JS_TO_BLOCK=0;Entry.Vim.PARSER_TYPE_PY_TO_BLOCK=1;Entry.Vim.PARSER_TYPE_BLOCK_TO_JS=2;Entry.Vim.PARSER_TYPE_BLOCK_TO_PY=3;Entry.Vim.PYTHON_IMPORT_ENTRY="import Entry";Entry.Vim.PYTHON_IMPORT_HW="import Arduino, Hamster, Albert, Bitbrick, Codeino, Dplay \n\t Neobot, Nemoino, Robotis, Sensorboard, Xbot from Hw";b="string"===typeof b?$("#"+b):$(b);if("DIV"!== b.prop("tagName"))return console.error("Dom is not div element");this.createDom(b);this._mode=Entry.Vim.WORKSPACE_MODE;this._parserType=Entry.Vim.PARSER_TYPE_BLOCK_TO_PY;this._parser=new Entry.Parser(this._mode,this._parserType,this.codeMirror);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 c(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,indentWithTabs:!0,styleActiveLine:!0,extraKeys:{"Ctrl-Space":"autocomplete"},lint:!0,viewportMargin:10});this.doc=this.codeMirror.getDoc();e=this;a=this.view[0];a.removeEventListener("dragEnd",b);a.removeEventListener("dragOver",c);a.addEventListener("dragEnd", b);a.addEventListener("dragOver",c)};b.hide=function(){this.view.addClass("entryRemove")};b.show=function(){this.view.removeClass("entryRemove")};b.textToCode=function(a){a===Entry.Vim.TEXT_TYPE_JS?(this._parserType=Entry.Vim.PARSER_TYPE_JS_TO_BLOCK,this._parser.setParser(this._mode,this._parserType,this.codeMirror)):a===Entry.Vim.TEXT_TYPE_PY&&(this._parserType=Entry.Vim.PARSER_TYPE_PY_TO_BLOCK,this._parser.setParser(this._mode,this._parserType,this.codeMirror));a=this.codeMirror.getValue();return this._parser.parse(a)}; -b.codeToText=function(a,b){var c;b&&(this._mode=b.runType);Entry.playground&&(c=Entry.playground.object,c="# "+c.name+" \uc624\ube0c\uc81d\ud2b8\uc758 \ud30c\uc774\uc36c \ucf54\ub4dc");b=b.textType;b===Entry.Vim.TEXT_TYPE_JS?(this._parserType=Entry.Vim.PARSER_TYPE_BLOCK_TO_JS,this._parser.setParser(this._mode,this._parserType,this.codeMirror)):b===Entry.Vim.TEXT_TYPE_PY&&(this._parserType=Entry.Vim.PARSER_TYPE_BLOCK_TO_PY,this._parser.setParser(this._mode,this._parserType,this.codeMirror));a=this._parser.parse(a, -Entry.Parser.PARSE_GENERAL);b===Entry.Vim.TEXT_TYPE_PY&&(a=c.concat("\n\n").concat(Entry.Vim.PYTHON_IMPORT_ENTRY).concat("\n\n").concat(a));this.codeMirror.setValue(a+"\n");b==Entry.Vim.TEXT_TYPE_PY&&this.codeMirror.getDoc().markText({line:0,ch:0},{line:4,ch:0},{readOnly:!0});a=this.codeMirror.getDoc();a.setCursor({line:a.lastLine()-1})};b.getCodeToText=function(a){var b=this.workspace.oldTextType;b===Entry.Vim.TEXT_TYPE_JS?(this._parserType=Entry.Vim.PARSER_TYPE_BLOCK_TO_JS,this._parser.setParser(this._mode, -this._parserType,this.codeMirror)):b===Entry.Vim.TEXT_TYPE_PY&&(this._parserType=Entry.Vim.PARSER_TYPE_BLOCK_TO_PY,this._parser.setParser(this._mode,this._parserType,this.codeMirror));return this._parser.parse(a,Entry.Parser.PARSE_SYNTAX)};b.setParserAvailableCode=function(a,b){this._parser.setAvailableCode(a,b)}})(Entry.Vim.prototype);Entry.Xml={};Entry.Xml.isTypeOf=function(b,a){return a.getAttribute("type")==b};Entry.Xml.getNextBlock=function(b){b=b.childNodes;for(var a=0;a"+c[1];d.addEventListener("click",function(){Entry.engine.toggleStop()});this.view_.appendChild(d);this.curtainView_=d;Entry.pictureEditable&&(d=Entry.createElement("div","entryPicture"),d.addClass("entryPlaygroundPictureWorkspace"),d.addClass("entryRemove"),this.view_.appendChild(d),this.generatePictureView(d),this.pictureView_=d);d=Entry.createElement("div","entryText");d.addClass("entryPlaygroundTextWorkspace");d.addClass("entryRemove");this.view_.appendChild(d);this.generateTextView(d); +this.textView_=d;Entry.soundEditable&&(d=Entry.createElement("div","entrySound"),d.addClass("entryPlaygroundSoundWorkspace"),d.addClass("entryRemove"),this.view_.appendChild(d),this.generateSoundView(d),this.soundView_=d);d=Entry.createElement("div","entryDefault");d.addClass("entryPlaygroundDefaultWorkspace");this.view_.appendChild(d);this.generateDefaultView(d);this.defaultView_=d;d=Entry.createElement("div","entryCode");d.addClass("entryPlaygroundCodeWorkspace");d.addClass("entryRemove");this.view_.appendChild(d); +this.generateCodeView(d);this.codeView_=d;c=Entry.createElement("div");c.addClass("entryPlaygroundResizeWorkspace","entryRemove");this.resizeHandle_=c;this.view_.appendChild(c);this.initializeResizeHandle(c);this.codeView_=d;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,d=Entry.createElement("ul");d.addClass("entryTabListWorkspace");this.tabList_=d;b.appendChild(d);this.tabViewElements={};b=Entry.createElement("li","entryCodeTab");b.innerHTML=Lang.Workspace.tab_code;b.addClass("entryTabListItemWorkspace");b.addClass("entryTabSelected");d.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"),d.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"),d.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"),d.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"),d.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 d=Entry.createElement("div","entryAddPictureInner");d.addClass("entryPlaygroundAddPictureInner");d.innerHTML=Lang.Workspace.picture_add;a.appendChild(d);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 d=b.item.data("start_pos"),g=b.item.index();Entry.playground.movePicture(d,g)},axis:"y"});b.appendChild(a);this.pictureListView_=a;a=Entry.createElement("div","entryPainter");a.addClass("entryPlaygroundPainter");b.appendChild(a);this.painter=new Entry.Painter2(a)}else"phone"==Entry.type&&(a=Entry.createElement("div","entryAddPicture"),a.addClass("entryPlaygroundAddPicturePhone"),a.bindOnClick(function(a){Entry.dispatchEvent("openPictureManager")}), +d=Entry.createElement("div","entryAddPictureInner"),d.addClass("entryPlaygroundAddPictureInnerPhone"),d.innerHTML=Lang.Workspace.picture_add,a.appendChild(d),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 d=b.item.data("start_pos"),g=b.item.index();Entry.playground.movePicture(d,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 d=Entry.createElement("div");d.addClass("entryTextFontSelect");b.appendChild(d);var c=Entry.createElement("select","entryPainterAttrFontName");c.addClass("entryPlaygroundPainterAttrFontName","entryTextFontSelecter");c.size="1";c.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,d=0,c=a.length;d 0) { - Entry.container.selectObject(this.getCurrentObjects()[0].id); - } else { - Entry.container.selectObject(); - } - } - else if (this.objects_.length && index === 0) - Entry.container.selectObject(this.getCurrentObjects()[0].id); + if (currentObjects.length) + this.selectObject(currentObjects[0].id); else { - Entry.container.selectObject(); + this.selectObject(); Entry.playground.flushPlayground(); }