smalruby-editor 0.3.2 → 0.3.3
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/fix_blockly.js.erb +13 -0
- data/app/assets/javascripts/views/signin_modal_view.js.coffee.erb +5 -0
- data/app/models/concerns/ruby_to_block/block.rb +22 -20
- data/app/models/preference.rb +7 -4
- data/lib/smalruby_editor/version.rb +1 -1
- data/public/assets/{application-d994c5cb05da6b9c674f86f27d48f991.js → application-35b1374d4d6717b94196f5c3f66db1a9.js} +4 -4
- data/public/assets/{application-d994c5cb05da6b9c674f86f27d48f991.js.gz → application-35b1374d4d6717b94196f5c3f66db1a9.js.gz} +0 -0
- data/public/assets/{manifest-09b9c583b55684372f2cf9fa635e4e2e.json → manifest-fad4a04f58abb204f6d35a9845835730.json} +1 -1
- data/spec/acceptance/standalone/signin.feature +17 -17
- data/spec/spec_helper.rb +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: bebbdfc696647df696d8ec217759b1bc129bf4f2
|
4
|
+
data.tar.gz: 09eff85af4fed47c11821137239d08bf2ef29d44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d562109fc5cfcc2b1fb159b59cf90dde5bb47c1f94703e4f31586ee5d7eec2ba18572d5673f8375838359b22910d984dbcac85c6fcc1e88190f296a8c65500fb
|
7
|
+
data.tar.gz: bb1350a0a5b035e17c5e44c144d0844d9b5355cad1af8bc441a864272cfafd2812eea71aa048ad9b83110d6a9441dc27b6a2647b6c52b32ba00ea5750c32cc59
|
@@ -53,3 +53,16 @@ Blockly.Names.prototype.safeName_ = function(name) {
|
|
53
53
|
}
|
54
54
|
return name;
|
55
55
|
};
|
56
|
+
|
57
|
+
// blockly/core/inject.js
|
58
|
+
Blockly._init_ = Blockly.init_;
|
59
|
+
Blockly.init_ = function(mainWorkspace) {
|
60
|
+
Blockly._init_(mainWorkspace);
|
61
|
+
|
62
|
+
Blockly.bindEvent_(Blockly.WidgetDiv.DIV, 'contextmenu', null,
|
63
|
+
function(e) {
|
64
|
+
if (!Blockly.isTargetInput_(e)) {
|
65
|
+
e.preventDefault();
|
66
|
+
}
|
67
|
+
});
|
68
|
+
};
|
@@ -13,6 +13,11 @@ Smalruby.SigninModalView = Backbone.View.extend
|
|
13
13
|
@$el.on 'shown', =>
|
14
14
|
@$el.find('#signin-modal-username')
|
15
15
|
.focus()
|
16
|
+
@$el.on 'hidden', =>
|
17
|
+
# HACK: IE11において、ログイン後に操作できなくなる問題が発生した。
|
18
|
+
# 原因はダイアログの背景(.modal-backdrop)が消えないことである。
|
19
|
+
# 以下はそれを回避するための処理である。
|
20
|
+
$('.modal-backdrop').remove();
|
16
21
|
|
17
22
|
render: ->
|
18
23
|
@$el.find('#signin-modal-username')
|
@@ -70,28 +70,30 @@ module RubyToBlock
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
}
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
73
|
+
if Rails.env.development? || Rails.env.test?
|
74
|
+
preloads = %w(
|
75
|
+
base
|
76
|
+
value
|
77
|
+
character_operation
|
78
|
+
character_method_call
|
79
|
+
character_event
|
80
|
+
).map { |s|
|
81
|
+
"#{s}.rb"
|
82
|
+
}
|
83
|
+
preloads.each do |preload|
|
84
|
+
path = Pathname(__FILE__).dirname.join('block', preload)
|
85
|
+
silence_warnings do
|
86
|
+
load path.expand_path
|
87
|
+
end
|
86
88
|
end
|
87
|
-
end
|
88
89
|
|
89
|
-
block_pattern = Pathname(__FILE__).dirname.join('block', '*.rb')
|
90
|
-
block_files = Pathname.glob(block_pattern)
|
91
|
-
block_files.each do |path|
|
92
|
-
|
90
|
+
block_pattern = Pathname(__FILE__).dirname.join('block', '*.rb')
|
91
|
+
block_files = Pathname.glob(block_pattern)
|
92
|
+
block_files.each do |path|
|
93
|
+
next if preloads.include?(path.basename)
|
93
94
|
|
94
|
-
|
95
|
-
|
95
|
+
silence_warnings do
|
96
|
+
load path.expand_path
|
97
|
+
end
|
96
98
|
end
|
97
99
|
end
|
data/app/models/preference.rb
CHANGED
@@ -59,14 +59,17 @@ class Preference < Settingslogic
|
|
59
59
|
private
|
60
60
|
|
61
61
|
def make_defaults(preference_names)
|
62
|
-
|
62
|
+
res = {}
|
63
|
+
preference_names.each do |n|
|
63
64
|
case n
|
64
65
|
when BOOLEAN_FIELD_REGEXP
|
65
|
-
|
66
|
+
val = false
|
66
67
|
else
|
67
|
-
|
68
|
+
val = ""
|
68
69
|
end
|
69
|
-
|
70
|
+
res[n] = val
|
71
|
+
end
|
72
|
+
res
|
70
73
|
end
|
71
74
|
end
|
72
75
|
|
@@ -32,9 +32,9 @@ goog.isString(e)?(this.warning||(this.warning=new Blockly.Warning(this),o=!0),th
|
|
32
32
|
t&&-1==e.indexOf(t)&&e.push(t),e.sort(goog.string.caseInsensitiveCompare),e.push(Blockly.Msg.RENAME_VARIABLE),e.push(Blockly.Msg.NEW_VARIABLE);for(var t=[],o=0;o<e.length;o++)t[o]=[e[o],e[o]];return t},Blockly.FieldVariable.dropdownChange=function(e){function t(e,t){Blockly.hideChaff();var o=window.prompt(e,t);return o&&(o=o.replace(/[\s\xa0]+/g," ").replace(/^ | $/g,""),o==Blockly.Msg.RENAME_VARIABLE||o==Blockly.Msg.NEW_VARIABLE)&&(o=null),o}var o=this.sourceBlock_.workspace;if(e==Blockly.Msg.RENAME_VARIABLE){var n=this.getText();return(e=t(Blockly.Msg.RENAME_VARIABLE_TITLE.replace("%1",n),n))&&Blockly.Variables.renameVariable(n,e,o),null}return e==Blockly.Msg.NEW_VARIABLE?(e=t(Blockly.Msg.NEW_VARIABLE_TITLE,""))?(Blockly.Variables.renameVariable(e,e,o),e):null:void 0},Blockly.Generator=function(e){this.name_=e,this.RESERVED_WORDS_="",this.FUNCTION_NAME_PLACEHOLDER_REGEXP_=new RegExp(this.FUNCTION_NAME_PLACEHOLDER_,"g")},Blockly.Generator.NAME_TYPE="generated_function",Blockly.Generator.prototype.INFINITE_LOOP_TRAP=null,Blockly.Generator.prototype.STATEMENT_PREFIX=null,Blockly.Generator.prototype.workspaceToCode=function(e){e||(console.warn("No workspace specified in workspaceToCode call. Guessing."),e=Blockly.getMainWorkspace());var t=[];this.init(e),e=e.getTopBlocks(!0);for(var o,n=0;o=e[n];n++){var i=this.blockToCode(o);goog.isArray(i)&&(i=i[0]),i&&(o.outputConnection&&this.scrubNakedValue&&(i=this.scrubNakedValue(i)),t.push(i))}return t=t.join("\n"),t=this.finish(t),t=t.replace(/^\s+\n/,""),t=t.replace(/\n\s+$/,"\n"),t=t.replace(/[ \t]+\n/g,"\n")},Blockly.Generator.prototype.prefixLines=function(e,t){return t+e.replace(/\n(.)/g,"\n"+t+"$1")},Blockly.Generator.prototype.allNestedComments=function(e){var t=[];e=e.getDescendants();for(var o=0;o<e.length;o++){var n=e[o].getCommentText();n&&t.push(n)}return t.length&&t.push(""),t.join("\n")},Blockly.Generator.prototype.blockToCode=function(e){if(!e)return"";if(e.disabled)return this.blockToCode(e.getNextBlock());var t=this[e.type];if(!t)throw'Language "'+this.name_+'" does not know how to generate code for block type "'+e.type+'".';if(t=t.call(e,e),goog.isArray(t))return[this.scrub_(e,t[0]),t[1]];if(goog.isString(t))return this.STATEMENT_PREFIX&&(t=this.STATEMENT_PREFIX.replace(/%1/g,"'"+e.id+"'")+t),this.scrub_(e,t);if(null===t)return"";throw"Invalid code generated: "+t},Blockly.Generator.prototype.valueToCode=function(e,t,o){if(isNaN(o))throw'Expecting valid order from block "'+e.type+'".';if(e=e.getInputTargetBlock(t),!e)return"";var n=this.blockToCode(e);if(""===n)return"";if(!goog.isArray(n))throw'Expecting tuple from value block "'+e.type+'".';if(t=n[0],n=n[1],isNaN(n))throw'Expecting valid order from value block "'+e.type+'".';return t&&n>=o&&(o!=n||0!=o&&99!=o)&&(t="("+t+")"),t},Blockly.Generator.prototype.statementToCode=function(e,t){var o=e.getInputTargetBlock(t),n=this.blockToCode(o);if(!goog.isString(n))throw'Expecting code from statement block "'+o.type+'".';return n&&(n=this.prefixLines(n,this.INDENT)),n},Blockly.Generator.prototype.addLoopTrap=function(e,t){return this.INFINITE_LOOP_TRAP&&(e=this.INFINITE_LOOP_TRAP.replace(/%1/g,"'"+t+"'")+e),this.STATEMENT_PREFIX&&(e+=this.prefixLines(this.STATEMENT_PREFIX.replace(/%1/g,"'"+t+"'"),this.INDENT)),e},Blockly.Generator.prototype.INDENT=" ",Blockly.Generator.prototype.addReservedWords=function(e){this.RESERVED_WORDS_+=e+","},Blockly.Generator.prototype.FUNCTION_NAME_PLACEHOLDER_="{leCUI8hutHZI4480Dc}",Blockly.Generator.prototype.provideFunction_=function(e,t){if(!this.definitions_[e]){var o=this.variableDB_.getDistinctName(e,this.NAME_TYPE);this.functionNames_[e]=o,this.definitions_[e]=t.join("\n").replace(this.FUNCTION_NAME_PLACEHOLDER_REGEXP_,o)}return this.functionNames_[e]},Blockly.Names=function(e){if(this.reservedDict_=Object.create(null),e){e=e.split(",");for(var t=0;t<e.length;t++)this.reservedDict_[e[t]]=!0}this.reset()},Blockly.Names.prototype.reset=function(){this.db_=Object.create(null),this.dbReverse_=Object.create(null)},Blockly.Names.prototype.getName=function(e,t){var o=e.toLowerCase()+"_"+t;if(o in this.db_)return this.db_[o];var n=this.getDistinctName(e,t);return this.db_[o]=n},Blockly.Names.prototype.getDistinctName=function(e){for(var t=this.safeName_(e),o="";this.dbReverse_[t+o]||t+o in this.reservedDict_;)o=o?o+1:2;return t+=o,this.dbReverse_[t]=!0,t},Blockly.Names.prototype.safeName_=function(e){return e?(e=encodeURI(e.replace(/ /g,"_")).replace(/[^\w]/g,"_"),-1!="0123456789".indexOf(e[0])&&(e="my_"+e)):e="unnamed",e},Blockly.Names.equals=function(e,t){return e.toLowerCase()==t.toLowerCase()},Blockly.Procedures={},Blockly.Procedures.NAME_TYPE="PROCEDURE",Blockly.Procedures.allProcedures=function(e){e=e.getAllBlocks();for(var t=[],o=[],n=0;n<e.length;n++){var i=e[n].getProcedureDef;i&&(i=i.call(e[n]))&&(i[2]?t.push(i):o.push(i))}return o.sort(Blockly.Procedures.procTupleComparator_),t.sort(Blockly.Procedures.procTupleComparator_),[o,t]},Blockly.Procedures.procTupleComparator_=function(e,t){var o=e[0].toLowerCase(),n=t[0].toLowerCase();return o>n?1:n>o?-1:0},Blockly.Procedures.findLegalName=function(e,t){if(t.isInFlyout)return e;for(;!Blockly.Procedures.isLegalName(e,t.workspace,t);){var o=e.match(/^(.*?)(\d+)$/);e=o?o[1]+(parseInt(o[2],10)+1):e+"2"}return e},Blockly.Procedures.isLegalName=function(e,t,o){t=t.getAllBlocks();for(var n=0;n<t.length;n++)if(t[n]!=o){var i=t[n].getProcedureDef;if(i&&(i=i.call(t[n]),Blockly.Names.equals(i[0],e)))return!1}return!0},Blockly.Procedures.rename=function(e){e=e.replace(/^[\s\xa0]+|[\s\xa0]+$/g,""),e=Blockly.Procedures.findLegalName(e,this.sourceBlock_);for(var t=this.sourceBlock_.workspace.getAllBlocks(),o=0;o<t.length;o++){var n=t[o].renameProcedure;n&&n.call(t[o],this.text_,e)}return e},Blockly.Procedures.flyoutCategory=function(e,t,o,n){function i(i,r){for(var s=0;s<i.length;s++){var l=Blockly.Block.obtain(n,r);l.setFieldValue(i[s][0],"NAME");for(var a=[],c=0;c<i[s][1].length;c++)a[c]="ARG"+c;l.setProcedureParameters(i[s][1],a),l.initSvg(),e.push(l),t.push(2*o)}}if(Blockly.Blocks.procedures_defnoreturn){var r=Blockly.Block.obtain(n,"procedures_defnoreturn");r.initSvg(),e.push(r),t.push(2*o)}Blockly.Blocks.procedures_defreturn&&(r=Blockly.Block.obtain(n,"procedures_defreturn"),r.initSvg(),e.push(r),t.push(2*o)),Blockly.Blocks.procedures_ifreturn&&(r=Blockly.Block.obtain(n,"procedures_ifreturn"),r.initSvg(),e.push(r),t.push(2*o)),t.length&&(t[t.length-1]=3*o),r=Blockly.Procedures.allProcedures(n.targetWorkspace),i(r[0],"procedures_callnoreturn"),i(r[1],"procedures_callreturn")},Blockly.Procedures.getCallers=function(e,t){for(var o=[],n=t.getAllBlocks(),i=0;i<n.length;i++){var r=n[i].getProcedureCall;r&&(r=r.call(n[i]))&&Blockly.Names.equals(r,e)&&o.push(n[i])}return o},Blockly.Procedures.disposeCallers=function(e,t){for(var o=Blockly.Procedures.getCallers(e,t),n=0;n<o.length;n++)o[n].dispose(!0,!1)},Blockly.Procedures.mutateCallers=function(e,t,o,n){for(e=Blockly.Procedures.getCallers(e,t),t=0;t<e.length;t++)e[t].setProcedureParameters(o,n)},Blockly.Procedures.getDefinition=function(e,t){for(var o=t.getAllBlocks(),n=0;n<o.length;n++){var i=o[n].getProcedureDef;if(i&&(i=i.call(o[n]))&&Blockly.Names.equals(i[0],e))return o[n]}return null};var rtclient={INSTALL_SCOPE:"https://www.googleapis.com/auth/drive.install",FILE_SCOPE:"https://www.googleapis.com/auth/drive.file",APPDATA_SCOPE:"https://www.googleapis.com/auth/drive.appdata",OPENID_SCOPE:"openid",REALTIME_MIMETYPE:"application/vnd.google-apps.drive-sdk",FOLDER_KEY:"folderId",getParams:function(){function e(e){e=e.slice(1).split("&");for(var t=0;t<e.length;t++){var n=e[t].split("=");o[decodeURIComponent(n[0])]=decodeURIComponent(n[1])}}var t=goog.global.location||{},o={},n=t.hash;return n&&e(n),(t=t.search)&&e(t),o}};rtclient.params=rtclient.getParams(),rtclient.getOption=function(e,t,o){return e.hasOwnProperty(t)?e[t]:(void 0===o&&console.error(t+" should be present in the options."),o)},rtclient.Authorizer=function(e){this.clientId=rtclient.getOption(e,"clientId"),this.userId=rtclient.params.userId,this.authButton=document.getElementById(rtclient.getOption(e,"authButtonElementId")),this.authDiv=document.getElementById(rtclient.getOption(e,"authDivElementId"))},rtclient.Authorizer.prototype.start=function(e){var t=this;gapi.load("auth:client,drive-realtime,drive-share",function(){t.authorize(e)})},rtclient.Authorizer.prototype.authorize=function(e){var t=this.clientId,o=this.userId,n=this,i=function(t){t&&!t.error?(n.authButton.disabled=!0,n.fetchUserId(e),n.authDiv.style.display="none"):(n.authButton.disabled=!1,n.authButton.onclick=r,n.authDiv.style.display="block")},r=function(){gapi.auth.authorize({client_id:t,scope:[rtclient.INSTALL_SCOPE,rtclient.FILE_SCOPE,rtclient.OPENID_SCOPE,rtclient.APPDATA_SCOPE],user_id:o,immediate:!1},i)};gapi.auth.authorize({client_id:t,scope:[rtclient.INSTALL_SCOPE,rtclient.FILE_SCOPE,rtclient.OPENID_SCOPE,rtclient.APPDATA_SCOPE],user_id:o,immediate:!0},i)},rtclient.Authorizer.prototype.fetchUserId=function(e){var t=this;gapi.client.load("oauth2","v2",function(){gapi.client.oauth2.userinfo.get().execute(function(o){o.id&&(t.userId=o.id),e&&e()})})},rtclient.createRealtimeFile=function(e,t,o,n){function i(o){gapi.client.drive.files.insert({resource:{mimeType:t,title:e,parents:[{id:o}]}}).execute(n)}function r(){function e(e){gapi.client.drive.properties.insert({fileId:"appdata",resource:{key:rtclient.FOLDER_KEY,value:e}}).execute(function(){i(e)})}function t(){gapi.client.drive.files.insert({resource:{mimeType:"application/vnd.google-apps.folder",title:o}}).execute(function(t){e(t.id)})}gapi.client.drive.properties.get({fileId:"appdata",propertyKey:rtclient.FOLDER_KEY}).execute(function(n){if(n.error)o?t():e("root");else{var r=n.result.value;gapi.client.drive.files.get({fileId:r}).execute(function(e){e.error||e.labels.trashed?t():i(r)})}})}gapi.client.load("drive","v2",function(){r()})},rtclient.getFileMetadata=function(e,t){gapi.client.load("drive","v2",function(){gapi.client.drive.files.get({fileId:e}).execute(t)})},rtclient.parseState=function(e){try{return JSON.parse(e)}catch(t){return null}},rtclient.RealtimeLoader=function(e){this.onFileLoaded=rtclient.getOption(e,"onFileLoaded"),this.newFileMimeType=rtclient.getOption(e,"newFileMimeType",rtclient.REALTIME_MIMETYPE),this.initializeModel=rtclient.getOption(e,"initializeModel"),this.registerTypes=rtclient.getOption(e,"registerTypes",function(){}),this.afterAuth=rtclient.getOption(e,"afterAuth",function(){}),this.autoCreate=rtclient.getOption(e,"autoCreate",!1),this.defaultTitle=rtclient.getOption(e,"defaultTitle","New Realtime File"),this.defaultFolderTitle=rtclient.getOption(e,"defaultFolderTitle",""),this.afterCreate=rtclient.getOption(e,"afterCreate",function(){}),this.authorizer=new rtclient.Authorizer(e)},rtclient.RealtimeLoader.prototype.redirectTo=function(e,t){var o=[];e&&o.push("fileIds="+e.join(",")),t&&o.push("userId="+t),o=0==o.length?window.location.pathname:window.location.pathname+"#"+o.join("&"),window.history&&window.history.replaceState?window.history.replaceState("Google Drive Realtime API Playground","Google Drive Realtime API Playground",o):window.location.href=o,rtclient.params=rtclient.getParams();for(var n in e)gapi.drive.realtime.load(e[n],this.onFileLoaded,this.initializeModel,this.handleErrors)},rtclient.RealtimeLoader.prototype.start=function(){var e=this;this.authorizer.start(function(){e.registerTypes&&e.registerTypes(),e.afterAuth&&e.afterAuth(),e.load()})},rtclient.RealtimeLoader.prototype.handleErrors=function(e){e.type==gapi.drive.realtime.ErrorType.TOKEN_REFRESH_REQUIRED?this.authorizer.authorize():e.type==gapi.drive.realtime.ErrorType.CLIENT_ERROR?(alert("An Error happened: "+e.message),window.location.href="/"):e.type==gapi.drive.realtime.ErrorType.NOT_FOUND&&(alert("The file was not found. It does not exist or you do not have read access to the file."),window.location.href="/")},rtclient.RealtimeLoader.prototype.load=function(){var e=rtclient.params.fileIds;e&&(e=e.split(","));var t=this.authorizer.userId,t=rtclient.params.state;if(e)for(var o in e)gapi.drive.realtime.load(e[o],this.onFileLoaded,this.initializeModel,this.handleErrors);else{if(t&&(o=rtclient.parseState(t),"open"==o.action))return e=o.ids,t=o.userId,this.redirectTo(e,t),void 0;this.autoCreate&&this.createNewFileAndRedirect()}},rtclient.RealtimeLoader.prototype.createNewFileAndRedirect=function(){var e=this;rtclient.createRealtimeFile(this.defaultTitle,this.newFileMimeType,this.defaultFolderTitle,function(t){t.id?(e.afterCreate&&e.afterCreate(t.id),e.redirectTo([t.id],e.authorizer.userId)):(console.error("Error creating file."),console.error(t))})},Blockly.Realtime={},Blockly.Realtime.enabled_=!1,Blockly.Realtime.document_=null,Blockly.Realtime.model_=null,Blockly.Realtime.sessionId_=null,Blockly.Realtime.initUi_=null,Blockly.Realtime.blocksMap_=null,Blockly.Realtime.withinSync=!1,Blockly.Realtime.realtimeLoader_=null,Blockly.Realtime.chatBoxElementId_=null,Blockly.Realtime.chatBoxInitialText_=null,Blockly.Realtime.withinUndo_=!1,Blockly.Realtime.isEnabled=function(){return Blockly.Realtime.enabled_},Blockly.Realtime.undoElementId_=null,Blockly.Realtime.redoElementId_=null,Blockly.Realtime.PROGRESS_URL_="progress.gif",Blockly.Realtime.ANONYMOUS_URL_="anon.jpeg",Blockly.Realtime.initializeModel_=function(e){Blockly.Realtime.model_=e;var t=e.createMap();e.getRoot().set("blocks",t),t=e.createList(),e.getRoot().set("topBlocks",t),Blockly.Realtime.chatBoxElementId_&&e.getRoot().set(Blockly.Realtime.chatBoxElementId_,e.createString(Blockly.Realtime.chatBoxInitialText_))},Blockly.Realtime.removeBlock=function(e){Blockly.Realtime.blocksMap_["delete"](e.id.toString())},Blockly.Realtime.addTopBlock=function(e){-1==Blockly.Realtime.topBlocks_.indexOf(e)&&Blockly.Realtime.topBlocks_.push(e)},Blockly.Realtime.removeTopBlock=function(e){Blockly.Realtime.topBlocks_.removeValue(e)},Blockly.Realtime.obtainBlock=function(e,t){return Blockly.Realtime.model_.create(Blockly.Block,e,t)},Blockly.Realtime.getBlockById=function(e){return Blockly.Realtime.blocksMap_.get(e)},Blockly.Realtime.logEvent_=function(e){if(console.log("Object event:"),console.log(" id: "+e.target.id),console.log(" type: "+e.type),e=e.events)for(var t=e.length,o=0;t>o;o++){var n=e[o];console.log(" child event:"),console.log(" id: "+n.target.id),console.log(" type: "+n.type)}},Blockly.Realtime.onObjectChange_=function(e){var t=e.events;e=e.events.length;for(var o=0;e>o;o++){var n=t[o];if(!n.isLocal||Blockly.Realtime.withinUndo_){var i=n.target;"value_changed"==n.type&&("xmlDom"==n.property?Blockly.Realtime.doWithinSync_(function(){Blockly.Realtime.placeBlockOnWorkspace_(i,!1),Blockly.Realtime.moveBlock_(i)}):"relativeX"!=n.property&&"relativeY"!=n.property||Blockly.Realtime.doWithinSync_(function(){i.svg_||Blockly.Realtime.placeBlockOnWorkspace_(i,!1),Blockly.Realtime.moveBlock_(i)}))}}},Blockly.Realtime.onBlocksMapChange_=function(e){if(!e.isLocal||Blockly.Realtime.withinUndo_){var t=e.newValue;t?Blockly.Realtime.placeBlockOnWorkspace_(t,!e.oldValue):(t=e.oldValue,Blockly.Realtime.deleteBlock(t))}},Blockly.Realtime.doWithinSync_=function(e){if(Blockly.Realtime.withinSync)e();else try{Blockly.Realtime.withinSync=!0,e()}finally{Blockly.Realtime.withinSync=!1}},Blockly.Realtime.placeBlockOnWorkspace_=function(e,t){Blockly.Realtime.doWithinSync_(function(){var o=Blockly.Xml.textToDom(e.xmlDom).firstChild;(o=Blockly.Xml.domToBlock(Blockly.mainWorkspace,o,!0))&&(t&&o.workspace.addTopBlock(o),(t||goog.array.contains(Blockly.Realtime.topBlocks_,o))&&Blockly.Realtime.moveBlock_(o))})},Blockly.Realtime.moveBlock_=function(e){if(!isNaN(e.relativeX)&&!isNaN(e.relativeY)){var t=Blockly.svgSize().width,o=e.getRelativeToSurfaceXY(),n=e.relativeX-o.x;e.moveBy(Blockly.RTL?t-n:n,e.relativeY-o.y)}},Blockly.Realtime.deleteBlock=function(e){Blockly.Realtime.doWithinSync_(function(){e.dispose(!0,!0,!0)})},Blockly.Realtime.loadBlocks_=function(){for(var e=Blockly.Realtime.topBlocks_,t=0;t<e.length;t++){var o=e.get(t);Blockly.Realtime.placeBlockOnWorkspace_(o,!0)}},Blockly.Realtime.blockChanged=function(e){if(e.workspace==Blockly.mainWorkspace&&Blockly.Realtime.isEnabled()&&!Blockly.Realtime.withinSync){e=e.getRootBlock();var t=e.getRelativeToSurfaceXY(),o=!1,n=Blockly.Xml.blockToDom_(e);n.setAttribute("id",e.id);var i=goog.dom.createDom("xml");i.appendChild(n),n=Blockly.Xml.domToText(i),n!=e.xmlDom&&(o=!0,e.xmlDom=n),(e.relativeX!=t.x||e.relativeY!=t.y)&&(e.relativeX=t.x,e.relativeY=t.y,o=!0),o&&Blockly.Realtime.blocksMap_.set(e.id.toString(),e)}},Blockly.Realtime.onFileLoaded_=function(e){Blockly.Realtime.document_=e,Blockly.Realtime.sessionId_=Blockly.Realtime.getSessionId_(e),Blockly.Realtime.model_=e.getModel(),Blockly.Realtime.blocksMap_=Blockly.Realtime.model_.getRoot().get("blocks"),Blockly.Realtime.topBlocks_=Blockly.Realtime.model_.getRoot().get("topBlocks"),Blockly.Realtime.model_.getRoot().addEventListener(gapi.drive.realtime.EventType.OBJECT_CHANGED,Blockly.Realtime.onObjectChange_),Blockly.Realtime.blocksMap_.addEventListener(gapi.drive.realtime.EventType.VALUE_CHANGED,Blockly.Realtime.onBlocksMapChange_),Blockly.Realtime.initUi_(),e.addEventListener(gapi.drive.realtime.EventType.COLLABORATOR_JOINED,Blockly.Realtime.onCollaboratorJoined_),e.addEventListener(gapi.drive.realtime.EventType.COLLABORATOR_LEFT,Blockly.Realtime.onCollaboratorLeft_),Blockly.Realtime.updateCollabUi_(),Blockly.Realtime.loadBlocks_()},Blockly.Realtime.getSessionId_=function(e){e=e.getCollaborators();for(var t=0;t<e.length;t++){var o=e[t];if(o.isMe)return o.sessionId}},Blockly.Realtime.registerTypes_=function(){var e=gapi.drive.realtime.custom;e.registerType(Blockly.Block,"Block"),Blockly.Block.prototype.id=e.collaborativeField("id"),Blockly.Block.prototype.xmlDom=e.collaborativeField("xmlDom"),Blockly.Block.prototype.relativeX=e.collaborativeField("relativeX"),Blockly.Block.prototype.relativeY=e.collaborativeField("relativeY"),e.setInitializer(Blockly.Block,Blockly.Block.prototype.initialize)},Blockly.Realtime.REAUTH_INTERVAL_IN_MILLISECONDS_=18e5,Blockly.Realtime.afterAuth_=function(){setTimeout(function(){Blockly.Realtime.realtimeLoader_.authorizer.authorize(Blockly.Realtime.afterAuth_)},Blockly.Realtime.REAUTH_INTERVAL_IN_MILLISECONDS_)},Blockly.Realtime.afterCreate_=function(e){var t=gapi.client.drive.permissions.insert({fileId:e,resource:{type:"anyone",role:"writer",value:"default",withLink:!0}});t.execute(function(o){o.error&&Blockly.Realtime.getUserDomain(e,function(o){t=gapi.client.drive.permissions.insert({fileId:e,resource:{type:"domain",role:"writer",value:o,withLink:!0}}),t.execute(function(){})})})},Blockly.Realtime.getUserDomain=function(e,t){gapi.client.drive.permissions.list({fileId:e}).execute(function(e){for(var o=0;o<e.items.length;o++){var n=e.items[o];if("owner"==n.role){t(n.domain);break}}})},Blockly.Realtime.rtclientOptions_={clientId:null,authButtonElementId:"authorizeButton",authDivElementId:"authButtonDiv",initializeModel:Blockly.Realtime.initializeModel_,autoCreate:!0,defaultTitle:"Realtime Blockly File",defaultFolderTitle:"Realtime Blockly Folder",newFileMimeType:null,onFileLoaded:Blockly.Realtime.onFileLoaded_,registerTypes:Blockly.Realtime.registerTypes_,afterAuth:Blockly.Realtime.afterAuth_,afterCreate:Blockly.Realtime.afterCreate_},Blockly.Realtime.parseOptions_=function(e){var t=rtclient.getOption(e,"chatbox");t&&(Blockly.Realtime.chatBoxElementId_=rtclient.getOption(t,"elementId"),Blockly.Realtime.chatBoxInitialText_=rtclient.getOption(t,"initText",Blockly.Msg.CHAT)),Blockly.Realtime.rtclientOptions_.clientId=rtclient.getOption(e,"clientId"),Blockly.Realtime.collabElementId=rtclient.getOption(e,"collabElementId")},Blockly.Realtime.startRealtime=function(e,t,o){Blockly.Realtime.parseOptions_(o),Blockly.Realtime.enabled_=!0,Blockly.Realtime.addAuthUi_(t),Blockly.Realtime.initUi_=function(){if(e(),Blockly.Realtime.chatBoxElementId_){var t=Blockly.Realtime.model_.getRoot().get(Blockly.Realtime.chatBoxElementId_),o=document.getElementById(Blockly.Realtime.chatBoxElementId_);gapi.drive.realtime.databinding.bindString(t,o),o.disabled=!1}},Blockly.Realtime.realtimeLoader_=new rtclient.RealtimeLoader(Blockly.Realtime.rtclientOptions_),Blockly.Realtime.realtimeLoader_.start()},Blockly.Realtime.addAuthUi_=function(e){e.style.background="url("+Blockly.pathToMedia+Blockly.Realtime.PROGRESS_URL_+") no-repeat center center";var t=goog.style.getBounds(e),o=goog.dom.createDom("div");o.id=Blockly.Realtime.rtclientOptions_.authDivElementId;var n=goog.dom.createDom("p",null,Blockly.Msg.AUTH);return o.appendChild(n),n=goog.dom.createDom("button",null,"Authorize"),n.id=Blockly.Realtime.rtclientOptions_.authButtonElementId,o.appendChild(n),e.appendChild(o),o.style.display="none",o.style.position="relative",o.style.textAlign="center",o.style.border="1px solid",o.style.backgroundColor="#f6f9ff",o.style.borderRadius="15px",o.style.boxShadow="10px 10px 5px #888",o.style.width=t.width/3+"px",e=goog.style.getBounds(o),o.style.left=(t.width-e.width)/3+"px",o.style.top=(t.height-e.height)/4+"px",o},Blockly.Realtime.updateCollabUi_=function(){if(Blockly.Realtime.collabElementId){var e=goog.dom.getElement(Blockly.Realtime.collabElementId);goog.dom.removeChildren(e);for(var t=Blockly.Realtime.document_.getCollaborators(),o=0;o<t.length;o++){var n=t[o],i=goog.dom.createDom("img",{src:n.photoUrl||Blockly.pathToMedia+Blockly.Realtime.ANONYMOUS_URL_,alt:n.displayName,title:n.displayName+(n.isMe?" ("+Blockly.Msg.ME+")":"")});i.style.backgroundColor=n.color,goog.dom.appendChild(e,i)}}},Blockly.Realtime.onCollaboratorJoined_=function(){Blockly.Realtime.updateCollabUi_()},Blockly.Realtime.onCollaboratorLeft_=function(){Blockly.Realtime.updateCollabUi_()},Blockly.Realtime.doCommand=function(e){e()},Blockly.Realtime.genUid=function(e){var t=Blockly.Realtime.sessionId_+"-"+e;return Blockly.Realtime.blocksMap_.has(t)?Blockly.Realtime.genUid("-"+e):t},Blockly.Flyout=function(e){var t=this;e.getMetrics=function(){return t.getMetrics_()},e.setMetrics=function(e){return t.setMetrics_(e)},this.workspace_=new Blockly.WorkspaceSvg(e),this.workspace_.isFlyout=!0,this.RTL=!!e.RTL,this.eventWrappers_=[],this.height_=this.width_=0,this.buttons_=[],this.listeners_=[]},Blockly.Flyout.prototype.autoClose=!0,Blockly.Flyout.prototype.CORNER_RADIUS=8,Blockly.Flyout.prototype.createDom=function(){return this.svgGroup_=Blockly.createSvgElement("g",{},null),this.svgBackground_=Blockly.createSvgElement("path",{"class":"blocklyFlyoutBackground"},this.svgGroup_),this.svgGroup_.appendChild(this.workspace_.createDom()),this.svgGroup_},Blockly.Flyout.prototype.init=function(e){this.targetWorkspace_=e,this.workspace_.targetWorkspace=e,this.scrollbar_=new Blockly.Scrollbar(this.workspace_,!1,!1),this.hide(),this.eventWrappers_.concat(Blockly.bindEvent_(this.svgGroup_,"wheel",this,this.wheel_)),this.eventWrappers_.concat(Blockly.bindEvent_(this.svgGroup_,"mousewheel",this,this.wheel_)),this.eventWrappers_.concat(Blockly.bindEvent_(this.targetWorkspace_.getCanvas(),"blocklyWorkspaceChange",this,this.filterForCapacity_)),this.eventWrappers_.concat(Blockly.bindEvent_(this.svgGroup_,"mousedown",this,this.onMouseDown_))},Blockly.Flyout.prototype.dispose=function(){this.hide(),Blockly.unbindEvent_(this.eventWrappers_),this.eventWrappers_.length=0,this.scrollbar_&&(this.scrollbar_.dispose(),this.scrollbar_=null),this.workspace_=null,this.svgGroup_&&(goog.dom.removeNode(this.svgGroup_),this.svgGroup_=null),this.targetWorkspace_=this.svgBackground_=null},Blockly.Flyout.prototype.getMetrics_=function(){if(!this.isVisible())return null;var e=this.height_-2*this.CORNER_RADIUS,t=this.width_;try{var o=this.workspace_.getCanvas().getBBox()}catch(n){o={height:0,y:0}}return{viewHeight:e,viewWidth:t,contentHeight:o.height+o.y,viewTop:-this.workspace_.scrollY,contentTop:0,absoluteTop:this.CORNER_RADIUS,absoluteLeft:0}},Blockly.Flyout.prototype.setMetrics_=function(e){var t=this.getMetrics_();t&&(goog.isNumber(e.y)&&(this.workspace_.scrollY=-t.contentHeight*e.y-t.contentTop),this.workspace_.translate(0,this.workspace_.scrollY+t.absoluteTop))},Blockly.Flyout.prototype.position=function(){if(this.isVisible()){var e=this.targetWorkspace_.getMetrics();if(e){var t=this.width_-this.CORNER_RADIUS;this.RTL&&(t*=-1);var o=["M "+(this.RTL?this.width_:0)+",0"];o.push("h",t),o.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,this.RTL?0:1,this.RTL?-this.CORNER_RADIUS:this.CORNER_RADIUS,this.CORNER_RADIUS),o.push("v",Math.max(0,e.viewHeight-2*this.CORNER_RADIUS)),o.push("a",this.CORNER_RADIUS,this.CORNER_RADIUS,0,0,this.RTL?0:1,this.RTL?this.CORNER_RADIUS:-this.CORNER_RADIUS,this.CORNER_RADIUS),o.push("h",-t),o.push("z"),this.svgBackground_.setAttribute("d",o.join(" ")),t=e.absoluteLeft,this.RTL&&(t+=e.viewWidth,t-=this.width_),this.svgGroup_.setAttribute("transform","translate("+t+","+e.absoluteTop+")"),this.height_=e.viewHeight,this.scrollbar_&&this.scrollbar_.resize()}}},Blockly.Flyout.prototype.scrollToTop=function(){this.scrollbar_.set(0)},Blockly.Flyout.prototype.wheel_=function(e){var t=e.deltaY||-e.wheelDeltaY;if(t){goog.userAgent.GECKO&&(t*=10);var o=this.getMetrics_(),t=o.viewTop+t,t=Math.min(t,o.contentHeight-o.viewHeight),t=Math.max(t,0);this.scrollbar_.set(t),e.preventDefault()}},Blockly.Flyout.prototype.isVisible=function(){return this.svgGroup_&&"block"==this.svgGroup_.style.display},Blockly.Flyout.prototype.hide=function(){if(this.isVisible()){this.svgGroup_.style.display="none";for(var e,t=0;e=this.listeners_[t];t++)Blockly.unbindEvent_(e);this.listeners_.length=0,this.reflowWrapper_&&(Blockly.unbindEvent_(this.reflowWrapper_),this.reflowWrapper_=null)}},Blockly.Flyout.prototype.show=function(e){this.hide();for(var t,o=this.workspace_.getTopBlocks(!1),n=0;t=o[n];n++)t.workspace==this.workspace_&&t.dispose(!1,!1);for(var i,n=0;i=this.buttons_[n];n++)goog.dom.removeNode(i);this.buttons_.length=0;var r=this.CORNER_RADIUS;this.svgGroup_.style.display="block";var o=[],s=[];if(e==Blockly.Variables.NAME_TYPE)Blockly.Variables.flyoutCategory(o,s,r,this.workspace_);else if(e==Blockly.Procedures.NAME_TYPE)Blockly.Procedures.flyoutCategory(o,s,r,this.workspace_);else for(var l=0;t=e[l];l++)t.tagName&&"BLOCK"==t.tagName.toUpperCase()&&(t=Blockly.Xml.domToBlock(this.workspace_,t),o.push(t),s.push(3*r));for(e=r,l=0;t=o[l];l++){n=t.getDescendants(),i=0;for(var a;a=n[i];i++)a.isInFlyout=!0,a.setCommentText(null);t.render(),a=t.getSvgRoot(),i=t.getHeightWidth(),n=this.RTL?0:r+Blockly.BlockSvg.TAB_WIDTH,t.moveBy(n,e),e+=i.height+s[l],i=Blockly.createSvgElement("rect",{"fill-opacity":0},null),this.workspace_.getCanvas().insertBefore(i,t.getSvgRoot()),t.flyoutRect_=i,this.buttons_[l]=i,this.autoClose?this.listeners_.push(Blockly.bindEvent_(a,"mousedown",null,this.createBlockFunc_(t))):this.listeners_.push(Blockly.bindEvent_(a,"mousedown",null,this.blockMouseDown_(t))),this.listeners_.push(Blockly.bindEvent_(a,"mouseover",t,t.addSelect)),this.listeners_.push(Blockly.bindEvent_(a,"mouseout",t,t.removeSelect)),this.listeners_.push(Blockly.bindEvent_(i,"mousedown",null,this.createBlockFunc_(t))),this.listeners_.push(Blockly.bindEvent_(i,"mouseover",t,t.addSelect)),this.listeners_.push(Blockly.bindEvent_(i,"mouseout",t,t.removeSelect))}this.listeners_.push(Blockly.bindEvent_(this.svgBackground_,"mouseover",this,function(e){e=this.workspace_.getTopBlocks(!1);for(var t,o=0;t=e[o];o++)t.removeSelect()})),this.width_=0,this.reflow(),this.filterForCapacity_(),Blockly.fireUiEventNow(window,"resize"),this.reflowWrapper_=Blockly.bindEvent_(this.workspace_.getCanvas(),"blocklyWorkspaceChange",this,this.reflow),this.workspace_.fireChangeEvent()},Blockly.Flyout.prototype.reflow=function(){for(var e,t=0,o=this.CORNER_RADIUS,n=this.workspace_.getTopBlocks(!1),i=0;e=n[i];i++){e.getSvgRoot();var r=e.getHeightWidth(),t=Math.max(t,r.width)}if(t+=o+Blockly.BlockSvg.TAB_WIDTH+o/2+Blockly.Scrollbar.scrollbarThickness,this.width_!=t){for(i=0;e=n[i];i++){var r=e.getHeightWidth(),s=e.getRelativeToSurfaceXY();if(this.RTL){var l=t-o-Blockly.BlockSvg.TAB_WIDTH-s.x;e.moveBy(l,0),s.x+=l}e.flyoutRect_&&(e.flyoutRect_.setAttribute("width",r.width),e.flyoutRect_.setAttribute("height",r.height),e.flyoutRect_.setAttribute("x",this.RTL?s.x-r.width:s.x),e.flyoutRect_.setAttribute("y",s.y))}this.width_=t,Blockly.fireUiEvent(window,"resize")}},Blockly.Flyout.prototype.blockMouseDown_=function(e){var t=this;return function(o){Blockly.terminateDrag_(),Blockly.hideChaff(),Blockly.isRightButton(o)?e.showContextMenu_(o):(Blockly.removeAllRanges(),Blockly.Css.setCursor(Blockly.Css.Cursor.CLOSED),Blockly.Flyout.startDownEvent_=o,Blockly.Flyout.startBlock_=e,Blockly.Flyout.startFlyout_=t,Blockly.Flyout.onMouseUpWrapper_=Blockly.bindEvent_(document,"mouseup",this,Blockly.terminateDrag_),Blockly.Flyout.onMouseMoveBlockWrapper_=Blockly.bindEvent_(document,"mousemove",this,t.onMouseMoveBlock_)),o.stopPropagation()}},Blockly.Flyout.prototype.onMouseDown_=function(e){Blockly.isRightButton(e)||(Blockly.hideChaff(!0),Blockly.Flyout.terminateDrag_(),this.startDragMouseY_=e.clientY,Blockly.Flyout.onMouseMoveWrapper_=Blockly.bindEvent_(document,"mousemove",this,this.onMouseMove_),Blockly.Flyout.onMouseUpWrapper_=Blockly.bindEvent_(document,"mouseup",this,Blockly.Flyout.terminateDrag_),e.preventDefault(),e.stopPropagation())},Blockly.Flyout.prototype.onMouseMove_=function(e){var t=e.clientY-this.startDragMouseY_;this.startDragMouseY_=e.clientY,e=this.getMetrics_(),t=e.viewTop-t,t=Math.min(t,e.contentHeight-e.viewHeight),t=Math.max(t,0),this.scrollbar_.set(t)},Blockly.Flyout.prototype.onMouseMoveBlock_=function(e){if("mousemove"==e.type&&1>=e.clientX&&0==e.clientY&&0==e.button)e.stopPropagation();else{Blockly.removeAllRanges();var t=e.clientY-Blockly.Flyout.startDownEvent_.clientY;Math.sqrt(Math.pow(e.clientX-Blockly.Flyout.startDownEvent_.clientX,2)+Math.pow(t,2))>Blockly.DRAG_RADIUS&&Blockly.Flyout.startFlyout_.createBlockFunc_(Blockly.Flyout.startBlock_)(Blockly.Flyout.startDownEvent_)}},Blockly.Flyout.prototype.createBlockFunc_=function(e){var t=this;return function(o){if(!Blockly.isRightButton(o)&&!e.disabled){var n=Blockly.Xml.blockToDom_(e),n=Blockly.Xml.domToBlock(t.targetWorkspace_,n),i=e.getSvgRoot();if(!i)throw"originBlock is not rendered.";var i=Blockly.getSvgXY_(i),r=n.getSvgRoot();if(!r)throw"block is not rendered.";r=Blockly.getSvgXY_(r),n.moveBy(i.x-r.x,i.y-r.y),t.autoClose?t.hide():t.filterForCapacity_(),n.onMouseDown_(o)}}},Blockly.Flyout.prototype.filterForCapacity_=function(){for(var e,t=this.targetWorkspace_.remainingCapacity(),o=this.workspace_.getTopBlocks(!1),n=0;e=o[n];n++){var i=e.getDescendants().length>t;e.setDisabled(i)}},Blockly.Flyout.prototype.getRect=function(){var e=Blockly.getSvgXY_(this.svgGroup_).x;return this.RTL||(e-=1e7),new goog.math.Rect(e,-1e7,1e7+this.width_,this.height_+2e7)},Blockly.Flyout.terminateDrag_=function(){Blockly.Flyout.onMouseUpWrapper_&&(Blockly.unbindEvent_(Blockly.Flyout.onMouseUpWrapper_),Blockly.Flyout.onMouseUpWrapper_=null),Blockly.Flyout.onMouseMoveBlockWrapper_&&(Blockly.unbindEvent_(Blockly.Flyout.onMouseMoveBlockWrapper_),Blockly.Flyout.onMouseMoveBlockWrapper_=null),Blockly.Flyout.onMouseMoveWrapper_&&(Blockly.unbindEvent_(Blockly.Flyout.onMouseMoveWrapper_),Blockly.Flyout.onMouseMoveWrapper_=null),Blockly.Flyout.onMouseUpWrapper_&&(Blockly.unbindEvent_(Blockly.Flyout.onMouseUpWrapper_),Blockly.Flyout.onMouseUpWrapper_=null),Blockly.Flyout.startDownEvent_=null,Blockly.Flyout.startBlock_=null,Blockly.Flyout.startFlyout_=null},Blockly.Toolbox=function(e){this.workspace_=e},Blockly.Toolbox.prototype.width=0,Blockly.Toolbox.prototype.selectedOption_=null,Blockly.Toolbox.prototype.lastCategory_=null,Blockly.Toolbox.prototype.CONFIG_={indentWidth:19,cssRoot:"blocklyTreeRoot",cssHideRoot:"blocklyHidden",cssItem:"",cssTreeRow:"blocklyTreeRow",cssItemLabel:"blocklyTreeLabel",cssTreeIcon:"blocklyTreeIcon",cssExpandedFolderIcon:"blocklyTreeIconOpen",cssFileIcon:"blocklyTreeIconNone",cssSelectedRow:"blocklyTreeSelected"},Blockly.Toolbox.prototype.init=function(){var e=this.workspace_,t=e.options.svg;this.HtmlDiv=goog.dom.createDom("div","blocklyToolboxDiv"),this.HtmlDiv.setAttribute("dir",this.workspace_.RTL?"RTL":"LTR"),t.parentNode.insertBefore(this.HtmlDiv,t),Blockly.bindEvent_(this.HtmlDiv,"mousedown",this,function(e){Blockly.isRightButton(e)||e.target==this.HtmlDiv?Blockly.hideChaff(!1):Blockly.hideChaff(!0)}),this.flyout_=new Blockly.Flyout({parentWorkspace:e,RTL:e.RTL}),goog.dom.insertSiblingAfter(this.flyout_.createDom(),e.svgGroup_),this.flyout_.init(e),this.CONFIG_.cleardotPath=e.options.pathToMedia+"1x1.gif",this.CONFIG_.cssCollapsedFolderIcon="blocklyTreeIconClosed"+(this.workspace_.RTL?"Rtl":"Ltr"),this.tree_=t=new Blockly.Toolbox.TreeControl(this,this.CONFIG_),t.setShowRootNode(!1),t.setShowLines(!1),t.setShowExpandIcons(!1),t.setSelectedItem(null),this.HtmlDiv.style.display="block",this.populate_(e.options.languageTree),t.render(this.HtmlDiv),this.position()
|
33
33
|
},Blockly.Toolbox.prototype.position=function(){var e=this.HtmlDiv;if(e){var t=this.workspace_.options.svg,o=goog.style.getBorderBox(t),n=Blockly.svgSize(t);this.workspace_.RTL?(t=Blockly.convertCoordinates(0,0,!1,t),e.style.left=t.x+n.width-e.offsetWidth+"px"):e.style.marginLeft=o.left,e.style.height=n.height+"px",this.width=e.offsetWidth,this.workspace_.RTL||--this.width,this.flyout_.position()}},Blockly.Toolbox.prototype.populate_=function(e){function t(e,n){for(var i,r=0;i=e.childNodes[r];r++)if(i.tagName){var s=i.tagName.toUpperCase();if("CATEGORY"==s){s=o.createNode(i.getAttribute("name")),s.blocks=[],n.add(s);var l=i.getAttribute("custom");l?s.blocks=l:t(i,s)}else"HR"==s?console.warn("The <hr> separator tag in the toolbox XML needs to be changed to <sep></sep> (due to a bug in IE)."):"SEP"==s?n.add(new Blockly.Toolbox.TreeSeparator):"BLOCK"==s&&n.blocks.push(i)}}var o=this.tree_;if(o.removeChildren(),o.blocks=[],t(e,this.tree_),o.blocks.length)throw"Toolbox cannot have both blocks and categories in the root level.";Blockly.fireUiEvent(window,"resize")},Blockly.Toolbox.prototype.clearSelection=function(){this.tree_.setSelectedItem(null)},Blockly.Toolbox.prototype.getRect=function(){var e=this.workspace_.RTL?Blockly.svgSize(this.workspace_.options.svg).width-this.width:-1e7;return new goog.math.Rect(e,-1e7,1e7+this.width,2e7)},Blockly.Toolbox.TreeControl=function(e,t){this.toolbox_=e,goog.ui.tree.TreeControl.call(this,goog.html.SafeHtml.EMPTY,t)},goog.inherits(Blockly.Toolbox.TreeControl,goog.ui.tree.TreeControl),Blockly.Toolbox.TreeControl.prototype.enterDocument=function(){if(Blockly.Toolbox.TreeControl.superClass_.enterDocument.call(this),goog.events.BrowserFeature.TOUCH_ENABLED){var e=this.getElement();Blockly.bindEvent_(e,goog.events.EventType.TOUCHSTART,this,this.handleTouchEvent_)}},Blockly.Toolbox.TreeControl.prototype.handleTouchEvent_=function(e){e.preventDefault();var t=this.getNodeFromEvent_(e);t&&e.type===goog.events.EventType.TOUCHSTART&&setTimeout(function(){t.onMouseDown(e)},1)},Blockly.Toolbox.TreeControl.prototype.createNode=function(e){return new Blockly.Toolbox.TreeNode(this.toolbox_,e?goog.html.SafeHtml.htmlEscape(e):goog.html.SafeHtml.EMPTY,this.getConfig(),this.getDomHelper())},Blockly.Toolbox.TreeControl.prototype.setSelectedItem=function(e){if(Blockly.removeAllRanges(),this.selectedItem_!=e){goog.ui.tree.TreeControl.prototype.setSelectedItem.call(this,e);var t=this.toolbox_;e&&e.blocks&&e.blocks.length?(t.flyout_.show(e.blocks),t.lastCategory_!=e.blocks&&(t.flyout_.scrollToTop(),t.lastCategory_=e.blocks)):t.flyout_.hide()}},Blockly.Toolbox.TreeNode=function(e,t,o,n){goog.ui.tree.TreeNode.call(this,t,o,n),e&&(t=function(){Blockly.fireUiEvent(window,"resize")},goog.events.listen(e.tree_,goog.ui.tree.BaseNode.EventType.EXPAND,t),goog.events.listen(e.tree_,goog.ui.tree.BaseNode.EventType.COLLAPSE,t))},goog.inherits(Blockly.Toolbox.TreeNode,goog.ui.tree.TreeNode),Blockly.Toolbox.TreeNode.prototype.getExpandIconSafeHtml=function(){return goog.html.SafeHtml.create("span")},Blockly.Toolbox.TreeNode.prototype.onMouseDown=function(){this.hasChildren()&&this.isUserCollapsible_?(this.toggle(),this.select()):this.isSelected()?this.getTree().setSelectedItem(null):this.select(),this.updateRow()},Blockly.Toolbox.TreeNode.prototype.onDoubleClick_=function(){},Blockly.Toolbox.TreeSeparator=function(){Blockly.Toolbox.TreeNode.call(this,null,"",Blockly.Toolbox.TreeSeparator.CONFIG_)},goog.inherits(Blockly.Toolbox.TreeSeparator,Blockly.Toolbox.TreeNode),Blockly.Toolbox.TreeSeparator.CONFIG_={cssTreeRow:"blocklyTreeSeparator"},Blockly.Css={},Blockly.Css.Cursor={OPEN:"handopen",CLOSED:"handclosed",DELETE:"handdelete"},Blockly.Css.currentCursor_="",Blockly.Css.styleSheet_=null,Blockly.Css.mediaPath_="",Blockly.Css.inject=function(e,t){if(!Blockly.Css.styleSheet_){var o=".blocklyDraggable {}\n";e&&(o+=Blockly.Css.CONTENT.join("\n")),Blockly.Css.mediaPath_=t.replace(/[\\\/]$/,""),o=o.replace(/<<<PATH>>>/g,Blockly.Css.mediaPath_),Blockly.Css.styleSheet_=goog.cssom.addCssText(o).sheet,Blockly.Css.setCursor(Blockly.Css.Cursor.OPEN)}},Blockly.Css.setCursor=function(e){if(Blockly.Css.currentCursor_!=e){Blockly.Css.currentCursor_=e;var t="url("+Blockly.Css.mediaPath_+"/"+e+".cur) "+(e==Blockly.Css.Cursor.OPEN?"8 5":"7 3")+", auto";goog.cssom.replaceCssRule("",".blocklyDraggable {\n cursor: "+t+";\n}\n",Blockly.Css.styleSheet_,0);for(var o,n=document.getElementsByClassName("blocklyToolboxDiv"),i=0;o=n[i];i++)o.style.cursor=e==Blockly.Css.Cursor.OPEN?"":t;document.body.parentNode.style.cursor=e==Blockly.Css.Cursor.OPEN?"":t}},Blockly.Css.CONTENT=[".blocklySvg {"," background-color: #fff;"," outline: none;"," overflow: hidden;","}",".blocklyWidgetDiv {"," display: none;"," position: absolute;"," z-index: 999;","}",".blocklyTooltipDiv {"," background-color: #ffffc7;"," border: 1px solid #ddc;"," box-shadow: 4px 4px 20px 1px rgba(0,0,0,.15);"," colour: #000;"," display: none;"," font-family: sans-serif;"," font-size: 9pt;"," opacity: 0.9;"," padding: 2px;"," position: absolute;"," z-index: 1000;","}",".blocklyResizeSE {"," cursor: se-resize;"," fill: #aaa;","}",".blocklyResizeSW {"," cursor: sw-resize;"," fill: #aaa;","}",".blocklyResizeLine {"," stroke: #888;"," stroke-width: 1;","}",".blocklyHighlightedConnectionPath {"," fill: none;"," stroke: #fc3;"," stroke-width: 4px;","}",".blocklyPathLight {"," fill: none;"," stroke-linecap: round;"," stroke-width: 2;","}",".blocklySelected>.blocklyPath {"," stroke: #fc3;"," stroke-width: 3px;","}",".blocklySelected>.blocklyPathLight {"," display: none;","}",".blocklyDragging>.blocklyPath,",".blocklyDragging>.blocklyPathLight {"," fill-opacity: .8;"," stroke-opacity: .8;","}",".blocklyDragging>.blocklyPathDark {"," display: none;","}",".blocklyDisabled>.blocklyPath {"," fill-opacity: .5;"," stroke-opacity: .5;","}",".blocklyDisabled>.blocklyPathLight,",".blocklyDisabled>.blocklyPathDark {"," display: none;","}",".blocklyText {"," cursor: default;"," fill: #fff;"," font-family: sans-serif;"," font-size: 11pt;","}",".blocklyNonEditableText>text {"," pointer-events: none;","}",".blocklyNonEditableText>rect,",".blocklyEditableText>rect {"," fill: #fff;"," fill-opacity: .6;","}",".blocklyNonEditableText>text,",".blocklyEditableText>text {"," fill: #000;","}",".blocklyEditableText:hover>rect {"," stroke: #fff;"," stroke-width: 2;","}",".blocklyBubbleText {"," fill: #000;","}",".blocklySvg text {"," user-select: none;"," -moz-user-select: none;"," -webkit-user-select: none;"," cursor: inherit;","}",".blocklyHidden {"," display: none;","}",".blocklyFieldDropdown:not(.blocklyHidden) {"," display: block;","}",".blocklyIconGroup {"," cursor: default;","}",".blocklyIconGroup:not(:hover),",".blocklyIconGroupReadonly {"," opacity: .6;","}",".blocklyMinimalBody {"," margin: 0;"," padding: 0;","}",".blocklyCommentTextarea {"," background-color: #ffc;"," border: 0;"," margin: 0;"," padding: 2px;"," resize: none;","}",".blocklyHtmlInput {"," border: none;"," font-family: sans-serif;"," font-size: 11pt;"," outline: none;"," width: 100%","}",".blocklyMainBackground {"," stroke-width: 1;"," stroke: #c6c6c6;","}",".blocklyMutatorBackground {"," fill: #fff;"," stroke: #ddd;"," stroke-width: 1;","}",".blocklyFlyoutBackground {"," fill: #ddd;"," fill-opacity: .8;","}",".blocklyColourBackground {"," fill: #666;","}",".blocklyScrollbarBackground {"," fill: #fff;"," stroke: #e4e4e4;"," stroke-width: 1;","}",".blocklyScrollbarKnob {"," fill: #ccc;","}",".blocklyScrollbarBackground:hover+.blocklyScrollbarKnob,",".blocklyScrollbarKnob:hover {"," fill: #bbb;","}",".blocklyInvalidInput {"," background: #faa;","}",".blocklyAngleCircle {"," stroke: #444;"," stroke-width: 1;"," fill: #ddd;"," fill-opacity: .8;","}",".blocklyAngleMarks {"," stroke: #444;"," stroke-width: 1;","}",".blocklyAngleGauge {"," fill: #f88;"," fill-opacity: .8; ","}",".blocklyAngleLine {"," stroke: #f00;"," stroke-width: 2;"," stroke-linecap: round;","}",".blocklyContextMenu {"," border-radius: 4px;","}",".blocklyDropdownMenu {"," padding: 0 !important;","}",".blocklyWidgetDiv .goog-option-selected .goog-menuitem-checkbox,",".blocklyWidgetDiv .goog-option-selected .goog-menuitem-icon {"," background: url(<<<PATH>>>/sprites.png) no-repeat -48px -16px !important;","}",".blocklyToolboxDiv {"," background-color: #ddd;"," display: none;"," overflow-x: visible;"," overflow-y: auto;"," position: absolute;","}",".blocklyTreeRoot {"," padding: 4px 0;","}",".blocklyTreeRoot:focus {"," outline: none;","}",".blocklyTreeRow {"," line-height: 22px;"," height: 22px;"," padding-right: 1em;"," white-space: nowrap;","}",'.blocklyToolboxDiv[dir="RTL"] .blocklyTreeRow {'," padding-right: 0;"," padding-left: 1em !important;","}",".blocklyTreeRow:hover {"," background-color: #e4e4e4;","}",".blocklyTreeSeparator {"," border-bottom: solid #e5e5e5 1px;"," height: 0px;"," margin: 5px 0;","}",".blocklyTreeIcon {"," background-image: url(<<<PATH>>>/sprites.png);"," height: 16px;"," vertical-align: middle;"," width: 16px;","}",".blocklyTreeIconClosedLtr {"," background-position: -32px -1px;","}",".blocklyTreeIconClosedRtl {"," background-position: 0px -1px;","}",".blocklyTreeIconOpen {"," background-position: -16px -1px;","}",".blocklyTreeSelected>.blocklyTreeIconClosedLtr {"," background-position: -32px -17px;","}",".blocklyTreeSelected>.blocklyTreeIconClosedRtl {"," background-position: 0px -17px;","}",".blocklyTreeSelected>.blocklyTreeIconOpen {"," background-position: -16px -17px;","}",".blocklyTreeIconNone,",".blocklyTreeSelected>.blocklyTreeIconNone {"," background-position: -48px -1px;","}",".blocklyTreeLabel {"," cursor: default;"," font-family: sans-serif;"," font-size: 16px;"," padding: 0 3px;"," vertical-align: middle;","}",".blocklyTreeSelected {"," background-color: #57e !important;","}",".blocklyTreeSelected .blocklyTreeLabel {"," color: #fff;","}",".blocklyWidgetDiv .goog-palette {"," outline: none;"," cursor: default;","}",".blocklyWidgetDiv .goog-palette-table {"," border: 1px solid #666;"," border-collapse: collapse;","}",".blocklyWidgetDiv .goog-palette-cell {"," height: 13px;"," width: 15px;"," margin: 0;"," border: 0;"," text-align: center;"," vertical-align: middle;"," border-right: 1px solid #666;"," font-size: 1px;","}",".blocklyWidgetDiv .goog-palette-colorswatch {"," position: relative;"," height: 13px;"," width: 15px;"," border: 1px solid #666;","}",".blocklyWidgetDiv .goog-palette-cell-hover .goog-palette-colorswatch {"," border: 1px solid #FFF;","}",".blocklyWidgetDiv .goog-palette-cell-selected .goog-palette-colorswatch {"," border: 1px solid #000;"," color: #fff;","}",".blocklyWidgetDiv .goog-date-picker,",".blocklyWidgetDiv .goog-date-picker th,",".blocklyWidgetDiv .goog-date-picker td {"," font: 13px Arial, sans-serif;","}",".blocklyWidgetDiv .goog-date-picker {"," -moz-user-focus: normal;"," -moz-user-select: none;"," position: relative;"," border: 1px solid #000;"," float: left;"," padding: 2px;"," color: #000;"," background: #c3d9ff;"," cursor: default;","}",".blocklyWidgetDiv .goog-date-picker th {"," text-align: center;","}",".blocklyWidgetDiv .goog-date-picker td {"," text-align: center;"," vertical-align: middle;"," padding: 1px 3px;","}",".blocklyWidgetDiv .goog-date-picker-menu {"," position: absolute;"," background: threedface;"," border: 1px solid gray;"," -moz-user-focus: normal;"," z-index: 1;"," outline: none;","}",".blocklyWidgetDiv .goog-date-picker-menu ul {"," list-style: none;"," margin: 0px;"," padding: 0px;","}",".blocklyWidgetDiv .goog-date-picker-menu ul li {"," cursor: default;","}",".blocklyWidgetDiv .goog-date-picker-menu-selected {"," background: #ccf;","}",".blocklyWidgetDiv .goog-date-picker th {"," font-size: .9em;","}",".blocklyWidgetDiv .goog-date-picker td div {"," float: left;","}",".blocklyWidgetDiv .goog-date-picker button {"," padding: 0px;"," margin: 1px 0;"," border: 0;"," color: #20c;"," font-weight: bold;"," background: transparent;","}",".blocklyWidgetDiv .goog-date-picker-date {"," background: #fff;","}",".blocklyWidgetDiv .goog-date-picker-week,",".blocklyWidgetDiv .goog-date-picker-wday {"," padding: 1px 3px;"," border: 0;"," border-color: #a2bbdd;"," border-style: solid;","}",".blocklyWidgetDiv .goog-date-picker-week {"," border-right-width: 1px;","}",".blocklyWidgetDiv .goog-date-picker-wday {"," border-bottom-width: 1px;","}",".blocklyWidgetDiv .goog-date-picker-head td {"," text-align: center;","}",".blocklyWidgetDiv td.goog-date-picker-today-cont {"," text-align: center;","}",".blocklyWidgetDiv td.goog-date-picker-none-cont {"," text-align: center;","}",".blocklyWidgetDiv .goog-date-picker-month {"," min-width: 11ex;"," white-space: nowrap;","}",".blocklyWidgetDiv .goog-date-picker-year {"," min-width: 6ex;"," white-space: nowrap;","}",".blocklyWidgetDiv .goog-date-picker-monthyear {"," white-space: nowrap;","}",".blocklyWidgetDiv .goog-date-picker table {"," border-collapse: collapse;","}",".blocklyWidgetDiv .goog-date-picker-other-month {"," color: #888;","}",".blocklyWidgetDiv .goog-date-picker-wkend-start,",".blocklyWidgetDiv .goog-date-picker-wkend-end {"," background: #eee;","}",".blocklyWidgetDiv td.goog-date-picker-selected {"," background: #c3d9ff;","}",".blocklyWidgetDiv .goog-date-picker-today {"," background: #9ab;"," font-weight: bold !important;"," border-color: #246 #9bd #9bd #246;"," color: #fff;","}",".blocklyWidgetDiv .goog-menu {"," background: #fff;"," border-color: #ccc #666 #666 #ccc;"," border-style: solid;"," border-width: 1px;"," cursor: default;"," font: normal 13px Arial, sans-serif;"," margin: 0;"," outline: none;"," padding: 4px 0;"," position: absolute;"," z-index: 20000;","}",".blocklyWidgetDiv .goog-menuitem {"," color: #000;"," font: normal 13px Arial, sans-serif;"," list-style: none;"," margin: 0;"," padding: 4px 7em 4px 28px;"," white-space: nowrap;","}",".blocklyWidgetDiv .goog-menuitem.goog-menuitem-rtl {"," padding-left: 7em;"," padding-right: 28px;","}",".blocklyWidgetDiv .goog-menu-nocheckbox .goog-menuitem,",".blocklyWidgetDiv .goog-menu-noicon .goog-menuitem {"," padding-left: 12px;","}",".blocklyWidgetDiv .goog-menu-noaccel .goog-menuitem {"," padding-right: 20px;","}",".blocklyWidgetDiv .goog-menuitem-content {"," color: #000;"," font: normal 13px Arial, sans-serif;","}",".blocklyWidgetDiv .goog-menuitem-disabled .goog-menuitem-accel,",".blocklyWidgetDiv .goog-menuitem-disabled .goog-menuitem-content {"," color: #ccc !important;","}",".blocklyWidgetDiv .goog-menuitem-disabled .goog-menuitem-icon {"," opacity: 0.3;"," -moz-opacity: 0.3;"," filter: alpha(opacity=30);","}",".blocklyWidgetDiv .goog-menuitem-highlight,",".blocklyWidgetDiv .goog-menuitem-hover {"," background-color: #d6e9f8;"," border-color: #d6e9f8;"," border-style: dotted;"," border-width: 1px 0;"," padding-bottom: 3px;"," padding-top: 3px;","}",".blocklyWidgetDiv .goog-menuitem-checkbox,",".blocklyWidgetDiv .goog-menuitem-icon {"," background-repeat: no-repeat;"," height: 16px;"," left: 6px;"," position: absolute;"," right: auto;"," vertical-align: middle;"," width: 16px;","}",".blocklyWidgetDiv .goog-menuitem-rtl .goog-menuitem-checkbox,",".blocklyWidgetDiv .goog-menuitem-rtl .goog-menuitem-icon {"," left: auto;"," right: 6px;","}",".blocklyWidgetDiv .goog-option-selected .goog-menuitem-checkbox,",".blocklyWidgetDiv .goog-option-selected .goog-menuitem-icon {"," background: url(//ssl.gstatic.com/editor/editortoolbar.png) no-repeat -512px 0;","}",".blocklyWidgetDiv .goog-menuitem-accel {"," color: #999;"," direction: ltr;"," left: auto;"," padding: 0 6px;"," position: absolute;"," right: 0;"," text-align: right;","}",".blocklyWidgetDiv .goog-menuitem-rtl .goog-menuitem-accel {"," left: 0;"," right: auto;"," text-align: left;","}",".blocklyWidgetDiv .goog-menuitem-mnemonic-hint {"," text-decoration: underline;","}",".blocklyWidgetDiv .goog-menuitem-mnemonic-separator {"," color: #999;"," font-size: 12px;"," padding-left: 4px;","}",".blocklyWidgetDiv .goog-menuseparator {"," border-top: 1px solid #ccc;"," margin: 4px 0;"," padding: 0;","}",""],Blockly.WidgetDiv={},Blockly.WidgetDiv.DIV=null,Blockly.WidgetDiv.owner_=null,Blockly.WidgetDiv.dispose_=null,Blockly.WidgetDiv.createDom=function(){Blockly.WidgetDiv.DIV||(Blockly.WidgetDiv.DIV=goog.dom.createDom("div","blocklyWidgetDiv"),document.body.appendChild(Blockly.WidgetDiv.DIV))},Blockly.WidgetDiv.show=function(e,t,o){Blockly.WidgetDiv.hide(),Blockly.WidgetDiv.owner_=e,Blockly.WidgetDiv.dispose_=o,Blockly.WidgetDiv.DIV.style.direction=t?"rtl":"ltr",Blockly.WidgetDiv.DIV.style.display="block"},Blockly.WidgetDiv.hide=function(){Blockly.WidgetDiv.owner_&&(Blockly.WidgetDiv.DIV.style.display="none",Blockly.WidgetDiv.dispose_&&Blockly.WidgetDiv.dispose_(),Blockly.WidgetDiv.owner_=null,Blockly.WidgetDiv.dispose_=null,goog.dom.removeChildren(Blockly.WidgetDiv.DIV))},Blockly.WidgetDiv.isVisible=function(){return!!Blockly.WidgetDiv.owner_},Blockly.WidgetDiv.hideIfOwner=function(e){Blockly.WidgetDiv.owner_==e&&Blockly.WidgetDiv.hide()},Blockly.WidgetDiv.position=function(e,t,o,n,i){t<n.y&&(t=n.y),i?e>o.width+n.x&&(e=o.width+n.x):e<n.x&&(e=n.x),Blockly.WidgetDiv.DIV.style.left=e+"px",Blockly.WidgetDiv.DIV.style.top=t+"px"},Blockly.inject=function(e,t){if(goog.isString(e)&&(e=document.getElementById(e)),!goog.dom.contains(document,e))throw"Error: container is not in current document.";var o,n=Blockly.parseOptions_(t||{}),i=function(){var t=Blockly.createDom_(e,n);o=Blockly.createMainWorkspace_(t,n),Blockly.init_(o),o.markFocused(),Blockly.bindEvent_(t,"focus",o,o.markFocused)};if(n.enableRealtime){var r=document.getElementById("realtime");r&&(r.style.display="block"),Blockly.Realtime.startRealtime(i,e,n.realtimeOptions)}else i();return o},Blockly.parseToolboxTree_=function(e){return e?("string"!=typeof e&&"undefined"==typeof XSLTProcessor&&(e=e.outerHTML),"string"==typeof e&&(e=Blockly.Xml.textToDom(e))):e=null,e},Blockly.parseOptions_=function(e){var t=!!e.readOnly;if(t)var o=null,n=!1,i=!1,r=!1,s=!1,l=!1,a=!1;else o=Blockly.parseToolboxTree_(e.toolbox),n=Boolean(o&&o.getElementsByTagName("category").length),i=e.trashcan,void 0===i&&(i=n),r=e.collapse,void 0===r&&(r=n),s=e.comments,void 0===s&&(s=n),l=e.disable,void 0===l&&(l=n),a=e.sounds,void 0===a&&(a=!0);var c=e.scrollbars;void 0===c&&(c=n);var g=e.css;void 0===g&&(g=!0);var u=e.grid||{};u.spacing=u.spacing?parseFloat(u.spacing):0,u.colour||(u.colour="#888"),u.length=u.length?parseFloat(u.length):1,u.snap=0<u.spacing&&!!u.snap;var h="https://blockly-demo.appspot.com/static/media/";e.media?h=e.media:e.path&&(h=e.path+"media/");var d=!!e.realtime;return{RTL:!!e.rtl,collapse:r,comments:s,disable:l,readOnly:t,maxBlocks:e.maxBlocks||1/0,pathToMedia:h,hasCategories:n,hasScrollbars:c,hasTrashcan:i,hasSounds:a,hasCss:g,languageTree:o,gridOptions:u,enableRealtime:d,realtimeOptions:d?e.realtimeOptions:void 0}},Blockly.createDom_=function(e,t){e.setAttribute("dir","LTR"),goog.ui.Component.setDefaultRightToLeft(t.RTL),Blockly.Css.inject(t.hasCss,t.pathToMedia);var o,n,i=Blockly.createSvgElement("svg",{xmlns:"http://www.w3.org/2000/svg","xmlns:html":"http://www.w3.org/1999/xhtml","xmlns:xlink":"http://www.w3.org/1999/xlink",version:"1.1","class":"blocklySvg"},e),r=Blockly.createSvgElement("defs",{},i);if(o=Blockly.createSvgElement("filter",{id:"blocklyEmboss"},r),Blockly.createSvgElement("feGaussianBlur",{"in":"SourceAlpha",stdDeviation:1,result:"blur"},o),n=Blockly.createSvgElement("feSpecularLighting",{"in":"blur",surfaceScale:1,specularConstant:.5,specularExponent:10,"lighting-color":"white",result:"specOut"},o),Blockly.createSvgElement("fePointLight",{x:-5e3,y:-1e4,z:2e4},n),Blockly.createSvgElement("feComposite",{"in":"specOut",in2:"SourceAlpha",operator:"in",result:"specOut"},o),Blockly.createSvgElement("feComposite",{"in":"SourceGraphic",in2:"specOut",operator:"arithmetic",k1:0,k2:1,k3:1,k4:0},o),o=Blockly.createSvgElement("filter",{id:"blocklyShadowFilter"},r),Blockly.createSvgElement("feGaussianBlur",{stdDeviation:2},o),o=Blockly.createSvgElement("pattern",{id:"blocklyDisabledPattern",patternUnits:"userSpaceOnUse",width:10,height:10},r),Blockly.createSvgElement("rect",{width:10,height:10,fill:"#aaa"},o),Blockly.createSvgElement("path",{d:"M 0 0 L 10 10 M 10 0 L 0 10",stroke:"#cc0"},o),o=t.gridOptions.spacing||100,r=Blockly.createSvgElement("pattern",{id:"blocklyGridPattern"+String(Math.random()).substring(2),patternUnits:"userSpaceOnUse",width:o,height:o},r),0<t.gridOptions.length&&0<t.gridOptions.spacing){o=Math.floor(t.gridOptions.spacing/2)+.5,n=o-t.gridOptions.length/2;var s=o+t.gridOptions.length/2;Blockly.createSvgElement("line",{x1:n,y1:o,x2:s,y2:o,stroke:t.gridOptions.colour},r),1<t.gridOptions.length&&Blockly.createSvgElement("line",{x1:o,y1:n,x2:o,y2:s,stroke:t.gridOptions.colour},r)}return t.gridPattern=r,t.svg=i},Blockly.createMainWorkspace_=function(e,t){t.parentWorkspace=null,t.getMetrics=Blockly.getMainWorkspaceMetrics_,t.setMetrics=Blockly.setMainWorkspaceMetrics_;var o=new Blockly.WorkspaceSvg(t);return e.appendChild(o.createDom("blocklyMainBackground")),o.markFocused(),t.readOnly||t.hasScrollbars||o.addChangeListener(function(){if(0==Blockly.dragMode_){var e=o.getMetrics(),n=e.viewLeft+e.absoluteLeft,i=e.viewTop+e.absoluteTop;if(e.contentTop<i||e.contentTop+e.contentHeight>e.viewHeight+i||e.contentLeft<(t.RTL?e.viewLeft:n)||e.contentLeft+e.contentWidth>(t.RTL?e.viewWidth:e.viewWidth+n))for(var r,s=o.getTopBlocks(!1),l=0;r=s[l];l++){var a=r.getRelativeToSurfaceXY(),c=r.getHeightWidth(),g=i+25-c.height-a.y;g>0&&r.moveBy(0,g),g=i+e.viewHeight-25-a.y,0>g&&r.moveBy(0,g),g=25+n-a.x-(t.RTL?0:c.width),g>0&&r.moveBy(g,0),g=n+e.viewWidth-25-a.x+(t.RTL?c.width:0),0>g&&r.moveBy(g,0)}}}),Blockly.svgResize(o),Blockly.WidgetDiv.createDom(),Blockly.Tooltip.createDom(),o},Blockly.init_=function(e){var t=e.options,o=e.options.svg;if(Blockly.bindEvent_(o,"contextmenu",null,function(e){Blockly.isTargetInput_(e)||e.preventDefault()}),Blockly.bindEvent_(o,"touchstart",null,function(e){Blockly.longStart_(e,null)}),Blockly.bindEvent_(window,"resize",null,function(){Blockly.svgResize(e)}),Blockly.documentEventsBound_||(Blockly.bindEvent_(document,"keydown",null,Blockly.onKeyDown_),Blockly.bindEvent_(document,"touchend",null,Blockly.longStop_),Blockly.bindEvent_(document,"touchcancel",null,Blockly.longStop_),document.addEventListener("mouseup",Blockly.onMouseUp_,!1),goog.userAgent.IPAD&&Blockly.bindEvent_(window,"orientationchange",document,function(){Blockly.fireUiEvent(window,"resize")}),Blockly.documentEventsBound_=!0),t.languageTree&&(e.toolbox_?e.toolbox_.init(e):e.flyout_&&(e.flyout_.init(e),e.flyout_.show(t.languageTree.childNodes),e.scrollX=e.flyout_.width_,t.RTL&&(e.scrollX*=-1),o="translate("+e.scrollX+", 0)",e.getCanvas().setAttribute("transform",o),e.getBubbleCanvas().setAttribute("transform",o))),t.hasScrollbars&&(e.scrollbar=new Blockly.ScrollbarPair(e),e.scrollbar.resize()),t.hasSounds){e.loadAudio_([t.pathToMedia+"click.mp3",t.pathToMedia+"click.wav",t.pathToMedia+"click.ogg"],"click"),e.loadAudio_([t.pathToMedia+"delete.mp3",t.pathToMedia+"delete.ogg",t.pathToMedia+"delete.wav"],"delete");var n=[],t=function(){for(;n.length;)Blockly.unbindEvent_(n.pop());e.preloadAudio_()};n.push(Blockly.bindEvent_(document,"mousemove",null,t)),n.push(Blockly.bindEvent_(document,"touchstart",null,t))}},Blockly.updateToolbox=function(e){console.warn("Deprecated call to Blockly.updateToolbox, use workspace.updateToolbox instead."),Blockly.getMainWorkspace().updateToolbox(e)},Blockly.utils={},Blockly.addClass_=function(e,t){var o=e.getAttribute("class")||"";-1==(" "+o+" ").indexOf(" "+t+" ")&&(o&&(o+=" "),e.setAttribute("class",o+t))},Blockly.removeClass_=function(e,t){var o=e.getAttribute("class");if(-1!=(" "+o+" ").indexOf(" "+t+" ")){for(var o=o.split(/\s+/),n=0;n<o.length;n++)o[n]&&o[n]!=t||(o.splice(n,1),n--);o.length?e.setAttribute("class",o.join(" ")):e.removeAttribute("class")}},Blockly.hasClass_=function(e,t){return-1!=(" "+e.getAttribute("class")+" ").indexOf(" "+t+" ")},Blockly.bindEvent_=function(e,t,o,n){var i=o?function(e){n.call(o,e)}:n;e.addEventListener(t,i,!1);var r=[[e,t,i]];if(t in Blockly.bindEvent_.TOUCH_MAP)for(var s,i=function(e){if(1==e.changedTouches.length){var t=e.changedTouches[0];e.clientX=t.clientX,e.clientY=t.clientY}n.call(o,e),e.preventDefault()},l=0;s=Blockly.bindEvent_.TOUCH_MAP[t][l];l++)e.addEventListener(s,i,!1),r.push([e,s,i]);return r},Blockly.bindEvent_.TOUCH_MAP={},goog.events.BrowserFeature.TOUCH_ENABLED&&(Blockly.bindEvent_.TOUCH_MAP={mousedown:["touchstart"],mousemove:["touchmove"],mouseup:["touchend","touchcancel"]}),Blockly.unbindEvent_=function(e){for(;e.length;){var t=e.pop(),o=t[2];t[0].removeEventListener(t[1],o,!1)}return o},Blockly.fireUiEventNow=function(e,t){var o=Blockly.fireUiEvent.DB_[t];if(o){var n=o.indexOf(e);-1!=n&&o.splice(n,1)}if(document.createEvent)o=document.createEvent("UIEvents"),o.initEvent(t,!0,!0),e.dispatchEvent(o);else{if(!document.createEventObject)throw"FireEvent: No event creation mechanism.";o=document.createEventObject(),e.fireEvent("on"+t,o)}},Blockly.fireUiEvent=function(e,t){var o=Blockly.fireUiEvent.DB_[t];if(o){if(-1!=o.indexOf(e))return;o.push(e)}else Blockly.fireUiEvent.DB_[t]=[e];setTimeout(function(){Blockly.fireUiEventNow(e,t)},0)},Blockly.fireUiEvent.DB_={},Blockly.noEvent=function(e){e.preventDefault(),e.stopPropagation()},Blockly.isTargetInput_=function(e){return"textarea"==e.target.type||"text"==e.target.type||"number"==e.target.type||"email"==e.target.type||"password"==e.target.type||"search"==e.target.type||"tel"==e.target.type||"url"==e.target.type},Blockly.getRelativeXY_=function(e){var t={x:0,y:0},o=e.getAttribute("x");return o&&(t.x=parseInt(o,10)),(o=e.getAttribute("y"))&&(t.y=parseInt(o,10)),(e=(e=e.getAttribute("transform"))&&e.match(/translate\(\s*([-\d.]+)([ ,]\s*([-\d.]+)\s*\))?/))&&(t.x+=parseInt(e[1],10),e[3]&&(t.y+=parseInt(e[3],10))),t},Blockly.getSvgXY_=function(e){var t=0,o=0;do{var n=Blockly.getRelativeXY_(e),t=t+n.x,o=o+n.y;e=e.parentNode}while(e&&"svg"!=e.nodeName.toLowerCase());return{x:t,y:o}},Blockly.createSvgElement=function(e,t,o){e=document.createElementNS(Blockly.SVG_NS,e);for(var n in t)e.setAttribute(n,t[n]);return document.body.runtimeStyle&&(e.runtimeStyle=e.currentStyle=e.style),o&&o.appendChild(e),e},Blockly.isRightButton=function(e){return e.ctrlKey&&goog.userAgent.MAC?!0:2==e.button},Blockly.convertCoordinates=function(e,t,o,n){o&&(e-=window.scrollX||window.pageXOffset,t-=window.scrollY||window.pageYOffset);var i=n.createSVGPoint();return i.x=e,i.y=t,e=n.getScreenCTM(),o&&(e=e.inverse()),i=i.matrixTransform(e),o||(i.x+=window.scrollX||window.pageXOffset,i.y+=window.scrollY||window.pageYOffset),i},Blockly.mouseToSvg=function(e,t){return Blockly.convertCoordinates(e.clientX+(window.scrollX||window.pageXOffset),e.clientY+(window.scrollY||window.pageYOffset),!0,t)},Blockly.shortestStringLength=function(e){if(!e.length)return 0;for(var t=e[0].length,o=1;o<e.length;o++)t=Math.min(t,e[o].length);return t},Blockly.commonWordPrefix=function(e,t){if(!e.length)return 0;if(1==e.length)return e[0].length;for(var o=0,n=t||Blockly.shortestStringLength(e),i=0;n>i;i++){for(var r=e[0][i],s=1;s<e.length;s++)if(r!=e[s][i])return o;" "==r&&(o=i+1)}for(s=1;s<e.length;s++)if((r=e[s][i])&&" "!=r)return o;return n},Blockly.commonWordSuffix=function(e,t){if(!e.length)return 0;if(1==e.length)return e[0].length;for(var o=0,n=t||Blockly.shortestStringLength(e),i=0;n>i;i++){for(var r=e[0].substr(-i-1,1),s=1;s<e.length;s++)if(r!=e[s].substr(-i-1,1))return o;" "==r&&(o=i+1)}for(s=1;s<e.length;s++)if((r=e[s].charAt(e[s].length-i-1))&&" "!=r)return o;return n},Blockly.isNumber=function(e){return!!e.match(/^\s*-?\d+(\.\d+)?\s*$/)},Blockly.SVG_NS="http://www.w3.org/2000/svg",Blockly.HTML_NS="http://www.w3.org/1999/xhtml",Blockly.HSV_SATURATION=.45,Blockly.HSV_VALUE=.65,Blockly.SPRITE={width:64,height:92,url:"sprites.png"},Blockly.makeColour=function(e){return goog.color.hsvToHex(e,Blockly.HSV_SATURATION,255*Blockly.HSV_VALUE)},Blockly.INPUT_VALUE=1,Blockly.OUTPUT_VALUE=2,Blockly.NEXT_STATEMENT=3,Blockly.PREVIOUS_STATEMENT=4,Blockly.DUMMY_INPUT=5,Blockly.ALIGN_LEFT=-1,Blockly.ALIGN_CENTRE=0,Blockly.ALIGN_RIGHT=1,Blockly.OPPOSITE_TYPE=[],Blockly.OPPOSITE_TYPE[Blockly.INPUT_VALUE]=Blockly.OUTPUT_VALUE,Blockly.OPPOSITE_TYPE[Blockly.OUTPUT_VALUE]=Blockly.INPUT_VALUE,Blockly.OPPOSITE_TYPE[Blockly.NEXT_STATEMENT]=Blockly.PREVIOUS_STATEMENT,Blockly.OPPOSITE_TYPE[Blockly.PREVIOUS_STATEMENT]=Blockly.NEXT_STATEMENT,Blockly.selected=null,Blockly.highlightedConnection_=null,Blockly.localConnection_=null,Blockly.DRAG_RADIUS=5,Blockly.SNAP_RADIUS=20,Blockly.BUMP_DELAY=250,Blockly.COLLAPSE_CHARS=30,Blockly.LONGPRESS=750,Blockly.mainWorkspace=null,Blockly.clipboardXml_=null,Blockly.clipboardSource_=null,Blockly.dragMode_=0,Blockly.onTouchUpWrapper_=null,Blockly.svgSize=function(e){return{width:e.cachedWidth_,height:e.cachedHeight_}},Blockly.svgResize=function(e){for(;e.options.parentWorkspace;)e=e.options.parentWorkspace;var t=e.options.svg,o=t.parentNode;if(o){var n=o.offsetWidth,o=o.offsetHeight;t.cachedWidth_!=n&&(t.setAttribute("width",n+"px"),t.cachedWidth_=n),t.cachedHeight_!=o&&(t.setAttribute("height",o+"px"),t.cachedHeight_=o),e.resize()}},Blockly.onMouseUp_=function(e){e=Blockly.getMainWorkspace(),Blockly.Css.setCursor(Blockly.Css.Cursor.OPEN),e.isScrolling=!1,Blockly.onTouchUpWrapper_&&(Blockly.unbindEvent_(Blockly.onTouchUpWrapper_),Blockly.onTouchUpWrapper_=null),Blockly.onMouseMoveWrapper_&&(Blockly.unbindEvent_(Blockly.onMouseMoveWrapper_),Blockly.onMouseMoveWrapper_=null)},Blockly.onMouseMove_=function(e){var t=Blockly.getMainWorkspace();if(t.isScrolling){Blockly.removeAllRanges();var o=e.clientX-t.startDragMouseX,n=e.clientY-t.startDragMouseY,i=t.startDragMetrics,r=t.startScrollX+o,s=t.startScrollY+n,r=Math.min(r,-i.contentLeft),s=Math.min(s,-i.contentTop),r=Math.max(r,i.viewWidth-i.contentLeft-i.contentWidth),s=Math.max(s,i.viewHeight-i.contentTop-i.contentHeight);t.scrollbar.set(-r-i.contentLeft,-s-i.contentTop),Math.sqrt(Math.pow(o,2)+Math.pow(n,2))>Blockly.DRAG_RADIUS&&Blockly.longStop_(),e.stopPropagation()}},Blockly.onKeyDown_=function(e){if(!Blockly.isTargetInput_(e))if(27==e.keyCode)Blockly.hideChaff();else if(8==e.keyCode||46==e.keyCode)try{Blockly.selected&&Blockly.selected.isDeletable()&&(Blockly.hideChaff(),Blockly.selected.dispose(!0,!0))}finally{e.preventDefault()}else(e.altKey||e.ctrlKey||e.metaKey)&&(Blockly.selected&&Blockly.selected.isDeletable()&&Blockly.selected.isMovable()&&(Blockly.hideChaff(),67==e.keyCode?Blockly.copy_(Blockly.selected):88==e.keyCode&&(Blockly.copy_(Blockly.selected),Blockly.selected.dispose(!0,!0))),86==e.keyCode&&Blockly.clipboardXml_&&Blockly.clipboardSource_.paste(Blockly.clipboardXml_))},Blockly.terminateDrag_=function(){Blockly.BlockSvg.terminateDrag_(),Blockly.Flyout.terminateDrag_()},Blockly.longPid_=0,Blockly.longStart_=function(e,t){Blockly.longStop_(),Blockly.longPid_=setTimeout(function(){e.button=2,t?t.onMouseDown_(e):Blockly.onMouseDown_(e)},Blockly.LONGPRESS)},Blockly.longStop_=function(){Blockly.longPid_&&(clearTimeout(Blockly.longPid_),Blockly.longPid_=0)},Blockly.copy_=function(e){var t=Blockly.Xml.blockToDom_(e);Blockly.Xml.deleteNext(t);var o=e.getRelativeToSurfaceXY();t.setAttribute("x",e.RTL?-o.x:o.x),t.setAttribute("y",o.y),Blockly.clipboardXml_=t,Blockly.clipboardSource_=e.workspace},Blockly.onContextMenu_=function(e){Blockly.isTargetInput_(e)||e.preventDefault()},Blockly.hideChaff=function(e){Blockly.Tooltip.hide(),Blockly.WidgetDiv.hide(),e||(e=Blockly.getMainWorkspace(),e.toolbox_&&e.toolbox_.flyout_&&e.toolbox_.flyout_.autoClose&&e.toolbox_.clearSelection())},Blockly.removeAllRanges=function(){getSelection()&&setTimeout(function(){try{var e=getSelection();e.isCollapsed||e.removeAllRanges()}catch(t){}},0)},Blockly.getMainWorkspaceMetrics_=function(){var e=Blockly.svgSize(this.options.svg);this.toolbox_&&(e.width-=this.toolbox_.width);var t=e.width-Blockly.Scrollbar.scrollbarThickness,o=e.height-Blockly.Scrollbar.scrollbarThickness;try{var n=this.getCanvas().getBBox()}catch(i){return null}if(this.scrollbar)var r=this.RTL?0:Blockly.Scrollbar.scrollbarThickness,s=Math.min(n.x-t/2,n.x+n.width-t-(this.RTL?Blockly.Scrollbar.scrollbarThickness:0)+5),t=Math.max(n.x+n.width+t/2,n.x+t+r-5),r=Math.min(n.y-o/2,n.y+n.height-o+5),o=Math.max(n.y+n.height+o/2,n.y+o+Blockly.Scrollbar.scrollbarThickness-5);else s=n.x,t=s+n.width,r=n.y,o=r+n.height;
|
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
|
-
}},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},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);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;
|
36
|
-
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()})},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},Blockly.Ruby.defineCharacter=function(e){var t,o,n;
|
38
|
-
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("")
|
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
|
+
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
|
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-35b1374d4d6717b94196f5c3f66db1a9.js":{"logical_path":"application.js","mtime":"2015-05-29T21:49:21+09:00","size":1322860,"digest":"35b1374d4d6717b94196f5c3f66db1a9"},"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-35b1374d4d6717b94196f5c3f66db1a9.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"}}
|
@@ -78,23 +78,6 @@
|
|
78
78
|
ならば "~/1102" ディレクトリに "01.rb" が存在すること
|
79
79
|
かつ "~/1102" ディレクトリの "01.rb" の内容が "puts 'Hello, World!'" であること
|
80
80
|
|
81
|
-
シナリオ: ログイン後、再度トップページを表示する
|
82
|
-
前提 "トップページ" にアクセスする
|
83
|
-
かつ "ログインボタン" をクリックする
|
84
|
-
かつ JavaScriptによるアニメーションが終わるまで待つ
|
85
|
-
かつ "ログインダイアログの名前" に "1102" を指定する
|
86
|
-
かつ "ログインダイアログのログインボタン" をクリックする
|
87
|
-
かつ JavaScriptによるリクエストが終わるまで待つ
|
88
|
-
|
89
|
-
もし "トップページ" にアクセスする
|
90
|
-
|
91
|
-
ならば "メニュー" に "ログイン" を含まないこと
|
92
|
-
かつ "メニュー" に "1102" を含むこと
|
93
|
-
|
94
|
-
もし "サブメニューボタン" をクリックする
|
95
|
-
|
96
|
-
ならば "サブメニュー" に "ログアウト" を含むこと
|
97
|
-
|
98
81
|
シナリオ: enabled_must_signinが有効な状態で、いったんログインしてからリロードするとログイン状態を維持できるのですが、その状態でログアウトしたときに表示されるログイン画面をESCキーや「やめる」ボタンでキャンセルできないこと
|
99
82
|
前提 次のRubyのスクリプトを実行する:
|
100
83
|
"""
|
@@ -124,3 +107,20 @@
|
|
124
107
|
|
125
108
|
ならば "#signin-modal" が表示されていること
|
126
109
|
かつ "#signin-modal-cancel-button" が表示されていないこと
|
110
|
+
|
111
|
+
シナリオ: ログイン後、再度トップページを表示する
|
112
|
+
前提 "トップページ" にアクセスする
|
113
|
+
かつ "ログインボタン" をクリックする
|
114
|
+
かつ JavaScriptによるアニメーションが終わるまで待つ
|
115
|
+
かつ "ログインダイアログの名前" に "1102" を指定する
|
116
|
+
かつ "ログインダイアログのログインボタン" をクリックする
|
117
|
+
かつ JavaScriptによるリクエストが終わるまで待つ
|
118
|
+
|
119
|
+
もし "トップページ" にアクセスする
|
120
|
+
|
121
|
+
ならば "メニュー" に "ログイン" を含まないこと
|
122
|
+
かつ "メニュー" に "1102" を含むこと
|
123
|
+
|
124
|
+
もし "サブメニューボタン" をクリックする
|
125
|
+
|
126
|
+
ならば "サブメニュー" に "ログアウト" を含むこと
|
data/spec/spec_helper.rb
CHANGED
@@ -100,7 +100,7 @@ RSpec.configure do |config|
|
|
100
100
|
config.include ActionView::Helpers::JavaScriptHelper, type: :feature
|
101
101
|
config.include FeatureHelper, type: :feature
|
102
102
|
|
103
|
-
config.before(:
|
103
|
+
config.before(:each) do
|
104
104
|
Preference.user_defaults.each do |key, value|
|
105
105
|
Preference[key] = value
|
106
106
|
end
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kouji Takao
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -483,8 +483,8 @@ files:
|
|
483
483
|
- public/422.html
|
484
484
|
- public/500.html
|
485
485
|
- public/apple-touch-icon.png
|
486
|
-
- public/assets/application-
|
487
|
-
- public/assets/application-
|
486
|
+
- public/assets/application-35b1374d4d6717b94196f5c3f66db1a9.js
|
487
|
+
- public/assets/application-35b1374d4d6717b94196f5c3f66db1a9.js.gz
|
488
488
|
- public/assets/application-f879948b97a781e3d996535a2a0585fa.css
|
489
489
|
- public/assets/application-f879948b97a781e3d996535a2a0585fa.css.gz
|
490
490
|
- public/assets/blockly/msg/js/en_us-d5e1938b2d57c1df954f4411b9165d10.js
|
@@ -507,7 +507,7 @@ files:
|
|
507
507
|
- public/assets/jquery-ui/ui-icons_888888_256x240-ce584ffa171c3ea9a018cf0d7bec65c8.png
|
508
508
|
- public/assets/jquery-ui/ui-icons_cd0a0a_256x240-747e96029e8dedcabc224e5f7d1f2ede.png
|
509
509
|
- public/assets/loading-e77296be32d066d3e29d3bf9803fa417.gif
|
510
|
-
- public/assets/manifest-
|
510
|
+
- public/assets/manifest-fad4a04f58abb204f6d35a9845835730.json
|
511
511
|
- public/assets/msg/en_us-a98cc83805d44f5f675fe6eac2c955ec.js
|
512
512
|
- public/assets/msg/en_us-a98cc83805d44f5f675fe6eac2c955ec.js.gz
|
513
513
|
- public/assets/msg/ja-243b0a55ef1086ef2180af94c422cb5e.js
|