diff --git a/dist/entry.css b/dist/entry.css
index 64ba1e04db..f8bf0a0756 100644
--- a/dist/entry.css
+++ b/dist/entry.css
@@ -781,6 +781,9 @@ svg .svgBlockGroup text {
.entry-field-dropdown {
cursor: default;
}
+.guideGroup {
+ opacity: 0.3;
+}
.entryWorkspaceBlockMenu {
background-color: #e5e5e5;
position: absolute;
diff --git a/dist/entry.js b/dist/entry.js
index 1495b048fa..338c8abd14 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 +
@@ -847,15 +829,30 @@ Lang.Hw.port_ko, type:"input", pos:{x:0, y:0}}, a0:{name:Lang.Hw.port_en + " A0
Lang.Hw.port_ko, type:"input", pos:{x:0, y:0}}}, mode:"both"}};
Entry.nemoino = {name:"nemoino", setZero:Entry.Arduino.setZero};
Entry.joystick = {name:"joystick", setZero:Entry.Arduino.setZero};
-Entry.CODEino = {name:"CODEino", setZero:Entry.Arduino.setZero, monitorTemplate:Entry.Arduino.monitorTemplate};
+Entry.CODEino = {name:"CODEino", getSensorKey:function() {
+ 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(b) {
+ return (new Date).getTime() + b;
+}, monitorTemplate:Entry.Arduino.monitorTemplate, setZero:function() {
+ 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()};
+ 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(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");
@@ -866,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");
@@ -882,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");
@@ -898,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");
@@ -913,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");
@@ -923,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");
@@ -933,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");
@@ -944,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");
@@ -956,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");
@@ -970,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 = "on" == a.getField("OPERATOR") ? 255 : 0;
+ Entry.hw.setDigitalPortValue(d, c);
+ return a.callReturn();
};
Blockly.Blocks.arduino_toggle_pwm = {init:function() {
this.setColour("#00979D");
@@ -988,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");
@@ -1011,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() {
@@ -1031,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");
@@ -1041,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");
@@ -1051,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() {
@@ -1082,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");
@@ -1091,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");
@@ -1100,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");
@@ -1109,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");
@@ -1118,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");
@@ -1129,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() {
@@ -1153,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");
@@ -1177,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 = "on" == a.getField("OPERATOR") ? 255 : 0;
+ Entry.hw.setDigitalPortValue(c, d);
+ return a.callReturn();
};
Blockly.Blocks.dplay_get_switch_status = {init:function() {
this.setColour("#00979D");
@@ -1193,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");
@@ -1205,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");
@@ -1218,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");
@@ -1228,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");
@@ -1240,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");
@@ -1262,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");
@@ -1283,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,
@@ -1329,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");
@@ -1339,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");
@@ -1349,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");
@@ -1368,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");
@@ -1383,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");
@@ -1399,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");
@@ -1418,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");
@@ -1434,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");
@@ -1454,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");
@@ -1470,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");
@@ -1485,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");
@@ -1507,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() {
@@ -1531,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);
@@ -1544,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);
@@ -1557,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);
@@ -1570,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);
@@ -1590,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);
@@ -1605,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);
@@ -1620,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);
@@ -1636,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);
@@ -1649,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);
@@ -1670,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);
@@ -1683,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);
@@ -1699,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() {
@@ -1712,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);
@@ -1721,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);
@@ -1730,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);
@@ -1739,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);
@@ -1748,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);
@@ -1758,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);
@@ -1767,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);
@@ -1781,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);
@@ -1791,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() {
@@ -1819,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);
@@ -1833,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);
@@ -1846,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);
@@ -1859,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);
@@ -1872,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);
@@ -1887,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);
@@ -1902,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);
@@ -1918,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);
@@ -1968,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);
@@ -1982,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);
@@ -1995,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;
}
}
};
@@ -2012,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);
@@ -2029,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);
@@ -2044,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() {
@@ -2054,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() {
@@ -2070,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);
@@ -2086,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);
@@ -2101,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);
@@ -2123,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);
@@ -2136,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);
@@ -2149,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);
@@ -2165,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);
@@ -2176,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() {
@@ -2188,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);
@@ -2205,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();
}};
@@ -2226,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() {
@@ -2235,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");
};
@@ -2245,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() {
@@ -2254,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() {
@@ -2264,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() {
@@ -2273,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() {
@@ -2282,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() {
@@ -2291,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() {
@@ -2300,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() {
@@ -2310,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");
@@ -2320,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");
}
};
@@ -2336,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");
}
};
@@ -2352,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");
}
};
@@ -2371,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");
@@ -2384,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");
@@ -2398,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");
@@ -2414,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");
@@ -2432,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");
@@ -2450,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");
@@ -2472,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");
@@ -2490,26 +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.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.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 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"};
@@ -2519,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");
@@ -2532,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");
@@ -2545,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");
@@ -2582,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");
@@ -2599,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;
+ delete a.isStart;
+ delete a.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();
+ 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");
@@ -2631,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");
@@ -2648,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), d = 60 / (Entry.FPS || 60) * d * 1E3;
setTimeout(function() {
- b.timeFlag = 0;
- }, 60 / (Entry.FPS || 60) * a * 1E3);
- return b;
+ a.timeFlag = 0;
+ }, d);
+ return a;
};
Blockly.Blocks.repeat_basic = {init:function() {
this.setColour("#498deb");
@@ -2676,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");
@@ -2699,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");
@@ -2710,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() {
@@ -2722,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");
@@ -2735,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");
@@ -2750,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");
@@ -2767,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");
@@ -2779,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");
@@ -2791,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");
@@ -2801,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() {
@@ -2813,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");
@@ -2827,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() {
@@ -2847,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();
};
@@ -2858,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();
@@ -2898,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]];
@@ -2919,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]];
@@ -2943,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() {
}};
@@ -2953,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"));
@@ -2970,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");
@@ -2982,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()) {
@@ -3017,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",
@@ -3052,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");
@@ -3063,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");
@@ -3075,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");
@@ -3130,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");
@@ -3199,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");
@@ -3234,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");
@@ -3269,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");
@@ -3305,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");
@@ -3324,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");
@@ -3340,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");
@@ -3356,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");
@@ -3371,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");
@@ -3389,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");
@@ -3410,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");
@@ -3421,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");
@@ -3436,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");
@@ -3449,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");
@@ -3462,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");
@@ -3494,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");
@@ -3510,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");
@@ -3523,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");
@@ -3539,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");
@@ -3580,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");
@@ -3612,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");
@@ -3626,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");
@@ -3639,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");
@@ -3654,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");
@@ -3669,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");
@@ -3681,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() {
@@ -3691,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");
@@ -3703,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;
}
}
@@ -3780,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");
@@ -3794,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");
@@ -3807,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");
@@ -3820,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");
@@ -3833,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");
@@ -3847,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");
@@ -3860,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");
@@ -3874,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");
@@ -3884,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");
@@ -3893,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() {
@@ -3902,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() {
@@ -3913,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() {
@@ -3937,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");
@@ -3948,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");
@@ -3965,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");
@@ -3991,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");
@@ -4006,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");
@@ -4019,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");
@@ -4031,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");
@@ -4048,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");
@@ -4065,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");
@@ -4078,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");
@@ -4091,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");
@@ -4106,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");
@@ -4121,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");
@@ -4135,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");
@@ -4147,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");
@@ -4158,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");
@@ -4171,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");
};
@@ -4187,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");
@@ -4199,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");
@@ -4217,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");
@@ -4234,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");
@@ -4251,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");
@@ -4268,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");
@@ -4282,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) {
@@ -4294,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");
@@ -4314,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");
@@ -4330,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");
@@ -4345,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");
@@ -4364,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");
@@ -4397,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");
@@ -4410,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");
@@ -4424,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");
@@ -4438,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");
@@ -4454,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");
@@ -4471,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");
@@ -4486,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");
@@ -4501,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");
@@ -4522,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");
@@ -4561,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");
@@ -4593,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");
@@ -4618,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");
@@ -4629,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");
@@ -4642,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");
@@ -4662,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");
@@ -4676,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");
@@ -4692,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");
@@ -4721,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");
@@ -4735,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");
@@ -4749,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");
@@ -4763,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");
@@ -4779,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");
@@ -4798,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");
@@ -4825,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",
@@ -4855,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");
@@ -4867,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");
@@ -4880,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");
@@ -4892,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");
@@ -4905,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");
@@ -4918,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");
@@ -4955,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");
@@ -4972,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");
@@ -4990,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");
@@ -5005,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]};
@@ -5063,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() {
@@ -5072,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() {
@@ -5082,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");
@@ -5092,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");
@@ -5103,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");
@@ -5116,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");
@@ -5127,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");
@@ -5156,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 = "on" == a.getField("OPERATOR") ? 1 : 0;
+ Entry.Roborobo_Roduino.setSendData([Entry.Roborobo_Roduino.INSTRUCTION.DIGITAL_WRITE, d, c]);
+ return a.callReturn();
};
Blockly.Blocks.roduino_motor = {init:function() {
this.setColour("#00979D");
@@ -5170,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");
@@ -5194,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");
@@ -5207,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() {
@@ -5216,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() {
@@ -5226,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");
@@ -5239,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 = "on" == a.getField("OPERATOR") ? 1 : 0;
+ Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.DIGITAL_WRITE, d, c]);
+ return a.callReturn();
};
Blockly.Blocks.schoolkit_get_in_port_number = {init:function() {
this.setColour("#00979D");
@@ -5252,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");
@@ -5263,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");
@@ -5277,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, c = 0, d = a.getField("MODE"), e = a.getField("OPERATOR"), f = a.getNumberValue("VALUE"), d = "motor1" == d ? 7 : 8;
+ 255 < f ? f = 255 : 0 > f && (f = 0);
+ "cw" == e ? Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.MOTOR, 1, d, f]) : "ccw" == e ? Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.MOTOR, 2, d, f]) : "stop" == e && Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.MOTOR, c, d, f]);
+ return a.callReturn();
};
Blockly.Blocks.schoolkit_set_servo_value = {init:function() {
this.setColour("#00979D");
@@ -5300,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];
@@ -5315,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() {
@@ -5379,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");
@@ -5396,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");
@@ -5423,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");
@@ -5479,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");
@@ -5499,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");
@@ -5511,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");
@@ -5522,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");
@@ -5538,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");
@@ -5555,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");
@@ -5571,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");
@@ -5587,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");
@@ -5604,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");
@@ -5621,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");
@@ -5637,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");
@@ -5657,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");
@@ -5671,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");
@@ -5692,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");
@@ -5708,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");
@@ -5720,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");
@@ -5737,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");
@@ -5750,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");
@@ -5760,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;
};
@@ -5774,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() {
@@ -5790,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");
@@ -5806,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");
@@ -5825,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");
@@ -5853,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");
@@ -5886,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");
@@ -5903,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");
@@ -5917,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");
@@ -5929,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");
@@ -5941,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");
@@ -5957,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");
@@ -5971,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");
@@ -6001,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");
@@ -6038,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");
@@ -6059,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");
@@ -6086,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");
@@ -6096,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");
@@ -6105,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");
@@ -6114,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");
@@ -6123,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");
@@ -6132,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");
@@ -6141,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");
@@ -6150,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");
@@ -6175,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");
@@ -6197,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() {
@@ -6232,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);
@@ -6244,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);
@@ -6258,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);
@@ -6272,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);
@@ -6284,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() {
@@ -6306,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");
@@ -6333,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");
@@ -6352,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");
@@ -6373,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);
@@ -6396,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");
@@ -6417,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");
@@ -6450,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() {
@@ -6466,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");
@@ -6492,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");
@@ -6515,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");
@@ -6538,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");
@@ -6558,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");
@@ -6576,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");
@@ -6588,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");
@@ -6601,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");
@@ -6614,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");
@@ -6627,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");
@@ -6644,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"};
@@ -6684,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");
@@ -6695,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");
@@ -6708,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");
@@ -6726,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");
@@ -6741,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");
@@ -6756,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");
@@ -6773,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");
@@ -6792,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");
@@ -6806,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");
@@ -6823,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");
@@ -6840,5314 +6660,3514 @@ 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);
- }
- };
- 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|$)"), " "));
+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.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);
-};
-Entry.hex2rgb = function(a) {
- return (a = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(a)) ? {r:parseInt(a[1], 16), g:parseInt(a[2], 16), b:parseInt(a[3], 16)} : null;
-};
-Entry.rgb2hex = function(a, b, d) {
- return "#" + (16777216 + (a << 16) + (b << 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(a, b, d) {
- return a > d ? d : a < b ? b : a;
+ return c;
};
-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.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 !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(" ");
+ return e;
};
-Entry.removeElement = function(a) {
- a && a.parentNode && a.parentNode.removeChild(a);
+Entry.Container.prototype.clearRunningStateOnScene = function() {
+ this.mapObjectOnScene(function(b) {
+ b.clearExecutor();
+ for (var a = b.clonedEntities.length;0 < a;a--) {
+ b.clonedEntities[a - 1].removeClone();
+ }
+ b.clonedEntities = [];
+ });
};
-Entry.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.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 b;
-};
-Entry.parseNumber = function(a) {
- return "string" != typeof a || isNaN(Number(a)) ? "number" != typeof a || isNaN(Number(a)) ? !1 : a : Number(a);
+ return c;
};
-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.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 d;
+ return e;
};
-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.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 a.substr(0, d);
+ return e;
};
-Entry.isChild = function(a, b) {
- if (!b) {
- for (;b.parentNode;) {
- if ((b = b.parentNode) == a) {
- return !0;
- }
+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 !1;
-};
-Entry.launchFullScreen = function(a) {
- a.requestFullscreen ? a.requestFullscreen() : a.mozRequestFulScreen ? a.mozRequestFulScreen() : a.webkitRequestFullscreen ? a.webkitRequestFullscreen() : a.msRequestFullScreen && a.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};
+ return e;
};
-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.getCachedPicture = function(b) {
+ Entry.assert("string" == typeof b, "pictureId must be string");
+ return this.cachedPicture[b];
};
-Entry.bindAnimationCallback = function(a, b) {
- a.addEventListener("webkitAnimationEnd", b, !1);
- a.addEventListener("animationend", b, !1);
- a.addEventListener("oanimationend", b, !1);
+Entry.Container.prototype.cachePicture = function(b, a) {
+ this.cachedPicture[b] = a;
};
-Entry.cloneSimpleObject = function(a) {
- var b = {}, d;
- for (d in a) {
- b[d] = a[d];
+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.nodeListToArray = function(a) {
- for (var b = Array(a.length), d = -1, c = a.length;++d !== c;b[d] = a[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 b;
};
-Entry.computeInputWidth = function(a) {
- var b = document.createElement("span");
- b.className = "tmp-element";
- b.innerHTML = a.replace(/&/g, "&").replace(//g, ">");
- document.body.appendChild(b);
- a = b.offsetWidth;
- document.body.removeChild(b);
- return Number(a + 10) + "px";
+Entry.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;
+ }
+ this.objects_ = a;
+ this.setCurrentObjects();
+ Entry.stage.sortZorder();
+ this.updateListView();
};
-Entry.isArrowOrBackspace = function(a) {
- return -1 < [37, 38, 39, 40, 8].indexOf(a);
+Entry.Container.prototype.getInputValue = function() {
+ return this.inputValue.getValue();
};
-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.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.findObjsByKey = function(a, b, d) {
- for (var c = [], e = 0;e < a.length;e++) {
- a[e][b] == d && c.push(a[e]);
- }
- return c;
+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.factorials = [];
-Entry.factorial = function(a) {
- return 0 === a || 1 == a ? 1 : 0 < Entry.factorials[a] ? Entry.factorials[a] : Entry.factorials[a] = Entry.factorial(a - 1) * a;
+Entry.Container.prototype.setCopiedObject = function(b) {
+ this.copiedObject = 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.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 a;
-};
-Entry.toRadian = function(a) {
- return a * Math.PI / 180;
+ this.objects_ = a;
};
-Entry.toDegrees = function(a) {
- return 180 * a / Math.PI;
-};
-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.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 b;
+ return a;
};
-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);
- }
- return b;
+Entry.Container.prototype.setCurrentObjects = function() {
+ this.currentObjects_ = this.getSceneObjects();
};
-Entry.cutDecimal = function(a) {
- return Math.round(100 * a) / 100;
+Entry.Container.prototype.getCurrentObjects = function() {
+ var b = this.currentObjects_;
+ b && 0 !== b.length || this.setCurrentObjects();
+ return this.currentObjects_;
};
-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.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.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.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.isFloat = function(a) {
- return /\d+\.{1}\d+$/.test(a);
+Entry.Container.prototype.showProjectAnswer = function() {
+ var b = this.inputValue;
+ b && b.setVisible(!0);
};
-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;
+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);
}
- 0 < d && (b.string = a.substring(0, d), b.index = parseInt(c.join("")) + 1);
- return b;
};
-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.Container.prototype.getView = function() {
+ return this._view;
};
-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());
- }
- }
- return a;
+Entry.Container.prototype.resize = function() {
};
-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.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.convertToRoundedDecimals = function(a, b) {
- return isNaN(a) || !this.isFloat(a) ? a : Number(Math.round(a + "e" + b) + "e-" + b);
+Entry.Container.prototype.removeFuncBlocks = function(b) {
+ this.objects_.forEach(function(a) {
+ a.script.removeBlocksByType(b);
+ });
};
-Entry.attachEventListener = function(a, b, d) {
- setTimeout(function() {
- a.addEventListener(b, d);
- }, 0);
+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 + ">" + 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.deAttachEventListener = function(a, b, d) {
- a.removeEventListener(b, d);
+Entry.SVG = function(b, a) {
+ var d = a ? a : document.getElementById(b);
+ return Entry.SVG.createElement(d);
};
-Entry.isEmpty = function(a) {
- if (!a) {
- return !0;
+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]);
+ }
+ }
+ 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;
+ "text" === b && d.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space", "preserve");
+ return d;
+};
+Entry.SVG.attr = function(b, a) {
+ if ("string" === typeof b) {
+ var d = {};
+ d[b] = a;
+ b = d;
}
- for (var b in a) {
- if (a.hasOwnProperty(b)) {
- return !1;
+ 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 !0;
+ return this;
};
-Entry.Utils.disableContextmenu = function(a) {
- if (a) {
- $(a).on("contextmenu", function(b) {
- b.stopPropagation();
- b.preventDefault();
- return !1;
- });
+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);
}
+ this.setAttribute("class", a);
+ return this;
};
-Entry.Utils.isRightButton = function(a) {
- return 2 == a.button || a.ctrlKey;
-};
-Entry.Utils.isTouchEvent = function(a) {
- return "mousedown" !== a.type.toLowerCase();
-};
-Entry.Utils.inherit = function(a, b) {
- function d() {
+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|$)"), " "));
}
- d.prototype = a.prototype;
- b.prototype = new d;
- return b;
-};
-Entry.bindAnimationCallbackOnce = function(a, b) {
- a.one("webkitAnimationEnd animationendo animationend", b);
-};
-Entry.Utils.isInInput = function(a) {
- return "textarea" == a.target.type || "text" == a.target.type;
-};
-Entry.Utils.isFunction = function(a) {
- return "function" === typeof a;
-};
-Entry.Utils.addFilters = function(a, b) {
- a = a.elem("defs");
- var 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};
+ this.setAttribute("class", a);
+ return this;
};
-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.SVG.hasClass = function(b) {
+ var a = this.getAttribute("class");
+ return a ? a.match(new RegExp("(\\s|^)" + b + "(\\s|$)")) : !1;
};
-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.SVG.remove = function() {
+ this.parentNode && this.parentNode.removeChild(this);
};
-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.SVG.removeAttr = function(b) {
+ this.removeAttribute(b);
};
-Entry.Utils.AsyncError = function(a) {
- this.name = "AsyncError";
- this.message = a || "\ube44\ub3d9\uae30 \ud638\ucd9c \ub300\uae30";
+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.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.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.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.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;
};
-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.device = "desktop";
- return !1;
+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.Utils.convertMouseEvent = function(a) {
- return a.originalEvent && a.originalEvent.touches ? a.originalEvent.touches[0] : a;
+Entry.Dialog.prototype.remove = function() {
+ Entry.stage.unloadDialog(this);
+ this.parent.dialog = null;
+ Entry.requestUpdate = !0;
};
-Entry.Utils.convertIntToHex = function(a) {
- return a.toString(16).toUpperCase();
+Entry.DoneProject = function(b) {
+ this.generateView(b);
};
-Entry.Utils.hasSpecialCharacter = function(a) {
- return /!|@|#|\$|%|\^|&|\*|\(|\)|\+|=|-|\[|\]|\\|\'|;|,|\.|\/|{|}|\||\"|:|<|>|\?/g.test(a);
+var p = Entry.DoneProject.prototype;
+p.init = function(b) {
+ this.projectId = 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;
+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");
};
-(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);
+p.getView = function() {
+ return this.doneContainer;
};
-(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;
+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();
}
- Entry.do = this.do.bind(this);
- Entry.undo = this.undo.bind(this);
- this.editor = {};
- this.reporters = [];
- this._tempStorage = null;
- Entry.Command.editor = this.editor;
+ 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.message = new Entry.Event(window);
};
-(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.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();
});
- }
- };
-})(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.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.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.Container.prototype.disableSort = function() {
- $ && $(this.listView_).sortable("destroy");
-};
-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.stage.sortZorder();
- }
-};
-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);
+ }.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();
});
- d.sounds.map(function(b) {
- Entry.playground.generateSoundElement(b);
+ 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);
}
- this.updateObjectsOrder();
- this.updateListView();
- Entry.stage.sortZorder();
- Entry.variableContainer.updateViews();
- a = Entry.type;
- ("workspace" == a || "phone" == a) && (a = this.getCurrentObjects()[0]) && this.selectObject(a.id);
-};
-Entry.Container.prototype.getPictureElement = function(a, b) {
- if (a = this.getObject(b).getPicture(a)) {
- return a.view;
- }
- throw Error("No picture found");
};
-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.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);
}
- 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;
- }
- throw Error("No picture found");
+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.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);
- });
- d.sounds.map(function(b) {
- Entry.playground.generateSoundElement(b);
- });
- this.setCurrentObjects();
- this.updateObjectsOrder();
- this.updateListView();
- this.selectObject(d.id);
- Entry.variableContainer.updateViews();
- return new Entry.State(this, this.removeObject, d);
+Entry.Engine.prototype.start = function(b) {
+ createjs.Ticker.setFPS(Entry.FPS);
+ this.ticker = setInterval(this.update, Math.floor(1E3 / Entry.FPS));
};
-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.Engine.prototype.stop = function() {
+ clearInterval(this.ticker);
+ this.ticker = null;
};
-Entry.Container.prototype.selectObject = function(a, b) {
- a = this.getObject(a);
- b && a && Entry.scene.selectScene(a.scene);
- this.mapObjectOnScene(function(b) {
- b.view_ && b.view_.removeClass("selectedObject");
- b.isSelected_ = !1;
- });
- a && (a.view_ && a.view_.addClass("selectedObject"), a.isSelected_ = !0);
- Entry.playground && Entry.playground.injectObject(a);
- "minimize" != Entry.type && Entry.engine.isState("stop") && Entry.stage.selectObject(a);
+Entry.Engine.prototype.update = function() {
+ Entry.engine.isState("run") && (Entry.engine.computeObjects(), Entry.hw.update());
};
-Entry.Container.prototype.getAllObjects = function() {
- return this.objects_;
+Entry.Engine.prototype.computeObjects = function() {
+ Entry.container.mapObjectOnScene(this.computeFunction);
};
-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.Engine.prototype.computeFunction = function(b) {
+ b.script.tick();
};
-Entry.Container.prototype.getEntity = function(a) {
- if (a = this.getObject(a)) {
- return a.entity;
+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;
}
- Entry.toast.alert(Lang.Msgs.runtime_error, Lang.Workspace.object_not_found, !0);
+ return a;
};
-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.Engine.prototype.isState = function(b) {
+ return -1 < this.state.indexOf(b);
+};
+Entry.Engine.prototype.run = function() {
+ this.isState("run") ? this.toggleStop() : (this.isState("stop") || this.isState("pause")) && this.toggleRun();
+};
+Entry.Engine.prototype.toggleRun = function() {
+ 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.runButton && (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.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.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 && (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.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.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.runButton && (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.runButton && (this.pauseButton.innerHTML =
+ Lang.Workspace.restart, this.runButton.removeClass("entryRemove"), this.stopButton.removeClass("entryRemove"), this.runButton2 && this.runButton2.removeClass("entryRemove")));
};
-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.Engine.prototype.fireEvent = function(b) {
+ "run" === this.state && Entry.container.mapEntityIncludeCloneOnScene(this.raiseEvent, b);
};
-Entry.Container.prototype.clearRunningState = function() {
- this.mapObject(function(a) {
- a.clearExecutor();
- for (var b = a.clonedEntities.length;0 < b;b--) {
- a.clonedEntities[b - 1].removeClone();
- }
- a.clonedEntities = [];
- });
+Entry.Engine.prototype.raiseEvent = function(b, a) {
+ b.parent.script.raiseEvent(a, b);
};
-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.Engine.prototype.fireEventOnEntity = function(b, a) {
+ "run" == this.state && Entry.container.mapEntityIncludeCloneOnScene(this.raiseEventOnEntity, [a, b]);
};
-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.Engine.prototype.raiseEventOnEntity = function(b, a) {
+ b === a[0] && b.parent.script.raiseEvent(a[1], b);
};
-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.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.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.Engine.prototype.raiseKeyEvent = function(b, a) {
+ return b.parent.script.raiseEvent(a[0], b, String(a[1]));
};
-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.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.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));
+Entry.Engine.prototype.hideMouseView = function() {
+ this.mouseView.addClass("entryRemove");
+};
+Entry.Engine.prototype.toggleFullscreen = function() {
+ if (this.popup) {
+ this.popup.remove(), this.popup = null;
+ } else {
+ this.popup = new Entry.Popup;
+ if ("workspace" != Entry.type) {
+ var b = $(document);
+ $(this.popup.body_).css("top", b.scrollTop());
+ $("body").css("overflow", "hidden");
+ popup.window_.appendChild(Entry.stage.canvas.canvas);
+ popup.window_.appendChild(Entry.engine.runButton[0]);
}
+ popup.window_.appendChild(Entry.engine.view_);
}
- return e;
+ Entry.windowResized.notify();
};
-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));
+Entry.Engine.prototype.exitFullScreen = function() {
+ document.webkitIsFullScreen || document.mozIsFullScreen || document.isFullScreen || (Entry.engine.footerView_.removeClass("entryRemove"), Entry.engine.headerView_.removeClass("entryRemove"));
+ Entry.windowResized.notify();
+};
+Entry.Engine.prototype.showProjectTimer = function() {
+ Entry.engine.projectTimer && this.projectTimer.setVisible(!0);
+};
+Entry.Engine.prototype.hideProjectTimer = function() {
+ var 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);
}
- return e;
};
-Entry.Container.prototype.getCachedPicture = function(a) {
- Entry.assert("string" == typeof a, "pictureId must be string");
- return this.cachedPicture[a];
+Entry.Engine.prototype.clearTimer = function() {
+ clearInterval(this.ticker);
+ clearInterval(this.projectTimer.tick);
};
-Entry.Container.prototype.cachePicture = function(a, b) {
- this.cachedPicture[a] = b;
+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.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.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.Container.prototype.takeSequenceSnapshot = function() {
- for (var a = this.objects_.length, b = this.objects_, d = 0;d < a;d++) {
- b[d].index = d;
+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);
}
};
-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.Engine.prototype.raiseMessage = function(b) {
+ Entry.message.notify(Entry.variableContainer.getMessage(b));
+ return Entry.container.mapEntityIncludeCloneOnScene(this.raiseKeyEvent, ["when_message_cast", b]);
};
-Entry.Container.prototype.getInputValue = function() {
- return this.inputValue.getValue();
+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));
+ });
+ this.object.on("pressup", function(a) {
+ Entry.dispatchEvent("entityClickCanceled", this.entity);
+ this.cursor = "pointer";
+ this.entity.checkCommand();
+ });
+ this.object.on("pressmove", function(a) {
+ "minimize" != Entry.type && Entry.engine.isState("stop") && !this.entity.parent.getLock() && (this.entity.doCommand(), this.entity.setX(.75 * a.stageX - 240 + this.offset.x), this.entity.setY(-(.75 * a.stageY - 135) - this.offset.y), Entry.stage.updateObject());
+ });
};
-Entry.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.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.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.initCommand = function() {
+ Entry.engine.isState("stop") && (this.isCommandValid = !1, Entry.stateManager && Entry.stateManager.addCommand("edit entity", this, this.restoreEntity, this.toJSON()));
};
-Entry.Container.prototype.setCopiedObject = function(a) {
- this.copiedObject = a;
+Entry.EntityObject.prototype.doCommand = function() {
+ this.isCommandValid = !0;
};
-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.checkCommand = function() {
+ Entry.engine.isState("stop") && !this.isCommandValid && Entry.dispatchEvent("cancelLastCommand");
};
-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.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.setCurrentObjects = function() {
- this.currentObjects_ = this.getSceneObjects();
+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.getCurrentObjects = function() {
- var a = this.currentObjects_;
- a && 0 !== a.length || this.setCurrentObjects();
- return this.currentObjects_;
+Entry.EntityObject.prototype.getX = function() {
+ return this.x;
};
-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.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.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.getY = function() {
+ return this.y;
};
-Entry.Container.prototype.showProjectAnswer = function() {
- var a = this.inputValue;
- a && a.setVisible(!0);
+Entry.EntityObject.prototype.getDirection = function() {
+ return this.direction;
};
-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.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.getView = function() {
- return this._view;
+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.resize = function() {
+Entry.EntityObject.prototype.getRotation = function() {
+ return this.rotation;
};
-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.setRegX = function(b) {
+ "textBox" == this.type && (b = 0);
+ this.regX = b;
+ this.object.regX = this.regX;
+ Entry.requestUpdate = !0;
};
-Entry.Container.prototype.removeFuncBlocks = function(a) {
- this.objects_.forEach(function(b) {
- b.script.removeBlocksByType(a);
- });
+Entry.EntityObject.prototype.getRegX = function() {
+ return this.regX;
};
-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 + ">" + a + ">");
- if (void 0 === b) {
- return c;
- }
- 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.EntityObject.prototype.setRegY = function(b) {
+ "textBox" == this.type && (b = 0);
+ this.regY = b;
+ this.object.regY = this.regY;
+ Entry.requestUpdate = !0;
};
-Entry.SVG = function(a) {
- a = document.getElementById(a);
- return Entry.SVG.createElement(a);
+Entry.EntityObject.prototype.getRegY = function() {
+ return this.regY;
};
-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.setScaleX = function(b) {
+ this.scaleX = b;
+ this.object.scaleX = this.scaleX;
+ this.parent.updateCoordinateView();
+ this.updateDialog();
+ Entry.requestUpdate = !0;
};
-Entry.SVG.attr = function(a, b) {
- if ("string" === typeof a) {
- var d = {};
- d[a] = b;
- a = d;
- }
- 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]);
- }
- }
- return this;
+Entry.EntityObject.prototype.getScaleX = function() {
+ return this.scaleX;
};
-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.setScaleY = function(b) {
+ this.scaleY = b;
+ this.object.scaleY = this.scaleY;
+ this.parent.updateCoordinateView();
+ this.updateDialog();
+ Entry.requestUpdate = !0;
};
-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.getScaleY = function() {
+ return this.scaleY;
};
-Entry.SVG.hasClass = function(a) {
- var b = this.getAttribute("class");
- return b ? b.match(new RegExp("(\\s|^)" + a + "(\\s|$)")) : !1;
+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.SVG.remove = function() {
- this.parentNode && this.parentNode.removeChild(this);
+Entry.EntityObject.prototype.getSize = function() {
+ return (this.getWidth() * Math.abs(this.getScaleX()) + this.getHeight() * Math.abs(this.getScaleY())) / 2;
};
-Entry.SVG.removeAttr = function(a) {
- this.removeAttribute(a);
+Entry.EntityObject.prototype.setWidth = function(b) {
+ this.width = b;
+ this.object.width = this.width;
+ this.textObject && this.getLineBreak() && (this.textObject.lineWidth = this.width);
+ this.updateDialog();
+ this.updateBG();
+ Entry.requestUpdate = !0;
};
-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.getWidth = function() {
+ return this.width;
};
-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.setHeight = function(b) {
+ this.height = b;
+ this.textObject && (this.object.height = this.height, this.alignTextBox());
+ this.updateDialog();
+ this.updateBG();
Entry.requestUpdate = !0;
};
-Entry.Dialog.prototype.update = function() {
- var a = this.parent.object.getTransformedBounds();
- if (!a && "textBox" === this.parent.type) {
- if (this._isNoContentTried) {
- delete this._isNoContentTried;
- return;
- }
- this.parent.setText(" ");
- a = this.parent.object.getTransformedBounds();
- this._isNoContentTried = !0;
+Entry.EntityObject.prototype.getHeight = function() {
+ return this.height;
+};
+Entry.EntityObject.prototype.setColour = function(b) {
+ b || (b = "#000000");
+ this.colour = b;
+ this.textObject && (this.textObject.color = this.colour);
+ Entry.requestUpdate = !0;
+};
+Entry.EntityObject.prototype.getColour = function() {
+ return this.colour;
+};
+Entry.EntityObject.prototype.setBGColour = function(b) {
+ b || (b = "transparent");
+ this.bgColor = b;
+ this.updateBG();
+ Entry.requestUpdate = !0;
+};
+Entry.EntityObject.prototype.getBGColour = function() {
+ return this.bgColor;
+};
+Entry.EntityObject.prototype.setUnderLine = function(b) {
+ void 0 === b && (b = !1);
+ this.underLine = b;
+ this.textObject.underLine = b;
+ Entry.requestUpdate = !0;
+};
+Entry.EntityObject.prototype.getUnderLine = function() {
+ return this.underLine;
+};
+Entry.EntityObject.prototype.setStrike = function(b) {
+ void 0 === b && (b = !1);
+ this.strike = b;
+ this.textObject.strike = b;
+ Entry.requestUpdate = !0;
+};
+Entry.EntityObject.prototype.getStrike = function() {
+ return this.strike;
+};
+Entry.EntityObject.prototype.getFont = function() {
+ var b = [];
+ this.fontBold && b.push("bold");
+ this.fontItalic && b.push("italic");
+ b.push(this.getFontSize() + "px");
+ b.push(this.fontType);
+ return b.join(" ");
+};
+Entry.EntityObject.prototype.setFont = function(b) {
+ if ("textBox" == this.parent.objectType && this.font !== b) {
+ b || (b = "20px Nanum Gothic");
+ var a = b.split(" "), 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();
}
- 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("");
+};
+Entry.EntityObject.prototype.setLineHeight = function() {
+ switch(this.getFontType()) {
+ case "Nanum Gothic Coding":
+ this.textObject.lineHeight = this.fontSize;
+ break;
+ default:
+ this.textObject.lineHeight = 0;
+ }
+};
+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.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.getFontType = function() {
+ return this.fontType;
};
-Entry.Dialog.prototype.remove = function() {
- Entry.stage.unloadDialog(this);
- this.parent.dialog = null;
+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.DoneProject = function(a) {
- this.generateView(a);
+Entry.EntityObject.prototype.toggleFontBold = function() {
+ this.fontBold = !this.fontBold;
+ this.syncFont();
+ return this.fontBold;
};
-var p = Entry.DoneProject.prototype;
-p.init = function(a) {
- this.projectId = a;
+Entry.EntityObject.prototype.setFontItalic = function(b) {
+ this.fontItalic = b;
+ Entry.requestUpdate = !0;
};
-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.toggleFontItalic = function() {
+ this.fontItalic = !this.fontItalic;
+ this.syncFont();
+ return this.fontItalic;
};
-p.getView = function() {
- return this.doneContainer;
+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]);
+ }
+ this.setFont(d.join(" ") + " " + b);
};
-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.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();
+ }
};
-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();
+Entry.EntityObject.prototype.setText = function(b) {
+ "textBox" == this.parent.objectType && (void 0 === b && (b = ""), this.text = b, this.textObject.text = this.text, this.lineBreak || (this.setWidth(this.textObject.getMeasuredWidth()), this.parent.updateCoordinateView()), this.updateBG(), Entry.stage.updateObject());
+};
+Entry.EntityObject.prototype.getText = function() {
+ return this.text;
+};
+Entry.EntityObject.prototype.setTextAlign = function(b) {
+ "textBox" == this.parent.objectType && (void 0 === b && (b = Entry.TEXT_ALIGN_CENTER), this.textAlign = b, this.textObject.textAlign = Entry.TEXT_ALIGNS[this.textAlign], this.alignTextBox(), this.updateBG(), Entry.stage.updateObject());
+};
+Entry.EntityObject.prototype.getTextAlign = function() {
+ return this.textAlign;
+};
+Entry.EntityObject.prototype.setLineBreak = function(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();
}
- 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);
+};
+Entry.EntityObject.prototype.getLineBreak = function() {
+ return this.lineBreak;
+};
+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.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;
});
- setInterval(function() {
- this._mouseMoved && (this.updateMouseView(), this._mouseMoved = !1);
- }.bind(this), 100);
+ Entry.dispatchEvent("updateObject");
};
-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.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.applyFilter = function(b) {
+ function a(a, b) {
+ for (var d in a) {
+ if (a[d] !== b[d]) {
+ return !1;
}
- });
- this.view_.insertBefore(this.speedHandle_, this.maximizeButton);
- this.setSpeedMeter(Entry.FPS);
+ }
+ return !0;
+ }
+ 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.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.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.Engine.prototype.start = function(a) {
- createjs.Ticker.setFPS(Entry.FPS);
- this.ticker = setInterval(this.update, Math.floor(1E3 / Entry.FPS));
+Entry.EntityObject.prototype.updateDialog = function() {
+ this.dialog && this.dialog.update();
+ Entry.requestUpdate = !0;
};
-Entry.Engine.prototype.stop = function() {
- clearInterval(this.ticker);
- this.ticker = null;
+Entry.EntityObject.prototype.takeSnapshot = function() {
+ this.snapshot_ = this.toJSON();
+ this.collision = Entry.Utils.COLLISION.NONE;
};
-Entry.Engine.prototype.update = function() {
- Entry.engine.isState("run") && (Entry.engine.computeObjects(), Entry.hw.update());
+Entry.EntityObject.prototype.loadSnapshot = function() {
+ this.snapshot_ && this.syncModel_(this.snapshot_);
+ "sprite" == this.parent.objectType && this.setImage(this.parent.getPicture());
+ Entry.requestUpdate = !0;
};
-Entry.Engine.prototype.computeObjects = function() {
- Entry.container.mapObjectOnScene(this.computeFunction);
+Entry.EntityObject.prototype.removeClone = function() {
+ if (this.isClone) {
+ this.dialog && this.dialog.remove();
+ this.brush && this.removeBrush();
+ Entry.stage.unloadEntity(this);
+ var b = this.parent.clonedEntities.indexOf(this);
+ this.parent.clonedEntities.splice(b, 1);
+ Entry.Utils.isFunction(this.clearExecutor) && this.clearExecutor();
+ }
};
-Entry.Engine.prototype.computeFunction = function(a) {
- a.script.tick();
+Entry.EntityObject.prototype.clearExecutor = function() {
+ this.parent.script.clearExecutorsByEntity(this);
};
-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;
- }
+Entry.EntityObject.prototype.toJSON = function() {
+ var b = {};
+ b.x = Entry.cutDecimal(this.getX());
+ b.y = Entry.cutDecimal(this.getY());
+ b.regX = Entry.cutDecimal(this.getRegX());
+ b.regY = Entry.cutDecimal(this.getRegY());
+ b.scaleX = this.getScaleX();
+ b.scaleY = this.getScaleY();
+ b.rotation = Entry.cutDecimal(this.getRotation());
+ b.direction = Entry.cutDecimal(this.getDirection());
+ b.width = Entry.cutDecimal(this.getWidth());
+ b.height = Entry.cutDecimal(this.getHeight());
+ b.font = this.getFont();
+ b.visible = this.getVisible();
+ "textBox" == this.parent.objectType && (b.colour = this.getColour(), b.text = this.getText(), b.textAlign = this.getTextAlign(), b.lineBreak = this.getLineBreak(), b.bgColor = this.getBGColour(), b.underLine = this.getUnderLine(), b.strike = this.getStrike(), b.fontSize = this.getFontSize());
return b;
};
-Entry.Engine.prototype.isState = function(a) {
- return -1 < this.state.indexOf(a);
+Entry.EntityObject.prototype.setInitialEffectValue = function() {
+ this.effect = this.getInitialEffectValue();
+ Entry.requestUpdate = !0;
};
-Entry.Engine.prototype.run = function() {
- this.isState("run") ? this.toggleStop() : (this.isState("stop") || this.isState("pause")) && this.toggleRun();
+Entry.EntityObject.prototype.getInitialEffectValue = function() {
+ return {blur:0, hue:0, hsv:0, brightness:0, contrast:0, saturation:0, alpha:1};
};
-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.EntityObject.prototype.removeBrush = function() {
+ Entry.stage.selectedObjectContainer.removeChild(this.shape);
+ this.shape = this.brush = null;
+};
+Entry.EntityObject.prototype.updateBG = function() {
+ if (this.bgObject) {
+ this.bgObject.graphics.clear();
+ var b = this.getWidth(), a = this.getHeight();
+ this.bgObject.graphics.setStrokeStyle(1).beginStroke().beginFill(this.getBGColour()).drawRect(-b / 2, -a / 2, b, a);
+ if (this.getLineBreak()) {
+ this.bgObject.x = 0;
+ } else {
+ switch(this.getTextAlign()) {
+ case Entry.TEXT_ALIGN_LEFT:
+ this.bgObject.x = b / 2;
+ break;
+ case Entry.TEXT_ALIGN_CENTER:
+ this.bgObject.x = 0;
+ break;
+ case Entry.TEXT_ALIGN_RIGHT:
+ this.bgObject.x = -b / 2;
+ }
}
- Entry.addActivity("run");
- "stop" == this.state && (Entry.container.mapEntity(function(b) {
- b.takeSnapshot();
- }), Entry.variableContainer.mapVariable(function(b) {
- b.takeSnapshot();
- }), Entry.variableContainer.mapList(function(b) {
- b.takeSnapshot();
- }), this.projectTimer.takeSnapshot(), Entry.container.inputValue.takeSnapshot(), Entry.container.takeSequenceSnapshot(), Entry.scene.takeStartSceneSnapshot(), this.state = "run", this.fireEvent("start"));
- this.state = "run";
- "mobile" == Entry.type && this.view_.addClass("entryEngineBlueWorkspace");
- this.pauseButton.innerHTML = Lang.Workspace.pause;
- this.runButton.addClass("run");
- this.runButton.addClass("entryRemove");
- this.stopButton.removeClass("entryRemove");
- this.pauseButton && this.pauseButton.removeClass("entryRemove");
- this.runButton2 && this.runButton2.addClass("entryRemove");
- this.stopButton2 && this.stopButton2.removeClass("entryRemove");
- this.isUpdating || (Entry.engine.update(), Entry.engine.isUpdating = !0);
- Entry.stage.selectObject();
- Entry.dispatchEvent("run");
}
};
-Entry.Engine.prototype.toggleStop = function() {
- Entry.addActivity("stop");
- var a = Entry.container, b = Entry.variableContainer;
- a.mapEntity(function(b) {
- b.loadSnapshot();
- b.object.filters = [];
- b.resetFilter();
- b.dialog && b.dialog.remove();
- b.brush && b.removeBrush();
- });
- 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.EntityObject.prototype.alignTextBox = function() {
+ if ("textBox" == this.type) {
+ var b = this.textObject;
+ if (this.lineBreak) {
+ var a = b.getMeasuredLineHeight();
+ b.y = a / 2 - this.getHeight() / 2;
+ switch(this.textAlign) {
+ case Entry.TEXT_ALIGN_CENTER:
+ b.x = 0;
+ break;
+ case Entry.TEXT_ALIGN_LEFT:
+ b.x = -this.getWidth() / 2;
+ break;
+ case Entry.TEXT_ALIGN_RIGHT:
+ b.x = this.getWidth() / 2;
+ }
+ b.maxHeight = this.getHeight();
+ } else {
+ b.x = 0, b.y = 0;
+ }
+ }
};
-Entry.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.EntityObject.prototype.syncDialogVisible = function() {
+ this.dialog && (this.dialog.object.visible = this.visible);
};
-Entry.Engine.prototype.fireEvent = function(a) {
- "run" == this.state && Entry.container.mapEntityIncludeCloneOnScene(this.raiseEvent, a);
+Entry.Helper = function() {
+ this.visible = !1;
};
-Entry.Engine.prototype.raiseEvent = function(a, b) {
- a.parent.script.raiseEvent(b, a);
+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.fireEventOnEntity = function(a, b) {
- "run" == this.state && Entry.container.mapEntityIncludeCloneOnScene(this.raiseEventOnEntity, [b, a]);
+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.prototype.raiseEventOnEntity = function(a, b) {
- a === b[0] && a.parent.script.raiseEvent(b[1], a);
+p.renderBlock = function(b) {
+ var a = Lang.Helper[b];
+ if (b && this.visible && a && !Entry.block[b].isPrimitive) {
+ this.first && (this.blockHelperContent_.removeClass("entryBlockHelperIntro"), this.first = !1);
+ this.code.clear();
+ var 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});
+ }
};
-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);
-};
-Entry.Engine.prototype.raiseKeyEvent = function(a, b) {
- return a.parent.script.raiseEvent(b[0], a, String(b[1]));
-};
-Entry.Engine.prototype.updateMouseView = function() {
- var a = Entry.stage.mouseCoordinate;
- this.mouseView.textContent = "X : " + a.x + ", Y : " + a.y;
- this.mouseView.removeClass("entryRemove");
+p.getView = function() {
+ return this.view;
};
-Entry.Engine.prototype.hideMouseView = function() {
- this.mouseView.addClass("entryRemove");
+p.resize = function() {
};
-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.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]});
}
- popup.window_.appendChild(Entry.engine.view_);
}
- Entry.windowResized.notify();
-};
-Entry.Engine.prototype.exitFullScreen = function() {
- document.webkitIsFullScreen || document.mozIsFullScreen || document.isFullScreen || (Entry.engine.footerView_.removeClass("entryRemove"), Entry.engine.headerView_.removeClass("entryRemove"));
- Entry.windowResized.notify();
+ this.data = d;
};
-Entry.Engine.prototype.showProjectTimer = function() {
- Entry.engine.projectTimer && this.projectTimer.setVisible(!0);
+Entry.ActivityReporter = function() {
+ this._activities = [];
};
-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;
- }
+(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);
}
- a.setVisible(!1);
- }
-};
-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));
+ };
+ 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.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.State.prototype.generateMessage = function() {
};
-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));
+Entry.StateManager = function() {
+ this.undoStack_ = [];
+ this.redoStack_ = [];
+ this.isIgnore = this.isRestore = !1;
+ Entry.addEventListener("cancelLastCommand", function(b) {
+ Entry.stateManager.cancelLastCommand();
});
- this.object.on("pressup", function(b) {
- Entry.dispatchEvent("entityClickCanceled", this.entity);
- this.cursor = "pointer";
- this.entity.checkCommand();
+ Entry.addEventListener("run", function(b) {
+ Entry.stateManager.updateView();
});
- 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.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.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.StateManager.prototype.generateView = function(b, a) {
};
-Entry.EntityObject.prototype.getRotation = function() {
- return this.rotation;
+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();
+ }
+ Entry.creationChangedEvent && Entry.creationChangedEvent.notify();
+ }
};
-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.cancelLastCommand = function() {
+ this.canUndo() && (this.undoStack_.pop(), this.updateView(), Entry.creationChangedEvent && Entry.creationChangedEvent.notify());
};
-Entry.EntityObject.prototype.getRegX = function() {
- return this.regX;
+Entry.StateManager.prototype.getLastCommand = function() {
+ return this.undoStack_[this.undoStack_.length - 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.undo = function() {
+ if (this.canUndo() && !this.isRestoring()) {
+ this.addActivity("undo");
+ for (this.startRestore();this.undoStack_.length;) {
+ var b = this.undoStack_.pop();
+ b.func.apply(b.caller, b.params);
+ if (!0 !== b.isPass) {
+ break;
+ }
+ }
+ this.updateView();
+ this.endRestore();
+ Entry.creationChangedEvent && Entry.creationChangedEvent.notify();
+ }
};
-Entry.EntityObject.prototype.getRegY = function() {
- return this.regY;
+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.prototype.setScaleX = function(a) {
- this.scaleX = a;
- this.object.scaleX = this.scaleX;
- this.parent.updateCoordinateView();
- this.updateDialog();
- Entry.requestUpdate = !0;
+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.getScaleX = function() {
- return this.scaleX;
+Entry.StateManager.prototype.startRestore = function() {
+ this.isRestore = !0;
};
-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.endRestore = function() {
+ this.isRestore = !1;
};
-Entry.EntityObject.prototype.getScaleY = function() {
- return this.scaleY;
+Entry.StateManager.prototype.isRestoring = function() {
+ return this.isRestore;
};
-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.startIgnore = function() {
+ this.isIgnore = !0;
};
-Entry.EntityObject.prototype.getSize = function() {
- return (this.getWidth() * Math.abs(this.getScaleX()) + this.getHeight() * Math.abs(this.getScaleY())) / 2;
+Entry.StateManager.prototype.endIgnore = function() {
+ this.isIgnore = !1;
};
-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.isIgnoring = function() {
+ return this.isIgnore;
};
-Entry.EntityObject.prototype.getWidth = function() {
- return this.width;
+Entry.StateManager.prototype.canUndo = function() {
+ return 0 < this.undoStack_.length && Entry.engine.isState("stop");
};
-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.StateManager.prototype.canRedo = function() {
+ return 0 < this.redoStack_.length && Entry.engine.isState("stop");
};
-Entry.EntityObject.prototype.getHeight = function() {
- return this.height;
+Entry.StateManager.prototype.addStamp = function() {
+ this.stamp = Entry.generateHash();
+ this.undoStack_.length && (this.undoStack_[this.undoStack_.length - 1].stamp = this.stamp);
};
-Entry.EntityObject.prototype.setColour = function(a) {
- a || (a = "#000000");
- this.colour = a;
- this.textObject && (this.textObject.color = this.colour);
- Entry.requestUpdate = !0;
+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.getColour = function() {
- return this.colour;
+Entry.StateManager.prototype.addActivity = function(b) {
+ Entry.reporter && Entry.reporter.report(new Entry.State(b));
};
-Entry.EntityObject.prototype.setBGColour = function(a) {
- a || (a = "transparent");
- this.bgColor = a;
- this.updateBG();
- Entry.requestUpdate = !0;
+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.getBGColour = function() {
- return this.bgColor;
+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.setUnderLine = function(a) {
- void 0 === a && (a = !1);
- this.underLine = a;
- this.textObject.underLine = a;
- Entry.requestUpdate = !0;
+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.getUnderLine = function() {
- return this.underLine;
+Entry.EntryObject.prototype.setText = function(b) {
+ Entry.assert("string" == typeof b, "object text must be string");
+ this.text = 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.setScript = function(b) {
+ this.script = b;
};
-Entry.EntityObject.prototype.getStrike = function() {
- return this.strike;
+Entry.EntryObject.prototype.getScriptText = function() {
+ return JSON.stringify(this.script.toJSON());
};
-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.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.setLineHeight = function() {
- switch(this.getFontType()) {
- case "Nanum Gothic Coding":
- this.textObject.lineHeight = this.fontSize;
- break;
- default:
- this.textObject.lineHeight = 0;
+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.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.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.getFontType = function() {
- return this.fontType;
+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.setFontType = function(a) {
- "textBox" == this.parent.objectType && (this.fontType = a ? a : "Nanum Gothic", this.syncFont());
+Entry.EntryObject.prototype.select = function(b) {
+ console.log(this);
};
-Entry.EntityObject.prototype.getFontSize = function(a) {
- return this.fontSize;
+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.setFontSize = function(a) {
- "textBox" == this.parent.objectType && this.fontSize != a && (this.fontSize = a ? a : 20, this.syncFont(), this.alignTextBox());
+Entry.EntryObject.prototype.removePicture = function(b) {
+ if (2 > this.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.EntityObject.prototype.setFontBold = function(a) {
- this.fontBold = a;
- Entry.requestUpdate = !0;
+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 (c = 0;c < d;c++) {
+ if (a[c].name == b) {
+ return a[c];
+ }
+ }
+ 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.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]);
- }
- this.setFont(d.join(" ") + " " + a);
-};
-Entry.EntityObject.prototype.getFontName = function() {
- if ("textBox" == this.type) {
- if (!this.font) {
- return "";
- }
- 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]);
+Entry.EntryObject.prototype.setPicture = function(b) {
+ for (var a in this.pictures) {
+ if (b.id === this.pictures[a].id) {
+ this.pictures[a] = b;
+ return;
}
- return b.join(" ").trim();
}
+ throw Error("No picture found");
};
-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();
+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];
+ }
}
};
-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.EntityObject.prototype.applyFilter = function(a) {
- function b(b, a) {
- for (var d in b) {
- if (b[d] !== a[d]) {
- return !1;
- }
+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];
}
- 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.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());
}
- 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("
q?(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);0 g?(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"}]},{type:"number",params:["0"]},{type:"number",params:["1023"]},{type:"number",params:["0"]},{type:"number",params:["100"]}],type:"nemoino_convert_scale"},"class":"arduino",syntax:{js:[],py:["Nemoino.convert_scale(%1, %2, %3, %4, %5)"]}},sensorBoard_get_number_sensor_value:{parent:"arduino_get_number_sensor_value",isNotFor:["sensorBoard"],def:{params:[{type:"arduino_get_sensor_number"}], +type:"sensorBoard_get_number_sensor_value"},"class":"arduino_value",syntax:{js:[],py:["hw.sensorBoard_get_number_sensor_value(%1)"]}},sensorBoard_get_digital_value:{parent:"arduino_get_digital_value",isNotFor:["sensorBoard"],def:{params:[{type:"arduino_get_port_number"}],type:"sensorBoard_get_digital_value"},"class":"arduino_value",syntax:{js:[],py:["hw.sensorBoard_get_digital_value(%1)"]}},sensorBoard_toggle_led:{parent:"arduino_toggle_led",isNotFor:["sensorBoard"],def:{params:[{type:"arduino_get_port_number"}, +null,null],type:"sensorBoard_toggle_led"},"class":"arduino_set",syntax:{js:[],py:["hw.sensorBoard_toggle_led(%1)"]}},sensorBoard_toggle_pwm:{parent:"arduino_toggle_pwm",isNotFor:["sensorBoard"],def:{params:[{type:"arduino_get_pwm_port_number"},{type:"arduino_text",params:["255"]},null],type:"sensorBoard_toggle_pwm"},"class":"arduino_set",syntax:{js:[],py:["hw.sensorBoard_toggle_pwm(%1, %2)"]}},sensorBoard_convert_scale:{parent:"arduino_convert_scale",isNotFor:["sensorBoard"],def:{params:[{type:"arduino_get_number_sensor_value", +params:[{type:"arduino_get_sensor_number",id:"bl5e"}]},{type:"number",params:["0"]},{type:"number",params:["1023"]},{type:"number",params:["0"]},{type:"number",params:["100"]}],type:"sensorBoard_convert_scale"},"class":"arduino",syntax:{js:[],py:["hw.sensorBoard_convert_scale(%1, %2, %3, %4, %5)"]}},ardublock_get_number_sensor_value:{parent:"arduino_get_number_sensor_value",isNotFor:["ardublock"],def:{params:[{type:"arduino_get_sensor_number"}],type:"ardublock_get_number_sensor_value"},"class":"arduino_value"}, +ardublock_get_digital_value:{parent:"arduino_get_digital_value",isNotFor:["ardublock"],def:{params:[{type:"arduino_get_port_number"}],type:"ardublock_get_digital_value"},"class":"arduino_value"},ardublock_toggle_led:{parent:"arduino_toggle_led",isNotFor:["ardublock"],def:{params:[{type:"arduino_get_port_number"},null,null],type:"ardublock_toggle_led"},"class":"arduino_set"},ardublock_toggle_pwm:{parent:"arduino_toggle_pwm",isNotFor:["ardublock"],def:{params:[{type:"arduino_get_pwm_port_number"},{type:"arduino_text", +params:["255"]},null],type:"ardublock_toggle_pwm"},"class":"arduino_set"},ardublock_convert_scale:{parent:"arduino_convert_scale",isNotFor:["ardublock"],def:{params:[{type:"arduino_get_number_sensor_value",params:[{type:"arduino_get_sensor_number"}]},{type:"number",params:["0"]},{type:"number",params:["1023"]},{type:"number",params:["0"]},{type:"number",params:["100"]}],type:"ardublock_convert_scale"},"class":"arduino"},joystick_get_number_sensor_value:{parent:"arduino_get_number_sensor_value",isNotFor:["joystick"], +def:{params:[{type:"arduino_get_sensor_number"}],type:"joystick_get_number_sensor_value"},"class":"arduino_value"},joystick_get_digital_value:{parent:"arduino_get_digital_value",isNotFor:["joystick"],def:{params:[{type:"arduino_get_port_number"}],type:"joystick_get_digital_value"},"class":"arduino_value"},joystick_toggle_led:{parent:"arduino_toggle_led",isNotFor:["joystick"],def:{params:[{type:"arduino_get_port_number"},null,null],type:"joystick_toggle_led"},"class":"arduino_set"},joystick_toggle_pwm:{parent:"arduino_toggle_pwm", +isNotFor:["joystick"],def:{params:[{type:"arduino_get_pwm_port_number"},{type:"arduino_text",params:["255"]},null],type:"joystick_toggle_pwm"},"class":"arduino_set"},joystick_convert_scale:{parent:"arduino_convert_scale",isNotFor:["joystick"],def:{params:[{type:"arduino_get_number_sensor_value",params:[{type:"arduino_get_sensor_number"}]},{type:"number",params:["0"]},{type:"number",params:["1023"]},{type:"number",params:["0"]},{type:"number",params:["100"]}],type:"joystick_convert_scale"},"class":"arduino"}, +ebs_if:{parent:"_if",def:{type:"_if",params:[{type:"reach_something",params:[null,"wall"]}]}},ebs_if2:{parent:"_if",def:{type:"_if",params:[{type:"reach_something",params:[null,"cwz5"]}]}},ai_move_right:{skeleton:"basic",mode:"maze",color:"#A751E3",syntax:["Scope","move"],params:[{type:"Image",img:"/img/assets/week/blocks/moveStep.png",size:24}],func:function(b,a){if(a.isStart){if(a.isAction)return Entry.STATIC.BREAK;delete a.isAction;delete a.isStart}else{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.EAST;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:0});d.x++;return Entry.STATIC.BREAK}}},ai_move_up:{skeleton:"basic",mode:"maze",color:"#A751E3",syntax:["Scope","up"],params:[{type:"Image",img:"/img/assets/week/blocks/ai_move_up.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.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();var d=Ntry.entityManager.getComponent(b.id,Ntry.STATIC.RADAR),c=this.block.statements,e=1;a.isLooped=!0;d.center.type==Ntry.STATIC.AI_METEO&&1==d.center.distance&&(e=0);this.executor.stepInto(c[e]);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){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 (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=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){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="on"==a.getField("OPERATOR")?1:0;Entry.Roborobo_Roduino.setSendData([Entry.Roborobo_Roduino.INSTRUCTION.DIGITAL_WRITE,d,c]);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){var d=a.getNumberValue("VALUE",a),c="on"==a.getField("OPERATOR")?1:0;Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.DIGITAL_WRITE,d,c]);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=0,c=0,d=a.getField("MODE"),e=a.getField("OPERATOR"),f=a.getNumberValue("VALUE"),d="motor1"==d?7:8;255 f&&(f=0);"cw"==e?Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.MOTOR,1,d,f]):"ccw"==e?Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.MOTOR, +2,d,f]):"stop"==e&&Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.MOTOR,c,d,f]);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:180 d&& +(e=0);255 d&&(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){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){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){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")}},hidden:{color:"#7C7C7C",skeleton:"basic",template:" ? %1",statements:[],params:[{type:"Indicator",color:"#6B6B6B",size:12}],events:{},def:{params:[null],type:"hidden"},paramsKeyMap:{VALUE:0},"class":"etc",isNotFor:[], +func:function(b,a){}}};(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);this.pattern=Entry.Utils.addBlockPattern(this.svg,this.suffix).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))}; (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 this._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;b (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=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 d=e.dragInstance; -e.scroll(a.pageY-d.offsetY);d.set({offsetY:a.pageY})}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()};b._addControl=function(){$(this.vScrollbar).bind("mousedown touchstart",this.mouseHandler)}})(Entry.BlockMenuScroller.prototype);Entry.BlockView=function(b,a,d){var c=this;Entry.Model(this,!1);this.block=b;this._lazyUpdatePos=_.debounce(b._updatePos.bind(b),200);this._board=a;this._observers=[];this.set(b);this.svgGroup=a.svgBlockGroup.elem("g");this._schema=Entry.block[b.type];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.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;a=this._skeleton;this.svgGroup.attr({class:"block"});var e=a.classes;e&&0!==e.length&&e.forEach(function(a){c.svgGroup.addClass(a)});e=a.path(this);this.pathGroup=this.svgGroup.elem("g");this._updateMagnet();this._path=this.pathGroup.elem("path");this.getBoard().patternRect&& -($(this._path).mouseenter(function(a){c._mouseEnable&&c._changeFill(!0)}),$(this._path).mouseleave(function(a){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= -a.outerLine;a.outerLine&&(e["stroke-width"]="0.6");this._path.attr(e);this._moveTo(this.x,this.y,!1);this._startContentRender(b);!0!==this._board.disableMouseEvent&&this._addControl();this.bindPrev()};b._startContentRender=function(a){a=void 0===a?Entry.Workspace.MODE_BOARD:a;this.contentSvgGroup&&this.contentSvgGroup.remove();var b=this._schema;b.statements&&b.statements.length&&this.statementSvgGroup&&this.statementSvgGroup.remove();this._contents=[];this.contentSvgGroup=this.svgGroup.elem("g"); -b.statements&&b.statements.length&&(this.statementSvgGroup=this.svgGroup.elem("g"));switch(a){case Entry.Workspace.MODE_BOARD:case Entry.Workspace.MODE_OVERLAYBOARD:for(var c=/(%\d)/mi,e=(b.template?b.template:Lang.template[this.block.type]).split(c),f=b.params,g=0;g 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,d),a= -!0),this.animating&&this.set({animating:!1}),0===f.dragInstance.height&&f.dragInstance.set({height:-1+f.height}),d=f.dragInstance,f._moveBy(c.pageX-d.offsetX,c.pageY-d.offsetY,!1),d.set({offsetX:c.pageX,offsetY:c.pageY}),Entry.GlobalSvg.position(),f.originPos||(f.originPos={x:f.x,y:f.y}),a&&g.generateCodeMagnetMap(),f._updateCloseBlock()))}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)))}};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(), -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)); -return this._shadow};b.destroyShadow=function(){this._shadow&&(this._shadow.remove(),delete this._shadow)};b._updateMagnet=function(){if(this._skeleton.magnets){var a=this._skeleton.magnets(this);a.next&&this._nextGroup.attr("transform","translate("+a.next.x+","+a.next.y+")");this.magnet=a;this.block.getThread().changeEvent.notify()}};b._updateBG=function(){if(this._board.dragBlock&&this._board.dragBlock.dragInstance){var a=this.svgGroup;if(this.magnet.next){if(a=this.magneting){var b=this._board.dragBlock.getShadow(), -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"))}};b.addDragging=function(){this.svgGroup.addClass("dragging")};b.removeDragging=function(){this.svgGroup.removeClass("dragging")};b.addSelected=function(){this.svgGroup.addClass("selected")};b.removeSelected=function(){this.svgGroup.removeClass("selected")};b.getSkeleton=function(){return this._skeleton};b.getContentPos=function(){return this._skeleton.contentPos(this)};b.renderText=function(){this._startContentRender(Entry.Workspace.MODE_VIMBOARD)}; +function(a){if(isNaN(a))return a;a=Number(a);for(var b=this._categories,c=this._categoryElems,e=0;e this._bannedClass.indexOf(a)&& +this._bannedClass.push(a);this.align(b)};b.unbanClass=function(a,b){var c=this._bannedClass.indexOf(a);-1 b&&(a.preventDefault(),this.selectMenu(b-49))};b.enablePattern=function(){this.pattern.removeAttribute("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;b =a?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 d=e.dragInstance;e.scroll(a.pageY-d.offsetY);d.set({offsetY:a.pageY})}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()};b._addControl=function(){$(this.vScrollbar).bind("mousedown touchstart",this.mouseHandler)}})(Entry.BlockMenuScroller.prototype);Entry.BlockView=function(b,a,d){var c=this;Entry.Model(this,!1);this.block=b;this._lazyUpdatePos=_.debounce(b._updatePos.bind(b),200);this._board=a;this._observers=[];this.set(b);this.svgGroup=a.svgBlockGroup.elem("g");this._schema=Entry.skinContainer.getSkin(b);if(void 0===this._schema)this.block.destroy(!1,!1);else{this._schema.deletable&&this.block.setDeletable(this._schema.deletable);this._schema.copyable&&this.block.setCopyable(this._schema.copyable);!1===this._schema.display&&this.set({display:!1}); +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._extensions=[];this.magnet={};this._paramMap={};e.magnets&&e.magnets(this).next&&(this.svgGroup.nextMagnet=this.block,this._nextGroup=this.svgGroup.elem("g",{class:"entryBlockNextGroup"}),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.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"});this._schema.css&&this.svgGroup.attr({style:this._schema.css});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");Entry.isMobile()||($(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);this._startExtension(b);!0!==this._board.disableMouseEvent&&this._addControl();(e=this.guideSvgGroup)&&this.svgGroup.insertBefore(e,this.svgGroup.firstChild);this.bindPrev()};b._startContentRender=function(a){a=void 0===a?Entry.Workspace.MODE_BOARD:a;var b=this._schema;this.contentSvgGroup&&this.contentSvgGroup.remove(); +this.statementSvgGroup&&this.statementSvgGroup.remove();this._contents=[];this.contentSvgGroup=this.svgGroup.elem("g",{class:"contentsGroup"});b.statements&&b.statements.length&&(this.statementSvgGroup=this.svgGroup.elem("g",{class:"statementGroup"}));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 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,d),a=!0),this.animating&&this.set({animating:!1}),0===f.dragInstance.height&&f.dragInstance.set({height:-1+f.height}),d=f.dragInstance,f._moveBy(c.pageX-d.offsetX, +c.pageY-d.offsetY,!1),d.set({offsetX:c.pageX,offsetY:c.pageY}),Entry.GlobalSvg.position(),f.originPos||(f.originPos={x:f.x,y:f.y}),a&&g.generateCodeMagnetMap(),f._updateCloseBlock()))}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)))}}; +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);switch(g.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()});this._statements.forEach(function(a){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));return this._shadow};b.destroyShadow=function(){this._shadow&& +(this._shadow.remove(),delete this._shadow)};b._updateMagnet=function(){if(this._skeleton.magnets){var a=this._skeleton.magnets(this);a.next&&this._nextGroup.attr("transform","translate("+a.next.x+","+a.next.y+")");this.magnet=a;this.block.getThread().changeEvent.notify()}};b._updateBG=function(){if(this._board.dragBlock&&this._board.dragBlock.dragInstance){var a=this.svgGroup;if(this.magnet.next||this.magnet.previous){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"))}};b.addDragging=function(){this.svgGroup.addClass("dragging")};b.removeDragging=function(){this.svgGroup.removeClass("dragging")};b.addSelected=function(){this.svgGroup.addClass("selected")};b.removeSelected=function(){this.svgGroup.removeClass("selected")};b.getSkeleton=function(){return this._skeleton};b.getContentPos=function(){return this._skeleton.contentPos(this)};b.renderText=function(){this._startContentRender(Entry.Workspace.MODE_VIMBOARD)}; b.renderBlock=function(){this._startContentRender(Entry.Workspace.MODE_BOARD)};b._updateOpacity=function(){this.svgGroup.attr({opacity:!1===this.visible?0:1});this.visible&&this._setPosition()};b._updateShadow=function(){this.shadow&&Entry.Utils.colorDarken(this._schema.color,.7)};b._setMovable=function(){this.movable=null!==this.block.isMovable()?this.block.isMovable():void 0!==this._skeleton.movable?this._skeleton.movable:!0};b._setReadOnly=function(){this.readOnly=null!==this.block.isReadOnly()? -this.block.isReadOnly():void 0!==this._skeleton.readOnly?this._skeleton.readOnly:!1};b._setCopyable=function(){this.copyable=null!==this.block.isCopyable()?this.block.isCopyable():void 0!==this._skeleton.copyable?this._skeleton.copyable:!0};b.bumpAway=function(a,b){var c=this;a=a||15;b?window.setTimeout(function(){c._moveBy(a,a,!1)},b):c._moveBy(a,a,!1)};b.bindPrev=function(a){if(a){if(this._toLocalCoordinate(a.view._nextGroup),(a=a.getNextBlock())&&a!==this.block){var b=this.block.getLastBlock(); -b.view.magnet.next?a.view._toLocalCoordinate(b.view._nextGroup):(a.view._toGlobalCoordinate(),a.separate(),a.view.bumpAway(null,100))}}else if(a=this.block.getPrevBlock())this._toLocalCoordinate(a.view._nextGroup),(a=this.block.getNextBlock())&&a.view&&a.view._toLocalCoordinate(this._nextGroup)};b.getAbsoluteCoordinate=function(a){a=void 0!==a?a:this.dragMode;if(a===Entry.DRAG_MODE_DRAG)return{x:this.x,y:this.y};a=this.block.getThread().view.requestAbsoluteCoordinate(this);a.x+=this.x;a.y+=this.y; -return a};b.getBelowHeight=function(){return this.block.getThread().view.requestPartHeight(this)};b._updateDisplay=function(){this.svgGroup.attr({display:!1===this.display?"none":"block"});this.display&&this._setPosition()};b._updateColor=function(){var a=this._schema.color;this.block.deletable===Entry.Block.DELETABLE_FALSE_LIGHTEN&&(a=Entry.Utils.colorLighten(a));this._fillColor=a;this._path.attr({fill:a});this._updateContents()};b._updateContents=function(){for(var a=0;a \s+/g, -">").replace(/\s+ <=+-x/".split(""),u= -0;u \s+/g,">").replace(/\s+ <=+-x/".split(""),v=0;v 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 e||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(a){for(var b=this.getThreads(),c=[],e=0,f=b.length;e b&&(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.x,y:b.y+a.y}};b.truncate=function(){var a=String(this.getValue()),b=this.TEXT_LIMIT_LENGTH,c=a.substring(0,b);a.length>b&&(c+="...");return c};b.appendSvgOptionGroup=function(){return this._block.view.getBoard().svgGroup.elem("g")};b.getValue=function(){var a=this._block.params[this._index];if(this._contents&&this._contents.reference&&this._contents.reference.length){var b=this._contents.reference.concat();"%"===b[0][0]&&(a=this._block.params[parseInt(b.shift().substr(1))-1]);return a?a.getDataByPointer(b): +a}return a};b.setValue=function(a,b){if(this.value!=a){this.value=a;if(this._contents&&this._contents.reference&&this._contents.reference.length){var c=this._contents.reference.concat(),e=c.pop(),f=this._block.params[this._index];c.length&&"%"===c[0][0]&&(f=this._block.params[parseInt(c.shift().substr(1))-1]);c.length&&(f=f.getDataByPointer(c));f.params[e]=a}else 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.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:0 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"})};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, @@ -2527,86 +2515,28 @@ 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;e g.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;f c.endPoint)f=h+1;else{e=c.blocks;for(f=0;f a||b.splice(a,1))};b.raiseEvent=function(a,b,c){a=this._eventMap[a];var e=[];if(void 0!==a){for(var f=0;f a||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;c 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];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}}; @@ -2632,25 +2563,199 @@ 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= -this.svgGroup.elem("g"),this.svgThreadGroup.board=this,this.svgBlockGroup=this.svgGroup.elem("g"),this.svgBlockGroup.board=this)}; +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,d){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._scale=void 0===d?1:d;this.disableMouseEvent=this.visible=!0;this._svgId="renderView_"+(new Date).getTime();this._generateView();this.offset=this.svgDom.offset();this._minBlockOffsetX=0;this._setSize();this.svg=Entry.SVG(this._svgId,this.svgDom[0]);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);this.pattern=Entry.Utils.addBlockPattern(this.svg, +this.suffix).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-k.x,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,b=this.dragBlock;if(a&&b){this._magnetMap={};for(var c in b.magnet)if("next"!==c||void 0!==b.block.getLastBlock().view.magnet.next){var e=this._getCodeBlocks(a,c);e.sort(function(a,b){return a.point-b.point});e.unshift({point:-Number.MAX_VALUE,blocks:[]});for(var f=1;f h.point&&(h.blocks.push(k), +m++,h=e[m],h););delete g.startBlock}g.endPoint=Number.MAX_VALUE;e[f-1].endPoint=g.point}this._magnetMap[c]=e}}};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":case "boolean":f=this._getFieldMagnets;break;case "param":f=this._getOutputMagnets;break;default:return[]}for(var g=0;g c.endPoint)f=h+1;else{e=c.blocks;for(f=0;f 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 =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){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=[]};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"; (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(); } diff --git a/src/core/svg.js b/src/core/svg.js index e7bff50be8..e0d6e90431 100644 --- a/src/core/svg.js +++ b/src/core/svg.js @@ -13,8 +13,8 @@ goog.provide('Entry.SVG'); * @param {string} tag or html to construct dom element. * @param {?object} options include id, classes, parent etc. */ -Entry.SVG = function (id) { - var element = document.getElementById(id); +Entry.SVG = function (id , svgDom) { + var element = svgDom ? svgDom : document.getElementById(id); return Entry.SVG.createElement(element); }; @@ -51,6 +51,9 @@ Entry.SVG.createElement = function (tag, options) { el.remove = Entry.SVG.remove; el.removeAttr = Entry.SVG.removeAttr; + if (tag === "text") + el.setAttributeNS("http://www.w3.org/XML/1998/namespace", "xml:space","preserve"); + return el; }; diff --git a/src/css/components/block.less b/src/css/components/block.less index aebeaec4e0..b84f4968c6 100644 --- a/src/css/components/block.less +++ b/src/css/components/block.less @@ -266,3 +266,6 @@ svg .svgBlockGroup text { cursor: default; } +.guideGroup { + opacity: 0.3; +} diff --git a/src/engine.js b/src/engine.js index ae1f2c0956..1df9264e5a 100644 --- a/src/engine.js +++ b/src/engine.js @@ -65,6 +65,8 @@ Entry.Engine = function() { this._mouseMoved = false; } }.bind(this), 100) + + Entry.message = new Entry.Event(window); }; /** @@ -509,17 +511,19 @@ Entry.Engine.prototype.toggleRun = function() { if (Entry.type == 'mobile') this.view_.addClass('entryEngineBlueWorkspace'); - this.pauseButton.innerHTML = Lang.Workspace.pause; - this.runButton.addClass('run'); - this.runButton.addClass('entryRemove'); - this.stopButton.removeClass('entryRemove'); - if (this.pauseButton) - this.pauseButton.removeClass('entryRemove'); + if (this.runButton) { + this.pauseButton.innerHTML = Lang.Workspace.pause; + this.runButton.addClass('run'); + this.runButton.addClass('entryRemove'); + this.stopButton.removeClass('entryRemove'); + if (this.pauseButton) + this.pauseButton.removeClass('entryRemove'); - if (this.runButton2) - this.runButton2.addClass('entryRemove'); - if (this.stopButton2) - this.stopButton2.removeClass('entryRemove'); + if (this.runButton2) + this.runButton2.addClass('entryRemove'); + if (this.stopButton2) + this.stopButton2.removeClass('entryRemove'); + } if (!this.isUpdating) { Entry.engine.update(); @@ -564,15 +568,17 @@ Entry.Engine.prototype.toggleStop = function() { createjs.Sound.setVolume(1); createjs.Sound.stop(); this.view_.removeClass('entryEngineBlueWorkspace'); - this.runButton.removeClass('entryRemove'); - this.stopButton.addClass('entryRemove'); - if (this.pauseButton) - this.pauseButton.addClass('entryRemove'); + if (this.runButton) { + this.runButton.removeClass('entryRemove'); + this.stopButton.addClass('entryRemove'); + if (this.pauseButton) + this.pauseButton.addClass('entryRemove'); - if (this.runButton2) - this.runButton2.removeClass('entryRemove'); - if (this.stopButton2) - this.stopButton2.addClass('entryRemove'); + if (this.runButton2) + this.runButton2.removeClass('entryRemove'); + if (this.stopButton2) + this.stopButton2.addClass('entryRemove'); + } this.state = 'stop'; Entry.dispatchEvent('stop'); @@ -590,10 +596,12 @@ Entry.Engine.prototype.togglePause = function() { timer.pauseStart = (new Date()).getTime() else delete timer.pauseStart; this.state = 'run'; - this.pauseButton.innerHTML = Lang.Workspace.pause; - this.runButton.addClass('entryRemove'); - if (this.runButton2) - this.runButton2.addClass('entryRemove'); + if (this.runButton) { + this.pauseButton.innerHTML = Lang.Workspace.pause; + this.runButton.addClass('entryRemove'); + if (this.runButton2) + this.runButton2.addClass('entryRemove'); + } } else { this.state = 'pause'; if (!timer.isPaused) @@ -602,11 +610,13 @@ Entry.Engine.prototype.togglePause = function() { timer.pausedTime += (new Date()).getTime() - timer.pauseStart; timer.pauseStart = (new Date()).getTime(); } - this.pauseButton.innerHTML = Lang.Workspace.restart; - this.runButton.removeClass('entryRemove'); - this.stopButton.removeClass('entryRemove'); - if (this.runButton2) - this.runButton2.removeClass('entryRemove'); + if (this.runButton) { + this.pauseButton.innerHTML = Lang.Workspace.restart; + this.runButton.removeClass('entryRemove'); + this.stopButton.removeClass('entryRemove'); + if (this.runButton2) + this.runButton2.removeClass('entryRemove'); + } } }; @@ -614,8 +624,8 @@ Entry.Engine.prototype.togglePause = function() { * @param {string} eventName */ Entry.Engine.prototype.fireEvent = function(eventName) { - if (this.state == 'run') - Entry.container.mapEntityIncludeCloneOnScene(this.raiseEvent, eventName); + if (this.state !== 'run') return; + Entry.container.mapEntityIncludeCloneOnScene(this.raiseEvent, eventName); }; /** @@ -817,3 +827,9 @@ Entry.Engine.prototype.updateProjectTimer = function(value) { } }; + +Entry.Engine.prototype.raiseMessage = function(value) { + Entry.message.notify(Entry.variableContainer.getMessage(value)); + return Entry.container.mapEntityIncludeCloneOnScene( + this.raiseKeyEvent, ["when_message_cast", value]); +}; diff --git a/src/hw.js b/src/hw.js index cc0f7b2059..1101bbfd17 100644 --- a/src/hw.js +++ b/src/hw.js @@ -42,7 +42,8 @@ Entry.HW = function() { '8.1': Entry.Arduino, '10.1': Entry.Roborobo_Roduino, '10.2': Entry.Roborobo_SchoolKit, - '12.1': Entry.EV3 + '12.1': Entry.EV3, + 'B.1': Entry.Codestar }; }; @@ -224,7 +225,7 @@ p.closeConnection = function() { }; p.downloadConnector = function() { - var url = "http://download.play-entry.org/apps/Entry_HW_1.5.10_Setup.exe"; + var url = "http://download.play-entry.org/apps/Entry_HW_1.5.11_Setup.exe"; var win = window.open(url, '_blank'); win.focus(); }; diff --git a/src/painter2.js b/src/painter2.js index 883a4ba178..7cad9ebec5 100644 --- a/src/painter2.js +++ b/src/painter2.js @@ -2,6 +2,7 @@ Entry.Painter2 = function(view) { this.view = view; + this.baseUrl = Entry.painterBaseUrl || '/lib/literallycanvas/lib/img'; this.file = { id: Entry.generateHash(), @@ -22,7 +23,7 @@ Entry.Painter2 = function(view) { p.initialize = function() { if (this.lc) return; - var imgURL = '/lib/literallycanvas/lib/img'; + var imgURL = this.baseUrl; var bgImage = new Image(); bgImage.src = imgURL + '/transparent-pattern.png'; this.lc = LC.init(this.view, { diff --git a/src/playground.js b/src/playground.js index 7c9e0cdffe..55e4e19c18 100644 --- a/src/playground.js +++ b/src/playground.js @@ -1099,14 +1099,16 @@ Entry.Playground.prototype.changeViewMode = function(viewType) { view.addClass('entryRemove'); } - if (viewType == 'picture') { - this.painter.show() - if (!this.pictureView_.object || - this.pictureView_.object != this.object) { - this.pictureView_.object = this.object; - this.injectPicture(); - } - } else this.painter.hide() + if (Entry.pictureEditable) { + if (viewType == 'picture') { + this.painter.show() + if (!this.pictureView_.object || + this.pictureView_.object != this.object) { + this.pictureView_.object = this.object; + this.injectPicture(); + } + } else this.painter.hide() + } if (viewType == 'sound' && (!this.soundView_.object || this.soundView_.object != this.object)) { diff --git a/src/popup_helper.js b/src/popup_helper.js index 1171ae0ffd..e7c43ac501 100644 --- a/src/popup_helper.js +++ b/src/popup_helper.js @@ -36,21 +36,6 @@ Entry.popupHelper = function(reset) { } }); - this.body_.bind('touchstart', function(e) { - if(that.nowContent && ignoreCloseType.indexOf(that.nowContent.prop('type')) > -1) { - return; - } - var $target = $(e.target); - spanArea.forEach((function (className) { - if($target.hasClass(className)) { - this.popup.hide(); - } - }).bind(this)); - if (e.target==this) { - this.popup.hide(); - } - }); - window.popupHelper = this; this.body_.prop('popup', this); @@ -105,14 +90,6 @@ Entry.popupHelper.prototype.addPopup = function(key, popupObject) { }).bind(this)); var self = this; - - titleButton_.bind('touchstart', function() { - if(popupObject.closeEvent) { - popupObject.closeEvent(self); - } else { - self.hide(); - } - }); var popupWrapper_ = Entry.Dom('div', { class: 'entryPopupHelperWrapper' @@ -135,6 +112,7 @@ Entry.popupHelper.prototype.addPopup = function(key, popupObject) { if(typeof popupObject.setPopupLayout === 'function') { popupObject.setPopupLayout(content_); } + content_._obj = popupObject; this.popupList[key] = content_; }; @@ -175,8 +153,10 @@ Entry.popupHelper.prototype.show = function(key) { this.window_.append(this.popupList[key]); this.nowContent = this.popupList[key]; this.body_.removeClass('hiddenPopup'); -}; + if (this.nowContent && this.nowContent._obj && this.nowContent._obj.onShow) + this.nowContent._obj.onShow(); +}; Entry.popupHelper.prototype.hide = function() { this.nowContent = undefined; diff --git a/src/property_panel.js b/src/property_panel.js index c2dfea123d..047a2a6a64 100644 --- a/src/property_panel.js +++ b/src/property_panel.js @@ -127,6 +127,7 @@ Entry.PropertyPanel = function() { var that = this; splitter.bind('mousedown touchstart', function(e) { that._cover.removeClass('entryRemove'); + that._cover._isVisible = true; Entry.container.disableSort(); Entry.container.splitterEnable = true; if (Entry.documentMousemove) { @@ -145,9 +146,12 @@ Entry.PropertyPanel = function() { if (listener) { Entry.container.splitterEnable = false; Entry.documentMousemove.detach(listener); - that._cover.addClass('entryRemove'); delete Entry.container.resizeEvent; } + if (that._cover._isVisible) { + that._cover._isVisible = false; + that._cover.addClass('entryRemove'); + } Entry.container.enableSort(); }); }; diff --git a/src/util/contextmenu.js b/src/util/contextmenu.js index 367509729d..d3ec651dc2 100644 --- a/src/util/contextmenu.js +++ b/src/util/contextmenu.js @@ -51,13 +51,13 @@ goog.provide('Entry.ContextMenu'); span.text(text); if (enable && option.callback) { - (function(span, cb) { - span.mousedown(function(e){ + (function(elem, cb) { + elem.mousedown(function(e){ e.preventDefault(); that.hide(); cb(e); }); - })(span, option.callback); + })(elem, option.callback); } } elem.addClass(className); diff --git a/src/util/utils.js b/src/util/utils.js index c90fb68f17..fddb43f63f 100644 --- a/src/util/utils.js +++ b/src/util/utils.js @@ -1072,31 +1072,19 @@ Entry.Utils.addBlockPattern = function (boardSvgDom, suffix) { style: "display: none" }); - var group = pattern.elem('g'); - - //this rect should be controlled by the board - //according to the target block - var elem = group.elem("rect", { - x: 0, y: 0, - width: 125, - height: 33 - }); - var imagePath = Entry.mediaFilePath + 'block_pattern_(order).png'; + var order = '(order)'; for (var i=1; i<5; i++) { - group.elem("image", { + pattern.elem("image", { class: 'pattern' + i, - href: imagePath.replace('(order)', i), + href: imagePath.replace(order, i), x: 0, y: 0, width: 125, height: 33 }); } - return { - pattern: pattern, - rect: elem - } + return { pattern: pattern }; }; Entry.Utils.COLLISION = { diff --git a/src/variable_container.js b/src/variable_container.js index 59a5b2cb7f..730b10d712 100644 --- a/src/variable_container.js +++ b/src/variable_container.js @@ -228,6 +228,10 @@ Entry.VariableContainer.prototype.select = function(object) { } }; +Entry.VariableContainer.prototype.getMessage = function(messageId) { + return this.messages_.filter(function(m) {return m.id === messageId})[0] +} + /** * @param {object} message */ diff --git a/src/workspace/block.js b/src/workspace/block.js index f8a1626a80..bfe91d6ea5 100644 --- a/src/workspace/block.js +++ b/src/workspace/block.js @@ -53,7 +53,8 @@ Entry.Block.DELETABLE_FALSE_LIGHTEN = 3; deletable: Entry.Block.DELETABLE_TRUE, readOnly: null, copyable: true, - events: {} + events: {}, + extensions: [] }; p.load = function(block) { @@ -176,6 +177,7 @@ Entry.Block.DELETABLE_FALSE_LIGHTEN = 3; }; p.destroyView = function() { + this.view.destroy(); this.set({view: null}); }; @@ -186,7 +188,7 @@ Entry.Block.DELETABLE_FALSE_LIGHTEN = 3; ); }; - p.toJSON = function(isNew) { + p.toJSON = function(isNew, excludeData) { var json = this._toJSON(); delete json.view; delete json.thread; @@ -196,12 +198,12 @@ Entry.Block.DELETABLE_FALSE_LIGHTEN = 3; json.params = json.params.map(function(p) { if (p instanceof Entry.Block) - p = p.toJSON(isNew); + p = p.toJSON(isNew, excludeData); return p; }); json.statements = json.statements.map( - function(s) {return s.toJSON(isNew);} + function(s) {return s.toJSON(isNew, undefined, excludeData);} ); json.x = this.x; @@ -210,10 +212,17 @@ Entry.Block.DELETABLE_FALSE_LIGHTEN = 3; json.movable = this.movable; json.deletable = this.deletable; json.readOnly = this.readOnly; + + if (excludeData && excludeData instanceof Array) { + excludeData.forEach(function(i) { delete json[i]; }); + } + return json; }; - p.destroy = function(animate, next) { + p.destroy = function(animate, next, isNotForce) { + if (isNotForce && this.deletable !== Entry.Block.DELETABLE_TRUE) + return; var that = this; var params = this.params; if (params) { @@ -252,7 +261,7 @@ Entry.Block.DELETABLE_FALSE_LIGHTEN = 3; } else if (parent.constructor === Entry.FieldStatement) { nextBlock.replace(parent._valueBlock); } else nextBlock.view._toGlobalCoordinate(); - } else nextBlock.view && nextBlock.view.bindPrev(prevBlock); + } else nextBlock.view && nextBlock.view.bindPrev(prevBlock, true); } } if (!this.doNotSplice && thread.spliceBlock) thread.spliceBlock(this); @@ -464,6 +473,18 @@ Entry.Block.DELETABLE_FALSE_LIGHTEN = 3; return pointer; }; + p.getDataByPointer = function(pointer) { + pointer = pointer.concat() + var data = this.params[pointer.shift()]; + if (pointer.length) + if (data.getDataByPointer) + return data.getDataByPointer(pointer); + else + return null; + else + return data; + }; + p.getBlockList = function(excludePrimitive, type) { var blocks = []; var currentType = type || this.type; @@ -487,14 +508,17 @@ Entry.Block.DELETABLE_FALSE_LIGHTEN = 3; var statements = this.statements; if (statements) { for (var j = 0; j < statements.length; j++) { - blocks = blocks.concat(statements[j].getBlockList(excludePrimitive, type)); + var statement = statements[j]; + if (statement.constructor !== Entry.Thread) + continue; + blocks = blocks.concat(statement.getBlockList(excludePrimitive, type)); } } return blocks; }; - p.stringify = function() { - return JSON.stringify(this.toJSON()); + p.stringify = function(excludeData) { + return JSON.stringify(this.toJSON(false, excludeData)); }; })(Entry.Block.prototype); diff --git a/src/workspace/block_entry.js b/src/workspace/block_entry.js index 3f05e02e5b..17ded93556 100644 --- a/src/workspace/block_entry.js +++ b/src/workspace/block_entry.js @@ -2896,6 +2896,7 @@ Entry.block = { ] } }, + //2016-09-23 added start "CODEino_get_sensor_number": { "color": "#00979D", "skeleton": "basic_string_field", @@ -2925,8 +2926,7 @@ Entry.block = { }, "func": function (sprite, script) { return script.getStringField("PORT"); - }, - "syntax": {"js": [], "py": ["Codeino.sensor_number(%1)"]} + } }, "CODEino_get_named_sensor_value": { "color": "#00979D", @@ -2957,12 +2957,38 @@ Entry.block = { "paramsKeyMap": { "PORT": 0 }, - "class": "CODEino", + "class": "CODEino_sensor", "isNotFor": [ "CODEino" ], "func": function (sprite, script) { - return Entry.hw.getAnalogPortValue(script.getField("PORT", script)); - }, - "syntax": {"js": [], "py": ["Codeino.sensor_value(%1)"]} + var port = script.getField("PORT", script); + var nowTime = Entry.ArduinoExt.getSensorTime(Entry.ArduinoExt.sensorTypes.ANALOG); + var hardwareTime = Entry.hw.portData['TIME'] || 0; + var scope = script.executor.scope; + var ANALOG = Entry.hw.portData.ANALOG; + if(!scope.isStart) { + scope.isStart = true; + scope.stamp = nowTime; + Entry.hw.sendQueue['TIME'] = nowTime; + Entry.hw.sendQueue['KEY'] = Entry.ArduinoExt.getSensorKey(); + Entry.hw.sendQueue['GET'] = { + type: Entry.ArduinoExt.sensorTypes.ANALOG, + port: port + }; + throw new Entry.Utils.AsyncError(); + return; + } else if(hardwareTime && (hardwareTime === scope.stamp)) { + delete scope.isStart; + delete scope.stamp; + return (ANALOG) ? ANALOG[port] || 0 : 0; + } else if(nowTime - scope.stamp > 64) { + delete scope.isStart; + delete scope.stamp; + return (ANALOG) ? ANALOG[port] || 0 : 0; + } else { + throw new Entry.Utils.AsyncError(); + return; + } + } }, "CODEino_get_sound_status": { "color": "#00979D", @@ -2988,15 +3014,41 @@ Entry.block = { "paramsKeyMap": { "STATUS": 0 }, - "class": "CODEino", + "class": "CODEino_sensor", "isNotFor": [ "CODEino" ], "func": function (sprite, script) { var value1 = script.getField("STATUS", script); - var value2 = 0; - if (value1 == "GREAT") return Entry.hw.getAnalogPortValue(value2) > 600 ? 1 : 0; - else return Entry.hw.getAnalogPortValue(value2) < 600 ? 1 : 0; - }, - "syntax": {"js": [], "py": ["Codeino.sound_status(%1)"]} + var value2 = 1; + var nowTime = Entry.ArduinoExt.getSensorTime(Entry.ArduinoExt.sensorTypes.ANALOG); + var hardwareTime = Entry.hw.portData['TIME'] || 0; + var scope = script.executor.scope; + var ANALOG = Entry.hw.portData.ANALOG; + if(!scope.isStart) { + scope.isStart = true; + scope.stamp = nowTime; + Entry.hw.sendQueue['TIME'] = nowTime; + Entry.hw.sendQueue['KEY'] = Entry.ArduinoExt.getSensorKey(); + Entry.hw.sendQueue['GET'] = { + type: Entry.ArduinoExt.sensorTypes.ANALOG, + port: 0 + }; + throw new Entry.Utils.AsyncError(); + return; + } else if(hardwareTime && (hardwareTime === scope.stamp)) { + delete scope.isStart; + delete scope.stamp; + if (value1 == "GREAT") return ANALOG[0] > 600 ? 1 : 0; + else return ANALOG[0] <= 600 ? 1 : 0; + } else if(nowTime - scope.stamp > 64) { + delete scope.isStart; + delete scope.stamp; + if (value1 == "GREAT") return ANALOG[0] > 600 ? 1 : 0; + else return ANALOG[0] <= 600 ? 1 : 0; + } else { + throw new Entry.Utils.AsyncError(); + return; + } + } }, "CODEino_get_light_status": { "color": "#00979D", @@ -3022,15 +3074,41 @@ Entry.block = { "paramsKeyMap": { "STATUS": 0 }, - "class": "CODEino", + "class": "CODEino_sensor", "isNotFor": [ "CODEino" ], "func": function (sprite, script) { var value1 = script.getField("STATUS", script); var value2 = 1; - if (value1 == "DARK") return Entry.hw.getAnalogPortValue(value2) > 800 ? 1 : 0; - else return Entry.hw.getAnalogPortValue(value2) < 800 ? 1 : 0; - }, - "syntax": {"js": [], "py": ["Codeino.light_status(%1)"]} + var nowTime = Entry.ArduinoExt.getSensorTime(Entry.ArduinoExt.sensorTypes.ANALOG); + var hardwareTime = Entry.hw.portData['TIME'] || 0; + var scope = script.executor.scope; + var ANALOG = Entry.hw.portData.ANALOG; + if(!scope.isStart) { + scope.isStart = true; + scope.stamp = nowTime; + Entry.hw.sendQueue['TIME'] = nowTime; + Entry.hw.sendQueue['KEY'] = Entry.ArduinoExt.getSensorKey(); + Entry.hw.sendQueue['GET'] = { + type: Entry.ArduinoExt.sensorTypes.ANALOG, + port: 1 + }; + throw new Entry.Utils.AsyncError(); + return; + } else if(hardwareTime && (hardwareTime === scope.stamp)) { + delete scope.isStart; + delete scope.stamp; + if (value1 == "GREAT") return ANALOG[value2] < 800 ? 1 : 0; + else return ANALOG[value2] <= 800 ? 1 : 0; + } else if(nowTime - scope.stamp > 64) { + delete scope.isStart; + delete scope.stamp; + if (value1 == "GREAT") return ANALOG[value2] < 800 ? 1 : 0; + else return ANALOG[value2] <= 800 ? 1 : 0; + } else { + throw new Entry.Utils.AsyncError(); + return; + } + } }, "CODEino_is_button_pressed": { "color": "#00979D", @@ -3059,16 +3137,69 @@ Entry.block = { "paramsKeyMap": { "PORT": 0 }, - "class": "CODEino", + "class": "CODEino_sensor", "isNotFor": [ "CODEino" ], "func": function (sprite, script) { - var value = script.getNumberField("PORT", script); - if (value > 14) { - value = value - 14; - return !Entry.hw.getAnalogPortValue(value); - } else return !Entry.hw.getDigitalPortValue(value); - }, - "syntax": {"js": [], "py": ["Codeino.is_button_pressed(%1)"]} + var port = script.getNumberField("PORT", script); + if (port < 10) { + var nowTime = Entry.ArduinoExt.getSensorTime(Entry.ArduinoExt.sensorTypes.DIGITAL); + var hardwareTime = Entry.hw.portData['TIME'] || 0; + var scope = script.executor.scope; + var DIGITAL = Entry.hw.portData.DIGITAL; + if(!scope.isStart) { + scope.isStart = true; + scope.stamp = nowTime; + Entry.hw.sendQueue['TIME'] = nowTime; + Entry.hw.sendQueue['KEY'] = Entry.ArduinoExt.getSensorKey(); + Entry.hw.sendQueue['GET'] = { + type: Entry.ArduinoExt.sensorTypes.DIGITAL, + port: 4 + }; + throw new Entry.Utils.AsyncError(); + return; + } else if(hardwareTime && (hardwareTime === scope.stamp)) { + delete scope.isStart; + delete scope.stamp; + return (DIGITAL) ? !(DIGITAL[port] || 0): 0 ; + } else if(nowTime - scope.stamp > 64) { + delete scope.isStart; + delete scope.stamp; + return (DIGITAL) ? !(DIGITAL[port] || 0) : 0; + } else { + throw new Entry.Utils.AsyncError(); + return; + } + } else { + var nowTime = Entry.ArduinoExt.getSensorTime(Entry.ArduinoExt.sensorTypes.ANALOG); + var hardwareTime = Entry.hw.portData['TIME'] || 0; + var scope = script.executor.scope; + var ANALOG = Entry.hw.portData.ANALOG; + if(!scope.isStart) { + scope.isStart = true; + scope.stamp = nowTime; + Entry.hw.sendQueue['TIME'] = nowTime; + Entry.hw.sendQueue['KEY'] = Entry.ArduinoExt.getSensorKey(); + Entry.hw.sendQueue['GET'] = { + type: Entry.ArduinoExt.sensorTypes.ANALOG, + port: port - 14 + }; + throw new Entry.Utils.AsyncError(); + return; + } else if(hardwareTime && (hardwareTime === scope.stamp)) { + delete scope.isStart; + delete scope.stamp; + return ANALOG[port-14] < 1000 ? 1 : 0; + } else if(nowTime - scope.stamp > 64) { + delete scope.isStart; + delete scope.stamp; + return ANALOG[port-14] < 1000 ? 1 : 0; + + } else { + throw new Entry.Utils.AsyncError(); + return; + } + } + } }, "CODEino_get_accelerometer_direction": { "color": "#00979D", @@ -3097,31 +3228,66 @@ Entry.block = { "paramsKeyMap": { "DIRECTION": 0 }, - "class": "CODEino", + "class": "CODEino_sensor", "isNotFor": [ "CODEino" ], "func": function (sprite, script) { var value1 = script.getField("DIRECTION", script); - var value2 = 0; - if (value1 == "LEFT" || value1 =="RIGHT") value2 = 3; - else if (value1 == "FRONT" || value1 =="REAR") value2 = 4; - else if (value1 == "REVERSE") value2 = 5; - var value3 = Entry.hw.getAnalogPortValue(value2); + var port = 0; + var nowTime = Entry.ArduinoExt.getSensorTime(Entry.ArduinoExt.sensorTypes.ANALOG); + var hardwareTime = Entry.hw.portData['TIME'] || 0; + var scope = script.executor.scope; + var ANALOG = Entry.hw.portData.ANALOG; var value4 = 265; var value5 = 402; var value6 = -90; var value7 = 90; - var result = value3; - result -= value4; - result = result * ((value7 - value6) / (value5 - value4)); - result += value6; - result = Math.min(value7, result); - result = Math.max(value6, result); - result = Math.round(result); - if (value1 == "LEFT" || value1 == "REAR") return result < -30 ? 1 : 0; - else if (value1 == "RIGHT" || value1 == "FRONT") return result > 30 ? 1 : 0; - else if (value1 == "REVERSE") return result < -50 ? 1 : 0; - }, - "syntax": {"js": [], "py": ["Codeino.accelerometer_direction(%1)"]} + var result; + if (value1 == "LEFT" || value1 =="RIGHT") port = 3; + else if (value1 == "FRONT" || value1 =="REAR")port = 4; + else if (value1 == "REVERSE") port = 5; + + if(!scope.isStart) { + scope.isStart = true; + scope.stamp = nowTime; + Entry.hw.sendQueue['TIME'] = nowTime; + Entry.hw.sendQueue['KEY'] = Entry.ArduinoExt.getSensorKey(); + Entry.hw.sendQueue['GET'] = { + type: Entry.ArduinoExt.sensorTypes.ANALOG, + port: port + }; + throw new Entry.Utils.AsyncError(); + return; + } else if(hardwareTime && (hardwareTime === scope.stamp)) { + delete scope.isStart; + delete scope.stamp; + result = ANALOG[port]; + result -= value4; + result = result * ((value7 - value6) / (value5 - value4)); + result += value6; + result = Math.min(value7, result); + result = Math.max(value6, result); + result = Math.round(result); + if (value1 == "LEFT" || value1 == "REAR") return result < -30 ? 1 : 0; + else if (value1 == "RIGHT" || value1 == "FRONT") return result > 30 ? 1 : 0; + else if (value1 == "REVERSE") return result < -50 ? 1 : 0; + } else if(nowTime - scope.stamp > 64) { + delete scope.isStart; + delete scope.stamp; + result = ANALOG[port]; + result -= value4; + result = result * ((value7 - value6) / (value5 - value4)); + result += value6; + result = Math.min(value7, result); + result = Math.max(value6, result); + result = Math.round(result); + if (value1 == "LEFT" || value1 == "REAR") return result < -30 ? 1 : 0; + else if (value1 == "RIGHT" || value1 == "FRONT") return result > 30 ? 1 : 0; + else if (value1 == "REVERSE") return result < -50 ? 1 : 0; + } else { + throw new Entry.Utils.AsyncError(); + return; + } + } }, "CODEino_get_accelerometer_value": { "color": "#00979D", @@ -3148,51 +3314,63 @@ Entry.block = { "paramsKeyMap": { "PORT": 0 }, - "class": "CODEino", + "class": "CODEino_sensor", "isNotFor": [ "CODEino" ], "func": function (sprite, script) { - var value1 = Entry.hw.getAnalogPortValue(script.getField("PORT", script)); - var value2 = 265; - var value3 = 402; - var value4 = -90; - var value5 = 90; - var result = value1; - if (value2 > value3) { - var swap = value2; - value2 = value3; - value3 = swap; - } - if (value4 > value5) { - var swap = value4; - value4 = value5; - value5 = swap; + var port = script.getNumberField("PORT", script); + var nowTime = Entry.ArduinoExt.getSensorTime(Entry.ArduinoExt.sensorTypes.ANALOG); + var hardwareTime = Entry.hw.portData['TIME'] || 0; + var scope = script.executor.scope; + var ANALOG = Entry.hw.portData.ANALOG; + var result = 0; + if(!scope.isStart) { + scope.isStart = true; + scope.stamp = nowTime; + Entry.hw.sendQueue['TIME'] = nowTime; + Entry.hw.sendQueue['KEY'] = Entry.ArduinoExt.getSensorKey(); + Entry.hw.sendQueue['GET'] = { + type: Entry.ArduinoExt.sensorTypes.ANALOG, + port: port + }; + throw new Entry.Utils.AsyncError(); + return; + } else if(hardwareTime && (hardwareTime === scope.stamp)) { + delete scope.isStart; + delete scope.stamp; + result = ANALOG[port]; + result = (result - 333) * 1.46; + result = Math.min(90, result); + result = Math.max(-90, result); + return Math.round(result); + } else if(nowTime - scope.stamp > 64) { + delete scope.isStart; + delete scope.stamp; + result = ANALOG[port]; + result = (result - 333) * 1.46; + result = Math.min(90, result); + result = Math.max(-90, result); + return Math.round(result); + } else { + throw new Entry.Utils.AsyncError(); + return; } - result -= value2; - result = result * ((value5 - value4) / (value3 - value2)); - result += value4; - result = Math.min(value5, result); - result = Math.max(value4, result); - return Math.round(result); - }, - "syntax": {"js": [], "py": ["Codeino.accelerometer_value(%1)"]} + } }, - "nemoino_get_named_sensor_value": { + "CODEino_get_analog_value": { "color": "#00979D", "fontColor": "#fff", "skeleton": "basic_string_field", "statements": [], - "template": "%1 센서값", "params": [ { "type": "Dropdown", "options": [ - ["소리","0"], - ["빛","1"], - ["슬라이더","2"], - ["저항-A","3"], - ["저항-B","4"], - ["저항-C","5"], - ["저항-D","6"] + [ "0", "0" ], + [ "1", "1" ], + [ "2", "2" ], + [ "3", "3" ], + [ "4", "4" ], + [ "5", "5" ] ], "value": "0", "fontSize": 11 @@ -3201,176 +3379,281 @@ Entry.block = { "events": {}, "def": { "params": [ null ], - "type": "nemoino_get_named_sensor_value" + "type": "CODEino_get_analog_value" }, "paramsKeyMap": { "PORT": 0 }, - "class": "nemoino", - "isNotFor": [ "nemoino" ], + "class": "CODEino_Adumode", + "isNotFor": [ "CODEino" ], "func": function (sprite, script) { - return Entry.hw.getAnalogPortValue(script.getField("PORT", script)); + var port = script.getField("PORT", script); + var nowTime = Entry.ArduinoExt.getSensorTime(Entry.ArduinoExt.sensorTypes.ANALOG); + var hardwareTime = Entry.hw.portData['TIME'] || 0; + var scope = script.executor.scope; + var ANALOG = Entry.hw.portData.ANALOG; + if(!scope.isStart) { + scope.isStart = true; + scope.stamp = nowTime; + Entry.hw.sendQueue['TIME'] = nowTime; + Entry.hw.sendQueue['KEY'] = Entry.ArduinoExt.getSensorKey(); + Entry.hw.sendQueue['GET'] = { + type: Entry.ArduinoExt.sensorTypes.ANALOG, + port: port + }; + throw new Entry.Utils.AsyncError(); + return; + } else if(hardwareTime && (hardwareTime === scope.stamp)) { + delete scope.isStart; + delete scope.stamp; + return (ANALOG) ? ANALOG[port] || 0 : 0; + } else if(nowTime - scope.stamp > 64) { + delete scope.isStart; + delete scope.stamp; + return (ANALOG) ? ANALOG[port] || 0 : 0; + } else { + throw new Entry.Utils.AsyncError(); + return; + } } }, - "nemoino_get_sound_status": { + "CODEino_get_digital_value": { "color": "#00979D", "fontColor": "#fff", "skeleton": "basic_boolean_field", - "statements": [], - "template": "소리센서 %1", - "params": [ - { - "type": "Dropdown", - "options": [ - ["소리큼","GREAT"], - ["소리작음","SMALL"] - ], - "value": "GREAT", - "fontSize": 11 - } - ], + "params": [{ + "type": "Block", + "accept": "string" + }], "events": {}, "def": { - "params": [ null ], - "type": "nemoino_get_sound_status" + "params": [ + { + "type": "arduino_get_port_number" + } + ], + "type": "CODEino_get_digital_value" }, "paramsKeyMap": { - "STATUS": 0 + "PORT": 0 }, - "class": "nemoino", - "isNotFor": [ "nemoino" ], + "class": "CODEino_Adumode", + "isNotFor": [ "CODEino" ], "func": function (sprite, script) { - var value1 = script.getField("STATUS", script); - var value2 = 0; - if (value1 == "GREAT") return Entry.hw.getAnalogPortValue(value2) > 600 ? 1 : 0; - else return Entry.hw.getAnalogPortValue(value2) < 600 ? 1 : 0; + var port = script.getNumberValue("PORT", script); + var nowTime = Entry.ArduinoExt.getSensorTime(Entry.ArduinoExt.sensorTypes.DIGITAL); + var hardwareTime = Entry.hw.portData['TIME'] || 0; + var scope = script.executor.scope; + var DIGITAL = Entry.hw.portData.DIGITAL; + if(!scope.isStart) { + scope.isStart = true; + scope.stamp = nowTime; + Entry.hw.sendQueue['TIME'] = nowTime; + Entry.hw.sendQueue['KEY'] = Entry.ArduinoExt.getSensorKey(); + Entry.hw.sendQueue['GET'] = { + type: Entry.ArduinoExt.sensorTypes.DIGITAL, + port: port + }; + throw new Entry.Utils.AsyncError(); + return; + } else if(hardwareTime && (hardwareTime === scope.stamp)) { + delete scope.isStart; + delete scope.stamp; + return (DIGITAL) ? DIGITAL[port] || 0 : 0; + } else if(nowTime - scope.stamp > 64) { + delete scope.isStart; + delete scope.stamp; + return (DIGITAL) ? DIGITAL[port] || 0 : 0; + } else { + throw new Entry.Utils.AsyncError(); + return; + } } }, - "nemoino_is_button_pressed": { + "CODEino_set_digital_value": { "color": "#00979D", - "fontColor": "#fff", - "skeleton": "basic_boolean_field", + "skeleton": "basic", "statements": [], - "template": "보드의 %1", "params": [ + { + "type": "Block", + "accept": "string" + }, { "type": "Dropdown", "options": [ - ["버튼누름","4"], - ["A연결됨","17"], - ["B연결됨","18"], - ["C연결됨","19"], - ["D연결됨","20"] + [Lang.Blocks.ARDUINO_on,"255"], + [Lang.Blocks.ARDUINO_off,"0"] ], - "value": "4", - "fontSize": 11 + "fontSize": 11, + 'arrowColor': EntryStatic.ARROW_COLOR_HW + }, + { + "type": "Indicator", + "img": "block_icon/hardware_03.png", + "size": 12 } ], "events": {}, "def": { - "params": [ null ], - "type": "nemoino_is_button_pressed" + "params": [ + { + "type": "arduino_get_port_number" + }, + '255', + null + ], + "type": "CODEino_set_digital_value" }, "paramsKeyMap": { - "PORT": 0 + "PORT": 0, + "VALUE": 1 }, - "class": "nemoino", - "isNotFor": [ "nemoino" ], + "class": "CODEino_Setmode", + "isNotFor": [ "CODEino" ], "func": function (sprite, script) { - var value = script.getNumberField("PORT", script); - if (value > 14) { - value = value - 14; - return !Entry.hw.getAnalogPortValue(value); - } else return !Entry.hw.getDigitalPortValue(value); + var port = script.getNumberValue("PORT"); + var value = script.getNumberField("VALUE"); + var nowTime = Entry.ArduinoExt.getSensorTime(Entry.ArduinoExt.sensorTypes.DIGITAL); + Entry.hw.sendQueue['TIME'] = nowTime; + Entry.hw.sendQueue['KEY'] = Entry.ArduinoExt.getSensorKey(); + if(!Entry.hw.sendQueue['SET']) { + Entry.hw.sendQueue['SET'] = {}; + } + Entry.hw.sendQueue['SET'][port] = { + type: Entry.ArduinoExt.sensorTypes.DIGITAL, + data: value + }; + return script.callReturn(); } }, - "nemoino_get_accelerometer_direction": { + "CODEino_set_pwm_value": { "color": "#00979D", - "fontColor": "#fff", - "skeleton": "basic_boolean_field", + "skeleton": "basic", "statements": [], - "template": "3축 가속도센서 %1", "params": [ { - "type": "Dropdown", - "options": [ - ["왼쪽 기울임", "LEFT"], - ["오른쪽 기울임", "RIGHT"], - ["위쪽 기울임", "FRONT"], - ["아래쪽 기울임", "REAR"], - ["뒤집힘", "REVERSE"] - ], - "value": "LEFT", - "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": "nemoino_get_accelerometer_direction" + "params": [ + { + "type": "arduino_get_pwm_port_number" + }, + { + "type": "arduino_text", + "params": [ "255" ] + }, + null + ], + "type": "CODEino_set_pwm_value" }, "paramsKeyMap": { - "DIRECTION": 0 + "PORT": 0, + "VALUE": 1 }, - "class": "nemoino", - "isNotFor": [ "nemoino" ], + "class": "CODEino_Setmode", + "isNotFor": [ "CODEino" ], "func": function (sprite, script) { - var value1 = script.getField("DIRECTION", script); - var value2 = 0; - if (value1 == "LEFT" || value1 =="RIGHT") value2 = 3; - else if (value1 == "FRONT" || value1 =="REAR") value2 = 4; - else if (value1 == "REVERSE") value2 = 5; - var value3 = Entry.hw.getAnalogPortValue(value2); - var value4 = 265; - var value5 = 402; - var value6 = -90; - var value7 = 90; - var result = value3; - result -= value4; - result = result * ((value7 - value6) / (value5 - value4)); - result += value6; - result = Math.min(value7, result); - result = Math.max(value6, result); - result = Math.round(result); - if (value1 == "LEFT" || value1 == "REAR") return result < -30 ? 1 : 0; - else if (value1 == "RIGHT" || value1 == "FRONT") return result > 30 ? 1 : 0; - else if (value1 == "REVERSE") return result < -50 ? 1 : 0; + var port = script.getNumberValue("PORT"); + var value = script.getNumberValue("VALUE"); + value = Math.round(value); + value = Math.max(value, 0); + value = Math.min(value, 255); + var nowTime = Entry.ArduinoExt.getSensorTime(Entry.ArduinoExt.sensorTypes.PWM); + Entry.hw.sendQueue['TIME'] = nowTime; + Entry.hw.sendQueue['KEY'] = Entry.ArduinoExt.getSensorKey(); + if(!Entry.hw.sendQueue['SET']) { + Entry.hw.sendQueue['SET'] = {}; + } + Entry.hw.sendQueue['SET'][port] = { + type: Entry.ArduinoExt.sensorTypes.PWM, + data: value + }; + return script.callReturn(); } }, - "nemoino_get_accelerometer_value": { + "CODEino_convert_scale": { "color": "#00979D", "fontColor": "#fff", "skeleton": "basic_string_field", "statements": [], - "template": "3축 가속도센서 %1 축의 센서값", "params": [ { - "type": "Dropdown", - "options": [ - [ "X", "3" ], - [ "Y", "4" ], - [ "Z", "5" ] - ], - "value": "3", - "fontSize": 11 + "type": "Block", + "accept": "string" + }, + { + "type": "Block", + "accept": "string" + }, + { + "type": "Block", + "accept": "string" + }, + { + "type": "Block", + "accept": "string" + }, + { + "type": "Block", + "accept": "string" } ], "events": {}, "def": { - "params": [ null ], - "type": "nemoino_get_accelerometer_value" + "params": [ + { + "type": "CODEino_get_analog_value", + "value": "0" + + }, + { + "type": "number", + "params": [ "0" ] + }, + { + "type": "number", + "params": [ "1023" ] + }, + { + "type": "number", + "params": [ "0" ] + }, + { + "type": "number", + "params": [ "100" ] + } + ], + "type": "CODEino_convert_scale" }, "paramsKeyMap": { - "PORT": 0 + "VALUE1": 0, + "VALUE2": 1, + "VALUE3": 2, + "VALUE4": 3, + "VALUE5": 4 }, - "class": "nemoino", - "isNotFor": [ "nemoino" ], + "class": "CODEino_extmode", + "isNotFor": [ "CODEino" ], "func": function (sprite, script) { - var value1 = Entry.hw.getAnalogPortValue(script.getField("PORT", script)); - var value2 = 265; - var value3 = 402; - var value4 = -90; - var value5 = 90; + var value1 = script.getNumberValue("VALUE1", script); + var value2 = script.getNumberValue("VALUE2", script); + var value3 = script.getNumberValue("VALUE3", script); + var value4 = script.getNumberValue("VALUE4", script); + var value5 = script.getNumberValue("VALUE5", script); var result = value1; if (value2 > value3) { var swap = value2; @@ -3390,66 +3673,198 @@ Entry.block = { return Math.round(result); } }, - "bitbrick_sensor_value": { + "CODEino_set_rgb_value": { "color": "#00979D", - "fontColor": "#fff", - "skeleton": "basic_string_field", + "skeleton": "basic", "statements": [], - "params": [ - { - "type": "DropdownDynamic", - "value": null, - "fontSize": 11, - 'arrowColor': EntryStatic.ARROW_COLOR_HW, - menuName: Entry.Bitbrick.sensorList + "params": [{ + "type": "Dropdown", + "options": [ + [ "빨강", "17" ], + [ "초록", "18" ], + [ "파랑", "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 (sprite, script) { + var sq = Entry.hw.sendQueue; + var port = script.getNumberField("PORT", script); + var value = script.getNumberValue("VALUE", script); + value = Math.min(255, value); + value = Math.max(0, value); + + if (port == 17) { + CODEINO_RED = value; + } else if (port == 18){ + CODEINO_GREEN = value; + } else CODEINO_BLUE = value; + sq['TIME'] = Entry.ArduinoExt.getSensorTime(4); + sq['KEY'] = Entry.ArduinoExt.getSensorKey(); + if(!sq['SET']) { + sq['SET'] = {}; } - ], + sq['SET'][port] = { + type: 4, + data: value + }; + return script.callReturn(); + } + }, + "CODEino_set_rgb_add_value": { + "color": "#00979D", + "skeleton": "basic", + "statements": [], + "params": [{ + "type": "Dropdown", + "options": [ + [ "빨강", "17" ], + [ "초록", "18" ], + [ "파랑", "19" ] + ], + "value": "17", + "fontSize": 11 + }, { + "type": "Block", + "accept": "string" + }, { + "type": "Indicator", + "img": "block_icon/hardware_03.png", + "size": 12 + }], "events": {}, "def": { - "params": [ null ], - "type": "bitbrick_sensor_value" + + "type": "CODEino_set_rgb_add_value" }, "paramsKeyMap": { - "PORT": 0 + "PORT": 0, + "VALUE": 1 }, - "class": "condition", - "isNotFor": [ "bitbrick" ], + "class": "CODEino_RGBLED_mode", + "isNotFor": [ "CODEino" ], "func": function (sprite, script) { - var port = script.getStringField("PORT"); - return Entry.hw.portData[port].value; - }, - "syntax": {"js": [], "py": ["Bitbrick.sensor_value(%1)"]} + var sq = Entry.hw.sendQueue; + var port = script.getNumberField("PORT", script); + var value = script.getNumberValue("VALUE", script); + value = Math.min(255, value); + value = Math.max(0, value); + if (port == 17) { + CODEINO_RED = CODEINO_RED + value; + CODEINO_RED = Math.min(255, CODEINO_RED); + CODEINO_RED = Math.max(0, CODEINO_RED); + value = CODEINO_RED; + } + if (port == 18){ + CODEINO_GREEN = CODEINO_GREEN + value; + CODEINO_GREEN = Math.min(255, CODEINO_GREEN); + CODEINO_GREEN = Math.max(0, CODEINO_GREEN); + value = CODEINO_GREEN; + } + if (port == 19) { + CODEINO_BLUE = CODEINO_BLUE + value; + CODEINO_BLUE = Math.min(255, CODEINO_BLUE); + CODEINO_BLUE = Math.max(0, CODEINO_BLUE); + value = CODEINO_BLUE; + } + + sq['TIME'] = Entry.ArduinoExt.getSensorTime(4); + sq['KEY'] = Entry.ArduinoExt.getSensorKey(); + if(!sq['SET']) { + sq['SET'] = {}; + } + sq['SET'][port] = { + type: 4, + data: value + }; + return script.callReturn(); + } }, - "bitbrick_is_touch_pressed": { + "CODEino_rgb_set_color": { "color": "#00979D", - "fontColor": "#fff", - "skeleton": "basic_boolean_field", + "skeleton": "basic", "statements": [], "params": [ { - "type": "DropdownDynamic", - "value": null, - "fontSize": 11, - menuName: Entry.Bitbrick.touchList + "type": "Color" + }, + { + "type": "Indicator", + "img": "block_icon/brush_03.png", + "size": 12 } ], "events": {}, "def": { "params": [ null ], - "type": "bitbrick_is_touch_pressed" + "type": "CODEino_rgb_set_color" }, "paramsKeyMap": { - "PORT": 0 + "VALUE": 0 }, - "class": "condition", - "isNotFor": [ "bitbrick" ], + "class": "CODEino_RGBLED_mode", + "isNotFor": [ "CODEino" ], "func": function (sprite, script) { - return Entry.hw.portData[script.getStringField("PORT")].value === 0; - }, - "syntax": {"js": [], "py": ["Bitbrick.is_touch_pressed(%1)"]} + var value = script.getStringField("VALUE"); + CODEINO_RED = parseInt(value.substr(1,2), 16); + CODEINO_GREEN = parseInt(value.substr(3,2), 16); + CODEINO_BLUE = parseInt(value.substr(5,2), 16); + var sq = Entry.hw.sendQueue; + var port = 17; + sq['TIME'] = Entry.ArduinoExt.getSensorTime(4); + sq['KEY'] = Entry.ArduinoExt.getSensorKey(); + if(!sq['SET']) { + sq['SET'] = {}; + } + sq['SET'][port] = { + type: 4, + data: CODEINO_RED + }; + var sq = Entry.hw.sendQueue; + var port = 18; + sq['TIME'] = Entry.ArduinoExt.getSensorTime(4); + sq['KEY'] = Entry.ArduinoExt.getSensorKey(); + if(!sq['SET']) { + sq['SET'] = {}; + } + sq['SET'][port] = { + type: 4, + data: CODEINO_GREEN + }; + var sq = Entry.hw.sendQueue; + var port = 19; + sq['TIME'] = Entry.ArduinoExt.getSensorTime(4); + sq['KEY'] = Entry.ArduinoExt.getSensorKey(); + if(!sq['SET']) { + sq['SET'] = {}; + } + sq['SET'][port] = { + type: 4, + data: CODEINO_BLUE + }; + return script.callReturn(); + } }, - "bitbrick_turn_off_color_led": { + "CODEino_set_rgb_off": { "color": "#00979D", "skeleton": "basic", "statements": [], @@ -3463,20 +3878,51 @@ Entry.block = { "events": {}, "def": { "params": [ null ], - "type": "bitbrick_turn_off_color_led", - "id": "i3je" + "type": "CODEino_set_rgb_off" }, - "class": "condition", - "isNotFor": [ "bitbrick" ], + "class": "CODEino_RGBLED_mode", + "isNotFor": [ "CODEino" ], "func": function (sprite, script) { - Entry.hw.sendQueue["LEDR"] = 0; - Entry.hw.sendQueue["LEDG"] = 0; - Entry.hw.sendQueue["LEDB"] = 0; + var sq = Entry.hw.sendQueue; + CODEINO_RED = 0; + CODEINO_BLUE = 0; + CODEINO_GREEN = 0; + var port = 17; + sq['TIME'] = Entry.ArduinoExt.getSensorTime(4); + sq['KEY'] = Entry.ArduinoExt.getSensorKey(); + if(!sq['SET']) { + sq['SET'] = {}; + } + sq['SET'][port] = { + type: 4, + data: 0 + }; + var sq = Entry.hw.sendQueue; + var port = 18; + sq['TIME'] = Entry.ArduinoExt.getSensorTime(4); + sq['KEY'] = Entry.ArduinoExt.getSensorKey(); + if(!sq['SET']) { + sq['SET'] = {}; + } + sq['SET'][port] = { + type: 4, + data: 0 + }; + var sq = Entry.hw.sendQueue; + var port = 19; + sq['TIME'] = Entry.ArduinoExt.getSensorTime(4); + sq['KEY'] = Entry.ArduinoExt.getSensorKey(); + if(!sq['SET']) { + sq['SET'] = {}; + } + sq['SET'][port] = { + type: 4, + data: 0 + }; return script.callReturn(); - }, - "syntax": {"js": [], "py": ["Bitbrick.turn_off_color_led()"]} + } }, - "bitbrick_turn_on_color_led_by_rgb": { + "CODEino_set__led_by_rgb": { "color": "#00979D", "skeleton": "basic", "statements": [], @@ -3516,39 +3962,61 @@ Entry.block = { }, null ], - "type": "bitbrick_turn_on_color_led_by_rgb" + "type": "CODEino_set__led_by_rgb" }, "paramsKeyMap": { "rValue": 0, "gValue": 1, "bValue": 2 }, - "class": "condition", - "isNotFor": [ "bitbrick" ], + "class": "CODEino_RGBLED_mode", + "isNotFor": [ "CODEino" ], "func": function (sprite, script) { - var red = script.getNumberValue("rValue"), - green = script.getNumberValue("gValue"), - blue = script.getNumberValue("bValue"), - min = 0, - max = 255, - adjustor = Entry.adjustValueWithMaxMin, - sq = Entry.hw.sendQueue; + CODEINO_RED = script.getNumberValue("rValue"); + CODEINO_GREEN = script.getNumberValue("gValue"); + CODEINO_BLUE = script.getNumberValue("bValue"); + var sq = Entry.hw.sendQueue; + var port = 17; + sq['TIME'] = Entry.ArduinoExt.getSensorTime(4); + sq['KEY'] = Entry.ArduinoExt.getSensorKey(); + if(!sq['SET']) { + sq['SET'] = {}; + } + sq['SET'][port] = { + type: 4, + data: CODEINO_RED + }; + var sq = Entry.hw.sendQueue; + var port = 18; + sq['TIME'] = Entry.ArduinoExt.getSensorTime(4); + sq['KEY'] = Entry.ArduinoExt.getSensorKey(); + if(!sq['SET']) { + sq['SET'] = {}; + } + sq['SET'][port] = { + type: 4, + data: CODEINO_GREEN + }; + var sq = Entry.hw.sendQueue; + var port = 19; + sq['TIME'] = Entry.ArduinoExt.getSensorTime(4); + sq['KEY'] = Entry.ArduinoExt.getSensorKey(); + if(!sq['SET']) { + sq['SET'] = {}; + } + sq['SET'][port] = { + type: 4, + data: CODEINO_BLUE + }; + return script.callReturn(); - sq["LEDR"] = adjustor(red, min, max); - sq["LEDG"] = adjustor(green, min, max); - sq["LEDB"] = adjustor(blue, min, max); - return script.callReturn(); - }, - "syntax": {"js": [], "py": ["Bitbrick.color_led_by_rgb(%1, %2, %3)"]} + } }, - "bitbrick_turn_on_color_led_by_picker": { + "CODEino_led_by_value": { "color": "#00979D", "skeleton": "basic", "statements": [], "params": [ - { - "type": "Color" - }, { "type": "Indicator", "img": "block_icon/hardware_03.png", @@ -3558,327 +4026,412 @@ Entry.block = { "events": {}, "def": { "params": [ null ], - "type": "bitbrick_turn_on_color_led_by_picker" + "type": "CODEino_led_by_value" }, - "paramsKeyMap": { - "VALUE": 0 - }, - "class": "condition", - "isNotFor": [ "bitbrick" ], + "class": "CODEino_RGBLED_mode", + "isNotFor": [ "CODEino" ], "func": function (sprite, script) { - var port = script.getStringField("VALUE"); - Entry.hw.sendQueue["LEDR"] = parseInt(port.substr(1,2), 16); - Entry.hw.sendQueue["LEDG"] = parseInt(port.substr(3,2), 16); - Entry.hw.sendQueue["LEDB"] = parseInt(port.substr(5,2), 16); - return script.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 + var sq = Entry.hw.sendQueue; + var port = 17; + CODEINO_RED = 100; + CODEINO_GREEN = 100; + CODEINO_BLUE = 100; + sq['TIME'] = Entry.ArduinoExt.getSensorTime(4); + sq['KEY'] = Entry.ArduinoExt.getSensorKey(); + if(!sq['SET']) { + sq['SET'] = {}; } - ], - "events": {}, + sq['SET'][port] = { + type: 4, + data: 100 + }; + var sq = Entry.hw.sendQueue; + var port = 18; + sq['TIME'] = Entry.ArduinoExt.getSensorTime(4); + sq['KEY'] = Entry.ArduinoExt.getSensorKey(); + if(!sq['SET']) { + sq['SET'] = {}; + } + sq['SET'][port] = { + type: 4, + data: 100 + }; + var sq = Entry.hw.sendQueue; + var port = 19; + sq['TIME'] = Entry.ArduinoExt.getSensorTime(4); + sq['KEY'] = Entry.ArduinoExt.getSensorKey(); + if(!sq['SET']) { + sq['SET'] = {}; + } + sq['SET'][port] = { + type: 4, + data: 100 + }; + return script.callReturn(); + } + }, + //2016-09-23 added finish + //legacy + "CODEino_get_number_sensor_value": { + "parent": "arduino_get_number_sensor_value", + "isNotFor": [ + "CODEino" + ], "def": { "params": [ { - "type": "text", - "params": [ "0" ] + "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": "bitbrick_turn_on_color_led_by_value" - }, - "paramsKeyMap": { - "VALUE": 0 - }, - "class": "condition", - "isNotFor": [ "bitbrick" ], - "func": function (sprite, script) { - var value = script.getNumberValue("VALUE"); - var red, green, blue; - value = value % 200; - if ( value < 67 ) { - red = 200 - (value * 3); - green = value * 3; - blue = 0; - } else if ( value < 134 ) { - value = value - 67; - red = 0; - green = 200 - (value * 3); - blue = value * 3; - } else if ( value < 201 ) { - value = value - 134; - red = value * 3; - green = 0; - blue = 200 - (value * 3); - } - Entry.hw.sendQueue["LEDR"] = red; - Entry.hw.sendQueue["LEDG"] = green; - Entry.hw.sendQueue["LEDB"] = blue; - return script.callReturn(); + "type": "CODEino_toggle_led" }, - "syntax": {"js": [], "py": ["Bitbrick.color_led_by_value(%1)"]} + "class": "arduino_set", + "syntax": {"js": [], "py": ["hw.CODEino_toggle_led(%1)"]} }, - "bitbrick_buzzer": { - "color": "#00979D", - "skeleton": "basic", - "statements": [], - "params": [ - { - "type": "Block", - "accept": "string" - }, - { - "type": "Indicator", - "img": "block_icon/hardware_03.png", - "size": 12 - } + "CODEino_toggle_pwm": { + "parent": "arduino_toggle_pwm", + "isNotFor": [ + "CODEino" ], - "events": {}, "def": { "params": [ { - "type": "text", - "params": [ "60" ] + "type": "arduino_get_pwm_port_number" + }, + { + "type": "arduino_text", + "params": [ "255" ] }, null ], - "type": "bitbrick_buzzer" - }, - "paramsKeyMap": { - "VALUE": 0 - }, - "class": "condition", - "isNotFor": [ "bitbrick" ], - "func": function (sprite, script) { - if (!script.isStart) { - var value = script.getNumberValue("VALUE"); - Entry.hw.sendQueue["buzzer"] = value; - script.isStart = true; - return script; - } else { - Entry.hw.sendQueue["buzzer"] = 0; - delete script.isStart; - return script.callReturn(); - } + "type": "CODEino_toggle_pwm" }, - "syntax": {"js": [], "py": ["Bitbrick.buzzer(%1)"]} + "class": "arduino_set", + "syntax": {"js": [], "py": ["hw.CODEino_toggle_pwm(%1, %2)"]} }, - "bitbrick_turn_off_all_motors": { + "nemoino_get_named_sensor_value": { "color": "#00979D", - "skeleton": "basic", + "fontColor": "#fff", + "skeleton": "basic_string_field", "statements": [], + "template": "%1 센서값", "params": [ { - "type": "Indicator", - "img": "block_icon/hardware_03.png", - "size": 12 + "type": "Dropdown", + "options": [ + ["소리","0"], + ["빛","1"], + ["슬라이더","2"], + ["저항-A","3"], + ["저항-B","4"], + ["저항-C","5"], + ["저항-D","6"] + ], + "value": "0", + "fontSize": 11 } ], "events": {}, "def": { "params": [ null ], - "type": "bitbrick_turn_off_all_motors" + "type": "nemoino_get_named_sensor_value" }, - "class": "condition", - "isNotFor": [ "bitbrick" ], - "func": function (sprite, script) { - var sq = Entry.hw.sendQueue; - var bitbrick = Entry.Bitbrick; - bitbrick.servoList().map(function(servo){ - sq[servo[1]] = 0; - }); - bitbrick.dcList().map(function(dc){ - sq[dc[1]] = 128; - }); - return script.callReturn(); + "paramsKeyMap": { + "PORT": 0 }, - "syntax": {"js": [], "py": ["Bitbrick.turn_off_all_motors()"]} + "class": "nemoino", + "isNotFor": [ "nemoino" ], + "func": function (sprite, script) { + return Entry.hw.getAnalogPortValue(script.getField("PORT", script)); + } }, - "bitbrick_dc_speed": { + "nemoino_get_sound_status": { "color": "#00979D", - "skeleton": "basic", + "fontColor": "#fff", + "skeleton": "basic_boolean_field", "statements": [], + "template": "소리센서 %1", "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 + "type": "Dropdown", + "options": [ + ["소리큼","GREAT"], + ["소리작음","SMALL"] + ], + "value": "GREAT", + "fontSize": 11 } ], "events": {}, "def": { - "params": [ - null, - { - "type": "text", - "params": [ "60" ] - }, - null - ], - "type": "bitbrick_dc_speed" + "params": [ null ], + "type": "nemoino_get_sound_status" }, "paramsKeyMap": { - "PORT": 0, - "VALUE": 1 + "STATUS": 0 }, - "class": "condition", - "isNotFor": [ "bitbrick" ], + "class": "nemoino", + "isNotFor": [ "nemoino" ], "func": function (sprite, script) { - var value = script.getNumberValue("VALUE"); - value = Math.min(value, Entry.Bitbrick.dcMaxValue); - value = Math.max(value, Entry.Bitbrick.dcMinValue); - - Entry.hw.sendQueue[script.getStringField("PORT")] = - value + 128; - return script.callReturn(); - }, - "syntax": {"js": [], "py": ["Bitbrick.dc_speed(%1, %2)"]} + var value1 = script.getField("STATUS", script); + var value2 = 0; + if (value1 == "GREAT") return Entry.hw.getAnalogPortValue(value2) > 600 ? 1 : 0; + else return Entry.hw.getAnalogPortValue(value2) < 600 ? 1 : 0; + } }, - "bitbrick_dc_direction_speed": { + "nemoino_is_button_pressed": { "color": "#00979D", - "skeleton": "basic", + "fontColor": "#fff", + "skeleton": "basic_boolean_field", "statements": [], + "template": "보드의 %1", "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"] + ["버튼누름","4"], + ["A연결됨","17"], + ["B연결됨","18"], + ["C연결됨","19"], + ["D연결됨","20"] ], - "value": "CW", + "value": "4", "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" + "params": [ null ], + "type": "nemoino_is_button_pressed" }, "paramsKeyMap": { - "PORT": 0, - "DIRECTION": 1, - "VALUE": 2 + "PORT": 0 }, - "class": "condition", - "isNotFor": [ "bitbrick" ], + "class": "nemoino", + "isNotFor": [ "nemoino" ], "func": function (sprite, script) { - var isFront = script.getStringField("DIRECTION") === "CW"; - var value = script.getNumberValue("VALUE"); - value = Math.min(value, Entry.Bitbrick.dcMaxValue); - value = Math.max(value, 0); - - Entry.hw.sendQueue[script.getStringField("PORT")] = - isFront ? value + 128 : 128 - value; - return script.callReturn(); + var value = script.getNumberField("PORT", script); + if (value > 14) { + value = value - 14; + return !Entry.hw.getAnalogPortValue(value); + } else return !Entry.hw.getDigitalPortValue(value); + } + }, + "nemoino_get_accelerometer_direction": { + "color": "#00979D", + "fontColor": "#fff", + "skeleton": "basic_boolean_field", + "statements": [], + "template": "3축 가속도센서 %1", + "params": [ + { + "type": "Dropdown", + "options": [ + ["왼쪽 기울임", "LEFT"], + ["오른쪽 기울임", "RIGHT"], + ["위쪽 기울임", "FRONT"], + ["아래쪽 기울임", "REAR"], + ["뒤집힘", "REVERSE"] + ], + "value": "LEFT", + "fontSize": 11 + } + ], + "events": {}, + "def": { + "params": [ null ], + "type": "nemoino_get_accelerometer_direction" }, - "syntax": {"js": [], "py": ["Bitbrick.dc_direction_speed(%1, %2, %3)"]} + "paramsKeyMap": { + "DIRECTION": 0 + }, + "class": "nemoino", + "isNotFor": [ "nemoino" ], + "func": function (sprite, script) { + var value1 = script.getField("DIRECTION", script); + var value2 = 0; + if (value1 == "LEFT" || value1 =="RIGHT") value2 = 3; + else if (value1 == "FRONT" || value1 =="REAR") value2 = 4; + else if (value1 == "REVERSE") value2 = 5; + var value3 = Entry.hw.getAnalogPortValue(value2); + var value4 = 265; + var value5 = 402; + var value6 = -90; + var value7 = 90; + var result = value3; + result -= value4; + result = result * ((value7 - value6) / (value5 - value4)); + result += value6; + result = Math.min(value7, result); + result = Math.max(value6, result); + result = Math.round(result); + if (value1 == "LEFT" || value1 == "REAR") return result < -30 ? 1 : 0; + else if (value1 == "RIGHT" || value1 == "FRONT") return result > 30 ? 1 : 0; + else if (value1 == "REVERSE") return result < -50 ? 1 : 0; + } }, - "bitbrick_servomotor_angle": { + "nemoino_get_accelerometer_value": { "color": "#00979D", - "skeleton": "basic", + "fontColor": "#fff", + "skeleton": "basic_string_field", + "statements": [], + "template": "3축 가속도센서 %1 축의 센서값", + "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 (sprite, script) { + var value1 = Entry.hw.getAnalogPortValue(script.getField("PORT", script)); + var value2 = 265; + var value3 = 402; + var value4 = -90; + var value5 = 90; + var result = value1; + if (value2 > value3) { + var swap = value2; + value2 = value3; + value3 = swap; + } + if (value4 > value5) { + var swap = value4; + value4 = value5; + value5 = swap; + } + result -= value2; + result = result * ((value5 - value4) / (value3 - value2)); + result += value4; + result = Math.min(value5, result); + result = Math.max(value4, result); + return Math.round(result); + } + }, + "bitbrick_sensor_value": { + "color": "#00979D", + "fontColor": "#fff", + "skeleton": "basic_string_field", "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 + 'arrowColor': EntryStatic.ARROW_COLOR_HW, + menuName: Entry.Bitbrick.sensorList + } ], "events": {}, "def": { - "params": [ - null, - { - "type": "text", - "params": [ "100" ] - }, - null - ], - "type": "bitbrick_servomotor_angle" + "params": [ null ], + "type": "bitbrick_sensor_value" }, "paramsKeyMap": { - "PORT": 0, - "VALUE": 1 + "PORT": 0 }, "class": "condition", "isNotFor": [ "bitbrick" ], "func": function (sprite, script) { - var value = Entry.Bitbrick.servoMaxValue - (script.getNumberValue("VALUE") + 1); - value = Math.min(value, Entry.Bitbrick.servoMaxValue); - value = Math.max(value, Entry.Bitbrick.servoMinValue); - Entry.hw.sendQueue[script.getStringField("PORT")] = value; - return script.callReturn(); + var port = script.getStringField("PORT"); + return Entry.hw.portData[port].value; }, - "syntax": {"js": [], "py": ["Bitbrick.servomotor_angle(%1, %2)"]} + "syntax": {"js": [], "py": ["Bitbrick.sensor_value(%1)"]} }, - "bitbrick_convert_scale": { + "bitbrick_is_touch_pressed": { "color": "#00979D", "fontColor": "#fff", - "skeleton": "basic_string_field", + "skeleton": "basic_boolean_field", "statements": [], "params": [ { "type": "DropdownDynamic", "value": null, "fontSize": 11, - menuName: Entry.Bitbrick.sensorList - }, + menuName: Entry.Bitbrick.touchList + } + ], + "events": {}, + "def": { + "params": [ null ], + "type": "bitbrick_is_touch_pressed" + }, + "paramsKeyMap": { + "PORT": 0 + }, + "class": "condition", + "isNotFor": [ "bitbrick" ], + "func": function (sprite, script) { + return Entry.hw.portData[script.getStringField("PORT")].value === 0; + }, + "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 (sprite, script) { + Entry.hw.sendQueue["LEDR"] = 0; + Entry.hw.sendQueue["LEDG"] = 0; + Entry.hw.sendQueue["LEDB"] = 0; + return script.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" @@ -3892,696 +4445,712 @@ Entry.block = { "accept": "string" }, { - "type": "Block", - "accept": "string" + "type": "Indicator", + "img": "block_icon/hardware_03.png", + "size": 12 } ], "events": {}, "def": { "params": [ - null, { - "type": "number", - "params": [ "0" ] + "type": "text", + "params": [ "255" ] }, { - "type": "number", - "params": [ "1023" ] + "type": "text", + "params": [ "255" ] }, { - "type": "number", - "params": [ "-100" ] - }, - { - "type": "number", - "params": [ "100" ] - } + "type": "text", + "params": [ "255" ] + }, + null ], - "type": "bitbrick_convert_scale" + "type": "bitbrick_turn_on_color_led_by_rgb" }, "paramsKeyMap": { - "PORT": 0, - "VALUE2": 1, - "VALUE3": 2, - "VALUE4": 3, - "VALUE5": 4 + "rValue": 0, + "gValue": 1, + "bValue": 2 }, "class": "condition", "isNotFor": [ "bitbrick" ], "func": function (sprite, script) { - var port = script.getNumberField("PORT"); - var value1 = Entry.hw.portData[port].value; - var value2 = script.getNumberValue("VALUE2", script); - var value3 = script.getNumberValue("VALUE3", script); - var value4 = script.getNumberValue("VALUE4", script); - var value5 = script.getNumberValue("VALUE5", script); - var result = value1; - - if (value4 > value5) { - var swap = value4; - value4 = value5; - value5 = swap; - } + var red = script.getNumberValue("rValue"), + green = script.getNumberValue("gValue"), + blue = script.getNumberValue("bValue"), + min = 0, + max = 255, + adjustor = Entry.adjustValueWithMaxMin, + sq = Entry.hw.sendQueue; - result -= value2; - result = result * ((value5 - value4) / (value3 - value2)); - result += value4; - result = Math.min(value5, result); - result = Math.max(value4, result); - return Math.round(result); - }, - "syntax": {"js": [], "py": ["Bitbrick.convert_scale(%1, %2, %3, %4, %5)"]} - }, - "cobl_read_ultrason": { - color: "#00979D", - fontColor: "#fff", - skeleton: "basic_string_field", - template: "1. 초음파거리(0~400)", - def: { - type: "cobl_read_ultrason" - }, - class: "cobl", - isNotFor : [ "cobl" ], - func: function (sprite, script) { - return Entry.hw.getAnalogPortValue("ultrason"); - } - }, - "cobl_read_potenmeter": { - color: "#00979D", - fontColor: "#fff", - skeleton: "basic_string_field", - template: "2.가변저항(0~1023)", - def: { - type: "cobl_read_potenmeter" - }, - class: "cobl", - isNotFor : [ "cobl" ], - func: function(sprite, script) { - return Entry.hw.getAnalogPortValue("potenmeter"); - } - }, - "cobl_read_irread1": { - color: "#00979D", - fontColor: "#fff", - skeleton: "basic_string_field", - template: "3.적외선센서1(0~1023)", - def: { - type: "cobl_read_irread1" - }, - class: "cobl", - isNotFor : [ "cobl" ], - func: function(sprite, script) { - return Entry.hw.getAnalogPortValue("irread1"); - } - }, - "cobl_read_irread2": { - color: "#00979D", - fontColor: "#fff", - skeleton: "basic_string_field", - template: "4.적외선센서2(0~1023)", - def: { - type: "cobl_read_irread2" - }, - class: "cobl", - isNotFor : [ "cobl" ], - "func": function(sprite, script) { - return Entry.hw.getAnalogPortValue("irread2"); - } - }, - "cobl_read_joyx": { - color: "#00979D", - fontColor: "#fff", - skeleton: "basic_string_field", - template: "5.조이스틱X축(1, 0, -1)", - def: { - type: "cobl_read_joyx" - }, - class: "cobl", - isNotFor : [ "cobl" ], - "func": function(sprite, script) { - return Entry.hw.getAnalogPortValue("joyx"); - } - }, - "cobl_read_joyy": { - color: "#00979D", - fontColor: "#fff", - skeleton: "basic_string_field", - template: "6.조이스틱Y축(1, 0, -1)", - def: { - type: "cobl_read_joyy" - }, - class: "cobl", - isNotFor : [ "cobl" ], - "func": function(sprite, script) { - return Entry.hw.getAnalogPortValue("joyy"); - } - }, - "cobl_read_tilt": { - color: "#00979D", - fontColor: "#fff", - skeleton: "basic_string_field", - template: "7.기울기센서(0~4)", - def: { - type: "cobl_read_tilt" + sq["LEDR"] = adjustor(red, min, max); + sq["LEDG"] = adjustor(green, min, max); + sq["LEDB"] = adjustor(blue, min, max); + return script.callReturn(); }, - class: "cobl", - isNotFor : [ "cobl" ], - "func": function(sprite, script) { - return Entry.hw.getAnalogPortValue("tilt"); - } + "syntax": {"js": [], "py": ["Bitbrick.color_led_by_rgb(%1, %2, %3)"]} }, - "cobl_read_temps": { - color: "#00979D", - fontColor: "#fff", - skeleton: "basic_string_field", - template: "8.온도센서@포트%1", - params: [ + "bitbrick_turn_on_color_led_by_picker": { + "color": "#00979D", + "skeleton": "basic", + "statements": [], + "params": [ { - type: "Dropdown", - options: [ - [ "1", "1" ], - [ "2", "2" ], - ], - fontSize: 11 + "type": "Color" + }, + { + "type": "Indicator", + "img": "block_icon/hardware_03.png", + "size": 12 } ], - def: { - params: [ - "1" - ], - type: "cobl_read_temps" + "events": {}, + "def": { + "params": [ null ], + "type": "bitbrick_turn_on_color_led_by_picker" }, - paramsKeyMap: { - VALUE: 0 + "paramsKeyMap": { + "VALUE": 0 }, - class: "cobl", - isNotFor : [ "cobl" ], - "func": function(sprite, script) { - // console.log("-----temptest------") - //var signal = script.getField("VALUE", script); - var signal = script.getValue("VALUE", script); - if (signal == 1) - { - // console.log("-----temp1 selected "); - return Entry.hw.getAnalogPortValue("temps1"); - } - - if (signal == 2) - { - // console.log("-----temp2 selected "); - return Entry.hw.getAnalogPortValue("temps2"); - } - } + "class": "condition", + "isNotFor": [ "bitbrick" ], + "func": function (sprite, script) { + var port = script.getStringField("VALUE"); + Entry.hw.sendQueue["LEDR"] = parseInt(port.substr(1,2), 16); + Entry.hw.sendQueue["LEDG"] = parseInt(port.substr(3,2), 16); + Entry.hw.sendQueue["LEDB"] = parseInt(port.substr(5,2), 16); + return script.callReturn(); + }, + "syntax": {"js": [], "py": ["Bitbrick.color_led_by_picker(%1)"]} }, - "cobl_read_light": { - color: "#00979D", - fontColor: "#fff", - skeleton: "basic_string_field", - template: "9.빛센서@포트%1", - params: [ + "bitbrick_turn_on_color_led_by_value": { + "color": "#00979D", + "skeleton": "basic", + "statements": [], + "params": [ { - type: "Dropdown", - options: [ - [ "1", "1" ], - [ "2", "2" ], - ], - fontSize: 11 + "type": "Block", + "accept": "string" + }, + { + "type": "Indicator", + "img": "block_icon/hardware_03.png", + "size": 12 } ], - def: { - params: [ - "1" + "events": {}, + "def": { + "params": [ + { + "type": "text", + "params": [ "0" ] + }, + null ], - type: "cobl_read_light" + "type": "bitbrick_turn_on_color_led_by_value" }, - paramsKeyMap: { - VALUE: 0 + "paramsKeyMap": { + "VALUE": 0 }, - class: "cobl", - isNotFor : [ "cobl" ], - "func": function(sprite, script) { - var signal = script.getValue("VALUE", script); - if (signal == 1) - { - return Entry.hw.getAnalogPortValue("light1"); - } - - if (signal == 2) - { - return Entry.hw.getAnalogPortValue("light2"); + "class": "condition", + "isNotFor": [ "bitbrick" ], + "func": function (sprite, script) { + var value = script.getNumberValue("VALUE"); + var red, green, blue; + value = value % 200; + if ( value < 67 ) { + red = 200 - (value * 3); + green = value * 3; + blue = 0; + } else if ( value < 134 ) { + value = value - 67; + red = 0; + green = 200 - (value * 3); + blue = value * 3; + } else if ( value < 201 ) { + value = value - 134; + red = value * 3; + green = 0; + blue = 200 - (value * 3); } - } + Entry.hw.sendQueue["LEDR"] = red; + Entry.hw.sendQueue["LEDG"] = green; + Entry.hw.sendQueue["LEDB"] = blue; + return script.callReturn(); + }, + "syntax": {"js": [], "py": ["Bitbrick.color_led_by_value(%1)"]} }, - "cobl_read_btn": { - color: "#00979D", - fontColor: "#fff", - skeleton: "basic_boolean_field", - template: "10.버튼스위치@포트%1", - params: [ + "bitbrick_buzzer": { + "color": "#00979D", + "skeleton": "basic", + "statements": [], + "params": [ { - type: "Dropdown", - options: [ - [ "1", "1" ], - [ "2", "2" ], - ], - fontSize: 11 + "type": "Block", + "accept": "string" + }, + { + "type": "Indicator", + "img": "block_icon/hardware_03.png", + "size": 12 } ], - def: { - params: [ - "1" + "events": {}, + "def": { + "params": [ + { + "type": "text", + "params": [ "60" ] + }, + null ], - type: "cobl_read_btn" + "type": "bitbrick_buzzer" }, - paramsKeyMap: { - VALUE: 0 + "paramsKeyMap": { + "VALUE": 0 }, - class: "cobl", - isNotFor : [ "cobl" ], - "func": function(sprite, script) { - var signal = script.getValue("VALUE", script); - if (signal == 1) - { - return Entry.hw.getDigitalPortValue("btn1"); + "class": "condition", + "isNotFor": [ "bitbrick" ], + "func": function (sprite, script) { + if (!script.isStart) { + var value = script.getNumberValue("VALUE"); + Entry.hw.sendQueue["buzzer"] = value; + script.isStart = true; + return script; + } else { + Entry.hw.sendQueue["buzzer"] = 0; + delete script.isStart; + return script.callReturn(); } - - if (signal == 2) + }, + "syntax": {"js": [], "py": ["Bitbrick.buzzer(%1)"]} + }, + "bitbrick_turn_off_all_motors": { + "color": "#00979D", + "skeleton": "basic", + "statements": [], + "params": [ { - return Entry.hw.getDigitalPortValue("btn2"); + "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 (sprite, script) { + var sq = Entry.hw.sendQueue; + var bitbrick = Entry.Bitbrick; + bitbrick.servoList().map(function(servo){ + sq[servo[1]] = 0; + }); + bitbrick.dcList().map(function(dc){ + sq[dc[1]] = 128; + }); + return script.callReturn(); + }, + "syntax": {"js": [], "py": ["Bitbrick.turn_off_all_motors()"]} }, - "cobl_led_control": { - color: "#00979D", - fontColor: "#fff", - skeleton: "basic", - template: "11.무지개LED%1%2 %3", - params: [ + "bitbrick_dc_speed": { + "color": "#00979D", + "skeleton": "basic", + "statements": [], + "params": [ { - type: "Dropdown", - options: [ - ["1","1"], - ["2","2"], - ["3","3"] - ], - fontSize: 11 + "type": "DropdownDynamic", + "value": null, + "fontSize": 11, + menuName: Entry.Bitbrick.dcList }, { - type: "Dropdown", - options: [ - ["OFF","OFF"], - ["빨강","Red"], - ["주황","Orange"], - ["노랑","Yellow"], - ["초록","Green"], - ["파랑","Blue"], - ["남색","Dark Blue"], - ["보라","Purple"], - ["흰색","White"] - ], - fontSize: 11 + "type": "Block", + "accept": "string" }, { - type: "Indicator", - img: "block_icon/hardware_03.png", - size: 12 + "type": "Indicator", + "img": "block_icon/hardware_03.png", + "size": 12 } ], - def: { - params: [ - "1", - "OFF" + "events": {}, + "def": { + "params": [ + null, + { + "type": "text", + "params": [ "60" ] + }, + null ], - type: "cobl_led_control" + "type": "bitbrick_dc_speed" }, - paramsKeyMap: { - PORT: 0, - OPERATOR: 1 + "paramsKeyMap": { + "PORT": 0, + "VALUE": 1 }, - class: "cobl", - isNotFor : [ "cobl" ], - "func": function(sprite, script) { - var port = script.getStringField("PORT"); - var value = script.getStringField("OPERATOR"); - Entry.hw.setDigitalPortValue("RainBowLED_" + port, value); - Entry.hw.update(); - delete Entry.hw.sendQueue["RainBowLED_" + port]; + "class": "condition", + "isNotFor": [ "bitbrick" ], + "func": function (sprite, script) { + var value = script.getNumberValue("VALUE"); + value = Math.min(value, Entry.Bitbrick.dcMaxValue); + value = Math.max(value, Entry.Bitbrick.dcMinValue); + + Entry.hw.sendQueue[script.getStringField("PORT")] = + value + 128; return script.callReturn(); - } + }, + "syntax": {"js": [], "py": ["Bitbrick.dc_speed(%1, %2)"]} }, - "cobl_servo_angle_control": { - color: "#00979D", - fontColor: "#fff", - skeleton: "basic", - template: "12.각도모터 각도%1(15~165) %2", - params: [ + "bitbrick_dc_direction_speed": { + "color": "#00979D", + "skeleton": "basic", + "statements": [], + "params": [ { - type: "TextInput", - value: 0 + "type": "DropdownDynamic", + "value": null, + "fontSize": 11, + menuName: Entry.Bitbrick.dcList }, { - type: "Indicator", - img: "block_icon/hardware_03.png", - size: 12 + "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 } ], - def: { - type: "cobl_servo_angle_control" - }, - paramsKeyMap: { - VALUE: 0 + "events": {}, + "def": { + "params": [ + null, + null, + { + "type": "text", + "params": [ "100" ] + }, + null + ], + "type": "bitbrick_dc_direction_speed" }, - class: "cobl", - isNotFor : [ "cobl" ], - "func": function(sprite, script) { - var value = script.getNumberField("VALUE"); - value = Math.round(value); - value = Math.max(value, 15); - value = Math.min(value, 165); - - Entry.hw.setDigitalPortValue("Servo1", value); - Entry.hw.update(); - delete Entry.hw.sendQueue["Servo1"]; + "paramsKeyMap": { + "PORT": 0, + "DIRECTION": 1, + "VALUE": 2 + }, + "class": "condition", + "isNotFor": [ "bitbrick" ], + "func": function (sprite, script) { + var isFront = script.getStringField("DIRECTION") === "CW"; + var value = script.getNumberValue("VALUE"); + value = Math.min(value, Entry.Bitbrick.dcMaxValue); + value = Math.max(value, 0); + Entry.hw.sendQueue[script.getStringField("PORT")] = + isFront ? value + 128 : 128 - value; return script.callReturn(); - } + }, + "syntax": {"js": [], "py": ["Bitbrick.dc_direction_speed(%1, %2, %3)"]} }, - "cobl_melody": { - color: "#00979D", - fontColor: "#fff", - skeleton: "basic", - template: "13.멜로디%1 ,%2", - params: [ + "bitbrick_servomotor_angle": { + "color": "#00979D", + "skeleton": "basic", + "statements": [], + "params": [ { - type: "Dropdown", - options: [ - ["((낮은)솔","L_So"], - ["(낮은)솔#","L_So#"], - ["(낮은)라","L_La"], - ["(낮은)라#","L_La#"], - ["(낮은)시","L_Ti"], - ["도","Do"], - ["도#","Do#"], - ["레","Re"], - ["레#","Re#"], - ["미","Mi"], - ["파","Fa"], - ["파#","Fa#"], - ["솔","So"], - ["솔#","So#"], - ["라","La"], - ["라#","La#"], - ["시","Ti"], - ["(높은)도","H_Do"], - ["(높은)도#","H_Do#"], - ["(높은)레","H_Re"], - ["(높은)레#","H_Re#"], - ["(높은)미#","H_Mi"], - ["(높은)파","H_Fa"] - ], - fontSize: 11 + "type": "DropdownDynamic", + "value": null, + "fontSize": 11, + menuName: Entry.Bitbrick.servoList }, { - type: "Indicator", - img: "block_icon/hardware_03.png", - size: 12 + "type": "Block", + "accept": "string" + }, + { + "type": "Indicator", + "img": "block_icon/hardware_03.png", + "size": 12 } ], - def: { - params: [ - "Do" + "events": {}, + "def": { + "params": [ + null, + { + "type": "text", + "params": [ "100" ] + }, + null ], - type: "cobl_melody" + "type": "bitbrick_servomotor_angle" }, - paramsKeyMap: { - MELODY: 0 + "paramsKeyMap": { + "PORT": 0, + "VALUE": 1 }, - class: "cobl", - isNotFor : [ "cobl" ], - "func": function(sprite, script) { - var melody = script.getStringField("MELODY"); - - Entry.hw.setDigitalPortValue("Melody", melody); - Entry.hw.update(); - delete Entry.hw.sendQueue["Melody"]; - + "class": "condition", + "isNotFor": [ "bitbrick" ], + "func": function (sprite, script) { + var value = Entry.Bitbrick.servoMaxValue - (script.getNumberValue("VALUE") + 1); + value = Math.min(value, Entry.Bitbrick.servoMaxValue); + value = Math.max(value, Entry.Bitbrick.servoMinValue); + Entry.hw.sendQueue[script.getStringField("PORT")] = value; return script.callReturn(); - } + }, + "syntax": {"js": [], "py": ["Bitbrick.servomotor_angle(%1, %2)"]} }, - "cobl_dcmotor": { - color: "#00979D", - fontColor: "#fff", - skeleton: "basic", - template: "14.회전모터%1%2속도%3 %4", - params: [ + "bitbrick_convert_scale": { + "color": "#00979D", + "fontColor": "#fff", + "skeleton": "basic_string_field", + "statements": [], + "params": [ { - type: "Dropdown", - options: [ - ["1","1"], - ["2","2"] - ], - fontSize: 11 + "type": "DropdownDynamic", + "value": null, + "fontSize": 11, + menuName: Entry.Bitbrick.sensorList }, { - type: "Dropdown", - options: [ - ["1.시계방향","1"], - ["2.반시계방향","2"], - ["3.정지","3"] - ], - fontSize: 11 + "type": "Block", + "accept": "string" }, { - type: "Dropdown", - options: [ - ["1","1"], - ["2","2"], - ["3","3"], - ["4","4"], - ["5","5"] - ], - fontSize: 11 + "type": "Block", + "accept": "string" }, { - type: "Indicator", - img: "block_icon/hardware_03.png", - size: 12 + "type": "Block", + "accept": "string" + }, + { + "type": "Block", + "accept": "string" } ], - def: { - params: [ - "1", - "1", - "1" + "events": {}, + "def": { + "params": [ + null, + { + "type": "number", + "params": [ "0" ] + }, + { + "type": "number", + "params": [ "1023" ] + }, + { + "type": "number", + "params": [ "-100" ] + }, + { + "type": "number", + "params": [ "100" ] + } ], - type: "cobl_dcmotor" + "type": "bitbrick_convert_scale" }, - paramsKeyMap: { - MOTOR: 0, - DIRECTION: 1, - SPEED:2 + "paramsKeyMap": { + "PORT": 0, + "VALUE2": 1, + "VALUE3": 2, + "VALUE4": 3, + "VALUE5": 4 }, - class: "cobl", - isNotFor : [ "cobl" ], - "func": function(sprite, script) { - var motor = script.getStringField("MOTOR"); - var direction = script.getStringField("DIRECTION"); - var speed = script.getStringField("SPEED"); - - if (motor == 1) { - Entry.hw.setDigitalPortValue("DC1_DIR", direction); - Entry.hw.setDigitalPortValue("DC1_SPEED", speed); - Entry.hw.update(); - delete Entry.hw.sendQueue["DC1_DIR"]; - delete Entry.hw.sendQueue["DC1_SPEED"]; - } + "class": "condition", + "isNotFor": [ "bitbrick" ], + "func": function (sprite, script) { + var port = script.getNumberField("PORT"); + var value1 = Entry.hw.portData[port].value; + var value2 = script.getNumberValue("VALUE2", script); + var value3 = script.getNumberValue("VALUE3", script); + var value4 = script.getNumberValue("VALUE4", script); + var value5 = script.getNumberValue("VALUE5", script); + var result = value1; - if (motor == 2) { - Entry.hw.setDigitalPortValue("DC2_DIR", direction); - Entry.hw.setDigitalPortValue("DC2_SPEED", speed); - Entry.hw.update(); - delete Entry.hw.sendQueue["DC2_DIR"]; - delete Entry.hw.sendQueue["DC2_SPEED"]; + if (value4 > value5) { + var swap = value4; + value4 = value5; + value5 = swap; } - return script.callReturn(); - } - }, - "cobl_extention_port": { + result -= value2; + result = result * ((value5 - value4) / (value3 - value2)); + result += value4; + result = Math.min(value5, result); + result = Math.max(value4, result); + return Math.round(result); + }, + "syntax": {"js": [], "py": ["Bitbrick.convert_scale(%1, %2, %3, %4, %5)"]} + }, + "cobl_read_ultrason": { color: "#00979D", fontColor: "#fff", - skeleton: "basic", - template: "15.USB포트%1단계%2 %3", + skeleton: "basic_string_field", + template: "1. 초음파거리(0~400)", + def: { + type: "cobl_read_ultrason" + }, + class: "cobl", + isNotFor : [ "cobl" ], + func: function (sprite, script) { + return Entry.hw.getAnalogPortValue("ultrason"); + } + }, + "cobl_read_potenmeter": { + color: "#00979D", + fontColor: "#fff", + skeleton: "basic_string_field", + template: "2.가변저항(0~1023)", + def: { + type: "cobl_read_potenmeter" + }, + class: "cobl", + isNotFor : [ "cobl" ], + func: function(sprite, script) { + return Entry.hw.getAnalogPortValue("potenmeter"); + } + }, + "cobl_read_irread1": { + color: "#00979D", + fontColor: "#fff", + skeleton: "basic_string_field", + template: "3.적외선센서1(0~1023)", + def: { + type: "cobl_read_irread1" + }, + class: "cobl", + isNotFor : [ "cobl" ], + func: function(sprite, script) { + return Entry.hw.getAnalogPortValue("irread1"); + } + }, + "cobl_read_irread2": { + color: "#00979D", + fontColor: "#fff", + skeleton: "basic_string_field", + template: "4.적외선센서2(0~1023)", + def: { + type: "cobl_read_irread2" + }, + class: "cobl", + isNotFor : [ "cobl" ], + "func": function(sprite, script) { + return Entry.hw.getAnalogPortValue("irread2"); + } + }, + "cobl_read_joyx": { + color: "#00979D", + fontColor: "#fff", + skeleton: "basic_string_field", + template: "5.조이스틱X축(1, 0, -1)", + def: { + type: "cobl_read_joyx" + }, + class: "cobl", + isNotFor : [ "cobl" ], + "func": function(sprite, script) { + return Entry.hw.getAnalogPortValue("joyx"); + } + }, + "cobl_read_joyy": { + color: "#00979D", + fontColor: "#fff", + skeleton: "basic_string_field", + template: "6.조이스틱Y축(1, 0, -1)", + def: { + type: "cobl_read_joyy" + }, + class: "cobl", + isNotFor : [ "cobl" ], + "func": function(sprite, script) { + return Entry.hw.getAnalogPortValue("joyy"); + } + }, + "cobl_read_tilt": { + color: "#00979D", + fontColor: "#fff", + skeleton: "basic_string_field", + template: "7.기울기센서(0~4)", + def: { + type: "cobl_read_tilt" + }, + class: "cobl", + isNotFor : [ "cobl" ], + "func": function(sprite, script) { + return Entry.hw.getAnalogPortValue("tilt"); + } + }, + "cobl_read_temps": { + color: "#00979D", + fontColor: "#fff", + skeleton: "basic_string_field", + template: "8.온도센서@포트%1", 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"] + [ "1", "1" ], + [ "2", "2" ], ], fontSize: 11 - }, - { - type: "Indicator", - img: "block_icon/hardware_03.png", - size: 12 } ], def: { params: [ - "1", - "0" + "1" ], - type: "cobl_extention_port" + type: "cobl_read_temps" }, paramsKeyMap: { - PORT: 0, - LEVEL: 1 + VALUE: 0 }, class: "cobl", isNotFor : [ "cobl" ], "func": function(sprite, script) { - var port = script.getStringField("PORT"); - var level = script.getStringField("LEVEL"); - - if(port == 1){ - Entry.hw.setDigitalPortValue("EXUSB1", level); - Entry.hw.update(); - delete Entry.hw.sendQueue["EXUSB1"]; + // console.log("-----temptest------") + //var signal = script.getField("VALUE", script); + var signal = script.getValue("VALUE", script); + if (signal == 1) + { + // console.log("-----temp1 selected "); + return Entry.hw.getAnalogPortValue("temps1"); } - if(port == 2){ - Entry.hw.setDigitalPortValue("EXUSB2", level); - Entry.hw.update(); - delete Entry.hw.sendQueue["EXUSB2"]; + if (signal == 2) + { + // console.log("-----temp2 selected "); + return Entry.hw.getAnalogPortValue("temps2"); } - return script.callReturn(); } }, - "cobl_external_led": { + "cobl_read_light": { color: "#00979D", fontColor: "#fff", - skeleton: "basic", - template: "16.외부LED%1(1~64)R%2G%3B%4 %5", + skeleton: "basic_string_field", + template: "9.빛센서@포트%1", 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"] + [ "1", "1" ], + [ "2", "2" ], ], fontSize: 11 - }, - { - type: "Indicator", - img: "block_icon/hardware_03.png", - size: 12 } ], def: { params: [ - "1", - "1", - "1", "1" ], - type: "cobl_external_led" + type: "cobl_read_light" }, paramsKeyMap: { - LED: 0, - RED: 1, - GREEN : 2, - BLUE : 3 + VALUE: 0 }, class: "cobl", isNotFor : [ "cobl" ], "func": function(sprite, script) { - var led = script.getNumberField("LED"); - var r = script.getStringField("RED"); - var g = script.getStringField("GREEN"); - var b = script.getStringField("BLUE"); - - Entry.hw.setDigitalPortValue("ELED_IDX", led); - Entry.hw.setDigitalPortValue("ELED_R", r); - Entry.hw.setDigitalPortValue("ELED_G", g); - Entry.hw.setDigitalPortValue("ELED_B", b); - 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"]; + var signal = script.getValue("VALUE", script); + if (signal == 1) + { + return Entry.hw.getAnalogPortValue("light1"); + } - return script.callReturn(); + if (signal == 2) + { + return Entry.hw.getAnalogPortValue("light2"); + } } }, - "cobl_7_segment": { + "cobl_read_btn": { + color: "#00979D", + fontColor: "#fff", + skeleton: "basic_boolean_field", + template: "10.버튼스위치@포트%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(sprite, script) { + var signal = script.getValue("VALUE", script); + if (signal == 1) + { + return Entry.hw.getDigitalPortValue("btn1"); + } + + if (signal == 2) + { + return Entry.hw.getDigitalPortValue("btn2"); + } + } + }, + "cobl_led_control": { color: "#00979D", fontColor: "#fff", skeleton: "basic", - template: "17.숫자전광판%1(0~9999) %2", + template: "11.무지개LED%1%2 %3", params: [ { - type: "TextInput", - value: 0 + type: "Dropdown", + options: [ + ["1","1"], + ["2","2"], + ["3","3"] + ], + fontSize: 11 + }, + { + type: "Dropdown", + options: [ + ["OFF","OFF"], + ["빨강","Red"], + ["주황","Orange"], + ["노랑","Yellow"], + ["초록","Green"], + ["파랑","Blue"], + ["남색","Dark Blue"], + ["보라","Purple"], + ["흰색","White"] + ], + fontSize: 11 }, { type: "Indicator", @@ -4590,324 +5159,408 @@ Entry.block = { } ], def: { - type: "cobl_7_segment" + params: [ + "1", + "OFF" + ], + type: "cobl_led_control" }, paramsKeyMap: { - VALUE: 0 + PORT: 0, + OPERATOR: 1 }, class: "cobl", isNotFor : [ "cobl" ], "func": function(sprite, script) { - var value = script.getNumberField("VALUE"); - Entry.hw.setDigitalPortValue("7SEG", value); + var port = script.getStringField("PORT"); + var value = script.getStringField("OPERATOR"); + Entry.hw.setDigitalPortValue("RainBowLED_" + port, value); Entry.hw.update(); - delete Entry.hw.sendQueue["7SEG"]; + delete Entry.hw.sendQueue["RainBowLED_" + port]; return script.callReturn(); } }, - "start_drawing": { - "color": "#FF9E20", - "skeleton": "basic", - "statements": [], - "params": [ + "cobl_servo_angle_control": { + color: "#00979D", + fontColor: "#fff", + skeleton: "basic", + template: "12.각도모터 각도%1(15~165) %2", + 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 (sprite, script) { - - if (sprite.brush) - sprite.brush.stop = false; - else - Entry.setBasicBrush(sprite); - - Entry.stage.sortZorder(); - sprite.brush.moveTo(sprite.getX(), sprite.getY()*-1); - - return script.callReturn(); - }, - "syntax": {"js": [], "py": ["Entry.start_drawing()"]} - }, - "stop_drawing": { - "color": "#FF9E20", - "skeleton": "basic", - "statements": [], - "params": [ + type: "TextInput", + value: 0 + }, { - "type": "Indicator", - "img": "block_icon/brush_03.png", - "size": 12 + type: "Indicator", + img: "block_icon/hardware_03.png", + size: 12 } ], - "events": {}, - "def": { - "params": [ null ], - "type": "stop_drawing" + def: { + type: "cobl_servo_angle_control" }, - "class": "brush_control", - "isNotFor": [ "textBox" ], - "func": function (sprite, script) { - if (sprite.brush && sprite.shape) - sprite.brush.stop = true; + paramsKeyMap: { + VALUE: 0 + }, + class: "cobl", + isNotFor : [ "cobl" ], + "func": function(sprite, script) { + var value = script.getNumberField("VALUE"); + value = Math.round(value); + value = Math.max(value, 15); + value = Math.min(value, 165); + + Entry.hw.setDigitalPortValue("Servo1", value); + Entry.hw.update(); + delete Entry.hw.sendQueue["Servo1"]; return script.callReturn(); - }, - "syntax": {"js": [], "py": ["Entry.stop_drawing()"]} + } }, - "set_color": { - "color": "#FF9E20", - "skeleton": "basic", - "statements": [], - "params": [ + "cobl_melody": { + color: "#00979D", + fontColor: "#fff", + skeleton: "basic", + template: "13.멜로디%1 ,%2", + params: [ { - "type": "Color" + type: "Dropdown", + options: [ + ["((낮은)솔","L_So"], + ["(낮은)솔#","L_So#"], + ["(낮은)라","L_La"], + ["(낮은)라#","L_La#"], + ["(낮은)시","L_Ti"], + ["도","Do"], + ["도#","Do#"], + ["레","Re"], + ["레#","Re#"], + ["미","Mi"], + ["파","Fa"], + ["파#","Fa#"], + ["솔","So"], + ["솔#","So#"], + ["라","La"], + ["라#","La#"], + ["시","Ti"], + ["(높은)도","H_Do"], + ["(높은)도#","H_Do#"], + ["(높은)레","H_Re"], + ["(높은)레#","H_Re#"], + ["(높은)미#","H_Mi"], + ["(높은)파","H_Fa"] + ], + fontSize: 11 }, { - "type": "Indicator", - "img": "block_icon/brush_03.png", - "size": 12 + type: "Indicator", + img: "block_icon/hardware_03.png", + size: 12 } ], - "events": {}, - "def": { - "params": [ null ], - "type": "set_color" + def: { + params: [ + "Do" + ], + type: "cobl_melody" }, - "paramsKeyMap": { - "VALUE": 0 + paramsKeyMap: { + MELODY: 0 }, - "class": "brush_color", - "isNotFor": [ "textBox" ], - "func": function (sprite, script) { - var colour = script.getField("VALUE", script); - - if (!sprite.brush) { - Entry.setBasicBrush(sprite); - sprite.brush.stop = true; - } - - if (sprite.brush) { - var rgb = Entry.hex2rgb(colour); - sprite.brush.rgb = rgb; - sprite.brush.endStroke(); - sprite.brush.beginStroke("rgba("+rgb.r+","+rgb.g+","+rgb.b+","+(sprite.brush.opacity/100)+")"); + class: "cobl", + isNotFor : [ "cobl" ], + "func": function(sprite, script) { + var melody = script.getStringField("MELODY"); - sprite.brush.moveTo(sprite.getX(), sprite.getY()*-1); - } + Entry.hw.setDigitalPortValue("Melody", melody); + Entry.hw.update(); + delete Entry.hw.sendQueue["Melody"]; return script.callReturn(); - }, - "syntax": {"js": [], "py": ["Entry.set_brush_color(%1)"]} + } }, - "set_random_color": { - "color": "#FF9E20", - "skeleton": "basic", - "statements": [], - "params": [ + "cobl_dcmotor": { + color: "#00979D", + fontColor: "#fff", + skeleton: "basic", + template: "14.회전모터%1%2속도%3 %4", + 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 (sprite, script) { - if (!sprite.brush) { - Entry.setBasicBrush(sprite); - sprite.brush.stop = true; - } - - if (sprite.brush) { - var rgb = Entry.generateRgb(); - sprite.brush.rgb = rgb; - sprite.brush.endStroke(); - sprite.brush.beginStroke("rgba("+rgb.r+","+rgb.g+","+rgb.b+","+(sprite.brush.opacity/100)+")"); - - sprite.brush.moveTo(sprite.getX(), sprite.getY()*-1); - } - return script.callReturn(); - }, - "syntax": {"js": [], "py": ["Entry.set_brush_color_random()"]} - }, - "change_thickness": { - "color": "#FF9E20", - "skeleton": "basic", - "statements": [], - "params": [ + type: "Dropdown", + options: [ + ["1","1"], + ["2","2"] + ], + fontSize: 11 + }, { - "type": "Block", - "accept": "string" + type: "Dropdown", + options: [ + ["1.시계방향","1"], + ["2.반시계방향","2"], + ["3.정지","3"] + ], + fontSize: 11 }, { - "type": "Indicator", - "img": "block_icon/brush_03.png", - "size": 12 + 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 } ], - "events": {}, - "def": { - "params": [ - { - "type": "number", - "params": [ "1" ] - }, - null + def: { + params: [ + "1", + "1", + "1" ], - "type": "change_thickness" + type: "cobl_dcmotor" }, - "paramsKeyMap": { - "VALUE": 0 + paramsKeyMap: { + MOTOR: 0, + DIRECTION: 1, + SPEED:2 }, - "class": "brush_thickness", - "isNotFor": [ "textBox" ], - "func": function (sprite, script) { - var thickness = script.getNumberValue("VALUE", script); + class: "cobl", + isNotFor : [ "cobl" ], + "func": function(sprite, script) { + var motor = script.getStringField("MOTOR"); + var direction = script.getStringField("DIRECTION"); + var speed = script.getStringField("SPEED"); - if (!sprite.brush) { - Entry.setBasicBrush(sprite); - sprite.brush.stop = true; + if (motor == 1) { + Entry.hw.setDigitalPortValue("DC1_DIR", direction); + Entry.hw.setDigitalPortValue("DC1_SPEED", speed); + Entry.hw.update(); + delete Entry.hw.sendQueue["DC1_DIR"]; + delete Entry.hw.sendQueue["DC1_SPEED"]; } - if (sprite.brush) { - sprite.brush.thickness += thickness; - if (sprite.brush.thickness < 1) - sprite.brush.thickness = 1; - - sprite.brush.setStrokeStyle(sprite.brush.thickness); - - sprite.brush.moveTo(sprite.getX(), sprite.getY()*-1); + if (motor == 2) { + Entry.hw.setDigitalPortValue("DC2_DIR", direction); + Entry.hw.setDigitalPortValue("DC2_SPEED", speed); + Entry.hw.update(); + delete Entry.hw.sendQueue["DC2_DIR"]; + delete Entry.hw.sendQueue["DC2_SPEED"]; } return script.callReturn(); - }, - "syntax": {"js": [], "py": ["Entry.add_brush_size(%1)"]} + } }, - "set_thickness": { - "color": "#FF9E20", - "skeleton": "basic", - "statements": [], - "params": [ + "cobl_extention_port": { + color: "#00979D", + fontColor: "#fff", + skeleton: "basic", + template: "15.USB포트%1단계%2 %3", + params: [ { - "type": "Block", - "accept": "string" + type: "Dropdown", + options: [ + ["1","1"], + ["2","2"] + ], + fontSize: 11 }, { - "type": "Indicator", - "img": "block_icon/brush_03.png", - "size": 12 + 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 } ], - "events": {}, - "def": { - "params": [ - { - "type": "number", - "params": [ "1" ] - }, - null + def: { + params: [ + "1", + "0" ], - "type": "set_thickness" + type: "cobl_extention_port" }, - "paramsKeyMap": { - "VALUE": 0 + paramsKeyMap: { + PORT: 0, + LEVEL: 1 }, - "class": "brush_thickness", - "isNotFor": [ "textBox" ], - "func": function (sprite, script) { - var thickness = script.getNumberValue("VALUE", script); + class: "cobl", + isNotFor : [ "cobl" ], + "func": function(sprite, script) { + var port = script.getStringField("PORT"); + var level = script.getStringField("LEVEL"); - if (!sprite.brush) { - Entry.setBasicBrush(sprite); - sprite.brush.stop = true; + if(port == 1){ + Entry.hw.setDigitalPortValue("EXUSB1", level); + Entry.hw.update(); + delete Entry.hw.sendQueue["EXUSB1"]; } - if (sprite.brush) { - sprite.brush.thickness = thickness; - sprite.brush.setStrokeStyle(sprite.brush.thickness); - - sprite.brush.moveTo(sprite.getX(), sprite.getY()*-1); + if(port == 2){ + Entry.hw.setDigitalPortValue("EXUSB2", level); + Entry.hw.update(); + delete Entry.hw.sendQueue["EXUSB2"]; } - return script.callReturn(); - }, - "syntax": {"js": [], "py": ["Entry.set_brush_size(%1)"]} + } }, - "change_opacity": { - "color": "#FF9E20", - "skeleton": "basic", - "statements": [], - "params": [ + "cobl_external_led": { + color: "#00979D", + fontColor: "#fff", + skeleton: "basic", + template: "16.외부LED%1(1~64)R%2G%3B%4 %5", + params: [ { - "type": "Block", - "accept": "string" + type: "TextInput", + value: 0, + fontSize: 11 }, { - "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 (sprite, script) { - var opacity = script.getNumberValue("VALUE", script); - - if (!sprite.brush) { - Entry.setBasicBrush(sprite); - sprite.brush.stop = true; + 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 } - opacity = Entry.adjustValueWithMaxMin(sprite.brush.opacity + opacity, 0, 100); + ], + 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(sprite, script) { + var led = script.getNumberField("LED"); + var r = script.getStringField("RED"); + var g = script.getStringField("GREEN"); + var b = script.getStringField("BLUE"); - if (sprite.brush) { - sprite.brush.opacity = opacity; - sprite.brush.endStroke(); - var rgb = sprite.brush.rgb; - sprite.brush.beginStroke("rgba("+rgb.r+","+rgb.g+","+rgb.b+","+(sprite.brush.opacity/100)+")"); - sprite.brush.moveTo(sprite.getX(), sprite.getY()*-1); - } + Entry.hw.setDigitalPortValue("ELED_IDX", led); + Entry.hw.setDigitalPortValue("ELED_R", r); + Entry.hw.setDigitalPortValue("ELED_G", g); + Entry.hw.setDigitalPortValue("ELED_B", b); + 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 script.callReturn(); + } + }, + "cobl_7_segment": { + color: "#00979D", + fontColor: "#fff", + skeleton: "basic", + template: "17.숫자전광판%1(0~9999) %2", + params: [ + { + type: "TextInput", + value: 0 + }, + { + type: "Indicator", + img: "block_icon/hardware_03.png", + size: 12 + } + ], + def: { + type: "cobl_7_segment" }, - "syntax": {"js": [], "py": [""]} + paramsKeyMap: { + VALUE: 0 + }, + class: "cobl", + isNotFor : [ "cobl" ], + "func": function(sprite, script) { + var value = script.getNumberField("VALUE"); + Entry.hw.setDigitalPortValue("7SEG", value); + Entry.hw.update(); + delete Entry.hw.sendQueue["7SEG"]; + return script.callReturn(); + } }, - "set_opacity": { + "start_drawing": { "color": "#FF9E20", "skeleton": "basic", "statements": [], "params": [ - { - "type": "Block", - "accept": "string" - }, { "type": "Indicator", "img": "block_icon/brush_03.png", @@ -4916,42 +5569,26 @@ Entry.block = { ], "events": {}, "def": { - "params": [ - { - "type": "number", - "params": [ "50" ] - }, - null - ], - "type": "set_opacity" - }, - "paramsKeyMap": { - "VALUE": 0 + "params": [ null ], + "type": "start_drawing" }, - "class": "brush_opacity", + "class": "brush_control", "isNotFor": [ "textBox" ], "func": function (sprite, script) { - var opacity = script.getNumberValue("VALUE", script); - if (!sprite.brush) { + if (sprite.brush) + sprite.brush.stop = false; + else Entry.setBasicBrush(sprite); - sprite.brush.stop = true; - } - if (sprite.brush) { - sprite.brush.opacity = Entry.adjustValueWithMaxMin(opacity, 0, 100); - sprite.brush.endStroke(); - var rgb = sprite.brush.rgb; - sprite.brush.beginStroke("rgba("+rgb.r+","+rgb.g+","+rgb.b+","+(sprite.brush.opacity/100)+")"); - sprite.brush.moveTo(sprite.getX(), sprite.getY()*-1); - } + Entry.stage.sortZorder(); + sprite.brush.moveTo(sprite.getX(), sprite.getY()*-1); return script.callReturn(); - }, - "syntax": {"js": [], "py": [""]} + "syntax": {"js": [], "py": ["Entry.start_drawing()"]} }, - "brush_erase_all": { + "stop_drawing": { "color": "#FF9E20", "skeleton": "basic", "statements": [], @@ -4965,34 +5602,26 @@ Entry.block = { "events": {}, "def": { "params": [ null ], - "type": "brush_erase_all" + "type": "stop_drawing" }, - "class": "brush_clear", + "class": "brush_control", "isNotFor": [ "textBox" ], "func": function (sprite, script) { - var brush = sprite.brush; - if (brush) { - var stroke = brush._stroke.style; - var style = brush._strokeStyle.width; - brush.clear().setStrokeStyle(style).beginStroke(stroke); - brush.moveTo(sprite.getX(), sprite.getY()*-1); - } - - var stampEntities = sprite.parent.getStampEntities(); - stampEntities.map(function (entity) { - entity.removeClone(); - }); - stampEntities = null; + if (sprite.brush && sprite.shape) + sprite.brush.stop = true; return script.callReturn(); }, - "syntax": {"js": [], "py": ["Entry.clear_drawing()"]} + "syntax": {"js": [], "py": ["Entry.stop_drawing()"]} }, - "brush_stamp": { + "set_color": { "color": "#FF9E20", "skeleton": "basic", "statements": [], "params": [ + { + "type": "Color" + }, { "type": "Indicator", "img": "block_icon/brush_03.png", @@ -5002,26 +5631,39 @@ Entry.block = { "events": {}, "def": { "params": [ null ], - "type": "brush_stamp" + "type": "set_color" }, - "class": "stamp", + "paramsKeyMap": { + "VALUE": 0 + }, + "class": "brush_color", "isNotFor": [ "textBox" ], "func": function (sprite, script) { - sprite.parent.addStampEntity(sprite); + var colour = script.getField("VALUE", script); + + if (!sprite.brush) { + Entry.setBasicBrush(sprite); + sprite.brush.stop = true; + } + + if (sprite.brush) { + var rgb = Entry.hex2rgb(colour); + sprite.brush.rgb = rgb; + sprite.brush.endStroke(); + sprite.brush.beginStroke("rgba("+rgb.r+","+rgb.g+","+rgb.b+","+(sprite.brush.opacity/100)+")"); + + sprite.brush.moveTo(sprite.getX(), sprite.getY()*-1); + } return script.callReturn(); }, - "syntax": {"js": [], "py": ["Entry.stamp()"]} + "syntax": {"js": [], "py": ["Entry.set_brush_color(%1)"]} }, - "change_brush_transparency": { + "set_random_color": { "color": "#FF9E20", "skeleton": "basic", "statements": [], "params": [ - { - "type": "Block", - "accept": "string" - }, { "type": "Indicator", "img": "block_icon/brush_03.png", @@ -5030,42 +5672,30 @@ Entry.block = { ], "events": {}, "def": { - "params": [ - { - "type": "number", - "params": [ "10" ] - }, - null - ], - "type": "change_brush_transparency" - }, - "paramsKeyMap": { - "VALUE": 0 + "params": [ null ], + "type": "set_random_color" }, - "class": "brush_opacity", + "class": "brush_color", "isNotFor": [ "textBox" ], "func": function (sprite, script) { - var opacity = script.getNumberValue("VALUE", script); - if (!sprite.brush) { Entry.setBasicBrush(sprite); sprite.brush.stop = true; } - opacity = Entry.adjustValueWithMaxMin(sprite.brush.opacity - opacity, 0, 100); if (sprite.brush) { - sprite.brush.opacity = opacity; + var rgb = Entry.generateRgb(); + sprite.brush.rgb = rgb; sprite.brush.endStroke(); - var rgb = sprite.brush.rgb; sprite.brush.beginStroke("rgba("+rgb.r+","+rgb.g+","+rgb.b+","+(sprite.brush.opacity/100)+")"); + sprite.brush.moveTo(sprite.getX(), sprite.getY()*-1); } - return script.callReturn(); }, - "syntax": {"js": [], "py": ["Entry.add_brush_transparency(%1)"]} + "syntax": {"js": [], "py": ["Entry.set_brush_color_random()"]} }, - "set_brush_tranparency": { + "change_thickness": { "color": "#FF9E20", "skeleton": "basic", "statements": [], @@ -5085,19 +5715,19 @@ Entry.block = { "params": [ { "type": "number", - "params": [ "50" ] + "params": [ "1" ] }, null ], - "type": "set_brush_tranparency" + "type": "change_thickness" }, "paramsKeyMap": { "VALUE": 0 }, - "class": "brush_opacity", + "class": "brush_thickness", "isNotFor": [ "textBox" ], "func": function (sprite, script) { - var opacity = script.getNumberValue("VALUE", script); + var thickness = script.getNumberValue("VALUE", script); if (!sprite.brush) { Entry.setBasicBrush(sprite); @@ -5105,148 +5735,469 @@ Entry.block = { } if (sprite.brush) { - sprite.brush.opacity = Entry.adjustValueWithMaxMin(opacity, 0, 100); - sprite.brush.endStroke(); - var rgb = sprite.brush.rgb; - sprite.brush.beginStroke("rgba("+rgb.r+","+rgb.g+","+rgb.b+","+(1 - sprite.brush.opacity/100)+")"); + sprite.brush.thickness += thickness; + if (sprite.brush.thickness < 1) + sprite.brush.thickness = 1; + + sprite.brush.setStrokeStyle(sprite.brush.thickness); + sprite.brush.moveTo(sprite.getX(), sprite.getY()*-1); } return script.callReturn(); - }, - "syntax": {"js": [], "py": ["Entry.set_brush_transparency(%1)"]} + "syntax": {"js": [], "py": ["Entry.add_brush_size(%1)"]} }, - "number": { - "color": "#FFD974", - "skeleton": "basic_string_field", + "set_thickness": { + "color": "#FF9E20", + "skeleton": "basic", "statements": [], "params": [ { - "type": "TextInput", - "value": 10 + "type": "Block", + "accept": "string" + }, + { + "type": "Indicator", + "img": "block_icon/brush_03.png", + "size": 12 } ], "events": {}, "def": { - "params": [] + "params": [ + { + "type": "number", + "params": [ "1" ] + }, + null + ], + "type": "set_thickness" }, "paramsKeyMap": { - "NUM": 0 + "VALUE": 0 }, + "class": "brush_thickness", + "isNotFor": [ "textBox" ], "func": function (sprite, script) { - return script.getField('NUM', script); + var thickness = script.getNumberValue("VALUE", script); + + if (!sprite.brush) { + Entry.setBasicBrush(sprite); + sprite.brush.stop = true; + } + + if (sprite.brush) { + sprite.brush.thickness = thickness; + sprite.brush.setStrokeStyle(sprite.brush.thickness); + + sprite.brush.moveTo(sprite.getX(), sprite.getY()*-1); + } + + return script.callReturn(); }, - "isPrimitive": true, - "syntax": {"js": ["Scope", "%1"], "py": ["%1number#"]} + "syntax": {"js": [], "py": ["Entry.set_brush_size(%1)"]} }, - "angle": { - "color": "#FFD974", - "skeleton": "basic_string_field", + "change_opacity": { + "color": "#FF9E20", + "skeleton": "basic", "statements": [], "params": [ { - "type": "Angle" + "type": "Block", + "accept": "string" + }, + { + "type": "Indicator", + "img": "block_icon/brush_03.png", + "size": 12 } ], "events": {}, "def": { - "params": [ null ], - "type": "angle" + "params": [ + { + "type": "number", + "params": [ "10" ] + }, + null + ], + "type": "change_opacity" }, "paramsKeyMap": { - "ANGLE": 0 + "VALUE": 0 }, + "class": "brush_opacity", + "isNotFor": [ "textBox" ], "func": function (sprite, script) { - return script.getNumberField("ANGLE"); + var opacity = script.getNumberValue("VALUE", script); + + if (!sprite.brush) { + Entry.setBasicBrush(sprite); + sprite.brush.stop = true; + } + opacity = Entry.adjustValueWithMaxMin(sprite.brush.opacity + opacity, 0, 100); + + if (sprite.brush) { + sprite.brush.opacity = opacity; + sprite.brush.endStroke(); + var rgb = sprite.brush.rgb; + sprite.brush.beginStroke("rgba("+rgb.r+","+rgb.g+","+rgb.b+","+(sprite.brush.opacity/100)+")"); + sprite.brush.moveTo(sprite.getX(), sprite.getY()*-1); + } + + return script.callReturn(); }, - "syntax": {"js": [], "py": ["%1angle#"]} + "syntax": {"js": [], "py": [""]} }, - "get_x_coordinate": { - "color": "#FFD974", - "skeleton": "basic_string_field", + "set_opacity": { + "color": "#FF9E20", + "skeleton": "basic", "statements": [], "params": [ { - "type": "Text", - "text": Lang.Blocks.CALC_get_x_coordinate, - "color": "#3D3D3D" + "type": "Block", + "accept": "string" + }, + { + "type": "Indicator", + "img": "block_icon/brush_03.png", + "size": 12 } ], "events": {}, "def": { - "params": [ null ], - "type": "get_x_coordinate" + "params": [ + { + "type": "number", + "params": [ "50" ] + }, + null + ], + "type": "set_opacity" }, - "class": "calc", - "isNotFor": [], + "paramsKeyMap": { + "VALUE": 0 + }, + "class": "brush_opacity", + "isNotFor": [ "textBox" ], "func": function (sprite, script) { - return sprite.getX(); + var opacity = script.getNumberValue("VALUE", script); + + if (!sprite.brush) { + Entry.setBasicBrush(sprite); + sprite.brush.stop = true; + } + + if (sprite.brush) { + sprite.brush.opacity = Entry.adjustValueWithMaxMin(opacity, 0, 100); + sprite.brush.endStroke(); + var rgb = sprite.brush.rgb; + sprite.brush.beginStroke("rgba("+rgb.r+","+rgb.g+","+rgb.b+","+(sprite.brush.opacity/100)+")"); + sprite.brush.moveTo(sprite.getX(), sprite.getY()*-1); + } + + return script.callReturn(); + }, "syntax": {"js": [], "py": [""]} }, - "get_y_coordinate": { - "color": "#FFD974", - "skeleton": "basic_string_field", + "brush_erase_all": { + "color": "#FF9E20", + "skeleton": "basic", "statements": [], "params": [ { - "type": "Text", - "text": Lang.Blocks.CALC_get_y_coordinate, - "color": "#3D3D3D" + "type": "Indicator", + "img": "block_icon/brush_03.png", + "size": 12 } ], "events": {}, "def": { "params": [ null ], - "type": "get_y_coordinate" + "type": "brush_erase_all" }, - "class": "calc", - "isNotFor": [], + "class": "brush_clear", + "isNotFor": [ "textBox" ], "func": function (sprite, script) { - return sprite.getY(); + var brush = sprite.brush; + if (brush) { + var stroke = brush._stroke.style; + var style = brush._strokeStyle.width; + brush.clear().setStrokeStyle(style).beginStroke(stroke); + brush.moveTo(sprite.getX(), sprite.getY()*-1); + } + + var stampEntities = sprite.parent.getStampEntities(); + stampEntities.map(function (entity) { + entity.removeClone(); + }); + stampEntities = null; + + return script.callReturn(); }, - "syntax": {"js": [], "py": [""]} + "syntax": {"js": [], "py": ["Entry.clear_drawing()"]} }, - "get_angle": { - "color": "#FFD974", - "skeleton": "basic_string_field", + "brush_stamp": { + "color": "#FF9E20", + "skeleton": "basic", "statements": [], "params": [ { - "type": "Text", - "text": Lang.Blocks.CALC_get_angle, - "color": "#3D3D3D" + "type": "Indicator", + "img": "block_icon/brush_03.png", + "size": 12 } ], "events": {}, "def": { - "params": [ null ] + "params": [ null ], + "type": "brush_stamp" }, + "class": "stamp", + "isNotFor": [ "textBox" ], "func": function (sprite, script) { - return parseFloat(sprite.getRotation().toFixed(1)); + sprite.parent.addStampEntity(sprite); + + return script.callReturn(); }, - "syntax": {"js": [], "py": [""]} + "syntax": {"js": [], "py": ["Entry.stamp()"]} }, - "get_rotation_direction": { - "color": "#FFD974", - "skeleton": "basic_string_field", + "change_brush_transparency": { + "color": "#FF9E20", + "skeleton": "basic", "statements": [], "params": [ { - "type": "Dropdown", - "options": [ - [Lang.Blocks.CALC_rotation_value,"ROTATION"], - [Lang.Blocks.CALC_direction_value,"DIRECTION"] - ], - "value": "ROTATION", - "fontSize": 11 + "type": "Block", + "accept": "string" + }, + { + "type": "Indicator", + "img": "block_icon/brush_03.png", + "size": 12 } ], "events": {}, "def": { - "params": [ null ], - "type": "get_rotation_direction" + "params": [ + { + "type": "number", + "params": [ "10" ] + }, + null + ], + "type": "change_brush_transparency" + }, + "paramsKeyMap": { + "VALUE": 0 + }, + "class": "brush_opacity", + "isNotFor": [ "textBox" ], + "func": function (sprite, script) { + var opacity = script.getNumberValue("VALUE", script); + + if (!sprite.brush) { + Entry.setBasicBrush(sprite); + sprite.brush.stop = true; + } + opacity = Entry.adjustValueWithMaxMin(sprite.brush.opacity - opacity, 0, 100); + + if (sprite.brush) { + sprite.brush.opacity = opacity; + sprite.brush.endStroke(); + var rgb = sprite.brush.rgb; + sprite.brush.beginStroke("rgba("+rgb.r+","+rgb.g+","+rgb.b+","+(sprite.brush.opacity/100)+")"); + sprite.brush.moveTo(sprite.getX(), sprite.getY()*-1); + } + + return script.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 (sprite, script) { + var opacity = script.getNumberValue("VALUE", script); + + if (!sprite.brush) { + Entry.setBasicBrush(sprite); + sprite.brush.stop = true; + } + + if (sprite.brush) { + sprite.brush.opacity = Entry.adjustValueWithMaxMin(opacity, 0, 100); + sprite.brush.endStroke(); + var rgb = sprite.brush.rgb; + sprite.brush.beginStroke("rgba("+rgb.r+","+rgb.g+","+rgb.b+","+(1 - sprite.brush.opacity/100)+")"); + sprite.brush.moveTo(sprite.getX(), sprite.getY()*-1); + } + + return script.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 (sprite, script) { + return script.getField('NUM', script); + }, + "isPrimitive": true, + "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 (sprite, script) { + return script.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 (sprite, script) { + return sprite.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 (sprite, script) { + return sprite.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 (sprite, script) { + return parseFloat(sprite.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 @@ -7695,6 +8646,7 @@ Entry.block = { function(blockView) { var mode = blockView.getBoard().workspace.getMode(); if (mode !== Entry.Workspace.MODE_BOARD) return; + if (Entry.type !== "workspace") return; var block = blockView.block; var id = block.type.substr(5); Entry.Func.edit(Entry.variableContainer.functions_[id]); @@ -13578,7 +14530,6 @@ Entry.block = { Entry.Robotis_carCont.update(); scope.data_default_address = data_default_address; - console.log(data_default_address); throw new Entry.Utils.AsyncError(); } else if(scope.count < 2) { scope.count++; @@ -16003,9 +16954,7 @@ Entry.block = { if (value == 'null' || !isExist) throw new Error('value can not be null or undefined'); - Entry.container.mapEntityIncludeCloneOnScene(Entry.engine.raiseKeyEvent, - ["when_message_cast", value]); - return script.callReturn(); + Entry.engine.raiseMessage(value); }, "syntax": {"js": [], "py": ["Entry.send_signal(%1)"]} }, @@ -16070,10 +17019,7 @@ Entry.block = { var isExist = Entry.isExist(value, 'id', arr); if (value == 'null' || !isExist) throw new Error('value can not be null or undefined'); - var data = Entry.container.mapEntityIncludeCloneOnScene( - Entry.engine.raiseKeyEvent, - ["when_message_cast", value] - ); + var data = Entry.engine.raiseMessage(value); var runningScript = []; while (data.length) { var executor = data.shift(); @@ -18039,120 +18985,1404 @@ Entry.block = { sq.lcdTxt = str; } else if (line == 1) { - sq.lcdNum = 1; - sq.lcdTxt = str; + sq.lcdNum = 1; + sq.lcdTxt = str; + } + //console.log('ledR' + sq.ledR + ' ledG ' + sq.ledG +' ledB ' + sq.ledB); + return script.callReturn(); + }, + "syntax": {"js": [], "py": ["Xbot.lcd(%1, %2)"]} + }, + "run": { + "skeleton": "basic", + "color": "#3BBD70", + "contents": [ + "this is", + "basic block" + ] + }, + "mutant": { + "skeleton": "basic", + "event": "start", + "color": "#3BBD70", + "params": [], + "changeEvent": { + "_listeners": [] + } + }, + "jr_start": { + "skeleton": "pebble_event", + "event": "start", + "color": "#3BBD70", + "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 entities = + Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT); + + for (var key in entities) this._unit = entities[key]; + + Ntry.unitComp = + Ntry.entityManager.getComponent(this._unit.id, Ntry.STATIC.UNIT); + } + }, + "jr_repeat": { + "skeleton": "pebble_loop", + "color": "#127CDB", + "params": [ + { + "type": "Text", + "text": "" + }, + { + "type": "Dropdown", + "options": [ + [ 1, 1 ], + [ 2, 2 ], + [ 3, 3 ], + [ 4, 4 ], + [ 5, 5 ], + [ 6, 6 ], + [ 7, 7 ], + [ 8, 8 ], + [ 9, 9 ], + [ 10, 10 ] + ], + "value": 3, + "fontSize": 14, + "roundValue": 3 + }, + { + "type": "Text", + "text": "반복" + } + ], + statements: [ + { accept: "pebble_basic" } + ], + func: function() { + if (this.repeatCount === undefined) { + this.repeatCount = this.block.params[1]; + return Entry.STATIC.BREAK; + } else if (this.repeatCount > 0) { + this.repeatCount--; + var statement = this.block.statements[0]; + if (statement.getBlocks().length === 0) + return; + this.executor.stepInto(statement); + return Entry.STATIC.BREAK; + } else { + delete this.repeatCount; + } + } + }, + "jr_item": { + "skeleton": "pebble_basic", + "color": "#F46C6C", + "params": [ + { + "type": "Indicator", + "img": "../../../img/assets/ntry/bitmap/jr/block_item_image.png", + "highlightColor": "#FFF", + "position": { + "x": 83, + "y": 0 + }, + "size": 22 + } + ], + func: function() { + if (!this.isContinue) { + this.isContinue = true; + this.isAction = true; + var self = this; + var callBack = function() { + Ntry.dispatchEvent("getItem"); + self.isAction = false; + }; + Ntry.dispatchEvent("unitAction", Ntry.STATIC.GET_ITEM , callBack); + return Entry.STATIC.BREAK; + } else if (this.isAction) { + return Entry.STATIC.BREAK; + } else { + delete this.isAction; + delete this.isContinue; + } + } + }, + "cparty_jr_item": { + "skeleton": "pebble_basic", + "color": "#8ABC1D", + "params": [ + { + "type": "Text", + "text": "연필 줍기" + }, + { + "type": "Indicator", + "img": "../../../img/assets/ntry/bitmap/cpartyjr/pen.png", + "highlightColor": "#FFF", + "position": { + "x": 83, + "y": 0 + }, + "size": 22 + } + ], + func: function() { + if (!this.isContinue) { + this.isContinue = true; + this.isAction = true; + var self = this; + var callBack = function() { + Ntry.dispatchEvent("getItem"); + self.isAction = false; + }; + Ntry.dispatchEvent("unitAction", Ntry.STATIC.GET_ITEM , callBack); + return Entry.STATIC.BREAK; + } else if (this.isAction) { + return Entry.STATIC.BREAK; + } else { + delete this.isAction; + delete this.isContinue; + + } + } + }, + "jr_north": { + "skeleton": "pebble_basic", + "color": "#A751E3", + "params": [ + { + "type": "Text", + "text": " 위쪽" + }, + { + "type": "Indicator", + "img": "../../../img/assets/ntry/bitmap/jr/block_up_image.png", + "position": { + "x": 83, + "y": 0 + }, + "size": 22 + } + ], + func: function() { + if (!this.isContinue) { + this.isContinue = true; + this.isAction = true; + var STATIC = Ntry.STATIC; + var self = this; + var callBack = function() { + window.setTimeout( + function() { Ntry.dispatchEvent("unitAction", Ntry.STATIC.WALK, function() { + self.isAction = false; + } + );}, 3); + }; + var actionType; + switch (Ntry.unitComp.direction) { + case Ntry.STATIC.EAST: + actionType = STATIC.TURN_LEFT; + break; + case Ntry.STATIC.SOUTH: + actionType = STATIC.HALF_ROTATION; + break; + case Ntry.STATIC.WEST: + actionType = STATIC.TURN_RIGHT; + break; + default: + callBack(); + break; + } + if (actionType) + Ntry.dispatchEvent("unitAction", actionType, callBack); + return Entry.STATIC.BREAK; + } else if (this.isAction) { + return Entry.STATIC.BREAK; + } else { + delete this.isAction; + delete this.isContinue; + } + } + }, + "jr_east": { + "skeleton": "pebble_basic", + "color": "#A751E3", + "params": [ + { + "type": "Text", + "text": "오른쪽" + }, + { + "type": "Indicator", + "img": "../../../img/assets/ntry/bitmap/jr/block_right_image.png", + "position": { + "x": 83, + "y": 0 + }, + "size": 22 + } + ], + func: function() { + var STATIC = Ntry.STATIC; + + if (!this.isContinue) { + this.isContinue = true; + this.isAction = true; + var self = this; + var callBack = function() { + window.setTimeout( + function() { + Ntry.dispatchEvent( + "unitAction", + STATIC.WALK, + function() { self.isAction = false; } );}, + 3); + }; + + // turn direction + var actionType; + switch (Ntry.unitComp.direction) { + case STATIC.SOUTH: + actionType = STATIC.TURN_LEFT; + break; + case STATIC.WEST: + actionType = STATIC.HALF_ROTATION; + break; + case STATIC.NORTH: + actionType = STATIC.TURN_RIGHT; + break; + default: + callBack(); + break; + } + if (actionType) + Ntry.dispatchEvent("unitAction", actionType, callBack); + return Entry.STATIC.BREAK; + } else if (this.isAction) { + return Entry.STATIC.BREAK; + } else { + delete this.isAction; + delete this.isContinue; + } + } + }, + "jr_south": { + "skeleton": "pebble_basic", + "color": "#A751E3", + "params": [ + { + "type": "Text", + "text": " 아래쪽" + }, + { + "type": "Indicator", + "img": "../../../img/assets/ntry/bitmap/jr/block_down_image.png", + "position": { + "x": 83, + "y": 0 + }, + "size": 22 + } + ], + func: function() { + if (!this.isContinue) { + + this.isContinue = true; + this.isAction = true; + var STATIC = Ntry.STATIC; + var self = this; + var callBack = function() { + window.setTimeout( + function() { + Ntry.dispatchEvent( + "unitAction", + Ntry.STATIC.WALK, + function() { self.isAction = false; } );}, + 3); + }; + + // turn direction + var actionType; + switch (Ntry.unitComp.direction) { + case STATIC.EAST: + actionType = STATIC.TURN_RIGHT; + break; + case STATIC.NORTH: + actionType = STATIC.HALF_ROTATION; + break; + case STATIC.WEST: + actionType = STATIC.TURN_LEFT; + break; + default: + callBack(); + break; + } + if (actionType) + Ntry.dispatchEvent("unitAction", actionType, callBack); + return Entry.STATIC.BREAK; + } else if (this.isAction) { + return Entry.STATIC.BREAK; + } else { + delete this.isAction; + delete this.isContinue; + } + } + }, + "jr_west": { + "skeleton": "pebble_basic", + "color": "#A751E3", + "params": [ + { + "type": "Text", + "text": " 왼쪽" + }, + { + "type": "Indicator", + "img": "../../../img/assets/ntry/bitmap/jr/block_left_image.png", + "position": { + "x": 83, + "y": 0 + }, + "size": 22 + } + ], + func: function() { + if (!this.isContinue) { + this.isContinue = true; + this.isAction = true; + var STATIC = Ntry.STATIC; + var self = this; + var callBack = function() { + window.setTimeout( + function() { Ntry.dispatchEvent( + "unitAction", + STATIC.WALK, + function() { self.isAction = false; } );}, + 3); + }; + + // turn direction + var actionType; + switch (Ntry.unitComp.direction) { + case STATIC.SOUTH: + actionType = STATIC.TURN_RIGHT; + break; + case STATIC.EAST: + actionType = STATIC.HALF_ROTATION; + break; + case STATIC.NORTH: + actionType = STATIC.TURN_LEFT; + break; + default: + callBack(); + break; + } + if (actionType) + Ntry.dispatchEvent("unitAction", actionType, callBack); + return Entry.STATIC.BREAK; + } else if (this.isAction) { + return Entry.STATIC.BREAK; + } else { + delete this.isAction; + delete this.isContinue; + } + } + }, + "jr_start_basic": { + "skeleton": "basic_event", + "event": "start", + "color": "#3BBD70", + "params": [ + { + "type": "Indicator", + "boxMultiplier": 2, + "img": "../../../img/assets/block_icon/start_icon_play.png", + "highlightColor": "#3BBD70", + "size": 17, + "position": { + "x": 0, + "y": -2 + } + }, + { + text: "시작하기를 클릭했을때", + type: "Text" + } + ], + func: function() { + var entities = Ntry.entityManager.getEntitiesByComponent( + Ntry.STATIC.UNIT); + + for (var key in entities) + this._unit = entities[key]; + + Ntry.unitComp = Ntry.entityManager.getComponent( + this._unit.id, Ntry.STATIC.UNIT); + } + }, + "jr_go_straight": { + "skeleton": "basic", + "color": "#A751E3", + "params": [ + { + text: "앞으로 가기", + type: "Text" + }, + { + "type": "Image", + "img": "../../../img/assets/ntry/bitmap/jr/cparty_go_straight.png", + "size": 24 + } + ], + func: function() { + if (!this.isContinue) { + + this.isContinue = true; + this.isAction = true; + var self = this; + var callBack = function() { + self.isAction = false; + }; + // turn direction + Ntry.dispatchEvent("unitAction", Ntry.STATIC.WALK, callBack); + + return Entry.STATIC.BREAK; + } else if (this.isAction) { + return Entry.STATIC.BREAK; + } else { + delete this.isAction; + delete this.isContinue; + } + }, + "syntax": [ + "Scope", + "move" + ] + }, + "jr_turn_left": { + "skeleton": "basic", + "color": "#A751E3", + "params": [ + { + text: "왼쪽으로 돌기", + type: "Text" + }, + { + "type": "Image", + "img": "../../../img/assets/ntry/bitmap/jr/cparty_rotate_l.png", + "size": 24 + } + ], + func: function() { + if (!this.isContinue) { + + this.isContinue = true; + this.isAction = true; + var self = this; + var callBack = function() { + self.isAction = false; + }; + + // turn direction + Ntry.dispatchEvent("unitAction", Ntry.STATIC.TURN_LEFT, callBack); + + return Entry.STATIC.BREAK; + } else if (this.isAction) { + return Entry.STATIC.BREAK; + } else { + delete this.isAction; + delete this.isContinue; + } + }, + "syntax": [ + "Scope", + "left" + ] + }, + "jr_turn_right": { + "skeleton": "basic", + "color": "#A751E3", + "params": [ + { + text: "오른쪽으로 돌기", + type: "Text" + }, + { + "type": "Image", + "img": "../../../img/assets/ntry/bitmap/jr/cparty_rotate_r.png", + "size": 24 + } + ], + func: function() { + if (!this.isContinue) { + + this.isContinue = true; + this.isAction = true; + var self = this; + var callBack = function() { + self.isAction = false; + }; + + // turn direction + Ntry.dispatchEvent("unitAction", Ntry.STATIC.TURN_RIGHT, callBack); + + return Entry.STATIC.BREAK; + } else if (this.isAction) { + return Entry.STATIC.BREAK + } else { + delete this.isAction; + delete this.isContinue; + } + }, + "syntax": [ + "Scope", + "right" + ] + }, + "jr_go_slow": { + "skeleton": "basic", + "color": "#f46c6c", + "params": [ + { + text: "천천히 가기", + type: "Text" + }, + { + "type": "Image", + "img": "../../../img/assets/ntry/bitmap/jr/cparty_go_slow.png", + "size": 24 + } + ], + func: function() { + if (!this.isContinue) { + + this.isContinue = true; + this.isAction = true; + var self = this; + var callBack = function() { + self.isAction = false; + }; + + // turn direction + Ntry.dispatchEvent("unitAction", Ntry.STATIC.GO_SLOW, callBack); + + return Entry.STATIC.BREAK; + } else if (this.isAction) { + return Entry.STATIC.BREAK; + } else { + delete this.isAction; + delete this.isContinue; + } + }, + "syntax": [ + "Scope", + "move_slowly" + ] + }, + "jr_repeat_until_dest": { + "skeleton": "basic_loop", + "color": "#498DEB", + "syntax": [ + "BasicWhile", + "true" + ], + "params": [ + { + "type": "Image", + "img": "../../../img/assets/ntry/bitmap/jr/jr_goal_image.png", + "size": 18 + }, + { + text: "만날 때 까지 반복하기", + type: "Text" + }, + { + "type": "Image", + "img": "/img/assets/week/blocks/for.png", + "size": 24 + } + ], + "statements": [ + { + "accept": "basic" + } + ], + func: function() { + var statement = this.block.statements[0]; + if (statement.getBlocks().length === 0) + return; + + this.executor.stepInto(statement); + return Entry.STATIC.BREAK; + } + }, + "jr_if_construction": { + "skeleton": "basic_loop", + "color": "#498DEB", + "syntax": [ + "BasicIf", + "front == 'wall'" + ], + "params": [ + { + text: "만약", + type: "Text" + }, + { + "type": "Image", + "img": "../../../img/assets/ntry/bitmap/jr/jr_construction_image.png", + "size": 18 + }, + { + text: "앞에 있다면", + type: "Text" + }, + { + "type": "Image", + "img": "/img/assets/week/blocks/for.png", + "size": 24 + } + ], + "statements": [ + { + "accept": "basic" + } + ], + func: function() { + if (this.isContinue) + return; + var entities = Ntry.entityManager.getEntitiesByComponent( + Ntry.STATIC.UNIT); + + var entity; + for (var key in entities) + entity = entities[key]; + + var unitComp = Ntry.entityManager.getComponent( + entity.id, Ntry.STATIC.UNIT); + var gridComp = Ntry.entityManager.getComponent( + entity.id, Ntry.STATIC.GRID); + + var grid = {x: gridComp.x, y: gridComp.y}; + Ntry.addVectorByDirection(grid, unitComp.direction, 1); + + var fitEntities = Ntry.entityManager.find( + { + type: Ntry.STATIC.GRID, + x: grid.x, + y: grid.y + }, + { + type: Ntry.STATIC.TILE, + tileType: Ntry.STATIC.OBSTACLE_REPAIR + } + ); + + this.isContinue = true; + + var statement = this.block.statements[0]; + if (fitEntities.length === 0) return; + else if (statement.getBlocks().length === 0) return; + else { + this.executor.stepInto(statement); + return Entry.STATIC.BREAK; + } + } + }, + "jr_if_speed": { + "skeleton": "basic_loop", + "color": "#498DEB", + "syntax": [ + "BasicIf", + "front == 'hump'" + ], + "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) + return; + var entities = Ntry.entityManager.getEntitiesByComponent( + Ntry.STATIC.UNIT); + + var entity; + for (var key in entities) + entity = entities[key]; + + var unitComp = Ntry.entityManager.getComponent( + entity.id, Ntry.STATIC.UNIT); + var gridComp = Ntry.entityManager.getComponent( + entity.id, Ntry.STATIC.GRID); + + var grid = {x: gridComp.x, y: gridComp.y}; + Ntry.addVectorByDirection(grid, unitComp.direction, 1); + + var fitEntities = Ntry.entityManager.find( + { + type: Ntry.STATIC.GRID, + x: grid.x, + y: grid.y + }, + { + type: Ntry.STATIC.TILE, + tileType: Ntry.STATIC.OBSTACLE_SLOW + } + ); + + this.isContinue = true; + + var statement = this.block.statements[0]; + if (fitEntities.length === 0) return; + else if(statement.getBlocks().length === 0) return; + else { + this.executor.stepInto(statement); + return Entry.STATIC.BREAK; + } + } + }, + "maze_step_start": { + "skeleton": "basic_event", + "mode": "maze", + "event": "start", + "color": "#3BBD70", + "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 entities = Ntry.entityManager.getEntitiesByComponent( + Ntry.STATIC.UNIT); + + for (var key in entities) + this._unit = entities[key]; + + Ntry.unitComp = Ntry.entityManager.getComponent( + this._unit.id, Ntry.STATIC.UNIT); + } + }, + "maze_step_jump": { + "skeleton": "basic", + "mode": "maze", + "color": "#FF6E4B", + "params": [ + { + "type": "Image", + "img": "/img/assets/week/blocks/jump.png", + "size": 24 + } + ], + "syntax": [ "Scope", "jump" ], + func: function() { + if (!this.isContinue) { + this.isContinue = true; + this.isAction = true; + var self = this; + var callBack = function() { + self.isAction = false; + }; + + Ntry.dispatchEvent("unitAction", Ntry.STATIC.JUMP, callBack); + + return Entry.STATIC.BREAK; + } else if (this.isAction) { + return Entry.STATIC.BREAK; + } else { + delete this.isAction; + delete this.isContinue; + } + } + }, + "maze_step_jump2": { + "parent": "maze_step_jump", + "template": Lang.template.maze_step_jump, + func: function() { + if (!this.isContinue) { + this.isContinue = true; + this.isAction = true; + var self = this; + var callBack = function() { + self.isAction = false; + }; + + var entities = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT); + var unitId; + $.each(entities, function (id, entity) { + unitId = id; + components = entity.components; + }); + + var unitComp = Ntry.entityManager.getComponent(unitId, Ntry.STATIC.UNIT); + var unitGrid = $.extend({}, Ntry.entityManager.getComponent(unitId, Ntry.STATIC.GRID)); + var checkGrid = { + x: unitGrid.x, + y: unitGrid.y, + } + var isCollisionPossible = Ntry.checkCollisionTile(unitGrid, unitComp.direction, [Ntry.STATIC.OBSTACLE_IRON], 2); + if(isCollisionPossible) { + Ntry.dispatchEvent("unitAction", Ntry.STATIC.FAIL_JUMP, callBack); + Ntry.dispatchEvent("complete", false, Ntry.STATIC.CONTACT_IRON); + return; + } + + Ntry.dispatchEvent("unitAction", Ntry.STATIC.JUMP, callBack); + return Entry.STATIC.BREAK; + } else if (this.isAction) { + return Entry.STATIC.BREAK; + } else { + delete this.isAction; + delete this.isContinue; + } + } + }, + "maze_step_for": { + "skeleton": "basic_loop", + "mode": "maze", + "color": "#498DEB", + "syntax": [ + "BasicIteration" + ], + "params": [ + { + "type": "Dropdown", + "key": "REPEAT", + "options": [ + [ 1, 1 ], + [ 2, 2 ], + [ 3, 3 ], + [ 4, 4 ], + [ 5, 5 ], + [ 6, 6 ], + [ 7, 7 ], + [ 8, 8 ], + [ 9, 9 ], + [ 10, 10 ] + ], + "value": 1 + }, + { + "type": "Image", + "img": "/img/assets/week/blocks/for.png", + "size": 24 + } + ], + "statements": [ + { + "accept": "basic" + } + ], + func: function() { + if (this.repeatCount === undefined) { + this.repeatCount = this.block.params[0]; + return Entry.STATIC.BREAK; + } else if (this.repeatCount > 0) { + this.repeatCount--; + var statement = this.block.statements[0]; + if (statement.getBlocks().length === 0) + return; + this.executor.stepInto(statement); + return Entry.STATIC.BREAK; + } else { + delete this.repeatCount; + } + } + }, + "test": { + "skeleton": "basic_boolean_field", + "mode": "maze", + "color": "#127CDB", + "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 + } + ] + }, + "maze_repeat_until_1": { + "skeleton": "basic_loop", + "mode": "maze", + "color": "#498DEB", + "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 statement = this.block.statements[0]; + if (statement.getBlocks().length === 0) + return; + + this.executor.stepInto(statement); + return Entry.STATIC.BREAK; + } + }, + "maze_repeat_until_2": { + "skeleton": "basic_loop", + "mode": "maze", + "color": "#498DEB", + "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 statement = this.block.statements[0]; + if (statement.getBlocks().length === 0) + return; + + this.executor.stepInto(statement); + return Entry.STATIC.BREAK; + } + }, + "maze_step_if_1": { + "skeleton": "basic_loop", + "mode": "maze", + "color": "#498DEB", + "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) + return; + var entities = + Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT); + + var entity; + for (var key in entities) + entity = entities[key]; + + var unitComp = Ntry.entityManager.getComponent( + entity.id, Ntry.STATIC.UNIT); + var gridComp = Ntry.entityManager.getComponent( + entity.id, Ntry.STATIC.GRID); + + var grid = {x: gridComp.x, y: gridComp.y}; + Ntry.addVectorByDirection(grid, unitComp.direction, 1); + + var existEntities = Ntry.entityManager.find( + { + type: Ntry.STATIC.GRID, + x: grid.x, + y: grid.y + }); + + var statement = this.block.statements[0]; + + if (existEntities.length === 0) { + this.executor.stepInto(statement); + return Entry.STATIC.BREAK; + } + + var fitEntities = Ntry.entityManager.find( + { + type: Ntry.STATIC.GRID, + x: grid.x, + y: grid.y + }, + { + type: Ntry.STATIC.TILE, + tileType: Ntry.STATIC.WALL + } + ); + + this.isContinue = true; + + if (fitEntities.length === 0) { + return; + } else if (statement.getBlocks().length === 0) + return; + else { + this.executor.stepInto(statement); + return Entry.STATIC.BREAK; + } + } + }, + "maze_step_if_2": { + "skeleton": "basic_loop", + "mode": "maze", + "color": "#498DEB", + "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) return; + + var entities = + Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT); + + var entity; + for (var key in entities) + entity = entities[key]; + + var unitComp = Ntry.entityManager.getComponent( + entity.id, Ntry.STATIC.UNIT); + var gridComp = Ntry.entityManager.getComponent( + entity.id, Ntry.STATIC.GRID); + + var grid = {x: gridComp.x, y: gridComp.y}; + Ntry.addVectorByDirection(grid, unitComp.direction, 1); + + var fitEntities = Ntry.entityManager.find( + { + type: Ntry.STATIC.GRID, + x: grid.x, + y: grid.y + }, + { + type: Ntry.STATIC.TILE, + tileType: Ntry.STATIC.OBSTACLE_BEE + } + ); + + this.isContinue = true; + + var statement = this.block.statements[0]; + if (fitEntities.length === 0) { + return; + } else if (statement.getBlocks().length === 0) + return; + else { + this.executor.stepInto(statement); + return Entry.STATIC.BREAK; + } + } + }, + "maze_call_function": { + "skeleton": "basic", + "mode": "maze", + "color": "#B57242", + "syntax": [ + "Scope", + "promise" + ], + "params": [ + { + "type": "Image", + "img": "/img/assets/week/blocks/function.png", + "size": 24 + } + ], + func: function() { + if (!this.funcExecutor) { + var codes = + Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.CODE); + + for (var key in codes) { + var code = codes[key].components[Ntry.STATIC.CODE].code; + this.funcExecutor = new Entry.Executor( + code.getEventMap("define")[0] + ); + } + } + + this.funcExecutor.execute(); + if (this.funcExecutor.scope.block === null) + return; + else + return Entry.STATIC.BREAK; + } + }, + "maze_define_function": { + "skeleton": "basic_define", + "mode": "maze", + "color": "#B57242", + "event": "define", + "syntax": [ + "BasicFunction" + ], + "params": [ + { + "type": "Image", + "img": "/img/assets/week/blocks/function.png", + "size": 24 } - //console.log('ledR' + sq.ledR + ' ledG ' + sq.ledG +' ledB ' + sq.ledB); - return script.callReturn(); - }, - "syntax": {"js": [], "py": ["Xbot.lcd(%1, %2)"]} - }, - "run": { - "skeleton": "basic", - "color": "#3BBD70", - "contents": [ - "this is", - "basic block" - ] - }, - "mutant": { - "skeleton": "basic", - "event": "start", - "color": "#3BBD70", - "params": [], - "changeEvent": { - "_listeners": [] + ], + "statements": [ + { + "accept": "basic" + } + ], + func: function(executor) { + if (this.executed) + return; + var statement = this.block.statements[0]; + if (statement.getBlocks().length === 0) + return; + this.executor.stepInto(statement); + this.executed = true; + return Entry.STATIC.BREAK; } }, - "jr_start": { - "skeleton": "pebble_event", - "event": "start", - "color": "#3BBD70", + "maze_step_if_3": { + "skeleton": "basic_loop", + "mode": "maze", + "color": "#498DEB", + "syntax": [ + "BasicIf", + "front == banana" + ], "params": [ { - "type": "Indicator", - "img": "../../../img/assets/ntry/bitmap/jr/block_play_image.png", - "highlightColor": "#3BBD70", - "position": { - "x": 0, - "y": 0 - }, - "size": 22 + "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) return; + var entities = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT); - for (var key in entities) this._unit = entities[key]; + var entity; + for (var key in entities) + entity = entities[key]; - Ntry.unitComp = - Ntry.entityManager.getComponent(this._unit.id, Ntry.STATIC.UNIT); + var unitComp = Ntry.entityManager.getComponent( + entity.id, Ntry.STATIC.UNIT); + var gridComp = Ntry.entityManager.getComponent( + entity.id, Ntry.STATIC.GRID); + + var grid = {x: gridComp.x, y: gridComp.y}; + Ntry.addVectorByDirection(grid, unitComp.direction, 1); + + var fitEntities = Ntry.entityManager.find( + { + type: Ntry.STATIC.GRID, + x: grid.x, + y: grid.y + }, + { + type: Ntry.STATIC.TILE, + tileType: Ntry.STATIC.OBSTACLE_BANANA + } + ); + + this.isContinue = true; + + var statement = this.block.statements[0]; + if (fitEntities.length === 0) { + return; + } else if (statement.getBlocks().length === 0) + return; + else { + this.executor.stepInto(statement); + return Entry.STATIC.BREAK; + } } }, - "jr_repeat": { - "skeleton": "pebble_loop", - "color": "#127CDB", + "maze_step_if_4": { + "skeleton": "basic_loop", + "mode": "maze", + "color": "#498DEB", + "syntax": [ + "BasicIf", + "front == wall" + ], "params": [ { - "type": "Text", - "text": "" - }, - { - "type": "Dropdown", - "options": [ - [ 1, 1 ], - [ 2, 2 ], - [ 3, 3 ], - [ 4, 4 ], - [ 5, 5 ], - [ 6, 6 ], - [ 7, 7 ], - [ 8, 8 ], - [ 9, 9 ], - [ 10, 10 ] - ], - "value": 3, - "fontSize": 14, - "roundValue": 3 + "type": "Image", + "img": "/img/assets/ntry/block_inner/if_target_2.png", + "size": 18 }, { - "type": "Text", - "text": "반복" + "type": "Image", + "img": "/img/assets/week/blocks/if.png", + "size": 24 } ], - statements: [ - { accept: "pebble_basic" } + "statements": [ + { + "accept": "basic" + } ], func: function() { - if (this.repeatCount === undefined) { - this.repeatCount = this.block.params[1]; - return Entry.STATIC.BREAK; - } else if (this.repeatCount > 0) { - this.repeatCount--; - var statement = this.block.statements[0]; - if (statement.getBlocks().length === 0) - return; + if (this.isContinue) return; + + var entities = + Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT); + + var entity; + for (var key in entities) + entity = entities[key]; + + var unitComp = Ntry.entityManager.getComponent( + entity.id, Ntry.STATIC.UNIT); + var gridComp = Ntry.entityManager.getComponent( + entity.id, Ntry.STATIC.GRID); + + var grid = {x: gridComp.x, y: gridComp.y}; + Ntry.addVectorByDirection(grid, unitComp.direction, 1); + + var fitEntities = Ntry.entityManager.find( + { + type: Ntry.STATIC.GRID, + x: grid.x, + y: grid.y + }, + { + type: Ntry.STATIC.TILE, + tileType: Ntry.STATIC.WALL + } + ); + + this.isContinue = true; + + var statement = this.block.statements[0]; + if (fitEntities.length === 0) { + return; + } else if (statement.getBlocks().length === 0) + return; + else { this.executor.stepInto(statement); return Entry.STATIC.BREAK; - } else { - delete this.repeatCount; } } }, - "jr_item": { - "skeleton": "pebble_basic", - "color": "#F46C6C", + "maze_step_move_step": { + "skeleton": "basic", + "mode": "maze", + "color": "#A751E3", + "syntax": [ + "Scope", + "move" + ], "params": [ { - "type": "Indicator", - "img": "../../../img/assets/ntry/bitmap/jr/block_item_image.png", - "highlightColor": "#FFF", - "position": { - "x": 83, - "y": 0 - }, - "size": 22 + "type": "Image", + "img": "/img/assets/week/blocks/moveStep.png", + "size": 24 } ], func: function() { @@ -18161,10 +20391,11 @@ Entry.block = { this.isAction = true; var self = this; var callBack = function() { - Ntry.dispatchEvent("getItem"); self.isAction = false; }; - Ntry.dispatchEvent("unitAction", Ntry.STATIC.GET_ITEM , callBack); + // turn direction + Ntry.dispatchEvent("unitAction", Ntry.STATIC.WALK, callBack); + return Entry.STATIC.BREAK; } else if (this.isAction) { return Entry.STATIC.BREAK; @@ -18174,93 +20405,71 @@ Entry.block = { } } }, - "cparty_jr_item": { - "skeleton": "pebble_basic", - "color": "#8ABC1D", - "params": [ - { - "type": "Text", - "text": "연필 줍기" - }, - { - "type": "Indicator", - "img": "../../../img/assets/ntry/bitmap/cpartyjr/pen.png", - "highlightColor": "#FFF", - "position": { - "x": 83, - "y": 0 - }, - "size": 22 + "maze_step_rotate_left": { + "skeleton": "basic", + "mode": "maze", + "color": "#A751E3", + "syntax": [ + "Scope", + "left" + ], + "params": [ + { + "type": "Image", + "img": "/img/assets/week/blocks/turnL.png", + "size": 24 } ], func: function() { if (!this.isContinue) { + this.isContinue = true; this.isAction = true; var self = this; var callBack = function() { - Ntry.dispatchEvent("getItem"); self.isAction = false; }; - Ntry.dispatchEvent("unitAction", Ntry.STATIC.GET_ITEM , callBack); + + // turn direction + Ntry.dispatchEvent("unitAction", Ntry.STATIC.TURN_LEFT, callBack); + return Entry.STATIC.BREAK; } else if (this.isAction) { return Entry.STATIC.BREAK; } else { delete this.isAction; delete this.isContinue; - } } }, - "jr_north": { - "skeleton": "pebble_basic", + "maze_step_rotate_right": { + "skeleton": "basic", + "mode": "maze", "color": "#A751E3", + "syntax": [ + "Scope", + "right" + ], "params": [ { - "type": "Text", - "text": " 위쪽" - }, - { - "type": "Indicator", - "img": "../../../img/assets/ntry/bitmap/jr/block_up_image.png", - "position": { - "x": 83, - "y": 0 - }, - "size": 22 + "type": "Image", + "img": "/img/assets/week/blocks/turnR.png", + "size": 24 } ], func: function() { if (!this.isContinue) { + this.isContinue = true; this.isAction = true; - var STATIC = Ntry.STATIC; var self = this; var callBack = function() { - window.setTimeout( - function() { Ntry.dispatchEvent("unitAction", Ntry.STATIC.WALK, function() { - self.isAction = false; - } - );}, 3); + self.isAction = false; }; - var actionType; - switch (Ntry.unitComp.direction) { - case Ntry.STATIC.EAST: - actionType = STATIC.TURN_LEFT; - break; - case Ntry.STATIC.SOUTH: - actionType = STATIC.HALF_ROTATION; - break; - case Ntry.STATIC.WEST: - actionType = STATIC.TURN_RIGHT; - break; - default: - callBack(); - break; - } - if (actionType) - Ntry.dispatchEvent("unitAction", actionType, callBack); + + // turn direction + Ntry.dispatchEvent("unitAction", Ntry.STATIC.TURN_RIGHT, callBack); + return Entry.STATIC.BREAK; } else if (this.isAction) { return Entry.STATIC.BREAK; @@ -18270,59 +20479,32 @@ Entry.block = { } } }, - "jr_east": { - "skeleton": "pebble_basic", + "maze_step_forward": { + "skeleton": "basic", + "mode": "maze", "color": "#A751E3", + "syntax": [ + "Scope", + "move" + ], "params": [ { - "type": "Text", - "text": "오른쪽" - }, - { - "type": "Indicator", - "img": "../../../img/assets/ntry/bitmap/jr/block_right_image.png", - "position": { - "x": 83, - "y": 0 - }, - "size": 22 + "type": "Image", + "img": "/img/assets/week/blocks/moveStep.png", + "size": 24 } ], func: function() { - var STATIC = Ntry.STATIC; - - if (!this.isContinue) { + if (!this.isContinue) { this.isContinue = true; this.isAction = true; var self = this; var callBack = function() { - window.setTimeout( - function() { - Ntry.dispatchEvent( - "unitAction", - STATIC.WALK, - function() { self.isAction = false; } );}, - 3); + self.isAction = false; }; - // turn direction - var actionType; - switch (Ntry.unitComp.direction) { - case STATIC.SOUTH: - actionType = STATIC.TURN_LEFT; - break; - case STATIC.WEST: - actionType = STATIC.HALF_ROTATION; - break; - case STATIC.NORTH: - actionType = STATIC.TURN_RIGHT; - break; - default: - callBack(); - break; - } - if (actionType) - Ntry.dispatchEvent("unitAction", actionType, callBack); + Ntry.dispatchEvent("unitAction", Ntry.STATIC.WALK, callBack); + return Entry.STATIC.BREAK; } else if (this.isAction) { return Entry.STATIC.BREAK; @@ -18332,59 +20514,34 @@ Entry.block = { } } }, - "jr_south": { - "skeleton": "pebble_basic", + "maze_rotate_left": { + "skeleton": "basic", + "mode": "maze", "color": "#A751E3", + "syntax": [ + "Scope", + "left" + ], "params": [ { - "type": "Text", - "text": " 아래쪽" - }, - { - "type": "Indicator", - "img": "../../../img/assets/ntry/bitmap/jr/block_down_image.png", - "position": { - "x": 83, - "y": 0 - }, - "size": 22 + "type": "Image", + "img": "/img/assets/week/blocks/turnL.png", + "size": 24 } ], func: function() { - if (!this.isContinue) { + if (!this.isContinue) { this.isContinue = true; this.isAction = true; - var STATIC = Ntry.STATIC; var self = this; var callBack = function() { - window.setTimeout( - function() { - Ntry.dispatchEvent( - "unitAction", - Ntry.STATIC.WALK, - function() { self.isAction = false; } );}, - 3); + self.isAction = false; }; // turn direction - var actionType; - switch (Ntry.unitComp.direction) { - case STATIC.EAST: - actionType = STATIC.TURN_RIGHT; - break; - case STATIC.NORTH: - actionType = STATIC.HALF_ROTATION; - break; - case STATIC.WEST: - actionType = STATIC.TURN_LEFT; - break; - default: - callBack(); - break; - } - if (actionType) - Ntry.dispatchEvent("unitAction", actionType, callBack); + Ntry.dispatchEvent("unitAction", Ntry.STATIC.TURN_LEFT, callBack); + return Entry.STATIC.BREAK; } else if (this.isAction) { return Entry.STATIC.BREAK; @@ -18394,123 +20551,92 @@ Entry.block = { } } }, - "jr_west": { - "skeleton": "pebble_basic", + "maze_rotate_right": { + "skeleton": "basic", + "mode": "maze", "color": "#A751E3", + "syntax": [ + "Scope", + "right" + ], "params": [ { - "type": "Text", - "text": " 왼쪽" - }, - { - "type": "Indicator", - "img": "../../../img/assets/ntry/bitmap/jr/block_left_image.png", - "position": { - "x": 83, - "y": 0 - }, - "size": 22 + "type": "Image", + "img": "/img/assets/week/blocks/turnR.png", + "size": 24 } ], func: function() { if (!this.isContinue) { + this.isContinue = true; this.isAction = true; - var STATIC = Ntry.STATIC; var self = this; var callBack = function() { - window.setTimeout( - function() { Ntry.dispatchEvent( - "unitAction", - STATIC.WALK, - function() { self.isAction = false; } );}, - 3); + self.isAction = false; }; // turn direction - var actionType; - switch (Ntry.unitComp.direction) { - case STATIC.SOUTH: - actionType = STATIC.TURN_RIGHT; - break; - case STATIC.EAST: - actionType = STATIC.HALF_ROTATION; - break; - case STATIC.NORTH: - actionType = STATIC.TURN_LEFT; - break; - default: - callBack(); - break; - } - if (actionType) - Ntry.dispatchEvent("unitAction", actionType, callBack); + Ntry.dispatchEvent("unitAction", Ntry.STATIC.TURN_RIGHT, callBack); + return Entry.STATIC.BREAK; } else if (this.isAction) { return Entry.STATIC.BREAK; } else { delete this.isAction; - delete this.isContinue; - } - } - }, - "jr_start_basic": { - "skeleton": "basic_event", - "event": "start", - "color": "#3BBD70", - "params": [ - { - "type": "Indicator", - "boxMultiplier": 2, - "img": "../../../img/assets/block_icon/start_icon_play.png", - "highlightColor": "#3BBD70", - "size": 17, - "position": { - "x": 0, - "y": -2 - } - }, - { - text: "시작하기를 클릭했을때", - type: "Text" - } - ], - func: function() { - var entities = Ntry.entityManager.getEntitiesByComponent( - Ntry.STATIC.UNIT); - - for (var key in entities) - this._unit = entities[key]; - - Ntry.unitComp = Ntry.entityManager.getComponent( - this._unit.id, Ntry.STATIC.UNIT); + delete this.isContinue; + } } }, - "jr_go_straight": { + "maze_moon_kick": { "skeleton": "basic", - "color": "#A751E3", + "mode": "maze", + "color": "#2EB0E8", + "syntax": [ + "Scope", + "right" + ], "params": [ - { - text: "앞으로 가기", - type: "Text" - }, { "type": "Image", - "img": "../../../img/assets/ntry/bitmap/jr/cparty_go_straight.png", + "img": "/img/assets/maze/sprite/moon_icon.png", "size": 24 } ], func: function() { + // TODO: func 내용은 변경해야 함. + if (!this.isContinue) { + var entities = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT); + var unitId; + $.each(entities, function (id, entity) { + unitId = id; + components = entity.components; + }); + var unitComp = Ntry.entityManager.getComponent(unitId, Ntry.STATIC.UNIT); + var unitGrid = $.extend({}, Ntry.entityManager.getComponent(unitId, Ntry.STATIC.GRID)); + var isCollisionPossible = Ntry.checkCollisionTile(unitGrid, unitComp.direction, [Ntry.STATIC.OBSTACLE_BRICK], 1); + if(!isCollisionPossible) { + Ntry.dispatchEvent("playSound", Ntry.STATIC.NOT_FOUND_DESTORY_OBJECT); + Ntry.dispatchEvent("complete", false, Ntry.STATIC.NOT_FOUND_DESTORY_OBJECT); + return; + } this.isContinue = true; this.isAction = true; var self = this; - var callBack = function() { - self.isAction = false; + var callback = function() { + Ntry.dispatchEvent('destroyObstacle', 1, function (state) { + switch(state) { + case Ntry.STATIC.OBSTACLE_DESTROY_SUCCESS: + self.isAction = false; + break; + } + }); }; + // turn direction - Ntry.dispatchEvent("unitAction", Ntry.STATIC.WALK, callBack); + Ntry.dispatchEvent("unitAction", Ntry.STATIC.ATTACK, callback); return Entry.STATIC.BREAK; } else if (this.isAction) { @@ -18519,39 +20645,75 @@ Entry.block = { delete this.isAction; delete this.isContinue; } - }, - "syntax": [ - "Scope", - "move" - ] + } }, - "jr_turn_left": { + "maze_cony_flower_throw": { "skeleton": "basic", - "color": "#A751E3", + "mode": "maze", + "color": "#D8617D", + "syntax": [ + "Scope", + "right" + ], "params": [ - { - text: "왼쪽으로 돌기", - type: "Text" - }, { "type": "Image", - "img": "../../../img/assets/ntry/bitmap/jr/cparty_rotate_l.png", + "img": "/img/assets/maze/sprite/cony_icon.png", "size": 24 } ], func: function() { + var self = this; if (!this.isContinue) { - this.isContinue = true; this.isAction = true; - var self = this; - var callBack = function() { - self.isAction = false; - }; - // turn direction - Ntry.dispatchEvent("unitAction", Ntry.STATIC.TURN_LEFT, callBack); + var entities = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT); + var unitId; + $.each(entities, function (id, entity) { + unitId = id; + components = entity.components; + }); + + var unitComp = Ntry.entityManager.getComponent(unitId, Ntry.STATIC.UNIT); + var unitGrid = $.extend({}, Ntry.entityManager.getComponent(unitId, Ntry.STATIC.GRID)); + var isCollisionPossible = Ntry.checkCollisionTile(unitGrid, unitComp.direction, [Ntry.STATIC.OBSTACLE_SPIDER]); + var particleZIndex = 550; + if(unitComp.direction === Ntry.STATIC.NORTH) { + particleZIndex = 450; + } + if(!isCollisionPossible) { + Ntry.dispatchEvent("playSound", Ntry.STATIC.NOT_FOUND_DESTORY_OBJECT); + Ntry.dispatchEvent("complete", false, Ntry.STATIC.NOT_FOUND_DESTORY_OBJECT); + return; + } + var particle = Ntry.entityManager.addEntity(); + Ntry.dispatchEvent("unitAction", Ntry.STATIC.ATTACK, function () { + $.each(components, function(type, component) { + if(+type === Ntry.STATIC.SPRITE) { + var cloneComponent = $.extend({}, component); + cloneComponent.zIndex = particleZIndex; + Ntry.entityManager.addComponent(particle.id, cloneComponent); + } else if(+type != Ntry.STATIC.UNIT) { + Ntry.entityManager.addComponent(particle.id, component); + } else { + Ntry.entityManager.addComponent(particle.id, { + type: Ntry.STATIC.PARTICLE, + direction: component.direction, + collisionList: [ Ntry.STATIC.OBSTACLE_SPIDER ], + }); + } + }); + Ntry.dispatchEvent("particleAction", { + entityId: particle.id, + actionType: Ntry.STATIC.FLOWER_ATTACK, + callback: function () { + Ntry.entityManager.removeEntity(particle.id); + self.isAction = false; + } + }); + }); return Entry.STATIC.BREAK; } else if (this.isAction) { return Entry.STATIC.BREAK; @@ -18559,79 +20721,161 @@ Entry.block = { delete this.isAction; delete this.isContinue; } - }, - "syntax": [ - "Scope", - "left" - ] + } }, - "jr_turn_right": { + "maze_cony_flower_throw2": { "skeleton": "basic", - "color": "#A751E3", + "mode": "maze", + "color": "#D8617D", + "template": Lang.template.maze_cony_flower_throw, + "syntax": [ + "Scope", + "right" + ], "params": [ - { - text: "오른쪽으로 돌기", - type: "Text" - }, { "type": "Image", - "img": "../../../img/assets/ntry/bitmap/jr/cparty_rotate_r.png", + "img": "/img/assets/maze/sprite/cony_icon.png", "size": 24 } ], func: function() { + var self = this; if (!this.isContinue) { + var entities = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT); + + var unitId; + $.each(entities, function (id, entity) { + unitId = id; + components = entity.components; + }); + + var unitComp = Ntry.entityManager.getComponent(unitId, Ntry.STATIC.UNIT); + var unitGrid = $.extend({}, Ntry.entityManager.getComponent(unitId, Ntry.STATIC.GRID)); + var isCollisionPossible = Ntry.checkCollisionTile(unitGrid, unitComp.direction, [Ntry.STATIC.OBSTACLE_ENERMY5, Ntry.STATIC.OBSTACLE_ENERMY4], 2, true); + var particleZIndex = 550; + if(unitComp.direction === Ntry.STATIC.NORTH) { + particleZIndex = 450; + } + if(!isCollisionPossible) { + Ntry.dispatchEvent("playSound", Ntry.STATIC.NOT_FOUND_DESTORY_OBJECT); + Ntry.dispatchEvent("complete", false, Ntry.STATIC.NOT_FOUND_DESTORY_OBJECT); + return; + } + this.isContinue = true; this.isAction = true; - var self = this; - var callBack = function() { - self.isAction = false; - }; - // turn direction - Ntry.dispatchEvent("unitAction", Ntry.STATIC.TURN_RIGHT, callBack); + var particle = Ntry.entityManager.addEntity(); + + Ntry.dispatchEvent("unitAction", Ntry.STATIC.ATTACK, function () { + $.each(components, function(type, component) { + if(+type === Ntry.STATIC.SPRITE) { + var cloneComponent = $.extend({}, component); + cloneComponent.zIndex = particleZIndex; + Ntry.entityManager.addComponent(particle.id, cloneComponent); + } else if(+type != Ntry.STATIC.UNIT) { + Ntry.entityManager.addComponent(particle.id, component); + } else { + Ntry.entityManager.addComponent(particle.id, { + type: Ntry.STATIC.PARTICLE, + direction: component.direction, + collisionList: [Ntry.STATIC.OBSTACLE_ENERMY5, , Ntry.STATIC.OBSTACLE_ENERMY4], + penetrationList: [Ntry.STATIC.WALL], + }); + } + }); + Ntry.dispatchEvent("particleAction", { + entityId: particle.id, + actionType: Ntry.STATIC.HEART_ATTACK, + callback: function () { + Ntry.entityManager.removeEntity(particle.id); + self.isAction = false; + } + }); + }); return Entry.STATIC.BREAK; } else if (this.isAction) { - return Entry.STATIC.BREAK + return Entry.STATIC.BREAK; } else { delete this.isAction; delete this.isContinue; } - }, + } + }, + "maze_james_heart": { + "skeleton": "basic", + "mode": "maze", + "color": "#D39D18", "syntax": [ "Scope", "right" - ] - }, - "jr_go_slow": { - "skeleton": "basic", - "color": "#f46c6c", + ], "params": [ - { - text: "천천히 가기", - type: "Text" - }, { "type": "Image", - "img": "../../../img/assets/ntry/bitmap/jr/cparty_go_slow.png", + "img": "/img/assets/maze/sprite/james_icon.png", "size": 24 } ], func: function() { + var self = this; if (!this.isContinue) { + var entities = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT); + + var unitId; + $.each(entities, function (id, entity) { + unitId = id; + components = entity.components; + }); + + var unitComp = Ntry.entityManager.getComponent(unitId, Ntry.STATIC.UNIT); + var unitGrid = $.extend({}, Ntry.entityManager.getComponent(unitId, Ntry.STATIC.GRID)); + var isCollisionPossible = Ntry.checkCollisionTile(unitGrid, unitComp.direction, [Ntry.STATIC.OBSTACLE_ENERMY1, Ntry.STATIC.OBSTACLE_ENERMY2, Ntry.STATIC.OBSTACLE_ENERMY3, Ntry.STATIC.OBSTACLE_ENERMY5]); + var particleZIndex = 550; + if(unitComp.direction === Ntry.STATIC.NORTH) { + particleZIndex = 450; + } + if(!isCollisionPossible) { + Ntry.dispatchEvent("playSound", Ntry.STATIC.NOT_FOUND_DESTORY_OBJECT); + Ntry.dispatchEvent("complete", false, Ntry.STATIC.NOT_FOUND_DESTORY_OBJECT); + return; + } + this.isContinue = true; this.isAction = true; - var self = this; - var callBack = function() { - self.isAction = false; - }; - // turn direction - Ntry.dispatchEvent("unitAction", Ntry.STATIC.GO_SLOW, callBack); + var particle = Ntry.entityManager.addEntity(); + + Ntry.dispatchEvent("unitAction", Ntry.STATIC.ATTACK, function () { + $.each(components, function(type, component) { + if(+type === Ntry.STATIC.SPRITE) { + var cloneComponent = $.extend({}, component); + cloneComponent.zIndex = particleZIndex; + Ntry.entityManager.addComponent(particle.id, cloneComponent); + } else if(+type != Ntry.STATIC.UNIT) { + Ntry.entityManager.addComponent(particle.id, component); + } else { + Ntry.entityManager.addComponent(particle.id, { + type: Ntry.STATIC.PARTICLE, + direction: component.direction, + collisionList: [ Ntry.STATIC.OBSTACLE_ENERMY1, Ntry.STATIC.OBSTACLE_ENERMY2, Ntry.STATIC.OBSTACLE_ENERMY3, Ntry.STATIC.OBSTACLE_ENERMY5 ], + }); + } + }); + Ntry.dispatchEvent("particleAction", { + entityId: particle.id, + actionType: Ntry.STATIC.HEART_ATTACK, + callback: function () { + Ntry.entityManager.removeEntity(particle.id); + self.isAction = false; + } + }); + }); return Entry.STATIC.BREAK; } else if (this.isAction) { return Entry.STATIC.BREAK; @@ -18639,133 +20883,298 @@ Entry.block = { delete this.isAction; delete this.isContinue; } - }, - "syntax": [ - "Scope", - "move_slowly" - ] + } }, - "jr_repeat_until_dest": { - "skeleton": "basic_loop", - "color": "#498DEB", + "maze_james_heart2": { + "skeleton": "basic", + "mode": "maze", + "color": "#D39D18", + "template": Lang.template.maze_james_heart, "syntax": [ - "BasicWhile", - "true" + "Scope", + "right" ], "params": [ { "type": "Image", - "img": "../../../img/assets/ntry/bitmap/jr/jr_goal_image.png", - "size": 18 - }, - { - text: "만날 때 까지 반복하기", - type: "Text" - }, - { - "type": "Image", - "img": "/img/assets/week/blocks/for.png", + "img": "/img/assets/maze/sprite/james_icon.png", "size": 24 } ], - "statements": [ - { - "accept": "basic" - } - ], func: function() { - var statement = this.block.statements[0]; - if (statement.getBlocks().length === 0) - return; + var self = this; + if (!this.isContinue) { - this.executor.stepInto(statement); - return Entry.STATIC.BREAK; + var entities = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT); + + var unitId; + $.each(entities, function (id, entity) { + unitId = id; + components = entity.components; + }); + + var unitComp = Ntry.entityManager.getComponent(unitId, Ntry.STATIC.UNIT); + var unitGrid = $.extend({}, Ntry.entityManager.getComponent(unitId, Ntry.STATIC.GRID)); + var isCollisionPossible = Ntry.checkCollisionTile(unitGrid, unitComp.direction, [Ntry.STATIC.OBSTACLE_ENERMY3, Ntry.STATIC.OBSTACLE_ENERMY4], 2); + var particleZIndex = 550; + if(unitComp.direction === Ntry.STATIC.NORTH) { + particleZIndex = 450; + } + if(!isCollisionPossible) { + Ntry.dispatchEvent("playSound", Ntry.STATIC.NOT_FOUND_DESTORY_OBJECT); + Ntry.dispatchEvent("complete", false, Ntry.STATIC.NOT_FOUND_DESTORY_OBJECT); + return; + } + + this.isContinue = true; + this.isAction = true; + + var particle = Ntry.entityManager.addEntity(); + + Ntry.dispatchEvent("unitAction", Ntry.STATIC.ATTACK, function () { + $.each(components, function(type, component) { + if(+type === Ntry.STATIC.SPRITE) { + var cloneComponent = $.extend({}, component); + cloneComponent.zIndex = particleZIndex; + Ntry.entityManager.addComponent(particle.id, cloneComponent); + } else if(+type != Ntry.STATIC.UNIT) { + Ntry.entityManager.addComponent(particle.id, component); + } else { + Ntry.entityManager.addComponent(particle.id, { + type: Ntry.STATIC.PARTICLE, + direction: component.direction, + collisionList: [Ntry.STATIC.OBSTACLE_ENERMY3, Ntry.STATIC.OBSTACLE_ENERMY4, Ntry.STATIC.OBSTACLE_ENERMY_AREA], + penetrationList: [Ntry.STATIC.OBSTACLE_ENERMY_AREA], + }); + } + }); + + Ntry.dispatchEvent("particleAction", { + entityId: particle.id, + actionType: Ntry.STATIC.HEART_ATTACK, + callback: function () { + Ntry.entityManager.removeEntity(particle.id); + self.isAction = false; + } + }); + }); + return Entry.STATIC.BREAK; + } else if (this.isAction) { + return Entry.STATIC.BREAK; + } else { + delete this.isAction; + delete this.isContinue; + } } }, - "jr_if_construction": { - "skeleton": "basic_loop", - "color": "#498DEB", + "maze_iron_switch": { + "skeleton": "basic", + "mode": "maze", + "color": "#748d69", "syntax": [ - "BasicIf", - "front == 'wall'" + "Scope", + "right" ], "params": [ - { - text: "만약", - type: "Text" - }, { "type": "Image", - "img": "../../../img/assets/ntry/bitmap/jr/jr_construction_image.png", - "size": 18 - }, - { - text: "앞에 있다면", - type: "Text" - }, + "img": "/img/assets/maze/sprite/iron_icon.png", + "size": 24 + } + ], + func: function() { + if (!this.isContinue) { + this.isContinue = true; + this.isAction = true; + var eventCount = 0; + var self = this; + var gridSize = Ntry.configManager.getConfig("gridSize"); + var tileSize = Ntry.configManager.getConfig("tileSize").width; + var entities = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.OBSTACLE); + + for(var id in entities) { + var obstacleComp = Ntry.entityManager.getComponent(id, Ntry.STATIC.OBSTACLE); + if(obstacleComp.tileType === Ntry.STATIC.OBSTACLE_IRON) { + var obstacleGrid = Ntry.entityManager.getComponent(id, Ntry.STATIC.GRID); + var obstaclePosition = Ntry.entityManager.getComponent(id, Ntry.STATIC.POSITION); + var grid = { + x: obstacleGrid.x, + y: (obstacleGrid.y === 1) ? 3 : 1, + } + + obstacleGrid.y = (obstacleGrid.y === 1) ? 3 : 1; + + var deltaY = tileSize * 2; + + if(obstacleGrid.y === 1) { + deltaY = -deltaY; + } + + var deltaPos = { + x: 0, + y: deltaY * 0.5, + }; + + var deltaPos2 = { + x: 0, + y: deltaY, + }; + + var targetPos = { + minY: 0, + maxY: gridSize.height * tileSize, + }; + + if(deltaY > 0) { + targetPos.maxY = obstacleGrid.y * tileSize + (tileSize / 2); + } else { + targetPos.minY = obstacleGrid.y * tileSize + (tileSize / 2); + } + + (function (_id, _deltaPos, _deltaPos2, _targetPos, obstacleGrid) { + var comp = Ntry.entityManager.getComponent(_id, Ntry.STATIC.ANIMATE); + if(comp) { + if(eventCount === 0) { + self.isAction = false; + } + Ntry.entityManager.addComponent( + _id, { + type: Ntry.STATIC.ANIMATE, + animateType: Ntry.STATIC.TRANSITION, + duration: 20, + option: { + deltaPos: _deltaPos2, + targetPos: _targetPos, + }, + afterAnimate: function() { + var unitGrid = Ntry.getUtilGrid(); + + if(obstacleGrid.x == unitGrid.x && obstacleGrid.y == unitGrid.y) { + Ntry.dispatchEvent("unitAction", Ntry.STATIC.CONTACT_IRON2); + } + } + } + ); + } else { + Ntry.entityManager.addComponent( + _id, { + type: Ntry.STATIC.ANIMATE, + animateType: Ntry.STATIC.TRANSITION, + duration: 10, + option: { + deltaPos: _deltaPos, + }, + afterAnimate: function() { + if(eventCount === 0) { + self.isAction = false; + } + Ntry.entityManager.addComponent( + _id, { + type: Ntry.STATIC.ANIMATE, + animateType: Ntry.STATIC.TRANSITION, + duration: 10, + option: { + deltaPos: _deltaPos, + targetPos: _targetPos, + }, + afterAnimate: function() { + var unitGrid = Ntry.getUtilGrid(); + + if(obstacleGrid.x == unitGrid.x && obstacleGrid.y == unitGrid.y) { + console.log('충돌'); + // Ntry.dispatchEvent("playSound", Ntry.STATIC.NOT_FOUND_DESTORY_OBJECT); + Ntry.dispatchEvent("unitAction", Ntry.STATIC.CONTACT_IRON2); + // Ntry.dispatchEvent("complete", false, Ntry.STATIC.CONTACT_IRON2); + } + }, + } + ); + }, + } + ); + } + })(id, deltaPos, deltaPos2, targetPos, obstacleGrid); + } + } + return Entry.STATIC.BREAK; + } else if (this.isAction) { + return Entry.STATIC.BREAK; + } else { + delete this.isAction; + delete this.isContinue; + } + } + }, + "maze_brown_punch": { + "skeleton": "basic", + "mode": "maze", + "color": "#6C483A", + "syntax": [ + "Scope", + "right" + ], + "params": [ { "type": "Image", - "img": "/img/assets/week/blocks/for.png", + "img": "/img/assets/maze/sprite/brown_icon.png", "size": 24 } ], - "statements": [ - { - "accept": "basic" - } - ], func: function() { - if (this.isContinue) - return; - var entities = Ntry.entityManager.getEntitiesByComponent( - Ntry.STATIC.UNIT); - - var entity; - for (var key in entities) - entity = entities[key]; - - var unitComp = Ntry.entityManager.getComponent( - entity.id, Ntry.STATIC.UNIT); - var gridComp = Ntry.entityManager.getComponent( - entity.id, Ntry.STATIC.GRID); - - var grid = {x: gridComp.x, y: gridComp.y}; - Ntry.addVectorByDirection(grid, unitComp.direction, 1); + if (!this.isContinue) { + var self = this; + var entities = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT); + var unitId; + $.each(entities, function (id, entity) { + unitId = id; + components = entity.components; + }); + var unitComp = Ntry.entityManager.getComponent(unitId, Ntry.STATIC.UNIT); + var unitGrid = $.extend({}, Ntry.entityManager.getComponent(unitId, Ntry.STATIC.GRID)); + var isCollisionPossible = Ntry.checkCollisionTile(unitGrid, unitComp.direction, [Ntry.STATIC.OBSTACLE_ICE], 1); - var fitEntities = Ntry.entityManager.find( - { - type: Ntry.STATIC.GRID, - x: grid.x, - y: grid.y - }, - { - type: Ntry.STATIC.TILE, - tileType: Ntry.STATIC.OBSTACLE_REPAIR + if(!isCollisionPossible) { + Ntry.dispatchEvent("playSound", Ntry.STATIC.NOT_FOUND_DESTORY_OBJECT); + Ntry.dispatchEvent("complete", false, Ntry.STATIC.NOT_FOUND_DESTORY_OBJECT); + return; } - ); + this.isContinue = true; + this.isAction = true; - this.isContinue = true; + var callback = function() { + Ntry.dispatchEvent('destroyObstacle', 1, function (state) { + switch(state) { + case Ntry.STATIC.OBSTACLE_DESTROY_SUCCESS: + self.isAction = false; + break; + } + }); + }; - var statement = this.block.statements[0]; - if (fitEntities.length === 0) return; - else if (statement.getBlocks().length === 0) return; - else { - this.executor.stepInto(statement); + // turn direction + Ntry.dispatchEvent("unitAction", Ntry.STATIC.ATTACK, callback); + + return Entry.STATIC.BREAK; + } else if (this.isAction) { return Entry.STATIC.BREAK; + } else { + delete this.isAction; + delete this.isContinue; } } }, - "jr_if_speed": { + "maze_repeat_until_3": { "skeleton": "basic_loop", + "mode": "maze", "color": "#498DEB", "syntax": [ - "BasicIf", - "front == 'hump'" + "BasicWhile", + "true" ], "params": [ { "type": "Image", - "img": "../../../img/assets/ntry/bitmap/jr/jr_speed_image.png", + "img": "/img/assets/maze/bitmap/ws/tile_goal_01.png", "size": 18 }, { @@ -18779,135 +21188,81 @@ Entry.block = { "accept": "basic" } ], - func: function() { - if (this.isContinue) + func: function() { + var isGoal = false; + var statement = this.block.statements[0]; + if (statement.getBlocks().length === 0) { return; - var entities = Ntry.entityManager.getEntitiesByComponent( - Ntry.STATIC.UNIT); + } + var entities = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT); var entity; - for (var key in entities) + for (var key in entities){ entity = entities[key]; + } + + var unitComp = Ntry.entityManager.getComponent(entity.id, Ntry.STATIC.UNIT); - var unitComp = Ntry.entityManager.getComponent( - entity.id, Ntry.STATIC.UNIT); - var gridComp = Ntry.entityManager.getComponent( - entity.id, Ntry.STATIC.GRID); + if(unitComp.isStartedUnit) { + var unitGrid = Ntry.entityManager.getComponent(entity.id, Ntry.STATIC.GRID); + var entities = Ntry.entityManager.getEntitiesByGrid(unitGrid.x, unitGrid.y); - var grid = {x: gridComp.x, y: gridComp.y}; - Ntry.addVectorByDirection(grid, unitComp.direction, 1); + for(var idx in entities) { + var entity = entities[idx]; + var tile = Ntry.entityManager.getComponent(entity.id, Ntry.STATIC.TILE); + var item = Ntry.entityManager.getComponent(entity.id, Ntry.STATIC.ITEM); - var fitEntities = Ntry.entityManager.find( - { - type: Ntry.STATIC.GRID, - x: grid.x, - y: grid.y - }, - { - type: Ntry.STATIC.TILE, - tileType: Ntry.STATIC.OBSTACLE_SLOW + if(tile && item && tile.tileType === Ntry.STATIC.GOAL && item.itemType === Ntry.STATIC.GOAL_ITEM) { + isGoal = true; + break; + } } - ); - - this.isContinue = true; + } - var statement = this.block.statements[0]; - if (fitEntities.length === 0) return; - else if(statement.getBlocks().length === 0) return; - else { + if(!isGoal) { this.executor.stepInto(statement); return Entry.STATIC.BREAK; - } + } + // Ntry.dispatchEvent('executeEnd'); } }, - "maze_step_start": { - "skeleton": "basic_event", - "mode": "maze", - "event": "start", - "color": "#3BBD70", - "syntax": [ - "Program" - ], + "maze_repeat_until_4": { + "parent": "maze_repeat_until_3", "params": [ { - "type": "Indicator", - "boxMultiplier": 2, - "img": "../../../img/assets/block_icon/start_icon_play.png", - "highlightColor": "#3BBD70", - "size": 17, - "position": { - "x": 0, - "y": -2 - } + "type": "Image", + "img": "/img/assets/maze/bitmap/ws/tile_goal_02.png", + "size": 18 + }, + { + "type": "Image", + "img": "/img/assets/week/blocks/for.png", + "size": 24 } ], - "func": function () { - var entities = Ntry.entityManager.getEntitiesByComponent( - Ntry.STATIC.UNIT); - - for (var key in entities) - this._unit = entities[key]; - - Ntry.unitComp = Ntry.entityManager.getComponent( - this._unit.id, Ntry.STATIC.UNIT); - } }, - "maze_step_jump": { - "skeleton": "basic", - "mode": "maze", - "color": "#FF6E4B", + "maze_repeat_until_5": { + "parent": "maze_repeat_until_3", "params": [ { "type": "Image", - "img": "/img/assets/week/blocks/jump.png", + "img": "/img/assets/maze/bitmap/ws/tile_goal_03.png", + "size": 18 + }, + { + "type": "Image", + "img": "/img/assets/week/blocks/for.png", "size": 24 } ], - "syntax": [ "Scope", "jump" ], - func: function() { - if (!this.isContinue) { - this.isContinue = true; - this.isAction = true; - var self = this; - var callBack = function() { - self.isAction = false; - }; - - Ntry.dispatchEvent("unitAction", Ntry.STATIC.JUMP, callBack); - - return Entry.STATIC.BREAK; - } else if (this.isAction) { - return Entry.STATIC.BREAK; - } else { - delete this.isAction; - delete this.isContinue; - } - } }, - "maze_step_for": { - "skeleton": "basic_loop", - "mode": "maze", - "color": "#498DEB", - "syntax": [ - "BasicIteration" - ], + "maze_repeat_until_6": { + "parent": "maze_repeat_until_3", "params": [ { - "type": "Dropdown", - "key": "REPEAT", - "options": [ - [ 1, 1 ], - [ 2, 2 ], - [ 3, 3 ], - [ 4, 4 ], - [ 5, 5 ], - [ 6, 6 ], - [ 7, 7 ], - [ 8, 8 ], - [ 9, 9 ], - [ 10, 10 ] - ], - "value": 1 + "type": "Image", + "img": "/img/assets/maze/bitmap/ws/blcok-1.png", + "size": 18 }, { "type": "Image", @@ -18915,66 +21270,61 @@ Entry.block = { "size": 24 } ], - "statements": [ + }, + "maze_repeat_until_7": { + "parent": "maze_repeat_until_3", + "params": [ { - "accept": "basic" + "type": "Image", + "img": "/img/assets/maze/bitmap/ws/blcok-4.png", + "size": 18 + }, + { + "type": "Image", + "img": "/img/assets/week/blocks/for.png", + "size": 24 } ], - func: function() { - if (this.repeatCount === undefined) { - this.repeatCount = this.block.params[0]; - return Entry.STATIC.BREAK; - } else if (this.repeatCount > 0) { - this.repeatCount--; - var statement = this.block.statements[0]; - if (statement.getBlocks().length === 0) - return; - this.executor.stepInto(statement); - return Entry.STATIC.BREAK; - } else { - delete this.repeatCount; - } - } }, - "test": { - "skeleton": "basic_boolean_field", - "mode": "maze", - "color": "#127CDB", + "maze_repeat_until_8": { + "template": Lang.template.maze_repeat_until_7, + "parent": "maze_repeat_until_3", "params": [ { - "type": "Angle", - "value": "90" + "type": "Image", + "img": "/img/assets/maze/bitmap/ws/blcok-5.png", + "size": 18 }, { - "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 + "type": "Image", + "img": "/img/assets/week/blocks/for.png", + "size": 24 } - ] + ], }, - "maze_repeat_until_1": { - "skeleton": "basic_loop", - "mode": "maze", - "color": "#498DEB", - "syntax": [ - "BasicWhile", - "true" + "maze_repeat_until_9": { + "template": Lang.template.maze_repeat_until_7, + "parent": "maze_repeat_until_3", + "params": [ + { + "type": "Image", + "img": "/img/assets/maze/bitmap/ws/blcok-6.png", + "size": 18 + }, + { + "type": "Image", + "img": "/img/assets/week/blocks/for.png", + "size": 24 + } ], + }, + "maze_repeat_until_10": { + "template": Lang.template.maze_repeat_until_7, + "parent": "maze_repeat_until_3", "params": [ { "type": "Image", - "img": "/img/assets/ntry/block_inner/repeat_goal_1.png", + "img": "/img/assets/maze/bitmap/ws/blcok-7.png", "size": 18 }, { @@ -18983,32 +21333,14 @@ Entry.block = { "size": 24 } ], - "statements": [ - { - "accept": "basic" - } - ], - func: function() { - var statement = this.block.statements[0]; - if (statement.getBlocks().length === 0) - return; - - this.executor.stepInto(statement); - return Entry.STATIC.BREAK; - } }, - "maze_repeat_until_2": { - "skeleton": "basic_loop", - "mode": "maze", - "color": "#498DEB", - "syntax": [ - "BasicWhile", - "true" - ], + "maze_repeat_until_11": { + "template": Lang.template.maze_repeat_until_7, + "parent": "maze_repeat_until_3", "params": [ { "type": "Image", - "img": "/img/assets/ntry/block_inner/repeat_goal_1.png", + "img": "/img/assets/maze/bitmap/ws/blcok-9.png", "size": 18 }, { @@ -19017,247 +21349,146 @@ Entry.block = { "size": 24 } ], - "statements": [ - { - "accept": "basic" - } - ], - func: function() { - var statement = this.block.statements[0]; - if (statement.getBlocks().length === 0) - return; - - this.executor.stepInto(statement); - return Entry.STATIC.BREAK; - } }, - "maze_step_if_1": { - "skeleton": "basic_loop", - "mode": "maze", - "color": "#498DEB", - "syntax": [ - "BasicIf", - "front == 'wall'" - ], + "maze_repeat_until_12": { + "template": Lang.template.maze_repeat_until_7, + "parent": "maze_repeat_until_3", "params": [ { "type": "Image", - "img": "/img/assets/ntry/block_inner/if_target_1.png", + "img": "/img/assets/maze/bitmap/ws/blcok-10.png", "size": 18 }, { "type": "Image", - "img": "/img/assets/week/blocks/if.png", + "img": "/img/assets/week/blocks/for.png", "size": 24 } ], - "statements": [ - { - "accept": "basic" - } - ], - func: function() { - if (this.isContinue) - return; - var entities = - Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT); - - var entity; - for (var key in entities) - entity = entities[key]; - - var unitComp = Ntry.entityManager.getComponent( - entity.id, Ntry.STATIC.UNIT); - var gridComp = Ntry.entityManager.getComponent( - entity.id, Ntry.STATIC.GRID); - - var grid = {x: gridComp.x, y: gridComp.y}; - Ntry.addVectorByDirection(grid, unitComp.direction, 1); - - var existEntities = Ntry.entityManager.find( - { - type: Ntry.STATIC.GRID, - x: grid.x, - y: grid.y - }); - - var statement = this.block.statements[0]; - - if (existEntities.length === 0) { - this.executor.stepInto(statement); - return Entry.STATIC.BREAK; - } - - var fitEntities = Ntry.entityManager.find( - { - type: Ntry.STATIC.GRID, - x: grid.x, - y: grid.y - }, - { - type: Ntry.STATIC.TILE, - tileType: Ntry.STATIC.WALL - } - ); - - this.isContinue = true; - - if (fitEntities.length === 0) { - return; - } else if (statement.getBlocks().length === 0) - return; - else { - this.executor.stepInto(statement); - return Entry.STATIC.BREAK; - } - } }, - "maze_step_if_2": { - "skeleton": "basic_loop", - "mode": "maze", - "color": "#498DEB", - "syntax": [ - "BasicIf", - "front == 'bee'" - ], + "maze_repeat_until_13": { + "template": Lang.template.maze_repeat_until_7, + "parent": "maze_repeat_until_3", "params": [ { "type": "Image", - "img": "../../../img/assets/ntry/bitmap/maze2/obstacle_01.png", + "img": "/img/assets/maze/bitmap/ws/blcok-11.png", "size": 18 }, { "type": "Image", - "img": "/img/assets/week/blocks/if.png", + "img": "/img/assets/week/blocks/for.png", "size": 24 } ], - "statements": [ - { - "accept": "basic" - } - ], - func: function() { - if (this.isContinue) return; - - var entities = - Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT); - - var entity; - for (var key in entities) - entity = entities[key]; - - var unitComp = Ntry.entityManager.getComponent( - entity.id, Ntry.STATIC.UNIT); - var gridComp = Ntry.entityManager.getComponent( - entity.id, Ntry.STATIC.GRID); - - var grid = {x: gridComp.x, y: gridComp.y}; - Ntry.addVectorByDirection(grid, unitComp.direction, 1); - - var fitEntities = Ntry.entityManager.find( - { - type: Ntry.STATIC.GRID, - x: grid.x, - y: grid.y - }, - { - type: Ntry.STATIC.TILE, - tileType: Ntry.STATIC.OBSTACLE_BEE - } - ); - - this.isContinue = true; - - var statement = this.block.statements[0]; - if (fitEntities.length === 0) { - return; - } else if (statement.getBlocks().length === 0) - return; - else { - this.executor.stepInto(statement); - return Entry.STATIC.BREAK; - } - } }, - "maze_call_function": { - "skeleton": "basic", - "mode": "maze", - "color": "#B57242", - "syntax": [ - "Scope", - "promise" - ], + "maze_repeat_until_14": { + "template": Lang.template.maze_repeat_until_7, + "parent": "maze_repeat_until_3", "params": [ { "type": "Image", - "img": "/img/assets/week/blocks/function.png", + "img": "/img/assets/maze/bitmap/ws/blcok-12.png", + "size": 18 + }, + { + "type": "Image", + "img": "/img/assets/week/blocks/for.png", "size": 24 } ], - func: function() { - if (!this.funcExecutor) { - var codes = - Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.CODE); - - for (var key in codes) { - var code = codes[key].components[Ntry.STATIC.CODE].code; - this.funcExecutor = new Entry.Executor( - code.getEventMap("define")[0] - ); - } - } - - this.funcExecutor.execute(); - if (this.funcExecutor.scope.block === null) - return; - else - return Entry.STATIC.BREAK; - } }, - "maze_define_function": { - "skeleton": "basic_define", - "mode": "maze", - "color": "#B57242", - "event": "define", - "syntax": [ - "BasicFunction" - ], + "maze_repeat_until_15": { + "template": Lang.template.maze_repeat_until_7, + "parent": "maze_repeat_until_3", "params": [ { "type": "Image", - "img": "/img/assets/week/blocks/function.png", + "img": "/img/assets/maze/bitmap/ws/tile_goal_04.png", + "size": 18 + }, + { + "type": "Image", + "img": "/img/assets/week/blocks/for.png", "size": 24 } ], - "statements": [ + }, + "maze_radar_check": { + "skeleton": "basic_boolean_field", + "mode": "maze", + "color": "#AEB8FF", + "params": [ { - "accept": "basic" + "type": "Dropdown", + "options": [ + [Lang.Menus.maze_distance1, "1"], + [Lang.Menus.maze_distance2, "2"], + ], + "value": "1", + "fontSize": 11 + }, { + "type": "Dropdown", + "options": [ + [Lang.Menus.maze_object_trap, "TRAP"], + [Lang.Menus.maze_object_monster, "MONSTER"], + [Lang.Menus.maze_object_obstacle1, "OBSTACLE"], + ], + "value": "TRAP", + "fontSize": 11 } ], - func: function(executor) { - if (this.executed) - return; - var statement = this.block.statements[0]; - if (statement.getBlocks().length === 0) - return; - this.executor.stepInto(statement); - this.executed = true; - return Entry.STATIC.BREAK; + "paramsKeyMap": { + "DISTANCE": 0, + "TYPE": 1, + }, + func: function(sprite, script) { + var distance = script.getNumberField("DISTANCE", script); + var type = script.getField("TYPE", script); + + var entityId = Ntry.getRadarEntityIdByDistance(distance); + var tileType; + if(entityId) { + var tileComp = Ntry.entityManager.getComponent(entityId, Ntry.STATIC.TILE); + switch(tileComp.tileType) { + case Ntry.STATIC.OBSTACLE_HOLE: + tileType = 'TRAP'; + break; + case Ntry.STATIC.OBSTACLE_ENERMY1: + case Ntry.STATIC.OBSTACLE_ENERMY2: + case Ntry.STATIC.OBSTACLE_ENERMY3: + case Ntry.STATIC.OBSTACLE_ENERMY4: + case Ntry.STATIC.OBSTACLE_ENERMY5: + tileType = 'MONSTER'; + break; + case Ntry.STATIC.OBSTACLE_IRON: + tileType = 'OBSTACLE'; + break; + } + } else { + tileType = 'TRAP'; + } + + if(type === tileType) { + return true; + } else { + return false; + } } }, - "maze_step_if_3": { + // TODO: 해당 부분 수정 필요 + "maze_step_if_5": { "skeleton": "basic_loop", "mode": "maze", "color": "#498DEB", "syntax": [ "BasicIf", - "front == banana" + "front == bee" ], "params": [ { "type": "Image", - "img": "/img/assets/ntry/block_inner/if_target_3.png", + "img": "../../../img/assets/ntry/bitmap/maze2/obstacle_01.png", "size": 18 }, { @@ -19297,7 +21528,7 @@ Entry.block = { }, { type: Ntry.STATIC.TILE, - tileType: Ntry.STATIC.OBSTACLE_BANANA + tileType: Ntry.STATIC.OBSTACLE_BEE } ); @@ -19314,18 +21545,19 @@ Entry.block = { } } }, - "maze_step_if_4": { + // TODO: 해당 부분 수정 필요 + "maze_step_if_6": { "skeleton": "basic_loop", "mode": "maze", "color": "#498DEB", "syntax": [ "BasicIf", - "front == wall" + "front == bee" ], "params": [ { "type": "Image", - "img": "/img/assets/ntry/block_inner/if_target_2.png", + "img": "../../../img/assets/maze/bitmap/stage4/road_4_01.png", "size": 18 }, { @@ -19339,11 +21571,10 @@ Entry.block = { "accept": "basic" } ], - func: function() { + func: function() { if (this.isContinue) return; - var entities = - Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT); + var entities = Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT); var entity; for (var key in entities) @@ -19365,132 +21596,100 @@ Entry.block = { }, { type: Ntry.STATIC.TILE, - tileType: Ntry.STATIC.WALL + tileType: Ntry.STATIC.ROAD } ); this.isContinue = true; var statement = this.block.statements[0]; - if (fitEntities.length === 0) { + if (fitEntities.length > 0) { return; - } else if (statement.getBlocks().length === 0) + } else if (statement.getBlocks().length === 0){ return; - else { + } else { this.executor.stepInto(statement); return Entry.STATIC.BREAK; } } }, - "maze_step_move_step": { - "skeleton": "basic", + // TODO: 해당 부분 수정 필요 + "maze_step_if_7": { + "skeleton": "basic_loop", "mode": "maze", - "color": "#A751E3", + "color": "#498DEB", "syntax": [ - "Scope", - "move" + "BasicIf", + "front == ice" ], "params": [ { "type": "Image", - "img": "/img/assets/week/blocks/moveStep.png", + "img": "../../../img/assets/maze/bitmap/stage4/obj_ice_01.png", + "size": 18 + }, + { + "type": "Image", + "img": "/img/assets/week/blocks/if.png", "size": 24 } ], - func: function() { - if (!this.isContinue) { - this.isContinue = true; - this.isAction = true; - var self = this; - var callBack = function() { - self.isAction = false; - }; - // turn direction - Ntry.dispatchEvent("unitAction", Ntry.STATIC.WALK, callBack); - - return Entry.STATIC.BREAK; - } else if (this.isAction) { - return Entry.STATIC.BREAK; - } else { - delete this.isAction; - delete this.isContinue; - } - } - }, - "maze_step_rotate_left": { - "skeleton": "basic", - "mode": "maze", - "color": "#A751E3", - "syntax": [ - "Scope", - "left" - ], - "params": [ + "statements": [ { - "type": "Image", - "img": "/img/assets/week/blocks/turnL.png", - "size": 24 + "accept": "basic" } ], func: function() { - if (!this.isContinue) { + if (this.isContinue) return; - this.isContinue = true; - this.isAction = true; - var self = this; - var callBack = function() { - self.isAction = false; - }; + var entities = + Ntry.entityManager.getEntitiesByComponent(Ntry.STATIC.UNIT); - // turn direction - Ntry.dispatchEvent("unitAction", Ntry.STATIC.TURN_LEFT, callBack); + var entity; + for (var key in entities) + entity = entities[key]; - return Entry.STATIC.BREAK; - } else if (this.isAction) { - return Entry.STATIC.BREAK; - } else { - delete this.isAction; - delete this.isContinue; - } - } - }, - "maze_step_rotate_right": { - "skeleton": "basic", - "mode": "maze", - "color": "#A751E3", - "syntax": [ - "Scope", - "right" - ], - "params": [ - { - "type": "Image", - "img": "/img/assets/week/blocks/turnR.png", - "size": 24 - } - ], - func: function() { - if (!this.isContinue) { + var unitComp = Ntry.entityManager.getComponent( + entity.id, Ntry.STATIC.UNIT); + var gridComp = Ntry.entityManager.getComponent( + entity.id, Ntry.STATIC.GRID); - this.isContinue = true; - this.isAction = true; - var self = this; - var callBack = function() { - self.isAction = false; - }; + var grid = {x: gridComp.x, y: gridComp.y}; + Ntry.addVectorByDirection(grid, unitComp.direction, 1); - // turn direction - Ntry.dispatchEvent("unitAction", Ntry.STATIC.TURN_RIGHT, callBack); + var fitEntities = Ntry.entityManager.find( + { + type: Ntry.STATIC.GRID, + x: grid.x, + y: grid.y + }, + { + type: Ntry.STATIC.TILE, + tileType: Ntry.STATIC.OBSTACLE_ICE + } + ); + this.isContinue = true; + + var statement = this.block.statements[0]; + if (fitEntities.length === 0) { + return; + } else if (statement.getBlocks().length === 0) + return; + else { + this.executor.stepInto(statement); return Entry.STATIC.BREAK; - } else if (this.isAction) { - return Entry.STATIC.BREAK; - } else { - delete this.isAction; - delete this.isContinue; } } }, + "maze_step_if_8": { + "parent": "_if", + "class": "", + }, + "maze_step_if_else": { + "parent": "if_else", + "class": "", + }, "test_wrapper": { "skeleton": "basic", "mode": "maze", @@ -20825,121 +23024,12 @@ Entry.block = { "type": "sensorBoard_get_number_sensor_value" }, "class": "arduino_value", - "syntax": {"js": [], "py": ["hw.sensorBoard_get_number_sensor_value(%1)"]} - }, - "sensorBoard_get_digital_value": { - "parent": "arduino_get_digital_value", - "isNotFor": [ - "sensorBoard" - ], - "def": { - "params": [ - { - "type": "arduino_get_port_number" - } - ], - "type": "sensorBoard_get_digital_value" - }, - "class": "arduino_value", - "syntax": {"js": [], "py": ["hw.sensorBoard_get_digital_value(%1)"]} - }, - "sensorBoard_toggle_led": { - "parent": "arduino_toggle_led", - "isNotFor": [ - "sensorBoard" - ], - "def": { - "params": [ - { - "type": "arduino_get_port_number" - }, - null, - null - ], - "type": "sensorBoard_toggle_led" - }, - "class": "arduino_set", - "syntax": {"js": [], "py": ["hw.sensorBoard_toggle_led(%1)"]} - }, - "sensorBoard_toggle_pwm": { - "parent": "arduino_toggle_pwm", - "isNotFor": [ - "sensorBoard" - ], - "def": { - "params": [ - { - "type": "arduino_get_pwm_port_number" - }, - { - "type": "arduino_text", - "params": [ "255" ] - }, - null - ], - "type": "sensorBoard_toggle_pwm" - }, - "class": "arduino_set", - "syntax": {"js": [], "py": ["hw.sensorBoard_toggle_pwm(%1, %2)"]} - }, - "sensorBoard_convert_scale": { - "parent": "arduino_convert_scale", - "isNotFor": [ - "sensorBoard" - ], - "def": { - "params": [ - { - "type": "arduino_get_number_sensor_value", - "params": [ - { - "type": "arduino_get_sensor_number", - "id": "bl5e" - } - ] - }, - { - "type": "number", - "params": [ "0" ] - }, - { - "type": "number", - "params": [ "1023" ] - }, - { - "type": "number", - "params": [ "0" ] - }, - { - "type": "number", - "params": [ "100" ] - } - ], - "type": "sensorBoard_convert_scale" - }, - "class": "arduino", - "syntax": {"js": [], "py": ["hw.sensorBoard_convert_scale(%1, %2, %3, %4, %5)"]} - }, - "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)"]} + "syntax": {"js": [], "py": ["hw.sensorBoard_get_number_sensor_value(%1)"]} }, - "CODEino_get_digital_value": { + "sensorBoard_get_digital_value": { "parent": "arduino_get_digital_value", "isNotFor": [ - "CODEino" + "sensorBoard" ], "def": { "params": [ @@ -20947,15 +23037,15 @@ Entry.block = { "type": "arduino_get_port_number" } ], - "type": "CODEino_get_digital_value" + "type": "sensorBoard_get_digital_value" }, "class": "arduino_value", - "syntax": {"js": [], "py": ["hw.CODEino_get_digital_value(%1)"]} + "syntax": {"js": [], "py": ["hw.sensorBoard_get_digital_value(%1)"]} }, - "CODEino_toggle_led": { + "sensorBoard_toggle_led": { "parent": "arduino_toggle_led", "isNotFor": [ - "CODEino" + "sensorBoard" ], "def": { "params": [ @@ -20965,15 +23055,15 @@ Entry.block = { null, null ], - "type": "CODEino_toggle_led" + "type": "sensorBoard_toggle_led" }, "class": "arduino_set", - "syntax": {"js": [], "py": ["hw.CODEino_toggle_led(%1)"]} + "syntax": {"js": [], "py": ["hw.sensorBoard_toggle_led(%1)"]} }, - "CODEino_toggle_pwm": { + "sensorBoard_toggle_pwm": { "parent": "arduino_toggle_pwm", "isNotFor": [ - "CODEino" + "sensorBoard" ], "def": { "params": [ @@ -20986,15 +23076,15 @@ Entry.block = { }, null ], - "type": "CODEino_toggle_pwm" + "type": "sensorBoard_toggle_pwm" }, "class": "arduino_set", - "syntax": {"js": [], "py": ["hw.CODEino_toggle_pwm(%1, %2)"]} + "syntax": {"js": [], "py": ["hw.sensorBoard_toggle_pwm(%1, %2)"]} }, - "CODEino_convert_scale": { + "sensorBoard_convert_scale": { "parent": "arduino_convert_scale", "isNotFor": [ - "CODEino" + "sensorBoard" ], "def": { "params": [ @@ -21002,7 +23092,8 @@ Entry.block = { "type": "arduino_get_number_sensor_value", "params": [ { - "type": "arduino_get_sensor_number" + "type": "arduino_get_sensor_number", + "id": "bl5e" } ] }, @@ -21023,10 +23114,10 @@ Entry.block = { "params": [ "100" ] } ], - "type": "CODEino_convert_scale" + "type": "sensorBoard_convert_scale" }, "class": "arduino", - "syntax": {"js": [], "py": ["hw.CODEino_convert_scale(%1, %2, %3, %4, %5)"]} + "syntax": {"js": [], "py": ["hw.sensorBoard_convert_scale(%1, %2, %3, %4, %5)"]} }, // ardublock Added 2016-06-01 "ardublock_get_number_sensor_value": { @@ -22354,7 +24445,7 @@ Entry.block = { Entry.hw.portData[Entry.Roborobo_Roduino.ColorPin[1] - 2], Entry.hw.portData[Entry.Roborobo_Roduino.ColorPin[2] - 2] ]; - + switch(signal) { case "red": if(value[0] == 1 && value[1] == 0 && value[2] == 0) { @@ -22426,7 +24517,7 @@ Entry.block = { var pin = script.getNumberValue("VALUE", script); var operator = script.getField("OPERATOR"); var value = operator == "on" ? 1 : 0; - + Entry.Roborobo_Roduino.setSendData([Entry.Roborobo_Roduino.INSTRUCTION.DIGITAL_WRITE, pin, value]); return script.callReturn(); } @@ -22440,7 +24531,7 @@ Entry.block = { "type": "Dropdown", "options": [ [ Lang.Blocks.roborobo_motor1, "motor1" ], - [ Lang.Blocks.roborobo_motor2, "motor2" ] + [ Lang.Blocks.roborobo_motor2, "motor2" ] ], "value": "motor1", "fontSize": 11, @@ -22483,7 +24574,7 @@ Entry.block = { var value1 = value2 = 0; var mode = script.getField("MODE"); var operator = script.getField("OPERATOR"); - + if(mode == "motor1") { pin1 = 9; pin2 = 10; @@ -22491,7 +24582,7 @@ Entry.block = { pin1 = 11; pin2 = 12; } - + if (operator == "cw") { value1 = 1; value2 = 0; @@ -22559,7 +24650,7 @@ Entry.block = { var redPin = script.getNumberValue("RED", script); var greenPin = script.getNumberValue("GREEN", script); var bluePin = script.getNumberValue("BLUE", script); - + Entry.Roborobo_Roduino.ColorPin = [ redPin, greenPin, bluePin ]; Entry.Roborobo_Roduino.setSendData([Entry.Roborobo_Roduino.INSTRUCTION.COLOR, redPin, greenPin, bluePin]); return script.callReturn(); @@ -22674,7 +24765,7 @@ Entry.block = { "func": function (sprite, script) { return script.getNumberField("PORT"); } - }, + }, "schoolkit_set_output": { "color": "#00979D", "skeleton": "basic", @@ -22721,7 +24812,7 @@ Entry.block = { var pin = script.getNumberValue("VALUE", script); var operator = script.getField("OPERATOR"); var value = operator == "on" ? 1 : 0; - + Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.DIGITAL_WRITE, pin, value]); return script.callReturn(); } @@ -22766,7 +24857,7 @@ Entry.block = { "type": "Dropdown", "options": [ [ Lang.Blocks.roborobo_motor1, "motor1" ], - [ Lang.Blocks.roborobo_motor2, "motor2" ] + [ Lang.Blocks.roborobo_motor2, "motor2" ] ], "value": "motor1", "fontSize": 11, @@ -22786,7 +24877,7 @@ Entry.block = { "value": "cw", "fontSize": 11, 'arrowColor': EntryStatic.ARROW_COLOR_HW - }, + }, { "type": "Indicator", "img": "block_icon/hardware_03.png", @@ -22796,7 +24887,7 @@ Entry.block = { "events": {}, "def": { "params": [ - null, + null, { "type": "number", "params": [ "0" ] @@ -22807,9 +24898,9 @@ Entry.block = { "type": "schoolkit_motor" }, "paramsKeyMap": { - "MODE": 0, + "MODE": 0, "VALUE": 1, - "OPERATOR": 2 + "OPERATOR": 2 }, "class": "schoolkit_set", "isNotFor": [ "roborobo_schoolkit" ], @@ -22819,7 +24910,7 @@ Entry.block = { var mode = script.getField("MODE"); var operator = script.getField("OPERATOR"); var value = script.getNumberValue("VALUE"); - + if(mode == "motor1") { pin = 7; } else { @@ -22830,7 +24921,7 @@ Entry.block = { } else if(value < 0) { value = 0; } - + if (operator == "cw") { operatorValue = 1; Entry.Roborobo_SchoolKit.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.MOTOR, operatorValue, pin, value]); @@ -22885,17 +24976,569 @@ Entry.block = { "func": function (sprite, script) { var pin = script.getNumberValue("PIN", script); var value = script.getNumberValue("VALUE"); - + if(value < 0) { value = 0; } else if(value > 180) { value = 180; } - + Entry.Roborobo_Roduino.setSendData([Entry.Roborobo_SchoolKit.INSTRUCTION.SERVO, pin, value]); return script.callReturn(); } - } + }, + codestar_color_single: { + color: '#00979D', + skeleton: 'basic', + statements: [], + template: '%1 LED %2 %3', + params: [{ + type: 'Dropdown', + options: [[Lang.Hw.leftEye, 7], [Lang.Hw.rightEye, 8]] + }, { + type: 'Dropdown', + options: [[Lang.Blocks.ARDUINO_on,"on"], [Lang.Blocks.ARDUINO_off,"off"]], + }, { + type: 'Indicator', + img: 'block_icon/hardware_03.png', + size: 12 + }], + events: {}, + def: { + params: [7, 'on', null], + type: 'codestar_color_single' + }, + paramsKeyMap: { + PORT: 0, + ONOFF: 1 + }, + class: 'codestar_output_sensor', + isNotFor: ['codestar'], + func: function (sprite, script) { + var port = script.getField('PORT'); + var onoff = script.getField('ONOFF'); + var value = onoff == 'on' ? 255 : 0; + Entry.hw.setDigitalPortValue(port, value); + return script.callReturn(); + } + }, + codestar_3color: { + color: '#00979D', + skeleton: 'basic', + statements: [], + template: '3색 LED %1 밝기 %2 %3', + params: [{ + type: 'Dropdown', + options: [['빨간색', 9], + ['초록색', 10], + ['파란색', 11]] + }, { + type: 'Block', + accept: 'string' + }, { + type: 'Indicator', + img: 'block_icon/hardware_03.png', + size: 12 + }], + events: {}, + def: { + params: [9, {type:'number', params: [120]}, null], + type: 'codestar_3color' + }, + paramsKeyMap: { + PORT: 0, + VALUE: 1 + }, + class: 'codestar_output_sensor', + isNotFor: ['codestar'], + func: function (sprite, script) { + var port = script.getField('PORT'); + var value = script.getNumberValue('VALUE'); + value = Math.round(value); + value = Math.max(value, 0); + value = Math.min(value, 255); + Entry.hw.setDigitalPortValue(port, value); + return script.callReturn(); + } + }, + codestar_vibration: { + color: '#00979D', + skeleton: 'basic', + statements: [], + template: '진동모터 %1 %2', + params: [{ + type: 'Dropdown', + options: [[Lang.Blocks.ARDUINO_on,"on"], [Lang.Blocks.ARDUINO_off,"off"]], + }, { + type: 'Indicator', + img: 'block_icon/hardware_03.png', + size: 12 + }], + events: {}, + def: { + params: ['on', null], + type: 'codestar_vibration' + }, + paramsKeyMap: { + ONOFF: 0 + }, + class: 'codestar_output_sensor', + isNotFor: ['codestar'], + func: function (sprite, script) { + var port = 13; + var onoff = script.getField('ONOFF'); + var value = onoff == 'on' ? 255 : 0; + Entry.hw.setDigitalPortValue(port, value); + return script.callReturn(); + } + }, + codestar_buzzer: { + color: '#00979D', + skeleton: 'basic', + statements: [], + template: '부저 톤%1 %2', + params: [{ + type: 'Dropdown', + options: [['G3', 1], ['A3', 2], ['B3', 3], ['C4', 4], ['D4', 5], ['E4', 6], ['F4', 7], ['G4', 8], ['A4', 9], ['B4', 10], ['C5', 11], ['D5', 12], ['E5', 13], ['F5', 14]] + }, { + type: 'Indicator', + img: 'block_icon/hardware_03.png', + size: 12 + }], + events: {}, + def: { + params: [4, null], + type: 'codestar_buzzer' + }, + paramsKeyMap: { + TONE: 0 + }, + class: 'codestar_output_sensor', + isNotFor: ['codestar'], + func: function (sprite, script) { + var tone = script.getField('TONE'); + Entry.hw.setDigitalPortValue(15, tone); + return script.callReturn(); + } + }, + codestar_buzzer_stop: { + color: '#00979D', + skeleton: 'basic', + statements: [], + template: '부저 중지 %1', + params: [{ + type: 'Indicator', + img: 'block_icon/hardware_03.png', + size: 12 + }], + events: {}, + def: { + params: [null], + type: 'codestar_buzzer_stop' + }, + paramsKeyMap: {}, + class: 'codestar_output_sensor', + isNotFor: ['codestar'], + func: function (sprite, script) { + Entry.hw.setDigitalPortValue(15, 24); + return script.callReturn(); + } + }, + codestar_servo: { + color: '#00979D', + skeleton: 'basic', + statements: [], + template: '서버모터 %1 모터값 %2 %3', + params: [{ + type: 'Dropdown', + options: [['D3', 'D3'], ['D5', 'D5'], ['D6', 'D6'], ['D9', 'D9'], ['D10', 'D10'], ['D11', 'D11']] + }, { + type: 'Block', + accept: 'string' + }, { + type: 'Indicator', + img: 'block_icon/hardware_03.png', + size: 12 + }], + events: {}, + def: { + params: ['D3', {type:'number', params: [90]}, null], + type: 'codestar_servo' + }, + paramsKeyMap: { + PORT: 0, + VALUE: 1 + }, + class: 'codestar_motor', + isNotFor: ['codestar'], + func: function (sprite, script) { + var value = script.getNumberValue('VALUE'); + var sq = Entry.hw.sendQueue; + sq.outport = script.getField('PORT'); + sq.value = 0; + if(!isNaN(value)){ + var tmp = value; + if(value < 0) tmp = 0; + if(value > 255) tmp = 255; + sq.value = tmp; + } + return script.callReturn(); + } + }, + codestar_drive: { + color: '#00979D', + skeleton: 'basic', + statements: [], + template: '방향 %1 속도 %2 %3', + params: [{ + type: 'Dropdown', + options: [['앞으로', '0'], ['뒤로', '1'], ['왼쪽', '2'], ['오른쪽', '3']] + }, { + type: 'Block', + accept: 'string' + }, { + type: 'Indicator', + img: 'block_icon/hardware_03.png', + size: 12 + }], + events: {}, + def: { + params: ['0', {type:'number', params: [100]}, null], + type: 'codestar_drive' + }, + paramsKeyMap: { + DIRECTION: 0, + VALUE: 1 + }, + class: 'codestar_motor', + isNotFor: ['codestar'], + func: function (sprite, script) { + var value = script.getNumberValue('VALUE'); + var dir = Number(script.getField('DIRECTION')); + var id = 0; + //if(value == 0) value = 1; + value = Math.round(value); + value = Math.max(value, 0); + value = Math.min(value, 255); + + value = Math.round(value/30); + //if(value == 0) value = 1; + var query = (id << 7) + (dir << 5) + value; + Entry.hw.setDigitalPortValue(14, query); + return script.callReturn(); + } + }, + codestar_wheel: { + color: '#00979D', + skeleton: 'basic', + statements: [], + template: '방향 %1 바퀴속도 %2 %3', + params: [{ + type: 'Dropdown', + options: [['왼쪽', '0'], ['오른쪽', '1']] + }, { + type: 'Block', + accept: 'string' + }, { + type: 'Indicator', + img: 'block_icon/hardware_03.png', + size: 12 + }], + events: {}, + def: { + params: ['0', {type:'number', params: [100]}, null], + type: 'codestar_wheel' + }, + paramsKeyMap: { + DIRECTION: 0, + VALUE: 1 + }, + class: 'codestar_motor', + isNotFor: ['codestar'], + func: function (sprite, script) { + var value = script.getNumberValue('VALUE'); + var dir = Number(script.getField('DIRECTION')); + var id = 1; + //if(value == 0)value = 1; + value = Math.round(value); + value = Math.max(value, -255); + value = Math.min(value, 255); + if( value < 0 ){ + dir = 2+dir; + value *=-1; + } + value = Math.round(value/30); + //if(value == 0) value = 1; + var query = (id << 7) + (dir << 5) + value; + Entry.hw.setDigitalPortValue(14, query); + return script.callReturn(); + } + }, + codestar_light: { + color: '#00979D', + fontColor: '#fff', + skeleton: 'basic_string_field', + statements: [], + template: '밝기센서', + params: [], + events: {}, + def: { + params: [], + type: 'codestar_light' + }, + paramsKeyMap: {}, + class: 'codestar_input_sensor', + isNotFor: ['codestar'], + func: function (sprite, script) { + return Entry.hw.getAnalogPortValue('6'); + } + }, + codestar_button: { + color: '#00979D', + fontColor: '#fff', + skeleton: 'basic_string_field', + statements: [], + template: '버튼', + params: [], + events: {}, + def: { + params: [], + type: 'codestar_button' + }, + paramsKeyMap: {}, + class: 'codestar_input_sensor', + isNotFor: ['codestar'], + func: function (sprite, script) { + 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 (sprite, script) { + var port = script.getField('PORT'); + return Entry.hw.getAnalogPortValue(port); + } + }, + codestar_sonar: { + color: '#00979D', + fontColor: '#fff', + skeleton: 'basic_string_field', + statements: [], + template: '초음파', + params: [], + events: {}, + def: { + params: [], + type: 'codestar_sonar' + }, + paramsKeyMap: {}, + class: 'codestar_input_sensor', + isNotFor: ['codestar'], + func: function (sprite, script) { + return Entry.hw.portData.sonar; + } + }, + codestar_variable_R: { + color: '#00979D', + fontColor: '#fff', + skeleton: 'basic_string_field', + statements: [], + template: '가변저항 %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 (sprite, script) { + var port = script.getField('PORT'); + return Entry.hw.getAnalogPortValue(port); + } + }, + codestar_mic: { + color: '#00979D', + fontColor: '#fff', + skeleton: 'basic_string_field', + statements: [], + template: '마이크', + params: [], + events: {}, + def: { + params: [], + type: 'codestar_mic' + }, + paramsKeyMap: {}, + class: 'codestar_input_sensor', + isNotFor: ['codestar'], + func: function (sprite, script) { + return Entry.hw.getAnalogPortValue('2'); + } + }, + codestar_temperature: { + color: '#00979D', + fontColor: '#fff', + skeleton: 'basic_string_field', + statements: [], + template: '온도', + params: [], + events: {}, + def: { + params: [], + type: 'codestar_temperature' + }, + paramsKeyMap: {}, + class: 'codestar_input_sensor', + isNotFor: ['codestar'], + func: function (sprite, script) { + return Entry.hw.portData.temperature; + } + }, + codestar_gyroscope: { + color: '#00979D', + fontColor: '#fff', + skeleton: 'basic_string_field', + statements: [], + template: '3축 자이로 %1 축 %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 (sprite, script) { + return Entry.hw.getAnalogPortValue('gyro_'+axis); + } + }, + codestar_geomagnetic: { + color: '#00979D', + fontColor: '#fff', + skeleton: 'basic_string_field', + statements: [], + template: '3축 지자기 %1 축 %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 (sprite, script) { + var axis = script.getField('AXIS'); + return Entry.hw.getAnalogPortValue('geo_'+axis); + } + }, + codestar_irR: { + color: '#00979D', + fontColor: '#fff', + skeleton: 'basic_string_field', + statements: [], + template: 'IR 리모콘', + params: [], + events: {}, + def: { + params: [], + type: 'codestar_irR' + }, + paramsKeyMap: {}, + class: 'codestar_input_sensor', + isNotFor: ['codestar'], + func: function (sprite, script) { + return Entry.hw.getDigitalPortValue('4'); + } + }, + codestar_tilt: { + color: '#00979D', + fontColor: '#fff', + skeleton: 'basic_string_field', + statements: [], + template: '틸트', + params: [], + events: {}, + def: { + params: [], + type: 'codestar_tilt' + }, + paramsKeyMap: {}, + class: 'codestar_input_sensor', + isNotFor: ['codestar'], + func: function (sprite, script) { + return Entry.hw.getDigitalPortValue('6'); + } + }, + "hidden": { + "color": "#7C7C7C", + "skeleton": "basic", + "template": " ? %1", + "statements": [], + "params": [ + { + "type": "Indicator", + "color": "#6B6B6B", + "size": 12 + } + ], + "events": {}, + "def": { + "params": [ + null + ], + "type": "hidden" + }, + "paramsKeyMap": { + "VALUE": 0 + }, + "class": "etc", + "isNotFor": [], + "func": function (sprite, script) { + } + } }; (function() { diff --git a/src/workspace/block_menu.js b/src/workspace/block_menu.js index 43c03e6012..c91e9fd2c2 100644 --- a/src/workspace/block_menu.js +++ b/src/workspace/block_menu.js @@ -39,7 +39,6 @@ Entry.BlockMenu = function(dom, align, categoryData, scroll) { this.svg = Entry.SVG(this._svgId); Entry.Utils.addFilters(this.svg, this.suffix); var returnVal = Entry.Utils.addBlockPattern(this.svg, this.suffix); - this.patternRect = returnVal.rect; this.pattern = returnVal.pattern; this.svgGroup = this.svg.elem("g"); @@ -250,7 +249,7 @@ Entry.BlockMenu = function(dom, align, categoryData, scroll) { .getFirstBlock().view; var offset = this.offset(); - var distance = offset.top - board.offset().top; + var distance = offset.top - board.offset().top - $(window).scrollTop(); var dx, dy; @@ -633,13 +632,8 @@ Entry.BlockMenu = function(dom, align, categoryData, scroll) { } }; - p.setPatternRectFill = function(color) { - this.patternRect.attr({ - fill:color - }); - this.pattern.attr({ - style: "" - }); + p.enablePattern = function() { + this.pattern.removeAttribute('style'); }; p.disablePattern = function() { diff --git a/src/workspace/block_menu_scroll.js b/src/workspace/block_menu_scroll.js index b4e6ccf745..87656f3b45 100644 --- a/src/workspace/block_menu_scroll.js +++ b/src/workspace/block_menu_scroll.js @@ -31,6 +31,7 @@ Entry.BlockMenuScroller = function(board) { this.setOpacity(0); this._addControl(); + this._domHeight = 0; if (Entry.windowResized) Entry.windowResized.attach(this, this.resizeScrollBar); }; @@ -54,9 +55,15 @@ Entry.BlockMenuScroller.RADIUS = 7; p.resizeScrollBar = function() { this._updateRatio(); + + var dom = this.board.blockMenuContainer; + var newHeight = dom.height(); + if (newHeight !== this._domHeight) { + this._domHeight = newHeight; + return this.board.align(); + } if (!this._visible || this.vRatio === 0) return; var that = this; - var dom = this.board.blockMenuContainer; this.vScrollbar.attr({ width: 9, @@ -123,7 +130,7 @@ Entry.BlockMenuScroller.RADIUS = 7; height: bRect.height }; - var vRatio = (bBox.height + bBox.y + 10)/realHeight; + var vRatio = (bBox.height + 20)/realHeight; this.vRatio = vRatio; if (vRatio <= 1) this.setVisible(false); diff --git a/src/workspace/block_view.js b/src/workspace/block_view.js index ac1b752923..75d075f36e 100644 --- a/src/workspace/block_view.js +++ b/src/workspace/block_view.js @@ -18,24 +18,32 @@ Entry.BlockView = function(block, board, mode) { this.set(block); this.svgGroup = board.svgBlockGroup.elem("g"); - this._schema = Entry.block[block.type]; + this._schema = Entry.skinContainer.getSkin(block); if (this._schema === undefined) { this.block.destroy(false, false); return; } + if (this._schema.deletable) + this.block.setDeletable(this._schema.deletable) + if (this._schema.copyable) + this.block.setCopyable(this._schema.copyable) + if (this._schema.display === false) + this.set({display: false}) if (this._schema.changeEvent) this._schemaChangeEvent = this._schema.changeEvent.attach( this, this._updateSchema); + var skeleton = this._skeleton = Entry.skeleton[this._schema.skeleton]; this._contents = []; this._statements = []; + this._extensions = []; this.magnet = {}; this._paramMap = {}; if (skeleton.magnets && skeleton.magnets(this).next) { this.svgGroup.nextMagnet = this.block; - this._nextGroup = this.svgGroup.elem("g"); + this._nextGroup = this.svgGroup.elem("g", {class: 'entryBlockNextGroup'}); this._observers.push(this.observe(this, "_updateMagnet", ["contentHeight"])); } @@ -47,8 +55,6 @@ Entry.BlockView = function(block, board, mode) { events.mousedown.forEach(function(fn){fn(that);}); that.onMouseDown.apply(that, arguments); - - }; this._startRender(block, mode); @@ -105,6 +111,11 @@ Entry.BlockView.pngMap = {}; class: "block" }); + if (this._schema.css) + this.svgGroup.attr({ + style: this._schema.css + }); + var classes = skeleton.classes; if (classes && classes.length !== 0) classes.forEach(function(c){that.svgGroup.addClass(c);}); @@ -116,7 +127,8 @@ Entry.BlockView.pngMap = {}; this._path = this.pathGroup.elem("path"); - if (this.getBoard().patternRect) { + //enable mouse pattern only for desktou + if (!Entry.isMobile()) { $(this._path).mouseenter(function(e) { if (!that._mouseEnable) return; that._changeFill(true); @@ -152,26 +164,36 @@ Entry.BlockView.pngMap = {}; this._moveTo(this.x, this.y, false); this._startContentRender(mode); + this._startExtension(mode) if (this._board.disableMouseEvent !== true) { this._addControl(); } + var guide = this.guideSvgGroup; + guide && this.svgGroup.insertBefore(guide, this.svgGroup.firstChild); + this.bindPrev(); }; p._startContentRender = function(mode) { mode = mode === undefined ? Entry.Workspace.MODE_BOARD : mode; + + var schema = this._schema; if (this.contentSvgGroup) this.contentSvgGroup.remove(); - var schema = this._schema; - if (schema.statements && schema.statements.length && this.statementSvgGroup) + if (this.statementSvgGroup) this.statementSvgGroup.remove(); + this._contents = []; - this.contentSvgGroup = this.svgGroup.elem("g"); - if (schema.statements && schema.statements.length) - this.statementSvgGroup = this.svgGroup.elem("g"); + this.contentSvgGroup = this.svgGroup.elem("g", {class:'contentsGroup'}); + if (schema.statements && schema.statements.length) { + this.statementSvgGroup = this.svgGroup.elem("g", { + class: 'statementGroup' + }); + } + switch (mode) { case Entry.Workspace.MODE_BOARD: case Entry.Workspace.MODE_OVERLAYBOARD: @@ -180,7 +202,9 @@ Entry.BlockView.pngMap = {}; var templateParams = template.split(reg); var params = schema.params; for (var i=0; i 1 && Entry.isOffline) { + topBlock.view.getDataUrl().then(function(data) { + images.push(data); + //console.log('add an image'); + if (images.length == threads.length) { + //console.log('images completely added'); + Entry.dispatchEvent( + 'saveBlockImages', + { images: images } + ); + } + + }); + } else { + topBlock.view.downloadAsImage(++i); + } + }); } } diff --git a/src/workspace/code.js b/src/workspace/code.js index c7715802d4..5a4f5976bc 100644 --- a/src/workspace/code.js +++ b/src/workspace/code.js @@ -53,12 +53,12 @@ Entry.PARAM = -1; return this; }; - p.clear = function() { + p.clear = function(isNotForce) { + isNotForce = isNotForce === undefined ? false : isNotForce; for (var i = this._data.length - 1; i >= 0; i--) - this._data[i].destroy(false); + this._data[i].destroy(false, isNotForce); this.clearExecutors(); - this._eventMap = {}; }; p.createView = function(board) { @@ -176,6 +176,7 @@ Entry.PARAM = -1; if (index === undefined) this._data.push(thread); else this._data.insert(thread, index); + this.changeEvent.notify(); return thread; }; @@ -205,11 +206,11 @@ Entry.PARAM = -1; return this._data.map(function(t){return t;}); }; - p.toJSON = function() { + p.toJSON = function(excludeData) { var threads = this.getThreads(); var json = []; for (var i=0, len=threads.length; i =0; i--) - blocks[i].destroy(animate); + blocks[i].destroy(animate, null, isNotForce); + + !blocks.length && this._code.destroyThread(this, false); }; p.getBlock = function(index) { @@ -257,14 +258,18 @@ Entry.Thread = function(thread, code, parent) { p.getBlockList = function(excludePrimitive, type) { var blocks = []; - for (var i = 0; i < this._data.length; i++) - blocks = blocks.concat(this._data[i].getBlockList(excludePrimitive, type)); + for (var i = 0; i < this._data.length; i++) { + var block = this._data[i]; + if (block.constructor !== Entry.Block) + continue; + blocks = blocks.concat(block.getBlockList(excludePrimitive, type)); + } return blocks; }; - p.stringify = function() { - return JSON.stringify(this.toJSON()); + p.stringify = function(excludeData) { + return JSON.stringify(this.toJSON(undefined, undefined, excludeData)); }; })(Entry.Thread.prototype); diff --git a/src/workspace/thread_view.js b/src/workspace/thread_view.js index e37f5c74b8..3250cfe073 100644 --- a/src/workspace/thread_view.js +++ b/src/workspace/thread_view.js @@ -16,6 +16,8 @@ Entry.ThreadView = function(thread, board) { this.svgGroup = board.svgThreadGroup.elem("g"); this.parent = board; // statement + + this._hasGuide = false; }; (function(p) { @@ -83,7 +85,7 @@ Entry.ThreadView = function(thread, board) { }; p.dominate = function() { - this.parent.dominate(this.thread); + !this._hasGuide && this.parent.dominate(this.thread); }; p.isGlobal = function() { @@ -98,7 +100,11 @@ Entry.ThreadView = function(thread, board) { }; p.setZIndex = function(zIndex) { - this.set({zIndex: zIndex}); - } + this.set({zIndex: zIndex}); + }; + + p.setHasGuide = function(bool) { + this._hasGuide = bool; + }; })(Entry.ThreadView.prototype); diff --git a/src/workspace/vim.js b/src/workspace/vim.js index 7bc8ae96c8..d4dad96933 100644 --- a/src/workspace/vim.js +++ b/src/workspace/vim.js @@ -4,21 +4,6 @@ goog.provide("Entry.Vim"); Entry.Vim = function(dom, textType) { //Definition For Textmode - 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"; - if (typeof dom === "string") dom = $('#' + dom); else @@ -43,6 +28,22 @@ Entry.Vim = function(dom, textType) { window.eventset = []; }; +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"; + + (function(p) { p.createDom = function (dom) { var parent, _self, target; @@ -183,6 +184,7 @@ Entry.Vim = function(dom, textType) { p.getCodeToText = function(code) { var textType = this.workspace.oldTextType; + if (textType === Entry.Vim.TEXT_TYPE_JS){ this._parserType = Entry.Vim.PARSER_TYPE_BLOCK_TO_JS; this._parser.setParser(this._mode, this._parserType, this.codeMirror); diff --git a/src/workspace/workspace.js b/src/workspace/workspace.js index 93d33a3665..108bda0d19 100644 --- a/src/workspace/workspace.js +++ b/src/workspace/workspace.js @@ -54,8 +54,9 @@ Entry.Workspace = function(options) { this.changeEvent = new Entry.Event(this); Entry.commander.setCurrentEditor("board", this.board); - this.textType = Entry.Vim.TEXT_TYPE_PY; - + if (options.textType !== undefined) + this.textType = options.textType; + else this.textType = Entry.Vim.TEXT_TYPE_PY; }; Entry.Workspace.MODE_BOARD = 0; @@ -79,15 +80,16 @@ Entry.Workspace.MODE_OVERLAYBOARD = 2; p.getMode = function() {return this.mode;}; p.setMode = function(mode, message){ - if (typeof mode === 'number') - this.mode = mode; - else { - this.mode = mode.boardType; - this.runType = mode.runType; - this.textType = mode.textType; - } + if (!isNaN(mode)) this.mode = mode; + else { + this.mode = mode.boardType; + this.runType = mode.runType; + this.textType = mode.textType; + } + + this.mode = Number(this.mode); - switch (this.mode) { + switch (this.mode) { case this.oldMode: return;