smalruby-editor 0.3.3-x86-mingw32 → 0.3.4-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of smalruby-editor might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/assets/javascripts/smalruby.js.coffee.erb +7 -0
- data/app/assets/javascripts/views/character_modal_view.js.coffee +2 -0
- data/app/assets/javascripts/views/load_modal_view.js.coffee.erb +2 -0
- data/app/assets/javascripts/views/preference_modal_view.js.coffee.erb +2 -2
- data/app/assets/javascripts/views/reset_modal_view.js.coffee +3 -0
- data/app/assets/javascripts/views/signin_modal_view.js.coffee.erb +2 -5
- data/lib/smalruby_editor/version.rb +1 -1
- data/public/assets/{application-35b1374d4d6717b94196f5c3f66db1a9.js → application-f411d2bebfcc93a4e8ac20b19af2fafd.js} +1 -1
- data/public/assets/{application-35b1374d4d6717b94196f5c3f66db1a9.js.gz → application-f411d2bebfcc93a4e8ac20b19af2fafd.js.gz} +0 -0
- data/public/assets/{manifest-fad4a04f58abb204f6d35a9845835730.json → manifest-ffc1bf227b15208b38f552b56f9f8c04.json} +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 012e88a0bd70877787902816fbb4f79151047e89
|
4
|
+
data.tar.gz: 9d9c64c9a0723d556f51a763788ceffad8fd93dd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a88c395f14acc2372ec5c9f79840fe1e444549c55df08a38a61c1f43418f5e1643ff55480f204ae756dc6d4fef510cc3e64fda4a3c89b1a64a02d91773662f0
|
7
|
+
data.tar.gz: cafff6a42b7f1f2a96685881af48f160d4bc22e37139f88e3f3b5dd389b833df8be877c74b0d50d908917728297463a21fee44abfa8ab9da07ab814697ae3117
|
@@ -169,6 +169,13 @@ window.Smalruby =
|
|
169
169
|
else
|
170
170
|
true
|
171
171
|
|
172
|
+
removeBackdropOnHidden: (el) ->
|
173
|
+
el.on 'hidden', =>
|
174
|
+
# HACK: IE11において、ログイン後に操作できなくなる問題が発生した。
|
175
|
+
# 原因はダイアログの背景(.modal-backdrop)が消えないことである。
|
176
|
+
# 以下はそれを回避するための処理である。
|
177
|
+
$('.modal-backdrop').remove();
|
178
|
+
|
172
179
|
# リセットする
|
173
180
|
reset: ->
|
174
181
|
@blocklyLoading = true
|
@@ -10,6 +10,8 @@ Smalruby.LoadModalView = Backbone.View.extend
|
|
10
10
|
'click #load-modal-remix-button': 'onRemix'
|
11
11
|
|
12
12
|
initialize: ->
|
13
|
+
Smalruby.removeBackdropOnHidden(@$el)
|
14
|
+
|
13
15
|
@$el.find('#load-modal-find-from-computer').click (e) =>
|
14
16
|
e.preventDefault()
|
15
17
|
@onFindFromComputerClick.call(@, e)
|
@@ -9,8 +9,8 @@ Smalruby.PreferenceModalView = Backbone.View.extend
|
|
9
9
|
'click #preference-modal-ok-button': 'onOk'
|
10
10
|
'change #user_preferences_toolbox_name': 'renderToolboxPreferences'
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
initialize: ->
|
13
|
+
Smalruby.removeBackdropOnHidden(@$el)
|
14
14
|
|
15
15
|
render: ->
|
16
16
|
@$el.find('.modal-body').block
|
@@ -10,14 +10,11 @@ Smalruby.SigninModalView = Backbone.View.extend
|
|
10
10
|
|
11
11
|
initialize: ->
|
12
12
|
Smalruby.ignoreEnterKey(@$el)
|
13
|
+
Smalruby.removeBackdropOnHidden(@$el)
|
14
|
+
|
13
15
|
@$el.on 'shown', =>
|
14
16
|
@$el.find('#signin-modal-username')
|
15
17
|
.focus()
|
16
|
-
@$el.on 'hidden', =>
|
17
|
-
# HACK: IE11において、ログイン後に操作できなくなる問題が発生した。
|
18
|
-
# 原因はダイアログの背景(.modal-backdrop)が消えないことである。
|
19
|
-
# 以下はそれを回避するための処理である。
|
20
|
-
$('.modal-backdrop').remove();
|
21
18
|
|
22
19
|
render: ->
|
23
20
|
@$el.find('#signin-modal-username')
|
@@ -34,7 +34,7 @@ t&&-1==e.indexOf(t)&&e.push(t),e.sort(goog.string.caseInsensitiveCompare),e.push
|
|
34
34
|
return n=0,!this.RTL&&this.toolbox_&&(n=this.toolbox_.width),{viewHeight:e.height,viewWidth:e.width,contentHeight:o-r,contentWidth:t-s,viewTop:-this.scrollY,viewLeft:-this.scrollX,contentTop:r,contentLeft:s,absoluteTop:0,absoluteLeft:n}},Blockly.setMainWorkspaceMetrics_=function(e){if(!this.scrollbar)throw"Attempt to set main workspace scroll without scrollbars.";var t=this.getMetrics();goog.isNumber(e.x)&&(this.scrollX=-t.contentWidth*e.x-t.contentLeft),goog.isNumber(e.y)&&(this.scrollY=-t.contentHeight*e.y-t.contentTop),e=this.scrollX+t.absoluteLeft,t=this.scrollY+t.absoluteTop,this.translate(e,t),this.options.gridPattern&&(this.options.gridPattern.setAttribute("x",e),this.options.gridPattern.setAttribute("y",t))},Blockly.doCommand=function(e){Blockly.Realtime.isEnabled?Blockly.Realtime.doCommand(e):e()},Blockly.addChangeListener=function(e){return console.warn("Deprecated call to Blockly.addChangeListener, use workspace.addChangeListener instead."),Blockly.getMainWorkspace().addChangeListener(e)},Blockly.getMainWorkspace=function(){return Blockly.mainWorkspace},goog.global.Blockly||(goog.global.Blockly={}),goog.global.Blockly.getMainWorkspace=Blockly.getMainWorkspace,goog.global.Blockly.addChangeListener=Blockly.addChangeListener,goog.global.Blockly.removeChangeListener=Blockly.removeChangeListener,Blockly.Blocks.colour={},Blockly.Blocks.colour.HUE=20,Blockly.Blocks.colour_picker={init:function(){this.setHelpUrl(Blockly.Msg.COLOUR_PICKER_HELPURL),this.setColour(Blockly.Blocks.colour.HUE),this.appendDummyInput().appendField(new Blockly.FieldColour("#ff0000"),"COLOUR"),this.setOutput(!0,"Colour"),this.setTooltip(Blockly.Msg.COLOUR_PICKER_TOOLTIP)}},Blockly.Blocks.colour_random={init:function(){this.setHelpUrl(Blockly.Msg.COLOUR_RANDOM_HELPURL),this.setColour(Blockly.Blocks.colour.HUE),this.appendDummyInput().appendField(Blockly.Msg.COLOUR_RANDOM_TITLE),this.setOutput(!0,"Colour"),this.setTooltip(Blockly.Msg.COLOUR_RANDOM_TOOLTIP)}},Blockly.Blocks.colour_rgb={init:function(){this.setHelpUrl(Blockly.Msg.COLOUR_RGB_HELPURL),this.setColour(Blockly.Blocks.colour.HUE),this.appendValueInput("RED").setCheck("Number").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.COLOUR_RGB_TITLE).appendField(Blockly.Msg.COLOUR_RGB_RED),this.appendValueInput("GREEN").setCheck("Number").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.COLOUR_RGB_GREEN),this.appendValueInput("BLUE").setCheck("Number").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.COLOUR_RGB_BLUE),this.setOutput(!0,"Colour"),this.setTooltip(Blockly.Msg.COLOUR_RGB_TOOLTIP)}},Blockly.Blocks.colour_blend={init:function(){this.setHelpUrl(Blockly.Msg.COLOUR_BLEND_HELPURL),this.setColour(Blockly.Blocks.colour.HUE),this.appendValueInput("COLOUR1").setCheck("Colour").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.COLOUR_BLEND_TITLE).appendField(Blockly.Msg.COLOUR_BLEND_COLOUR1),this.appendValueInput("COLOUR2").setCheck("Colour").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.COLOUR_BLEND_COLOUR2),this.appendValueInput("RATIO").setCheck("Number").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.COLOUR_BLEND_RATIO),this.setOutput(!0,"Colour"),this.setTooltip(Blockly.Msg.COLOUR_BLEND_TOOLTIP)}},Blockly.Blocks.lists={},Blockly.Blocks.lists.HUE=260,Blockly.Blocks.lists_create_empty={init:function(){this.setHelpUrl(Blockly.Msg.LISTS_CREATE_EMPTY_HELPURL),this.setColour(Blockly.Blocks.lists.HUE),this.setOutput(!0,"Array"),this.appendDummyInput().appendField(Blockly.Msg.LISTS_CREATE_EMPTY_TITLE),this.setTooltip(Blockly.Msg.LISTS_CREATE_EMPTY_TOOLTIP)}},Blockly.Blocks.lists_create_with={init:function(){this.setHelpUrl(Blockly.Msg.LISTS_CREATE_WITH_HELPURL),this.setColour(Blockly.Blocks.lists.HUE),this.itemCount_=3,this.updateShape_(),this.setOutput(!0,"Array"),this.setMutator(new Blockly.Mutator(["lists_create_with_item"])),this.setTooltip(Blockly.Msg.LISTS_CREATE_WITH_TOOLTIP)},mutationToDom:function(){var e=document.createElement("mutation");return e.setAttribute("items",this.itemCount_),e},domToMutation:function(e){this.itemCount_=parseInt(e.getAttribute("items"),10),this.updateShape_()},decompose:function(e){var t=Blockly.Block.obtain(e,"lists_create_with_container");t.initSvg();for(var o=t.getInput("STACK").connection,n=0;n<this.itemCount_;n++){var i=Blockly.Block.obtain(e,"lists_create_with_item");i.initSvg(),o.connect(i.previousConnection),o=i.nextConnection}return t},compose:function(e){e=e.getInputTargetBlock("STACK");for(var t=[],o=0;e;)t[o]=e.valueConnection_,e=e.nextConnection&&e.nextConnection.targetBlock(),o++;for(this.itemCount_=o,this.updateShape_(),o=0;o<this.itemCount_;o++)t[o]&&this.getInput("ADD"+o).connection.connect(t[o])},saveConnections:function(e){e=e.getInputTargetBlock("STACK");for(var t=0;e;){var o=this.getInput("ADD"+t);e.valueConnection_=o&&o.connection.targetConnection,t++,e=e.nextConnection&&e.nextConnection.targetBlock()}},updateShape_:function(){if(this.getInput("EMPTY"))this.removeInput("EMPTY");else for(var e=0;this.getInput("ADD"+e);)this.removeInput("ADD"+e),e++;if(0==this.itemCount_)this.appendDummyInput("EMPTY").appendField(Blockly.Msg.LISTS_CREATE_EMPTY_TITLE);else for(e=0;e<this.itemCount_;e++){var t=this.appendValueInput("ADD"+e);0==e&&t.appendField(Blockly.Msg.LISTS_CREATE_WITH_INPUT_WITH)}}},Blockly.Blocks.lists_create_with_container={init:function(){this.setColour(Blockly.Blocks.lists.HUE),this.appendDummyInput().appendField(Blockly.Msg.LISTS_CREATE_WITH_CONTAINER_TITLE_ADD),this.appendStatementInput("STACK"),this.setTooltip(Blockly.Msg.LISTS_CREATE_WITH_CONTAINER_TOOLTIP),this.contextMenu=!1}},Blockly.Blocks.lists_create_with_item={init:function(){this.setColour(Blockly.Blocks.lists.HUE),this.appendDummyInput().appendField(Blockly.Msg.LISTS_CREATE_WITH_ITEM_TITLE),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Blockly.Msg.LISTS_CREATE_WITH_ITEM_TOOLTIP),this.contextMenu=!1}},Blockly.Blocks.lists_repeat={init:function(){this.setHelpUrl(Blockly.Msg.LISTS_REPEAT_HELPURL),this.setColour(Blockly.Blocks.lists.HUE),this.setOutput(!0,"Array"),this.interpolateMsg(Blockly.Msg.LISTS_REPEAT_TITLE,["ITEM",null,Blockly.ALIGN_RIGHT],["NUM","Number",Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setTooltip(Blockly.Msg.LISTS_REPEAT_TOOLTIP)}},Blockly.Blocks.lists_length={init:function(){this.setHelpUrl(Blockly.Msg.LISTS_LENGTH_HELPURL),this.setColour(Blockly.Blocks.lists.HUE),this.interpolateMsg(Blockly.Msg.LISTS_LENGTH_TITLE,["VALUE",["Array","String"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setOutput(!0,"Number"),this.setTooltip(Blockly.Msg.LISTS_LENGTH_TOOLTIP)}},Blockly.Blocks.lists_isEmpty={init:function(){this.setHelpUrl(Blockly.Msg.LISTS_IS_EMPTY_HELPURL),this.setColour(Blockly.Blocks.lists.HUE),this.interpolateMsg(Blockly.Msg.LISTS_IS_EMPTY_TITLE,["VALUE",["Array","String"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setOutput(!0,"Boolean"),this.setTooltip(Blockly.Msg.LISTS_TOOLTIP)}},Blockly.Blocks.lists_indexOf={init:function(){var e=[[Blockly.Msg.LISTS_INDEX_OF_FIRST,"FIRST"],[Blockly.Msg.LISTS_INDEX_OF_LAST,"LAST"]];this.setHelpUrl(Blockly.Msg.LISTS_INDEX_OF_HELPURL),this.setColour(Blockly.Blocks.lists.HUE),this.setOutput(!0,"Number"),this.appendValueInput("VALUE").setCheck("Array").appendField(Blockly.Msg.LISTS_INDEX_OF_INPUT_IN_LIST),this.appendValueInput("FIND").appendField(new Blockly.FieldDropdown(e),"END"),this.setInputsInline(!0),this.setTooltip(Blockly.Msg.LISTS_INDEX_OF_TOOLTIP)}},Blockly.Blocks.lists_getIndex={init:function(){var e=[[Blockly.Msg.LISTS_GET_INDEX_GET,"GET"],[Blockly.Msg.LISTS_GET_INDEX_GET_REMOVE,"GET_REMOVE"],[Blockly.Msg.LISTS_GET_INDEX_REMOVE,"REMOVE"]];this.WHERE_OPTIONS=[[Blockly.Msg.LISTS_GET_INDEX_FROM_START,"FROM_START"],[Blockly.Msg.LISTS_GET_INDEX_FROM_END,"FROM_END"],[Blockly.Msg.LISTS_GET_INDEX_FIRST,"FIRST"],[Blockly.Msg.LISTS_GET_INDEX_LAST,"LAST"],[Blockly.Msg.LISTS_GET_INDEX_RANDOM,"RANDOM"]],this.setHelpUrl(Blockly.Msg.LISTS_GET_INDEX_HELPURL),this.setColour(Blockly.Blocks.lists.HUE),e=new Blockly.FieldDropdown(e,function(e){this.sourceBlock_.updateStatement_("REMOVE"==e)}),this.appendValueInput("VALUE").setCheck("Array").appendField(Blockly.Msg.LISTS_GET_INDEX_INPUT_IN_LIST),this.appendDummyInput().appendField(e,"MODE").appendField("","SPACE"),this.appendDummyInput("AT"),Blockly.Msg.LISTS_GET_INDEX_TAIL&&this.appendDummyInput("TAIL").appendField(Blockly.Msg.LISTS_GET_INDEX_TAIL),this.setInputsInline(!0),this.setOutput(!0),this.updateAt_(!0);var t=this;this.setTooltip(function(){var e=t.getFieldValue("MODE")+"_"+t.getFieldValue("WHERE");return Blockly.Msg["LISTS_GET_INDEX_TOOLTIP_"+e]})},mutationToDom:function(){var e=document.createElement("mutation");e.setAttribute("statement",!this.outputConnection);var t=this.getInput("AT").type==Blockly.INPUT_VALUE;return e.setAttribute("at",t),e},domToMutation:function(e){var t="true"==e.getAttribute("statement");this.updateStatement_(t),e="false"!=e.getAttribute("at"),this.updateAt_(e)},updateStatement_:function(e){e!=!this.outputConnection&&(this.unplug(!0,!0),e?(this.setOutput(!1),this.setPreviousStatement(!0),this.setNextStatement(!0)):(this.setPreviousStatement(!1),this.setNextStatement(!1),this.setOutput(!0)))},updateAt_:function(e){this.removeInput("AT"),this.removeInput("ORDINAL",!0),e?(this.appendValueInput("AT").setCheck("Number"),Blockly.Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField(Blockly.Msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT");var t=new Blockly.FieldDropdown(this.WHERE_OPTIONS,function(t){var o="FROM_START"==t||"FROM_END"==t;if(o!=e){var n=this.sourceBlock_;return n.updateAt_(o),n.setFieldValue(t,"WHERE"),null}});this.getInput("AT").appendField(t,"WHERE"),Blockly.Msg.LISTS_GET_INDEX_TAIL&&this.moveInputBefore("TAIL",null)}},Blockly.Blocks.lists_setIndex={init:function(){var e=[[Blockly.Msg.LISTS_SET_INDEX_SET,"SET"],[Blockly.Msg.LISTS_SET_INDEX_INSERT,"INSERT"]];this.WHERE_OPTIONS=[[Blockly.Msg.LISTS_GET_INDEX_FROM_START,"FROM_START"],[Blockly.Msg.LISTS_GET_INDEX_FROM_END,"FROM_END"],[Blockly.Msg.LISTS_GET_INDEX_FIRST,"FIRST"],[Blockly.Msg.LISTS_GET_INDEX_LAST,"LAST"],[Blockly.Msg.LISTS_GET_INDEX_RANDOM,"RANDOM"]],this.setHelpUrl(Blockly.Msg.LISTS_SET_INDEX_HELPURL),this.setColour(Blockly.Blocks.lists.HUE),this.appendValueInput("LIST").setCheck("Array").appendField(Blockly.Msg.LISTS_SET_INDEX_INPUT_IN_LIST),this.appendDummyInput().appendField(new Blockly.FieldDropdown(e),"MODE").appendField("","SPACE"),this.appendDummyInput("AT"),this.appendValueInput("TO").appendField(Blockly.Msg.LISTS_SET_INDEX_INPUT_TO),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Blockly.Msg.LISTS_SET_INDEX_TOOLTIP),this.updateAt_(!0);var t=this;this.setTooltip(function(){var e=t.getFieldValue("MODE")+"_"+t.getFieldValue("WHERE");return Blockly.Msg["LISTS_SET_INDEX_TOOLTIP_"+e]})},mutationToDom:function(){var e=document.createElement("mutation"),t=this.getInput("AT").type==Blockly.INPUT_VALUE;return e.setAttribute("at",t),e},domToMutation:function(e){e="false"!=e.getAttribute("at"),this.updateAt_(e)},updateAt_:function(e){this.removeInput("AT"),this.removeInput("ORDINAL",!0),e?(this.appendValueInput("AT").setCheck("Number"),Blockly.Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField(Blockly.Msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT");var t=new Blockly.FieldDropdown(this.WHERE_OPTIONS,function(t){var o="FROM_START"==t||"FROM_END"==t;if(o!=e){var n=this.sourceBlock_;return n.updateAt_(o),n.setFieldValue(t,"WHERE"),null}});this.moveInputBefore("AT","TO"),this.getInput("ORDINAL")&&this.moveInputBefore("ORDINAL","TO"),this.getInput("AT").appendField(t,"WHERE")}},Blockly.Blocks.lists_getSublist={init:function(){this.WHERE_OPTIONS_1=[[Blockly.Msg.LISTS_GET_SUBLIST_START_FROM_START,"FROM_START"],[Blockly.Msg.LISTS_GET_SUBLIST_START_FROM_END,"FROM_END"],[Blockly.Msg.LISTS_GET_SUBLIST_START_FIRST,"FIRST"]],this.WHERE_OPTIONS_2=[[Blockly.Msg.LISTS_GET_SUBLIST_END_FROM_START,"FROM_START"],[Blockly.Msg.LISTS_GET_SUBLIST_END_FROM_END,"FROM_END"],[Blockly.Msg.LISTS_GET_SUBLIST_END_LAST,"LAST"]],this.setHelpUrl(Blockly.Msg.LISTS_GET_SUBLIST_HELPURL),this.setColour(Blockly.Blocks.lists.HUE),this.appendValueInput("LIST").setCheck("Array").appendField(Blockly.Msg.LISTS_GET_SUBLIST_INPUT_IN_LIST),this.appendDummyInput("AT1"),this.appendDummyInput("AT2"),Blockly.Msg.LISTS_GET_SUBLIST_TAIL&&this.appendDummyInput("TAIL").appendField(Blockly.Msg.LISTS_GET_SUBLIST_TAIL),this.setInputsInline(!0),this.setOutput(!0,"Array"),this.updateAt_(1,!0),this.updateAt_(2,!0),this.setTooltip(Blockly.Msg.LISTS_GET_SUBLIST_TOOLTIP)},mutationToDom:function(){var e=document.createElement("mutation"),t=this.getInput("AT1").type==Blockly.INPUT_VALUE;return e.setAttribute("at1",t),t=this.getInput("AT2").type==Blockly.INPUT_VALUE,e.setAttribute("at2",t),e},domToMutation:function(e){var t="true"==e.getAttribute("at1");e="true"==e.getAttribute("at2"),this.updateAt_(1,t),this.updateAt_(2,e)},updateAt_:function(e,t){this.removeInput("AT"+e),this.removeInput("ORDINAL"+e,!0),t?(this.appendValueInput("AT"+e).setCheck("Number"),Blockly.Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL"+e).appendField(Blockly.Msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT"+e);var o=new Blockly.FieldDropdown(this["WHERE_OPTIONS_"+e],function(o){var n="FROM_START"==o||"FROM_END"==o;if(n!=t){var i=this.sourceBlock_;return i.updateAt_(e,n),i.setFieldValue(o,"WHERE"+e),null}});this.getInput("AT"+e).appendField(o,"WHERE"+e),1==e&&(this.moveInputBefore("AT1","AT2"),this.getInput("ORDINAL1")&&this.moveInputBefore("ORDINAL1","AT2")),Blockly.Msg.LISTS_GET_SUBLIST_TAIL&&this.moveInputBefore("TAIL",null)}},Blockly.Blocks.lists_split={init:function(){var e=this,t=new Blockly.FieldDropdown([[Blockly.Msg.LISTS_SPLIT_LIST_FROM_TEXT,"SPLIT"],[Blockly.Msg.LISTS_SPLIT_TEXT_FROM_LIST,"JOIN"]],function(t){"SPLIT"==t?(e.outputConnection.setCheck("Array"),e.getInput("INPUT").setCheck("String")):(e.outputConnection.setCheck("String"),e.getInput("INPUT").setCheck("Array"))});this.setHelpUrl(Blockly.Msg.LISTS_SPLIT_HELPURL),this.setColour(Blockly.Blocks.lists.HUE),this.appendValueInput("INPUT").setCheck("String").appendField(t,"MODE"),this.appendValueInput("DELIM").setCheck("String").appendField(Blockly.Msg.LISTS_SPLIT_WITH_DELIMITER),this.setInputsInline(!0),this.setOutput(!0,"Array"),this.setTooltip(function(){var t=e.getFieldValue("MODE");if("SPLIT"==t)return Blockly.Msg.LISTS_SPLIT_TOOLTIP_SPLIT;if("JOIN"==t)return Blockly.Msg.LISTS_SPLIT_TOOLTIP_JOIN;throw"Unknown mode: "+t})}},Blockly.Blocks.logic={},Blockly.Blocks.logic.HUE=210,Blockly.Blocks.controls_if={init:function(){this.setHelpUrl(Blockly.Msg.CONTROLS_IF_HELPURL),this.setColour(Blockly.Blocks.logic.HUE),this.appendValueInput("IF0").setCheck("Boolean").appendField(Blockly.Msg.CONTROLS_IF_MSG_IF),this.appendStatementInput("DO0").appendField(Blockly.Msg.CONTROLS_IF_MSG_THEN),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setMutator(new Blockly.Mutator(["controls_if_elseif","controls_if_else"]));var e=this;this.setTooltip(function(){return e.elseifCount_||e.elseCount_?!e.elseifCount_&&e.elseCount_?Blockly.Msg.CONTROLS_IF_TOOLTIP_2:e.elseifCount_&&!e.elseCount_?Blockly.Msg.CONTROLS_IF_TOOLTIP_3:e.elseifCount_&&e.elseCount_?Blockly.Msg.CONTROLS_IF_TOOLTIP_4:"":Blockly.Msg.CONTROLS_IF_TOOLTIP_1}),this.elseCount_=this.elseifCount_=0},mutationToDom:function(){if(!this.elseifCount_&&!this.elseCount_)return null;var e=document.createElement("mutation");return this.elseifCount_&&e.setAttribute("elseif",this.elseifCount_),this.elseCount_&&e.setAttribute("else",1),e},domToMutation:function(e){for(this.elseifCount_=parseInt(e.getAttribute("elseif"),10),this.elseCount_=parseInt(e.getAttribute("else"),10),e=1;e<=this.elseifCount_;e++)this.appendValueInput("IF"+e).setCheck("Boolean").appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSEIF),this.appendStatementInput("DO"+e).appendField(Blockly.Msg.CONTROLS_IF_MSG_THEN);this.elseCount_&&this.appendStatementInput("ELSE").appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSE)},decompose:function(e){var t=Blockly.Block.obtain(e,"controls_if_if");t.initSvg();for(var o=t.getInput("STACK").connection,n=1;n<=this.elseifCount_;n++){var i=Blockly.Block.obtain(e,"controls_if_elseif");i.initSvg(),o.connect(i.previousConnection),o=i.nextConnection}return this.elseCount_&&(e=Blockly.Block.obtain(e,"controls_if_else"),e.initSvg(),o.connect(e.previousConnection)),t},compose:function(e){this.elseCount_&&this.removeInput("ELSE"),this.elseCount_=0;for(var t=this.elseifCount_;t>0;t--)this.removeInput("IF"+t),this.removeInput("DO"+t);for(this.elseifCount_=0,e=e.getInputTargetBlock("STACK");e;){switch(e.type){case"controls_if_elseif":this.elseifCount_++;var t=this.appendValueInput("IF"+this.elseifCount_).setCheck("Boolean").appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSEIF),o=this.appendStatementInput("DO"+this.elseifCount_);o.appendField(Blockly.Msg.CONTROLS_IF_MSG_THEN),e.valueConnection_&&t.connection.connect(e.valueConnection_),e.statementConnection_&&o.connection.connect(e.statementConnection_);break;case"controls_if_else":this.elseCount_++,t=this.appendStatementInput("ELSE"),t.appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSE),e.statementConnection_&&t.connection.connect(e.statementConnection_);break;default:throw"Unknown block type."}e=e.nextConnection&&e.nextConnection.targetBlock()}},saveConnections:function(e){e=e.getInputTargetBlock("STACK");for(var t=1;e;){switch(e.type){case"controls_if_elseif":var o=this.getInput("IF"+t),n=this.getInput("DO"+t);e.valueConnection_=o&&o.connection.targetConnection,e.statementConnection_=n&&n.connection.targetConnection,t++;break;case"controls_if_else":n=this.getInput("ELSE"),e.statementConnection_=n&&n.connection.targetConnection;break;default:throw"Unknown block type."}e=e.nextConnection&&e.nextConnection.targetBlock()}}},Blockly.Blocks.controls_if_if={init:function(){this.setColour(Blockly.Blocks.logic.HUE),this.appendDummyInput().appendField(Blockly.Msg.CONTROLS_IF_IF_TITLE_IF),this.appendStatementInput("STACK"),this.setTooltip(Blockly.Msg.CONTROLS_IF_IF_TOOLTIP),this.contextMenu=!1}},Blockly.Blocks.controls_if_elseif={init:function(){this.setColour(Blockly.Blocks.logic.HUE),this.appendDummyInput().appendField(Blockly.Msg.CONTROLS_IF_ELSEIF_TITLE_ELSEIF),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Blockly.Msg.CONTROLS_IF_ELSEIF_TOOLTIP),this.contextMenu=!1}},Blockly.Blocks.controls_if_else={init:function(){this.setColour(Blockly.Blocks.logic.HUE),this.appendDummyInput().appendField(Blockly.Msg.CONTROLS_IF_ELSE_TITLE_ELSE),this.setPreviousStatement(!0),this.setTooltip(Blockly.Msg.CONTROLS_IF_ELSE_TOOLTIP),this.contextMenu=!1}},Blockly.Blocks.logic_compare={init:function(){var e=this.RTL?[["=","EQ"],["≠","NEQ"],[">","LT"],["≥","LTE"],["<","GT"],["≤","GTE"]]:[["=","EQ"],["≠","NEQ"],["<","LT"],["≤","LTE"],[">","GT"],["≥","GTE"]];this.setHelpUrl(Blockly.Msg.LOGIC_COMPARE_HELPURL),this.setColour(Blockly.Blocks.logic.HUE),this.setOutput(!0,"Boolean"),this.appendValueInput("A"),this.appendValueInput("B").appendField(new Blockly.FieldDropdown(e),"OP"),this.setInputsInline(!0);var t=this;this.setTooltip(function(){var e=t.getFieldValue("OP");return{EQ:Blockly.Msg.LOGIC_COMPARE_TOOLTIP_EQ,NEQ:Blockly.Msg.LOGIC_COMPARE_TOOLTIP_NEQ,LT:Blockly.Msg.LOGIC_COMPARE_TOOLTIP_LT,LTE:Blockly.Msg.LOGIC_COMPARE_TOOLTIP_LTE,GT:Blockly.Msg.LOGIC_COMPARE_TOOLTIP_GT,GTE:Blockly.Msg.LOGIC_COMPARE_TOOLTIP_GTE}[e]}),this.prevBlocks_=[null,null]},onchange:function(){if(this.workspace){var e=this.getInputTargetBlock("A"),t=this.getInputTargetBlock("B");if(e&&t&&!e.outputConnection.checkType_(t.outputConnection))for(var o=0;o<this.prevBlocks_.length;o++){var n=this.prevBlocks_[o];(n===e||n===t)&&(n.setParent(null),n.bumpNeighbours_())}this.prevBlocks_[0]=e,this.prevBlocks_[1]=t}}},Blockly.Blocks.logic_operation={init:function(){var e=[[Blockly.Msg.LOGIC_OPERATION_AND,"AND"],[Blockly.Msg.LOGIC_OPERATION_OR,"OR"]];this.setHelpUrl(Blockly.Msg.LOGIC_OPERATION_HELPURL),this.setColour(Blockly.Blocks.logic.HUE),this.setOutput(!0,"Boolean"),this.appendValueInput("A").setCheck("Boolean"),this.appendValueInput("B").setCheck("Boolean").appendField(new Blockly.FieldDropdown(e),"OP"),this.setInputsInline(!0);var t=this;this.setTooltip(function(){var e=t.getFieldValue("OP");return{AND:Blockly.Msg.LOGIC_OPERATION_TOOLTIP_AND,OR:Blockly.Msg.LOGIC_OPERATION_TOOLTIP_OR}[e]})}},Blockly.Blocks.logic_negate={init:function(){this.setHelpUrl(Blockly.Msg.LOGIC_NEGATE_HELPURL),this.setColour(Blockly.Blocks.logic.HUE),this.setOutput(!0,"Boolean"),this.interpolateMsg(Blockly.Msg.LOGIC_NEGATE_TITLE,["BOOL","Boolean",Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setTooltip(Blockly.Msg.LOGIC_NEGATE_TOOLTIP)}},Blockly.Blocks.logic_boolean={init:function(){var e=[[Blockly.Msg.LOGIC_BOOLEAN_TRUE,"TRUE"],[Blockly.Msg.LOGIC_BOOLEAN_FALSE,"FALSE"]];this.setHelpUrl(Blockly.Msg.LOGIC_BOOLEAN_HELPURL),this.setColour(Blockly.Blocks.logic.HUE),this.setOutput(!0,"Boolean"),this.appendDummyInput().appendField(new Blockly.FieldDropdown(e),"BOOL"),this.setTooltip(Blockly.Msg.LOGIC_BOOLEAN_TOOLTIP)}},Blockly.Blocks.logic_null={init:function(){this.setHelpUrl(Blockly.Msg.LOGIC_NULL_HELPURL),this.setColour(Blockly.Blocks.logic.HUE),this.setOutput(!0),this.appendDummyInput().appendField(Blockly.Msg.LOGIC_NULL),this.setTooltip(Blockly.Msg.LOGIC_NULL_TOOLTIP)}},Blockly.Blocks.logic_ternary={init:function(){this.setHelpUrl(Blockly.Msg.LOGIC_TERNARY_HELPURL),this.setColour(Blockly.Blocks.logic.HUE),this.appendValueInput("IF").setCheck("Boolean").appendField(Blockly.Msg.LOGIC_TERNARY_CONDITION),this.appendValueInput("THEN").appendField(Blockly.Msg.LOGIC_TERNARY_IF_TRUE),this.appendValueInput("ELSE").appendField(Blockly.Msg.LOGIC_TERNARY_IF_FALSE),this.setOutput(!0),this.setTooltip(Blockly.Msg.LOGIC_TERNARY_TOOLTIP),this.prevParentConnection_=null},onchange:function(){if(this.workspace){var e=this.getInputTargetBlock("THEN"),t=this.getInputTargetBlock("ELSE"),o=this.outputConnection.targetConnection;if((e||t)&&o)for(var n=0;2>n;n++){var i=1==n?e:t;i&&!i.outputConnection.checkType_(o)&&(o===this.prevParentConnection_?(this.setParent(null),o.sourceBlock_.bumpNeighbours_()):(i.setParent(null),i.bumpNeighbours_()))}this.prevParentConnection_=o}}},Blockly.Blocks.loops={},Blockly.Blocks.loops.HUE=120,Blockly.Blocks.controls_repeat={init:function(){this.setHelpUrl(Blockly.Msg.CONTROLS_REPEAT_HELPURL),this.setColour(Blockly.Blocks.loops.HUE),this.appendDummyInput().appendField(Blockly.Msg.CONTROLS_REPEAT_TITLE_REPEAT).appendField(new Blockly.FieldTextInput("10",Blockly.FieldTextInput.nonnegativeIntegerValidator),"TIMES").appendField(Blockly.Msg.CONTROLS_REPEAT_TITLE_TIMES),this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_REPEAT_INPUT_DO),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Blockly.Msg.CONTROLS_REPEAT_TOOLTIP)}},Blockly.Blocks.controls_repeat_ext={init:function(){this.setHelpUrl(Blockly.Msg.CONTROLS_REPEAT_HELPURL),this.setColour(Blockly.Blocks.loops.HUE),this.interpolateMsg(Blockly.Msg.CONTROLS_REPEAT_TITLE,["TIMES","Number",Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_REPEAT_INPUT_DO),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip(Blockly.Msg.CONTROLS_REPEAT_TOOLTIP)}},Blockly.Blocks.controls_whileUntil={init:function(){var e=[[Blockly.Msg.CONTROLS_WHILEUNTIL_OPERATOR_WHILE,"WHILE"],[Blockly.Msg.CONTROLS_WHILEUNTIL_OPERATOR_UNTIL,"UNTIL"]];this.setHelpUrl(Blockly.Msg.CONTROLS_WHILEUNTIL_HELPURL),this.setColour(Blockly.Blocks.loops.HUE),this.appendValueInput("BOOL").setCheck("Boolean").appendField(new Blockly.FieldDropdown(e),"MODE"),this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_WHILEUNTIL_INPUT_DO),this.setPreviousStatement(!0),this.setNextStatement(!0);var t=this;this.setTooltip(function(){var e=t.getFieldValue("MODE");return{WHILE:Blockly.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_WHILE,UNTIL:Blockly.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL}[e]})}},Blockly.Blocks.controls_for={init:function(){this.setHelpUrl(Blockly.Msg.CONTROLS_FOR_HELPURL),this.setColour(Blockly.Blocks.loops.HUE),this.appendDummyInput().appendField(Blockly.Msg.CONTROLS_FOR_INPUT_WITH).appendField(new Blockly.FieldVariable(null),"VAR"),this.interpolateMsg(Blockly.Msg.CONTROLS_FOR_INPUT_FROM_TO_BY,["FROM","Number",Blockly.ALIGN_RIGHT],["TO","Number",Blockly.ALIGN_RIGHT],["BY","Number",Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_FOR_INPUT_DO),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0);var e=this;this.setTooltip(function(){return Blockly.Msg.CONTROLS_FOR_TOOLTIP.replace("%1",e.getFieldValue("VAR"))})},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(e,t){Blockly.Names.equals(e,this.getFieldValue("VAR"))&&this.setFieldValue(t,"VAR")},customContextMenu:function(e){if(!this.isCollapsed()){var t={enabled:!0},o=this.getFieldValue("VAR");t.text=Blockly.Msg.VARIABLES_SET_CREATE_GET.replace("%1",o),o=goog.dom.createDom("field",null,o),o.setAttribute("name","VAR"),o=goog.dom.createDom("block",null,o),o.setAttribute("type","variables_get"),t.callback=Blockly.ContextMenu.callbackFactory(this,o),e.push(t)}}},Blockly.Blocks.controls_forEach={init:function(){this.setHelpUrl(Blockly.Msg.CONTROLS_FOREACH_HELPURL),this.setColour(Blockly.Blocks.loops.HUE),this.appendValueInput("LIST").setCheck("Array").appendField(Blockly.Msg.CONTROLS_FOREACH_INPUT_ITEM).appendField(new Blockly.FieldVariable(null),"VAR").appendField(Blockly.Msg.CONTROLS_FOREACH_INPUT_INLIST),Blockly.Msg.CONTROLS_FOREACH_INPUT_INLIST_TAIL&&(this.appendDummyInput().appendField(Blockly.Msg.CONTROLS_FOREACH_INPUT_INLIST_TAIL),this.setInputsInline(!0)),this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_FOREACH_INPUT_DO),this.setPreviousStatement(!0),this.setNextStatement(!0);var e=this;this.setTooltip(function(){return Blockly.Msg.CONTROLS_FOREACH_TOOLTIP.replace("%1",e.getFieldValue("VAR"))})},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(e,t){Blockly.Names.equals(e,this.getFieldValue("VAR"))&&this.setFieldValue(t,"VAR")},customContextMenu:Blockly.Blocks.controls_for.customContextMenu},Blockly.Blocks.controls_flow_statements={init:function(){var e=[[Blockly.Msg.CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK,"BREAK"],[Blockly.Msg.CONTROLS_FLOW_STATEMENTS_OPERATOR_CONTINUE,"CONTINUE"]];this.setHelpUrl(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_HELPURL),this.setColour(Blockly.Blocks.loops.HUE),this.appendDummyInput().appendField(new Blockly.FieldDropdown(e),"FLOW"),this.setPreviousStatement(!0);var t=this;this.setTooltip(function(){var e=t.getFieldValue("FLOW");return{BREAK:Blockly.Msg.CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK,CONTINUE:Blockly.Msg.CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE}[e]})},onchange:function(){if(this.workspace){var e=!1,t=this;do{if("controls_repeat"==t.type||"controls_repeat_ext"==t.type||"controls_forEach"==t.type||"controls_for"==t.type||"controls_whileUntil"==t.type){e=!0;break}t=t.getSurroundParent()}while(t);e?this.setWarningText(null):this.setWarningText(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING)}}},Blockly.Blocks.math={},Blockly.Blocks.math.HUE=230,Blockly.Blocks.math_number={init:function(){this.setHelpUrl(Blockly.Msg.MATH_NUMBER_HELPURL),this.setColour(Blockly.Blocks.math.HUE),this.appendDummyInput().appendField(new Blockly.FieldTextInput("0",Blockly.FieldTextInput.numberValidator),"NUM"),this.setOutput(!0,"Number"),this.setTooltip(Blockly.Msg.MATH_NUMBER_TOOLTIP)}},Blockly.Blocks.math_arithmetic={init:function(){var e=[[Blockly.Msg.MATH_ADDITION_SYMBOL,"ADD"],[Blockly.Msg.MATH_SUBTRACTION_SYMBOL,"MINUS"],[Blockly.Msg.MATH_MULTIPLICATION_SYMBOL,"MULTIPLY"],[Blockly.Msg.MATH_DIVISION_SYMBOL,"DIVIDE"],[Blockly.Msg.MATH_POWER_SYMBOL,"POWER"]];this.setHelpUrl(Blockly.Msg.MATH_ARITHMETIC_HELPURL),this.setColour(Blockly.Blocks.math.HUE),this.setOutput(!0,"Number"),this.appendValueInput("A").setCheck("Number"),this.appendValueInput("B").setCheck("Number").appendField(new Blockly.FieldDropdown(e),"OP"),this.setInputsInline(!0);var t=this;this.setTooltip(function(){var e=t.getFieldValue("OP");return{ADD:Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_ADD,MINUS:Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_MINUS,MULTIPLY:Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_MULTIPLY,DIVIDE:Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_DIVIDE,POWER:Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_POWER}[e]})}},Blockly.Blocks.math_single={init:function(){var e=[[Blockly.Msg.MATH_SINGLE_OP_ROOT,"ROOT"],[Blockly.Msg.MATH_SINGLE_OP_ABSOLUTE,"ABS"],["-","NEG"],["ln","LN"],["log10","LOG10"],["e^","EXP"],["10^","POW10"]];this.setHelpUrl(Blockly.Msg.MATH_SINGLE_HELPURL),this.setColour(Blockly.Blocks.math.HUE),this.setOutput(!0,"Number"),this.interpolateMsg("%1 %2",["OP",new Blockly.FieldDropdown(e)],["NUM","Number",Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT);var t=this;this.setTooltip(function(){var e=t.getFieldValue("OP");return{ROOT:Blockly.Msg.MATH_SINGLE_TOOLTIP_ROOT,ABS:Blockly.Msg.MATH_SINGLE_TOOLTIP_ABS,NEG:Blockly.Msg.MATH_SINGLE_TOOLTIP_NEG,LN:Blockly.Msg.MATH_SINGLE_TOOLTIP_LN,LOG10:Blockly.Msg.MATH_SINGLE_TOOLTIP_LOG10,EXP:Blockly.Msg.MATH_SINGLE_TOOLTIP_EXP,POW10:Blockly.Msg.MATH_SINGLE_TOOLTIP_POW10}[e]})}},Blockly.Blocks.math_trig={init:function(){var e=[[Blockly.Msg.MATH_TRIG_SIN,"SIN"],[Blockly.Msg.MATH_TRIG_COS,"COS"],[Blockly.Msg.MATH_TRIG_TAN,"TAN"],[Blockly.Msg.MATH_TRIG_ASIN,"ASIN"],[Blockly.Msg.MATH_TRIG_ACOS,"ACOS"],[Blockly.Msg.MATH_TRIG_ATAN,"ATAN"]];this.setHelpUrl(Blockly.Msg.MATH_TRIG_HELPURL),this.setColour(Blockly.Blocks.math.HUE),this.setOutput(!0,"Number"),this.appendValueInput("NUM").setCheck("Number").appendField(new Blockly.FieldDropdown(e),"OP");var t=this;this.setTooltip(function(){var e=t.getFieldValue("OP");return{SIN:Blockly.Msg.MATH_TRIG_TOOLTIP_SIN,COS:Blockly.Msg.MATH_TRIG_TOOLTIP_COS,TAN:Blockly.Msg.MATH_TRIG_TOOLTIP_TAN,ASIN:Blockly.Msg.MATH_TRIG_TOOLTIP_ASIN,ACOS:Blockly.Msg.MATH_TRIG_TOOLTIP_ACOS,ATAN:Blockly.Msg.MATH_TRIG_TOOLTIP_ATAN}[e]})}},Blockly.Blocks.math_constant={init:function(){this.setHelpUrl(Blockly.Msg.MATH_CONSTANT_HELPURL),this.setColour(Blockly.Blocks.math.HUE),this.setOutput(!0,"Number"),this.appendDummyInput().appendField(new Blockly.FieldDropdown([["π","PI"],["e","E"],["φ","GOLDEN_RATIO"],["sqrt(2)","SQRT2"],["sqrt(½)","SQRT1_2"],["∞","INFINITY"]]),"CONSTANT"),this.setTooltip(Blockly.Msg.MATH_CONSTANT_TOOLTIP)}},Blockly.Blocks.math_number_property={init:function(){var e=[[Blockly.Msg.MATH_IS_EVEN,"EVEN"],[Blockly.Msg.MATH_IS_ODD,"ODD"],[Blockly.Msg.MATH_IS_PRIME,"PRIME"],[Blockly.Msg.MATH_IS_WHOLE,"WHOLE"],[Blockly.Msg.MATH_IS_POSITIVE,"POSITIVE"],[Blockly.Msg.MATH_IS_NEGATIVE,"NEGATIVE"],[Blockly.Msg.MATH_IS_DIVISIBLE_BY,"DIVISIBLE_BY"]];this.setColour(Blockly.Blocks.math.HUE),this.appendValueInput("NUMBER_TO_CHECK").setCheck("Number"),e=new Blockly.FieldDropdown(e,function(e){this.sourceBlock_.updateShape_("DIVISIBLE_BY"==e)}),this.appendDummyInput().appendField(e,"PROPERTY"),this.setInputsInline(!0),this.setOutput(!0,"Boolean"),this.setTooltip(Blockly.Msg.MATH_IS_TOOLTIP)},mutationToDom:function(){var e=document.createElement("mutation"),t="DIVISIBLE_BY"==this.getFieldValue("PROPERTY");return e.setAttribute("divisor_input",t),e},domToMutation:function(e){e="true"==e.getAttribute("divisor_input"),this.updateShape_(e)},updateShape_:function(e){var t=this.getInput("DIVISOR");e?t||this.appendValueInput("DIVISOR").setCheck("Number"):t&&this.removeInput("DIVISOR")}},Blockly.Blocks.math_change={init:function(){this.setHelpUrl(Blockly.Msg.MATH_CHANGE_HELPURL),this.setColour(Blockly.Blocks.math.HUE),this.interpolateMsg(Blockly.Msg.MATH_CHANGE_TITLE_CHANGE+" %1 "+Blockly.Msg.MATH_CHANGE_INPUT_BY+" %2",["VAR",new Blockly.FieldVariable(Blockly.Msg.MATH_CHANGE_TITLE_ITEM)],["DELTA","Number",Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setPreviousStatement(!0),this.setNextStatement(!0);var e=this;this.setTooltip(function(){return Blockly.Msg.MATH_CHANGE_TOOLTIP.replace("%1",e.getFieldValue("VAR"))})},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(e,t){Blockly.Names.equals(e,this.getFieldValue("VAR"))&&this.setFieldValue(t,"VAR")}},Blockly.Blocks.math_round={init:function(){var e=[[Blockly.Msg.MATH_ROUND_OPERATOR_ROUND,"ROUND"],[Blockly.Msg.MATH_ROUND_OPERATOR_ROUNDUP,"ROUNDUP"],[Blockly.Msg.MATH_ROUND_OPERATOR_ROUNDDOWN,"ROUNDDOWN"]];this.setHelpUrl(Blockly.Msg.MATH_ROUND_HELPURL),this.setColour(Blockly.Blocks.math.HUE),this.setOutput(!0,"Number"),this.appendValueInput("NUM").setCheck("Number").appendField(new Blockly.FieldDropdown(e),"OP"),this.setTooltip(Blockly.Msg.MATH_ROUND_TOOLTIP)
|
35
35
|
}},Blockly.Blocks.math_on_list={init:function(){var e=[[Blockly.Msg.MATH_ONLIST_OPERATOR_SUM,"SUM"],[Blockly.Msg.MATH_ONLIST_OPERATOR_MIN,"MIN"],[Blockly.Msg.MATH_ONLIST_OPERATOR_MAX,"MAX"],[Blockly.Msg.MATH_ONLIST_OPERATOR_AVERAGE,"AVERAGE"],[Blockly.Msg.MATH_ONLIST_OPERATOR_MEDIAN,"MEDIAN"],[Blockly.Msg.MATH_ONLIST_OPERATOR_MODE,"MODE"],[Blockly.Msg.MATH_ONLIST_OPERATOR_STD_DEV,"STD_DEV"],[Blockly.Msg.MATH_ONLIST_OPERATOR_RANDOM,"RANDOM"]],t=this;this.setHelpUrl(Blockly.Msg.MATH_ONLIST_HELPURL),this.setColour(Blockly.Blocks.math.HUE),this.setOutput(!0,"Number"),e=new Blockly.FieldDropdown(e,function(e){"MODE"==e?t.outputConnection.setCheck("Array"):t.outputConnection.setCheck("Number")}),this.appendValueInput("LIST").setCheck("Array").appendField(e,"OP"),this.setTooltip(function(){var e=t.getFieldValue("OP");return{SUM:Blockly.Msg.MATH_ONLIST_TOOLTIP_SUM,MIN:Blockly.Msg.MATH_ONLIST_TOOLTIP_MIN,MAX:Blockly.Msg.MATH_ONLIST_TOOLTIP_MAX,AVERAGE:Blockly.Msg.MATH_ONLIST_TOOLTIP_AVERAGE,MEDIAN:Blockly.Msg.MATH_ONLIST_TOOLTIP_MEDIAN,MODE:Blockly.Msg.MATH_ONLIST_TOOLTIP_MODE,STD_DEV:Blockly.Msg.MATH_ONLIST_TOOLTIP_STD_DEV,RANDOM:Blockly.Msg.MATH_ONLIST_TOOLTIP_RANDOM}[e]})}},Blockly.Blocks.math_modulo={init:function(){this.setHelpUrl(Blockly.Msg.MATH_MODULO_HELPURL),this.setColour(Blockly.Blocks.math.HUE),this.setOutput(!0,"Number"),this.interpolateMsg(Blockly.Msg.MATH_MODULO_TITLE,["DIVIDEND","Number",Blockly.ALIGN_RIGHT],["DIVISOR","Number",Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setTooltip(Blockly.Msg.MATH_MODULO_TOOLTIP)}},Blockly.Blocks.math_constrain={init:function(){this.setHelpUrl(Blockly.Msg.MATH_CONSTRAIN_HELPURL),this.setColour(Blockly.Blocks.math.HUE),this.setOutput(!0,"Number"),this.interpolateMsg(Blockly.Msg.MATH_CONSTRAIN_TITLE,["VALUE","Number",Blockly.ALIGN_RIGHT],["LOW","Number",Blockly.ALIGN_RIGHT],["HIGH","Number",Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setTooltip(Blockly.Msg.MATH_CONSTRAIN_TOOLTIP)}},Blockly.Blocks.math_random_int={init:function(){this.setHelpUrl(Blockly.Msg.MATH_RANDOM_INT_HELPURL),this.setColour(Blockly.Blocks.math.HUE),this.setOutput(!0,"Number"),this.interpolateMsg(Blockly.Msg.MATH_RANDOM_INT_TITLE,["FROM","Number",Blockly.ALIGN_RIGHT],["TO","Number",Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setTooltip(Blockly.Msg.MATH_RANDOM_INT_TOOLTIP)}},Blockly.Blocks.math_random_float={init:function(){this.setHelpUrl(Blockly.Msg.MATH_RANDOM_FLOAT_HELPURL),this.setColour(Blockly.Blocks.math.HUE),this.setOutput(!0,"Number"),this.appendDummyInput().appendField(Blockly.Msg.MATH_RANDOM_FLOAT_TITLE_RANDOM),this.setTooltip(Blockly.Msg.MATH_RANDOM_FLOAT_TOOLTIP)}},Blockly.Blocks.procedures={},Blockly.Blocks.procedures.HUE=290,Blockly.Blocks.procedures_defnoreturn={init:function(){this.setHelpUrl(Blockly.Msg.PROCEDURES_DEFNORETURN_HELPURL),this.setColour(Blockly.Blocks.procedures.HUE);var e=Blockly.Procedures.findLegalName(Blockly.Msg.PROCEDURES_DEFNORETURN_PROCEDURE,this),e=new Blockly.FieldTextInput(e,Blockly.Procedures.rename);e.setSpellcheck(!1),this.appendDummyInput().appendField(Blockly.Msg.PROCEDURES_DEFNORETURN_TITLE).appendField(e,"NAME").appendField("","PARAMS"),this.setMutator(new Blockly.Mutator(["procedures_mutatorarg"])),this.setTooltip(Blockly.Msg.PROCEDURES_DEFNORETURN_TOOLTIP),this.arguments_=[],this.setStatements_(!0),this.statementConnection_=null},setStatements_:function(e){this.hasStatements_!==e&&(e?(this.appendStatementInput("STACK").appendField(Blockly.Msg.PROCEDURES_DEFNORETURN_DO),this.getInput("RETURN")&&this.moveInputBefore("STACK","RETURN")):this.removeInput("STACK",!0),this.hasStatements_=e)},updateParams_:function(){for(var e=!1,t={},o=0;o<this.arguments_.length;o++){if(t["arg_"+this.arguments_[o].toLowerCase()]){e=!0;break}t["arg_"+this.arguments_[o].toLowerCase()]=!0}e?this.setWarningText(Blockly.Msg.PROCEDURES_DEF_DUPLICATE_WARNING):this.setWarningText(null),e="",this.arguments_.length&&(e=Blockly.Msg.PROCEDURES_BEFORE_PARAMS+" "+this.arguments_.join(", ")),this.setFieldValue(e,"PARAMS")},mutationToDom:function(){for(var e=document.createElement("mutation"),t=0;t<this.arguments_.length;t++){var o=document.createElement("arg");o.setAttribute("name",this.arguments_[t]),e.appendChild(o)}return this.hasStatements_||e.setAttribute("statements","false"),e},domToMutation:function(e){this.arguments_=[];for(var t,o=0;t=e.childNodes[o];o++)"arg"==t.nodeName.toLowerCase()&&this.arguments_.push(t.getAttribute("name"));this.updateParams_(),this.setStatements_("false"!==e.getAttribute("statements"))},decompose:function(e){var t=Blockly.Block.obtain(e,"procedures_mutatorcontainer");t.initSvg(),this.getInput("RETURN")?t.setFieldValue(this.hasStatements_?"TRUE":"FALSE","STATEMENTS"):t.getInput("STATEMENT_INPUT").setVisible(!1);for(var o=t.getInput("STACK").connection,n=0;n<this.arguments_.length;n++){var i=Blockly.Block.obtain(e,"procedures_mutatorarg");i.initSvg(),i.setFieldValue(this.arguments_[n],"NAME"),i.oldLocation=n,o.connect(i.previousConnection),o=i.nextConnection}return Blockly.Procedures.mutateCallers(this.getFieldValue("NAME"),this.workspace,this.arguments_,null),t},compose:function(e){this.arguments_=[],this.paramIds_=[];for(var t=e.getInputTargetBlock("STACK");t;)this.arguments_.push(t.getFieldValue("NAME")),this.paramIds_.push(t.id),t=t.nextConnection&&t.nextConnection.targetBlock();this.updateParams_(),Blockly.Procedures.mutateCallers(this.getFieldValue("NAME"),this.workspace,this.arguments_,this.paramIds_),e=e.getFieldValue("STATEMENTS"),null!==e&&(e="TRUE"==e,this.hasStatements_!=e)&&(e?(this.setStatements_(!0),e=this.getInput("STACK").connection,e.targetConnection||!this.statementConnection_||this.statementConnection_.targetConnection||this.statementConnection_.sourceBlock_.workspace!=this.workspace?this.statementConnection_=null:e.connect(this.statementConnection_)):(e=this.getInput("STACK").connection,(this.statementConnection_=e.targetConnection)&&(e=e.targetBlock(),e.setParent(null),e.bumpNeighbours_()),this.setStatements_(!1)))},dispose:function(){var e=this.getFieldValue("NAME");Blockly.Procedures.disposeCallers(e,this.workspace),this.constructor.prototype.dispose.apply(this,arguments)},getProcedureDef:function(){return[this.getFieldValue("NAME"),this.arguments_,!1]},getVars:function(){return this.arguments_},renameVar:function(e,t){for(var o=!1,n=0;n<this.arguments_.length;n++)Blockly.Names.equals(e,this.arguments_[n])&&(this.arguments_[n]=t,o=!0);if(o&&(this.updateParams_(),this.mutator.isVisible()))for(var i,o=this.mutator.workspace_.getAllBlocks(),n=0;i=o[n];n++)"procedures_mutatorarg"==i.type&&Blockly.Names.equals(e,i.getFieldValue("NAME"))&&i.setFieldValue(t,"NAME")},customContextMenu:function(e){var t={enabled:!0},o=this.getFieldValue("NAME");t.text=Blockly.Msg.PROCEDURES_CREATE_DO.replace("%1",o);var n=goog.dom.createDom("mutation");n.setAttribute("name",o);for(var i=0;i<this.arguments_.length;i++)o=goog.dom.createDom("arg"),o.setAttribute("name",this.arguments_[i]),n.appendChild(o);if(n=goog.dom.createDom("block",null,n),n.setAttribute("type",this.callType_),t.callback=Blockly.ContextMenu.callbackFactory(this,n),e.push(t),!this.isCollapsed())for(i=0;i<this.arguments_.length;i++)t={enabled:!0},o=this.arguments_[i],t.text=Blockly.Msg.VARIABLES_SET_CREATE_GET.replace("%1",o),n=goog.dom.createDom("field",null,o),n.setAttribute("name","VAR"),n=goog.dom.createDom("block",null,n),n.setAttribute("type","variables_get"),t.callback=Blockly.ContextMenu.callbackFactory(this,n),e.push(t)},callType_:"procedures_callnoreturn"},Blockly.Blocks.procedures_defreturn={init:function(){this.setHelpUrl(Blockly.Msg.PROCEDURES_DEFRETURN_HELPURL),this.setColour(Blockly.Blocks.procedures.HUE);var e=Blockly.Procedures.findLegalName(Blockly.Msg.PROCEDURES_DEFRETURN_PROCEDURE,this),e=new Blockly.FieldTextInput(e,Blockly.Procedures.rename);e.setSpellcheck(!1),this.appendDummyInput().appendField(Blockly.Msg.PROCEDURES_DEFRETURN_TITLE).appendField(e,"NAME").appendField("","PARAMS"),this.appendValueInput("RETURN").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN),this.setMutator(new Blockly.Mutator(["procedures_mutatorarg"])),this.setTooltip(Blockly.Msg.PROCEDURES_DEFRETURN_TOOLTIP),this.arguments_=[],this.setStatements_(!0),this.statementConnection_=null},setStatements_:Blockly.Blocks.procedures_defnoreturn.setStatements_,updateParams_:Blockly.Blocks.procedures_defnoreturn.updateParams_,mutationToDom:Blockly.Blocks.procedures_defnoreturn.mutationToDom,domToMutation:Blockly.Blocks.procedures_defnoreturn.domToMutation,decompose:Blockly.Blocks.procedures_defnoreturn.decompose,compose:Blockly.Blocks.procedures_defnoreturn.compose,dispose:Blockly.Blocks.procedures_defnoreturn.dispose,getProcedureDef:function(){return[this.getFieldValue("NAME"),this.arguments_,!0]},getVars:Blockly.Blocks.procedures_defnoreturn.getVars,renameVar:Blockly.Blocks.procedures_defnoreturn.renameVar,customContextMenu:Blockly.Blocks.procedures_defnoreturn.customContextMenu,callType_:"procedures_callreturn"},Blockly.Blocks.procedures_mutatorcontainer={init:function(){this.setColour(Blockly.Blocks.procedures.HUE),this.appendDummyInput().appendField(Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE),this.appendStatementInput("STACK"),this.appendDummyInput("STATEMENT_INPUT").appendField(Blockly.Msg.PROCEDURES_ALLOW_STATEMENTS).appendField(new Blockly.FieldCheckbox("TRUE"),"STATEMENTS"),this.setTooltip(Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP),this.contextMenu=!1}},Blockly.Blocks.procedures_mutatorarg={init:function(){this.setColour(Blockly.Blocks.procedures.HUE),this.appendDummyInput().appendField(Blockly.Msg.PROCEDURES_MUTATORARG_TITLE).appendField(new Blockly.FieldTextInput("x",this.validator_),"NAME"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP),this.contextMenu=!1},validator_:function(e){return(e=e.replace(/[\s\xa0]+/g," ").replace(/^ | $/g,""))||null}},Blockly.Blocks.procedures_callnoreturn={init:function(){this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLNORETURN_HELPURL),this.setColour(Blockly.Blocks.procedures.HUE),this.appendDummyInput("TOPROW").appendField(Blockly.Msg.PROCEDURES_CALLNORETURN_CALL).appendField("","NAME"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.arguments_=[],this.quarkConnections_={},this.quarkArguments_=null},getProcedureCall:function(){return this.getFieldValue("NAME")},renameProcedure:function(e,t){Blockly.Names.equals(e,this.getProcedureCall())&&(this.setFieldValue(t,"NAME"),this.setTooltip((this.outputConnection?Blockly.Msg.PROCEDURES_CALLRETURN_TOOLTIP:Blockly.Msg.PROCEDURES_CALLNORETURN_TOOLTIP).replace("%1",t)))},setProcedureParameters:function(e,t){if(t)if(goog.array.equals(this.arguments_,e))this.quarkArguments_=t;else{if(this.setCollapsed(!1),t.length!=e.length)throw"Error: paramNames and paramIds must be the same length.";this.quarkArguments_||(this.quarkConnections_={},this.quarkArguments_=e.join("\n")==this.arguments_.join("\n")?t:[]);var o=this.rendered;this.rendered=!1;for(var n=this.arguments_.length-1;n>=0;n--){var i=this.getInput("ARG"+n);if(i){var r=i.connection.targetConnection;this.quarkConnections_[this.quarkArguments_[n]]=r,this.removeInput("ARG"+n)}}if(this.arguments_=[].concat(e),this.renderArgs_(),this.quarkArguments_=t)for(n=0;n<this.arguments_.length;n++){var i=this.getInput("ARG"+n),s=this.quarkArguments_[n];s in this.quarkConnections_&&(r=this.quarkConnections_[s],!r||r.targetConnection||r.sourceBlock_.workspace!=this.workspace?delete this.quarkConnections_[s]:i.connection.connect(r))}(this.rendered=o)&&this.render()}else this.quarkConnections_={},this.quarkArguments_=null},renderArgs_:function(){for(var e=0;e<this.arguments_.length;e++){var t=this.appendValueInput("ARG"+e).setAlign(Blockly.ALIGN_RIGHT).appendField(this.arguments_[e]);t.init()}(t=this.getInput("TOPROW"))&&(this.arguments_.length?this.getField_("WITH")||(t.appendField(Blockly.Msg.PROCEDURES_CALL_BEFORE_PARAMS,"WITH"),t.init()):this.getField_("WITH")&&t.removeField("WITH"))},mutationToDom:function(){var e=document.createElement("mutation");e.setAttribute("name",this.getProcedureCall());for(var t=0;t<this.arguments_.length;t++){var o=document.createElement("arg");o.setAttribute("name",this.arguments_[t]),e.appendChild(o)}return e},domToMutation:function(e){var t=e.getAttribute("name");if(this.setFieldValue(t,"NAME"),this.setTooltip((this.outputConnection?Blockly.Msg.PROCEDURES_CALLRETURN_TOOLTIP:Blockly.Msg.PROCEDURES_CALLNORETURN_TOOLTIP).replace("%1",t)),(t=Blockly.Procedures.getDefinition(t,this.workspace))&&t.mutator&&t.mutator.isVisible())this.setProcedureParameters(t.arguments_,t.paramIds_);else{for(var o,t=[],n=0;o=e.childNodes[n];n++)"arg"==o.nodeName.toLowerCase()&&t.push(o.getAttribute("name"));this.setProcedureParameters(t,t)}},renameVar:function(e,t){for(var o=0;o<this.arguments_.length;o++)Blockly.Names.equals(e,this.arguments_[o])&&(this.arguments_[o]=t,this.getInput("ARG"+o).fieldRow[0].setText(t))},customContextMenu:function(e){var t={enabled:!0};t.text=Blockly.Msg.PROCEDURES_HIGHLIGHT_DEF;var o=this.getProcedureCall(),n=this.workspace;t.callback=function(){var e=Blockly.Procedures.getDefinition(o,n);e&&e.select()},e.push(t)}},Blockly.Blocks.procedures_callreturn={init:function(){this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLRETURN_HELPURL),this.setColour(Blockly.Blocks.procedures.HUE),this.appendDummyInput("TOPROW").appendField(Blockly.Msg.PROCEDURES_CALLRETURN_CALL).appendField("","NAME"),this.setOutput(!0),this.arguments_=[],this.quarkConnections_={},this.quarkArguments_=null},getProcedureCall:Blockly.Blocks.procedures_callnoreturn.getProcedureCall,renameProcedure:Blockly.Blocks.procedures_callnoreturn.renameProcedure,setProcedureParameters:Blockly.Blocks.procedures_callnoreturn.setProcedureParameters,renderArgs_:Blockly.Blocks.procedures_callnoreturn.renderArgs_,mutationToDom:Blockly.Blocks.procedures_callnoreturn.mutationToDom,domToMutation:Blockly.Blocks.procedures_callnoreturn.domToMutation,renameVar:Blockly.Blocks.procedures_callnoreturn.renameVar,customContextMenu:Blockly.Blocks.procedures_callnoreturn.customContextMenu},Blockly.Blocks.procedures_ifreturn={init:function(){this.setHelpUrl("http://c2.com/cgi/wiki?GuardClause"),this.setColour(Blockly.Blocks.procedures.HUE),this.appendValueInput("CONDITION").setCheck("Boolean").appendField(Blockly.Msg.CONTROLS_IF_MSG_IF),this.appendValueInput("VALUE").appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Blockly.Msg.PROCEDURES_IFRETURN_TOOLTIP),this.hasReturnValue_=!0},mutationToDom:function(){var e=document.createElement("mutation");return e.setAttribute("value",Number(this.hasReturnValue_)),e},domToMutation:function(e){this.hasReturnValue_=1==e.getAttribute("value"),this.hasReturnValue_||(this.removeInput("VALUE"),this.appendDummyInput("VALUE").appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN))},onchange:function(){if(this.workspace){var e=!1,t=this;do{if("procedures_defnoreturn"==t.type||"procedures_defreturn"==t.type){e=!0;break}t=t.getSurroundParent()}while(t);e?("procedures_defnoreturn"==t.type&&this.hasReturnValue_?(this.removeInput("VALUE"),this.appendDummyInput("VALUE").appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN),this.hasReturnValue_=!1):"procedures_defreturn"!=t.type||this.hasReturnValue_||(this.removeInput("VALUE"),this.appendValueInput("VALUE").appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN),this.hasReturnValue_=!0),this.setWarningText(null)):this.setWarningText(Blockly.Msg.PROCEDURES_IFRETURN_WARNING)}}},Blockly.Blocks.texts={},Blockly.Blocks.texts.HUE=160,Blockly.Blocks.text={init:function(){this.setHelpUrl(Blockly.Msg.TEXT_TEXT_HELPURL),this.setColour(Blockly.Blocks.texts.HUE),this.appendDummyInput().appendField(this.newQuote_(!0)).appendField(new Blockly.FieldTextInput(""),"TEXT").appendField(this.newQuote_(!1)),this.setOutput(!0,"String"),this.setTooltip(Blockly.Msg.TEXT_TEXT_TOOLTIP)},newQuote_:function(e){return new Blockly.FieldImage(e==this.RTL?"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAqUlEQVQI1z3KvUpCcRiA8ef9E4JNHhI0aFEacm1o0BsI0Slx8wa8gLauoDnoBhq7DcfWhggONDmJJgqCPA7neJ7p934EOOKOnM8Q7PDElo/4x4lFb2DmuUjcUzS3URnGib9qaPNbuXvBO3sGPHJDRG6fGVdMSeWDP2q99FQdFrz26Gu5Tq7dFMzUvbXy8KXeAj57cOklgA+u1B5AoslLtGIHQMaCVnwDnADZIFIrXsoXrgAAAABJRU5ErkJggg==":"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAn0lEQVQI1z3OMa5BURSF4f/cQhAKjUQhuQmFNwGJEUi0RKN5rU7FHKhpjEH3TEMtkdBSCY1EIv8r7nFX9e29V7EBAOvu7RPjwmWGH/VuF8CyN9/OAdvqIXYLvtRaNjx9mMTDyo+NjAN1HNcl9ZQ5oQMM3dgDUqDo1l8DzvwmtZN7mnD+PkmLa+4mhrxVA9fRowBWmVBhFy5gYEjKMfz9AylsaRRgGzvZAAAAAElFTkSuQmCC",12,12,'"')}},Blockly.Blocks.text_join={init:function(){this.setHelpUrl(Blockly.Msg.TEXT_JOIN_HELPURL),this.setColour(Blockly.Blocks.texts.HUE),this.itemCount_=2,this.updateShape_(),this.setOutput(!0,"String"),this.setMutator(new Blockly.Mutator(["text_create_join_item"])),this.setTooltip(Blockly.Msg.TEXT_JOIN_TOOLTIP)},mutationToDom:function(){var e=document.createElement("mutation");return e.setAttribute("items",this.itemCount_),e},domToMutation:function(e){this.itemCount_=parseInt(e.getAttribute("items"),10),this.updateShape_()},decompose:function(e){var t=Blockly.Block.obtain(e,"text_create_join_container");t.initSvg();for(var o=t.getInput("STACK").connection,n=0;n<this.itemCount_;n++){var i=Blockly.Block.obtain(e,"text_create_join_item");i.initSvg(),o.connect(i.previousConnection),o=i.nextConnection}return t},compose:function(e){e=e.getInputTargetBlock("STACK");for(var t=[],o=0;e;)t[o]=e.valueConnection_,e=e.nextConnection&&e.nextConnection.targetBlock(),o++;for(this.itemCount_=o,this.updateShape_(),o=0;o<this.itemCount_;o++)t[o]&&this.getInput("ADD"+o).connection.connect(t[o])},saveConnections:function(e){e=e.getInputTargetBlock("STACK");for(var t=0;e;){var o=this.getInput("ADD"+t);e.valueConnection_=o&&o.connection.targetConnection,t++,e=e.nextConnection&&e.nextConnection.targetBlock()}},updateShape_:function(){if(this.getInput("EMPTY"))this.removeInput("EMPTY");else for(var e=0;this.getInput("ADD"+e);)this.removeInput("ADD"+e),e++;if(0==this.itemCount_)this.appendDummyInput("EMPTY").appendField(this.newQuote_(!0)).appendField(this.newQuote_(!1));else for(e=0;e<this.itemCount_;e++){var t=this.appendValueInput("ADD"+e);0==e&&t.appendField(Blockly.Msg.TEXT_JOIN_TITLE_CREATEWITH)}},newQuote_:Blockly.Blocks.text.newQuote_},Blockly.Blocks.text_create_join_container={init:function(){this.setColour(Blockly.Blocks.texts.HUE),this.appendDummyInput().appendField(Blockly.Msg.TEXT_CREATE_JOIN_TITLE_JOIN),this.appendStatementInput("STACK"),this.setTooltip(Blockly.Msg.TEXT_CREATE_JOIN_TOOLTIP),this.contextMenu=!1}},Blockly.Blocks.text_create_join_item={init:function(){this.setColour(Blockly.Blocks.texts.HUE),this.appendDummyInput().appendField(Blockly.Msg.TEXT_CREATE_JOIN_ITEM_TITLE_ITEM),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Blockly.Msg.TEXT_CREATE_JOIN_ITEM_TOOLTIP),this.contextMenu=!1}},Blockly.Blocks.text_append={init:function(){this.setHelpUrl(Blockly.Msg.TEXT_APPEND_HELPURL),this.setColour(Blockly.Blocks.texts.HUE),this.appendValueInput("TEXT").appendField(Blockly.Msg.TEXT_APPEND_TO).appendField(new Blockly.FieldVariable(Blockly.Msg.TEXT_APPEND_VARIABLE),"VAR").appendField(Blockly.Msg.TEXT_APPEND_APPENDTEXT),this.setPreviousStatement(!0),this.setNextStatement(!0);var e=this;this.setTooltip(function(){return Blockly.Msg.TEXT_APPEND_TOOLTIP.replace("%1",e.getFieldValue("VAR"))})},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(e,t){Blockly.Names.equals(e,this.getFieldValue("VAR"))&&this.setFieldValue(t,"VAR")}},Blockly.Blocks.text_length={init:function(){this.setHelpUrl(Blockly.Msg.TEXT_LENGTH_HELPURL),this.setColour(Blockly.Blocks.texts.HUE),this.interpolateMsg(Blockly.Msg.TEXT_LENGTH_TITLE,["VALUE",["String","Array"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setOutput(!0,"Number"),this.setTooltip(Blockly.Msg.TEXT_LENGTH_TOOLTIP)}},Blockly.Blocks.text_isEmpty={init:function(){this.setHelpUrl(Blockly.Msg.TEXT_ISEMPTY_HELPURL),this.setColour(Blockly.Blocks.texts.HUE),this.interpolateMsg(Blockly.Msg.TEXT_ISEMPTY_TITLE,["VALUE",["String","Array"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setOutput(!0,"Boolean"),this.setTooltip(Blockly.Msg.TEXT_ISEMPTY_TOOLTIP)}},Blockly.Blocks.text_indexOf={init:function(){var e=[[Blockly.Msg.TEXT_INDEXOF_OPERATOR_FIRST,"FIRST"],[Blockly.Msg.TEXT_INDEXOF_OPERATOR_LAST,"LAST"]];this.setHelpUrl(Blockly.Msg.TEXT_INDEXOF_HELPURL),this.setColour(Blockly.Blocks.texts.HUE),this.setOutput(!0,"Number"),this.appendValueInput("VALUE").setCheck("String").appendField(Blockly.Msg.TEXT_INDEXOF_INPUT_INTEXT),this.appendValueInput("FIND").setCheck("String").appendField(new Blockly.FieldDropdown(e),"END"),Blockly.Msg.TEXT_INDEXOF_TAIL&&this.appendDummyInput().appendField(Blockly.Msg.TEXT_INDEXOF_TAIL),this.setInputsInline(!0),this.setTooltip(Blockly.Msg.TEXT_INDEXOF_TOOLTIP)}},Blockly.Blocks.text_charAt={init:function(){this.WHERE_OPTIONS=[[Blockly.Msg.TEXT_CHARAT_FROM_START,"FROM_START"],[Blockly.Msg.TEXT_CHARAT_FROM_END,"FROM_END"],[Blockly.Msg.TEXT_CHARAT_FIRST,"FIRST"],[Blockly.Msg.TEXT_CHARAT_LAST,"LAST"],[Blockly.Msg.TEXT_CHARAT_RANDOM,"RANDOM"]],this.setHelpUrl(Blockly.Msg.TEXT_CHARAT_HELPURL),this.setColour(Blockly.Blocks.texts.HUE),this.setOutput(!0,"String"),this.appendValueInput("VALUE").setCheck("String").appendField(Blockly.Msg.TEXT_CHARAT_INPUT_INTEXT),this.appendDummyInput("AT"),this.setInputsInline(!0),this.updateAt_(!0),this.setTooltip(Blockly.Msg.TEXT_CHARAT_TOOLTIP)},mutationToDom:function(){var e=document.createElement("mutation"),t=this.getInput("AT").type==Blockly.INPUT_VALUE;return e.setAttribute("at",t),e},domToMutation:function(e){e="false"!=e.getAttribute("at"),this.updateAt_(e)},updateAt_:function(e){this.removeInput("AT"),this.removeInput("ORDINAL",!0),e?(this.appendValueInput("AT").setCheck("Number"),Blockly.Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL").appendField(Blockly.Msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT"),Blockly.Msg.TEXT_CHARAT_TAIL&&(this.removeInput("TAIL",!0),this.appendDummyInput("TAIL").appendField(Blockly.Msg.TEXT_CHARAT_TAIL));var t=new Blockly.FieldDropdown(this.WHERE_OPTIONS,function(t){var o="FROM_START"==t||"FROM_END"==t;if(o!=e){var n=this.sourceBlock_;return n.updateAt_(o),n.setFieldValue(t,"WHERE"),null}});this.getInput("AT").appendField(t,"WHERE")}},Blockly.Blocks.text_getSubstring={init:function(){this.WHERE_OPTIONS_1=[[Blockly.Msg.TEXT_GET_SUBSTRING_START_FROM_START,"FROM_START"],[Blockly.Msg.TEXT_GET_SUBSTRING_START_FROM_END,"FROM_END"],[Blockly.Msg.TEXT_GET_SUBSTRING_START_FIRST,"FIRST"]],this.WHERE_OPTIONS_2=[[Blockly.Msg.TEXT_GET_SUBSTRING_END_FROM_START,"FROM_START"],[Blockly.Msg.TEXT_GET_SUBSTRING_END_FROM_END,"FROM_END"],[Blockly.Msg.TEXT_GET_SUBSTRING_END_LAST,"LAST"]],this.setHelpUrl(Blockly.Msg.TEXT_GET_SUBSTRING_HELPURL),this.setColour(Blockly.Blocks.texts.HUE),this.appendValueInput("STRING").setCheck("String").appendField(Blockly.Msg.TEXT_GET_SUBSTRING_INPUT_IN_TEXT),this.appendDummyInput("AT1"),this.appendDummyInput("AT2"),Blockly.Msg.TEXT_GET_SUBSTRING_TAIL&&this.appendDummyInput("TAIL").appendField(Blockly.Msg.TEXT_GET_SUBSTRING_TAIL),this.setInputsInline(!0),this.setOutput(!0,"String"),this.updateAt_(1,!0),this.updateAt_(2,!0),this.setTooltip(Blockly.Msg.TEXT_GET_SUBSTRING_TOOLTIP)},mutationToDom:function(){var e=document.createElement("mutation"),t=this.getInput("AT1").type==Blockly.INPUT_VALUE;return e.setAttribute("at1",t),t=this.getInput("AT2").type==Blockly.INPUT_VALUE,e.setAttribute("at2",t),e},domToMutation:function(e){var t="true"==e.getAttribute("at1");e="true"==e.getAttribute("at2"),this.updateAt_(1,t),this.updateAt_(2,e)},updateAt_:function(e,t){this.removeInput("AT"+e),this.removeInput("ORDINAL"+e,!0),t?(this.appendValueInput("AT"+e).setCheck("Number"),Blockly.Msg.ORDINAL_NUMBER_SUFFIX&&this.appendDummyInput("ORDINAL"+e).appendField(Blockly.Msg.ORDINAL_NUMBER_SUFFIX)):this.appendDummyInput("AT"+e),2==e&&Blockly.Msg.TEXT_GET_SUBSTRING_TAIL&&(this.removeInput("TAIL",!0),this.appendDummyInput("TAIL").appendField(Blockly.Msg.TEXT_GET_SUBSTRING_TAIL));var o=new Blockly.FieldDropdown(this["WHERE_OPTIONS_"+e],function(o){var n="FROM_START"==o||"FROM_END"==o;if(n!=t){var i=this.sourceBlock_;return i.updateAt_(e,n),i.setFieldValue(o,"WHERE"+e),null}});this.getInput("AT"+e).appendField(o,"WHERE"+e),1==e&&this.moveInputBefore("AT1","AT2")}},Blockly.Blocks.text_changeCase={init:function(){var e=[[Blockly.Msg.TEXT_CHANGECASE_OPERATOR_UPPERCASE,"UPPERCASE"],[Blockly.Msg.TEXT_CHANGECASE_OPERATOR_LOWERCASE,"LOWERCASE"],[Blockly.Msg.TEXT_CHANGECASE_OPERATOR_TITLECASE,"TITLECASE"]];this.setHelpUrl(Blockly.Msg.TEXT_CHANGECASE_HELPURL),this.setColour(Blockly.Blocks.texts.HUE),this.appendValueInput("TEXT").setCheck("String").appendField(new Blockly.FieldDropdown(e),"CASE"),this.setOutput(!0,"String"),this.setTooltip(Blockly.Msg.TEXT_CHANGECASE_TOOLTIP)}},Blockly.Blocks.text_trim={init:function(){var e=[[Blockly.Msg.TEXT_TRIM_OPERATOR_BOTH,"BOTH"],[Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT,"LEFT"],[Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT,"RIGHT"]];this.setHelpUrl(Blockly.Msg.TEXT_TRIM_HELPURL),this.setColour(Blockly.Blocks.texts.HUE),this.appendValueInput("TEXT").setCheck("String").appendField(new Blockly.FieldDropdown(e),"MODE"),this.setOutput(!0,"String"),this.setTooltip(Blockly.Msg.TEXT_TRIM_TOOLTIP)}},Blockly.Blocks.text_print={init:function(){this.setHelpUrl(Blockly.Msg.TEXT_PRINT_HELPURL),this.setColour(Blockly.Blocks.texts.HUE),this.interpolateMsg(Blockly.Msg.TEXT_PRINT_TITLE,["TEXT",null,Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Blockly.Msg.TEXT_PRINT_TOOLTIP)}},Blockly.Blocks.text_prompt={init:function(){var e=[[Blockly.Msg.TEXT_PROMPT_TYPE_TEXT,"TEXT"],[Blockly.Msg.TEXT_PROMPT_TYPE_NUMBER,"NUMBER"]],t=this;this.setHelpUrl(Blockly.Msg.TEXT_PROMPT_HELPURL),this.setColour(Blockly.Blocks.texts.HUE),e=new Blockly.FieldDropdown(e,function(e){"NUMBER"==e?t.changeOutput("Number"):t.changeOutput("String")}),this.appendDummyInput().appendField(e,"TYPE").appendField(this.newQuote_(!0)).appendField(new Blockly.FieldTextInput(""),"TEXT").appendField(this.newQuote_(!1)),this.setOutput(!0,"String"),t=this,this.setTooltip(function(){return"TEXT"==t.getFieldValue("TYPE")?Blockly.Msg.TEXT_PROMPT_TOOLTIP_TEXT:Blockly.Msg.TEXT_PROMPT_TOOLTIP_NUMBER})},newQuote_:Blockly.Blocks.text.newQuote_},Blockly.Blocks.text_prompt_ext={init:function(){var e=[[Blockly.Msg.TEXT_PROMPT_TYPE_TEXT,"TEXT"],[Blockly.Msg.TEXT_PROMPT_TYPE_NUMBER,"NUMBER"]],t=this;this.setHelpUrl(Blockly.Msg.TEXT_PROMPT_HELPURL),this.setColour(Blockly.Blocks.texts.HUE),e=new Blockly.FieldDropdown(e,function(e){"NUMBER"==e?t.changeOutput("Number"):t.changeOutput("String")}),this.appendValueInput("TEXT").appendField(e,"TYPE"),this.setOutput(!0,"String"),t=this,this.setTooltip(function(){return"TEXT"==t.getFieldValue("TYPE")?Blockly.Msg.TEXT_PROMPT_TOOLTIP_TEXT:Blockly.Msg.TEXT_PROMPT_TOOLTIP_NUMBER})}},Blockly.Blocks.variables={},Blockly.Blocks.variables.HUE=330,Blockly.Blocks.variables_get={init:function(){this.setHelpUrl(Blockly.Msg.VARIABLES_GET_HELPURL),this.setColour(Blockly.Blocks.variables.HUE),this.appendDummyInput().appendField(Blockly.Msg.VARIABLES_GET_TITLE).appendField(new Blockly.FieldVariable(Blockly.Msg.VARIABLES_GET_ITEM),"VAR").appendField(Blockly.Msg.VARIABLES_GET_TAIL),this.setOutput(!0),this.setTooltip(Blockly.Msg.VARIABLES_GET_TOOLTIP),this.contextMenuMsg_=Blockly.Msg.VARIABLES_GET_CREATE_SET,this.contextMenuType_="variables_set"},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(e,t){Blockly.Names.equals(e,this.getFieldValue("VAR"))&&this.setFieldValue(t,"VAR")},customContextMenu:function(e){var t={enabled:!0},o=this.getFieldValue("VAR");t.text=this.contextMenuMsg_.replace("%1",o),o=goog.dom.createDom("field",null,o),o.setAttribute("name","VAR"),o=goog.dom.createDom("block",null,o),o.setAttribute("type",this.contextMenuType_),t.callback=Blockly.ContextMenu.callbackFactory(this,o),e.push(t)}},Blockly.Blocks.variables_set={init:function(){this.setHelpUrl(Blockly.Msg.VARIABLES_SET_HELPURL),this.setColour(Blockly.Blocks.variables.HUE),this.interpolateMsg(Blockly.Msg.VARIABLES_SET_TITLE+" %1 "+Blockly.Msg.VARIABLES_SET_TAIL+" %2",["VAR",new Blockly.FieldVariable(Blockly.Msg.VARIABLES_SET_ITEM)],["VALUE",null,Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(Blockly.Msg.VARIABLES_SET_TOOLTIP),this.contextMenuMsg_=Blockly.Msg.VARIABLES_SET_CREATE_GET,this.contextMenuType_="variables_get"},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(e,t){Blockly.Names.equals(e,this.getFieldValue("VAR"))&&this.setFieldValue(t,"VAR")},customContextMenu:Blockly.Blocks.variables_get.customContextMenu},Blockly.Toolbox.TreeNode.prototype.onMouseDown=function(){this.hasChildren()&&this.isUserCollapsible_?(this.toggle(),this.select()):this.isSelected()||this.select(),this.updateRow()},Blockly.Blocks.math.HUE=100,Blockly.Blocks.texts.HUE=100,Blockly.Names.prototype.safeName_=function(e){return e?(e=e.replace(/[ !"#$%&'()=\-~^\\|`@{\[+;*:}\]<>,.?\/]/g,"_"),-1!="0123456789".indexOf(e[0])&&(e="_"+e)):e="unnamed",e},Blockly._init_=Blockly.init_,Blockly.init_=function(e){Blockly._init_(e),Blockly.bindEvent_(Blockly.WidgetDiv.DIV,"contextmenu",null,function(e){Blockly.isTargetInput_(e)||e.preventDefault()})},function(){var e=this,t=e._,o={},n=Array.prototype,i=Object.prototype,r=Function.prototype,s=n.push,l=n.slice,a=n.concat,c=i.toString,g=i.hasOwnProperty,u=n.forEach,h=n.map,d=n.reduce,p=n.reduceRight,f=n.filter,m=n.every,y=n.some,_=n.indexOf,E=n.lastIndexOf,v=Array.isArray,C=Object.keys,B=r.bind,b=function(e){return e instanceof b?e:this instanceof b?(this._wrapped=e,void 0):new b(e)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=b),exports._=b):e._=b,b.VERSION="1.5.2";var k=b.each=b.forEach=function(e,t,n){if(null!=e)if(u&&e.forEach===u)e.forEach(t,n);else if(e.length===+e.length){for(var i=0,r=e.length;r>i;i++)if(t.call(n,e[i],i,e)===o)return}else for(var s=b.keys(e),i=0,r=s.length;r>i;i++)if(t.call(n,e[s[i]],s[i],e)===o)return};b.map=b.collect=function(e,t,o){var n=[];return null==e?n:h&&e.map===h?e.map(t,o):(k(e,function(e,i,r){n.push(t.call(o,e,i,r))}),n)};var A="Reduce of empty array with no initial value";b.reduce=b.foldl=b.inject=function(e,t,o,n){var i=arguments.length>2;if(null==e&&(e=[]),d&&e.reduce===d)return n&&(t=b.bind(t,n)),i?e.reduce(t,o):e.reduce(t);if(k(e,function(e,r,s){i?o=t.call(n,o,e,r,s):(o=e,i=!0)}),!i)throw new TypeError(A);return o},b.reduceRight=b.foldr=function(e,t,o,n){var i=arguments.length>2;if(null==e&&(e=[]),p&&e.reduceRight===p)return n&&(t=b.bind(t,n)),i?e.reduceRight(t,o):e.reduceRight(t);var r=e.length;if(r!==+r){var s=b.keys(e);r=s.length}if(k(e,function(l,a,c){a=s?s[--r]:--r,i?o=t.call(n,o,e[a],a,c):(o=e[a],i=!0)}),!i)throw new TypeError(A);return o},b.find=b.detect=function(e,t,o){var n;return S(e,function(e,i,r){return t.call(o,e,i,r)?(n=e,!0):void 0}),n},b.filter=b.select=function(e,t,o){var n=[];return null==e?n:f&&e.filter===f?e.filter(t,o):(k(e,function(e,i,r){t.call(o,e,i,r)&&n.push(e)}),n)},b.reject=function(e,t,o){return b.filter(e,function(e,n,i){return!t.call(o,e,n,i)},o)},b.every=b.all=function(e,t,n){t||(t=b.identity);var i=!0;return null==e?i:m&&e.every===m?e.every(t,n):(k(e,function(e,r,s){return(i=i&&t.call(n,e,r,s))?void 0:o}),!!i)};var S=b.some=b.any=function(e,t,n){t||(t=b.identity);var i=!1;return null==e?i:y&&e.some===y?e.some(t,n):(k(e,function(e,r,s){return i||(i=t.call(n,e,r,s))?o:void 0}),!!i)};b.contains=b.include=function(e,t){return null==e?!1:_&&e.indexOf===_?-1!=e.indexOf(t):S(e,function(e){return e===t})},b.invoke=function(e,t){var o=l.call(arguments,2),n=b.isFunction(t);return b.map(e,function(e){return(n?t:e[t]).apply(e,o)})},b.pluck=function(e,t){return b.map(e,function(e){return e[t]})},b.where=function(e,t,o){return b.isEmpty(t)?o?void 0:[]:b[o?"find":"filter"](e,function(e){for(var o in t)if(t[o]!==e[o])return!1;return!0})},b.findWhere=function(e,t){return b.where(e,t,!0)},b.max=function(e,t,o){if(!t&&b.isArray(e)&&e[0]===+e[0]&&e.length<65535)return Math.max.apply(Math,e);if(!t&&b.isEmpty(e))return-1/0;var n={computed:-1/0,value:-1/0};return k(e,function(e,i,r){var s=t?t.call(o,e,i,r):e;s>n.computed&&(n={value:e,computed:s})}),n.value},b.min=function(e,t,o){if(!t&&b.isArray(e)&&e[0]===+e[0]&&e.length<65535)return Math.min.apply(Math,e);
|
36
36
|
if(!t&&b.isEmpty(e))return 1/0;var n={computed:1/0,value:1/0};return k(e,function(e,i,r){var s=t?t.call(o,e,i,r):e;s<n.computed&&(n={value:e,computed:s})}),n.value},b.shuffle=function(e){var t,o=0,n=[];return k(e,function(e){t=b.random(o++),n[o-1]=n[t],n[t]=e}),n},b.sample=function(e,t,o){return arguments.length<2||o?e[b.random(e.length-1)]:b.shuffle(e).slice(0,Math.max(0,t))};var T=function(e){return b.isFunction(e)?e:function(t){return t[e]}};b.sortBy=function(e,t,o){var n=T(t);return b.pluck(b.map(e,function(e,t,i){return{value:e,index:t,criteria:n.call(o,e,t,i)}}).sort(function(e,t){var o=e.criteria,n=t.criteria;if(o!==n){if(o>n||void 0===o)return 1;if(n>o||void 0===n)return-1}return e.index-t.index}),"value")};var R=function(e){return function(t,o,n){var i={},r=null==o?b.identity:T(o);return k(t,function(o,s){var l=r.call(n,o,s,t);e(i,l,o)}),i}};b.groupBy=R(function(e,t,o){(b.has(e,t)?e[t]:e[t]=[]).push(o)}),b.indexBy=R(function(e,t,o){e[t]=o}),b.countBy=R(function(e,t){b.has(e,t)?e[t]++:e[t]=1}),b.sortedIndex=function(e,t,o,n){o=null==o?b.identity:T(o);for(var i=o.call(n,t),r=0,s=e.length;s>r;){var l=r+s>>>1;o.call(n,e[l])<i?r=l+1:s=l}return r},b.toArray=function(e){return e?b.isArray(e)?l.call(e):e.length===+e.length?b.map(e,b.identity):b.values(e):[]},b.size=function(e){return null==e?0:e.length===+e.length?e.length:b.keys(e).length},b.first=b.head=b.take=function(e,t,o){return null==e?void 0:null==t||o?e[0]:l.call(e,0,t)},b.initial=function(e,t,o){return l.call(e,0,e.length-(null==t||o?1:t))},b.last=function(e,t,o){return null==e?void 0:null==t||o?e[e.length-1]:l.call(e,Math.max(e.length-t,0))},b.rest=b.tail=b.drop=function(e,t,o){return l.call(e,null==t||o?1:t)},b.compact=function(e){return b.filter(e,b.identity)};var I=function(e,t,o){return t&&b.every(e,b.isArray)?a.apply(o,e):(k(e,function(e){b.isArray(e)||b.isArguments(e)?t?s.apply(o,e):I(e,t,o):o.push(e)}),o)};b.flatten=function(e,t){return I(e,t,[])},b.without=function(e){return b.difference(e,l.call(arguments,1))},b.uniq=b.unique=function(e,t,o,n){b.isFunction(t)&&(n=o,o=t,t=!1);var i=o?b.map(e,o,n):e,r=[],s=[];return k(i,function(o,n){(t?n&&s[s.length-1]===o:b.contains(s,o))||(s.push(o),r.push(e[n]))}),r},b.union=function(){return b.uniq(b.flatten(arguments,!0))},b.intersection=function(e){var t=l.call(arguments,1);return b.filter(b.uniq(e),function(e){return b.every(t,function(t){return b.indexOf(t,e)>=0})})},b.difference=function(e){var t=a.apply(n,l.call(arguments,1));return b.filter(e,function(e){return!b.contains(t,e)})},b.zip=function(){for(var e=b.max(b.pluck(arguments,"length").concat(0)),t=new Array(e),o=0;e>o;o++)t[o]=b.pluck(arguments,""+o);return t},b.object=function(e,t){if(null==e)return{};for(var o={},n=0,i=e.length;i>n;n++)t?o[e[n]]=t[n]:o[e[n][0]]=e[n][1];return o},b.indexOf=function(e,t,o){if(null==e)return-1;var n=0,i=e.length;if(o){if("number"!=typeof o)return n=b.sortedIndex(e,t),e[n]===t?n:-1;n=0>o?Math.max(0,i+o):o}if(_&&e.indexOf===_)return e.indexOf(t,o);for(;i>n;n++)if(e[n]===t)return n;return-1},b.lastIndexOf=function(e,t,o){if(null==e)return-1;var n=null!=o;if(E&&e.lastIndexOf===E)return n?e.lastIndexOf(t,o):e.lastIndexOf(t);for(var i=n?o:e.length;i--;)if(e[i]===t)return i;return-1},b.range=function(e,t,o){arguments.length<=1&&(t=e||0,e=0),o=arguments[2]||1;for(var n=Math.max(Math.ceil((t-e)/o),0),i=0,r=new Array(n);n>i;)r[i++]=e,e+=o;return r};var D=function(){};b.bind=function(e,t){var o,n;if(B&&e.bind===B)return B.apply(e,l.call(arguments,1));if(!b.isFunction(e))throw new TypeError;return o=l.call(arguments,2),n=function(){if(!(this instanceof n))return e.apply(t,o.concat(l.call(arguments)));D.prototype=e.prototype;var i=new D;D.prototype=null;var r=e.apply(i,o.concat(l.call(arguments)));return Object(r)===r?r:i}},b.partial=function(e){var t=l.call(arguments,1);return function(){return e.apply(this,t.concat(l.call(arguments)))}},b.bindAll=function(e){var t=l.call(arguments,1);if(0===t.length)throw new Error("bindAll must be passed function names");return k(t,function(t){e[t]=b.bind(e[t],e)}),e},b.memoize=function(e,t){var o={};return t||(t=b.identity),function(){var n=t.apply(this,arguments);return b.has(o,n)?o[n]:o[n]=e.apply(this,arguments)}},b.delay=function(e,t){var o=l.call(arguments,2);return setTimeout(function(){return e.apply(null,o)},t)},b.defer=function(e){return b.delay.apply(b,[e,1].concat(l.call(arguments,1)))},b.throttle=function(e,t,o){var n,i,r,s=null,l=0;o||(o={});var a=function(){l=o.leading===!1?0:new Date,s=null,r=e.apply(n,i)};return function(){var c=new Date;l||o.leading!==!1||(l=c);var g=t-(c-l);return n=this,i=arguments,0>=g?(clearTimeout(s),s=null,l=c,r=e.apply(n,i)):s||o.trailing===!1||(s=setTimeout(a,g)),r}},b.debounce=function(e,t,o){var n,i,r,s,l;return function(){r=this,i=arguments,s=new Date;var a=function(){var c=new Date-s;t>c?n=setTimeout(a,t-c):(n=null,o||(l=e.apply(r,i)))},c=o&&!n;return n||(n=setTimeout(a,t)),c&&(l=e.apply(r,i)),l}},b.once=function(e){var t,o=!1;return function(){return o?t:(o=!0,t=e.apply(this,arguments),e=null,t)}},b.wrap=function(e,t){return function(){var o=[e];return s.apply(o,arguments),t.apply(this,o)}},b.compose=function(){var e=arguments;return function(){for(var t=arguments,o=e.length-1;o>=0;o--)t=[e[o].apply(this,t)];return t[0]}},b.after=function(e,t){return function(){return--e<1?t.apply(this,arguments):void 0}},b.keys=C||function(e){if(e!==Object(e))throw new TypeError("Invalid object");var t=[];for(var o in e)b.has(e,o)&&t.push(o);return t},b.values=function(e){for(var t=b.keys(e),o=t.length,n=new Array(o),i=0;o>i;i++)n[i]=e[t[i]];return n},b.pairs=function(e){for(var t=b.keys(e),o=t.length,n=new Array(o),i=0;o>i;i++)n[i]=[t[i],e[t[i]]];return n},b.invert=function(e){for(var t={},o=b.keys(e),n=0,i=o.length;i>n;n++)t[e[o[n]]]=o[n];return t},b.functions=b.methods=function(e){var t=[];for(var o in e)b.isFunction(e[o])&&t.push(o);return t.sort()},b.extend=function(e){return k(l.call(arguments,1),function(t){if(t)for(var o in t)e[o]=t[o]}),e},b.pick=function(e){var t={},o=a.apply(n,l.call(arguments,1));return k(o,function(o){o in e&&(t[o]=e[o])}),t},b.omit=function(e){var t={},o=a.apply(n,l.call(arguments,1));for(var i in e)b.contains(o,i)||(t[i]=e[i]);return t},b.defaults=function(e){return k(l.call(arguments,1),function(t){if(t)for(var o in t)void 0===e[o]&&(e[o]=t[o])}),e},b.clone=function(e){return b.isObject(e)?b.isArray(e)?e.slice():b.extend({},e):e},b.tap=function(e,t){return t(e),e};var w=function(e,t,o,n){if(e===t)return 0!==e||1/e==1/t;if(null==e||null==t)return e===t;e instanceof b&&(e=e._wrapped),t instanceof b&&(t=t._wrapped);var i=c.call(e);if(i!=c.call(t))return!1;switch(i){case"[object String]":return e==String(t);case"[object Number]":return e!=+e?t!=+t:0==e?1/e==1/t:e==+t;case"[object Date]":case"[object Boolean]":return+e==+t;case"[object RegExp]":return e.source==t.source&&e.global==t.global&&e.multiline==t.multiline&&e.ignoreCase==t.ignoreCase}if("object"!=typeof e||"object"!=typeof t)return!1;for(var r=o.length;r--;)if(o[r]==e)return n[r]==t;var s=e.constructor,l=t.constructor;if(s!==l&&!(b.isFunction(s)&&s instanceof s&&b.isFunction(l)&&l instanceof l))return!1;o.push(e),n.push(t);var a=0,g=!0;if("[object Array]"==i){if(a=e.length,g=a==t.length)for(;a--&&(g=w(e[a],t[a],o,n)););}else{for(var u in e)if(b.has(e,u)&&(a++,!(g=b.has(t,u)&&w(e[u],t[u],o,n))))break;if(g){for(u in t)if(b.has(t,u)&&!a--)break;g=!a}}return o.pop(),n.pop(),g};b.isEqual=function(e,t){return w(e,t,[],[])},b.isEmpty=function(e){if(null==e)return!0;if(b.isArray(e)||b.isString(e))return 0===e.length;for(var t in e)if(b.has(e,t))return!1;return!0},b.isElement=function(e){return!(!e||1!==e.nodeType)},b.isArray=v||function(e){return"[object Array]"==c.call(e)},b.isObject=function(e){return e===Object(e)},k(["Arguments","Function","String","Number","Date","RegExp"],function(e){b["is"+e]=function(t){return c.call(t)=="[object "+e+"]"}}),b.isArguments(arguments)||(b.isArguments=function(e){return!(!e||!b.has(e,"callee"))}),"function"!=typeof/./&&(b.isFunction=function(e){return"function"==typeof e}),b.isFinite=function(e){return isFinite(e)&&!isNaN(parseFloat(e))},b.isNaN=function(e){return b.isNumber(e)&&e!=+e},b.isBoolean=function(e){return e===!0||e===!1||"[object Boolean]"==c.call(e)},b.isNull=function(e){return null===e},b.isUndefined=function(e){return void 0===e},b.has=function(e,t){return g.call(e,t)},b.noConflict=function(){return e._=t,this},b.identity=function(e){return e},b.times=function(e,t,o){for(var n=Array(Math.max(0,e)),i=0;e>i;i++)n[i]=t.call(o,i);return n},b.random=function(e,t){return null==t&&(t=e,e=0),e+Math.floor(Math.random()*(t-e+1))};var L={escape:{"&":"&","<":"<",">":">",'"':""","'":"'"}};L.unescape=b.invert(L.escape);var O={escape:new RegExp("["+b.keys(L.escape).join("")+"]","g"),unescape:new RegExp("("+b.keys(L.unescape).join("|")+")","g")};b.each(["escape","unescape"],function(e){b[e]=function(t){return null==t?"":(""+t).replace(O[e],function(t){return L[e][t]})}}),b.result=function(e,t){if(null==e)return void 0;var o=e[t];return b.isFunction(o)?o.call(e):o},b.mixin=function(e){k(b.functions(e),function(t){var o=b[t]=e[t];b.prototype[t]=function(){var e=[this._wrapped];return s.apply(e,arguments),P.call(this,o.apply(b,e))}})};var F=0;b.uniqueId=function(e){var t=++F+"";return e?e+t:t},b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var N=/(.)^/,M={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},x=/\\|'|\r|\n|\t|\u2028|\u2029/g;b.template=function(e,t,o){var n;o=b.defaults({},o,b.templateSettings);var i=new RegExp([(o.escape||N).source,(o.interpolate||N).source,(o.evaluate||N).source].join("|")+"|$","g"),r=0,s="__p+='";e.replace(i,function(t,o,n,i,l){return s+=e.slice(r,l).replace(x,function(e){return"\\"+M[e]}),o&&(s+="'+\n((__t=("+o+"))==null?'':_.escape(__t))+\n'"),n&&(s+="'+\n((__t=("+n+"))==null?'':__t)+\n'"),i&&(s+="';\n"+i+"\n__p+='"),r=l+t.length,t}),s+="';\n",o.variable||(s="with(obj||{}){\n"+s+"}\n"),s="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+s+"return __p;\n";try{n=new Function(o.variable||"obj","_",s)}catch(l){throw l.source=s,l}if(t)return n(t,b);var a=function(e){return n.call(this,e,b)};return a.source="function("+(o.variable||"obj")+"){\n"+s+"}",a},b.chain=function(e){return b(e).chain()};var P=function(e){return this._chain?b(e).chain():e};b.mixin(b),k(["pop","push","reverse","shift","sort","splice","unshift"],function(e){var t=n[e];b.prototype[e]=function(){var o=this._wrapped;return t.apply(o,arguments),"shift"!=e&&"splice"!=e||0!==o.length||delete o[0],P.call(this,o)}}),k(["concat","join","slice"],function(e){var t=n[e];b.prototype[e]=function(){return P.call(this,t.apply(this._wrapped,arguments))}}),b.extend(b.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}.call(this),function(){{var e,t=this,o=t.Backbone,n=[],i=(n.push,n.slice);n.splice}e="undefined"!=typeof exports?exports:t.Backbone={},e.VERSION="1.1.0";var r=t._;r||"undefined"==typeof require||(r=require("underscore")),e.$=t.jQuery||t.Zepto||t.ender||t.$,e.noConflict=function(){return t.Backbone=o,this},e.emulateHTTP=!1,e.emulateJSON=!1;var s=e.Events={on:function(e,t,o){if(!a(this,"on",e,[t,o])||!t)return this;this._events||(this._events={});var n=this._events[e]||(this._events[e]=[]);return n.push({callback:t,context:o,ctx:o||this}),this},once:function(e,t,o){if(!a(this,"once",e,[t,o])||!t)return this;var n=this,i=r.once(function(){n.off(e,i),t.apply(this,arguments)});return i._callback=t,this.on(e,i,o)},off:function(e,t,o){var n,i,s,l,c,g,u,h;if(!this._events||!a(this,"off",e,[t,o]))return this;if(!e&&!t&&!o)return this._events={},this;for(l=e?[e]:r.keys(this._events),c=0,g=l.length;g>c;c++)if(e=l[c],s=this._events[e]){if(this._events[e]=n=[],t||o)for(u=0,h=s.length;h>u;u++)i=s[u],(t&&t!==i.callback&&t!==i.callback._callback||o&&o!==i.context)&&n.push(i);n.length||delete this._events[e]}return this},trigger:function(e){if(!this._events)return this;var t=i.call(arguments,1);if(!a(this,"trigger",e,t))return this;var o=this._events[e],n=this._events.all;return o&&c(o,t),n&&c(n,arguments),this},stopListening:function(e,t,o){var n=this._listeningTo;if(!n)return this;var i=!t&&!o;o||"object"!=typeof t||(o=this),e&&((n={})[e._listenId]=e);for(var s in n)e=n[s],e.off(t,o,this),(i||r.isEmpty(e._events))&&delete this._listeningTo[s];return this}},l=/\s+/,a=function(e,t,o,n){if(!o)return!0;if("object"==typeof o){for(var i in o)e[t].apply(e,[i,o[i]].concat(n));return!1}if(l.test(o)){for(var r=o.split(l),s=0,a=r.length;a>s;s++)e[t].apply(e,[r[s]].concat(n));return!1}return!0},c=function(e,t){var o,n=-1,i=e.length,r=t[0],s=t[1],l=t[2];switch(t.length){case 0:for(;++n<i;)(o=e[n]).callback.call(o.ctx);return;case 1:for(;++n<i;)(o=e[n]).callback.call(o.ctx,r);return;case 2:for(;++n<i;)(o=e[n]).callback.call(o.ctx,r,s);return;case 3:for(;++n<i;)(o=e[n]).callback.call(o.ctx,r,s,l);return;default:for(;++n<i;)(o=e[n]).callback.apply(o.ctx,t)}},g={listenTo:"on",listenToOnce:"once"};r.each(g,function(e,t){s[t]=function(t,o,n){var i=this._listeningTo||(this._listeningTo={}),s=t._listenId||(t._listenId=r.uniqueId("l"));return i[s]=t,n||"object"!=typeof o||(n=this),t[e](o,n,this),this}}),s.bind=s.on,s.unbind=s.off,r.extend(e,s);var u=e.Model=function(e,t){var o=e||{};t||(t={}),this.cid=r.uniqueId("c"),this.attributes={},t.collection&&(this.collection=t.collection),t.parse&&(o=this.parse(o,t)||{}),o=r.defaults({},o,r.result(this,"defaults")),this.set(o,t),this.changed={},this.initialize.apply(this,arguments)};r.extend(u.prototype,s,{changed:null,validationError:null,idAttribute:"id",initialize:function(){},toJSON:function(){return r.clone(this.attributes)},sync:function(){return e.sync.apply(this,arguments)},get:function(e){return this.attributes[e]},escape:function(e){return r.escape(this.get(e))},has:function(e){return null!=this.get(e)},set:function(e,t,o){var n,i,s,l,a,c,g,u;if(null==e)return this;if("object"==typeof e?(i=e,o=t):(i={})[e]=t,o||(o={}),!this._validate(i,o))return!1;s=o.unset,a=o.silent,l=[],c=this._changing,this._changing=!0,c||(this._previousAttributes=r.clone(this.attributes),this.changed={}),u=this.attributes,g=this._previousAttributes,this.idAttribute in i&&(this.id=i[this.idAttribute]);for(n in i)t=i[n],r.isEqual(u[n],t)||l.push(n),r.isEqual(g[n],t)?delete this.changed[n]:this.changed[n]=t,s?delete u[n]:u[n]=t;if(!a){l.length&&(this._pending=!0);for(var h=0,d=l.length;d>h;h++)this.trigger("change:"+l[h],this,u[l[h]],o)}if(c)return this;if(!a)for(;this._pending;)this._pending=!1,this.trigger("change",this,o);return this._pending=!1,this._changing=!1,this},unset:function(e,t){return this.set(e,void 0,r.extend({},t,{unset:!0}))},clear:function(e){var t={};for(var o in this.attributes)t[o]=void 0;return this.set(t,r.extend({},e,{unset:!0}))},hasChanged:function(e){return null==e?!r.isEmpty(this.changed):r.has(this.changed,e)},changedAttributes:function(e){if(!e)return this.hasChanged()?r.clone(this.changed):!1;var t,o=!1,n=this._changing?this._previousAttributes:this.attributes;for(var i in e)r.isEqual(n[i],t=e[i])||((o||(o={}))[i]=t);return o},previous:function(e){return null!=e&&this._previousAttributes?this._previousAttributes[e]:null},previousAttributes:function(){return r.clone(this._previousAttributes)},fetch:function(e){e=e?r.clone(e):{},void 0===e.parse&&(e.parse=!0);var t=this,o=e.success;return e.success=function(n){return t.set(t.parse(n,e),e)?(o&&o(t,n,e),t.trigger("sync",t,n,e),void 0):!1},M(this,e),this.sync("read",this,e)},save:function(e,t,o){var n,i,s,l=this.attributes;if(null==e||"object"==typeof e?(n=e,o=t):(n={})[e]=t,o=r.extend({validate:!0},o),n&&!o.wait){if(!this.set(n,o))return!1}else if(!this._validate(n,o))return!1;n&&o.wait&&(this.attributes=r.extend({},l,n)),void 0===o.parse&&(o.parse=!0);var a=this,c=o.success;return o.success=function(e){a.attributes=l;var t=a.parse(e,o);return o.wait&&(t=r.extend(n||{},t)),r.isObject(t)&&!a.set(t,o)?!1:(c&&c(a,e,o),a.trigger("sync",a,e,o),void 0)},M(this,o),i=this.isNew()?"create":o.patch?"patch":"update","patch"===i&&(o.attrs=n),s=this.sync(i,this,o),n&&o.wait&&(this.attributes=l),s},destroy:function(e){e=e?r.clone(e):{};var t=this,o=e.success,n=function(){t.trigger("destroy",t,t.collection,e)};if(e.success=function(i){(e.wait||t.isNew())&&n(),o&&o(t,i,e),t.isNew()||t.trigger("sync",t,i,e)},this.isNew())return e.success(),!1;M(this,e);var i=this.sync("delete",this,e);return e.wait||n(),i},url:function(){var e=r.result(this,"urlRoot")||r.result(this.collection,"url")||N();return this.isNew()?e:e+("/"===e.charAt(e.length-1)?"":"/")+encodeURIComponent(this.id)},parse:function(e){return e},clone:function(){return new this.constructor(this.attributes)},isNew:function(){return null==this.id},isValid:function(e){return this._validate({},r.extend(e||{},{validate:!0}))},_validate:function(e,t){if(!t.validate||!this.validate)return!0;e=r.extend({},this.attributes,e);var o=this.validationError=this.validate(e,t)||null;return o?(this.trigger("invalid",this,o,r.extend(t,{validationError:o})),!1):!0}});var h=["keys","values","pairs","invert","pick","omit"];r.each(h,function(e){u.prototype[e]=function(){var t=i.call(arguments);return t.unshift(this.attributes),r[e].apply(r,t)}});var d=e.Collection=function(e,t){t||(t={}),t.model&&(this.model=t.model),void 0!==t.comparator&&(this.comparator=t.comparator),this._reset(),this.initialize.apply(this,arguments),e&&this.reset(e,r.extend({silent:!0},t))},p={add:!0,remove:!0,merge:!0},f={add:!0,remove:!1};r.extend(d.prototype,s,{model:u,initialize:function(){},toJSON:function(e){return this.map(function(t){return t.toJSON(e)})},sync:function(){return e.sync.apply(this,arguments)},add:function(e,t){return this.set(e,r.extend({merge:!1},t,f))},remove:function(e,t){var o=!r.isArray(e);e=o?[e]:r.clone(e),t||(t={});var n,i,s,l;for(n=0,i=e.length;i>n;n++)l=e[n]=this.get(e[n]),l&&(delete this._byId[l.id],delete this._byId[l.cid],s=this.indexOf(l),this.models.splice(s,1),this.length--,t.silent||(t.index=s,l.trigger("remove",l,this,t)),this._removeReference(l));return o?e[0]:e},set:function(e,t){t=r.defaults({},t,p),t.parse&&(e=this.parse(e,t));var o=!r.isArray(e);e=o?e?[e]:[]:r.clone(e);var n,i,s,l,a,c,g,h=t.at,d=this.model,f=this.comparator&&null==h&&t.sort!==!1,m=r.isString(this.comparator)?this.comparator:null,y=[],_=[],E={},v=t.add,C=t.merge,B=t.remove,b=!f&&v&&B?[]:!1;for(n=0,i=e.length;i>n;n++){if(a=e[n],s=a instanceof u?l=a:a[d.prototype.idAttribute],c=this.get(s))B&&(E[c.cid]=!0),C&&(a=a===l?l.attributes:a,t.parse&&(a=c.parse(a,t)),c.set(a,t),f&&!g&&c.hasChanged(m)&&(g=!0)),e[n]=c;else if(v){if(l=e[n]=this._prepareModel(a,t),!l)continue;y.push(l),l.on("all",this._onModelEvent,this),this._byId[l.cid]=l,null!=l.id&&(this._byId[l.id]=l)}b&&b.push(c||l)}if(B){for(n=0,i=this.length;i>n;++n)E[(l=this.models[n]).cid]||_.push(l);_.length&&this.remove(_,t)}if(y.length||b&&b.length)if(f&&(g=!0),this.length+=y.length,null!=h)for(n=0,i=y.length;i>n;n++)this.models.splice(h+n,0,y[n]);else{b&&(this.models.length=0);var k=b||y;for(n=0,i=k.length;i>n;n++)this.models.push(k[n])}if(g&&this.sort({silent:!0}),!t.silent){for(n=0,i=y.length;i>n;n++)(l=y[n]).trigger("add",l,this,t);(g||b&&b.length)&&this.trigger("sort",this,t)}return o?e[0]:e},reset:function(e,t){t||(t={});for(var o=0,n=this.models.length;n>o;o++)this._removeReference(this.models[o]);return t.previousModels=this.models,this._reset(),e=this.add(e,r.extend({silent:!0},t)),t.silent||this.trigger("reset",this,t),e},push:function(e,t){return this.add(e,r.extend({at:this.length},t))},pop:function(e){var t=this.at(this.length-1);return this.remove(t,e),t},unshift:function(e,t){return this.add(e,r.extend({at:0},t))},shift:function(e){var t=this.at(0);return this.remove(t,e),t},slice:function(){return i.apply(this.models,arguments)},get:function(e){return null==e?void 0:this._byId[e.id]||this._byId[e.cid]||this._byId[e]},at:function(e){return this.models[e]},where:function(e,t){return r.isEmpty(e)?t?void 0:[]:this[t?"find":"filter"](function(t){for(var o in e)if(e[o]!==t.get(o))return!1;return!0})},findWhere:function(e){return this.where(e,!0)},sort:function(e){if(!this.comparator)throw new Error("Cannot sort a set without a comparator");return e||(e={}),r.isString(this.comparator)||1===this.comparator.length?this.models=this.sortBy(this.comparator,this):this.models.sort(r.bind(this.comparator,this)),e.silent||this.trigger("sort",this,e),this},pluck:function(e){return r.invoke(this.models,"get",e)},fetch:function(e){e=e?r.clone(e):{},void 0===e.parse&&(e.parse=!0);var t=e.success,o=this;return e.success=function(n){var i=e.reset?"reset":"set";o[i](n,e),t&&t(o,n,e),o.trigger("sync",o,n,e)},M(this,e),this.sync("read",this,e)},create:function(e,t){if(t=t?r.clone(t):{},!(e=this._prepareModel(e,t)))return!1;t.wait||this.add(e,t);var o=this,n=t.success;return t.success=function(e,t,i){i.wait&&o.add(e,i),n&&n(e,t,i)},e.save(null,t),e},parse:function(e){return e},clone:function(){return new this.constructor(this.models)},_reset:function(){this.length=0,this.models=[],this._byId={}},_prepareModel:function(e,t){if(e instanceof u)return e.collection||(e.collection=this),e;t=t?r.clone(t):{},t.collection=this;var o=new this.model(e,t);return o.validationError?(this.trigger("invalid",this,o.validationError,t),!1):o},_removeReference:function(e){this===e.collection&&delete e.collection,e.off("all",this._onModelEvent,this)},_onModelEvent:function(e,t,o,n){("add"!==e&&"remove"!==e||o===this)&&("destroy"===e&&this.remove(t,n),t&&e==="change:"+t.idAttribute&&(delete this._byId[t.previous(t.idAttribute)],null!=t.id&&(this._byId[t.id]=t)),this.trigger.apply(this,arguments))}});var m=["forEach","each","map","collect","reduce","foldl","inject","reduceRight","foldr","find","detect","filter","select","reject","every","all","some","any","include","contains","invoke","max","min","toArray","size","first","head","take","initial","rest","tail","drop","last","without","difference","indexOf","shuffle","lastIndexOf","isEmpty","chain"];r.each(m,function(e){d.prototype[e]=function(){var t=i.call(arguments);return t.unshift(this.models),r[e].apply(r,t)}});var y=["groupBy","countBy","sortBy"];r.each(y,function(e){d.prototype[e]=function(t,o){var n=r.isFunction(t)?t:function(e){return e.get(t)};return r[e](this.models,n,o)}});var _=e.View=function(e){this.cid=r.uniqueId("view"),e||(e={}),r.extend(this,r.pick(e,v)),this._ensureElement(),this.initialize.apply(this,arguments),this.delegateEvents()},E=/^(\S+)\s*(.*)$/,v=["model","collection","el","id","attributes","className","tagName","events"];r.extend(_.prototype,s,{tagName:"div",$:function(e){return this.$el.find(e)},initialize:function(){},render:function(){return this},remove:function(){return this.$el.remove(),this.stopListening(),this},setElement:function(t,o){return this.$el&&this.undelegateEvents(),this.$el=t instanceof e.$?t:e.$(t),this.el=this.$el[0],o!==!1&&this.delegateEvents(),this},delegateEvents:function(e){if(!e&&!(e=r.result(this,"events")))return this;this.undelegateEvents();for(var t in e){var o=e[t];if(r.isFunction(o)||(o=this[e[t]]),o){var n=t.match(E),i=n[1],s=n[2];o=r.bind(o,this),i+=".delegateEvents"+this.cid,""===s?this.$el.on(i,o):this.$el.on(i,s,o)}}return this},undelegateEvents:function(){return this.$el.off(".delegateEvents"+this.cid),this},_ensureElement:function(){if(this.el)this.setElement(r.result(this,"el"),!1);else{var t=r.extend({},r.result(this,"attributes"));this.id&&(t.id=r.result(this,"id")),this.className&&(t["class"]=r.result(this,"className"));var o=e.$("<"+r.result(this,"tagName")+">").attr(t);this.setElement(o,!1)}}}),e.sync=function(t,o,n){var i=B[t];r.defaults(n||(n={}),{emulateHTTP:e.emulateHTTP,emulateJSON:e.emulateJSON});var s={type:i,dataType:"json"};if(n.url||(s.url=r.result(o,"url")||N()),null!=n.data||!o||"create"!==t&&"update"!==t&&"patch"!==t||(s.contentType="application/json",s.data=JSON.stringify(n.attrs||o.toJSON(n))),n.emulateJSON&&(s.contentType="application/x-www-form-urlencoded",s.data=s.data?{model:s.data}:{}),n.emulateHTTP&&("PUT"===i||"DELETE"===i||"PATCH"===i)){s.type="POST",n.emulateJSON&&(s.data._method=i);var l=n.beforeSend;n.beforeSend=function(e){return e.setRequestHeader("X-HTTP-Method-Override",i),l?l.apply(this,arguments):void 0}}"GET"===s.type||n.emulateJSON||(s.processData=!1),"PATCH"===s.type&&C&&(s.xhr=function(){return new ActiveXObject("Microsoft.XMLHTTP")});var a=n.xhr=e.ajax(r.extend(s,n));return o.trigger("request",o,a,n),a};var C=!("undefined"==typeof window||!window.ActiveXObject||window.XMLHttpRequest&&(new XMLHttpRequest).dispatchEvent),B={create:"POST",update:"PUT",patch:"PATCH","delete":"DELETE",read:"GET"};e.ajax=function(){return e.$.ajax.apply(e.$,arguments)};var b=e.Router=function(e){e||(e={}),e.routes&&(this.routes=e.routes),this._bindRoutes(),this.initialize.apply(this,arguments)},k=/\((.*?)\)/g,A=/(\(\?)?:\w+/g,S=/\*\w+/g,T=/[\-{}\[\]+?.,\\\^$|#\s]/g;r.extend(b.prototype,s,{initialize:function(){},route:function(t,o,n){r.isRegExp(t)||(t=this._routeToRegExp(t)),r.isFunction(o)&&(n=o,o=""),n||(n=this[o]);var i=this;return e.history.route(t,function(r){var s=i._extractParameters(t,r);n&&n.apply(i,s),i.trigger.apply(i,["route:"+o].concat(s)),i.trigger("route",o,s),e.history.trigger("route",i,o,s)}),this},navigate:function(t,o){return e.history.navigate(t,o),this},_bindRoutes:function(){if(this.routes){this.routes=r.result(this,"routes");for(var e,t=r.keys(this.routes);null!=(e=t.pop());)this.route(e,this.routes[e])}},_routeToRegExp:function(e){return e=e.replace(T,"\\$&").replace(k,"(?:$1)?").replace(A,function(e,t){return t?e:"([^/]+)"}).replace(S,"(.*?)"),new RegExp("^"+e+"$")},_extractParameters:function(e,t){var o=e.exec(t).slice(1);return r.map(o,function(e){return e?decodeURIComponent(e):null})}});var R=e.History=function(){this.handlers=[],r.bindAll(this,"checkUrl"),"undefined"!=typeof window&&(this.location=window.location,this.history=window.history)},I=/^[#\/]|\s+$/g,D=/^\/+|\/+$/g,w=/msie [\w.]+/,L=/\/$/,O=/[?#].*$/;R.started=!1,r.extend(R.prototype,s,{interval:50,getHash:function(e){var t=(e||this).location.href.match(/#(.*)$/);return t?t[1]:""},getFragment:function(e,t){if(null==e)if(this._hasPushState||!this._wantsHashChange||t){e=this.location.pathname;var o=this.root.replace(L,"");e.indexOf(o)||(e=e.slice(o.length))}else e=this.getHash();return e.replace(I,"")},start:function(t){if(R.started)throw new Error("Backbone.history has already been started");R.started=!0,this.options=r.extend({root:"/"},this.options,t),this.root=this.options.root,this._wantsHashChange=this.options.hashChange!==!1,this._wantsPushState=!!this.options.pushState,this._hasPushState=!!(this.options.pushState&&this.history&&this.history.pushState);var o=this.getFragment(),n=document.documentMode,i=w.exec(navigator.userAgent.toLowerCase())&&(!n||7>=n);this.root=("/"+this.root+"/").replace(D,"/"),i&&this._wantsHashChange&&(this.iframe=e.$('<iframe src="javascript:0" tabindex="-1" />').hide().appendTo("body")[0].contentWindow,this.navigate(o)),this._hasPushState?e.$(window).on("popstate",this.checkUrl):this._wantsHashChange&&"onhashchange"in window&&!i?e.$(window).on("hashchange",this.checkUrl):this._wantsHashChange&&(this._checkUrlInterval=setInterval(this.checkUrl,this.interval)),this.fragment=o;var s=this.location,l=s.pathname.replace(/[^\/]$/,"$&/")===this.root;if(this._wantsHashChange&&this._wantsPushState){if(!this._hasPushState&&!l)return this.fragment=this.getFragment(null,!0),this.location.replace(this.root+this.location.search+"#"+this.fragment),!0;this._hasPushState&&l&&s.hash&&(this.fragment=this.getHash().replace(I,""),this.history.replaceState({},document.title,this.root+this.fragment+s.search))}return this.options.silent?void 0:this.loadUrl()},stop:function(){e.$(window).off("popstate",this.checkUrl).off("hashchange",this.checkUrl),clearInterval(this._checkUrlInterval),R.started=!1},route:function(e,t){this.handlers.unshift({route:e,callback:t})},checkUrl:function(){var e=this.getFragment();return e===this.fragment&&this.iframe&&(e=this.getFragment(this.getHash(this.iframe))),e===this.fragment?!1:(this.iframe&&this.navigate(e),this.loadUrl(),void 0)},loadUrl:function(e){return e=this.fragment=this.getFragment(e),r.any(this.handlers,function(t){return t.route.test(e)?(t.callback(e),!0):void 0})},navigate:function(e,t){if(!R.started)return!1;t&&t!==!0||(t={trigger:!!t});var o=this.root+(e=this.getFragment(e||""));if(e=e.replace(O,""),this.fragment!==e){if(this.fragment=e,""===e&&"/"!==o&&(o=o.slice(0,-1)),this._hasPushState)this.history[t.replace?"replaceState":"pushState"]({},document.title,o);else{if(!this._wantsHashChange)return this.location.assign(o);this._updateHash(this.location,e,t.replace),this.iframe&&e!==this.getFragment(this.getHash(this.iframe))&&(t.replace||this.iframe.document.open().close(),this._updateHash(this.iframe.location,e,t.replace))}return t.trigger?this.loadUrl(e):void 0}},_updateHash:function(e,t,o){if(o){var n=e.href.replace(/(javascript:|#).*$/,"");e.replace(n+"#"+t)}else e.hash="#"+t}}),e.history=new R;var F=function(e,t){var o,n=this;o=e&&r.has(e,"constructor")?e.constructor:function(){return n.apply(this,arguments)},r.extend(o,n,t);var i=function(){this.constructor=o};return i.prototype=n.prototype,o.prototype=new i,e&&r.extend(o.prototype,e),o.__super__=n.prototype,o};u.extend=d.extend=b.extend=_.extend=R.extend=F;var N=function(){throw new Error('A "url" property or function must be specified')},M=function(e,t){var o=t.error;t.error=function(n){o&&o(e,n,t),e.trigger("error",e,n,t)}}}.call(this),function(){window.SmalrubyEditor={},window.changed=!1,window.textEditor=null,window.blockMode=!0,window.successMessage=function(e,t,o){var n;null==t&&(t=""),null==o&&(o="#messages"),n=$('<div class="alert alert-success" style="display: none">').append('<h4><i class="icon-star"></i>'+e+"</h4>").append(t),$(o).append(n),n.fadeIn("slow").delay(3e3).fadeOut("slow")},window.errorMessage=function(e,t){var o;null==t&&(t="#messages"),o=$('<div class="alert alert-error" style="display: none">').append('<button type="button" class="close" data-dismiss="alert">×</button>').append('<h4><i class="icon-exclamation-sign"></i>'+Smalruby.bm("COMMON_ERROR")+"</h4>").append(e),$(t).append(o),o.fadeIn("slow")},window.clearMessages=function(e){return null==e&&(e="#messages"),$(e).empty()},window.Smalruby={Models:{},Collections:{},Views:{},Routers:{},Preferences:{},username:null,initialize:function(){var e,t,o=this;return $.ajaxSetup({headers:{"X-CSRF-Token":$('meta[name="csrf-token"]').attr("content")}}),_.extend(_.templateSettings,{escape:/{{-([\s\S]+?)}}/,evaluate:/{{([\s\S]+?)}}/,interpolate:/{{=([\s\S]+?)}}/}),this.Collections.CharacterSet=new Smalruby.CharacterSet,this.Views.MainMenuView=new Smalruby.MainMenuView,this.Views.SigninModalView=new Smalruby.SigninModalView({el:$("#signin-modal")}),this.Views.CharacterSelectorView=new Smalruby.CharacterSelectorView({model:this.Collections.CharacterSet}),this.Views.CharacterModalView=new Smalruby.CharacterModalView({el:$("#character-modal")}),this.Views.LoadModalView=new Smalruby.LoadModalView({el:$("#load-modal")}),this.Views.ResetModalView=new Smalruby.ResetModalView({el:$("#reset-modal")}),this.Views.PreferenceModalView=new Smalruby.PreferenceModalView({el:$("#preference-modal")}),Smalruby.downloading=!1,window.onbeforeunload=function(){return!Smalruby.downloading&&window.changed?Smalruby.bm("SMALRUBY_WILL_DISAPPER_YOUR_PROGRAM"):(Smalruby.downloading=!1,void 0)},Blockly.HSV_SATURATION=1,Blockly.HSV_VALUE=.8,Blockly.inject(document.getElementById("blockly-div"),{path:"/blockly/",toolbox:document.getElementById("toolbox"),trashcan:!0,comments:!1}),this.hideEmptyCategory(),this.blocklyFirst=!0,this.blocklyLoading=!1,Blockly.getMainWorkspace().addChangeListener(function(){return Smalruby.changedAfterTranslating=!0,o.blocklyFirst?(o.blocklyFirst=!1,void 0):o.blocklyLoading?(o.blocklyLoading=!1,void 0):window.changed=!0}),window.textEditor=t=ace.edit("text-editor"),t.setTheme("ace/theme/clouds"),t.setShowInvisibles(!0),t.gotoLine(0,0),t.on("change",function(){return o.translating?void 0:(window.changed=!0,Smalruby.changedAfterTranslating=!0)}),e=t.getSession(),e.setMode("ace/mode/ruby"),e.setTabSize(2),e.setUseSoftTabs(!0),this.applyPreferences(),this.addCharacterFromBeginning()},loadXml:function(e,t){var o,n,i,r,s;for(null==t&&(t=Blockly.mainWorkspace),r=Blockly.Xml.textToDom(e),t.clear(),n=[],i=0;s=r.childNodes[i];)"character"===s.nodeName.toLowerCase()&&(o=new Smalruby.Character({name:s.getAttribute("name"),costumes:s.getAttribute("costumes").split(","),x:parseInt(s.getAttribute("x"),10),y:parseInt(s.getAttribute("y"),10),angle:parseInt(s.getAttribute("angle"),10),rotationStyle:s.getAttribute("rotation_style")||"free"}),n.push(o)),i++;
|
37
|
-
return Smalruby.Collections.CharacterSet.reset(n),Blockly.Xml.domToWorkspace(t,r)},dumpXml:function(e,t){var o,n;return null==e&&(e=Blockly.mainWorkspace),null==t&&(t=Smalruby.Collections.CharacterSet),n=Blockly.Xml.workspaceToDom(e),o=n.firstChild,t.each(function(e){var t,i;return t=goog.dom.createDom("character"),t.setAttribute("x",e.get("x")),t.setAttribute("y",e.get("y")),t.setAttribute("name",e.get("name")),t.setAttribute("costumes",e.get("costumes").join(",")),t.setAttribute("angle",e.get("angle")),i=e.get("rotationStyle"),"free"!==i&&t.setAttribute("rotation_style",i),n.insertBefore(t,o)}),Blockly.Xml.domToPrettyText(n)},ignoreEnterKey:function(e){return e.find("input[type=text]").keypress(function(e){return e||(e=window.event),13===e.keyCode?!1:!0})},reset:function(){return this.blocklyLoading=!0,Blockly.mainWorkspace.clear(),this.Collections.CharacterSet.reset(),$("#filename").val(""),window.textEditor.getSession().getDocument().setValue(""),window.textEditor.moveCursorTo(0,0),this.addCharacterFromBeginning(),window.changed=!1},bm:function(e){var t;return t=Blockly.Msg[e],"string"==typeof t?t:e},addCharacterFromBeginning:function(){var e,t;return this.isEnabled("disabled_add_character_from_beginning")?void 0:(t="cat1.png",e=new Smalruby.Character({name:this.Collections.CharacterSet.uniqueName(t),costumes:[t],x:200,y:200}),this.Collections.CharacterSet.add(e),this.Views.CharacterSelectorView.prevBlock=null,this.Views.CharacterSelectorView.addBlock_(e),window.changed=!1)},applyPreferences:function(){return window.textEditor.setReadOnly(this.isEnabled("enabled_readonly_ruby_mode")),this.isEnabled("disabled_new_character")?$("#add-character-item").hide():$("#add-character-item").show()},setPreferences:function(e){return this.Preferences=e,this.applyPreferences(),this.changedAfterTranslating=!0,this.reloadToolbox()},isEnabled:function(e){return this.Preferences[e]===!0||"true"===this.Preferences[e]||"1"===this.Preferences[e]},reloadToolbox:function(){var e,t,o=this;return $("body").block({message:Smalruby.bm("COMMON_PROCESSING")}),t=function(){return $("body").unblock(),null},e=$.Deferred(),$.ajax({url:"/toolbox",type:"GET",success:function(t){return e.resolve(t)},error:e.reject}),e.promise().then(function(e){return Blockly.getMainWorkspace().updateToolbox(e),o.hideEmptyCategory()}).then(t,t).fail(function(){return errorMessage(Smalruby.bm("SMALRUBY_ERROR"))})},hideEmptyCategory:function(){var e,t,o,n,i,r;for(e=1,i=Blockly.getMainWorkspace().options.languageTree.childNodes,r=[],o=0,n=i.length;n>o;o++)t=i[o],r.push(function(t){return t.tagName?(0===t.getElementsByTagName("block").length&&null===t.getAttribute("custom")&&$("div.blocklyTreeRoot > div:nth-child(2) > div:nth-child("+e+')[aria-level="1"]').hide(),e++):void 0}(t));return r}},$(document).ready(function(){return Smalruby.initialize(),null===Smalruby.username&&Smalruby.isEnabled("enabled_must_signin")?Smalruby.Views.SigninModalView.render():void 0})}.call(this),function(){Smalruby.Character=Backbone.Model.extend({defaults:{name:null,costumes:[],costumeIndex:0,x:0,y:0,angle:0,rotationStyle:"free",visible:!0,using:!1},initialize:function(){return this.objects=[],0===this.get("costumes").length?this.set({costumes:[Smalruby.Character.PRESET_COSTUMES[0]]}):void 0},validate:function(e){var t,o;return t=[],o=e.name,(_.isUndefined(o)||_.isNull(o)||_.isString(o)&&0===o.length)&&t.push({attr:"name",message:"Name is required"}),_.isString(o)&&o.match(/^[0-9A-Z]|[!\"\#$%&\'()\-=^~\\|@`\[{;+:*\]},<.>/?]/)&&t.push({attr:"name",message:"Name is invalid"}),t.length>0?t:void 0},link:function(e){return this.objects.push(e),this.objects=_.uniq(this.objects),this.objects.length>0?this.set("using",!0):void 0},unlink:function(e){return this.objects=_.without(this.objects,e),0===this.objects.length?this.set("using",!1):void 0},namePrefix:function(){return Smalruby.Character.costumeToNamePrefix(this.get("name"))},costume:function(){return this.get("costumes")[this.get("costumeIndex")]},costumeUrl:function(e){var t;return null==e&&(e=this.get("costumeIndex")),t=this.get("costumes")[e],-1===_.indexOf(Smalruby.Character.PRESET_COSTUMES,t)?t:"/smalruby/assets/"+t},nextCostume:function(){var e;return e=this.get("costumeIndex")+1,e>=this.get("costumes").length&&(e=0),this.set({costumeIndex:e}),e},rotationStyleIconName:function(){switch(this.get("rotationStyle")){case"free":return"icon-repeat";case"left_right":return"icon-resize-horizontal";case"none":return"icon-arrow-right"}},rotateImage:function(e){var t,o;switch(t=this.get("angle"),this.get("rotationStyle")){case"free":o="rotate("+t+"deg) scaleX(1)";break;case"left_right":o=90>t||t>=270?"rotate(0deg) scaleX(1)":"rotate(0deg) scaleX(-1)";break;case"none":o="rotate(0deg) scaleX(1)"}return $(e).css({"-moz-transform":o,"-webkit-transform":o,transform:o})}},{PRESET_COSTUMES:["car1.png","car2.png","car3.png","car4.png","ball1.png","ball2.png","ball3.png","ball4.png","ball5.png","ball6.png","cat1.png","cat2.png","cat3.png","frog1.png","ryu1.png","ryu2.png","taichi1.png","taichi2.png"],costumeToNamePrefix:function(e){return e.substring(e.lastIndexOf("/")+1).replace(/\.[^.]*$/,"").replace(/[\d]*$/,"")}})}.call(this),function(){Smalruby.Scene=Backbone.Model.extend({defaults:{width:640,height:480,color:"black"}})}.call(this),Smalruby.SourceCode=Backbone.Model.extend({defaults:{filename:null,data:null},initialize:function(){if(!this.get("filename")){var e=Smalruby.Views.MainMenuView.getFilename();0==e.length&&(e=Smalruby.SourceCode.defaultFilename()),this.set("filename",e)}if(!this.get("data")){if(this.get("filename").match(/\.xml$/))var t=Smalruby.dumpXml();else if(window.blockMode)var t=Blockly.Ruby.workspaceToCode(Blockly.getMainWorkspace());else var t=window.textEditor.getSession().getDocument().getValue();this.set("data",t)}},getRbxmlFilename:function(){var e=this.get("filename");return e.match(/\.rb\.xml$/)?e:e.match(/\.rb$/)?e+".xml":e.match(/\.xml$/)?e.replace(/\.xml$/,".rb.xml"):e+".rb.xml"},run:function(){return this.post_("run")},check:function(){return this.post_("check")},save2:function(){return this.post_("")},write:function(e){null==e&&(e=!1);var t="write";return e&&(t+="?force=1"),this.delete_(t)},toBlocks:function(){return this.post_("to_blocks","html")},post_:function(e,t){return null==t&&(t="json"),dfr=$.Deferred(),$.ajax({url:"/source_codes/"+e,type:"POST",data:{source_code:{filename:this.get("filename"),data:this.get("data")}},dataType:t,success:function(e){return dfr.resolve(e)},error:dfr.reject}),dfr.promise()},delete_:function(e){return dfr=$.Deferred(),$.ajax({url:"/source_codes/"+e,type:"DELETE",dataType:"json",success:function(e){return dfr.resolve(e)},error:dfr.reject}),dfr.promise()}},{defaultFilename:function(e){return null==e&&(e=new Date),strftime("program_%y%m%d_%H%M%S.rb",e)}}),function(){Smalruby.CharacterSet=Backbone.Collection.extend({model:Smalruby.Character,uniqueName:function(e){var t,o,n;return null==e&&(e=Smalruby.Character.PRESET_COSTUMES[0]),o=e.substring(e.lastIndexOf("/")+1).replace(/\.[^.]*$/,"").replace(/[\d]*$/,""),t=0,n=new RegExp("^"+o+"(\\d+)$"),_.each(this.pluck("name"),function(e){return e.match(n)?t=_.max([t,parseInt(RegExp.$1)]):void 0}),""+o+(t+1)}})}.call(this),function(){Smalruby.CharacterModalView=Backbone.View.extend({model:new Smalruby.Character,events:{"click #character-modal-costume-selector a":"onSelectCostume","click #character_rotation_style_free":"onRotationStyleFree","click #character_rotation_style_left_right":"onRotationStyleLeftRight","click #character_rotation_style_none":"onRotationStyleNone","click #character-modal-ok-button":"onOk"},previewZoomLevel:.5,initialize:function(){var e,t,o,n=this;return this.target=null,$("#character-modal-costume-selector img").on("dragstart",function(e){return e.preventDefault()}),o=function(e){return n.model.set({x:parseInt(e.left/n.previewZoomLevel),y:parseInt(e.top/n.previewZoomLevel)})},$("#character-modal-character").draggable({containment:"#character-modal-preview",cursor:"move",drag:function(e,t){return o(t.position)}}),$("#character-modal-preview").droppable({drop:function(e,t){return o(t.draggable.position())}}),this.$el.find('input[name="character[name]"]').keypress(function(e){return e||(e=window.event),13===e.keyCode?!1:!0}),t=this,e=function(){return t.model.set({name:$(this).val()}),t.nameChanged=!0},this.$el.find('input[name="character[name]"]').change(e),this.$el.find('input[name="character[name]"]').keyup(e),this.$el.find('input[name="character[x]"]').change(function(){return t.model.set({x:$(this).val()})}),this.$el.find('input[name="character[y]"]').change(function(){return t.model.set({y:$(this).val()})}),this.$el.find('input[name="character[angle]"]').change(function(){return t.model.set({angle:$(this).val()})}),this.listenTo(this.model,"change:name",this.onChangeName),this.listenTo(this.model,"change:x",this.onChangeX),this.listenTo(this.model,"change:y",this.onChangeY),this.listenTo(this.model,"change:angle",this.onChangeAngle),this.listenTo(this.model,"change:costumes",this.onChangeCostumes),this.listenTo(this.model,"change:rotationStyle",this.onChangeRotationStyle),this.listenTo(this.model,"change",this.onChange),this.callAllOnChangeAttributes_()},render:function(){var e;return this.onChange(this.model),this.$el.modal({backdrop:"static"}),this.$el.modal("show"),e=function(){var t;return this.readImageSizeflag?(t=$("#character-modal-costume-selector .active img"),t.width()>0?($("#character-modal-character").css({width:""+t.width()/2+"px",height:""+t.height()/2+"px"}),this.readImageSizeflag=!1):setTimeout(_.bind(e,this),50)):void 0},this.readImageSizeflag?setTimeout(_.bind(e,this),1):void 0},callAllOnChangeAttributes_:function(){return this.onChangeName(this.model,this.model.get("name")),this.onChangeX(this.model,this.model.get("x")),this.onChangeY(this.model,this.model.get("y")),this.onChangeAngle(this.model,this.model.get("angle")),this.onChangeCostumes(this.model,this.model.get("costumes")),this.onChangeRotationStyle(this.model,this.model.get("rotationStyle"))},onChangeName:function(e,t){return this.$el.find('input[name="character[name]"]').val(t)},onChangeX:function(e,t){return this.$el.find('input[name="character[x]"]').val(t),$("#character_x_value").text(t),$("#character-modal-character").css("left",parseInt(t*this.previewZoomLevel))},onChangeY:function(e,t){return this.$el.find('input[name="character[y]"]').val(t),$("#character_y_value").text(t),$("#character-modal-character").css("top",parseInt(t*this.previewZoomLevel))},onChangeAngle:function(e,t){var o;return this.$el.find('input[name="character[angle]"]').val(t),$("#character_angle_value").text(""+t+"°"),o="rotate("+t+"deg)",$("#character_angle_vector").css({"-moz-transform":o,"-webkit-transform":o,transform:o}),this.model.rotateImage("#character-modal-character")},onChangeCostumes:function(e){var t,o;return t=$("<img>").attr({src:e.costumeUrl(),alt:e.costume()}),$("#character-modal-character img").replaceWith(t),this.$el.find("#character-modal-costume-selector a.thumbnail").removeClass("active"),o=this.$el.find('#character-modal-costume-selector img[alt="'+e.costume()+'"]'),o.parent().addClass("active"),o.width()>0?$("#character-modal-character").css({width:""+o.width()/2+"px",height:""+o.height()/2+"px"}):this.readImageSizeflag=!0},onChangeRotationStyle:function(e,t){return $("#character_rotation_style button.btn").removeClass("btn-primary"),$("#character_rotation_style_"+t).addClass("btn-primary"),this.onChangeAngle(this.model,this.model.get("angle"))},onChange:function(){var e;if(this.target)return this.$el.find('.control-group[for="character[name]"]').removeClass("error"),this.$el.find("#character-modal-ok-button").removeClass("disabled").removeAttr("disabled"),this.model.isValid()||(this.$el.find('.control-group[for="character[name]"]').addClass("error"),this.$el.find("#character-modal-ok-button").addClass("disabled").attr({disabled:"disabled"})),e=this.model.get("name"),this.target.get("name")!==e&&Smalruby.Collections.CharacterSet.findWhere({name:e})?(this.$el.find('.control-group[for="character[name]"]').addClass("error"),this.$el.find("#character-modal-ok-button").addClass("disabled").attr({disabled:"disabled"})):void 0},onSelectCostume:function(e){var t,o,n;return e.preventDefault(),o=$(e.target).attr("alt")||$(e.target).find("img").attr("alt"),t={costumes:[o]},this.nameChanged||(n=Smalruby.Character.costumeToNamePrefix(o),n!==this.model.namePrefix()&&(t.name=n===this.target.namePrefix()?this.target.get("name"):Smalruby.Collections.CharacterSet.uniqueName(o))),this.model.set(t)},onRotationStyleFree:function(){return this.model.set({rotationStyle:"free"})},onRotationStyleLeftRight:function(){return this.model.set({rotationStyle:"left_right"})},onRotationStyleNone:function(){return this.model.set({rotationStyle:"none"})},onOk:function(){return this.$el.modal("hide"),this.target?this.target.set(_.clone(this.model.attributes)):void 0},setCharacter:function(e){return this.target=e,this.model.set(_.clone(this.target.attributes)),this.nameChanged=!1,this}})}.call(this),function(){Smalruby.CharacterSelectorView=Backbone.View.extend({el:"#character-selector-tab",initialize:function(){var e,t,o,n;for(this.klass=Smalruby.CharacterSelectorView,n=["add","remove","reset","change"],t=0,o=n.length;o>t;t++)e=n[t],this.listenTo(this.model,e,this.onChange);return this.templateText=$("#character-selector-template").text(),$("#add-character-button").click(function(e){var t,o,n,i;return e.preventDefault(),n=Smalruby.Collections.CharacterSet,t=(i=_.last(n.models))?{name:n.uniqueName(i.costume()),costumes:_.clone(i.get("costumes"))}:{name:n.uniqueName()},o=new Smalruby.Character(t),n.add(o),Smalruby.Views.CharacterModalView.setCharacter(o).render()}),this.render()},render:function(){var e,t=this;return e=$("#character-selector-character-set"),e.children().remove(),this.model.each(function(o){var n,i,r;return n=$(_.template(t.templateText,o)),e.append(n),n.find("a.character").click(function(e){return e.preventDefault(),Smalruby.Views.CharacterModalView.setCharacter(o).render()}),n.find("a.add-block-button").click(function(e){return e.preventDefault(),t.addBlock_(o)}),r=n.find("a.remove-button"),r.click(function(e){return e.preventDefault(),t.removeCharacter_(o)}),(Smalruby.isEnabled("disabled_new_character")||o.get("using"))&&r.hide(),i=n.find("img"),o.rotateImage(i),i.on("dragstart",function(e){return e.preventDefault()})})},onChange:function(){return Smalruby.blocklyLoading||(Smalruby.changedAfterTranslating=!0,window.changed=!0),this.render()},addBlock_:function(e){var t,o;return t=Blockly.Block.obtain(Blockly.mainWorkspace,"character_new"),t.setCharacter(e),t.initSvg(),t.render(),this.moveByNewBlock_(t),t.select(),o=Blockly.Block.obtain(Blockly.mainWorkspace,"events_on_start"),o.initSvg(),o.render(),t.getInput("DO").connection.connect(o.previousConnection)},moveByNewBlock_:function(e){var t,o,n,i,r,s,l;return o=Blockly.mainWorkspace.getMetrics(),i={x:o.viewLeft+this.klass.NEW_BLOCK_MARGIN.LEFT,y:o.viewTop+this.klass.NEW_BLOCK_MARGIN.TOP},this.prevBlock&&(s=this.prevBlock.getRelativeToSurfaceXY(),t=this.prevBlock.getHeightWidth(),n=e.getHeightWidth(),s.x===this.prevXY.x&&s.y===this.prevXY.y?(r=s.x,l=s.y+t.height+this.klass.NEW_BLOCK_MARGIN.TOP,l+n.height>o.viewTop+o.viewHeight&&(r+=t.width+this.klass.NEW_BLOCK_MARGIN.LEFT,l=i.y)):(r=this.prevXY.x,l=this.prevXY.y),r>=o.viewLeft&&r+n.width<=o.viewLeft+o.viewWidth&&l>=o.viewTop&&l+n.height<=o.viewTop+o.viewHeight&&(i.x=r,i.y=l)),e.moveBy(i.x,i.y),this.prevBlock=e,this.prevXY=e.getRelativeToSurfaceXY()},removeCharacter_:function(e){return Smalruby.isEnabled("disabled_new_character")||e.get("using")?void 0:Smalruby.Collections.CharacterSet.remove(e)}},{NEW_BLOCK_MARGIN:{LEFT:20,TOP:20}})}.call(this),function(){Smalruby.LoadModalView=Backbone.View.extend({events:{"click #load-modal-ok-button":"onOk","click #load-modal-remix-button":"onRemix"},initialize:function(){var e=this;return this.$el.find("#load-modal-find-from-computer").click(function(t){return t.preventDefault(),e.onFindFromComputerClick.call(e,t)})},render:function(){var e,t,o,n,i=this;return this.type=null,this.program=null,this.setRemix(!1),this.unselect(),o=this.$el.find("#load-modal-local-programs"),o.empty(),t=this.$el.find("#load-modal-demo-programs"),t.empty(),this.$el.find(".modal-body").block({message:null}),n=function(){return i.$el.find(".modal-body").unblock(),null},this.$el.modal({backdrop:"static"}),this.$el.modal("show"),e=$.Deferred(),$.ajax({url:"/source_codes/",type:"GET",dataType:"json",success:function(t){return e.resolve(t)},error:e.reject}),e.promise().then(function(e){var n,r,s,l,a,c,g,u,h;for(g=e.localPrograms,r=function(e){var t;return t=i.programToHtml(e,i.onLocalProgramClick),o.append(t)},s=0,a=g.length;a>s;s++)n=g[s],r(n);for(u=e.demoPrograms,h=[],l=0,c=u.length;c>l;l++)n=u[l],h.push(function(e){var o;return o=i.programToHtml(e,i.onDemoProgramClick),t.append(o)}(n));return h}).then(n,n).fail(function(){return i.$el.modal("hide"),errorMessage(Smalruby.bm("VIEWS_LOAD_MODAL_VIEW_ERROR"))})},onOk:function(){switch(this.type){case"local":$.ajax({url:"/source_codes/load_local",type:"POST",data:{source_code:{filename:this.program.filename,remix:this.remix}},dataType:"json",success:function(e){return Smalruby.Views.MainMenuView.load(e.source_code)}});break;case"demo":$.ajax({url:"/source_codes/load_demo",type:"POST",data:{source_code:{filename:this.program.filename,remix:this.remix}},dataType:"json",success:function(e){return Smalruby.Views.MainMenuView.load(e.source_code)}});break;case"find-from-computer":$('input#load-file[name="source_code[file]"]').click()}return this.$el.modal("hide")},onRemix:function(){return this.setRemix(!this.remix)},setRemix:function(e){var t,o;return this.remix=e,o=$("#load-modal-remix-button"),t="btn-success",this.remix?o.addClass(t):o.removeClass(t)},onLocalProgramClick:function(e,t){return this.select(e.currentTarget,"local",t)},onDemoProgramClick:function(e,t){return this.select(e.currentTarget,"demo",t)},onFindFromComputerClick:function(e){return this.select(e.currentTarget,"find-from-computer")},select:function(e,t,o){return null==o&&(o=null),this.unselect(),$(e).addClass("active"),this.type=t,this.program=o},unselect:function(){return this.$el.find("a.thumbnail").removeClass("active")},programToHtml:function(e,t){var o,n,i=this;return n=e.imageUrl?'<img src="'+e.imageUrl+'">':'<h1 class="icon"><i class="icon-file" /></h1>',o='<li>\n <a class="thumbnail">\n '+n+"\n <blockquote>\n <p>\n "+e.title+"\n </p>\n <small>"+e.filename+"</small>\n </blockquote>\n </div>\n</li>",o=$(o),o.find("a.thumbnail").click(function(o){return o.preventDefault(),t.call(i,o,e)}),o}})}.call(this),function(){Smalruby.MainMenuView=Backbone.View.extend({el:"#main-menu",events:{"click #block-mode-button":"onBlockMode","click #ruby-mode-button":"onRubyMode","click #run-button":"onRun","click #download-button":"onDownload","click #load-local-button":"onLoadLocal","click #load-button":"onLoad","click #save-button":"onSave","click #check-button":"onCheck","click #reset-button":"onReset","click #preference-button":"onPreference","click #signin-button":"onSignin","click #signout-button":"onSignout","click #username-button":"onUsername"},initialize:function(){var e=this;return $("#filename").keypress(function(e){return e||(e=window.event),13===e.keyCode?($("#save-button").click(),!1):!0}),$("#file-form").fileupload({dataType:"json",done:function(t,o){return e.load(o.result.source_code)}}),$(".dropdown-toggle").dropdown()},onBlockMode:function(e){var t;return e.preventDefault(),window.blockMode?void 0:Smalruby.changedAfterTranslating?(this.blockUI({title:'<i class="icon-filter"></i>\n'+Smalruby.bm("VIEWS_MAIN_MENU_VIEW_BLOCK_MODE_BLOCKUI_TITLE"),message:Smalruby.bm("VIEWS_MAIN_MENU_VIEW_BLOCK_MODE_BLOCKUI_MESSAGE")}),t=new Smalruby.SourceCode,t.toBlocks().then(function(e){return window.blockMode=!0,$('#tabs a[href="#block-tab"]').tab("show"),e.length>0?(Smalruby.blocklyLoading=!0,Smalruby.translating=!0,Smalruby.loadXml(e),Smalruby.translating=!1,Smalruby.changedAfterTranslating=!1):void 0}).then(this.unblockUI,this.unblockUI).fail(function(){return window.errorMessage(Smalruby.bm("VIEWS_MAIN_MENU_VIEW_BLOCK_MODE_ERROR"))})):(window.blockMode=!0,$('#tabs a[href="#block-tab"]').tab("show"),void 0)},onRubyMode:function(e){var t;return e.preventDefault(),window.blockMode&&(window.blockMode=!1,$('#tabs a[href="#ruby-tab"]').tab("show"),Smalruby.changedAfterTranslating)?(t=Blockly.Ruby.workspaceToCode(Blockly.getMainWorkspace()),Smalruby.translating=!0,window.textEditor.getSession().getDocument().setValue(t),Smalruby.translating=!1,Smalruby.changedAfterTranslating=!1,window.textEditor.moveCursorTo(0,0),window.textEditor.focus()):void 0},onRun:function(e){var t,o,n,i=this;return e.preventDefault(),o=this.getSourceCode(),n=new Smalruby.SourceCode({filename:o.getRbxmlFilename()}),clearMessages(),this.blockUI({title:'<i class="icon-play"></i>\n'+Smalruby.bm("VIEWS_MAIN_MENU_VIEW_RUN_BLOCKUI_TITLE"),message:Smalruby.bm("VIEWS_MAIN_MENU_VIEW_RUN_BLOCKUI_MESSAGE"),notice:Smalruby.bm("VIEWS_MAIN_MENU_VIEW_RUN_BLOCKUI_NOTICE")}),t=Smalruby.bm("VIEWS_MAIN_MENU_VIEW_RUN_ERROR_CANT_RUN"),o.save2().then(function(){return o.write()}).then(function(e){return i.confirmOverwrite_.call(i,e,o,function(){return t=Smalruby.bm("VIEWS_MAIN_MENU_VIEW_RUN_ERROR_CANCEL_TO_RUN")})}).then(function(){return Smalruby.savedFilename=o.get("filename"),window.changed=!1,o.check()}).then(function(e){var t,o,n,i;if(e.length>0){for(o=function(e){var t;return t=""+e.row+Smalruby.bm("VIEWS_MAIN_MENU_VIEW_COMMON_LINES"),e.column>0&&(t+=""+Smalruby.bm("VIEWS_MAIN_MENU_VIEW_COMMON_COMMA")+e.column+Smalruby.bm("VIEWS_MAIN_MENU_VIEW_COMMON_LETTERS")),window.errorMessage(t+(": "+_.escape(e.message)))},n=0,i=e.length;i>n;n++)t=e[n],o(t);return $.Deferred().reject().promise()}}).then(function(){return n.save2()}).then(function(){return n.write(!0)}).then(function(){return o.run()}).then(function(e){var t,o,n,i;if(e.length>0){for(o=function(e){var t;return t=""+e.row+Smalruby.bm("VIEWS_MAIN_MENU_VIEW_COMMON_LINES"),e.column>0&&(t+=""+Smalruby.bm("VIEWS_MAIN_MENU_VIEW_COMMON_COMMA")+e.column+Smalruby.bm("VIEWS_MAIN_MENU_VIEW_COMMON_LETTERS")),errorMessage(t+(": "+_.escape(e.message)))},n=0,i=e.length;i>n;n++)t=e[n],o(t);return $.Deferred().reject().promise()}}).then(this.unblockUI,this.unblockUI).fail(function(){return errorMessage(t)})},onDownload:function(e){var t;return e.preventDefault(),t=this.getSourceCode(),clearMessages(),this.blockUI({title:Smalruby.bm("VIEWS_MAIN_MENU_VIEW_DOWNLOAD_BLOCKUI_TITLE"),message:Smalruby.bm("VIEWS_MAIN_MENU_VIEW_DOWNLOAD_BLOCKUI_MESSAGE")}),t.save2().then(function(){return window.changed=!1,window.successMessage(goog.getMsg(Smalruby.bm("VIEWS_MAIN_MENU_VIEW_DOWNLOAD_SUCCEEDED"),{filename:t.get("filename")})),Smalruby.downloading=!0,$("#download-link").click()}).then(this.unblockUI,this.unblockUI).fail(function(){return window.errorMessage(Smalruby.bm("VIEWS_MAIN_MENU_VIEW_DOWNLOAD_ERROR"))})},onLoadLocal:function(e){return e.preventDefault(),!window.changed||confirm(Smalruby.bm("VIEWS_MAIN_MENU_VIEW_LOAD_CONFIRM"))?Smalruby.Views.LoadModalView.render():void 0},onLoad:function(e){return e.preventDefault(),!window.changed||confirm(Smalruby.bm("VIEWS_MAIN_MENU_VIEW_LOAD_CONFIRM"))?$('input#load-file[name="source_code[file]"]').click():void 0},onSave:function(e){var t,o,n,i=this;return e.preventDefault(),o=$.trim($("#filename").val()),o.length<=0?(window.errorMessage(Smalruby.bm("VIEWS_MAIN_MENU_VIEW_SAVE_ERROR_NO_NAME")),$("#filename").focus(),void 0):(n=this.getSourceCode(),window.blockMode&&(n=new Smalruby.SourceCode({filename:n.getRbxmlFilename()})),clearMessages(),this.blockUI({title:Smalruby.bm("VIEWS_MAIN_MENU_VIEW_SAVE_BLOCKUI_TITLE"),message:Smalruby.bm("VIEWS_MAIN_MENU_VIEW_SAVE_BLOCKUI_MESSAGE"),notice:goog.getMsg(Smalruby.bm("VIEWS_MAIN_MENU_VIEW_SAVE_BLOCKUI_NOTICE"),{filename:n.get("filename")})}),t=Smalruby.bm("VIEWS_MAIN_MENU_VIEW_SAVE_ERROR_MESSAGE"),n.save2().then(function(){return n.write()}).then(function(e){return i.confirmOverwrite_.call(i,e,n,function(){return t=Smalruby.bm("VIEWS_MAIN_MENU_VIEW_SAVE_CANCELED")})}).then(this.unblockUI,this.unblockUI).done(function(){return Smalruby.savedFilename=n.get("filename"),window.changed=!1,window.successMessage(Smalruby.bm("VIEWS_MAIN_MENU_VIEW_SAVE_SUCCEEDED"))}).fail(function(){return window.errorMessage(t)}))},onCheck:function(e){var t;return e.preventDefault(),clearMessages(),t=this.getSourceCode(),this.blockUI({title:Smalruby.bm("VIEWS_MAIN_MENU_VIEW_CHECK_BLOCKUI_TITLE"),message:Smalruby.bm("VIEWS_MAIN_MENU_VIEW_CHECK_BLOCKUI_MESSAGE"),notice:Smalruby.bm("VIEWS_MAIN_MENU_VIEW_CHECK_BLOCKUI_NOTICE")}),t.check().then(function(e){var t,o,n,i;if(0===e.length)return window.successMessage(Smalruby.bm("VIEWS_MAIN_MENU_VIEW_CHECK_SUCCEEDED"),Smalruby.bm("VIEWS_MAIN_MENU_VIEW_CHECK_SUCCEEDED_NOTICE"));for(i=[],o=0,n=e.length;n>o;o++)t=e[o],i.push(function(e){var t;return t=""+e.row+Smalruby.bm("VIEWS_MAIN_MENU_VIEW_COMMON_LINES"),e.column>0&&(t+=""+Smalruby.bm("VIEWS_MAIN_MENU_VIEW_COMMON_COMMA")+e.column+Smalruby.bm("VIEWS_MAIN_MENU_VIEW_COMMON_LETTERS")),window.errorMessage(t+(": "+e.message))}(t));return i}).then(this.unblockUI,this.unblockUI).fail(function(){return errorMessage(Smalruby.bm("VIEWS_MAIN_MENU_VIEW_CHECK_ERROR"))})},onReset:function(e){return e.preventDefault(),window.changed?Smalruby.Views.ResetModalView.render():Smalruby.reset(),!0},onPreference:function(e){return e.preventDefault(),Smalruby.Views.PreferenceModalView.render()},onSignin:function(e){return e.preventDefault(),Smalruby.Views.SigninModalView.render()},onSignout:function(e){return e.preventDefault(),$.ajax({url:"/signout",type:"DELETE"}).then(function(e){return Smalruby.setPreferences(e),Smalruby.username=null,$("#signin-button").show(),$(".signed-in-menu").hide(),$("#username-label").text(""),$("#username-button").hide(),successMessage(Smalruby.bm("VIEWS_MAIN_MENU_VIEW_SIGNOUT_SUCCEEDED")),Smalruby.isEnabled("enabled_must_signin")?Smalruby.Views.SigninModalView.render():void 0},function(){return errorMessage(Smalruby.bm("VIEWS_MAIN_MENU_VIEW_SIGNOUT_ERROR"))})},onUsername:function(e){return e.preventDefault()},getFilename:function(){return $.trim($("#filename").val())},getSourceCode:function(){var e;return e=new Smalruby.SourceCode,$("#filename").val(e.get("filename")),e},blockUI:function(e){var t,o;return t="",e.title&&(t+="<h3>\n "+e.title+"\n</h3>"),(e.message||e.notice)&&(o="",e.message&&(o+="<p>\n "+e.message+"\n</p>"),e.notice&&(o+="<small>\n "+e.notice+"\n</small>"),t+="<blockquote>\n "+o+"\n</blockquote>"),$.blockUI({message:t,css:{border:"none","text-align":"left","padding-left":"2em"}})},unblockUI:function(){return $.unblockUI()},confirmOverwrite_:function(e,t,o){return null==o&&(o=$.noop),e.source_code.error?t.get("filename")===Smalruby.savedFilename||confirm(goog.getMsg(Smalruby.bm("VIEWS_MAIN_MENU_VIEW_COMMON_CONFIRM_OVERWRITE"),{filename:t.get("filename")}))?t.write(!0):(o.call(),$.Deferred().reject().promise()):void 0},load:function(e){var t;return e.error?window.errorMessage(goog.getMsg(Smalruby.bm("VIEWS_MAIN_MENU_VIEW_LOAD_ERROR"),{filename:e.filename,error:e.error})):(clearMessages(),t=e.filename,t.match(/\.xml$/)?(window.blockMode||(window.blockMode=!0,$('#tabs a[href="#block-tab"]').tab("show")),t=t.replace(/(\.rb)?\.xml$/,".rb"),Smalruby.blocklyLoading=!0,Smalruby.loadXml(e.data),e.data=Blockly.Ruby.workspaceToCode(Blockly.getMainWorkspace())):(Smalruby.Collections.CharacterSet.reset(),Blockly.mainWorkspace.clear(),window.blockMode&&(window.blockMode=!1,$('#tabs a[href="#ruby-tab"]').tab("show"),window.textEditor.focus())),$("#filename").val(t),window.textEditor.getSession().getDocument().setValue(e.data),window.textEditor.moveCursorTo(0,0),window.changed=!1,Smalruby.changedAfterTranslating=!0,window.successMessage(Smalruby.bm("VIEWS_MAIN_MENU_VIEW_LOAD_SUCCEEDED")))}})}.call(this),function(){Smalruby.PreferenceModalView=Backbone.View.extend({events:{"click #preference-modal-ok-button":"onOk","change #user_preferences_toolbox_name":"renderToolboxPreferences"},render:function(){var e,t,o=this;return this.$el.find(".modal-body").block({message:null}),t=function(){return o.$el.find(".modal-body").unblock(),null},this.$el.modal({backdrop:"static"}),this.$el.modal("show"),e=$.Deferred(),$.ajax({url:"preferences",type:"GET",cache:!1,success:function(t){return e.resolve(t)},error:e.reject}),e.promise().then(function(e){return $("#preference-modal-content").replaceWith(e),o.renderToolboxPreferences()}).then(t,t).fail(function(){return o.$el.modal("hide"),errorMessage(Smalruby.bm("VIEWS_PREFERENCE_MODAL_VIEW_ERROR"))})},onOk:function(){var e,t,o,n=this;return this.$el.block({message:Smalruby.bm("COMMON_PROCESSING")}),o=function(){return n.$el.unblock(),null},t=this.$el.find("form"),e=$.Deferred(),$.ajax({url:t.attr("action"),data:t.serialize(),type:"POST",success:function(t){return e.resolve(t)},error:e.reject}),e.promise().then(function(e){return Smalruby.setPreferences(e)}).then(o,o).done(function(){return n.$el.modal("hide")}).fail(function(){return errorMessage(Smalruby.bm("VIEWS_PREFERENCE_MODAL_VIEW_ERROR"))})},renderToolboxPreferences:function(){var e;return this.$el.find(".toolbox_preferences").hide(),e=$("#user_preferences_toolbox_name").val()||"default",this.$el.find(".toolbox_preferences."+e).show()}})}.call(this),function(){Smalruby.ResetModalView=Backbone.View.extend({events:{"click #reset-modal-ok-button":"onOk"},render:function(){return this.$el.modal({backdrop:"static"}),this.$el.modal("show")},onOk:function(){return Smalruby.reset(),this.$el.modal("hide")}})}.call(this),function(){Smalruby.SigninModalView=Backbone.View.extend({events:{"click #signin-modal-ok-button":"onOk"},initialize:function(){var e=this;return Smalruby.ignoreEnterKey(this.$el),this.$el.on("shown",function(){return e.$el.find("#signin-modal-username").focus()}),this.$el.on("hidden",function(){return $(".modal-backdrop").remove()})},render:function(){var e;return this.$el.find("#signin-modal-username").val($("#username-label").text()),e={backdrop:"static"},Smalruby.isEnabled("enabled_must_signin")?(this.$el.find("#signin-modal-cancel-button").hide(),e.keyboard=!1):(this.$el.find("#signin-modal-cancel-button").show(),e.keyboard=!0),this.$el.modal(e),this.$el.modal("show")},onOk:function(){var e,t=this;return e=this.$el.find("input[name=username]").val(),$.trim(e).length>0?$.post("/sessions/",{username:e}).then(function(t){return Smalruby.setPreferences(t),Smalruby.username=e,$("#signin-button").hide(),$(".signed-in-menu").show(),$("#username-label").text(e),$("#username-button").show(),successMessage(Smalruby.bm("VIEWS_SIGNIN_MODAL_VIEW_SIGNED_IN")),(new $.Deferred).resolve().promise()},function(){return errorMessage(Smalruby.bm("VIEWS_SIGNIN_MODAL_VIEW_ERROR")),(new $.Deferred).resolve().promise()}).done(function(){return null===Smalruby.username&&Smalruby.isEnabled("enabled_must_signin")?void 0:t.$el.modal("hide")}):void 0}})}.call(this),function(){Blockly.Ruby=new Blockly.Generator("Ruby"),Blockly.Ruby.addReservedWords("BEGIN class ensure nil self whenEND def false not super whilealias defined? for or then yieldand do if redo true __LINE__begin else in rescue undef __FILE__break elsif module retry unless __ENCODING__case end next return until".split(/\s+/)),Blockly.Ruby.ORDER_ATOMIC=0,Blockly.Ruby.ORDER_COLLECTION=1,Blockly.Ruby.ORDER_STRING_CONVERSION=1,Blockly.Ruby.ORDER_MEMBER=2,Blockly.Ruby.ORDER_INDEX=3,Blockly.Ruby.ORDER_FUNCTION_CALL=4,Blockly.Ruby.ORDER_UNARY_SIGN=5,Blockly.Ruby.ORDER_EXPONENTIATION=6,Blockly.Ruby.ORDER_UNARY_MINUS_SIGN=7,Blockly.Ruby.ORDER_MULTIPLICATIVE=8,Blockly.Ruby.ORDER_ADDITIVE=9,Blockly.Ruby.ORDER_BITWISE_SHIFT=10,Blockly.Ruby.ORDER_BITWISE_AND=11,Blockly.Ruby.ORDER_BITWISE_XOR=12,Blockly.Ruby.ORDER_BITWISE_OR=12,Blockly.Ruby.ORDER_RELATIONAL=13,Blockly.Ruby.ORDER_EQUALS=14,Blockly.Ruby.ORDER_LOGICAL_AND=15,Blockly.Ruby.ORDER_LOGICAL_OR=16,Blockly.Ruby.ORDER_RANGE=17,Blockly.Ruby.ORDER_CONDITIONAL=18,Blockly.Ruby.ORDER_ASSIGNMENT=19,Blockly.Ruby.ORDER_NOT=20,Blockly.Ruby.ORDER_AND_OR=21,Blockly.Ruby.ORDER_NONE=99,Blockly.Ruby.INFINITE_LOOP_TRAP=null,Blockly.Ruby.init=function(){return this.definitions_=Object.create(null),Blockly.Variables?(this.variableDB_?this.variableDB_.reset():this.variableDB_=new Blockly.Names(Blockly.Ruby.RESERVED_WORDS_),this.definitions_.require__smalruby='require "smalruby"',this.definitions_.receiver_stack=["main"],this.definitions_.character_stack=[]):void 0
|
37
|
+
return Smalruby.Collections.CharacterSet.reset(n),Blockly.Xml.domToWorkspace(t,r)},dumpXml:function(e,t){var o,n;return null==e&&(e=Blockly.mainWorkspace),null==t&&(t=Smalruby.Collections.CharacterSet),n=Blockly.Xml.workspaceToDom(e),o=n.firstChild,t.each(function(e){var t,i;return t=goog.dom.createDom("character"),t.setAttribute("x",e.get("x")),t.setAttribute("y",e.get("y")),t.setAttribute("name",e.get("name")),t.setAttribute("costumes",e.get("costumes").join(",")),t.setAttribute("angle",e.get("angle")),i=e.get("rotationStyle"),"free"!==i&&t.setAttribute("rotation_style",i),n.insertBefore(t,o)}),Blockly.Xml.domToPrettyText(n)},ignoreEnterKey:function(e){return e.find("input[type=text]").keypress(function(e){return e||(e=window.event),13===e.keyCode?!1:!0})},removeBackdropOnHidden:function(e){return e.on("hidden",function(){return $(".modal-backdrop").remove()})},reset:function(){return this.blocklyLoading=!0,Blockly.mainWorkspace.clear(),this.Collections.CharacterSet.reset(),$("#filename").val(""),window.textEditor.getSession().getDocument().setValue(""),window.textEditor.moveCursorTo(0,0),this.addCharacterFromBeginning(),window.changed=!1},bm:function(e){var t;return t=Blockly.Msg[e],"string"==typeof t?t:e},addCharacterFromBeginning:function(){var e,t;return this.isEnabled("disabled_add_character_from_beginning")?void 0:(t="cat1.png",e=new Smalruby.Character({name:this.Collections.CharacterSet.uniqueName(t),costumes:[t],x:200,y:200}),this.Collections.CharacterSet.add(e),this.Views.CharacterSelectorView.prevBlock=null,this.Views.CharacterSelectorView.addBlock_(e),window.changed=!1)},applyPreferences:function(){return window.textEditor.setReadOnly(this.isEnabled("enabled_readonly_ruby_mode")),this.isEnabled("disabled_new_character")?$("#add-character-item").hide():$("#add-character-item").show()},setPreferences:function(e){return this.Preferences=e,this.applyPreferences(),this.changedAfterTranslating=!0,this.reloadToolbox()},isEnabled:function(e){return this.Preferences[e]===!0||"true"===this.Preferences[e]||"1"===this.Preferences[e]},reloadToolbox:function(){var e,t,o=this;return $("body").block({message:Smalruby.bm("COMMON_PROCESSING")}),t=function(){return $("body").unblock(),null},e=$.Deferred(),$.ajax({url:"/toolbox",type:"GET",success:function(t){return e.resolve(t)},error:e.reject}),e.promise().then(function(e){return Blockly.getMainWorkspace().updateToolbox(e),o.hideEmptyCategory()}).then(t,t).fail(function(){return errorMessage(Smalruby.bm("SMALRUBY_ERROR"))})},hideEmptyCategory:function(){var e,t,o,n,i,r;for(e=1,i=Blockly.getMainWorkspace().options.languageTree.childNodes,r=[],o=0,n=i.length;n>o;o++)t=i[o],r.push(function(t){return t.tagName?(0===t.getElementsByTagName("block").length&&null===t.getAttribute("custom")&&$("div.blocklyTreeRoot > div:nth-child(2) > div:nth-child("+e+')[aria-level="1"]').hide(),e++):void 0}(t));return r}},$(document).ready(function(){return Smalruby.initialize(),null===Smalruby.username&&Smalruby.isEnabled("enabled_must_signin")?Smalruby.Views.SigninModalView.render():void 0})}.call(this),function(){Smalruby.Character=Backbone.Model.extend({defaults:{name:null,costumes:[],costumeIndex:0,x:0,y:0,angle:0,rotationStyle:"free",visible:!0,using:!1},initialize:function(){return this.objects=[],0===this.get("costumes").length?this.set({costumes:[Smalruby.Character.PRESET_COSTUMES[0]]}):void 0},validate:function(e){var t,o;return t=[],o=e.name,(_.isUndefined(o)||_.isNull(o)||_.isString(o)&&0===o.length)&&t.push({attr:"name",message:"Name is required"}),_.isString(o)&&o.match(/^[0-9A-Z]|[!\"\#$%&\'()\-=^~\\|@`\[{;+:*\]},<.>/?]/)&&t.push({attr:"name",message:"Name is invalid"}),t.length>0?t:void 0},link:function(e){return this.objects.push(e),this.objects=_.uniq(this.objects),this.objects.length>0?this.set("using",!0):void 0},unlink:function(e){return this.objects=_.without(this.objects,e),0===this.objects.length?this.set("using",!1):void 0},namePrefix:function(){return Smalruby.Character.costumeToNamePrefix(this.get("name"))},costume:function(){return this.get("costumes")[this.get("costumeIndex")]},costumeUrl:function(e){var t;return null==e&&(e=this.get("costumeIndex")),t=this.get("costumes")[e],-1===_.indexOf(Smalruby.Character.PRESET_COSTUMES,t)?t:"/smalruby/assets/"+t},nextCostume:function(){var e;return e=this.get("costumeIndex")+1,e>=this.get("costumes").length&&(e=0),this.set({costumeIndex:e}),e},rotationStyleIconName:function(){switch(this.get("rotationStyle")){case"free":return"icon-repeat";case"left_right":return"icon-resize-horizontal";case"none":return"icon-arrow-right"}},rotateImage:function(e){var t,o;switch(t=this.get("angle"),this.get("rotationStyle")){case"free":o="rotate("+t+"deg) scaleX(1)";break;case"left_right":o=90>t||t>=270?"rotate(0deg) scaleX(1)":"rotate(0deg) scaleX(-1)";break;case"none":o="rotate(0deg) scaleX(1)"}return $(e).css({"-moz-transform":o,"-webkit-transform":o,transform:o})}},{PRESET_COSTUMES:["car1.png","car2.png","car3.png","car4.png","ball1.png","ball2.png","ball3.png","ball4.png","ball5.png","ball6.png","cat1.png","cat2.png","cat3.png","frog1.png","ryu1.png","ryu2.png","taichi1.png","taichi2.png"],costumeToNamePrefix:function(e){return e.substring(e.lastIndexOf("/")+1).replace(/\.[^.]*$/,"").replace(/[\d]*$/,"")}})}.call(this),function(){Smalruby.Scene=Backbone.Model.extend({defaults:{width:640,height:480,color:"black"}})}.call(this),Smalruby.SourceCode=Backbone.Model.extend({defaults:{filename:null,data:null},initialize:function(){if(!this.get("filename")){var e=Smalruby.Views.MainMenuView.getFilename();0==e.length&&(e=Smalruby.SourceCode.defaultFilename()),this.set("filename",e)}if(!this.get("data")){if(this.get("filename").match(/\.xml$/))var t=Smalruby.dumpXml();else if(window.blockMode)var t=Blockly.Ruby.workspaceToCode(Blockly.getMainWorkspace());else var t=window.textEditor.getSession().getDocument().getValue();this.set("data",t)}},getRbxmlFilename:function(){var e=this.get("filename");return e.match(/\.rb\.xml$/)?e:e.match(/\.rb$/)?e+".xml":e.match(/\.xml$/)?e.replace(/\.xml$/,".rb.xml"):e+".rb.xml"},run:function(){return this.post_("run")},check:function(){return this.post_("check")},save2:function(){return this.post_("")},write:function(e){null==e&&(e=!1);var t="write";return e&&(t+="?force=1"),this.delete_(t)},toBlocks:function(){return this.post_("to_blocks","html")},post_:function(e,t){return null==t&&(t="json"),dfr=$.Deferred(),$.ajax({url:"/source_codes/"+e,type:"POST",data:{source_code:{filename:this.get("filename"),data:this.get("data")}},dataType:t,success:function(e){return dfr.resolve(e)},error:dfr.reject}),dfr.promise()},delete_:function(e){return dfr=$.Deferred(),$.ajax({url:"/source_codes/"+e,type:"DELETE",dataType:"json",success:function(e){return dfr.resolve(e)},error:dfr.reject}),dfr.promise()}},{defaultFilename:function(e){return null==e&&(e=new Date),strftime("program_%y%m%d_%H%M%S.rb",e)}}),function(){Smalruby.CharacterSet=Backbone.Collection.extend({model:Smalruby.Character,uniqueName:function(e){var t,o,n;return null==e&&(e=Smalruby.Character.PRESET_COSTUMES[0]),o=e.substring(e.lastIndexOf("/")+1).replace(/\.[^.]*$/,"").replace(/[\d]*$/,""),t=0,n=new RegExp("^"+o+"(\\d+)$"),_.each(this.pluck("name"),function(e){return e.match(n)?t=_.max([t,parseInt(RegExp.$1)]):void 0}),""+o+(t+1)}})}.call(this),function(){Smalruby.CharacterModalView=Backbone.View.extend({model:new Smalruby.Character,events:{"click #character-modal-costume-selector a":"onSelectCostume","click #character_rotation_style_free":"onRotationStyleFree","click #character_rotation_style_left_right":"onRotationStyleLeftRight","click #character_rotation_style_none":"onRotationStyleNone","click #character-modal-ok-button":"onOk"},previewZoomLevel:.5,initialize:function(){var e,t,o,n=this;return Smalruby.removeBackdropOnHidden(this.$el),this.target=null,$("#character-modal-costume-selector img").on("dragstart",function(e){return e.preventDefault()}),o=function(e){return n.model.set({x:parseInt(e.left/n.previewZoomLevel),y:parseInt(e.top/n.previewZoomLevel)})},$("#character-modal-character").draggable({containment:"#character-modal-preview",cursor:"move",drag:function(e,t){return o(t.position)}}),$("#character-modal-preview").droppable({drop:function(e,t){return o(t.draggable.position())}}),this.$el.find('input[name="character[name]"]').keypress(function(e){return e||(e=window.event),13===e.keyCode?!1:!0}),t=this,e=function(){return t.model.set({name:$(this).val()}),t.nameChanged=!0},this.$el.find('input[name="character[name]"]').change(e),this.$el.find('input[name="character[name]"]').keyup(e),this.$el.find('input[name="character[x]"]').change(function(){return t.model.set({x:$(this).val()})}),this.$el.find('input[name="character[y]"]').change(function(){return t.model.set({y:$(this).val()})}),this.$el.find('input[name="character[angle]"]').change(function(){return t.model.set({angle:$(this).val()})}),this.listenTo(this.model,"change:name",this.onChangeName),this.listenTo(this.model,"change:x",this.onChangeX),this.listenTo(this.model,"change:y",this.onChangeY),this.listenTo(this.model,"change:angle",this.onChangeAngle),this.listenTo(this.model,"change:costumes",this.onChangeCostumes),this.listenTo(this.model,"change:rotationStyle",this.onChangeRotationStyle),this.listenTo(this.model,"change",this.onChange),this.callAllOnChangeAttributes_()},render:function(){var e;return this.onChange(this.model),this.$el.modal({backdrop:"static"}),this.$el.modal("show"),e=function(){var t;return this.readImageSizeflag?(t=$("#character-modal-costume-selector .active img"),t.width()>0?($("#character-modal-character").css({width:""+t.width()/2+"px",height:""+t.height()/2+"px"}),this.readImageSizeflag=!1):setTimeout(_.bind(e,this),50)):void 0},this.readImageSizeflag?setTimeout(_.bind(e,this),1):void 0},callAllOnChangeAttributes_:function(){return this.onChangeName(this.model,this.model.get("name")),this.onChangeX(this.model,this.model.get("x")),this.onChangeY(this.model,this.model.get("y")),this.onChangeAngle(this.model,this.model.get("angle")),this.onChangeCostumes(this.model,this.model.get("costumes")),this.onChangeRotationStyle(this.model,this.model.get("rotationStyle"))},onChangeName:function(e,t){return this.$el.find('input[name="character[name]"]').val(t)},onChangeX:function(e,t){return this.$el.find('input[name="character[x]"]').val(t),$("#character_x_value").text(t),$("#character-modal-character").css("left",parseInt(t*this.previewZoomLevel))},onChangeY:function(e,t){return this.$el.find('input[name="character[y]"]').val(t),$("#character_y_value").text(t),$("#character-modal-character").css("top",parseInt(t*this.previewZoomLevel))},onChangeAngle:function(e,t){var o;return this.$el.find('input[name="character[angle]"]').val(t),$("#character_angle_value").text(""+t+"°"),o="rotate("+t+"deg)",$("#character_angle_vector").css({"-moz-transform":o,"-webkit-transform":o,transform:o}),this.model.rotateImage("#character-modal-character")},onChangeCostumes:function(e){var t,o;return t=$("<img>").attr({src:e.costumeUrl(),alt:e.costume()}),$("#character-modal-character img").replaceWith(t),this.$el.find("#character-modal-costume-selector a.thumbnail").removeClass("active"),o=this.$el.find('#character-modal-costume-selector img[alt="'+e.costume()+'"]'),o.parent().addClass("active"),o.width()>0?$("#character-modal-character").css({width:""+o.width()/2+"px",height:""+o.height()/2+"px"}):this.readImageSizeflag=!0},onChangeRotationStyle:function(e,t){return $("#character_rotation_style button.btn").removeClass("btn-primary"),$("#character_rotation_style_"+t).addClass("btn-primary"),this.onChangeAngle(this.model,this.model.get("angle"))},onChange:function(){var e;if(this.target)return this.$el.find('.control-group[for="character[name]"]').removeClass("error"),this.$el.find("#character-modal-ok-button").removeClass("disabled").removeAttr("disabled"),this.model.isValid()||(this.$el.find('.control-group[for="character[name]"]').addClass("error"),this.$el.find("#character-modal-ok-button").addClass("disabled").attr({disabled:"disabled"})),e=this.model.get("name"),this.target.get("name")!==e&&Smalruby.Collections.CharacterSet.findWhere({name:e})?(this.$el.find('.control-group[for="character[name]"]').addClass("error"),this.$el.find("#character-modal-ok-button").addClass("disabled").attr({disabled:"disabled"})):void 0},onSelectCostume:function(e){var t,o,n;return e.preventDefault(),o=$(e.target).attr("alt")||$(e.target).find("img").attr("alt"),t={costumes:[o]},this.nameChanged||(n=Smalruby.Character.costumeToNamePrefix(o),n!==this.model.namePrefix()&&(t.name=n===this.target.namePrefix()?this.target.get("name"):Smalruby.Collections.CharacterSet.uniqueName(o))),this.model.set(t)},onRotationStyleFree:function(){return this.model.set({rotationStyle:"free"})},onRotationStyleLeftRight:function(){return this.model.set({rotationStyle:"left_right"})},onRotationStyleNone:function(){return this.model.set({rotationStyle:"none"})},onOk:function(){return this.$el.modal("hide"),this.target?this.target.set(_.clone(this.model.attributes)):void 0},setCharacter:function(e){return this.target=e,this.model.set(_.clone(this.target.attributes)),this.nameChanged=!1,this}})}.call(this),function(){Smalruby.CharacterSelectorView=Backbone.View.extend({el:"#character-selector-tab",initialize:function(){var e,t,o,n;for(this.klass=Smalruby.CharacterSelectorView,n=["add","remove","reset","change"],t=0,o=n.length;o>t;t++)e=n[t],this.listenTo(this.model,e,this.onChange);return this.templateText=$("#character-selector-template").text(),$("#add-character-button").click(function(e){var t,o,n,i;return e.preventDefault(),n=Smalruby.Collections.CharacterSet,t=(i=_.last(n.models))?{name:n.uniqueName(i.costume()),costumes:_.clone(i.get("costumes"))}:{name:n.uniqueName()},o=new Smalruby.Character(t),n.add(o),Smalruby.Views.CharacterModalView.setCharacter(o).render()}),this.render()},render:function(){var e,t=this;return e=$("#character-selector-character-set"),e.children().remove(),this.model.each(function(o){var n,i,r;return n=$(_.template(t.templateText,o)),e.append(n),n.find("a.character").click(function(e){return e.preventDefault(),Smalruby.Views.CharacterModalView.setCharacter(o).render()}),n.find("a.add-block-button").click(function(e){return e.preventDefault(),t.addBlock_(o)}),r=n.find("a.remove-button"),r.click(function(e){return e.preventDefault(),t.removeCharacter_(o)}),(Smalruby.isEnabled("disabled_new_character")||o.get("using"))&&r.hide(),i=n.find("img"),o.rotateImage(i),i.on("dragstart",function(e){return e.preventDefault()})})},onChange:function(){return Smalruby.blocklyLoading||(Smalruby.changedAfterTranslating=!0,window.changed=!0),this.render()},addBlock_:function(e){var t,o;return t=Blockly.Block.obtain(Blockly.mainWorkspace,"character_new"),t.setCharacter(e),t.initSvg(),t.render(),this.moveByNewBlock_(t),t.select(),o=Blockly.Block.obtain(Blockly.mainWorkspace,"events_on_start"),o.initSvg(),o.render(),t.getInput("DO").connection.connect(o.previousConnection)},moveByNewBlock_:function(e){var t,o,n,i,r,s,l;return o=Blockly.mainWorkspace.getMetrics(),i={x:o.viewLeft+this.klass.NEW_BLOCK_MARGIN.LEFT,y:o.viewTop+this.klass.NEW_BLOCK_MARGIN.TOP},this.prevBlock&&(s=this.prevBlock.getRelativeToSurfaceXY(),t=this.prevBlock.getHeightWidth(),n=e.getHeightWidth(),s.x===this.prevXY.x&&s.y===this.prevXY.y?(r=s.x,l=s.y+t.height+this.klass.NEW_BLOCK_MARGIN.TOP,l+n.height>o.viewTop+o.viewHeight&&(r+=t.width+this.klass.NEW_BLOCK_MARGIN.LEFT,l=i.y)):(r=this.prevXY.x,l=this.prevXY.y),r>=o.viewLeft&&r+n.width<=o.viewLeft+o.viewWidth&&l>=o.viewTop&&l+n.height<=o.viewTop+o.viewHeight&&(i.x=r,i.y=l)),e.moveBy(i.x,i.y),this.prevBlock=e,this.prevXY=e.getRelativeToSurfaceXY()},removeCharacter_:function(e){return Smalruby.isEnabled("disabled_new_character")||e.get("using")?void 0:Smalruby.Collections.CharacterSet.remove(e)}},{NEW_BLOCK_MARGIN:{LEFT:20,TOP:20}})}.call(this),function(){Smalruby.LoadModalView=Backbone.View.extend({events:{"click #load-modal-ok-button":"onOk","click #load-modal-remix-button":"onRemix"},initialize:function(){var e=this;return Smalruby.removeBackdropOnHidden(this.$el),this.$el.find("#load-modal-find-from-computer").click(function(t){return t.preventDefault(),e.onFindFromComputerClick.call(e,t)})},render:function(){var e,t,o,n,i=this;return this.type=null,this.program=null,this.setRemix(!1),this.unselect(),o=this.$el.find("#load-modal-local-programs"),o.empty(),t=this.$el.find("#load-modal-demo-programs"),t.empty(),this.$el.find(".modal-body").block({message:null}),n=function(){return i.$el.find(".modal-body").unblock(),null},this.$el.modal({backdrop:"static"}),this.$el.modal("show"),e=$.Deferred(),$.ajax({url:"/source_codes/",type:"GET",dataType:"json",success:function(t){return e.resolve(t)},error:e.reject}),e.promise().then(function(e){var n,r,s,l,a,c,g,u,h;for(g=e.localPrograms,r=function(e){var t;return t=i.programToHtml(e,i.onLocalProgramClick),o.append(t)},s=0,a=g.length;a>s;s++)n=g[s],r(n);for(u=e.demoPrograms,h=[],l=0,c=u.length;c>l;l++)n=u[l],h.push(function(e){var o;return o=i.programToHtml(e,i.onDemoProgramClick),t.append(o)}(n));return h}).then(n,n).fail(function(){return i.$el.modal("hide"),errorMessage(Smalruby.bm("VIEWS_LOAD_MODAL_VIEW_ERROR"))})},onOk:function(){switch(this.type){case"local":$.ajax({url:"/source_codes/load_local",type:"POST",data:{source_code:{filename:this.program.filename,remix:this.remix}},dataType:"json",success:function(e){return Smalruby.Views.MainMenuView.load(e.source_code)}});break;case"demo":$.ajax({url:"/source_codes/load_demo",type:"POST",data:{source_code:{filename:this.program.filename,remix:this.remix}},dataType:"json",success:function(e){return Smalruby.Views.MainMenuView.load(e.source_code)}});break;case"find-from-computer":$('input#load-file[name="source_code[file]"]').click()}return this.$el.modal("hide")},onRemix:function(){return this.setRemix(!this.remix)},setRemix:function(e){var t,o;return this.remix=e,o=$("#load-modal-remix-button"),t="btn-success",this.remix?o.addClass(t):o.removeClass(t)},onLocalProgramClick:function(e,t){return this.select(e.currentTarget,"local",t)},onDemoProgramClick:function(e,t){return this.select(e.currentTarget,"demo",t)},onFindFromComputerClick:function(e){return this.select(e.currentTarget,"find-from-computer")},select:function(e,t,o){return null==o&&(o=null),this.unselect(),$(e).addClass("active"),this.type=t,this.program=o},unselect:function(){return this.$el.find("a.thumbnail").removeClass("active")},programToHtml:function(e,t){var o,n,i=this;return n=e.imageUrl?'<img src="'+e.imageUrl+'">':'<h1 class="icon"><i class="icon-file" /></h1>',o='<li>\n <a class="thumbnail">\n '+n+"\n <blockquote>\n <p>\n "+e.title+"\n </p>\n <small>"+e.filename+"</small>\n </blockquote>\n </div>\n</li>",o=$(o),o.find("a.thumbnail").click(function(o){return o.preventDefault(),t.call(i,o,e)}),o}})}.call(this),function(){Smalruby.MainMenuView=Backbone.View.extend({el:"#main-menu",events:{"click #block-mode-button":"onBlockMode","click #ruby-mode-button":"onRubyMode","click #run-button":"onRun","click #download-button":"onDownload","click #load-local-button":"onLoadLocal","click #load-button":"onLoad","click #save-button":"onSave","click #check-button":"onCheck","click #reset-button":"onReset","click #preference-button":"onPreference","click #signin-button":"onSignin","click #signout-button":"onSignout","click #username-button":"onUsername"},initialize:function(){var e=this;return $("#filename").keypress(function(e){return e||(e=window.event),13===e.keyCode?($("#save-button").click(),!1):!0}),$("#file-form").fileupload({dataType:"json",done:function(t,o){return e.load(o.result.source_code)}}),$(".dropdown-toggle").dropdown()},onBlockMode:function(e){var t;return e.preventDefault(),window.blockMode?void 0:Smalruby.changedAfterTranslating?(this.blockUI({title:'<i class="icon-filter"></i>\n'+Smalruby.bm("VIEWS_MAIN_MENU_VIEW_BLOCK_MODE_BLOCKUI_TITLE"),message:Smalruby.bm("VIEWS_MAIN_MENU_VIEW_BLOCK_MODE_BLOCKUI_MESSAGE")}),t=new Smalruby.SourceCode,t.toBlocks().then(function(e){return window.blockMode=!0,$('#tabs a[href="#block-tab"]').tab("show"),e.length>0?(Smalruby.blocklyLoading=!0,Smalruby.translating=!0,Smalruby.loadXml(e),Smalruby.translating=!1,Smalruby.changedAfterTranslating=!1):void 0}).then(this.unblockUI,this.unblockUI).fail(function(){return window.errorMessage(Smalruby.bm("VIEWS_MAIN_MENU_VIEW_BLOCK_MODE_ERROR"))})):(window.blockMode=!0,$('#tabs a[href="#block-tab"]').tab("show"),void 0)},onRubyMode:function(e){var t;return e.preventDefault(),window.blockMode&&(window.blockMode=!1,$('#tabs a[href="#ruby-tab"]').tab("show"),Smalruby.changedAfterTranslating)?(t=Blockly.Ruby.workspaceToCode(Blockly.getMainWorkspace()),Smalruby.translating=!0,window.textEditor.getSession().getDocument().setValue(t),Smalruby.translating=!1,Smalruby.changedAfterTranslating=!1,window.textEditor.moveCursorTo(0,0),window.textEditor.focus()):void 0},onRun:function(e){var t,o,n,i=this;return e.preventDefault(),o=this.getSourceCode(),n=new Smalruby.SourceCode({filename:o.getRbxmlFilename()}),clearMessages(),this.blockUI({title:'<i class="icon-play"></i>\n'+Smalruby.bm("VIEWS_MAIN_MENU_VIEW_RUN_BLOCKUI_TITLE"),message:Smalruby.bm("VIEWS_MAIN_MENU_VIEW_RUN_BLOCKUI_MESSAGE"),notice:Smalruby.bm("VIEWS_MAIN_MENU_VIEW_RUN_BLOCKUI_NOTICE")}),t=Smalruby.bm("VIEWS_MAIN_MENU_VIEW_RUN_ERROR_CANT_RUN"),o.save2().then(function(){return o.write()}).then(function(e){return i.confirmOverwrite_.call(i,e,o,function(){return t=Smalruby.bm("VIEWS_MAIN_MENU_VIEW_RUN_ERROR_CANCEL_TO_RUN")})}).then(function(){return Smalruby.savedFilename=o.get("filename"),window.changed=!1,o.check()}).then(function(e){var t,o,n,i;if(e.length>0){for(o=function(e){var t;return t=""+e.row+Smalruby.bm("VIEWS_MAIN_MENU_VIEW_COMMON_LINES"),e.column>0&&(t+=""+Smalruby.bm("VIEWS_MAIN_MENU_VIEW_COMMON_COMMA")+e.column+Smalruby.bm("VIEWS_MAIN_MENU_VIEW_COMMON_LETTERS")),window.errorMessage(t+(": "+_.escape(e.message)))},n=0,i=e.length;i>n;n++)t=e[n],o(t);return $.Deferred().reject().promise()}}).then(function(){return n.save2()}).then(function(){return n.write(!0)}).then(function(){return o.run()}).then(function(e){var t,o,n,i;if(e.length>0){for(o=function(e){var t;return t=""+e.row+Smalruby.bm("VIEWS_MAIN_MENU_VIEW_COMMON_LINES"),e.column>0&&(t+=""+Smalruby.bm("VIEWS_MAIN_MENU_VIEW_COMMON_COMMA")+e.column+Smalruby.bm("VIEWS_MAIN_MENU_VIEW_COMMON_LETTERS")),errorMessage(t+(": "+_.escape(e.message)))},n=0,i=e.length;i>n;n++)t=e[n],o(t);return $.Deferred().reject().promise()}}).then(this.unblockUI,this.unblockUI).fail(function(){return errorMessage(t)})},onDownload:function(e){var t;return e.preventDefault(),t=this.getSourceCode(),clearMessages(),this.blockUI({title:Smalruby.bm("VIEWS_MAIN_MENU_VIEW_DOWNLOAD_BLOCKUI_TITLE"),message:Smalruby.bm("VIEWS_MAIN_MENU_VIEW_DOWNLOAD_BLOCKUI_MESSAGE")}),t.save2().then(function(){return window.changed=!1,window.successMessage(goog.getMsg(Smalruby.bm("VIEWS_MAIN_MENU_VIEW_DOWNLOAD_SUCCEEDED"),{filename:t.get("filename")})),Smalruby.downloading=!0,$("#download-link").click()}).then(this.unblockUI,this.unblockUI).fail(function(){return window.errorMessage(Smalruby.bm("VIEWS_MAIN_MENU_VIEW_DOWNLOAD_ERROR"))})},onLoadLocal:function(e){return e.preventDefault(),!window.changed||confirm(Smalruby.bm("VIEWS_MAIN_MENU_VIEW_LOAD_CONFIRM"))?Smalruby.Views.LoadModalView.render():void 0},onLoad:function(e){return e.preventDefault(),!window.changed||confirm(Smalruby.bm("VIEWS_MAIN_MENU_VIEW_LOAD_CONFIRM"))?$('input#load-file[name="source_code[file]"]').click():void 0},onSave:function(e){var t,o,n,i=this;return e.preventDefault(),o=$.trim($("#filename").val()),o.length<=0?(window.errorMessage(Smalruby.bm("VIEWS_MAIN_MENU_VIEW_SAVE_ERROR_NO_NAME")),$("#filename").focus(),void 0):(n=this.getSourceCode(),window.blockMode&&(n=new Smalruby.SourceCode({filename:n.getRbxmlFilename()})),clearMessages(),this.blockUI({title:Smalruby.bm("VIEWS_MAIN_MENU_VIEW_SAVE_BLOCKUI_TITLE"),message:Smalruby.bm("VIEWS_MAIN_MENU_VIEW_SAVE_BLOCKUI_MESSAGE"),notice:goog.getMsg(Smalruby.bm("VIEWS_MAIN_MENU_VIEW_SAVE_BLOCKUI_NOTICE"),{filename:n.get("filename")})}),t=Smalruby.bm("VIEWS_MAIN_MENU_VIEW_SAVE_ERROR_MESSAGE"),n.save2().then(function(){return n.write()}).then(function(e){return i.confirmOverwrite_.call(i,e,n,function(){return t=Smalruby.bm("VIEWS_MAIN_MENU_VIEW_SAVE_CANCELED")})}).then(this.unblockUI,this.unblockUI).done(function(){return Smalruby.savedFilename=n.get("filename"),window.changed=!1,window.successMessage(Smalruby.bm("VIEWS_MAIN_MENU_VIEW_SAVE_SUCCEEDED"))}).fail(function(){return window.errorMessage(t)}))},onCheck:function(e){var t;return e.preventDefault(),clearMessages(),t=this.getSourceCode(),this.blockUI({title:Smalruby.bm("VIEWS_MAIN_MENU_VIEW_CHECK_BLOCKUI_TITLE"),message:Smalruby.bm("VIEWS_MAIN_MENU_VIEW_CHECK_BLOCKUI_MESSAGE"),notice:Smalruby.bm("VIEWS_MAIN_MENU_VIEW_CHECK_BLOCKUI_NOTICE")}),t.check().then(function(e){var t,o,n,i;if(0===e.length)return window.successMessage(Smalruby.bm("VIEWS_MAIN_MENU_VIEW_CHECK_SUCCEEDED"),Smalruby.bm("VIEWS_MAIN_MENU_VIEW_CHECK_SUCCEEDED_NOTICE"));for(i=[],o=0,n=e.length;n>o;o++)t=e[o],i.push(function(e){var t;return t=""+e.row+Smalruby.bm("VIEWS_MAIN_MENU_VIEW_COMMON_LINES"),e.column>0&&(t+=""+Smalruby.bm("VIEWS_MAIN_MENU_VIEW_COMMON_COMMA")+e.column+Smalruby.bm("VIEWS_MAIN_MENU_VIEW_COMMON_LETTERS")),window.errorMessage(t+(": "+e.message))}(t));return i}).then(this.unblockUI,this.unblockUI).fail(function(){return errorMessage(Smalruby.bm("VIEWS_MAIN_MENU_VIEW_CHECK_ERROR"))})},onReset:function(e){return e.preventDefault(),window.changed?Smalruby.Views.ResetModalView.render():Smalruby.reset(),!0},onPreference:function(e){return e.preventDefault(),Smalruby.Views.PreferenceModalView.render()},onSignin:function(e){return e.preventDefault(),Smalruby.Views.SigninModalView.render()},onSignout:function(e){return e.preventDefault(),$.ajax({url:"/signout",type:"DELETE"}).then(function(e){return Smalruby.setPreferences(e),Smalruby.username=null,$("#signin-button").show(),$(".signed-in-menu").hide(),$("#username-label").text(""),$("#username-button").hide(),successMessage(Smalruby.bm("VIEWS_MAIN_MENU_VIEW_SIGNOUT_SUCCEEDED")),Smalruby.isEnabled("enabled_must_signin")?Smalruby.Views.SigninModalView.render():void 0},function(){return errorMessage(Smalruby.bm("VIEWS_MAIN_MENU_VIEW_SIGNOUT_ERROR"))})},onUsername:function(e){return e.preventDefault()},getFilename:function(){return $.trim($("#filename").val())},getSourceCode:function(){var e;return e=new Smalruby.SourceCode,$("#filename").val(e.get("filename")),e},blockUI:function(e){var t,o;return t="",e.title&&(t+="<h3>\n "+e.title+"\n</h3>"),(e.message||e.notice)&&(o="",e.message&&(o+="<p>\n "+e.message+"\n</p>"),e.notice&&(o+="<small>\n "+e.notice+"\n</small>"),t+="<blockquote>\n "+o+"\n</blockquote>"),$.blockUI({message:t,css:{border:"none","text-align":"left","padding-left":"2em"}})},unblockUI:function(){return $.unblockUI()},confirmOverwrite_:function(e,t,o){return null==o&&(o=$.noop),e.source_code.error?t.get("filename")===Smalruby.savedFilename||confirm(goog.getMsg(Smalruby.bm("VIEWS_MAIN_MENU_VIEW_COMMON_CONFIRM_OVERWRITE"),{filename:t.get("filename")}))?t.write(!0):(o.call(),$.Deferred().reject().promise()):void 0},load:function(e){var t;return e.error?window.errorMessage(goog.getMsg(Smalruby.bm("VIEWS_MAIN_MENU_VIEW_LOAD_ERROR"),{filename:e.filename,error:e.error})):(clearMessages(),t=e.filename,t.match(/\.xml$/)?(window.blockMode||(window.blockMode=!0,$('#tabs a[href="#block-tab"]').tab("show")),t=t.replace(/(\.rb)?\.xml$/,".rb"),Smalruby.blocklyLoading=!0,Smalruby.loadXml(e.data),e.data=Blockly.Ruby.workspaceToCode(Blockly.getMainWorkspace())):(Smalruby.Collections.CharacterSet.reset(),Blockly.mainWorkspace.clear(),window.blockMode&&(window.blockMode=!1,$('#tabs a[href="#ruby-tab"]').tab("show"),window.textEditor.focus())),$("#filename").val(t),window.textEditor.getSession().getDocument().setValue(e.data),window.textEditor.moveCursorTo(0,0),window.changed=!1,Smalruby.changedAfterTranslating=!0,window.successMessage(Smalruby.bm("VIEWS_MAIN_MENU_VIEW_LOAD_SUCCEEDED")))}})}.call(this),function(){Smalruby.PreferenceModalView=Backbone.View.extend({events:{"click #preference-modal-ok-button":"onOk","change #user_preferences_toolbox_name":"renderToolboxPreferences"},initialize:function(){return Smalruby.removeBackdropOnHidden(this.$el)},render:function(){var e,t,o=this;return this.$el.find(".modal-body").block({message:null}),t=function(){return o.$el.find(".modal-body").unblock(),null},this.$el.modal({backdrop:"static"}),this.$el.modal("show"),e=$.Deferred(),$.ajax({url:"preferences",type:"GET",cache:!1,success:function(t){return e.resolve(t)},error:e.reject}),e.promise().then(function(e){return $("#preference-modal-content").replaceWith(e),o.renderToolboxPreferences()}).then(t,t).fail(function(){return o.$el.modal("hide"),errorMessage(Smalruby.bm("VIEWS_PREFERENCE_MODAL_VIEW_ERROR"))})},onOk:function(){var e,t,o,n=this;return this.$el.block({message:Smalruby.bm("COMMON_PROCESSING")}),o=function(){return n.$el.unblock(),null},t=this.$el.find("form"),e=$.Deferred(),$.ajax({url:t.attr("action"),data:t.serialize(),type:"POST",success:function(t){return e.resolve(t)},error:e.reject}),e.promise().then(function(e){return Smalruby.setPreferences(e)}).then(o,o).done(function(){return n.$el.modal("hide")}).fail(function(){return errorMessage(Smalruby.bm("VIEWS_PREFERENCE_MODAL_VIEW_ERROR"))})},renderToolboxPreferences:function(){var e;return this.$el.find(".toolbox_preferences").hide(),e=$("#user_preferences_toolbox_name").val()||"default",this.$el.find(".toolbox_preferences."+e).show()}})}.call(this),function(){Smalruby.ResetModalView=Backbone.View.extend({events:{"click #reset-modal-ok-button":"onOk"},initialize:function(){return Smalruby.removeBackdropOnHidden(this.$el)},render:function(){return this.$el.modal({backdrop:"static"}),this.$el.modal("show")},onOk:function(){return Smalruby.reset(),this.$el.modal("hide")}})}.call(this),function(){Smalruby.SigninModalView=Backbone.View.extend({events:{"click #signin-modal-ok-button":"onOk"},initialize:function(){var e=this;return Smalruby.ignoreEnterKey(this.$el),Smalruby.removeBackdropOnHidden(this.$el),this.$el.on("shown",function(){return e.$el.find("#signin-modal-username").focus()})},render:function(){var e;return this.$el.find("#signin-modal-username").val($("#username-label").text()),e={backdrop:"static"},Smalruby.isEnabled("enabled_must_signin")?(this.$el.find("#signin-modal-cancel-button").hide(),e.keyboard=!1):(this.$el.find("#signin-modal-cancel-button").show(),e.keyboard=!0),this.$el.modal(e),this.$el.modal("show")},onOk:function(){var e,t=this;return e=this.$el.find("input[name=username]").val(),$.trim(e).length>0?$.post("/sessions/",{username:e}).then(function(t){return Smalruby.setPreferences(t),Smalruby.username=e,$("#signin-button").hide(),$(".signed-in-menu").show(),$("#username-label").text(e),$("#username-button").show(),successMessage(Smalruby.bm("VIEWS_SIGNIN_MODAL_VIEW_SIGNED_IN")),(new $.Deferred).resolve().promise()},function(){return errorMessage(Smalruby.bm("VIEWS_SIGNIN_MODAL_VIEW_ERROR")),(new $.Deferred).resolve().promise()}).done(function(){return null===Smalruby.username&&Smalruby.isEnabled("enabled_must_signin")?void 0:t.$el.modal("hide")}):void 0}})}.call(this),function(){Blockly.Ruby=new Blockly.Generator("Ruby"),Blockly.Ruby.addReservedWords("BEGIN class ensure nil self whenEND def false not super whilealias defined? for or then yieldand do if redo true __LINE__begin else in rescue undef __FILE__break elsif module retry unless __ENCODING__case end next return until".split(/\s+/)),Blockly.Ruby.ORDER_ATOMIC=0,Blockly.Ruby.ORDER_COLLECTION=1,Blockly.Ruby.ORDER_STRING_CONVERSION=1,Blockly.Ruby.ORDER_MEMBER=2,Blockly.Ruby.ORDER_INDEX=3,Blockly.Ruby.ORDER_FUNCTION_CALL=4,Blockly.Ruby.ORDER_UNARY_SIGN=5,Blockly.Ruby.ORDER_EXPONENTIATION=6,Blockly.Ruby.ORDER_UNARY_MINUS_SIGN=7,Blockly.Ruby.ORDER_MULTIPLICATIVE=8,Blockly.Ruby.ORDER_ADDITIVE=9,Blockly.Ruby.ORDER_BITWISE_SHIFT=10,Blockly.Ruby.ORDER_BITWISE_AND=11,Blockly.Ruby.ORDER_BITWISE_XOR=12,Blockly.Ruby.ORDER_BITWISE_OR=12,Blockly.Ruby.ORDER_RELATIONAL=13,Blockly.Ruby.ORDER_EQUALS=14,Blockly.Ruby.ORDER_LOGICAL_AND=15,Blockly.Ruby.ORDER_LOGICAL_OR=16,Blockly.Ruby.ORDER_RANGE=17,Blockly.Ruby.ORDER_CONDITIONAL=18,Blockly.Ruby.ORDER_ASSIGNMENT=19,Blockly.Ruby.ORDER_NOT=20,Blockly.Ruby.ORDER_AND_OR=21,Blockly.Ruby.ORDER_NONE=99,Blockly.Ruby.INFINITE_LOOP_TRAP=null,Blockly.Ruby.init=function(){return this.definitions_=Object.create(null),Blockly.Variables?(this.variableDB_?this.variableDB_.reset():this.variableDB_=new Blockly.Names(Blockly.Ruby.RESERVED_WORDS_),this.definitions_.require__smalruby='require "smalruby"',this.definitions_.receiver_stack=["main"],this.definitions_.character_stack=[]):void 0
|
38
38
|
},Blockly.Ruby.defineCharacter=function(e){var t,o,n;if(o=e.get("name"),t="character_"+o,!Blockly.Ruby.definitions_[t]){switch(e.get("rotationStyle")){case"left_right":n=", rotation_style: :left_right";break;case"none":n=", rotation_style: :none";break;default:n=""}return Blockly.Ruby.definitions_[t]=""+o+" = Character.new(costume: "+Blockly.Ruby.quote_(e.costume())+", x: "+e.get("x")+", y: "+e.get("y")+", angle: "+e.get("angle")+n+")"}},Blockly.Ruby.characterStack=function(){return this.definitions_.character_stack},Blockly.Ruby.character=function(){return _.last(this.characterStack())},Blockly.Ruby.receiverStack=function(){return this.definitions_.receiver_stack},Blockly.Ruby.receiver=function(){return _.last(this.receiverStack())},Blockly.Ruby.receiverName=function(e){var t,o;return null==e&&(e={}),t={object:Blockly.Ruby.character(),dropSelf:!0},_.extend(t,e),o=this.receiver(),o===t.object?t.dropSelf?"":"self.":""+t.object.get("name")+"."},Blockly.Ruby.cs=Blockly.Ruby.characterStack,Blockly.Ruby.cs_=Blockly.Ruby.characterStack,Blockly.Ruby.c=Blockly.Ruby.character,Blockly.Ruby.c_=Blockly.Ruby.character,Blockly.Ruby.rs=Blockly.Ruby.receiverStack,Blockly.Ruby.rs_=Blockly.Ruby.receiverStack,Blockly.Ruby.r=Blockly.Ruby.receiver,Blockly.Ruby.r_=Blockly.Ruby.receiver,Blockly.Ruby.rn=Blockly.Ruby.receiverName,Blockly.Ruby.rn_=Blockly.Ruby.receiverName,Blockly.Ruby.characterMethodCall_=function(e,t,o){var n;return null==o&&(o={}),n=this.characterMethodCallInput_(e,t,o),n[0]?""+n[0]+"\n":""},Blockly.Ruby.characterMethodCallInput_=function(e,t,o){var n;return null==o&&(o={}),n=this.c_()?t&&t.length>0?""+this.rn_(o)+e+"("+t+")":""+this.rn_(o)+e:null,[n,this.ORDER_FUNCTION_CALL]},Blockly.Ruby.characterSetVariable_=function(e,t,o){return null==o&&(o="="),this.c_()?""+this.rn_({dropSelf:!1})+e+" "+o+" "+t+"\n":""},Blockly.Ruby.characterEvent_=function(e,t,o,n){var i,r;if(null==n&&(n=null),r=this.c_()){this.rs_().push(r);try{i=Blockly.Ruby.statementToCode(e,t)||"\n"}finally{this.rs_().pop()}return n=n?", "+n:"","\n"+this.rn_()+"on(:"+o+n+") do\n"+i+"end\n"}return""},Blockly.Ruby.finish=function(e){var t,o,n,i,r,s;r=[],i=[],o=[],s=function(e){var t;return t=Blockly.Ruby.definitions_[e],_.isString(t)?e.match(/^require__/)?r.push(t):e.match(/^prepare__/)?i.push(t):o.push(t):void 0};for(n in Blockly.Ruby.definitions_)s(n);return 0===i.length&&0===o.length&&0===e.length?"":(t=r.join("\n")+"\n\n",i.length>0&&(t+=i.join("\n")+"\n\n"),o.length>0&&(t+=o.join("\n").replace(/\n\n+/g,"\n\n").replace(/\n*$/,"\n")),t+e)},Blockly.Ruby.scrubNakedValue=function(e){return e+"\n"},Blockly.Ruby.escapeChars_={'"':'\\"'},Blockly.Ruby.quote_=function(e){var t,o,n,i,r,s;for(o=String(e),n=['"'],i=function(e){var t;return t=o.charAt(e),n[e+1]=Blockly.Ruby.escapeChars_[t]||t},t=r=0,s=o.length;s>=0?s>r:r>s;t=s>=0?++r:--r)i(t);return n.push('"'),n.join("")},Blockly.Ruby.scrub_=function(e,t){var o,n,i,r,s,l,a,c,g,u=this;if(null===t)return"";if(n="",!e.outputConnection||!e.outputConnection.targetConnection)for(o=e.getCommentText(),o&&(n+=this.prefixLines(o,"# ")+"\n"),g=e.inputList,l=function(e){var t;return e.type===Blockly.INPUT_VALUE&&(t=e.connection.targetBlock(),t&&(o=u.allNestedComments(t)))?n+=u.prefixLines(o,"# "):void 0},a=0,c=g.length;c>a;a++)i=g[a],l(i);return r=e.nextConnection&&e.nextConnection.targetBlock(),s=this.blockToCode(r),n+t+s},Blockly.Ruby.blockToCode_=Blockly.Ruby.blockToCode,Blockly.Ruby.blockToCode=function(e){return e&&!e.disabled&&e.type.match(/^hardware_/)&&(this.definitions_.prepare__init_hardware="init_hardware"),this.blockToCode_(e)}}.call(this),function(){"use strict";goog.provide("Smalruby.FieldCharacter"),goog.require("Blockly.FieldDropdown"),Smalruby.FieldCharacter=function(e,t){var o,n,i=this;return o=t?function(e){var o,n;return n=Smalruby.FieldCharacter.dropdownChange.call(i,e),n?o=n:n=i.getValue(),t.call(i,o),n}:Smalruby.FieldCharacter.dropdownChange,Smalruby.FieldCharacter.superClass_.constructor.call(this,Smalruby.FieldCharacter.dropdownCreate,o),n=Smalruby.Collections.CharacterSet,n.on("add",this.onCharacterSetAdd_,this),n.on("remove",this.onCharacterSetRemove_,this),n.on("reset",this.onCharacterSetReset_,this),this.character=Smalruby.FieldCharacter.NullCharacter,e||(e=Smalruby.Collections.CharacterSet.first()),this.setCharacter(e)},goog.inherits(Smalruby.FieldCharacter,Blockly.FieldDropdown),Smalruby.FieldCharacter.prototype.setCharacter=function(e){return e!==this.character?(this.character.unlink(this),this.character.off("change:name",this.onCharacterChangeName_,this),this.character=e?e:Smalruby.FieldCharacter.NullCharacter,this.character.link(this),this.character.on("change:name",this.onCharacterChangeName_,this),this.setValue(this.character.get("name"))):void 0},Smalruby.FieldCharacter.prototype.onCharacterSetAdd_=function(e){return this.character===Smalruby.FieldCharacter.NullCharacter?this.setCharacter(e):void 0},Smalruby.FieldCharacter.prototype.onCharacterSetRemove_=function(e){return e===this.character?this.setCharacter():void 0},Smalruby.FieldCharacter.prototype.onCharacterSetReset_=function(e){return this.character===Smalruby.FieldCharacter.NullCharacter?this.setCharacter(e.first()):this.setCharacter(e.findWhere({name:this.getValue()}))},Smalruby.FieldCharacter.prototype.onCharacterChangeName_=function(e,t){return this.setValue(t)},Smalruby.FieldCharacter.prototype.clone=function(){return new Smalruby.FieldCharacter(this.character,this.changeHandler_)},Smalruby.FieldCharacter.prototype.dispose=function(){var e;return e=Smalruby.Collections.CharacterSet,e.off("add",this.onCharacterSetAdd_,this),e.off("remove",this.onCharacterSetRemove_,this),e.off("reset",this.onCharacterSetReset_,this),this.setCharacter(),Blockly.FieldDropdown.prototype.dispose.call(this)},Smalruby.FieldCharacter.prototype.setText=function(e){var t;return this.character||(this.character=Smalruby.FieldCharacter.NullCharacter,t=Smalruby.Collections.CharacterSet,this.setCharacter(t.findWhere({name:e}))),Blockly.FieldDropdown.prototype.setText.call(this,e)},Smalruby.FieldCharacter.dropdownCreate=function(){var e;return e=Smalruby.Collections.CharacterSet,e.length>0?Smalruby.Collections.CharacterSet.map(function(e){var t;return t=e.get("name"),[t,t]}):[[Smalruby.FieldCharacter.NullCharacter.get("name"),""]]},Smalruby.FieldCharacter.dropdownChange=function(e){var t;return t=Smalruby.Collections.CharacterSet.findWhere({name:e}),t?(this.setCharacter(t),e):null},Smalruby.FieldCharacter.NullCharacter={get:function(){return Smalruby.bm("BLOCKS_FIELD_CHARACTER_NO_CHARACTER")},on:function(){return $.noop},off:function(){return $.noop},link:function(){return $.noop},unlink:function(){return $.noop}},Blockly.Block.prototype.getCharacterFieldValue=function(e){var t,o;return null==e&&(e="CHAR"),o=this.getFieldValue(e),Blockly.Ruby.c()&&(t=Smalruby.Collections.CharacterSet.findWhere({name:o}),Blockly.Ruby.defineCharacter(t)),o}}.call(this),function(){Blockly.Ruby.math_number=function(){var e,t;return e=parseFloat(this.getFieldValue("NUM")),t=0>e?Blockly.Ruby.ORDER_UNARY_MINUS_SIGN:Blockly.Ruby.ORDER_ATOMIC,[e,t]},Blockly.Ruby.text=function(){var e;return e=Blockly.Ruby.quote_(this.getFieldValue("TEXT")),[e,Blockly.Ruby.ORDER_ATOMIC]},Blockly.Ruby.variables_get=function(e){var t;return t=Blockly.Ruby.variableDB_.getName(e.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE),[t,Blockly.Ruby.ORDER_ATOMIC]},Blockly.Ruby.variables_set=function(e){var t,o;return o=Blockly.Ruby.valueToCode(e,"VALUE",Blockly.Ruby.ORDER_NONE)||"0",t=Blockly.Ruby.variableDB_.getName(e.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE),t+" = "+o+"\n"}}.call(this),function(){Blockly.Blocks.character_new={init:function(){var e,t,o,n;return this.setHelpUrl(""),this.setColour(198),n=2*Blockly.BlockSvg.FIELD_HEIGHT,e=new Blockly.FieldImage(null,n,n),t=new Blockly.FieldLabel(""),t.EDITABLE=!0,t.setText=_.bind(this.nameFieldSetText_,this),o=t.init,t.init=function(){return o.apply(this,arguments),this.getSvgRoot().setAttribute("y",n/4)},this.appendDummyInput().appendField(e,"COSTUME").appendField(t,"NAME"),this.appendStatementInput("DO"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")},dispose:function(){var e;return this.character.off("change",this.changeHandler),"function"==typeof(e=this.character).unlink&&e.unlink(this),this.constructor.prototype.dispose.apply(this,arguments)},nameFieldSetText_:function(e){var t,o;return o=Smalruby.Collections.CharacterSet,t=o.findWhere({name:e}),t?this.setCharacter(t):this.fieldLableSetText_(this.getField_("NAME"),e)},fieldLableSetText_:function(e,t){return Blockly.FieldLabel.prototype.setText.call(e,t)},setCharacter:function(e){var t=this;return this.changeHandler&&this.character.off("change",this.changeHandler),this.character=e,this.setFieldValue(e.costumeUrl(),"COSTUME"),this.fieldLableSetText_(this.getField_("NAME"),e.get("name")),e.link(this),this.changeHandler=function(o){return t.setFieldValue(o.costumeUrl(),"COSTUME"),t.fieldLableSetText_(t.getField_("NAME"),e.get("name"))},e.on("change",this.changeHandler),this}},Blockly.Ruby.character_new=function(e){var t,o,n;t=e.character,Blockly.Ruby.defineCharacter(t),Blockly.Ruby.cs_().push(t);try{n=e.getInputTargetBlock("DO"),o=Blockly.Ruby.blockToCode(n)||"\n"}finally{Blockly.Ruby.cs_().pop()}return o}}.call(this),function(){Blockly.Blocks.control_sleep={init:function(){return this.setHelpUrl(""),this.setColour(43),this.interpolateMsg(Smalruby.bm("BLOCKS_CONTROL_SLEEP"),["SEC",["Number"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.control_sleep=function(){var e;return e=Blockly.Ruby.valueToCode(this,"SEC",Blockly.Ruby.ORDER_FUNCTION_CALL)||"0","sleep("+e+")\n"},Blockly.Blocks.control_loop={init:function(){return this.setHelpUrl(""),this.setColour(43),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_CONTROL_LOOP")),this.appendStatementInput("DO"),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_CONTROL_LOOP_END")),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.control_loop=function(e){var t;return"main"===Blockly.Ruby.r_()?"":(t=Blockly.Ruby.statementToCode(e,"DO")||"\n","loop do\n"+t+"end\n")},Blockly.Blocks.control_break={init:function(){return this.setHelpUrl(""),this.setColour(43),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_CONTROL_BREAK")),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.control_break=function(){return"main"===Blockly.Ruby.receiver()?"":"break\n"},Blockly.Blocks.control_next={init:function(){return this.setHelpUrl(""),this.setColour(43),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_CONTROL_NEXT")),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.control_next=function(){return"main"===Blockly.Ruby.receiver()?"":"next\n"},Blockly.Blocks.control_redo={init:function(){return this.setHelpUrl(""),this.setColour(43),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_CONTROL_REDO")),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.control_redo=function(){return"main"===Blockly.Ruby.receiver()?"":"redo\n"},Blockly.Blocks.control_if={init:function(){return this.setHelpUrl(""),this.setColour(43),this.appendValueInput("COND").setCheck("Boolean").appendField(Smalruby.bm("BLOCKS_CONTROL_IF")),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_CONTROL_THEN")),this.appendStatementInput("THEN"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip("")}},Blockly.Ruby.control_if=function(e){var t,o;return o=Blockly.Ruby.valueToCode(e,"COND",Blockly.Ruby.ORDER_CONDITIONAL)||"false",t=Blockly.Ruby.statementToCode(e,"THEN")||"\n","if "+o+"\n"+t+"end\n"},Blockly.Blocks.control_if_else={init:function(){return this.setHelpUrl(""),this.setColour(43),this.appendValueInput("COND").setCheck("Boolean").appendField(Smalruby.bm("BLOCKS_CONTROL_IF")),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_CONTROL_THEN")),this.appendStatementInput("THEN"),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_CONTROL_ELSE")),this.appendStatementInput("ELSE"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setInputsInline(!0),this.setTooltip("")}},Blockly.Ruby.control_if_else=function(e){var t,o,n;return n=Blockly.Ruby.valueToCode(e,"COND",Blockly.Ruby.ORDER_CONDITIONAL)||"false",t=Blockly.Ruby.statementToCode(e,"THEN")||"\n",o=Blockly.Ruby.statementToCode(e,"ELSE")||"\n","if "+n+"\n"+t+"else\n"+o+"end\n"},Blockly.Blocks.control_times={init:function(){return this.setHelpUrl(""),this.setColour(43),this.interpolateMsg(Smalruby.bm("BLOCKS_CONTROL_TIMES"),["COUNT",["Number"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.appendStatementInput("DO"),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.control_times=function(e){var t,o;return o=Blockly.Ruby.valueToCode(this,"COUNT",Blockly.Ruby.ORDER_NONE)||0,t=Blockly.Ruby.statementToCode(e,"DO")||"\n",""+o+".times do\n"+t+"end\n"},Blockly.Blocks.control_await_until={init:function(){return this.setHelpUrl(""),this.setColour(43),this.interpolateMsg(Smalruby.bm("BLOCKS_CONTROL_AWAIT_UNTIL"),["COND",["Boolean"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.control_await_until=function(){var e,t;return"main"===Blockly.Ruby.receiver()?"":(e=Blockly.Ruby.characterMethodCallInput_("await")[0],t=Blockly.Ruby.valueToCode(this,"COND",Blockly.Ruby.ORDER_CONDITIONAL)||"true",""+e+" until "+t+"\n")},Blockly.Blocks.control_until={init:function(){return this.setHelpUrl(""),this.setColour(43),this.interpolateMsg(Smalruby.bm("BLOCKS_CONTROL_UNTIL"),["COND",["Boolean"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.appendStatementInput("DO"),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_CONTROL_LOOP_END")).setAlign(Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.control_until=function(e){var t,o;return o=Blockly.Ruby.valueToCode(this,"COND",Blockly.Ruby.ORDER_CONDITIONAL)||"true",t=Blockly.Ruby.statementToCode(e,"DO")||"\n","until "+o+"\n"+t+"end\n"},Blockly.Blocks.control_await={init:function(){return this.setHelpUrl(""),this.setColour(43),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_CONTROL_AWAIT")),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.control_await=function(){return"main"===Blockly.Ruby.receiver()?"":Blockly.Ruby.characterMethodCall_("await")}}.call(this),function(){}.call(this),function(){}.call(this),function(){Blockly.Blocks.events_on_start={init:function(){return this.setHelpUrl(""),this.setColour(33),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_EVENTS_ON_START")),this.appendStatementInput("DO"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.events_on_start=function(e){return Blockly.Ruby.characterEvent_(e,"DO","start")},Blockly.Blocks.events_on_key_push_or_down={init:function(){var e,t;return e=window.SmalrubyEditor.Sensing.KeyDropdown,t=window.SmalrubyEditor.Sensing.PushOrDownDropdown,this.setHelpUrl(""),this.setColour(33),this.interpolateMsg(Smalruby.bm("BLOCKS_EVENTS_ON_KEY_PUSH_OR_DOWN"),["KEY",new Blockly.FieldDropdown(e)],["POD",new Blockly.FieldDropdown(t)],Blockly.ALIGN_RIGHT),this.appendStatementInput("DO"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.events_on_key_push_or_down=function(e){var t,o;return t=this.getFieldValue("KEY"),o=this.getFieldValue("POD"),Blockly.Ruby.characterEvent_(e,"DO","key_"+o,t)},Blockly.Blocks.events_on_click={init:function(){return this.setHelpUrl(""),this.setColour(33),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_EVENTS_ON_CLICK")),this.appendStatementInput("DO"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.events_on_click=function(e){return Blockly.Ruby.characterEvent_(e,"DO","click")},Blockly.Blocks.events_on_hit={init:function(){return this.setHelpUrl(""),this.setColour(33),this.interpolateMsg(Smalruby.bm("BLOCKS_EVENTS_ON_HIT"),["CHAR",new Smalruby.FieldCharacter],Blockly.ALIGN_RIGHT),this.appendStatementInput("DO"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.events_on_hit=function(e){var t;return t=this.getCharacterFieldValue(),Blockly.Ruby.characterEvent_(e,"DO","hit",t)}}.call(this),function(){var e,t,o,n,i,r,s,l;n=null,r=null,s=null,o=null,e=null,i=null,l=null,t=null,$(document).ready(function(){var a;return window.SmalrubyEditor.Hardware={Type:"Arduino",DioPins:[2,3,4,5,6,7,8,9,10,11,12,13],PwmPins:[3,5,6,9,10,11],AiPins:[0,1,2,3,4,5]},n=function(){var e,t,o,n;for(o=window.SmalrubyEditor.Hardware.DioPins,n=[],e=0,t=o.length;t>e;e++)a=o[e],n.push(["D"+a,"D"+a]);return n}(),r=function(){var e,t,o,n;for(o=window.SmalrubyEditor.Hardware.PwmPins,n=[],e=0,t=o.length;t>e;e++)a=o[e],n.push(["D"+a,"D"+a]);return n}(),s=function(){var e,t,o,n;for(o=[3,9],n=[],e=0,t=o.length;t>e;e++)a=o[e],n.push(["D"+a,"D"+a]);return n}(),o=function(){var e,t,o,n;for(o=window.SmalrubyEditor.Hardware.AiPins,n=[],e=0,t=o.length;t>e;e++)a=o[e],n.push(["A"+a,"A"+a]);return n}(),e=[[Smalruby.bm("BLOCKS_HARDWARE_ANODE"),"anode"],[Smalruby.bm("BLOCKS_HARDWARE_CATHODE"),"cathode"]],i=[[Smalruby.bm("BLOCKS_HARDWARE_LEFT"),"left"],[Smalruby.bm("BLOCKS_HARDWARE_RIGHT"),"right"]],l=function(){var e,t,o,n;for(o=[5,6],n=[],e=0,t=o.length;t>e;e++)a=o[e],n.push(["D"+a,"D"+a]);return n}(),t=[[Smalruby.bm("COMMON_FORWARD"),"forward"],[Smalruby.bm("COMMON_BACKWARD"),"backward"],[Smalruby.bm("COMMON_TURN_LEFT"),"turn_left"],[Smalruby.bm("COMMON_TURN_RIGHT"),"turn_right"],[Smalruby.bm("COMMON_STOP"),"stop"]]}),Blockly.Blocks.hardware_init_hardware={init:function(){return this.setHelpUrl(""),this.setColour(340),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_HARDWARE_INIT_HARDWARE")),this.setTooltip("")}},Blockly.Ruby.hardware_init_hardware=function(){return Blockly.Ruby.definitions_.prepare__init_hardware="init_hardware",""},Blockly.Blocks.hardware_led_turn_on={init:function(){return this.setHelpUrl(""),this.setColour(270),this.interpolateMsg(Smalruby.bm("BLOCKS_HARDWARE_LED_TURN_ON"),["PIN",new Blockly.FieldDropdown(n)],Blockly.ALIGN_RIGHT),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(""),this.setFieldValue("D2","PIN")}},Blockly.Ruby.hardware_led_turn_on=function(){var e;return e=this.getFieldValue("PIN"),Blockly.Ruby.characterMethodCall_("led("+Blockly.Ruby.quote_(e)+").turn_on")},Blockly.Blocks.hardware_led_turn_off={init:function(){return this.setHelpUrl(""),this.setColour(270),this.interpolateMsg(Smalruby.bm("BLOCKS_HARDWARE_LED_TURN_OFF"),["PIN",new Blockly.FieldDropdown(n)],Blockly.ALIGN_RIGHT),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip(""),this.setFieldValue("D2","PIN")}},Blockly.Ruby.hardware_led_turn_off=function(){var e;return e=this.getFieldValue("PIN"),Blockly.Ruby.characterMethodCall_("led("+Blockly.Ruby.quote_(e)+").turn_off")},Blockly.Blocks.hardware_rgb_led_set_color={init:function(){return this.setHelpUrl(""),this.setColour(270),this.interpolateMsg(Smalruby.bm("BLOCKS_HARDWARE_RGB_LED_SET_COLOR"),["AC",new Blockly.FieldDropdown(e)],["PIN",new Blockly.FieldDropdown(s)],["COLOUR",new Blockly.FieldColour("#ff0000")],Blockly.ALIGN_RIGHT),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.hardware_rgb_led_set_color=function(e){var t,o,n,i,r,s;return t=this.getFieldValue("AC"),r=this.getFieldValue("PIN"),n=e.getFieldValue("COLOUR"),s=parseInt(n.slice(1,3),16),i=parseInt(n.slice(3,5),16),o=parseInt(n.slice(5,7),16),Blockly.Ruby.characterSetVariable_("rgb_led_"+t+"("+Blockly.Ruby.quote_(r)+").color","["+s+", "+i+", "+o+"]")},Blockly.Blocks.hardware_rgb_led_turn_off={init:function(){return this.setHelpUrl(""),this.setColour(270),this.interpolateMsg(Smalruby.bm("BLOCKS_HARDWARE_RGB_LED_TURN_OFF"),["AC",new Blockly.FieldDropdown(e)],["PIN",new Blockly.FieldDropdown(s)],Blockly.ALIGN_RIGHT),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.hardware_rgb_led_turn_off=function(){var e,t;return e=this.getFieldValue("AC"),t=this.getFieldValue("PIN"),Blockly.Ruby.characterMethodCall_("rgb_led_"+e+"("+Blockly.Ruby.quote_(t)+").turn_off")},Blockly.Blocks.hardware_seven_segment_display_show={init:function(){var e,t;return e=function(){var e,o;for(o=[],t=e=0;9>=e;t=++e)o.push([String(t),String(t)]);return o}(),this.setHelpUrl(""),this.setColour(270),this.interpolateMsg(Smalruby.bm("BLOCKS_HARDWARE_SEVEN_SEGMENT_DISPLAY_SHOW"),["NUM",new Blockly.FieldDropdown(e)],Blockly.ALIGN_RIGHT),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.hardware_seven_segment_display_show=function(){var e;return e=parseInt(this.getFieldValue("NUM")),Blockly.Ruby.characterMethodCall_("seven_segment_display.show("+e+")")},Blockly.Blocks.hardware_seven_segment_display_off={init:function(){return this.setHelpUrl(""),this.setColour(270),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_HARDWARE_SEVEN_SEGMENT_DISPLAY_OFF")),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.hardware_seven_segment_display_off=function(){return Blockly.Ruby.characterMethodCall_("seven_segment_display.off")},Blockly.Blocks.hardware_lcd_puts={init:function(){return this.setHelpUrl(""),this.setColour(270),this.interpolateMsg(Smalruby.bm("BLOCKS_HARDWARE_LCD_PUTS"),["TEXT",["String"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.hardware_lcd_puts=function(){var e;return e=Blockly.Ruby.valueToCode(this,"TEXT",Blockly.Ruby.ORDER_NONE)||"",Blockly.Ruby.characterMethodCall_("lcd.puts("+e+")")},Blockly.Blocks.hardware_lcd_clear={init:function(){return this.setHelpUrl(""),this.setColour(270),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_HARDWARE_LCD_CLEAR")),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.hardware_lcd_clear=function(){return Blockly.Ruby.characterMethodCall_("lcd.clear")},Blockly.Blocks.hardware_servo_set_position={init:function(){return this.setHelpUrl(""),this.setColour(208),this.interpolateMsg(Smalruby.bm("BLOCKS_HARDWARE_SERVO_SET_POSITION"),["PIN",new Blockly.FieldDropdown(r)],["POS",["Number"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.hardware_servo_set_position=function(){var e,t;return e=this.getFieldValue("PIN"),t=Blockly.Ruby.valueToCode(this,"POS",Blockly.Ruby.ORDER_FUNCTION_CALL)||"5",Blockly.Ruby.characterMethodCall_("servo("+Blockly.Ruby.quote_(e)+").position = "+t)},Blockly.Blocks.hardware_two_wheel_drive_car_forward={init:function(){return this.setHelpUrl(""),this.setColour(208),this.interpolateMsg(Smalruby.bm("BLOCKS_HARDWARE_TWO_WHEEL_DRIVE_CAR_FORWARD"),["PIN",new Blockly.FieldDropdown(l)],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.hardware_two_wheel_drive_car_forward=function(){var e;return e=this.getFieldValue("PIN"),Blockly.Ruby.characterMethodCall_("two_wheel_drive_car("+Blockly.Ruby.quote_(e)+").forward")},Blockly.Blocks.hardware_two_wheel_drive_car_backward={init:function(){return this.setHelpUrl(""),this.setColour(208),this.interpolateMsg(Smalruby.bm("BLOCKS_HARDWARE_TWO_WHEEL_DRIVE_CAR_BACKWARD"),["PIN",new Blockly.FieldDropdown(l)],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.hardware_two_wheel_drive_car_backward=function(){var e;return e=this.getFieldValue("PIN"),Blockly.Ruby.characterMethodCall_("two_wheel_drive_car("+Blockly.Ruby.quote_(e)+").backward")},Blockly.Blocks.hardware_two_wheel_drive_car_turn_left={init:function(){return this.setHelpUrl(""),this.setColour(208),this.interpolateMsg(Smalruby.bm("BLOCKS_HARDWARE_TWO_WHEEL_DRIVE_CAR_TURN_LEFT"),["PIN",new Blockly.FieldDropdown(l)],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.hardware_two_wheel_drive_car_turn_left=function(){var e;return e=this.getFieldValue("PIN"),Blockly.Ruby.characterMethodCall_("two_wheel_drive_car("+Blockly.Ruby.quote_(e)+").turn_left")},Blockly.Blocks.hardware_two_wheel_drive_car_turn_right={init:function(){return this.setHelpUrl(""),this.setColour(208),this.interpolateMsg(Smalruby.bm("BLOCKS_HARDWARE_TWO_WHEEL_DRIVE_CAR_TURN_RIGHT"),["PIN",new Blockly.FieldDropdown(l)],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.hardware_two_wheel_drive_car_turn_right=function(){var e;return e=this.getFieldValue("PIN"),Blockly.Ruby.characterMethodCall_("two_wheel_drive_car("+Blockly.Ruby.quote_(e)+").turn_right")},Blockly.Blocks.hardware_two_wheel_drive_car_stop={init:function(){return this.setHelpUrl(""),this.setColour(208),this.interpolateMsg(Smalruby.bm("BLOCKS_HARDWARE_TWO_WHEEL_DRIVE_CAR_STOP"),["PIN",new Blockly.FieldDropdown(l)],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.hardware_two_wheel_drive_car_stop=function(){var e;return e=this.getFieldValue("PIN"),Blockly.Ruby.characterMethodCall_("two_wheel_drive_car("+Blockly.Ruby.quote_(e)+").stop")},Blockly.Blocks.hardware_two_wheel_drive_car_run={init:function(){return this.setHelpUrl(""),this.setColour(208),this.interpolateMsg(Smalruby.bm("BLOCKS_HARDWARE_TWO_WHEEL_DRIVE_CAR_RUN"),["COMMAND",["String"],Blockly.ALIGN_RIGHT],["PIN",new Blockly.FieldDropdown(l)],["SEC",["Number"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.hardware_two_wheel_drive_car_run=function(){var e,t,o;return t=this.getFieldValue("PIN"),o=Blockly.Ruby.valueToCode(this,"SEC",Blockly.Ruby.ORDER_NONE)||0,e=Blockly.Ruby.valueToCode(this,"COMMAND",Blockly.Ruby.ORDER_NONE)||Blockly.Ruby.quote_("stop"),Blockly.Ruby.characterMethodCall_("two_wheel_drive_car("+Blockly.Ruby.quote_(t)+").run(command: "+e+", sec: "+o+")")},Blockly.Blocks.hardware_two_wheel_drive_car_commands={init:function(){return this.setHelpUrl(""),this.setColour(208),this.interpolateMsg(Smalruby.bm("BLOCKS_HARDWARE_TWO_WHEEL_DRIVE_CAR_COMMANDS"),["COMMAND",new Blockly.FieldDropdown(t)],Blockly.ALIGN_RIGHT),this.setOutput(!0,"String"),this.setTooltip("")}},Blockly.Ruby.hardware_two_wheel_drive_car_commands=function(){var e;return e=Blockly.Ruby.quote_(this.getFieldValue("COMMAND")),[e,Blockly.Ruby.ORDER_ATOMIC]},Blockly.Blocks.hardware_two_wheel_drive_car_set_speed={init:function(){return this.setHelpUrl(""),this.setColour(208),this.interpolateMsg(Smalruby.bm("BLOCKS_HARDWARE_TWO_WHEEL_DRIVE_CAR_SET_SPEED"),["PIN",new Blockly.FieldDropdown(r)],["LOR",new Blockly.FieldDropdown(i)],["SPEED",["Number"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.hardware_two_wheel_drive_car_set_speed=function(){var e,t,o;return t=this.getFieldValue("PIN"),e=this.getFieldValue("LOR"),o=Blockly.Ruby.valueToCode(this,"SPEED",Blockly.Ruby.ORDER_NONE)||"100",Blockly.Ruby.characterMethodCall_("two_wheel_drive_car("+Blockly.Ruby.quote_(t)+")."+e+"_speed = "+o)},Blockly.Blocks.hardware_two_wheel_drive_car_speed={init:function(){return this.setHelpUrl(""),this.setColour(190),this.interpolateMsg(Smalruby.bm("BLOCKS_HARDWARE_TWO_WHEEL_DRIVE_CAR_SPEED"),["PIN",new Blockly.FieldDropdown(r)],["LOR",new Blockly.FieldDropdown(i)],Blockly.ALIGN_RIGHT),this.setOutput(!0,"Number"),this.setTooltip("")}},Blockly.Ruby.hardware_two_wheel_drive_car_speed=function(){var e,t;return t=this.getFieldValue("PIN"),e=this.getFieldValue("LOR"),Blockly.Ruby.characterMethodCallInput_("two_wheel_drive_car("+Blockly.Ruby.quote_(t)+")."+e+"_speed")},Blockly.Blocks.hardware_motor_driver={init:function(){var e;return e=[[Smalruby.bm("BLOCKS_HARDWARE_MOTOR_DRIVER_FORWARD"),"forward"],[Smalruby.bm("BLOCKS_HARDWARE_MOTOR_DRIVER_BACKWARD"),"backward"],[Smalruby.bm("BLOCKS_HARDWARE_MOTOR_DRIVER_STOP"),"stop"]],this.setHelpUrl(""),this.setColour(208),this.interpolateMsg(Smalruby.bm("BLOCKS_HARDWARE_MOTOR_DRIVER"),["PIN",new Blockly.FieldDropdown(r)],["METHOD",new Blockly.FieldDropdown(e)],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.hardware_motor_driver=function(){var e,t;return t=this.getFieldValue("PIN"),e=this.getFieldValue("METHOD"),Blockly.Ruby.characterMethodCall_("motor_driver("+Blockly.Ruby.quote_(t)+")."+e)},Blockly.Blocks.hardware_motor_driver_set_speed={init:function(){return this.setHelpUrl(""),this.setColour(208),this.interpolateMsg(Smalruby.bm("BLOCKS_HARDWARE_MOTOR_DRIVER_SET_SPEED"),["PIN",new Blockly.FieldDropdown(r)],["SPEED",["Number"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.hardware_motor_driver_set_speed=function(){var e,t;return e=this.getFieldValue("PIN"),t=Blockly.Ruby.valueToCode(this,"SPEED",Blockly.Ruby.ORDER_NONE)||"100",Blockly.Ruby.characterMethodCall_("motor_driver("+Blockly.Ruby.quote_(e)+").speed = "+t)},Blockly.Blocks.hardware_motor_driver_speed={init:function(){return this.setHelpUrl(""),this.setColour(190),this.interpolateMsg(Smalruby.bm("BLOCKS_HARDWARE_MOTOR_DRIVER_SPEED"),["PIN",new Blockly.FieldDropdown(r)],Blockly.ALIGN_RIGHT),this.setOutput(!0,"Number"),this.setTooltip("")}},Blockly.Ruby.hardware_motor_driver_speed=function(){var e;return e=this.getFieldValue("PIN"),Blockly.Ruby.characterMethodCallInput_("motor_driver("+Blockly.Ruby.quote_(e)+").speed")},Blockly.Blocks.hardware_button_pressed_or_released={init:function(){var e;return e=window.SmalrubyEditor.Sensing.PressedOrReleasedDropdown,this.setHelpUrl(""),this.setColour(190),this.interpolateMsg(Smalruby.bm("BLOCKS_HARDWARE_BUTTON_PRESSED_OR_RELEASED"),["PIN",new Blockly.FieldDropdown(n)],["POR",new Blockly.FieldDropdown(e)],Blockly.ALIGN_RIGHT),this.setOutput(!0,"Boolean"),this.setTooltip("")}},Blockly.Ruby.hardware_button_pressed_or_released=function(){var e,t;return e=this.getFieldValue("PIN"),t=this.getFieldValue("POR"),Blockly.Ruby.characterMethodCallInput_("button("+Blockly.Ruby.quote_(e)+")."+t+"?")},Blockly.Blocks.hardware_sensor_value={init:function(){return this.setHelpUrl(""),this.setColour(190),this.interpolateMsg(Smalruby.bm("BLOCKS_HARDWARE_SENSOR_VALUE"),["PIN",new Blockly.FieldDropdown(o)],Blockly.ALIGN_RIGHT),this.setOutput(!0,"Number"),this.setTooltip("")}},Blockly.Ruby.hardware_sensor_value=function(){var e;return e=this.getFieldValue("PIN"),Blockly.Ruby.characterMethodCallInput_("sensor("+Blockly.Ruby.quote_(e)+").value")},Blockly.Blocks.hardware_smalrubot_v3_led_turn_on_or_off={init:function(){var e;return e=[[Smalruby.bm("COMMON_TURN_ON"),"turn_on"],[Smalruby.bm("COMMON_TURN_OFF"),"turn_off"]],this.setHelpUrl(""),this.setColour(270),this.interpolateMsg(Smalruby.bm("BLOCKS_HARDWARE_SMALRUBOT_V3_LED_TURN_ON_OR_OFF"),["LOR",new Blockly.FieldDropdown(i)],["OOO",new Blockly.FieldDropdown(e)],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.hardware_smalrubot_v3_led_turn_on_or_off=function(){var e,t;return e=this.getFieldValue("LOR"),t=this.getFieldValue("OOO"),Blockly.Ruby.characterMethodCall_("smalrubot_v3."+t+"_"+e+"_led")},Blockly.Blocks.hardware_smalrubot_v3_action={init:function(){return this.setHelpUrl(""),this.setColour(208),this.interpolateMsg(Smalruby.bm("BLOCKS_HARDWARE_SMALRUBOT_V3_ACTION"),["ACTION",new Blockly.FieldDropdown(t)],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.hardware_smalrubot_v3_action=function(){var e;return e=this.getFieldValue("ACTION"),Blockly.Ruby.characterMethodCall_("smalrubot_v3."+e)},Blockly.Blocks.hardware_smalrubot_v3_action_with_sec={init:function(){return this.setHelpUrl(""),this.setColour(208),this.interpolateMsg(Smalruby.bm("BLOCKS_HARDWARE_SMALRUBOT_V3_ACTION_WITH_SEC"),["ACTION",new Blockly.FieldDropdown(t)],["SEC",["Number"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")
|
39
39
|
}},Blockly.Ruby.hardware_smalrubot_v3_action_with_sec=function(){var e,t;return e=this.getFieldValue("ACTION"),t=Blockly.Ruby.valueToCode(this,"SEC",Blockly.Ruby.ORDER_FUNCTION_CALL)||"nil",Blockly.Ruby.characterMethodCall_("smalrubot_v3."+e+"(sec: "+t+")")},Blockly.Blocks.hardware_smalrubot_v3_sensor_value={init:function(){return this.setHelpUrl(""),this.setColour(190),this.interpolateMsg(Smalruby.bm("BLOCKS_HARDWARE_SMALRUBOT_V3_SENSOR_VALUE"),["LOR",new Blockly.FieldDropdown(i)],Blockly.ALIGN_RIGHT),this.setOutput(!0,"Boolean"),this.setTooltip("")}},Blockly.Ruby.hardware_smalrubot_v3_sensor_value=function(){var e;return e=this.getFieldValue("LOR"),Blockly.Ruby.characterMethodCallInput_("smalrubot_v3."+e+"_sensor_value")},Blockly.Blocks.hardware_smalrubot_v3_dc_motor_power_ratio={init:function(){return this.setHelpUrl(""),this.setColour(190),this.interpolateMsg(Smalruby.bm("BLOCKS_HARDWARE_SMALRUBOT_V3_DC_MOTOR_POWER_RATIO"),["LOR",new Blockly.FieldDropdown(i)],Blockly.ALIGN_RIGHT),this.setOutput(!0,"Number"),this.setTooltip("")}},Blockly.Ruby.hardware_smalrubot_v3_dc_motor_power_ratio=function(){var e;return e=this.getFieldValue("LOR"),Blockly.Ruby.characterMethodCallInput_("smalrubot_v3."+e+"_dc_motor_power_ratio")},Blockly.Blocks.hardware_smalrubot_v3_dc_motor_set_power_ratio={init:function(){return this.setHelpUrl(""),this.setColour(208),this.interpolateMsg(Smalruby.bm("BLOCKS_HARDWARE_SMALRUBOT_V3_DC_MOTOR_SET_POWER_RATIO"),["LOR",new Blockly.FieldDropdown(i)],["SPEED",["Number"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.hardware_smalrubot_v3_dc_motor_set_power_ratio=function(){var e,t;return e=this.getFieldValue("LOR"),t=Blockly.Ruby.valueToCode(this,"SPEED",Blockly.Ruby.ORDER_NONE)||"100",Blockly.Ruby.characterSetVariable_("smalrubot_v3."+e+"_dc_motor_power_ratio",t)},Blockly.Blocks.hardware_smalrubot_s1_led_turn_on_or_off={init:function(){var e;return e=[[Smalruby.bm("COMMON_TURN_ON"),"turn_on"],[Smalruby.bm("COMMON_TURN_OFF"),"turn_off"]],this.setHelpUrl(""),this.setColour(270),this.interpolateMsg(Smalruby.bm("BLOCKS_HARDWARE_SMALRUBOT_S1_LED_TURN_ON_OR_OFF"),["LOR",new Blockly.FieldDropdown(i)],["OOO",new Blockly.FieldDropdown(e)],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.hardware_smalrubot_s1_led_turn_on_or_off=function(){var e,t;return e=this.getFieldValue("LOR"),t=this.getFieldValue("OOO"),Blockly.Ruby.characterMethodCall_("smalrubot_s1."+t+"_"+e+"_led")},Blockly.Blocks.hardware_smalrubot_s1_action={init:function(){return this.setHelpUrl(""),this.setColour(208),this.interpolateMsg(Smalruby.bm("BLOCKS_HARDWARE_SMALRUBOT_S1_ACTION"),["ACTION",new Blockly.FieldDropdown(t)],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.hardware_smalrubot_s1_action=function(){var e;return e=this.getFieldValue("ACTION"),Blockly.Ruby.characterMethodCall_("smalrubot_s1."+e)},Blockly.Blocks.hardware_smalrubot_s1_action_with_sec={init:function(){return this.setHelpUrl(""),this.setColour(208),this.interpolateMsg(Smalruby.bm("BLOCKS_HARDWARE_SMALRUBOT_S1_ACTION_WITH_SEC"),["ACTION",new Blockly.FieldDropdown(t)],["SEC",["Number"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.hardware_smalrubot_s1_action_with_sec=function(){var e,t;return e=this.getFieldValue("ACTION"),t=Blockly.Ruby.valueToCode(this,"SEC",Blockly.Ruby.ORDER_FUNCTION_CALL)||"nil",Blockly.Ruby.characterMethodCall_("smalrubot_s1."+e+"(sec: "+t+")")},Blockly.Blocks.hardware_smalrubot_s1_sensor_value={init:function(){return this.setHelpUrl(""),this.setColour(190),this.interpolateMsg(Smalruby.bm("BLOCKS_HARDWARE_SMALRUBOT_S1_SENSOR_VALUE"),["LOR",new Blockly.FieldDropdown(i)],Blockly.ALIGN_RIGHT),this.setOutput(!0,"Boolean"),this.setTooltip("")}},Blockly.Ruby.hardware_smalrubot_s1_sensor_value=function(){var e;return e=this.getFieldValue("LOR"),Blockly.Ruby.characterMethodCallInput_("smalrubot_s1."+e+"_sensor_value")},Blockly.Blocks.hardware_smalrubot_s1_dc_motor_power_ratio={init:function(){return this.setHelpUrl(""),this.setColour(190),this.interpolateMsg(Smalruby.bm("BLOCKS_HARDWARE_SMALRUBOT_S1_DC_MOTOR_POWER_RATIO"),["LOR",new Blockly.FieldDropdown(i)],Blockly.ALIGN_RIGHT),this.setOutput(!0,"Number"),this.setTooltip("")}},Blockly.Ruby.hardware_smalrubot_s1_dc_motor_power_ratio=function(){var e;return e=this.getFieldValue("LOR"),Blockly.Ruby.characterMethodCallInput_("smalrubot_s1."+e+"_dc_motor_power_ratio")},Blockly.Blocks.hardware_smalrubot_s1_dc_motor_set_power_ratio={init:function(){return this.setHelpUrl(""),this.setColour(208),this.interpolateMsg(Smalruby.bm("BLOCKS_HARDWARE_SMALRUBOT_S1_DC_MOTOR_SET_POWER_RATIO"),["LOR",new Blockly.FieldDropdown(i)],["SPEED",["Number"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.hardware_smalrubot_s1_dc_motor_set_power_ratio=function(){var e,t;return e=this.getFieldValue("LOR"),t=Blockly.Ruby.valueToCode(this,"SPEED",Blockly.Ruby.ORDER_NONE)||"100",Blockly.Ruby.characterSetVariable_("smalrubot_s1."+e+"_dc_motor_power_ratio",t)}}.call(this),function(){Blockly.Blocks.looks_say_second={init:function(){return this.setHelpUrl(""),this.setColour(270),this.interpolateMsg(Smalruby.bm("BLOCKS_LOOKS_SAY_WITH_SECOND"),["TEXT",null,Blockly.ALIGN_RIGHT],["SEC",["Number"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.looks_say_second=function(){var e,t;return e=Blockly.Ruby.valueToCode(this,"SEC",Blockly.Ruby.ORDER_NONE)||"0",t=Blockly.Ruby.valueToCode(this,"TEXT",Blockly.Ruby.ORDER_NONE)||Blockly.Ruby.quote_(""),Blockly.Ruby.characterMethodCall_("say","message: "+t+", second: "+e)},Blockly.Blocks.looks_say={init:function(){return this.setHelpUrl(""),this.setColour(270),this.interpolateMsg(Smalruby.bm("BLOCKS_LOOKS_SAY"),["TEXT",null,Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.looks_say=function(){var e;return e=Blockly.Ruby.valueToCode(this,"TEXT",Blockly.Ruby.ORDER_NONE)||Blockly.Ruby.quote_(""),Blockly.Ruby.characterMethodCall_("say","message: "+e)},Blockly.Blocks.looks_think_second={init:function(){return this.setHelpUrl(""),this.setColour(270),this.interpolateMsg(Smalruby.bm("BLOCKS_LOOKS_THINK_WITH_SECOND"),["TEXT",null,Blockly.ALIGN_RIGHT],["SEC",["Number"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.looks_think_second=function(){var e,t;return e=Blockly.Ruby.valueToCode(this,"SEC",Blockly.Ruby.ORDER_NONE)||"0",t=Blockly.Ruby.valueToCode(this,"TEXT",Blockly.Ruby.ORDER_NONE)||Blockly.Ruby.quote_(""),Blockly.Ruby.characterMethodCall_("think","message: "+t+", second: "+e)},Blockly.Blocks.looks_think={init:function(){return this.setHelpUrl(""),this.setColour(270),this.interpolateMsg(Smalruby.bm("BLOCKS_LOOKS_THINK"),["TEXT",null,Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.looks_think=function(){var e;return e=Blockly.Ruby.valueToCode(this,"TEXT",Blockly.Ruby.ORDER_NONE)||Blockly.Ruby.quote_(""),Blockly.Ruby.characterMethodCall_("think","message: "+e)},Blockly.Blocks.looks_show={init:function(){return this.setHelpUrl(""),this.setColour(270),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_LOOKS_SHOW")),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.looks_show=function(){return Blockly.Ruby.characterSetVariable_("visible","true")},Blockly.Blocks.looks_hide={init:function(){return this.setHelpUrl(""),this.setColour(270),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_LOOKS_HIDE")),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.looks_hide=function(){return Blockly.Ruby.characterSetVariable_("visible","false")},Blockly.Blocks.looks_vanish={init:function(){return this.setHelpUrl(""),this.setColour(270),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_LOOKS_VANISH")),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.looks_vanish=function(){return Blockly.Ruby.characterMethodCall_("vanish")},Blockly.Blocks.looks_change_scale_by={init:function(){return this.setHelpUrl(""),this.setColour(270),this.interpolateMsg("大きさを%1%ずつ変える",["SCALE",["Number"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.looks_change_scale_by=function(){var e;return e=Blockly.Ruby.valueToCode(this,"SCALE",Blockly.Ruby.ORDER_NONE)||"0",e=parseInt(e)/100,"self.scale += "+e+"\n"},Blockly.Blocks.looks_set_scale={init:function(){return this.setHelpUrl(""),this.setColour(270),this.interpolateMsg("大きさを%1%にする",["SCALE",["Number"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.looks_set_scale=function(){var e;return e=Blockly.Ruby.valueToCode(this,"SCALE",Blockly.Ruby.ORDER_NONE)||"0",e=parseInt(e)/100,"self.scale = "+e+"\n"},Blockly.Blocks.looks_self_scale={init:function(){return this.setHelpUrl(""),this.setColour(270),this.appendDummyInput().appendField("大きさ"),this.setOutput(!0,"Number"),this.setTooltip("")}},Blockly.Ruby.looks_self_scale=function(){return["scale",Blockly.Ruby.ORDER_ATOMIC]},Blockly.Blocks.looks_preset_images={init:function(){var e;return e=[["車1","car1.png"],["車2","car2.png"],["車3","car3.png"],["車4","car4.png"],["ボール1","ball1.png"],["ボール2","ball2.png"],["ボール3","ball3.png"],["ボール4","ball4.png"],["ボール5","ball5.png"],["ボール6","ball6.png"],["猫1","cat1.png"],["猫2","cat2.png"],["猫3","cat3.png"],["かえる1","frog1.png"],["コウガ リュウ1","ryu1.png"],["コウガ リュウ2","ryu2.png"],["イタチのタイチ","taichi1.png"],["イタチのタイチ","taichi2.png"]],this.setHelpUrl(""),this.setColour(270),this.appendDummyInput().appendField(new Blockly.FieldDropdown(e),"NAME"),this.setOutput(!0,"String"),this.setTooltip("")}},Blockly.Ruby.looks_preset_images=function(){var e;return e=Blockly.Ruby.quote_(this.getFieldValue("NAME")),[e,Blockly.Ruby.ORDER_ATOMIC]}}.call(this),function(){Blockly.Blocks.motion_move={init:function(){return this.setHelpUrl(""),this.setColour(208),this.interpolateMsg(Smalruby.bm("BLOCKS_MOTION_MOVE"),["STEP",["Number"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.motion_move=function(){var e;return e=Blockly.Ruby.valueToCode(this,"STEP",Blockly.Ruby.ORDER_NONE)||"0",Blockly.Ruby.characterMethodCall_("move",""+e)},Blockly.Blocks.motion_rotate_right={init:function(){return this.setHelpUrl(""),this.setColour(208),this.interpolateMsg(Smalruby.bm("BLOCKS_MOTION_TURN_RIGHT_DEGREES"),["ANGLE",["Number"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.motion_rotate_right=function(){var e;return e=Blockly.Ruby.valueToCode(this,"ANGLE",Blockly.Ruby.ORDER_NONE)||"0",Blockly.Ruby.characterMethodCall_("rotate",""+e)},Blockly.Blocks.motion_rotate_left={init:function(){return this.setHelpUrl(""),this.setColour(208),this.interpolateMsg(Smalruby.bm("BLOCKS_MOTION_TURN_LEFT_DEGREES"),["ANGLE",["Number"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.motion_rotate_left=function(){var e;return e=Blockly.Ruby.valueToCode(this,"ANGLE",Blockly.Ruby.ORDER_NONE)||"0",Blockly.Ruby.characterMethodCall_("rotate","-"+e)},Blockly.Blocks.motion_set_angle={init:function(){return this.setHelpUrl(""),this.setColour(208),this.interpolateMsg(Smalruby.bm("BLOCKS_MOTION_POINT_IN_DIRECTION"),["ANGLE",["Number"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.motion_set_angle=function(){var e;return e=Blockly.Ruby.valueToCode(this,"ANGLE",Blockly.Ruby.ORDER_NONE)||"0",Blockly.Ruby.characterSetVariable_("angle",e)},Blockly.Blocks.motion_point_towards_mouse={init:function(){return this.setHelpUrl(""),this.setColour(208),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_MOTION_POINT_TOWARDS_MOUSE")),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.motion_point_towards_mouse=function(){return""+Blockly.Ruby.rn()+"point_towards(:mouse)\n"},Blockly.Blocks.motion_point_towards_character={init:function(){return this.setHelpUrl(""),this.setColour(208),this.interpolateMsg(Smalruby.bm("BLOCKS_MOTION_POINT_TOWARDS_CHARACTER"),["CHAR",new Smalruby.FieldCharacter],Blockly.ALIGN_RIGHT),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.motion_point_towards_character=function(){var e;return e=this.getCharacterFieldValue(),Blockly.Ruby.characterMethodCall_("point_towards",e)},Blockly.Blocks.motion_set_x_y={init:function(){return this.setHelpUrl(""),this.setColour(208),this.interpolateMsg(Smalruby.bm("BLOCKS_MOTION_SET_X_Y"),["X",["Number"],Blockly.ALIGN_RIGHT],["Y",["Number"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.motion_set_x_y=function(){var e,t;return e=Blockly.Ruby.valueToCode(this,"X",Blockly.Ruby.ORDER_NONE)||"0",t=Blockly.Ruby.valueToCode(this,"Y",Blockly.Ruby.ORDER_NONE)||"0",Blockly.Ruby.characterSetVariable_("position","["+e+", "+t+"]")},Blockly.Blocks.motion_go_to_mouse={init:function(){return this.setHelpUrl(""),this.setColour(208),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_MOTION_GO_TO_MOUSE")),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.motion_go_to_mouse=function(){return Blockly.Ruby.characterMethodCall_("go_to(:mouse)")},Blockly.Blocks.motion_go_to_character={init:function(){return this.setHelpUrl(""),this.setColour(208),this.interpolateMsg(Smalruby.bm("BLOCKS_MOTION_GO_TO_CHARACTER"),["CHAR",new Smalruby.FieldCharacter],Blockly.ALIGN_RIGHT),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.motion_go_to_character=function(){var e;return e=this.getCharacterFieldValue(),Blockly.Ruby.characterMethodCall_("go_to("+e+")")},Blockly.Blocks.motion_glide_to_x_y={init:function(){return this.setHelpUrl(""),this.setColour(208),this.interpolateMsg("%1秒でx座標を%2、y座標を%3に変える",["SEC",["Number"],Blockly.ALIGN_RIGHT],["X",["Number"],Blockly.ALIGN_RIGHT],["Y",["Number"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.motion_glide_to_x_y=function(){var e,t,o;return e=Blockly.Ruby.valueToCode(this,"SEC",Blockly.Ruby.ORDER_NONE)||"0",t=Blockly.Ruby.valueToCode(this,"X",Blockly.Ruby.ORDER_NONE)||"0",o=Blockly.Ruby.valueToCode(this,"Y",Blockly.Ruby.ORDER_NONE)||"0",""+Blockly.Ruby.rn()+"glide_to(second: "+e+", x: "+t+", y: "+o+")\n"},Blockly.Blocks.motion_change_x_by={init:function(){return this.setHelpUrl(""),this.setColour(208),this.interpolateMsg(Smalruby.bm("BLOCKS_MOTION_CHANGE_X_BY"),["X",["Number"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.motion_change_x_by=function(){var e;return e=Blockly.Ruby.valueToCode(this,"X",Blockly.Ruby.ORDER_NONE)||"0",Blockly.Ruby.characterSetVariable_("x",e,"+=")},Blockly.Blocks.motion_set_x={init:function(){return this.setHelpUrl(""),this.setColour(208),this.interpolateMsg(Smalruby.bm("BLOCKS_MOTION_SET_X"),["X",["Number"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.motion_set_x=function(){var e;return e=Blockly.Ruby.valueToCode(this,"X",Blockly.Ruby.ORDER_NONE)||"0",Blockly.Ruby.characterSetVariable_("x",e,"=")},Blockly.Blocks.motion_change_y_by={init:function(){return this.setHelpUrl(""),this.setColour(208),this.interpolateMsg(Smalruby.bm("BLOCKS_MOTION_CHANGE_Y_BY"),["Y",["Number"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.motion_change_y_by=function(){var e;return e=Blockly.Ruby.valueToCode(this,"Y",Blockly.Ruby.ORDER_NONE)||"0",Blockly.Ruby.characterSetVariable_("y",e,"+=")},Blockly.Blocks.motion_set_y={init:function(){return this.setHelpUrl(""),this.setColour(208),this.interpolateMsg(Smalruby.bm("BLOCKS_MOTION_SET_Y"),["Y",["Number"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.motion_set_y=function(){var e;return e=Blockly.Ruby.valueToCode(this,"Y",Blockly.Ruby.ORDER_NONE)||"0",Blockly.Ruby.characterSetVariable_("y",e,"=")},Blockly.Blocks.motion_turn_if_reach_wall={init:function(){return this.setHelpUrl(""),this.setColour(208),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_MOTION_TURN_IF_REACH_WALL")),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.motion_turn_if_reach_wall=function(){return Blockly.Ruby.characterMethodCall_("turn_if_reach_wall")},Blockly.Blocks.motion_turn={init:function(){return this.setHelpUrl(""),this.setColour(208),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_MOTION_TURN")),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.motion_turn=function(){return Blockly.Ruby.characterMethodCall_("turn")},Blockly.Blocks.motion_turn_xy={init:function(){var e;return e=[[Smalruby.bm("BLOCKS_MOTION_TURN_XY_X"),"x"],[Smalruby.bm("BLOCKS_MOTION_TURN_XY_Y"),"y"]],this.setHelpUrl(""),this.setColour(208),this.interpolateMsg(Smalruby.bm("BLOCKS_MOTION_TURN_XY"),["XY",new Blockly.FieldDropdown(e)],Blockly.ALIGN_RIGHT),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.motion_turn_xy=function(){var e;return e=this.getFieldValue("XY"),Blockly.Ruby.characterMethodCall_("turn_"+e)},Blockly.Blocks.motion_set_rotation_style={init:function(){var e;return e=[[Smalruby.bm("BLOCKS_MOTION_SET_ROTATION_STYLE_LEFT_RIGHT"),"left_right"],[Smalruby.bm("BLOCKS_MOTION_SET_ROTATION_STYLE_NONE"),"none"],[Smalruby.bm("BLOCKS_MOTION_SET_ROTATION_STYLE_FREE"),"free"]],this.setHelpUrl(""),this.setColour(208),this.interpolateMsg(Smalruby.bm("BLOCKS_MOTION_SET_ROTATION_STYLE"),["STYLE",new Blockly.FieldDropdown(e)],Blockly.ALIGN_RIGHT),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.motion_set_rotation_style=function(){var e;return e=this.getFieldValue("STYLE"),Blockly.Ruby.characterSetVariable_("rotation_style",":"+e)},Blockly.Blocks.motion_self_x={init:function(){return this.setHelpUrl(""),this.setColour(208),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_MOTION_SELF_X")),this.setOutput(!0,"Number"),this.setTooltip("")}},Blockly.Ruby.motion_self_x=function(){return Blockly.Ruby.characterMethodCallInput_("x")},Blockly.Blocks.motion_self_y={init:function(){return this.setHelpUrl(""),this.setColour(208),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_MOTION_SELF_Y")),this.setOutput(!0,"Number"),this.setTooltip("")}},Blockly.Ruby.motion_self_y=function(){return Blockly.Ruby.characterMethodCallInput_("y")},Blockly.Blocks.motion_self_angle={init:function(){return this.setHelpUrl(""),this.setColour(208),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_MOTION_SELF_ANGLE")),this.setOutput(!0,"Number"),this.setTooltip("")}},Blockly.Ruby.motion_self_angle=function(){return Blockly.Ruby.characterMethodCallInput_("angle")}}.call(this),function(){Blockly.Blocks.operators_add={init:function(){return this.setHelpUrl(""),this.setColour(100),this.interpolateMsg(Smalruby.bm("BLOCKS_OPERATORS_ADD"),["A",null,Blockly.ALIGN_RIGHT],["B",null,Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setOutput(!0,null),this.setTooltip("")}},Blockly.Ruby.operators_add=function(e){var t,o,n;return n=Blockly.Ruby.ORDER_ADDITIVE,t=Blockly.Ruby.valueToCode(e,"A",n)||"0",o=Blockly.Ruby.valueToCode(e,"B",n)||"0",[t+" + "+o,n]},Blockly.Blocks.operators_minus={init:function(){return this.setHelpUrl(""),this.setColour(100),this.interpolateMsg(Smalruby.bm("BLOCKS_OPERATORS_MINUS"),["A",null,Blockly.ALIGN_RIGHT],["B",null,Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setOutput(!0,null),this.setTooltip("")}},Blockly.Ruby.operators_minus=function(e){var t,o,n;return n=Blockly.Ruby.ORDER_ADDITIVE,t=Blockly.Ruby.valueToCode(e,"A",n)||"0",o=Blockly.Ruby.valueToCode(e,"B",n)||"0",[t+" - "+o,n]},Blockly.Blocks.operators_multiply={init:function(){return this.setHelpUrl(""),this.setColour(100),this.interpolateMsg(Smalruby.bm("BLOCKS_OPERATORS_MULTIPLY"),["A",null,Blockly.ALIGN_RIGHT],["B",null,Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setOutput(!0,null),this.setTooltip("")}},Blockly.Ruby.operators_multiply=function(e){var t,o,n;return n=Blockly.Ruby.ORDER_MULTIPLICATIVE,t=Blockly.Ruby.valueToCode(e,"A",n)||"0",o=Blockly.Ruby.valueToCode(e,"B",n)||"0",[t+" * "+o,n]},Blockly.Blocks.operators_divide={init:function(){return this.setHelpUrl(""),this.setColour(100),this.interpolateMsg(Smalruby.bm("BLOCKS_OPERATORS_DIVIDE"),["A",null,Blockly.ALIGN_RIGHT],["B",null,Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setOutput(!0,null),this.setTooltip("")}},Blockly.Ruby.operators_divide=function(e){var t,o,n;return n=Blockly.Ruby.ORDER_MULTIPLICATIVE,t=Blockly.Ruby.valueToCode(e,"A",n)||"0",o=Blockly.Ruby.valueToCode(e,"B",n)||"1",[t+" / "+o,n]},Blockly.Blocks.operators_compare_lt={init:function(){return this.setHelpUrl(""),this.setColour(100),this.interpolateMsg(Smalruby.bm("BLOCKS_OPERATORS_COMPARE_LT"),["A",null,Blockly.ALIGN_RIGHT],["B",null,Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setOutput(!0,"Boolean"),this.setTooltip("")}},Blockly.Ruby.operators_compare_lt=function(e){var t,o,n;return n=Blockly.Ruby.ORDER_RELATIONAL,t=Blockly.Ruby.valueToCode(e,"A",n)||"0",o=Blockly.Ruby.valueToCode(e,"B",n)||"0",[t+" < "+o,n]},Blockly.Blocks.operators_compare_lte={init:function(){return this.setHelpUrl(""),this.setColour(100),this.interpolateMsg(Smalruby.bm("BLOCKS_OPERATORS_COMPARE_LTE"),["A",null,Blockly.ALIGN_RIGHT],["B",null,Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setOutput(!0,"Boolean"),this.setTooltip("")}},Blockly.Ruby.operators_compare_lte=function(e){var t,o,n;return n=Blockly.Ruby.ORDER_RELATIONAL,t=Blockly.Ruby.valueToCode(e,"A",n)||"0",o=Blockly.Ruby.valueToCode(e,"B",n)||"0",[t+" <= "+o,n]},Blockly.Blocks.operators_compare_eq={init:function(){return this.setHelpUrl(""),this.setColour(100),this.interpolateMsg(Smalruby.bm("BLOCKS_OPERATORS_COMPARE_EQ"),["A",null,Blockly.ALIGN_RIGHT],["B",null,Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setOutput(!0,"Boolean"),this.setTooltip("")}},Blockly.Ruby.operators_compare_eq=function(e){var t,o,n;return n=Blockly.Ruby.ORDER_EQUALS,t=Blockly.Ruby.valueToCode(e,"A",n)||"0",o=Blockly.Ruby.valueToCode(e,"B",n)||"0",[t+" == "+o,n]},Blockly.Blocks.operators_compare_gte={init:function(){return this.setHelpUrl(""),this.setColour(100),this.interpolateMsg(Smalruby.bm("BLOCKS_OPERATORS_COMPARE_GTE"),["A",null,Blockly.ALIGN_RIGHT],["B",null,Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setOutput(!0,"Boolean"),this.setTooltip("")}},Blockly.Ruby.operators_compare_gte=function(e){var t,o,n;return n=Blockly.Ruby.ORDER_RELATIONAL,t=Blockly.Ruby.valueToCode(e,"A",n)||"0",o=Blockly.Ruby.valueToCode(e,"B",n)||"0",[t+" >= "+o,n]},Blockly.Blocks.operators_compare_gt={init:function(){return this.setHelpUrl(""),this.setColour(100),this.interpolateMsg(Smalruby.bm("BLOCKS_OPERATORS_COMPARE_GT"),["A",null,Blockly.ALIGN_RIGHT],["B",null,Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setOutput(!0,"Boolean"),this.setTooltip("")}},Blockly.Ruby.operators_compare_gt=function(e){var t,o,n;return n=Blockly.Ruby.ORDER_RELATIONAL,t=Blockly.Ruby.valueToCode(e,"A",n)||"0",o=Blockly.Ruby.valueToCode(e,"B",n)||"0",[t+" > "+o,n]},Blockly.Blocks.operators_rand={init:function(){return this.setHelpUrl(""),this.setColour(100),this.interpolateMsg(Smalruby.bm("BLOCKS_OPERATORS_RAND"),["A",["Number"],Blockly.ALIGN_RIGHT],["B",["Number"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setOutput(!0,"Number"),this.setTooltip("")}},Blockly.Ruby.operators_rand=function(e){var t,o;return t=Blockly.Ruby.valueToCode(e,"A",Blockly.Ruby.ORDER_RANGE)||"0",o=Blockly.Ruby.valueToCode(e,"B",Blockly.Ruby.ORDER_RANGE)||"0",["rand("+t+".."+o+")",Blockly.Ruby.ORDER_FUNCTION_CALL]},Blockly.Blocks.operators_and={init:function(){return this.setHelpUrl(""),this.setColour(100),this.interpolateMsg(Smalruby.bm("BLOCKS_OPERATORS_AND"),["A",["Boolean"],Blockly.ALIGN_RIGHT],["B",["Boolean"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setOutput(!0,"Boolean"),this.setTooltip("")}},Blockly.Ruby.operators_and=function(e){var t,o,n;return n=Blockly.Ruby.ORDER_LOGICAL_AND,t=Blockly.Ruby.valueToCode(e,"A",n)||"true",o=Blockly.Ruby.valueToCode(e,"B",n)||"true",[""+t+" && "+o,n]},Blockly.Blocks.operators_or={init:function(){return this.setHelpUrl(""),this.setColour(100),this.interpolateMsg(Smalruby.bm("BLOCKS_OPERATORS_OR"),["A",["Boolean"],Blockly.ALIGN_RIGHT],["B",["Boolean"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setOutput(!0,"Boolean"),this.setTooltip("")}},Blockly.Ruby.operators_or=function(e){var t,o,n;return n=Blockly.Ruby.ORDER_LOGICAL_OR,t=Blockly.Ruby.valueToCode(e,"A",n)||"true",o=Blockly.Ruby.valueToCode(e,"B",n)||"true",[""+t+" || "+o,n]},Blockly.Blocks.operators_negate={init:function(){return this.setHelpUrl(""),this.setColour(100),this.interpolateMsg(Smalruby.bm("BLOCKS_OPERATORS_NOT"),["A",["Boolean"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setOutput(!0,"Boolean"),this.setTooltip("")}},Blockly.Ruby.operators_negate=function(e){var t,o;return o=Blockly.Ruby.ORDER_UNARY_SIGN,t=Blockly.Ruby.valueToCode(e,"A",o)||"true",["!"+t,o]},Blockly.Blocks.operators_index_of={init:function(){return this.setHelpUrl(""),this.setColour(100),this.interpolateMsg(Smalruby.bm("BLOCKS_OPERATORS_INDEX_OF"),["A",null,Blockly.ALIGN_RIGHT],["INDEX",["Number"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setOutput(!0,null),this.setTooltip("")}},Blockly.Ruby.operators_index_of=function(e){var t,o;return t=Blockly.Ruby.valueToCode(e,"A",Blockly.Ruby.ORDER_FUNCTION_CALL)||'""',o=Blockly.Ruby.valueToCode(e,"INDEX",Blockly.Ruby.ORDER_INDEX)||"0",[""+t+"["+o+"]",Blockly.Ruby.ORDER_FUNCTION_CALL]},Blockly.Blocks.operators_length={init:function(){return this.setHelpUrl(""),this.setColour(100),this.interpolateMsg(Smalruby.bm("BLOCKS_OPERATORS_LENGTH"),["A",null,Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setOutput(!0,null),this.setTooltip("")}},Blockly.Ruby.operators_length=function(e){var t,o;return o=Blockly.Ruby.ORDER_FUNCTION_CALL,t=Blockly.Ruby.valueToCode(e,"A",o)||'""',[""+t+".length",o]},Blockly.Blocks.operators_modulo={init:function(){return this.setHelpUrl(""),this.setColour(100),this.interpolateMsg(Smalruby.bm("BLOCKS_OPERATORS_MODULO"),["A",["Number"],Blockly.ALIGN_RIGHT],["B",["Number"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setOutput(!0,"Number"),this.setTooltip("")}},Blockly.Ruby.operators_modulo=function(e){var t,o,n;return n=Blockly.Ruby.ORDER_MULTIPLICATIVE,t=Blockly.Ruby.valueToCode(e,"A",n)||"1",o=Blockly.Ruby.valueToCode(e,"B",n)||"1",[""+t+" % "+o,n]},Blockly.Blocks.operators_round={init:function(){return this.setHelpUrl(""),this.setColour(100),this.interpolateMsg(Smalruby.bm("BLOCKS_OPERATORS_ROUND"),["A",["Number"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setOutput(!0,"Number"),this.setTooltip("")}},Blockly.Ruby.operators_round=function(e){var t,o;return o=Blockly.Ruby.ORDER_FUNCTION_CALL,t=Blockly.Ruby.valueToCode(e,"A",o)||"0",[""+t+".round",o]},Blockly.Blocks.operators_math_method={init:function(){var e;return e=[[Smalruby.bm("BLOCKS_OPERATORS_MATH_METHOD_ABS"),"%num%.abs"],[Smalruby.bm("BLOCKS_OPERATORS_MATH_METHOD_FLOOR"),"%num%.floor"],[Smalruby.bm("BLOCKS_OPERATORS_MATH_METHOD_CEIL"),"%num%.ceil"],[Smalruby.bm("BLOCKS_OPERATORS_MATH_METHOD_SQRT"),"Math.sqrt(%num%)"],[Smalruby.bm("BLOCKS_OPERATORS_MATH_METHOD_SIN"),"Math.sin(%num%)"],[Smalruby.bm("BLOCKS_OPERATORS_MATH_METHOD_COS"),"Math.cos(%num%)"],[Smalruby.bm("BLOCKS_OPERATORS_MATH_METHOD_TAN"),"Math.tan(%num%)"],[Smalruby.bm("BLOCKS_OPERATORS_MATH_METHOD_ASIN"),"Math.asin(%num%)"],[Smalruby.bm("BLOCKS_OPERATORS_MATH_METHOD_ACOS"),"Math.acos(%num%)"],[Smalruby.bm("BLOCKS_OPERATORS_MATH_METHOD_ATAN"),"Math.atan(%num%)"],[Smalruby.bm("BLOCKS_OPERATORS_MATH_METHOD_LN"),"Math.log(%num%)"],[Smalruby.bm("BLOCKS_OPERATORS_MATH_METHOD_LOG"),"Math.log10(%num%)"],[Smalruby.bm("BLOCKS_OPERATORS_MATH_METHOD_E_SQUARE"),"Math::E ** %num%"],[Smalruby.bm("BLOCKS_OPERATORS_MATH_METHOD_10_SQUARE"),"10 ** %num%"]],this.setHelpUrl(""),this.setColour(100),this.interpolateMsg(Smalruby.bm("BLOCKS_OPERATORS_MATH_METHOD"),["NUM",["Number"],Blockly.ALIGN_RIGHT],["METHOD",new Blockly.FieldDropdown(e)],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setOutput(!0,"Number"),this.setTooltip("")}},Blockly.Ruby.operators_math_method=function(e){var t,o,n;return n=Blockly.Ruby.ORDER_FUNCTION_CALL,t=this.getFieldValue("METHOD"),o=Blockly.Ruby.valueToCode(e,"NUM",n)||"0",[t.replace(/%num%/,o),n]},Blockly.Blocks.operators_true={init:function(){return this.setHelpUrl(""),this.setColour(100),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_OPERATORS_TRUE")),this.setInputsInline(!0),this.setOutput(!0,"Boolean"),this.setTooltip("")}},Blockly.Ruby.operators_true=function(){return["true",Blockly.Ruby.ORDER_ATOMIC]},Blockly.Blocks.operators_false={init:function(){return this.setHelpUrl(""),this.setColour(100),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_OPERATORS_FALSE")),this.setInputsInline(!0),this.setOutput(!0,"Boolean"),this.setTooltip("")}},Blockly.Ruby.operators_false=function(){return["false",Blockly.Ruby.ORDER_ATOMIC]}}.call(this),function(){Blockly.Blocks.pen_down_pen={init:function(){return this.setHelpUrl(""),this.setColour(160),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_PEN_DOWN_PEN")),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.pen_down_pen=function(){return Blockly.Ruby.characterMethodCall_("down_pen")},Blockly.Blocks.pen_up_pen={init:function(){return this.setHelpUrl(""),this.setColour(160),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_PEN_UP_PEN")),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.pen_up_pen=function(){return Blockly.Ruby.characterMethodCall_("up_pen")},Blockly.Blocks.pen_set_pen_color={init:function(){return this.setHelpUrl(""),this.setColour(160),this.interpolateMsg(Smalruby.bm("BLOCKS_PEN_SET_PEN_COLOR"),["COLOUR",new Blockly.FieldColour("#ff0000")],Blockly.ALIGN_RIGHT),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.pen_set_pen_color=function(){var e,t,o,n;return t=this.getFieldValue("COLOUR"),n=parseInt(t.slice(1,3),16),o=parseInt(t.slice(3,5),16),e=parseInt(t.slice(5,7),16),Blockly.Ruby.characterSetVariable_("pen_color","["+n+", "+o+", "+e+"]")}}.call(this),function(){Blockly.Blocks.ruby_statement={init:function(){return this.setHelpUrl(""),this.setColour(340),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_RUBY_STATEMENT")).appendField(new Blockly.FieldTextInput(""),"STATEMENT"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.ruby_statement=function(){var e;return e=this.getFieldValue("STATEMENT"),""+e+"\n"
|
40
40
|
},Blockly.Blocks.ruby_expression={init:function(){return this.setHelpUrl(""),this.setColour(340),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_RUBY_EXPRESSION")).appendField(new Blockly.FieldTextInput(""),"EXP"),this.setOutput(!0,null),this.setTooltip("")}},Blockly.Ruby.ruby_expression=function(){var e;return e=this.getFieldValue("EXP"),["("+e+")",Blockly.Ruby.ORDER_ATOMIC]},Blockly.Blocks.ruby_comment={init:function(){return this.setHelpUrl(""),this.setColour(340),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_RUBY_COMMENT")).appendField(new Blockly.FieldTextInput(""),"COMMENT"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.ruby_comment=function(){var e;return e=this.getFieldValue("COMMENT"),"# "+e+"\n"},Blockly.Blocks.ruby_p={init:function(){return this.setHelpUrl(""),this.setColour(340),this.interpolateMsg(Smalruby.bm("BLOCKS_RUBY_P"),["ARG",null,Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.ruby_p=function(){var e;return e=Blockly.Ruby.valueToCode(this,"ARG",Blockly.Ruby.ORDER_NONE)||'""',"p("+e+")\n"}}.call(this),function(){$(document).ready(function(){return window.SmalrubyEditor.Sensing={KeyDropdown:[[Smalruby.bm("BLOCKS_SENSING_K_UP"),"K_UP"],[Smalruby.bm("BLOCKS_SENSING_K_DOWN"),"K_DOWN"],[Smalruby.bm("BLOCKS_SENSING_K_LEFT"),"K_LEFT"],[Smalruby.bm("BLOCKS_SENSING_K_RIGHT"),"K_RIGHT"],[Smalruby.bm("BLOCKS_SENSING_K_SPACE"),"K_SPACE"],["a","K_A"],["b","K_B"],["c","K_C"],["d","K_D"],["e","K_E"],["f","K_F"],["g","K_G"],["h","K_H"],["i","K_I"],["j","K_J"],["k","K_K"],["l","K_L"],["m","K_M"],["n","K_N"],["o","K_O"],["p","K_P"],["q","K_Q"],["r","K_R"],["s","K_S"],["t","K_T"],["u","K_U"],["v","K_V"],["w","K_W"],["x","K_X"],["y","K_Y"],["z","K_Z"],["0","K_0"],["1","K_1"],["2","K_2"],["3","K_3"],["4","K_4"],["5","K_5"],["6","K_6"],["7","K_7"],["8","K_8"],["9","K_9"]],PushOrDownDropdown:[[Smalruby.bm("BLOCKS_SENSING_PUSH"),"push"],[Smalruby.bm("BLOCKS_SENSING_HOLD_DOWN"),"down"]],MouseButtonDropdown:[[Smalruby.bm("BLOCKS_SENSING_M_LBUTTON"),"M_LBUTTON"],[Smalruby.bm("BLOCKS_SENSING_M_MBUTTON"),"M_MBUTTON"],[Smalruby.bm("BLOCKS_SENSING_M_RBUTTON"),"M_RBUTTON"]],DownOrUpDropdown:[[Smalruby.bm("BLOCKS_SENSING_DOWN"),"down"],[Smalruby.bm("BLOCKS_SENSING_UP"),"up"]],PressedOrReleasedDropdown:[[Smalruby.bm("BLOCKS_SENSING_PRESSED"),"pressed"],[Smalruby.bm("BLOCKS_SENSING_RELEASED"),"released"]]}}),Blockly.Blocks.sensing_reach_wall={init:function(){return this.setHelpUrl(""),this.setColour(190),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_SENSING_REACH_WALL")),this.setOutput(!0,"Boolean"),this.setTooltip("")}},Blockly.Ruby.sensing_reach_wall=function(){return Blockly.Ruby.characterMethodCallInput_("reach_wall?")},Blockly.Blocks.motion_reach_wall=Blockly.Blocks.sensing_reach_wall,Blockly.Ruby.motion_reach_wall=Blockly.Ruby.sensing_reach_wall,Blockly.Blocks.sensing_input_key_push_or_down={init:function(){var e,t;return e=window.SmalrubyEditor.Sensing.KeyDropdown,t=window.SmalrubyEditor.Sensing.PushOrDownDropdown,this.setHelpUrl(""),this.setColour(190),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_SENSING_INPUT_KEY_PUSH_OR_DOWN_PREFIX")).appendField(new Blockly.FieldDropdown(e),"KEY").appendField(Smalruby.bm("BLOCKS_SENSING_INPUT_KEY_PUSH_OR_DOWN_MIDDLE")).appendField(new Blockly.FieldDropdown(t),"POD").appendField(Smalruby.bm("BLOCKS_SENSING_INPUT_KEY_PUSH_OR_DOWN_SUFFIX")),this.setOutput(!0,"Boolean"),this.setTooltip("")}},Blockly.Ruby.sensing_input_key_push_or_down=function(){var e,t;return e=this.getFieldValue("KEY"),t=this.getFieldValue("POD"),["Input.key_"+t+"?("+e+")",Blockly.Ruby.ORDER_ATOMIC]},Blockly.Blocks.sensing_input_mouse_push_or_down={init:function(){var e,t;return e=window.SmalrubyEditor.Sensing.MouseButtonDropdown,t=window.SmalrubyEditor.Sensing.PushOrDownDropdown,this.setHelpUrl(""),this.setColour(190),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_SENSING_INPUT_MOUSE_PUSH_OR_DOWN_PREFIX")).appendField(new Blockly.FieldDropdown(e),"MOUSE_BUTTON").appendField(Smalruby.bm("BLOCKS_SENSING_INPUT_MOUSE_PUSH_OR_DOWN_MIDDLE")).appendField(new Blockly.FieldDropdown(t),"POD").appendField(Smalruby.bm("BLOCKS_SENSING_INPUT_MOUSE_PUSH_OR_DOWN_SUFFIX")),this.setOutput(!0,"Boolean"),this.setTooltip("")}},Blockly.Ruby.sensing_input_mouse_push_or_down=function(){var e,t;return e=this.getFieldValue("MOUSE_BUTTON"),t=this.getFieldValue("POD"),["Input.mouse_"+t+"?("+e+")",Blockly.Ruby.ORDER_ATOMIC]},Blockly.Blocks.sensing_input_mouse_pos_x={init:function(){return this.setHelpUrl(""),this.setColour(190),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_SENSING_INPUT_MOUSE_POS_X")),this.setOutput(!0,"Number"),this.setTooltip("")}},Blockly.Ruby.sensing_input_mouse_pos_x=function(){return["Input.mouse_pos_x",Blockly.Ruby.ORDER_ATOMIC]},Blockly.Blocks.sensing_input_mouse_pos_y={init:function(){return this.setHelpUrl(""),this.setColour(190),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_SENSING_INPUT_MOUSE_POS_Y")),this.setOutput(!0,"Number"),this.setTooltip("")}},Blockly.Ruby.sensing_input_mouse_pos_y=function(){return["Input.mouse_pos_y",Blockly.Ruby.ORDER_ATOMIC]},Blockly.Blocks.sensing_hit={init:function(){return this.setHelpUrl(""),this.setColour(190),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_SENSING_HIT_PREFIX")).appendField(new Smalruby.FieldCharacter,"CHAR").appendField(Smalruby.bm("BLOCKS_SENSING_HIT_SUFFIX")),this.setOutput(!0,"Boolean"),this.setTooltip("")}},Blockly.Ruby.sensing_hit=function(){var e;return e=this.getCharacterFieldValue(),Blockly.Ruby.characterMethodCallInput_("hit?",e)},Blockly.Blocks.sensing_ask={init:function(){return this.setHelpUrl(""),this.setColour(190),this.interpolateMsg("%1と聞いて待つ",["TEXT",["String"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.sensing_ask=function(){var e;return e=Blockly.Ruby.valueToCode(this,"TEXT",Blockly.Ruby.ORDER_NONE)||'""',"ask("+e+")\n"},Blockly.Blocks.sensing_answer={init:function(){return this.setHelpUrl(""),this.setColour(190),this.appendDummyInput().appendField("答え"),this.setOutput(!0,"String"),this.setTooltip("")}},Blockly.Ruby.sensing_answer=function(){return["answer",Blockly.Ruby.ORDER_ATOMIC]},Blockly.Blocks.sensing_timer_count={init:function(){return this.setHelpUrl(""),this.setColour(190),this.appendDummyInput().appendField("タイマー"),this.setOutput(!0,"Number"),this.setTooltip("")}},Blockly.Ruby.sensing_timer_count=function(){return["timer.count",Blockly.Ruby.ORDER_ATOMIC]},Blockly.Blocks.sensing_timer_reset={init:function(){return this.setHelpUrl(""),this.setColour(190),this.appendDummyInput().appendField("タイマーをリセット"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.sensing_timer_reset=function(){return"timer.reset\n"},Blockly.Blocks.sensing_character_property={init:function(){var e;return e=[[Smalruby.bm("BLOCKS_SENSING_CHARACTER_PROPERTY_X"),"x"],[Smalruby.bm("BLOCKS_SENSING_CHARACTER_PROPERTY_Y"),"y"],[Smalruby.bm("BLOCKS_SENSING_CHARACTER_PROPERTY_ANGLE"),"angle"],[Smalruby.bm("BLOCKS_SENSING_CHARACTER_PROPERTY_COSTUME_INDEX"),"costume_index"],[Smalruby.bm("BLOCKS_SENSING_CHARACTER_PROPERTY_COSTUME"),"costume"],[Smalruby.bm("BLOCKS_SENSING_CHARACTER_PROPERTY_SCALE"),"scale"],[Smalruby.bm("BLOCKS_SENSING_CHARACTER_PROPERTY_VOLUME"),"volume"]],this.setHelpUrl(""),this.setColour(190),this.interpolateMsg(Smalruby.bm("BLOCKS_SENSING_CHARACTER_PROPERTY"),["CHAR",new Smalruby.FieldCharacter],["PROPERTY",new Blockly.FieldDropdown(e)],Blockly.ALIGN_RIGHT),this.setOutput(!0,["Number","String"]),this.setTooltip("")}},Blockly.Ruby.sensing_character_property=function(){var e,t,o;return t=this.getCharacterFieldValue(),o=this.getFieldValue("PROPERTY"),e=Smalruby.Collections.CharacterSet.findWhere({name:t}),Blockly.Ruby.characterMethodCallInput_(o,null,{object:e})},Blockly.Blocks.sensing_time_now={init:function(){var e;return e=[[Smalruby.bm("BLOCKS_SENSING_TIME_NOW_YEAR"),"year"],[Smalruby.bm("BLOCKS_SENSING_TIME_NOW_MONTH"),"month"],[Smalruby.bm("BLOCKS_SENSING_TIME_NOW_DAY"),"day"],[Smalruby.bm("BLOCKS_SENSING_TIME_NOW_WDAY"),"wday"],[Smalruby.bm("BLOCKS_SENSING_TIME_NOW_HOUR"),"hour"],[Smalruby.bm("BLOCKS_SENSING_TIME_NOW_MIN"),"min"],[Smalruby.bm("BLOCKS_SENSING_TIME_NOW_SEC"),"sec"]],this.setHelpUrl(""),this.setColour(190),this.interpolateMsg(Smalruby.bm("BLOCKS_SENSING_TIME_NOW"),["METHOD",new Blockly.FieldDropdown(e)],Blockly.ALIGN_RIGHT),this.setOutput(!0,"Number"),this.setTooltip("")}},Blockly.Ruby.sensing_time_now=function(){var e;return e=this.getFieldValue("METHOD"),["Time.now."+e,Blockly.Ruby.ORDER_ATOMIC]},Blockly.Blocks.sensing_days_since_2000={init:function(){return this.setHelpUrl(""),this.setColour(190),this.appendDummyInput().appendField(Smalruby.bm("BLOCKS_SENSING_DAYS_SINCE_2000")),this.setOutput(!0,"Number"),this.setTooltip("")}},Blockly.Ruby.sensing_days_since_2000=function(){return["(Time.now - Time.mktime(2000, 1, 1)).to_i / 1.day",Blockly.Ruby.ORDER_ATOMIC]}}.call(this),function(){Blockly.Blocks.sound_preset_sounds={init:function(){var e;return e=[[Smalruby.bm("BLOCKS_SOUND_PRESET_SOUNDS_PIANO_DO"),"piano_do.wav"],[Smalruby.bm("BLOCKS_SOUND_PRESET_SOUNDS_PIANO_RE"),"piano_re.wav"],[Smalruby.bm("BLOCKS_SOUND_PRESET_SOUNDS_PIANO_MI"),"piano_mi.wav"],[Smalruby.bm("BLOCKS_SOUND_PRESET_SOUNDS_PIANO_FA"),"piano_fa.wav"],[Smalruby.bm("BLOCKS_SOUND_PRESET_SOUNDS_PIANO_SO"),"piano_so.wav"],[Smalruby.bm("BLOCKS_SOUND_PRESET_SOUNDS_PIANO_RA"),"piano_ra.wav"],[Smalruby.bm("BLOCKS_SOUND_PRESET_SOUNDS_PIANO_SI"),"piano_si.wav"],[Smalruby.bm("BLOCKS_SOUND_PRESET_SOUNDS_PIANO_DO_2"),"piano_do_2.wav"]],this.setHelpUrl(""),this.setColour(300),this.interpolateMsg(Smalruby.bm("BLOCKS_SOUND_PRESET_SOUNDS"),["NAME",new Blockly.FieldDropdown(e)],Blockly.ALIGN_RIGHT),this.setOutput(!0,"String"),this.setTooltip("")}},Blockly.Ruby.sound_preset_sounds=function(){var e;return e=Blockly.Ruby.quote_(this.getFieldValue("NAME")),[e,Blockly.Ruby.ORDER_ATOMIC]},Blockly.Blocks.sound_play={init:function(){return this.setHelpUrl(""),this.setColour(300),this.interpolateMsg(Smalruby.bm("BLOCKS_SOUND_PLAY"),["NAME",["String"],Blockly.ALIGN_RIGHT],Blockly.ALIGN_RIGHT),this.setInputsInline(!0),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.sound_play=function(){var e;return e=Blockly.Ruby.valueToCode(this,"NAME",Blockly.Ruby.ORDER_NONE)||"",Blockly.Ruby.characterMethodCall_("play","name: "+e)},Blockly.Blocks.sound_stop={init:function(){return this.setHelpUrl(""),this.setColour(300),this.appendDummyInput().appendField("すべての音を止める"),this.setPreviousStatement(!0),this.setNextStatement(!0),this.setTooltip("")}},Blockly.Ruby.sound_stop=function(){return"stop\n"},Blockly.Blocks.sound_volume={init:function(){return this.setHelpUrl(""),this.setColour(300),this.appendDummyInput().appendField("ボリューム"),this.setOutput(!0,"Number"),this.setTooltip("")}},Blockly.Ruby.sound_volume=function(){return["volume",Blockly.Ruby.ORDER_ATOMIC]}}.call(this);
|
Binary file
|
@@ -1 +1 @@
|
|
1
|
-
{"files":{"favicon-d958ba1d3efbea2e9a10fda1b5970b6c.ico":{"logical_path":"favicon.ico","mtime":"2014-12-02T18:24:29+09:00","size":5430,"digest":"d958ba1d3efbea2e9a10fda1b5970b6c"},"application-
|
1
|
+
{"files":{"favicon-d958ba1d3efbea2e9a10fda1b5970b6c.ico":{"logical_path":"favicon.ico","mtime":"2014-12-02T18:24:29+09:00","size":5430,"digest":"d958ba1d3efbea2e9a10fda1b5970b6c"},"application-f411d2bebfcc93a4e8ac20b19af2fafd.js":{"logical_path":"application.js","mtime":"2015-06-01T19:19:29+09:00","size":1323166,"digest":"f411d2bebfcc93a4e8ac20b19af2fafd"},"msg/en_us-a98cc83805d44f5f675fe6eac2c955ec.js":{"logical_path":"msg/en_us.js","mtime":"2015-05-20T11:03:43+09:00","size":15017,"digest":"a98cc83805d44f5f675fe6eac2c955ec"},"msg/ja-243b0a55ef1086ef2180af94c422cb5e.js":{"logical_path":"msg/ja.js","mtime":"2015-05-20T11:03:43+09:00","size":17584,"digest":"243b0a55ef1086ef2180af94c422cb5e"},"application-f879948b97a781e3d996535a2a0585fa.css":{"logical_path":"application.css","mtime":"2015-05-20T11:03:43+09:00","size":94538,"digest":"f879948b97a781e3d996535a2a0585fa"},"blockly/msg/js/en_us-d5e1938b2d57c1df954f4411b9165d10.js":{"logical_path":"blockly/msg/js/en_us.js","mtime":"2015-05-20T03:21:50+09:00","size":25865,"digest":"d5e1938b2d57c1df954f4411b9165d10"},"blockly/msg/js/ja-16b694632120c3d1ace214702c6ea413.js":{"logical_path":"blockly/msg/js/ja.js","mtime":"2015-05-20T11:03:43+09:00","size":31354,"digest":"16b694632120c3d1ace214702c6ea413"},"jquery-ui/animated-overlay-9b629ab5247187e831ea51106acdf03a.gif":{"logical_path":"jquery-ui/animated-overlay.gif","mtime":"2015-01-11T23:15:23+09:00","size":1738,"digest":"9b629ab5247187e831ea51106acdf03a"},"jquery-ui/ui-bg_flat_0_aaaaaa_40x100-e055bc219bd3aed111713c2ef884d6f4.png":{"logical_path":"jquery-ui/ui-bg_flat_0_aaaaaa_40x100.png","mtime":"2015-01-11T23:15:23+09:00","size":180,"digest":"e055bc219bd3aed111713c2ef884d6f4"},"jquery-ui/ui-bg_flat_75_ffffff_40x100-1ed964fd6a424fc2d8653d5a64705840.png":{"logical_path":"jquery-ui/ui-bg_flat_75_ffffff_40x100.png","mtime":"2015-01-11T23:15:23+09:00","size":178,"digest":"1ed964fd6a424fc2d8653d5a64705840"},"jquery-ui/ui-bg_glass_55_fbf9ee_1x400-c47b4313972b0311e02e671fd15a66c9.png":{"logical_path":"jquery-ui/ui-bg_glass_55_fbf9ee_1x400.png","mtime":"2015-01-11T23:15:23+09:00","size":120,"digest":"c47b4313972b0311e02e671fd15a66c9"},"jquery-ui/ui-bg_glass_65_ffffff_1x400-4b5173f329e3e9fbfcfcc88a84920e81.png":{"logical_path":"jquery-ui/ui-bg_glass_65_ffffff_1x400.png","mtime":"2015-01-11T23:15:23+09:00","size":105,"digest":"4b5173f329e3e9fbfcfcc88a84920e81"},"jquery-ui/ui-bg_glass_75_dadada_1x400-b0155cdc12d3bcdfa7f4890938366181.png":{"logical_path":"jquery-ui/ui-bg_glass_75_dadada_1x400.png","mtime":"2015-01-11T23:15:23+09:00","size":111,"digest":"b0155cdc12d3bcdfa7f4890938366181"},"jquery-ui/ui-bg_glass_75_e6e6e6_1x400-21014afa81b0fea76840432b22d9d0e5.png":{"logical_path":"jquery-ui/ui-bg_glass_75_e6e6e6_1x400.png","mtime":"2015-01-11T23:15:23+09:00","size":110,"digest":"21014afa81b0fea76840432b22d9d0e5"},"jquery-ui/ui-bg_glass_95_fef1ec_1x400-6526cba95388d3f36f03cc6296f192b5.png":{"logical_path":"jquery-ui/ui-bg_glass_95_fef1ec_1x400.png","mtime":"2015-01-11T23:15:23+09:00","size":119,"digest":"6526cba95388d3f36f03cc6296f192b5"},"jquery-ui/ui-bg_highlight-soft_75_cccccc_1x100-f0e42cc2ef6523f77aa730753cff0462.png":{"logical_path":"jquery-ui/ui-bg_highlight-soft_75_cccccc_1x100.png","mtime":"2015-01-11T23:15:23+09:00","size":101,"digest":"f0e42cc2ef6523f77aa730753cff0462"},"jquery-ui/ui-icons_222222_256x240-d5b2a50ddba8e90f9487cc29efbc9080.png":{"logical_path":"jquery-ui/ui-icons_222222_256x240.png","mtime":"2015-01-11T23:15:23+09:00","size":4369,"digest":"d5b2a50ddba8e90f9487cc29efbc9080"},"jquery-ui/ui-icons_2e83ff_256x240-735b447c0a9f42ce6836a1e74aad6f23.png":{"logical_path":"jquery-ui/ui-icons_2e83ff_256x240.png","mtime":"2015-01-11T23:15:23+09:00","size":4369,"digest":"735b447c0a9f42ce6836a1e74aad6f23"},"jquery-ui/ui-icons_454545_256x240-ed3057724414ea20ff7bae1cdb644aca.png":{"logical_path":"jquery-ui/ui-icons_454545_256x240.png","mtime":"2015-01-11T23:15:23+09:00","size":4369,"digest":"ed3057724414ea20ff7bae1cdb644aca"},"jquery-ui/ui-icons_888888_256x240-ce584ffa171c3ea9a018cf0d7bec65c8.png":{"logical_path":"jquery-ui/ui-icons_888888_256x240.png","mtime":"2015-01-11T23:15:23+09:00","size":4369,"digest":"ce584ffa171c3ea9a018cf0d7bec65c8"},"jquery-ui/ui-icons_cd0a0a_256x240-747e96029e8dedcabc224e5f7d1f2ede.png":{"logical_path":"jquery-ui/ui-icons_cd0a0a_256x240.png","mtime":"2015-01-11T23:15:23+09:00","size":4369,"digest":"747e96029e8dedcabc224e5f7d1f2ede"},"loading-e77296be32d066d3e29d3bf9803fa417.gif":{"logical_path":"loading.gif","mtime":"2015-05-13T15:34:45+09:00","size":3897,"digest":"e77296be32d066d3e29d3bf9803fa417"},"progressbar-ee8fb1222f286f625bbf7332844a6a0c.gif":{"logical_path":"progressbar.gif","mtime":"2015-05-13T15:34:45+09:00","size":3323,"digest":"ee8fb1222f286f625bbf7332844a6a0c"}},"assets":{"favicon.ico":"favicon-d958ba1d3efbea2e9a10fda1b5970b6c.ico","application.js":"application-f411d2bebfcc93a4e8ac20b19af2fafd.js","msg/en_us.js":"msg/en_us-a98cc83805d44f5f675fe6eac2c955ec.js","msg/ja.js":"msg/ja-243b0a55ef1086ef2180af94c422cb5e.js","application.css":"application-f879948b97a781e3d996535a2a0585fa.css","blockly/msg/js/en_us.js":"blockly/msg/js/en_us-d5e1938b2d57c1df954f4411b9165d10.js","blockly/msg/js/ja.js":"blockly/msg/js/ja-16b694632120c3d1ace214702c6ea413.js","jquery-ui/animated-overlay.gif":"jquery-ui/animated-overlay-9b629ab5247187e831ea51106acdf03a.gif","jquery-ui/ui-bg_flat_0_aaaaaa_40x100.png":"jquery-ui/ui-bg_flat_0_aaaaaa_40x100-e055bc219bd3aed111713c2ef884d6f4.png","jquery-ui/ui-bg_flat_75_ffffff_40x100.png":"jquery-ui/ui-bg_flat_75_ffffff_40x100-1ed964fd6a424fc2d8653d5a64705840.png","jquery-ui/ui-bg_glass_55_fbf9ee_1x400.png":"jquery-ui/ui-bg_glass_55_fbf9ee_1x400-c47b4313972b0311e02e671fd15a66c9.png","jquery-ui/ui-bg_glass_65_ffffff_1x400.png":"jquery-ui/ui-bg_glass_65_ffffff_1x400-4b5173f329e3e9fbfcfcc88a84920e81.png","jquery-ui/ui-bg_glass_75_dadada_1x400.png":"jquery-ui/ui-bg_glass_75_dadada_1x400-b0155cdc12d3bcdfa7f4890938366181.png","jquery-ui/ui-bg_glass_75_e6e6e6_1x400.png":"jquery-ui/ui-bg_glass_75_e6e6e6_1x400-21014afa81b0fea76840432b22d9d0e5.png","jquery-ui/ui-bg_glass_95_fef1ec_1x400.png":"jquery-ui/ui-bg_glass_95_fef1ec_1x400-6526cba95388d3f36f03cc6296f192b5.png","jquery-ui/ui-bg_highlight-soft_75_cccccc_1x100.png":"jquery-ui/ui-bg_highlight-soft_75_cccccc_1x100-f0e42cc2ef6523f77aa730753cff0462.png","jquery-ui/ui-icons_222222_256x240.png":"jquery-ui/ui-icons_222222_256x240-d5b2a50ddba8e90f9487cc29efbc9080.png","jquery-ui/ui-icons_2e83ff_256x240.png":"jquery-ui/ui-icons_2e83ff_256x240-735b447c0a9f42ce6836a1e74aad6f23.png","jquery-ui/ui-icons_454545_256x240.png":"jquery-ui/ui-icons_454545_256x240-ed3057724414ea20ff7bae1cdb644aca.png","jquery-ui/ui-icons_888888_256x240.png":"jquery-ui/ui-icons_888888_256x240-ce584ffa171c3ea9a018cf0d7bec65c8.png","jquery-ui/ui-icons_cd0a0a_256x240.png":"jquery-ui/ui-icons_cd0a0a_256x240-747e96029e8dedcabc224e5f7d1f2ede.png","loading.gif":"loading-e77296be32d066d3e29d3bf9803fa417.gif","progressbar.gif":"progressbar-ee8fb1222f286f625bbf7332844a6a0c.gif"}}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smalruby-editor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: x86-mingw32
|
6
6
|
authors:
|
7
7
|
- Kouji Takao
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -469,8 +469,8 @@ files:
|
|
469
469
|
- public/422.html
|
470
470
|
- public/500.html
|
471
471
|
- public/apple-touch-icon.png
|
472
|
-
- public/assets/application-
|
473
|
-
- public/assets/application-
|
472
|
+
- public/assets/application-f411d2bebfcc93a4e8ac20b19af2fafd.js
|
473
|
+
- public/assets/application-f411d2bebfcc93a4e8ac20b19af2fafd.js.gz
|
474
474
|
- public/assets/application-f879948b97a781e3d996535a2a0585fa.css
|
475
475
|
- public/assets/application-f879948b97a781e3d996535a2a0585fa.css.gz
|
476
476
|
- public/assets/blockly/msg/js/en_us-d5e1938b2d57c1df954f4411b9165d10.js
|
@@ -493,7 +493,7 @@ files:
|
|
493
493
|
- public/assets/jquery-ui/ui-icons_888888_256x240-ce584ffa171c3ea9a018cf0d7bec65c8.png
|
494
494
|
- public/assets/jquery-ui/ui-icons_cd0a0a_256x240-747e96029e8dedcabc224e5f7d1f2ede.png
|
495
495
|
- public/assets/loading-e77296be32d066d3e29d3bf9803fa417.gif
|
496
|
-
- public/assets/manifest-
|
496
|
+
- public/assets/manifest-ffc1bf227b15208b38f552b56f9f8c04.json
|
497
497
|
- public/assets/msg/en_us-a98cc83805d44f5f675fe6eac2c955ec.js
|
498
498
|
- public/assets/msg/en_us-a98cc83805d44f5f675fe6eac2c955ec.js.gz
|
499
499
|
- public/assets/msg/ja-243b0a55ef1086ef2180af94c422cb5e.js
|