Merge pull request #298 from google/develop

Undo/Redo
This commit is contained in:
Neil Fraser
2016-03-24 16:56:58 -07:00
136 changed files with 5888 additions and 2336 deletions
+1
View File
@@ -30,6 +30,7 @@ blockly/
|- blocks_compressed.js
|- dart_compressed.js
|- javascript_compressed.js
|- lua_compressed.js
|- php_compressed.js
`- python_compressed.js
+141 -116
View File
@@ -852,12 +852,14 @@ goog.ui.tree.TreeControl.prototype.createNode=function(a){return new goog.ui.tre
// Copyright 2013 Google Inc. Apache License 2.0
var Blockly={Blocks:{}};
// Copyright 2012 Google Inc. Apache License 2.0
Blockly.Workspace=function(a){this.id=Blockly.genUid();Blockly.Workspace.WorkspaceDB_[this.id]=this;this.options=a||{};this.RTL=!!this.options.RTL;this.topBlocks_=[];this.listeners_=[]};Blockly.Workspace.prototype.rendered=!1;Blockly.Workspace.prototype.dispose=function(){this.listeners_.length=0;this.clear();delete Blockly.Workspace.WorkspaceDB_[this.id]};Blockly.Workspace.SCAN_ANGLE=3;Blockly.Workspace.prototype.addTopBlock=function(a){this.topBlocks_.push(a)};
Blockly.Workspace.prototype.removeTopBlock=function(a){for(var b=!1,c,d=0;c=this.topBlocks_[d];d++)if(c==a){this.topBlocks_.splice(d,1);b=!0;break}if(!b)throw"Block not present in workspace's list of top-most blocks.";};
Blockly.Workspace.prototype.getTopBlocks=function(a){var b=[].concat(this.topBlocks_);if(a&&1<b.length){var c=Math.sin(goog.math.toRadians(Blockly.Workspace.SCAN_ANGLE));this.RTL&&(c*=-1);b.sort(function(a,b){var f=a.getRelativeToSurfaceXY(),g=b.getRelativeToSurfaceXY();return f.y+c*f.x-(g.y+c*g.x)})}return b};Blockly.Workspace.prototype.getAllBlocks=function(){for(var a=this.getTopBlocks(!1),b=0;b<a.length;b++)a.push.apply(a,a[b].getChildren());return a};Blockly.Workspace.prototype.clear=function(){for(;this.topBlocks_.length;)this.topBlocks_[0].dispose()};
Blockly.Workspace.prototype.getWidth=function(){return 0};Blockly.Workspace.prototype.newBlock=function(a,b){return new Blockly.Block(this,a,b)};Blockly.Workspace.prototype.getBlockById=function(a){for(var b=this.getAllBlocks(),c=0,d;d=b[c];c++)if(d.id==a)return d;return null};Blockly.Workspace.prototype.remainingCapacity=function(){return isNaN(this.options.maxBlocks)?Infinity:this.options.maxBlocks-this.getAllBlocks().length};
Blockly.Workspace.prototype.addChangeListener=function(a){this.listeners_.push(a);return a};Blockly.Workspace.prototype.removeChangeListener=function(a){a=this.listeners_.indexOf(a);-1!=a&&this.listeners_.splice(a,1)};Blockly.Workspace.prototype.fireChangeListener=function(a){for(var b=0,c;c=this.listeners_[b];b++)c(a)};Blockly.Workspace.WorkspaceDB_=Object.create(null);Blockly.Workspace.getById=function(a){return Blockly.Workspace.WorkspaceDB_[a]||null};Blockly.Workspace.prototype.clear=Blockly.Workspace.prototype.clear;
Blockly.Workspace.prototype.addChangeListener=Blockly.Workspace.prototype.addChangeListener;Blockly.Workspace.prototype.removeChangeListener=Blockly.Workspace.prototype.removeChangeListener;Blockly.Bubble=function(a,b,c,d,e,f,g){this.workspace_=a;this.content_=b;this.shape_=c;c=Blockly.Bubble.ARROW_ANGLE;this.workspace_.RTL&&(c=-c);this.arrow_radians_=goog.math.toRadians(c);a.getBubbleCanvas().appendChild(this.createDom_(b,!(!f||!g)));this.setAnchorLocation(d,e);f&&g||(b=this.content_.getBBox(),f=b.width+2*Blockly.Bubble.BORDER_WIDTH,g=b.height+2*Blockly.Bubble.BORDER_WIDTH);this.setBubbleSize(f,g);this.positionBubble_();this.renderArrow_();this.rendered_=!0;a.options.readOnly||(Blockly.bindEvent_(this.bubbleBack_,
Blockly.Workspace=function(a){this.id=Blockly.genUid();Blockly.Workspace.WorkspaceDB_[this.id]=this;this.options=a||{};this.RTL=!!this.options.RTL;this.topBlocks_=[];this.listeners_=[];this.undoStack_=[];this.redoStack_=[]};Blockly.Workspace.prototype.rendered=!1;Blockly.Workspace.prototype.MAX_UNDO=1024;Blockly.Workspace.prototype.dispose=function(){this.listeners_.length=0;this.clear();delete Blockly.Workspace.WorkspaceDB_[this.id]};Blockly.Workspace.SCAN_ANGLE=3;
Blockly.Workspace.prototype.addTopBlock=function(a){this.topBlocks_.push(a)};Blockly.Workspace.prototype.removeTopBlock=function(a){for(var b=!1,c,d=0;c=this.topBlocks_[d];d++)if(c==a){this.topBlocks_.splice(d,1);b=!0;break}if(!b)throw"Block not present in workspace's list of top-most blocks.";};
Blockly.Workspace.prototype.getTopBlocks=function(a){var b=[].concat(this.topBlocks_);if(a&&1<b.length){var c=Math.sin(goog.math.toRadians(Blockly.Workspace.SCAN_ANGLE));this.RTL&&(c*=-1);b.sort(function(a,b){var f=a.getRelativeToSurfaceXY(),g=b.getRelativeToSurfaceXY();return f.y+c*f.x-(g.y+c*g.x)})}return b};Blockly.Workspace.prototype.getAllBlocks=function(){for(var a=this.getTopBlocks(!1),b=0;b<a.length;b++)a.push.apply(a,a[b].getChildren());return a};
Blockly.Workspace.prototype.clear=function(){var a=Blockly.Events.getGroup();for(a||Blockly.Events.setGroup(!0);this.topBlocks_.length;)this.topBlocks_[0].dispose();a||Blockly.Events.setGroup(!1)};Blockly.Workspace.prototype.getWidth=function(){return 0};Blockly.Workspace.prototype.newBlock=function(a,b){return new Blockly.Block(this,a,b)};Blockly.Workspace.prototype.getBlockById=function(a){for(var b=this.getAllBlocks(),c=0,d;d=b[c];c++)if(d.id==a)return d;return null};
Blockly.Workspace.prototype.remainingCapacity=function(){return isNaN(this.options.maxBlocks)?Infinity:this.options.maxBlocks-this.getAllBlocks().length};
Blockly.Workspace.prototype.undo=function(a){var b=a?this.redoStack_:this.undoStack_,c=a?this.undoStack_:this.redoStack_,d=b.pop();if(d){for(var e=[d];b.length&&d.group&&d.group==b[b.length-1].group;)e.push(b.pop());for(b=0;d=e[b];b++)c.push(d);e=Blockly.Events.filter(e,a);Blockly.Events.recordUndo=!1;for(b=0;d=e[b];b++)d.run(a);Blockly.Events.recordUndo=!0}};Blockly.Workspace.prototype.addChangeListener=function(a){this.listeners_.push(a);return a};
Blockly.Workspace.prototype.removeChangeListener=function(a){a=this.listeners_.indexOf(a);-1!=a&&this.listeners_.splice(a,1)};Blockly.Workspace.prototype.fireChangeListener=function(a){a.recordUndo&&(this.undoStack_.push(a),this.redoStack_.length=0,this.undoStack_.length>this.MAX_UNDO&&this.undoStack_.unshift());for(var b=0,c;c=this.listeners_[b];b++)c(a)};Blockly.Workspace.WorkspaceDB_=Object.create(null);Blockly.Workspace.getById=function(a){return Blockly.Workspace.WorkspaceDB_[a]||null};
Blockly.Workspace.prototype.clear=Blockly.Workspace.prototype.clear;Blockly.Workspace.prototype.addChangeListener=Blockly.Workspace.prototype.addChangeListener;Blockly.Workspace.prototype.removeChangeListener=Blockly.Workspace.prototype.removeChangeListener;Blockly.Bubble=function(a,b,c,d,e,f,g){this.workspace_=a;this.content_=b;this.shape_=c;c=Blockly.Bubble.ARROW_ANGLE;this.workspace_.RTL&&(c=-c);this.arrow_radians_=goog.math.toRadians(c);a.getBubbleCanvas().appendChild(this.createDom_(b,!(!f||!g)));this.setAnchorLocation(d,e);f&&g||(b=this.content_.getBBox(),f=b.width+2*Blockly.Bubble.BORDER_WIDTH,g=b.height+2*Blockly.Bubble.BORDER_WIDTH);this.setBubbleSize(f,g);this.positionBubble_();this.renderArrow_();this.rendered_=!0;a.options.readOnly||(Blockly.bindEvent_(this.bubbleBack_,
"mousedown",this,this.bubbleMouseDown_),this.resizeGroup_&&Blockly.bindEvent_(this.resizeGroup_,"mousedown",this,this.resizeMouseDown_))};Blockly.Bubble.BORDER_WIDTH=6;Blockly.Bubble.ARROW_THICKNESS=10;Blockly.Bubble.ARROW_ANGLE=20;Blockly.Bubble.ARROW_BEND=4;Blockly.Bubble.ANCHOR_RADIUS=8;Blockly.Bubble.onMouseUpWrapper_=null;Blockly.Bubble.onMouseMoveWrapper_=null;
Blockly.Bubble.unbindDragEvents_=function(){Blockly.Bubble.onMouseUpWrapper_&&(Blockly.unbindEvent_(Blockly.Bubble.onMouseUpWrapper_),Blockly.Bubble.onMouseUpWrapper_=null);Blockly.Bubble.onMouseMoveWrapper_&&(Blockly.unbindEvent_(Blockly.Bubble.onMouseMoveWrapper_),Blockly.Bubble.onMouseMoveWrapper_=null)};Blockly.Bubble.prototype.rendered_=!1;Blockly.Bubble.prototype.anchorX_=0;Blockly.Bubble.prototype.anchorY_=0;Blockly.Bubble.prototype.relativeLeft_=0;Blockly.Bubble.prototype.relativeTop_=0;
Blockly.Bubble.prototype.width_=0;Blockly.Bubble.prototype.height_=0;Blockly.Bubble.prototype.autoLayout_=!0;
@@ -890,29 +892,33 @@ this.foreignObject_.appendChild(a);Blockly.bindEvent_(this.textarea_,"mouseup",t
Blockly.Comment.prototype.updateEditable=function(){this.isVisible()&&(this.setVisible(!1),this.setVisible(!0));Blockly.Icon.prototype.updateEditable.call(this)};Blockly.Comment.prototype.resizeBubble_=function(){var a=this.bubble_.getBubbleSize(),b=2*Blockly.Bubble.BORDER_WIDTH;this.foreignObject_.setAttribute("width",a.width-b);this.foreignObject_.setAttribute("height",a.height-b);this.textarea_.style.width=a.width-b-4+"px";this.textarea_.style.height=a.height-b-4+"px"};
Blockly.Comment.prototype.setVisible=function(a){if(a!=this.isVisible())if(!this.block_.isEditable()&&!this.textarea_||goog.userAgent.IE)Blockly.Warning.prototype.setVisible.call(this,a);else{var b=this.getText(),c=this.getBubbleSize();a?(this.bubble_=new Blockly.Bubble(this.block_.workspace,this.createEditor_(),this.block_.svgPath_,this.iconX_,this.iconY_,this.width_,this.height_),this.bubble_.registerResizeEvent(this,this.resizeBubble_),this.updateColour()):(this.bubble_.dispose(),this.foreignObject_=
this.textarea_=this.bubble_=null);this.setText(b);this.setBubbleSize(c.width,c.height)}};Blockly.Comment.prototype.textareaFocus_=function(a){this.bubble_.promote_();this.textarea_.focus()};Blockly.Comment.prototype.getBubbleSize=function(){return this.isVisible()?this.bubble_.getBubbleSize():{width:this.width_,height:this.height_}};Blockly.Comment.prototype.setBubbleSize=function(a,b){this.textarea_?this.bubble_.setBubbleSize(a,b):(this.width_=a,this.height_=b)};
Blockly.Comment.prototype.getText=function(){return this.textarea_?this.textarea_.value:this.text_};Blockly.Comment.prototype.setText=function(a){this.text_!=a&&(Blockly.Events.fire(new Blockly.Events.Change(this.block_,"comment",null,this.text_,a)),this.text_=a);this.textarea_&&(this.textarea_.value=a)};Blockly.Comment.prototype.dispose=function(){Blockly.Events.isEnabled()&&this.setText("");this.block_.comment=null;Blockly.Icon.prototype.dispose.call(this)};Blockly.Connection=function(a,b){this.sourceBlock_=a;this.type=b;a.workspace.connectionDBList&&(this.db_=a.workspace.connectionDBList[b],this.dbOpposite_=a.workspace.connectionDBList[Blockly.OPPOSITE_TYPE[b]],this.hidden_=!this.db_)};Blockly.Connection.prototype.targetConnection=null;Blockly.Connection.prototype.check_=null;Blockly.Connection.prototype.shadowDom_=null;Blockly.Connection.prototype.x_=0;Blockly.Connection.prototype.y_=0;Blockly.Connection.prototype.inDB_=!1;
Blockly.Connection.prototype.db_=null;Blockly.Connection.prototype.dbOpposite_=null;Blockly.Connection.prototype.hidden_=null;Blockly.Connection.prototype.dispose=function(){if(this.targetConnection)throw"Disconnect connection before disposing of it.";this.inDB_&&this.db_.removeConnection_(this);Blockly.highlightedConnection_==this&&(Blockly.highlightedConnection_=null);Blockly.localConnection_==this&&(Blockly.localConnection_=null);this.dbOpposite_=this.db_=null};
Blockly.Connection.prototype.isSuperior=function(){return this.type==Blockly.INPUT_VALUE||this.type==Blockly.NEXT_STATEMENT};
Blockly.Connection.prototype.connect=function(a){if(this.sourceBlock_==a.sourceBlock_)throw"Attempted to connect a block to itself.";if(this.sourceBlock_.workspace!==a.sourceBlock_.workspace)throw"Blocks are on different workspaces.";if(Blockly.OPPOSITE_TYPE[this.type]!=a.type)throw"Attempt to connect incompatible types.";if(this.targetConnection)throw"Source connection already connected.";if(a.targetConnection){var b=a.targetBlock();if(b.isShadow())b.dispose(),b=null;else if(this.type==Blockly.INPUT_VALUE||
this.type==Blockly.OUTPUT_VALUE){b.setParent(null);if(!b.outputConnection)throw"Orphan block does not have an output connection.";for(var c=this.sourceBlock_,d;d=Blockly.Connection.singleConnection_(c,b);)if(c=d.targetBlock(),!c||c.isShadow()){b.outputConnection.connect(d);b=null;break}}else if(this.type==Blockly.PREVIOUS_STATEMENT){b.setParent(null);if(!b.previousConnection)throw"Orphan block does not have a previous connection.";for(c=this.sourceBlock_;c.nextConnection;)if(c.nextConnection.targetConnection)c=
c.getNextBlock();else{b.previousConnection.checkType_(c.nextConnection)&&(c.nextConnection.connect(b.previousConnection),b=null);break}}else throw"Can only do a mid-stack connection with the top of a block.";b&&setTimeout(function(){b.workspace&&!b.getParent()&&b.outputConnection.bumpAwayFrom_(a)},Blockly.BUMP_DELAY)}this.isSuperior()?(c=this.sourceBlock_,d=a.sourceBlock_):(c=a.sourceBlock_,d=this.sourceBlock_);this.targetConnection=a;a.targetConnection=this;d.setParent(c);c.rendered&&c.updateDisabled();
d.rendered&&d.updateDisabled();c.rendered&&d.rendered&&(this.type==Blockly.NEXT_STATEMENT||this.type==Blockly.PREVIOUS_STATEMENT?d.render():c.render())};Blockly.Connection.singleConnection_=function(a,b){for(var c=!1,d=0;d<a.inputList.length;d++){var e=a.inputList[d].connection;if(e&&e.type==Blockly.INPUT_VALUE&&b.outputConnection.checkType_(e)){if(c)return null;c=e}}return c};
Blockly.Connection.prototype.disconnect=function(){var a=this.targetConnection;if(!a)throw"Source connection not connected.";if(a.targetConnection!=this)throw"Target connection not connected to source connection.";this.targetConnection=a.targetConnection=null;var b,c;this.isSuperior()?(b=this.sourceBlock_,c=a.sourceBlock_,a=this):(b=a.sourceBlock_,c=this.sourceBlock_);var d=a.getShadowDom();if(b.workspace&&!c.isShadow()&&d){d=Blockly.Xml.domToBlock(b.workspace,d);if(d.outputConnection)a.connect(d.outputConnection);
else if(d.previousConnection)a.connect(d.previousConnection);else throw"Child block does not have output or previous statement.";d.initSvg();d.render(!1)}b.rendered&&b.render();c.rendered&&(c.updateDisabled(),c.render())};Blockly.Connection.prototype.targetBlock=function(){return this.targetConnection?this.targetConnection.sourceBlock_:null};
Blockly.Connection.prototype.bumpAwayFrom_=function(a){if(0==Blockly.dragMode_){var b=this.sourceBlock_.getRootBlock();if(!b.isInFlyout){var c=!1;if(!b.isMovable()){b=a.sourceBlock_.getRootBlock();if(!b.isMovable())return;a=this;c=!0}b.getSvgRoot().parentNode.appendChild(b.getSvgRoot());var d=a.x_+Blockly.SNAP_RADIUS-this.x_;a=a.y_+Blockly.SNAP_RADIUS-this.y_;c&&(a=-a);b.RTL&&(d=-d);b.moveBy(d,a)}}};
Blockly.Connection.prototype.moveTo=function(a,b){this.inDB_&&this.db_.removeConnection_(this);this.x_=a;this.y_=b;this.hidden_||this.db_.addConnection_(this)};Blockly.Connection.prototype.moveBy=function(a,b){this.moveTo(this.x_+a,this.y_+b)};
Blockly.Connection.prototype.highlight=function(){var a;a=this.type==Blockly.INPUT_VALUE||this.type==Blockly.OUTPUT_VALUE?"m 0,0 "+Blockly.BlockSvg.TAB_PATH_DOWN+" v 5":"m -20,0 h 5 "+Blockly.BlockSvg.NOTCH_PATH_LEFT+" h 5";var b=this.sourceBlock_.getRelativeToSurfaceXY();Blockly.Connection.highlightedPath_=Blockly.createSvgElement("path",{"class":"blocklyHighlightedConnectionPath",d:a,transform:"translate("+(this.x_-b.x)+","+(this.y_-b.y)+")"+(this.sourceBlock_.RTL?" scale(-1 1)":"")},this.sourceBlock_.getSvgRoot())};
Blockly.Connection.prototype.unhighlight=function(){goog.dom.removeNode(Blockly.Connection.highlightedPath_);delete Blockly.Connection.highlightedPath_};Blockly.Connection.prototype.tighten_=function(){var a=this.targetConnection.x_-this.x_,b=this.targetConnection.y_-this.y_;if(0!=a||0!=b){var c=this.targetBlock(),d=c.getSvgRoot();if(!d)throw"block is not rendered.";d=Blockly.getRelativeXY_(d);c.getSvgRoot().setAttribute("transform","translate("+(d.x-a)+","+(d.y-b)+")");c.moveConnections_(-a,-b)}};
Blockly.Connection.prototype.closest=function(a,b,c){function d(b){b=e[b];if((b.type==Blockly.OUTPUT_VALUE||b.type==Blockly.PREVIOUS_STATEMENT)&&b.targetConnection||b.type==Blockly.INPUT_VALUE&&b.targetConnection&&!b.targetBlock().isMovable()&&!b.targetBlock().isShadow()||!q.checkType_(b))return!0;var c=b.sourceBlock_;do{if(l==c)return!0;c=c.getParent()}while(c);var d=f-b.x_,c=g-b.y_,d=Math.sqrt(d*d+c*c);d<=a&&(k=b,a=d);return Math.abs(c)<a}if(this.targetConnection)return{connection:null,radius:a};
var e=this.dbOpposite_,f=this.x_+b,g=this.y_+c;b=0;for(var h=c=e.length-2;b<h;)e[h].y_<g?b=h:c=h,h=Math.floor((b+c)/2);c=b=h;var k=null,l=this.sourceBlock_,q=this;if(e.length){for(;0<=b&&d(b);)b--;do c++;while(c<e.length&&d(c))}return{connection:k,radius:a}};
Blockly.Connection.prototype.checkType_=function(a){var b=this.targetBlock();if(b&&!b.isMovable()&&!this.sourceBlock_.isMovable()||(b=a.targetBlock())&&!b.isMovable()&&!a.sourceBlock_.isMovable())return!1;if(!this.check_||!a.check_)return!0;for(b=0;b<this.check_.length;b++)if(-1!=a.check_.indexOf(this.check_[b]))return!0;return!1};
Blockly.Connection.prototype.setCheck=function(a){a?(goog.isArray(a)||(a=[a]),this.check_=a,this.targetConnection&&!this.checkType_(this.targetConnection)&&((this.isSuperior()?this.targetBlock():this.sourceBlock_).setParent(null),this.sourceBlock_.bumpNeighbours_())):this.check_=null;return this};Blockly.Connection.prototype.setShadowDom=function(a){this.shadowDom_=a};Blockly.Connection.prototype.getShadowDom=function(){return this.shadowDom_};
Blockly.Connection.prototype.neighbours_=function(a){function b(b){var f=d-c[b].x_,g=e-c[b].y_;Math.sqrt(f*f+g*g)<=a&&k.push(c[b]);return g<a}for(var c=this.dbOpposite_,d=this.x_,e=this.y_,f=0,g=c.length-2,h=g;f<h;)c[h].y_<e?f=h:g=h,h=Math.floor((f+g)/2);var g=f=h,k=[];if(c.length){for(;0<=f&&b(f);)f--;do g++;while(g<c.length&&b(g))}return k};Blockly.Connection.prototype.setHidden=function(a){(this.hidden_=a)&&this.inDB_?this.db_.removeConnection_(this):a||this.inDB_||this.db_.addConnection_(this)};
Blockly.Comment.prototype.getText=function(){return this.textarea_?this.textarea_.value:this.text_};Blockly.Comment.prototype.setText=function(a){this.text_!=a&&(Blockly.Events.fire(new Blockly.Events.Change(this.block_,"comment",null,this.text_,a)),this.text_=a);this.textarea_&&(this.textarea_.value=a)};Blockly.Comment.prototype.dispose=function(){Blockly.Events.isEnabled()&&this.setText("");this.block_.comment=null;Blockly.Icon.prototype.dispose.call(this)};Blockly.Connection=function(a,b){this.sourceBlock_=a;this.type=b;a.workspace.connectionDBList&&(this.db_=a.workspace.connectionDBList[b],this.dbOpposite_=a.workspace.connectionDBList[Blockly.OPPOSITE_TYPE[b]],this.hidden_=!this.db_)};Blockly.Connection.CAN_CONNECT=0;Blockly.Connection.REASON_SELF_CONNECTION=1;Blockly.Connection.REASON_WRONG_TYPE=2;Blockly.Connection.REASON_TARGET_NULL=3;Blockly.Connection.REASON_CHECKS_FAILED=4;Blockly.Connection.REASON_DIFFERENT_WORKSPACES=5;
Blockly.Connection.connect_=function(a,b){var c=a.getSourceBlock(),d=b.getSourceBlock();b.targetConnection&&b.disconnect();if(a.targetConnection){var e=a.targetBlock(),f=a.getShadowDom();a.setShadowDom(null);if(e.isShadow())f=Blockly.Xml.blockToDom(e),e.dispose(),e=null;else if(a.type==Blockly.INPUT_VALUE){if(!e.outputConnection)throw"Orphan block does not have an output connection.";var g=Blockly.Connection.lastConnectionInRow_(d,e);g&&(e.outputConnection.connect(g),e=null)}else if(a.type==Blockly.NEXT_STATEMENT){if(!e.previousConnection)throw"Orphan block does not have a previous connection.";
for(g=d;g.nextConnection;)if(g.nextConnection.targetConnection)g=g.getNextBlock();else{e.previousConnection.checkType_(g.nextConnection)&&(g.nextConnection.connect(e.previousConnection),e=null);break}}if(e&&(a.disconnect(),Blockly.Events.recordUndo)){var h=Blockly.Events.getGroup();setTimeout(function(){e.workspace&&!e.getParent()&&(Blockly.Events.setGroup(h),e.outputConnection?e.outputConnection.bumpAwayFrom_(a):e.previousConnection&&e.previousConnection.bumpAwayFrom_(a),Blockly.Events.setGroup(!1))},
Blockly.BUMP_DELAY)}a.setShadowDom(f)}var k;Blockly.Events.isEnabled()&&(k=new Blockly.Events.Move(d));Blockly.Connection.connectReciprocally_(a,b);d.setParent(c);k&&(k.recordNew(),Blockly.Events.fire(k));c.rendered&&c.updateDisabled();d.rendered&&d.updateDisabled();c.rendered&&d.rendered&&(a.type==Blockly.NEXT_STATEMENT||a.type==Blockly.PREVIOUS_STATEMENT?d.render():c.render())};Blockly.Connection.prototype.targetConnection=null;Blockly.Connection.prototype.check_=null;
Blockly.Connection.prototype.shadowDom_=null;Blockly.Connection.prototype.x_=0;Blockly.Connection.prototype.y_=0;Blockly.Connection.prototype.inDB_=!1;Blockly.Connection.prototype.db_=null;Blockly.Connection.prototype.dbOpposite_=null;Blockly.Connection.prototype.hidden_=null;
Blockly.Connection.prototype.dispose=function(){if(this.targetConnection)throw"Disconnect connection before disposing of it.";this.inDB_&&this.db_.removeConnection_(this);Blockly.highlightedConnection_==this&&(Blockly.highlightedConnection_=null);Blockly.localConnection_==this&&(Blockly.localConnection_=null);this.dbOpposite_=this.db_=null};Blockly.Connection.prototype.getSourceBlock=function(){return this.sourceBlock_};
Blockly.Connection.prototype.isSuperior=function(){return this.type==Blockly.INPUT_VALUE||this.type==Blockly.NEXT_STATEMENT};Blockly.Connection.prototype.distanceFrom=function(a){var b=this.x_-a.x_;a=this.y_-a.y_;return Math.sqrt(b*b+a*a)};
Blockly.Connection.prototype.canConnectWithReason_=function(a){if(a){if(this.sourceBlock_&&a.getSourceBlock()==this.sourceBlock_)return Blockly.Connection.REASON_SELF_CONNECTION;if(a.type!=Blockly.OPPOSITE_TYPE[this.type])return Blockly.Connection.REASON_WRONG_TYPE;if(this.sourceBlock_&&a.getSourceBlock()&&this.sourceBlock_.workspace!==a.getSourceBlock().workspace)return Blockly.Connection.REASON_DIFFERENT_WORKSPACES;if(!this.checkType_(a))return Blockly.Connection.REASON_CHECKS_FAILED}else return Blockly.Connection.REASON_TARGET_NULL;
return Blockly.Connection.CAN_CONNECT};
Blockly.Connection.prototype.checkConnection_=function(a){switch(this.canConnectWithReason_(a)){case Blockly.Connection.CAN_CONNECT:break;case Blockly.Connection.REASON_SELF_CONNECTION:throw"Attempted to connect a block to itself.";case Blockly.Connection.REASON_DIFFERENT_WORKSPACES:throw"Blocks not on same workspace.";case Blockly.Connection.REASON_WRONG_TYPE:throw"Attempt to connect incompatible types.";case Blockly.Connection.REASON_TARGET_NULL:throw"Target connection is null.";case Blockly.Connection.REASON_CHECKS_FAILED:throw"Connection checks failed.";
default:throw"Unknown connection failure: this should never happen!";}};
Blockly.Connection.prototype.isConnectionAllowed=function(a,b){if(this.distanceFrom(a)>b)return!1;var c=this.canConnectWithReason_(a);if(c!=Blockly.Connection.CAN_CONNECT&&c!=Blockly.Connection.REASON_MUST_DISCONNECT)return!1;if(a.type==Blockly.OUTPUT_VALUE||a.type==Blockly.PREVIOUS_STATEMENT)if(a.targetConnection||this.targetConnection)return!1;if(a.type==Blockly.INPUT_VALUE&&a.targetConnection&&!a.targetBlock().isMovable()&&!a.targetBlock().isShadow()||this.type==Blockly.PREVIOUS_STATEMENT&&a.targetConnection&&
!this.sourceBlock_.nextConnection)return!1;var c=a.getSourceBlock(),d=this.sourceBlock_;if(c&&d){do{if(d==c)return!1;c=c.getParent()}while(c)}return!0};Blockly.Connection.prototype.connect=function(a){this.targetConnection!=a&&(this.checkConnection_(a),this.isSuperior()?Blockly.Connection.connect_(this,a):Blockly.Connection.connect_(a,this))};Blockly.Connection.connectReciprocally_=function(a,b){goog.asserts.assert(a&&b,"Cannot connect null connections.");a.targetConnection=b;b.targetConnection=a};
Blockly.Connection.singleConnection_=function(a,b){for(var c=!1,d=0;d<a.inputList.length;d++){var e=a.inputList[d].connection;if(e&&e.type==Blockly.INPUT_VALUE&&b.outputConnection.checkType_(e)){if(c)return null;c=e}}return c};Blockly.Connection.lastConnectionInRow_=function(a,b){for(var c=a,d;d=Blockly.Connection.singleConnection_(c,b);)if(c=d.targetBlock(),!c||c.isShadow())return d;return null};
Blockly.Connection.prototype.disconnect=function(){var a=this.targetConnection;goog.asserts.assert(a,"Source connection not connected.");goog.asserts.assert(a.targetConnection==this,"Target connection not connected to source connection.");var b,c,d;this.isSuperior()?(b=this.sourceBlock_,c=a.getSourceBlock(),d=this):(b=a.getSourceBlock(),c=this.sourceBlock_,d=a);var e;Blockly.Events.isEnabled()&&(e=new Blockly.Events.Move(c));this.targetConnection=a.targetConnection=null;c.setParent(null);e&&(e.recordNew(),
Blockly.Events.fire(e));a=d.getShadowDom();if(b.workspace&&a&&Blockly.Events.recordUndo){a=Blockly.Xml.domToBlock(b.workspace,a);if(a.outputConnection)d.connect(a.outputConnection);else if(a.previousConnection)d.connect(a.previousConnection);else throw"Child block does not have output or previous statement.";a.initSvg();a.render(!1)}b.rendered&&b.render();c.rendered&&(c.updateDisabled(),c.render())};
Blockly.Connection.prototype.targetBlock=function(){return this.targetConnection?this.targetConnection.getSourceBlock():null};
Blockly.Connection.prototype.bumpAwayFrom_=function(a){if(0==Blockly.dragMode_){var b=this.sourceBlock_.getRootBlock();if(!b.isInFlyout){var c=!1;if(!b.isMovable()){b=a.getSourceBlock().getRootBlock();if(!b.isMovable())return;a=this;c=!0}b.getSvgRoot().parentNode.appendChild(b.getSvgRoot());var d=a.x_+Blockly.SNAP_RADIUS-this.x_;a=a.y_+Blockly.SNAP_RADIUS-this.y_;c&&(a=-a);b.RTL&&(d=-d);b.moveBy(d,a)}}};
Blockly.Connection.prototype.moveTo=function(a,b){this.inDB_&&this.db_.removeConnection_(this);this.x_=a;this.y_=b;this.hidden_||this.db_.addConnection(this)};Blockly.Connection.prototype.moveBy=function(a,b){this.moveTo(this.x_+a,this.y_+b)};
Blockly.Connection.prototype.tighten_=function(){var a=this.targetConnection.x_-this.x_,b=this.targetConnection.y_-this.y_;if(0!=a||0!=b){var c=this.targetBlock(),d=c.getSvgRoot();if(!d)throw"block is not rendered.";d=Blockly.getRelativeXY_(d);c.getSvgRoot().setAttribute("transform","translate("+(d.x-a)+","+(d.y-b)+")");c.moveConnections_(-a,-b)}};Blockly.Connection.prototype.closest=function(a,b,c){return this.dbOpposite_.searchForClosest(this,a,b,c)};
Blockly.Connection.prototype.checkType_=function(a){var b=this.targetBlock();if(b&&!b.isMovable()&&!this.sourceBlock_.isMovable()||(b=a.targetBlock())&&!b.isMovable()&&!a.getSourceBlock().isMovable())return!1;if(!this.check_||!a.check_)return!0;for(b=0;b<this.check_.length;b++)if(-1!=a.check_.indexOf(this.check_[b]))return!0;return!1};
Blockly.Connection.prototype.setCheck=function(a){a?(goog.isArray(a)||(a=[a]),this.check_=a,this.targetConnection&&!this.checkType_(this.targetConnection)&&((this.isSuperior()?this.targetBlock():this.sourceBlock_).unplug(),this.sourceBlock_.bumpNeighbours_())):this.check_=null;return this};Blockly.Connection.prototype.setShadowDom=function(a){this.shadowDom_=a};Blockly.Connection.prototype.getShadowDom=function(){return this.shadowDom_};
Blockly.Connection.prototype.neighbours_=function(a){return this.dbOpposite_.getNeighbours(this,a)};Blockly.Connection.prototype.setHidden=function(a){(this.hidden_=a)&&this.inDB_?this.db_.removeConnection_(this):a||this.inDB_||this.db_.addConnection(this)};
Blockly.Connection.prototype.hideAll=function(){this.setHidden(!0);if(this.targetConnection)for(var a=this.targetBlock().getDescendants(),b=0;b<a.length;b++){for(var c=a[b],d=c.getConnections_(!0),e=0;e<d.length;e++)d[e].setHidden(!0);c=c.getIcons();for(d=0;d<c.length;d++)c[d].setVisible(!1)}};
Blockly.Connection.prototype.unhideAll=function(){this.setHidden(!1);var a=[];if(this.type!=Blockly.INPUT_VALUE&&this.type!=Blockly.NEXT_STATEMENT)return a;var b=this.targetBlock();if(b){var c;b.isCollapsed()?(c=[],b.outputConnection&&c.push(b.outputConnection),b.nextConnection&&c.push(b.nextConnection),b.previousConnection&&c.push(b.previousConnection)):c=b.getConnections_(!0);for(var d=0;d<c.length;d++)a.push.apply(a,c[d].unhideAll());0==a.length&&(a[0]=b)}return a};Blockly.ConnectionDB=function(){};
Blockly.ConnectionDB.prototype=[];Blockly.ConnectionDB.constructor=Blockly.ConnectionDB;Blockly.ConnectionDB.prototype.addConnection_=function(a){if(a.inDB_)throw"Connection already in database.";if(!a.sourceBlock_.isInFlyout){for(var b=0,c=this.length;b<c;){var d=Math.floor((b+c)/2);if(this[d].y_<a.y_)b=d+1;else if(this[d].y_>a.y_)c=d;else{b=d;break}}this.splice(b,0,a);a.inDB_=!0}};
Blockly.ConnectionDB.prototype.removeConnection_=function(a){if(!a.inDB_)throw"Connection not in database.";a.inDB_=!1;for(var b=0,c=this.length-2,d=c;b<d;)this[d].y_<a.y_?b=d:c=d,d=Math.floor((b+c)/2);for(c=b=d;0<=b&&this[b].y_==a.y_;){if(this[b]==a){this.splice(b,1);return}b--}do{if(this[c]==a){this.splice(c,1);return}c++}while(c<this.length&&this[c].y_==a.y_);throw"Unable to find connection in connectionDB.";};
Blockly.ConnectionDB.init=function(a){var b=[];b[Blockly.INPUT_VALUE]=new Blockly.ConnectionDB;b[Blockly.OUTPUT_VALUE]=new Blockly.ConnectionDB;b[Blockly.NEXT_STATEMENT]=new Blockly.ConnectionDB;b[Blockly.PREVIOUS_STATEMENT]=new Blockly.ConnectionDB;a.connectionDBList=b};Blockly.Field=function(a,b){this.size_=new goog.math.Size(0,25);this.setValue(a);this.setValidator(b)};Blockly.Field.cacheWidths_=null;Blockly.Field.cacheReference_=0;Blockly.Field.prototype.name=void 0;Blockly.Field.prototype.maxDisplayLength=50;Blockly.Field.prototype.text_="";Blockly.Field.prototype.sourceBlock_=null;Blockly.Field.prototype.visible_=!0;Blockly.Field.prototype.validator_=null;Blockly.Field.NBSP="\u00a0";Blockly.Field.prototype.EDITABLE=!0;
Blockly.Connection.prototype.unhideAll=function(){this.setHidden(!1);var a=[];if(this.type!=Blockly.INPUT_VALUE&&this.type!=Blockly.NEXT_STATEMENT)return a;var b=this.targetBlock();if(b){var c;b.isCollapsed()?(c=[],b.outputConnection&&c.push(b.outputConnection),b.nextConnection&&c.push(b.nextConnection),b.previousConnection&&c.push(b.previousConnection)):c=b.getConnections_(!0);for(var d=0;d<c.length;d++)a.push.apply(a,c[d].unhideAll());a.length||(a[0]=b)}return a};
Blockly.Connection.prototype.highlight=function(){var a;a=this.type==Blockly.INPUT_VALUE||this.type==Blockly.OUTPUT_VALUE?"m 0,0 "+Blockly.BlockSvg.TAB_PATH_DOWN+" v 5":"m -20,0 h 5 "+Blockly.BlockSvg.NOTCH_PATH_LEFT+" h 5";var b=this.sourceBlock_.getRelativeToSurfaceXY();Blockly.Connection.highlightedPath_=Blockly.createSvgElement("path",{"class":"blocklyHighlightedConnectionPath",d:a,transform:"translate("+(this.x_-b.x)+","+(this.y_-b.y)+")"+(this.sourceBlock_.RTL?" scale(-1 1)":"")},this.sourceBlock_.getSvgRoot())};
Blockly.Connection.prototype.unhighlight=function(){goog.dom.removeNode(Blockly.Connection.highlightedPath_);delete Blockly.Connection.highlightedPath_};Blockly.Field=function(a,b){this.size_=new goog.math.Size(0,25);this.setValue(a);this.setValidator(b)};Blockly.Field.cacheWidths_=null;Blockly.Field.cacheReference_=0;Blockly.Field.prototype.name=void 0;Blockly.Field.prototype.maxDisplayLength=50;Blockly.Field.prototype.text_="";Blockly.Field.prototype.sourceBlock_=null;Blockly.Field.prototype.visible_=!0;Blockly.Field.prototype.validator_=null;Blockly.Field.NBSP="\u00a0";Blockly.Field.prototype.EDITABLE=!0;
Blockly.Field.prototype.init=function(a){this.sourceBlock_||(this.sourceBlock_=a,this.fieldGroup_=Blockly.createSvgElement("g",{},null),this.visible_||(this.fieldGroup_.style.display="none"),this.borderRect_=Blockly.createSvgElement("rect",{rx:4,ry:4,x:-Blockly.BlockSvg.SEP_SPACE_X/2,y:0,height:16},this.fieldGroup_,this.sourceBlock_.workspace),this.textElement_=Blockly.createSvgElement("text",{"class":"blocklyText",y:this.size_.height-12.5},this.fieldGroup_),this.updateEditable(),a.getSvgRoot().appendChild(this.fieldGroup_),
this.mouseUpWrapper_=Blockly.bindEvent_(this.fieldGroup_,"mouseup",this,this.onMouseUp_),this.updateTextNode_(),Blockly.Events.isEnabled()&&Blockly.Events.fire(new Blockly.Events.Change(this.sourceBlock_,"field",this.name,"",this.getValue())))};
Blockly.Field.prototype.dispose=function(){this.mouseUpWrapper_&&(Blockly.unbindEvent_(this.mouseUpWrapper_),this.mouseUpWrapper_=null);this.sourceBlock_=null;goog.dom.removeNode(this.fieldGroup_);this.validator_=this.borderRect_=this.textElement_=this.fieldGroup_=null};
@@ -939,11 +945,17 @@ Blockly.FieldLabel.prototype.dispose=function(){goog.dom.removeNode(this.textEle
Blockly.Input.prototype.appendField=function(a,b){if(!a&&!b)return this;goog.isString(a)&&(a=new Blockly.FieldLabel(a));this.sourceBlock_.rendered&&a.init(this.sourceBlock_);a.name=b;a.prefixField&&this.appendField(a.prefixField);this.fieldRow.push(a);a.suffixField&&this.appendField(a.suffixField);this.sourceBlock_.rendered&&(this.sourceBlock_.render(),this.sourceBlock_.bumpNeighbours_());return this};
Blockly.Input.prototype.appendTitle=function(a,b){console.warn("Deprecated call to appendTitle, use appendField instead.");return this.appendField(a,b)};Blockly.Input.prototype.removeField=function(a){for(var b=0,c;c=this.fieldRow[b];b++)if(c.name===a){c.dispose();this.fieldRow.splice(b,1);this.sourceBlock_.rendered&&(this.sourceBlock_.render(),this.sourceBlock_.bumpNeighbours_());return}goog.asserts.fail('Field "%s" not found.',a)};Blockly.Input.prototype.isVisible=function(){return this.visible_};
Blockly.Input.prototype.setVisible=function(a){var b=[];if(this.visible_==a)return b;for(var c=(this.visible_=a)?"block":"none",d=0,e;e=this.fieldRow[d];d++)e.setVisible(a);this.connection&&(a?b=this.connection.unhideAll():this.connection.hideAll(),d=this.connection.targetBlock())&&(d.getSvgRoot().style.display=c,a||(d.rendered=!1));return b};Blockly.Input.prototype.setCheck=function(a){if(!this.connection)throw"This input does not have a connection.";this.connection.setCheck(a);return this};
Blockly.Input.prototype.setAlign=function(a){this.align=a;this.sourceBlock_.rendered&&this.sourceBlock_.render();return this};Blockly.Input.prototype.init=function(){if(this.sourceBlock_.workspace.rendered)for(var a=0;a<this.fieldRow.length;a++)this.fieldRow[a].init(this.sourceBlock_)};Blockly.Input.prototype.dispose=function(){for(var a=0,b;b=this.fieldRow[a];a++)b.dispose();this.connection&&this.connection.dispose();this.sourceBlock_=null};Blockly.ScrollbarPair=function(a){this.workspace_=a;this.hScroll=new Blockly.Scrollbar(a,!0,!0);this.vScroll=new Blockly.Scrollbar(a,!1,!0);this.corner_=Blockly.createSvgElement("rect",{height:Blockly.Scrollbar.scrollbarThickness,width:Blockly.Scrollbar.scrollbarThickness,"class":"blocklyScrollbarBackground"},null);Blockly.Scrollbar.insertAfter_(this.corner_,a.getBubbleCanvas())};Blockly.ScrollbarPair.prototype.oldHostMetrics_=null;
Blockly.Input.prototype.setAlign=function(a){this.align=a;this.sourceBlock_.rendered&&this.sourceBlock_.render();return this};Blockly.Input.prototype.init=function(){if(this.sourceBlock_.workspace.rendered)for(var a=0;a<this.fieldRow.length;a++)this.fieldRow[a].init(this.sourceBlock_)};Blockly.Input.prototype.dispose=function(){for(var a=0,b;b=this.fieldRow[a];a++)b.dispose();this.connection&&this.connection.dispose();this.sourceBlock_=null};Blockly.ConnectionDB=function(){};Blockly.ConnectionDB.prototype=[];Blockly.ConnectionDB.constructor=Blockly.ConnectionDB;Blockly.ConnectionDB.prototype.addConnection=function(a){if(a.inDB_)throw"Connection already in database.";if(!a.getSourceBlock().isInFlyout){var b=this.findPositionForConnection_(a);this.splice(b,0,a);a.inDB_=!0}};
Blockly.ConnectionDB.prototype.findConnection=function(a){if(!this.length)return-1;var b=this.findPositionForConnection_(a);if(b>=this.length)return-1;for(var c=a.y_,d=b;0<=d&&this[d].y_==c;){if(this[d]==a)return d;d--}for(;b<this.length&&this[b].y_==c;){if(this[b]==a)return b;b++}return-1};
Blockly.ConnectionDB.prototype.findPositionForConnection_=function(a){if(!this.length)return 0;for(var b=0,c=this.length;b<c;){var d=Math.floor((b+c)/2);if(this[d].y_<a.y_)b=d+1;else if(this[d].y_>a.y_)c=d;else{b=d;break}}return b};Blockly.ConnectionDB.prototype.removeConnection_=function(a){if(!a.inDB_)throw"Connection not in database.";var b=this.findConnection(a);if(-1==b)throw"Unable to find connection in connectionDB.";a.inDB_=!1;this.splice(b,1)};
Blockly.ConnectionDB.prototype.getNeighbours=function(a,b){function c(a){var c=e-d[a].x_,g=f-d[a].y_;Math.sqrt(c*c+g*g)<=b&&l.push(d[a]);return g<b}for(var d=this,e=a.x_,f=a.y_,g=0,h=d.length-2,k=h;g<k;)d[k].y_<f?g=k:h=k,k=Math.floor((g+h)/2);var h=g=k,l=[];a.getSourceBlock();if(d.length){for(;0<=g&&c(g);)g--;do h++;while(h<d.length&&c(h))}return l};Blockly.ConnectionDB.prototype.isInYRange_=function(a,b,c){return Math.abs(this[a].y_-b)<=c};
Blockly.ConnectionDB.prototype.searchForClosest=function(a,b,c,d){if(!this.length)return{connection:null,radius:b};var e=a.y_,f=a.x_;a.x_=f+c;a.y_=e+d;var g=this.findPositionForConnection_(a);c=null;d=b;for(var h,k=g-1;0<=k&&this.isInYRange_(k,a.y_,b);)h=this[k],a.isConnectionAllowed(h,d)&&(c=h,d=h.distanceFrom(a)),k--;for(;g<this.length&&this.isInYRange_(g,a.y_,b);)h=this[g],a.isConnectionAllowed(h,d)&&(c=h,d=h.distanceFrom(a)),g++;a.x_=f;a.y_=e;return{connection:c,radius:d}};
Blockly.ConnectionDB.init=function(a){var b=[];b[Blockly.INPUT_VALUE]=new Blockly.ConnectionDB;b[Blockly.OUTPUT_VALUE]=new Blockly.ConnectionDB;b[Blockly.NEXT_STATEMENT]=new Blockly.ConnectionDB;b[Blockly.PREVIOUS_STATEMENT]=new Blockly.ConnectionDB;a.connectionDBList=b};Blockly.ScrollbarPair=function(a){this.workspace_=a;this.hScroll=new Blockly.Scrollbar(a,!0,!0);this.vScroll=new Blockly.Scrollbar(a,!1,!0);this.corner_=Blockly.createSvgElement("rect",{height:Blockly.Scrollbar.scrollbarThickness,width:Blockly.Scrollbar.scrollbarThickness,"class":"blocklyScrollbarBackground"},null);Blockly.Scrollbar.insertAfter_(this.corner_,a.getBubbleCanvas())};Blockly.ScrollbarPair.prototype.oldHostMetrics_=null;
Blockly.ScrollbarPair.prototype.dispose=function(){goog.dom.removeNode(this.corner_);this.oldHostMetrics_=this.workspace_=this.corner_=null;this.hScroll.dispose();this.hScroll=null;this.vScroll.dispose();this.vScroll=null};
Blockly.ScrollbarPair.prototype.resize=function(){var a=this.workspace_.getMetrics();if(a){var b=!1,c=!1;this.oldHostMetrics_&&this.oldHostMetrics_.viewWidth==a.viewWidth&&this.oldHostMetrics_.viewHeight==a.viewHeight&&this.oldHostMetrics_.absoluteTop==a.absoluteTop&&this.oldHostMetrics_.absoluteLeft==a.absoluteLeft?(this.oldHostMetrics_&&this.oldHostMetrics_.contentWidth==a.contentWidth&&this.oldHostMetrics_.viewLeft==a.viewLeft&&this.oldHostMetrics_.contentLeft==a.contentLeft||(b=!0),this.oldHostMetrics_&&
this.oldHostMetrics_.contentHeight==a.contentHeight&&this.oldHostMetrics_.viewTop==a.viewTop&&this.oldHostMetrics_.contentTop==a.contentTop||(c=!0)):c=b=!0;b&&this.hScroll.resize(a);c&&this.vScroll.resize(a);this.oldHostMetrics_&&this.oldHostMetrics_.viewWidth==a.viewWidth&&this.oldHostMetrics_.absoluteLeft==a.absoluteLeft||this.corner_.setAttribute("x",this.vScroll.xCoordinate);this.oldHostMetrics_&&this.oldHostMetrics_.viewHeight==a.viewHeight&&this.oldHostMetrics_.absoluteTop==a.absoluteTop||this.corner_.setAttribute("y",
this.hScroll.yCoordinate);this.oldHostMetrics_=a}};Blockly.ScrollbarPair.prototype.set=function(a,b){var c={},d=a*this.hScroll.ratio_;this.hScroll.svgKnob_.setAttribute("x",d);var e=parseFloat(this.hScroll.svgBackground_.getAttribute("width")),d=d/e;isNaN(d)&&(d=0);c.x=d;d=b*this.vScroll.ratio_;this.vScroll.svgKnob_.setAttribute("y",d);e=parseFloat(this.vScroll.svgBackground_.getAttribute("height"));d/=e;isNaN(d)&&(d=0);c.y=d;this.workspace_.setMetrics(c)};
this.hScroll.yCoordinate);this.oldHostMetrics_=a}};Blockly.ScrollbarPair.prototype.set=function(a,b){var c={},d=a*this.hScroll.ratio_,e=b*this.vScroll.ratio_,f=parseFloat(this.hScroll.svgBackground_.getAttribute("width")),g=parseFloat(this.vScroll.svgBackground_.getAttribute("height"));c.x=this.getRatio_(d,f);c.y=this.getRatio_(e,g);this.workspace_.setMetrics(c);this.hScroll.svgKnob_.setAttribute("x",d);this.vScroll.svgKnob_.setAttribute("y",e)};
Blockly.ScrollbarPair.prototype.getRatio_=function(a,b){var c=a/b;return isNaN(c)?0:c};
Blockly.Scrollbar=function(a,b,c){this.workspace_=a;this.pair_=c||!1;this.horizontal_=b;this.createDom_();b?(this.svgBackground_.setAttribute("height",Blockly.Scrollbar.scrollbarThickness),this.svgKnob_.setAttribute("height",Blockly.Scrollbar.scrollbarThickness-5),this.svgKnob_.setAttribute("y",2.5)):(this.svgBackground_.setAttribute("width",Blockly.Scrollbar.scrollbarThickness),this.svgKnob_.setAttribute("width",Blockly.Scrollbar.scrollbarThickness-5),this.svgKnob_.setAttribute("x",2.5));this.onMouseDownBarWrapper_=
Blockly.bindEvent_(this.svgBackground_,"mousedown",this,this.onMouseDownBar_);this.onMouseDownKnobWrapper_=Blockly.bindEvent_(this.svgKnob_,"mousedown",this,this.onMouseDownKnob_)};Blockly.Scrollbar.scrollbarThickness=15;goog.events.BrowserFeature.TOUCH_ENABLED&&(Blockly.Scrollbar.scrollbarThickness=25);
Blockly.Scrollbar.prototype.dispose=function(){this.onMouseUpKnob_();Blockly.unbindEvent_(this.onMouseDownBarWrapper_);this.onMouseDownBarWrapper_=null;Blockly.unbindEvent_(this.onMouseDownKnobWrapper_);this.onMouseDownKnobWrapper_=null;goog.dom.removeNode(this.svgGroup_);this.workspace_=this.svgKnob_=this.svgBackground_=this.svgGroup_=null};
@@ -967,14 +979,7 @@ Blockly.SPRITE.url);Blockly.bindEvent_(this.svgGroup_,"mouseup",this,this.click)
Blockly.Trashcan.prototype.position=function(){var a=this.workspace_.getMetrics();a&&(this.left_=this.workspace_.RTL?this.MARGIN_SIDE_+Blockly.Scrollbar.scrollbarThickness:a.viewWidth+a.absoluteLeft-this.WIDTH_-this.MARGIN_SIDE_-Blockly.Scrollbar.scrollbarThickness,this.top_=a.viewHeight+a.absoluteTop-(this.BODY_HEIGHT_+this.LID_HEIGHT_)-this.bottom_,this.svgGroup_.setAttribute("transform","translate("+this.left_+","+this.top_+")"))};
Blockly.Trashcan.prototype.getClientRect=function(){var a=this.svgGroup_.getBoundingClientRect();return new goog.math.Rect(a.left-this.MARGIN_HOTSPOT_,a.top-this.MARGIN_HOTSPOT_,a.width+2*this.MARGIN_HOTSPOT_,a.height+2*this.MARGIN_HOTSPOT_)};Blockly.Trashcan.prototype.setOpen_=function(a){this.isOpen!=a&&(goog.Timer.clear(this.lidTask_),this.isOpen=a,this.animateLid_())};
Blockly.Trashcan.prototype.animateLid_=function(){this.lidOpen_+=this.isOpen?.2:-.2;this.lidOpen_=goog.math.clamp(this.lidOpen_,0,1);var a=45*this.lidOpen_;this.svgLid_.setAttribute("transform","rotate("+(this.workspace_.RTL?-a:a)+","+(this.workspace_.RTL?4:this.WIDTH_-4)+","+(this.LID_HEIGHT_-2)+")");a=goog.math.lerp(.4,.8,this.lidOpen_);this.svgGroup_.style.opacity=a;0<this.lidOpen_&&1>this.lidOpen_&&(this.lidTask_=goog.Timer.callOnce(this.animateLid_,20,this))};
Blockly.Trashcan.prototype.close=function(){this.setOpen_(!1)};Blockly.Trashcan.prototype.click=function(){var a=this.workspace_.startScrollX-this.workspace_.scrollX,b=this.workspace_.startScrollY-this.workspace_.scrollY;Math.sqrt(a*a+b*b)>Blockly.DRAG_RADIUS||console.log("TODO: Inspect trash.")};
// Copyright 2015 Google Inc. Apache License 2.0
Blockly.ZoomControls=function(a){this.workspace_=a};Blockly.ZoomControls.prototype.WIDTH_=32;Blockly.ZoomControls.prototype.HEIGHT_=110;Blockly.ZoomControls.prototype.MARGIN_BOTTOM_=20;Blockly.ZoomControls.prototype.MARGIN_SIDE_=20;Blockly.ZoomControls.prototype.svgGroup_=null;Blockly.ZoomControls.prototype.left_=0;Blockly.ZoomControls.prototype.top_=0;
Blockly.ZoomControls.prototype.createDom=function(){var a=this.workspace_;this.svgGroup_=Blockly.createSvgElement("g",{"class":"blocklyZoom"},null);var b=String(Math.random()).substring(2),c=Blockly.createSvgElement("clipPath",{id:"blocklyZoomoutClipPath"+b},this.svgGroup_);Blockly.createSvgElement("rect",{width:32,height:32,y:77},c);var d=Blockly.createSvgElement("image",{width:Blockly.SPRITE.width,height:Blockly.SPRITE.height,x:-64,y:-15,"clip-path":"url(#blocklyZoomoutClipPath"+b+")"},this.svgGroup_);
d.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a.options.pathToMedia+Blockly.SPRITE.url);c=Blockly.createSvgElement("clipPath",{id:"blocklyZoominClipPath"+b},this.svgGroup_);Blockly.createSvgElement("rect",{width:32,height:32,y:43},c);var e=Blockly.createSvgElement("image",{width:Blockly.SPRITE.width,height:Blockly.SPRITE.height,x:-32,y:-49,"clip-path":"url(#blocklyZoominClipPath"+b+")"},this.svgGroup_);e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a.options.pathToMedia+
Blockly.SPRITE.url);c=Blockly.createSvgElement("clipPath",{id:"blocklyZoomresetClipPath"+b},this.svgGroup_);Blockly.createSvgElement("rect",{width:32,height:32},c);b=Blockly.createSvgElement("image",{width:Blockly.SPRITE.width,height:Blockly.SPRITE.height,y:-92,"clip-path":"url(#blocklyZoomresetClipPath"+b+")"},this.svgGroup_);b.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a.options.pathToMedia+Blockly.SPRITE.url);Blockly.bindEvent_(b,"mousedown",a,a.zoomReset);Blockly.bindEvent_(e,
"mousedown",null,function(b){a.zoomCenter(1);b.stopPropagation()});Blockly.bindEvent_(d,"mousedown",null,function(b){a.zoomCenter(-1);b.stopPropagation()});return this.svgGroup_};Blockly.ZoomControls.prototype.init=function(a){this.bottom_=this.MARGIN_BOTTOM_+a;return this.bottom_+this.HEIGHT_};Blockly.ZoomControls.prototype.dispose=function(){this.svgGroup_&&(goog.dom.removeNode(this.svgGroup_),this.svgGroup_=null);this.workspace_=null};
Blockly.ZoomControls.prototype.position=function(){var a=this.workspace_.getMetrics();a&&(this.left_=this.workspace_.RTL?this.MARGIN_SIDE_+Blockly.Scrollbar.scrollbarThickness:a.viewWidth+a.absoluteLeft-this.WIDTH_-this.MARGIN_SIDE_-Blockly.Scrollbar.scrollbarThickness,this.top_=a.viewHeight+a.absoluteTop-this.HEIGHT_-this.bottom_,this.svgGroup_.setAttribute("transform","translate("+this.left_+","+this.top_+")"))};Blockly.Xml={};Blockly.Xml.workspaceToDom=function(a){var b=goog.dom.createDom("xml");a=a.getTopBlocks(!0);for(var c=0,d;d=a[c];c++)b.appendChild(Blockly.Xml.blockToDomWithXY(d));return b};Blockly.Xml.blockToDomWithXY=function(a){var b;a.workspace.RTL&&(b=a.workspace.getWidth());var c=Blockly.Xml.blockToDom(a),d=a.getRelativeToSurfaceXY();c.setAttribute("x",Math.round(a.workspace.RTL?b-d.x:d.x));c.setAttribute("y",Math.round(d.y));return c};
Blockly.Trashcan.prototype.close=function(){this.setOpen_(!1)};Blockly.Trashcan.prototype.click=function(){var a=this.workspace_.startScrollX-this.workspace_.scrollX,b=this.workspace_.startScrollY-this.workspace_.scrollY;Math.sqrt(a*a+b*b)>Blockly.DRAG_RADIUS||console.log("TODO: Inspect trash.")};Blockly.Xml={};Blockly.Xml.workspaceToDom=function(a){var b=goog.dom.createDom("xml");a=a.getTopBlocks(!0);for(var c=0,d;d=a[c];c++)b.appendChild(Blockly.Xml.blockToDomWithXY(d));return b};Blockly.Xml.blockToDomWithXY=function(a){var b;a.workspace.RTL&&(b=a.workspace.getWidth());var c=Blockly.Xml.blockToDom(a),d=a.getRelativeToSurfaceXY();c.setAttribute("x",Math.round(a.workspace.RTL?b-d.x:d.x));c.setAttribute("y",Math.round(d.y));return c};
Blockly.Xml.blockToDom=function(a){var b=goog.dom.createDom(a.isShadow()?"shadow":"block");b.setAttribute("type",a.type);b.setAttribute("id",a.id);if(a.mutationToDom){var c=a.mutationToDom();c&&(c.hasChildNodes()||c.hasAttributes())&&b.appendChild(c)}for(var c=0,d;d=a.inputList[c];c++)for(var e=0,f;f=d.fieldRow[e];e++)if(f.name&&f.EDITABLE){var g=goog.dom.createDom("field",null,f.getValue());g.setAttribute("name",f.name);b.appendChild(g)}if(c=a.getCommentText())c=goog.dom.createDom("comment",null,
c),"object"==typeof a.comment&&(c.setAttribute("pinned",a.comment.isVisible()),d=a.comment.getBubbleSize(),c.setAttribute("h",d.height),c.setAttribute("w",d.width)),b.appendChild(c);a.data&&(c=goog.dom.createDom("data",null,a.data),b.appendChild(c));for(c=0;d=a.inputList[c];c++){var h;f=!0;d.type!=Blockly.DUMMY_INPUT&&(g=d.connection.targetBlock(),d.type==Blockly.INPUT_VALUE?h=goog.dom.createDom("value"):d.type==Blockly.NEXT_STATEMENT&&(h=goog.dom.createDom("statement")),e=d.connection.getShadowDom(),
!e||g&&g.isShadow()||h.appendChild(Blockly.Xml.cloneShadow_(e)),g&&(h.appendChild(Blockly.Xml.blockToDom(g)),f=!1),h.setAttribute("name",d.name),f||b.appendChild(h))}a.inputsInlineDefault!=a.inputsInline&&b.setAttribute("inline",a.inputsInline);a.isCollapsed()&&b.setAttribute("collapsed",!0);a.disabled&&b.setAttribute("disabled",!0);a.isDeletable()||a.isShadow()||b.setAttribute("deletable",!1);a.isMovable()||a.isShadow()||b.setAttribute("movable",!1);a.isEditable()||b.setAttribute("editable",!1);
@@ -982,14 +987,21 @@ if(c=a.getNextBlock())h=goog.dom.createDom("next",null,Blockly.Xml.blockToDom(c)
Blockly.Xml.cloneShadow_=function(a){for(var b=a=a.cloneNode(!0),c;b;)if(b.firstChild)b=b.firstChild;else{for(;b&&!b.nextSibling;)c=b,b=b.parentNode,3==c.nodeType&&""==c.data.trim()&&b.firstChild!=c&&goog.dom.removeNode(c);b&&(c=b,b=b.nextSibling,3==c.nodeType&&""==c.data.trim()&&goog.dom.removeNode(c))}return a};Blockly.Xml.domToText=function(a){return(new XMLSerializer).serializeToString(a)};
Blockly.Xml.domToPrettyText=function(a){a=Blockly.Xml.domToText(a).split("<");for(var b="",c=1;c<a.length;c++){var d=a[c];"/"==d[0]&&(b=b.substring(2));a[c]=b+"<"+d;"/"!=d[0]&&"/>"!=d.slice(-2)&&(b+=" ")}a=a.join("\n");a=a.replace(/(<(\w+)\b[^>]*>[^\n]*)\n *<\/\2>/g,"$1</$2>");return a.replace(/^\n/,"")};
Blockly.Xml.textToDom=function(a){a=(new DOMParser).parseFromString(a,"text/xml");if(!a||!a.firstChild||"xml"!=a.firstChild.nodeName.toLowerCase()||a.firstChild!==a.lastChild)throw"Blockly.Xml.textToDom did not obtain a valid XML tree.";return a.firstChild};
Blockly.Xml.domToWorkspace=function(a,b){var c;a.RTL&&(c=a.getWidth());Blockly.Field.startCache();for(var d=b.childNodes.length,e=0;e<d;e++){var f=b.childNodes[e],g=f.nodeName.toLowerCase();if("block"==g||"shadow"==g){var g=Blockly.Xml.domToBlock(a,f),h=parseInt(f.getAttribute("x"),10),f=parseInt(f.getAttribute("y"),10);isNaN(h)||isNaN(f)||g.moveBy(a.RTL?c-h:h,f)}}Blockly.Field.stopCache()};
Blockly.Xml.domToBlock=function(a,b){Blockly.Events.disable();var c=Blockly.Xml.domToBlockHeadless_(a,b);if(a.rendered){c.setConnectionsHidden(!0);for(var d=c.getDescendants(),e=d.length-1;0<=e;e--)d[e].initSvg();for(e=d.length-1;0<=e;e--)d[e].render(!1);setTimeout(function(){c.workspace&&c.setConnectionsHidden(!1)},1);c.updateDisabled();Blockly.fireUiEvent(window,"resize")}Blockly.Events.enable();Blockly.Events.isEnabled()&&!c.isShadow()&&Blockly.Events.fire(new Blockly.Events.Create(c));return c};
Blockly.Xml.domToWorkspace=function(a,b){var c;a.RTL&&(c=a.getWidth());Blockly.Field.startCache();var d=b.childNodes.length,e=Blockly.Events.getGroup();e||Blockly.Events.setGroup(!0);for(var f=0;f<d;f++){var g=b.childNodes[f],h=g.nodeName.toLowerCase();if("block"==h||"shadow"==h){var h=Blockly.Xml.domToBlock(a,g),k=parseInt(g.getAttribute("x"),10),g=parseInt(g.getAttribute("y"),10);isNaN(k)||isNaN(g)||h.moveBy(a.RTL?c-k:k,g)}}e||Blockly.Events.setGroup(!1);Blockly.Field.stopCache()};
Blockly.Xml.domToBlock=function(a,b){Blockly.Events.disable();var c=Blockly.Xml.domToBlockHeadless_(a,b);if(a.rendered){c.setConnectionsHidden(!0);for(var d=c.getDescendants(),e=d.length-1;0<=e;e--)d[e].initSvg();for(e=d.length-1;0<=e;e--)d[e].render(!1);setTimeout(function(){c.workspace&&c.setConnectionsHidden(!1)},1);c.updateDisabled();Blockly.fireUiEvent(window,"resize")}Blockly.Events.enable();Blockly.Events.isEnabled()&&Blockly.Events.fire(new Blockly.Events.Create(c));return c};
Blockly.Xml.domToBlockHeadless_=function(a,b){var c=null,d=b.getAttribute("type");if(!d)throw"Block type unspecified: \n"+b.outerHTML;for(var e=b.getAttribute("id"),c=a.newBlock(d,e),f=null,e=0,g;g=b.childNodes[e];e++)if(3!=g.nodeType){for(var h=f=null,k=0,l;l=g.childNodes[k];k++)1==l.nodeType&&("block"==l.nodeName.toLowerCase()?f=l:"shadow"==l.nodeName.toLowerCase()&&(h=l));!f&&h&&(f=h);k=g.getAttribute("name");switch(g.nodeName.toLowerCase()){case "mutation":c.domToMutation&&(c.domToMutation(g),
c.initSvg&&c.initSvg());break;case "comment":c.setCommentText(g.textContent);var q=g.getAttribute("pinned");q&&!c.isInFlyout&&setTimeout(function(){c.comment&&c.comment.setVisible&&c.comment.setVisible("true"==q)},1);f=parseInt(g.getAttribute("w"),10);g=parseInt(g.getAttribute("h"),10);!isNaN(f)&&!isNaN(g)&&c.comment&&c.comment.setVisible&&c.comment.setBubbleSize(f,g);break;case "data":c.data=g.textContent;break;case "title":case "field":f=c.getField(k);if(!f){console.warn("Ignoring non-existent field "+
k+" in block "+d);break}f.setValue(g.textContent);break;case "value":case "statement":g=c.getInput(k);if(!g){console.warn("Ignoring non-existent input "+k+" in block "+d);break}h&&g.connection.setShadowDom(h);if(f)if(f=Blockly.Xml.domToBlockHeadless_(a,f),f.outputConnection)g.connection.connect(f.outputConnection);else if(f.previousConnection)g.connection.connect(f.previousConnection);else throw"Child block does not have output or previous statement.";break;case "next":h&&c.nextConnection&&c.nextConnection.setShadowDom(h);
if(f){if(!c.nextConnection)throw"Next statement does not exist.";if(c.nextConnection.targetConnection)throw"Next statement is already connected.";f=Blockly.Xml.domToBlockHeadless_(a,f);if(!f.previousConnection)throw"Next block does not have previous statement.";c.nextConnection.connect(f.previousConnection)}break;default:console.warn("Ignoring unknown tag: "+g.nodeName)}}(d=b.getAttribute("inline"))&&c.setInputsInline("true"==d);(d=b.getAttribute("disabled"))&&c.setDisabled("true"==d);(d=b.getAttribute("deletable"))&&
c.setDeletable("true"==d);(d=b.getAttribute("movable"))&&c.setMovable("true"==d);(d=b.getAttribute("editable"))&&c.setEditable("true"==d);(d=b.getAttribute("collapsed"))&&c.setCollapsed("true"==d);"shadow"==b.nodeName.toLowerCase()&&c.setShadow(!0);c.validate&&c.validate();return c};Blockly.Xml.deleteNext=function(a){for(var b=0,c;c=a.childNodes[b];b++)if("next"==c.nodeName.toLowerCase()){a.removeChild(c);break}};goog.global.Blockly||(goog.global.Blockly={});
goog.global.Blockly.Xml||(goog.global.Blockly.Xml={});goog.global.Blockly.Xml.domToText=Blockly.Xml.domToText;goog.global.Blockly.Xml.domToWorkspace=Blockly.Xml.domToWorkspace;goog.global.Blockly.Xml.textToDom=Blockly.Xml.textToDom;goog.global.Blockly.Xml.workspaceToDom=Blockly.Xml.workspaceToDom;
// Copyright 2015 Google Inc. Apache License 2.0
Blockly.ZoomControls=function(a){this.workspace_=a};Blockly.ZoomControls.prototype.WIDTH_=32;Blockly.ZoomControls.prototype.HEIGHT_=110;Blockly.ZoomControls.prototype.MARGIN_BOTTOM_=20;Blockly.ZoomControls.prototype.MARGIN_SIDE_=20;Blockly.ZoomControls.prototype.svgGroup_=null;Blockly.ZoomControls.prototype.left_=0;Blockly.ZoomControls.prototype.top_=0;
Blockly.ZoomControls.prototype.createDom=function(){var a=this.workspace_;this.svgGroup_=Blockly.createSvgElement("g",{"class":"blocklyZoom"},null);var b=String(Math.random()).substring(2),c=Blockly.createSvgElement("clipPath",{id:"blocklyZoomoutClipPath"+b},this.svgGroup_);Blockly.createSvgElement("rect",{width:32,height:32,y:77},c);var d=Blockly.createSvgElement("image",{width:Blockly.SPRITE.width,height:Blockly.SPRITE.height,x:-64,y:-15,"clip-path":"url(#blocklyZoomoutClipPath"+b+")"},this.svgGroup_);
d.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a.options.pathToMedia+Blockly.SPRITE.url);c=Blockly.createSvgElement("clipPath",{id:"blocklyZoominClipPath"+b},this.svgGroup_);Blockly.createSvgElement("rect",{width:32,height:32,y:43},c);var e=Blockly.createSvgElement("image",{width:Blockly.SPRITE.width,height:Blockly.SPRITE.height,x:-32,y:-49,"clip-path":"url(#blocklyZoominClipPath"+b+")"},this.svgGroup_);e.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a.options.pathToMedia+
Blockly.SPRITE.url);c=Blockly.createSvgElement("clipPath",{id:"blocklyZoomresetClipPath"+b},this.svgGroup_);Blockly.createSvgElement("rect",{width:32,height:32},c);b=Blockly.createSvgElement("image",{width:Blockly.SPRITE.width,height:Blockly.SPRITE.height,y:-92,"clip-path":"url(#blocklyZoomresetClipPath"+b+")"},this.svgGroup_);b.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",a.options.pathToMedia+Blockly.SPRITE.url);Blockly.bindEvent_(b,"mousedown",a,a.zoomReset);Blockly.bindEvent_(e,
"mousedown",null,function(b){a.zoomCenter(1);b.stopPropagation()});Blockly.bindEvent_(d,"mousedown",null,function(b){a.zoomCenter(-1);b.stopPropagation()});return this.svgGroup_};Blockly.ZoomControls.prototype.init=function(a){this.bottom_=this.MARGIN_BOTTOM_+a;return this.bottom_+this.HEIGHT_};Blockly.ZoomControls.prototype.dispose=function(){this.svgGroup_&&(goog.dom.removeNode(this.svgGroup_),this.svgGroup_=null);this.workspace_=null};
Blockly.ZoomControls.prototype.position=function(){var a=this.workspace_.getMetrics();a&&(this.left_=this.workspace_.RTL?this.MARGIN_SIDE_+Blockly.Scrollbar.scrollbarThickness:a.viewWidth+a.absoluteLeft-this.WIDTH_-this.MARGIN_SIDE_-Blockly.Scrollbar.scrollbarThickness,this.top_=a.viewHeight+a.absoluteTop-this.HEIGHT_-this.bottom_,this.svgGroup_.setAttribute("transform","translate("+this.left_+","+this.top_+")"))};
// Copyright 2014 Google Inc. Apache License 2.0
Blockly.WorkspaceSvg=function(a){Blockly.WorkspaceSvg.superClass_.constructor.call(this,a);this.getMetrics=a.getMetrics;this.setMetrics=a.setMetrics;Blockly.ConnectionDB.init(this);this.SOUNDS_=Object.create(null)};goog.inherits(Blockly.WorkspaceSvg,Blockly.Workspace);Blockly.WorkspaceSvg.prototype.rendered=!0;Blockly.WorkspaceSvg.prototype.isFlyout=!1;Blockly.WorkspaceSvg.prototype.isScrolling=!1;Blockly.WorkspaceSvg.prototype.scrollX=0;Blockly.WorkspaceSvg.prototype.scrollY=0;
Blockly.WorkspaceSvg.prototype.startScrollX=0;Blockly.WorkspaceSvg.prototype.startScrollY=0;Blockly.WorkspaceSvg.prototype.dragDeltaX_=0;Blockly.WorkspaceSvg.prototype.dragDeltaY_=0;Blockly.WorkspaceSvg.prototype.scale=1;Blockly.WorkspaceSvg.prototype.trashcan=null;Blockly.WorkspaceSvg.prototype.scrollbar=null;
@@ -1011,11 +1023,13 @@ Blockly.WorkspaceSvg.prototype.isDeleteArea=function(a){a=new goog.math.Coordina
Blockly.WorkspaceSvg.prototype.onMouseDown_=function(a){this.markFocused();Blockly.isTargetInput_(a)||(Blockly.svgResize(this),Blockly.terminateDrag_(),Blockly.hideChaff(),a.target&&a.target.nodeName&&("svg"==a.target.nodeName.toLowerCase()||a.target==this.svgBackground_)&&Blockly.selected&&!this.options.readOnly&&Blockly.selected.unselect(),Blockly.isRightButton(a)?this.showContextMenu_(a):this.scrollbar&&(Blockly.removeAllRanges(),this.isScrolling=!0,this.startDragMouseX=a.clientX,this.startDragMouseY=
a.clientY,this.startDragMetrics=this.getMetrics(),this.startScrollX=this.scrollX,this.startScrollY=this.scrollY,"mouseup"in Blockly.bindEvent_.TOUCH_MAP&&(Blockly.onTouchUpWrapper_=Blockly.onTouchUpWrapper_||[],Blockly.onTouchUpWrapper_=Blockly.onTouchUpWrapper_.concat(Blockly.bindEvent_(document,"mouseup",null,Blockly.onMouseUp_))),Blockly.onMouseMoveWrapper_=Blockly.onMouseMoveWrapper_||[],Blockly.onMouseMoveWrapper_=Blockly.onMouseMoveWrapper_.concat(Blockly.bindEvent_(document,"mousemove",null,
Blockly.onMouseMove_))),a.stopPropagation())};Blockly.WorkspaceSvg.prototype.startDrag=function(a,b,c){a=Blockly.mouseToSvg(a,this.getParentSvg());a.x/=this.scale;a.y/=this.scale;this.dragDeltaX_=b-a.x;this.dragDeltaY_=c-a.y};Blockly.WorkspaceSvg.prototype.moveDrag=function(a){a=Blockly.mouseToSvg(a,this.getParentSvg());a.x/=this.scale;a.y/=this.scale;return new goog.math.Coordinate(this.dragDeltaX_+a.x,this.dragDeltaY_+a.y)};
Blockly.WorkspaceSvg.prototype.onMouseWheel_=function(a){Blockly.terminateDrag_();var b=0<a.deltaY?-1:1,c=Blockly.mouseToSvg(a,this.getParentSvg());this.zoom(c.x,c.y,b);a.preventDefault()};Blockly.WorkspaceSvg.prototype.cleanUp_=function(){for(var a=this.getTopBlocks(!0),b=0,c=0,d;d=a[c];c++){var e=d.getRelativeToSurfaceXY();d.moveBy(-e.x,b-e.y);d.snapToGrid();b=d.getRelativeToSurfaceXY().y+d.getHeightWidth().height+Blockly.BlockSvg.MIN_BLOCK_Y}Blockly.fireUiEvent(window,"resize")};
Blockly.WorkspaceSvg.prototype.showContextMenu_=function(a){function b(a){if(a.isDeletable())q=q.concat(a.getDescendants());else{a=a.getChildren();for(var c=0;c<a.length;c++)b(a[c])}}function c(){var a=q.shift();a&&(a.workspace?(a.dispose(!1,!0),setTimeout(c,10)):c())}if(!this.options.readOnly&&!this.isFlyout){var d=[],e=this.getTopBlocks(!0),f={};f.text=Blockly.Msg.CLEAN_UP;f.enabled=1<e.length;f.callback=this.cleanUp_.bind(this);d.push(f);if(this.options.collapse){for(var g=f=!1,h=0;h<e.length;h++)for(var k=
e[h];k;)k.isCollapsed()?f=!0:g=!0,k=k.getNextBlock();var l=function(a){for(var b=0,c=0;c<e.length;c++)for(var d=e[c];d;)setTimeout(d.setCollapsed.bind(d,a),b),d=d.getNextBlock(),b+=10},g={enabled:g};g.text=Blockly.Msg.COLLAPSE_ALL;g.callback=function(){l(!0)};d.push(g);f={enabled:f};f.text=Blockly.Msg.EXPAND_ALL;f.callback=function(){l(!1)};d.push(f)}for(var q=[],h=0;h<e.length;h++)b(e[h]);f={text:1>=q.length?Blockly.Msg.DELETE_BLOCK:Blockly.Msg.DELETE_X_BLOCKS.replace("%1",String(q.length)),enabled:0<
q.length,callback:function(){(2>q.length||window.confirm(Blockly.Msg.DELETE_ALL_BLOCKS.replace("%1",String(q.length))))&&c()}};d.push(f);Blockly.ContextMenu.show(a,d,this.RTL)}};Blockly.WorkspaceSvg.prototype.loadAudio_=function(a,b){if(a.length){try{var c=new window.Audio}catch(h){return}for(var d,e=0;e<a.length;e++){var f=a[e],g=f.match(/\.(\w+)$/);if(g&&c.canPlayType("audio/"+g[1])){d=new window.Audio(f);break}}d&&d.play&&(this.SOUNDS_[b]=d)}};
Blockly.WorkspaceSvg.prototype.preloadAudio_=function(){for(var a in this.SOUNDS_){var b=this.SOUNDS_[a];b.volume=.01;b.play();b.pause();if(goog.userAgent.IPAD||goog.userAgent.IPHONE)break}};
Blockly.WorkspaceSvg.prototype.onMouseWheel_=function(a){Blockly.terminateDrag_();var b=0<a.deltaY?-1:1,c=Blockly.mouseToSvg(a,this.getParentSvg());this.zoom(c.x,c.y,b);a.preventDefault()};
Blockly.WorkspaceSvg.prototype.getBlocksBoundingBox=function(){var a=this.getTopBlocks();if(!a.length)return{x:0,y:0,width:0,height:0};for(var b=a[0].getBoundingRectangle(),c=1;c<a.length;c++){var d=a[c].getBoundingRectangle();d.topLeft.x<b.topLeft.x&&(b.topLeft.x=d.topLeft.x);d.bottomRight.x>b.bottomRight.x&&(b.bottomRight.x=d.bottomRight.x);d.topLeft.y<b.topLeft.y&&(b.topLeft.y=d.topLeft.y);d.bottomRight.y>b.bottomRight.y&&(b.bottomRight.y=d.bottomRight.y)}return{x:b.topLeft.x,y:b.topLeft.y,width:b.bottomRight.x-
b.topLeft.x,height:b.bottomRight.y-b.topLeft.y}};Blockly.WorkspaceSvg.prototype.cleanUp_=function(){Blockly.Events.setGroup(!0);for(var a=this.getTopBlocks(!0),b=0,c=0,d;d=a[c];c++){var e=d.getRelativeToSurfaceXY();d.moveBy(-e.x,b-e.y);d.snapToGrid();b=d.getRelativeToSurfaceXY().y+d.getHeightWidth().height+Blockly.BlockSvg.MIN_BLOCK_Y}Blockly.Events.setGroup(!1);Blockly.fireUiEvent(window,"resize")};
Blockly.WorkspaceSvg.prototype.showContextMenu_=function(a){function b(a){if(a.isDeletable())m=m.concat(a.getDescendants());else{a=a.getChildren();for(var c=0;c<a.length;c++)b(a[c])}}function c(){Blockly.Events.setGroup(f);var a=m.shift();a&&(a.workspace?(a.dispose(!1,!0),setTimeout(c,10)):c());Blockly.Events.setGroup(!1)}if(!this.options.readOnly&&!this.isFlyout){var d=[],e=this.getTopBlocks(!0),f=Blockly.genUid(),g={};g.text=Blockly.Msg.UNDO;g.enabled=0<this.undoStack_.length;g.callback=this.undo.bind(this,
!1);d.push(g);g={};g.text=Blockly.Msg.REDO;g.enabled=0<this.redoStack_.length;g.callback=this.undo.bind(this,!0);d.push(g);g={};g.text=Blockly.Msg.CLEAN_UP;g.enabled=1<e.length;g.callback=this.cleanUp_.bind(this);d.push(g);if(this.options.collapse){for(var h=g=!1,k=0;k<e.length;k++)for(var l=e[k];l;)l.isCollapsed()?g=!0:h=!0,l=l.getNextBlock();var q=function(a){for(var b=0,c=0;c<e.length;c++)for(var d=e[c];d;)setTimeout(d.setCollapsed.bind(d,a),b),d=d.getNextBlock(),b+=10},h={enabled:h};h.text=Blockly.Msg.COLLAPSE_ALL;
h.callback=function(){q(!0)};d.push(h);g={enabled:g};g.text=Blockly.Msg.EXPAND_ALL;g.callback=function(){q(!1)};d.push(g)}for(var m=[],k=0;k<e.length;k++)b(e[k]);g={text:1>=m.length?Blockly.Msg.DELETE_BLOCK:Blockly.Msg.DELETE_X_BLOCKS.replace("%1",String(m.length)),enabled:0<m.length,callback:function(){(2>m.length||window.confirm(Blockly.Msg.DELETE_ALL_BLOCKS.replace("%1",String(m.length))))&&c()}};d.push(g);Blockly.ContextMenu.show(a,d,this.RTL)}};
Blockly.WorkspaceSvg.prototype.loadAudio_=function(a,b){if(a.length){try{var c=new window.Audio}catch(h){return}for(var d,e=0;e<a.length;e++){var f=a[e],g=f.match(/\.(\w+)$/);if(g&&c.canPlayType("audio/"+g[1])){d=new window.Audio(f);break}}d&&d.play&&(this.SOUNDS_[b]=d)}};Blockly.WorkspaceSvg.prototype.preloadAudio_=function(){for(var a in this.SOUNDS_){var b=this.SOUNDS_[a];b.volume=.01;b.play();b.pause();if(goog.userAgent.IPAD||goog.userAgent.IPHONE)break}};
Blockly.WorkspaceSvg.prototype.playAudio=function(a,b){var c=this.SOUNDS_[a];c?(c=goog.userAgent.DOCUMENT_MODE&&9===goog.userAgent.DOCUMENT_MODE||goog.userAgent.IPAD||goog.userAgent.ANDROID?c:c.cloneNode(),c.volume=void 0===b?1:b,c.play()):this.options.parentWorkspace&&this.options.parentWorkspace.playAudio(a,b)};
Blockly.WorkspaceSvg.prototype.updateToolbox=function(a){if(a=Blockly.parseToolboxTree_(a)){if(!this.options.languageTree)throw"Existing toolbox is null. Can't create new toolbox.";if(a.getElementsByTagName("category").length){if(!this.toolbox_)throw"Existing toolbox has no categories. Can't change mode.";this.options.languageTree=a;this.toolbox_.populate_(a);this.toolbox_.addColour_()}else{if(!this.flyout_)throw"Existing toolbox has categories. Can't change mode.";this.options.languageTree=a;
this.flyout_.show(a.childNodes)}}else if(this.options.languageTree)throw"Can't nullify an existing toolbox.";};Blockly.WorkspaceSvg.prototype.markFocused=function(){this.options.parentWorkspace?this.options.parentWorkspace.markFocused():Blockly.mainWorkspace=this};
@@ -1035,29 +1049,29 @@ this.svgDialog_.setAttribute("height",this.workspaceHeight_);this.block_.RTL&&(a
Blockly.Mutator.prototype.setVisible=function(a){if(a!=this.isVisible())if(a){this.bubble_=new Blockly.Bubble(this.block_.workspace,this.createEditor_(),this.block_.svgPath_,this.iconX_,this.iconY_,null,null);if(a=this.workspace_.options.languageTree)this.workspace_.flyout_.init(this.workspace_),this.workspace_.flyout_.show(a.childNodes);this.rootBlock_=this.block_.decompose(this.workspace_);a=this.rootBlock_.getDescendants();for(var b=0,c;c=a[b];b++)c.render();this.rootBlock_.setMovable(!1);this.rootBlock_.setDeletable(!1);
this.workspace_.flyout_?(a=2*this.workspace_.flyout_.CORNER_RADIUS,b=this.workspace_.flyout_.width_+a):b=a=16;this.block_.RTL&&(b=-b);this.rootBlock_.moveBy(b,a);if(this.block_.saveConnections){var d=this;this.block_.saveConnections(this.rootBlock_);this.sourceListener_=function(){d.block_.saveConnections(d.rootBlock_)};this.block_.workspace.addChangeListener(this.sourceListener_)}this.resizeBubble_();this.workspace_.addChangeListener(this.workspaceChanged_.bind(this));this.updateColour()}else this.svgDialog_=
null,this.workspace_.dispose(),this.rootBlock_=this.workspace_=null,this.bubble_.dispose(),this.bubble_=null,this.workspaceHeight_=this.workspaceWidth_=0,this.sourceListener_&&(this.block_.workspace.removeChangeListener(this.sourceListener_),this.sourceListener_=null)};
Blockly.Mutator.prototype.workspaceChanged_=function(){if(0==Blockly.dragMode_)for(var a=this.workspace_.getTopBlocks(!1),b=0,c;c=a[b];b++){var d=c.getRelativeToSurfaceXY(),e=c.getHeightWidth();20>d.y+e.height&&c.moveBy(0,20-e.height-d.y)}this.rootBlock_.workspace==this.workspace_&&(a=(a=this.block_.mutationToDom())&&Blockly.Xml.domToText(a),b=this.block_.rendered,this.block_.rendered=!1,this.block_.compose(this.rootBlock_),this.block_.rendered=b,this.block_.initSvg(),b=(b=this.block_.mutationToDom())&&
Blockly.Xml.domToText(b),a!=b&&(Blockly.Events.fire(new Blockly.Events.Change(this.block_,"mutation",null,a,b)),goog.Timer.callOnce(this.block_.bumpNeighbours_,Blockly.BUMP_DELAY,this.block_)),this.block_.rendered&&this.block_.render(),this.resizeBubble_())};Blockly.Mutator.prototype.getFlyoutMetrics_=function(){return{viewHeight:this.workspaceHeight_,viewWidth:this.workspaceWidth_,absoluteTop:0,absoluteLeft:0}};Blockly.Mutator.prototype.dispose=function(){this.block_.mutator=null;Blockly.Icon.prototype.dispose.call(this)};Blockly.Warning=function(a){Blockly.Warning.superClass_.constructor.call(this,a);this.createIcon();this.text_={}};goog.inherits(Blockly.Warning,Blockly.Icon);Blockly.Warning.prototype.collapseHidden=!1;
Blockly.Mutator.prototype.workspaceChanged_=function(){if(0==Blockly.dragMode_)for(var a=this.workspace_.getTopBlocks(!1),b=0,c;c=a[b];b++){var d=c.getRelativeToSurfaceXY(),e=c.getHeightWidth();20>d.y+e.height&&c.moveBy(0,20-e.height-d.y)}if(this.rootBlock_.workspace==this.workspace_){Blockly.Events.setGroup(!0);c=this.block_;a=(a=c.mutationToDom())&&Blockly.Xml.domToText(a);b=c.rendered;c.rendered=!1;c.compose(this.rootBlock_);c.rendered=b;c.initSvg();b=(b=c.mutationToDom())&&Blockly.Xml.domToText(b);
if(a!=b){Blockly.Events.fire(new Blockly.Events.Change(c,"mutation",null,a,b));var f=Blockly.Events.getGroup();setTimeout(function(){Blockly.Events.setGroup(f);c.bumpNeighbours_();Blockly.Events.setGroup(!1)},Blockly.BUMP_DELAY)}c.rendered&&c.render();this.resizeBubble_();Blockly.Events.setGroup(!1)}};Blockly.Mutator.prototype.getFlyoutMetrics_=function(){return{viewHeight:this.workspaceHeight_,viewWidth:this.workspaceWidth_,absoluteTop:0,absoluteLeft:0}};
Blockly.Mutator.prototype.dispose=function(){this.block_.mutator=null;Blockly.Icon.prototype.dispose.call(this)};Blockly.Mutator.reconnect=function(a,b,c){if(!a||!a.getSourceBlock().workspace)return!1;c=b.getInput(c).connection;var d=a.targetBlock();return d&&d!=b||c.targetConnection==a?!1:(c.targetConnection&&c.disconnect(),c.connect(a),!0)};goog.global.Blockly||(goog.global.Blockly={});goog.global.Blockly.Mutator||(goog.global.Blockly.Mutator={});goog.global.Blockly.Mutator.reconnect=Blockly.Mutator.reconnect;Blockly.Warning=function(a){Blockly.Warning.superClass_.constructor.call(this,a);this.createIcon();this.text_={}};goog.inherits(Blockly.Warning,Blockly.Icon);Blockly.Warning.prototype.collapseHidden=!1;
Blockly.Warning.prototype.drawIcon_=function(a){Blockly.createSvgElement("path",{"class":"blocklyIconShape",d:"M2,15Q-1,15 0.5,12L6.5,1.7Q8,-1 9.5,1.7L15.5,12Q17,15 14,15z"},a);Blockly.createSvgElement("path",{"class":"blocklyIconSymbol",d:"m7,4.8v3.16l0.27,2.27h1.46l0.27,-2.27v-3.16z"},a);Blockly.createSvgElement("rect",{"class":"blocklyIconSymbol",x:"7",y:"11",height:"2",width:"2"},a)};
Blockly.Warning.textToDom_=function(a){var b=Blockly.createSvgElement("text",{"class":"blocklyText blocklyBubbleText",y:Blockly.Bubble.BORDER_WIDTH},null);a=a.split("\n");for(var c=0;c<a.length;c++){var d=Blockly.createSvgElement("tspan",{dy:"1em",x:Blockly.Bubble.BORDER_WIDTH},b),e=document.createTextNode(a[c]);d.appendChild(e)}return b};
Blockly.Warning.prototype.setVisible=function(a){if(a!=this.isVisible())if(a){a=Blockly.Warning.textToDom_(this.getText());this.bubble_=new Blockly.Bubble(this.block_.workspace,a,this.block_.svgPath_,this.iconX_,this.iconY_,null,null);if(this.block_.RTL)for(var b=a.getBBox().width,c=0,d;d=a.childNodes[c];c++)d.setAttribute("text-anchor","end"),d.setAttribute("x",b+Blockly.Bubble.BORDER_WIDTH);this.updateColour();a=this.bubble_.getBubbleSize();this.bubble_.setBubbleSize(a.width,a.height)}else this.bubble_.dispose(),
this.body_=this.bubble_=null};Blockly.Warning.prototype.bodyFocus_=function(a){this.bubble_.promote_()};Blockly.Warning.prototype.setText=function(a,b){this.text_[b]!=a&&(a?this.text_[b]=a:delete this.text_[b],this.isVisible()&&(this.setVisible(!1),this.setVisible(!0)))};Blockly.Warning.prototype.getText=function(){var a=[],b;for(b in this.text_)a.push(this.text_[b]);return a.join("\n")};Blockly.Warning.prototype.dispose=function(){this.block_.warning=null;Blockly.Icon.prototype.dispose.call(this)};Blockly.Block=function(a,b,c){this.id=c&&!Blockly.Block.getById(c)?c:Blockly.genUid();Blockly.Block.BlockDB_[this.id]=this;this.previousConnection=this.nextConnection=this.outputConnection=null;this.inputList=[];this.inputsInline=void 0;this.disabled=this.rendered=!1;this.tooltip="";this.contextMenu=!0;this.parentBlock_=null;this.childBlocks_=[];this.editable_=this.movable_=this.deletable_=!0;this.collapsed_=this.isShadow_=!1;this.comment=null;this.xy_=new goog.math.Coordinate(0,0);this.workspace=
a;this.isInFlyout=a.isFlyout;this.RTL=a.RTL;b&&(this.type=b,c=Blockly.Blocks[b],goog.asserts.assertObject(c,'Error: "%s" is an unknown language block.',b),goog.mixin(this,c));a.addTopBlock(this);goog.isFunction(this.init)&&this.init();this.inputsInlineDefault=this.inputsInline;Blockly.Events.isEnabled()&&!this.isShadow()&&Blockly.Events.fire(new Blockly.Events.Create(this));goog.isFunction(this.onchange)&&(this.onchangeWrapper_=this.onchange.bind(this),this.workspace.addChangeListener(this.onchangeWrapper_))};
a;this.isInFlyout=a.isFlyout;this.RTL=a.RTL;b&&(this.type=b,c=Blockly.Blocks[b],goog.asserts.assertObject(c,'Error: "%s" is an unknown language block.',b),goog.mixin(this,c));a.addTopBlock(this);goog.isFunction(this.init)&&this.init();this.inputsInlineDefault=this.inputsInline;Blockly.Events.isEnabled()&&Blockly.Events.fire(new Blockly.Events.Create(this));goog.isFunction(this.onchange)&&(this.onchangeWrapper_=this.onchange.bind(this),this.workspace.addChangeListener(this.onchangeWrapper_))};
Blockly.Block.obtain=function(a,b){console.warn("Deprecated call to Blockly.Block.obtain, use workspace.newBlock instead.");return a.newBlock(b)};Blockly.Block.prototype.data=null;Blockly.Block.prototype.colour_="#000000";
Blockly.Block.prototype.dispose=function(a){this.onchangeWrapper_&&this.workspace.removeChangeListener(this.onchangeWrapper_);this.unplug(a);Blockly.Events.isEnabled()&&!this.isShadow()&&Blockly.Events.fire(new Blockly.Events.Delete(this));Blockly.Events.disable();this.workspace&&(this.workspace.removeTopBlock(this),this.workspace=null);Blockly.selected==this&&(Blockly.selected=null);for(a=this.childBlocks_.length-1;0<=a;a--)this.childBlocks_[a].dispose(!1);a=0;for(var b;b=this.inputList[a];a++)b.dispose();
this.inputList.length=0;b=this.getConnections_(!0);for(a=0;a<b.length;a++){var c=b[a];c.targetConnection&&c.disconnect();b[a].dispose()}delete Blockly.Block.BlockDB_[this.id];Blockly.Events.enable()};
Blockly.Block.prototype.unplug=function(a){if(this.outputConnection)this.outputConnection.targetConnection&&this.setParent(null);else{var b=null;this.previousConnection&&this.previousConnection.targetConnection&&(b=this.previousConnection.targetConnection,this.setParent(null));var c=this.getNextBlock();a&&c&&(a=this.nextConnection.targetConnection,c.setParent(null),b&&b.checkType_(a)&&b.connect(a))}};
Blockly.Block.prototype.getConnections_=function(a){var b=[];if(a||this.rendered)if(this.outputConnection&&b.push(this.outputConnection),this.previousConnection&&b.push(this.previousConnection),this.nextConnection&&b.push(this.nextConnection),a||!this.collapsed_){a=0;for(var c;c=this.inputList[a];a++)c.connection&&b.push(c.connection)}return b};
Blockly.Block.prototype.bumpNeighbours_=function(){if(this.workspace&&0==Blockly.dragMode_){var a=this.getRootBlock();if(!a.isInFlyout)for(var b=this.getConnections_(!1),c=0,d;d=b[c];c++){d.targetConnection&&d.isSuperior()&&d.targetBlock().bumpNeighbours_();for(var e=d.neighbours_(Blockly.SNAP_RADIUS),f=0,g;g=e[f];f++)d.targetConnection&&g.targetConnection||g.sourceBlock_.getRootBlock()!=a&&(d.isSuperior()?g.bumpAwayFrom_(d):d.bumpAwayFrom_(g))}}};Blockly.Block.prototype.getParent=function(){return this.parentBlock_};
Blockly.Block.prototype.dispose=function(a){this.onchangeWrapper_&&this.workspace.removeChangeListener(this.onchangeWrapper_);this.unplug(a);Blockly.Events.isEnabled()&&Blockly.Events.fire(new Blockly.Events.Delete(this));Blockly.Events.disable();this.workspace&&(this.workspace.removeTopBlock(this),this.workspace=null);Blockly.selected==this&&(Blockly.selected=null);for(a=this.childBlocks_.length-1;0<=a;a--)this.childBlocks_[a].dispose(!1);a=0;for(var b;b=this.inputList[a];a++)b.dispose();this.inputList.length=
0;b=this.getConnections_(!0);for(a=0;a<b.length;a++){var c=b[a];c.targetConnection&&c.disconnect();b[a].dispose()}delete Blockly.Block.BlockDB_[this.id];Blockly.Events.enable()};
Blockly.Block.prototype.unplug=function(a){if(this.outputConnection)this.outputConnection.targetConnection&&this.outputConnection.disconnect();else if(this.previousConnection){var b=null;this.previousConnection.targetConnection&&(b=this.previousConnection.targetConnection,this.previousConnection.disconnect());var c=this.getNextBlock();a&&c&&(a=this.nextConnection.targetConnection,a.disconnect(),b&&b.checkType_(a)&&b.connect(a))}};
Blockly.Block.prototype.getConnections_=function(a){var b=[];if(a||this.rendered)if(this.outputConnection&&b.push(this.outputConnection),this.previousConnection&&b.push(this.previousConnection),this.nextConnection&&b.push(this.nextConnection),a||!this.collapsed_){a=0;for(var c;c=this.inputList[a];a++)c.connection&&b.push(c.connection)}return b};Blockly.Block.prototype.lastConnectionInStack_=function(){for(var a=this.nextConnection;a;){var b=a.targetBlock();if(!b)return a;a=b.nextConnection}return null};
Blockly.Block.prototype.bumpNeighbours_=function(){if(this.workspace&&0==Blockly.dragMode_){var a=this.getRootBlock();if(!a.isInFlyout)for(var b=this.getConnections_(!1),c=0,d;d=b[c];c++){d.targetConnection&&d.isSuperior()&&d.targetBlock().bumpNeighbours_();for(var e=d.neighbours_(Blockly.SNAP_RADIUS),f=0,g;g=e[f];f++)d.targetConnection&&g.targetConnection||g.getSourceBlock().getRootBlock()!=a&&(d.isSuperior()?g.bumpAwayFrom_(d):d.bumpAwayFrom_(g))}}};Blockly.Block.prototype.getParent=function(){return this.parentBlock_};
Blockly.Block.prototype.getInputWithBlock=function(a){for(var b=0,c;c=this.inputList[b];b++)if(c.connection&&c.connection.targetBlock()==a)return c;return null};Blockly.Block.prototype.getSurroundParent=function(){var a=this;do{var b=a,a=a.getParent();if(!a)return null}while(a.getNextBlock()==b);return a};Blockly.Block.prototype.getNextBlock=function(){return this.nextConnection&&this.nextConnection.targetBlock()};
Blockly.Block.prototype.getRootBlock=function(){var a,b=this;do a=b,b=a.parentBlock_;while(b);return a};Blockly.Block.prototype.getChildren=function(){return this.childBlocks_};
Blockly.Block.prototype.setParent=function(a){var b;Blockly.Events.isEnabled()&&!this.isShadow()&&(b=new Blockly.Events.Move(this));if(this.parentBlock_){for(var c=this.parentBlock_.childBlocks_,d,e=0;d=c[e];e++)if(d==this){c.splice(e,1);break}this.parentBlock_=null;this.previousConnection&&this.previousConnection.targetConnection&&this.previousConnection.disconnect();this.outputConnection&&this.outputConnection.targetConnection&&this.outputConnection.disconnect()}else this.workspace.removeTopBlock(this);
(this.parentBlock_=a)?a.childBlocks_.push(this):this.workspace.addTopBlock(this);b&&(b.recordNew(),Blockly.Events.fire(b))};Blockly.Block.prototype.getDescendants=function(){for(var a=[this],b,c=0;b=this.childBlocks_[c];c++)a.push.apply(a,b.getDescendants());return a};Blockly.Block.prototype.isDeletable=function(){return this.deletable_&&!this.isShadow_&&!(this.workspace&&this.workspace.options.readOnly)};Blockly.Block.prototype.setDeletable=function(a){this.deletable_=a};
Blockly.Block.prototype.isMovable=function(){return this.movable_&&!this.isShadow_&&!(this.workspace&&this.workspace.options.readOnly)};Blockly.Block.prototype.setMovable=function(a){this.movable_=a};Blockly.Block.prototype.isShadow=function(){return this.isShadow_};
Blockly.Block.prototype.setShadow=function(a){this.isShadow_!=a&&(this.isShadow_=a,Blockly.Events.isEnabled()&&!a&&(Blockly.Events.group=Blockly.genUid(),Blockly.Events.fire(new Blockly.Events.Create(this)),a=new Blockly.Events.Move(this),a.oldParentId=void 0,a.oldInputName=void 0,a.oldCoordinate=new goog.math.Coordinate(0,0),a.recordNew(),Blockly.Events.fire(a),Blockly.Events.group=""))};Blockly.Block.prototype.isEditable=function(){return this.editable_&&!(this.workspace&&this.workspace.options.readOnly)};
Blockly.Block.prototype.setEditable=function(a){this.editable_=a;a=0;for(var b;b=this.inputList[a];a++)for(var c=0,d;d=b.fieldRow[c];c++)d.updateEditable()};
Blockly.Block.prototype.setParent=function(a){if(a!=this.parentBlock_){if(this.parentBlock_){for(var b=this.parentBlock_.childBlocks_,c,d=0;c=b[d];d++)if(c==this){b.splice(d,1);break}if(this.previousConnection&&this.previousConnection.targetConnection)throw"Still connected to previous block.";if(this.outputConnection&&this.outputConnection.targetConnection)throw"Still connected to parent block.";this.parentBlock_=null}else this.workspace.removeTopBlock(this);(this.parentBlock_=a)?a.childBlocks_.push(this):
this.workspace.addTopBlock(this)}};Blockly.Block.prototype.getDescendants=function(){for(var a=[this],b,c=0;b=this.childBlocks_[c];c++)a.push.apply(a,b.getDescendants());return a};Blockly.Block.prototype.isDeletable=function(){return this.deletable_&&!this.isShadow_&&!(this.workspace&&this.workspace.options.readOnly)};Blockly.Block.prototype.setDeletable=function(a){this.deletable_=a};Blockly.Block.prototype.isMovable=function(){return this.movable_&&!this.isShadow_&&!(this.workspace&&this.workspace.options.readOnly)};
Blockly.Block.prototype.setMovable=function(a){this.movable_=a};Blockly.Block.prototype.isShadow=function(){return this.isShadow_};Blockly.Block.prototype.setShadow=function(a){this.isShadow_=a};Blockly.Block.prototype.isEditable=function(){return this.editable_&&!(this.workspace&&this.workspace.options.readOnly)};Blockly.Block.prototype.setEditable=function(a){this.editable_=a;a=0;for(var b;b=this.inputList[a];a++)for(var c=0,d;d=b.fieldRow[c];c++)d.updateEditable()};
Blockly.Block.prototype.setConnectionsHidden=function(a){if(!a&&this.isCollapsed()){if(this.outputConnection&&this.outputConnection.setHidden(a),this.previousConnection&&this.previousConnection.setHidden(a),this.nextConnection){this.nextConnection.setHidden(a);var b=this.nextConnection.targetBlock();b&&b.setConnectionsHidden(a)}}else for(var c=this.getConnections_(!0),d=0;b=c[d];d++)b.setHidden(a),b.isSuperior()&&(b=b.targetBlock())&&b.setConnectionsHidden(a)};
Blockly.Block.prototype.setHelpUrl=function(a){this.helpUrl=a};Blockly.Block.prototype.setTooltip=function(a){this.tooltip=a};Blockly.Block.prototype.getColour=function(){return this.colour_};Blockly.Block.prototype.setColour=function(a){var b=parseFloat(a);if(isNaN(b))if(goog.isString(a)&&a.match(/^#[0-9a-fA-F]{6}$/))this.colour_=a;else throw"Invalid colour: "+a;else this.colour_=Blockly.hueToRgb(b);this.rendered&&this.updateColour()};
Blockly.Block.prototype.getField=function(a){for(var b=0,c;c=this.inputList[b];b++)for(var d=0,e;e=c.fieldRow[d];d++)if(e.name===a)return e;return null};Blockly.Block.prototype.getFieldValue=function(a){return(a=this.getField(a))?a.getValue():null};Blockly.Block.prototype.getTitleValue=function(a){console.warn("Deprecated call to getTitleValue, use getFieldValue instead.");return this.getFieldValue(a)};
Blockly.Block.prototype.getField=function(a){for(var b=0,c;c=this.inputList[b];b++)for(var d=0,e;e=c.fieldRow[d];d++)if(e.name===a)return e;return null};Blockly.Block.prototype.getVars=function(){for(var a=[],b=0,c;c=this.inputList[b];b++)for(var d=0,e;e=c.fieldRow[d];d++)e instanceof Blockly.FieldVariable&&a.push(e.getValue());return a};
Blockly.Block.prototype.renameVar=function(a,b){for(var c=0,d;d=this.inputList[c];c++)for(var e=0,f;f=d.fieldRow[e];e++)f instanceof Blockly.FieldVariable&&Blockly.Names.equals(a,f.getValue())&&f.setValue(b)};Blockly.Block.prototype.getFieldValue=function(a){return(a=this.getField(a))?a.getValue():null};Blockly.Block.prototype.getTitleValue=function(a){console.warn("Deprecated call to getTitleValue, use getFieldValue instead.");return this.getFieldValue(a)};
Blockly.Block.prototype.setFieldValue=function(a,b){var c=this.getField(b);goog.asserts.assertObject(c,'Field "%s" not found.',b);c.setValue(a)};Blockly.Block.prototype.setTitleValue=function(a,b){console.warn("Deprecated call to setTitleValue, use setFieldValue instead.");this.setFieldValue(a,b)};
Blockly.Block.prototype.setPreviousStatement=function(a,b){this.previousConnection&&(goog.asserts.assert(!this.previousConnection.targetConnection,"Must disconnect previous statement before removing connection."),this.previousConnection.dispose(),this.previousConnection=null);a&&(goog.asserts.assert(!this.outputConnection,"Remove output connection prior to adding previous connection."),void 0===b&&(b=null),this.previousConnection=new Blockly.Connection(this,Blockly.PREVIOUS_STATEMENT),this.previousConnection.setCheck(b));
this.rendered&&(this.render(),this.bumpNeighbours_())};Blockly.Block.prototype.setNextStatement=function(a,b){this.nextConnection&&(goog.asserts.assert(!this.nextConnection.targetConnection,"Must disconnect next statement before removing connection."),this.nextConnection.dispose(),this.nextConnection=null);a&&(void 0===b&&(b=null),this.nextConnection=new Blockly.Connection(this,Blockly.NEXT_STATEMENT),this.nextConnection.setCheck(b));this.rendered&&(this.render(),this.bumpNeighbours_())};
@@ -1077,9 +1091,9 @@ e.alt);break;case "field_date":if(Blockly.FieldDate){f=new Blockly.FieldDate(e.d
Blockly.Block.prototype.appendInput_=function(a,b){var c=null;if(a==Blockly.INPUT_VALUE||a==Blockly.NEXT_STATEMENT)c=new Blockly.Connection(this,a);c=new Blockly.Input(a,b,this,c);this.inputList.push(c);this.rendered&&(this.render(),this.bumpNeighbours_());return c};
Blockly.Block.prototype.moveInputBefore=function(a,b){if(a!=b){for(var c=-1,d=b?-1:this.inputList.length,e=0,f;f=this.inputList[e];e++)if(f.name==a){if(c=e,-1!=d)break}else if(b&&f.name==b&&(d=e,-1!=c))break;goog.asserts.assert(-1!=c,'Named input "%s" not found.',a);goog.asserts.assert(-1!=d,'Reference input "%s" not found.',b);this.moveNumberedInputBefore(c,d)}};
Blockly.Block.prototype.moveNumberedInputBefore=function(a,b){goog.asserts.assert(a!=b,"Can't move input to itself.");goog.asserts.assert(a<this.inputList.length,"Input index "+a+" out of bounds.");goog.asserts.assert(b<=this.inputList.length,"Reference input "+b+" out of bounds.");var c=this.inputList[a];this.inputList.splice(a,1);a<b&&b--;this.inputList.splice(b,0,c);this.rendered&&(this.render(),this.bumpNeighbours_())};
Blockly.Block.prototype.removeInput=function(a,b){for(var c=0,d;d=this.inputList[c];c++)if(d.name==a){d.connection&&d.connection.targetConnection&&d.connection.targetBlock().setParent(null);d.dispose();this.inputList.splice(c,1);this.rendered&&(this.render(),this.bumpNeighbours_());return}b||goog.asserts.fail('Input "%s" not found.',a)};Blockly.Block.prototype.getInput=function(a){for(var b=0,c;c=this.inputList[b];b++)if(c.name==a)return c;return null};
Blockly.Block.prototype.removeInput=function(a,b){for(var c=0,d;d=this.inputList[c];c++)if(d.name==a){d.connection&&d.connection.targetConnection&&d.connection.targetBlock().unplug();d.dispose();this.inputList.splice(c,1);this.rendered&&(this.render(),this.bumpNeighbours_());return}b||goog.asserts.fail('Input "%s" not found.',a)};Blockly.Block.prototype.getInput=function(a){for(var b=0,c;c=this.inputList[b];b++)if(c.name==a)return c;return null};
Blockly.Block.prototype.getInputTargetBlock=function(a){return(a=this.getInput(a))&&a.connection&&a.connection.targetBlock()};Blockly.Block.prototype.getCommentText=function(){return this.comment||""};Blockly.Block.prototype.setCommentText=function(a){this.comment!=a&&(Blockly.Events.fire(new Blockly.Events.Change(this,"comment",null,this.comment,a||"")),this.comment=a)};Blockly.Block.prototype.setWarningText=function(a){};Blockly.Block.prototype.setMutator=function(a){};
Blockly.Block.prototype.getRelativeToSurfaceXY=function(){return this.xy_};Blockly.Block.prototype.moveBy=function(a,b){var c=new Blockly.Events.Move(this);this.xy_.translate(a,b);c.recordNew();Blockly.Events.fire(c)};Blockly.Block.BlockDB_=Object.create(null);Blockly.Block.getById=function(a){return Blockly.Block.BlockDB_[a]||null};Blockly.ContextMenu={};Blockly.ContextMenu.currentBlock=null;
Blockly.Block.prototype.getRelativeToSurfaceXY=function(){return this.xy_};Blockly.Block.prototype.moveBy=function(a,b){goog.asserts.assert(!this.parentBlock_,"Block has parent.");var c=new Blockly.Events.Move(this);this.xy_.translate(a,b);c.recordNew();Blockly.Events.fire(c)};Blockly.Block.BlockDB_=Object.create(null);Blockly.Block.getById=function(a){return Blockly.Block.BlockDB_[a]||null};Blockly.ContextMenu={};Blockly.ContextMenu.currentBlock=null;
Blockly.ContextMenu.show=function(a,b,c){Blockly.WidgetDiv.show(Blockly.ContextMenu,c,null);if(b.length){var d=new goog.ui.Menu;d.setRightToLeft(c);for(var e=0,f;f=b[e];e++){var g=new goog.ui.MenuItem(f.text);g.setRightToLeft(c);d.addChild(g,!0);g.setEnabled(f.enabled);f.enabled&&goog.events.listen(g,goog.ui.Component.EventType.ACTION,f.callback)}goog.events.listen(d,goog.ui.Component.EventType.ACTION,Blockly.ContextMenu.hide);b=goog.dom.getViewportSize();f=goog.style.getViewportPageOffset(document);
d.render(Blockly.WidgetDiv.DIV);var h=d.getElement();Blockly.addClass_(h,"blocklyContextMenu");var g=goog.style.getSize(h),e=a.clientX+f.x,k=a.clientY+f.y;a.clientY+g.height>=b.height&&(k-=g.height);c?g.width>=a.clientX&&(e+=g.width):a.clientX+g.width>=b.width&&(e-=g.width);Blockly.WidgetDiv.position(e,k,b,f,c);d.setAllowAutoFocus(!0);setTimeout(function(){h.focus()},1);Blockly.ContextMenu.currentBlock=null}else Blockly.ContextMenu.hide()};
Blockly.ContextMenu.hide=function(){Blockly.WidgetDiv.hideIfOwner(Blockly.ContextMenu);Blockly.ContextMenu.currentBlock=null};
@@ -1089,34 +1103,29 @@ Blockly.BlockSvg.prototype.initSvg=function(){goog.asserts.assert(this.workspace
!0;this.getSvgRoot().parentNode||this.workspace.getCanvas().appendChild(this.getSvgRoot())};Blockly.BlockSvg.prototype.select=function(){Blockly.selected&&Blockly.selected.unselect();Blockly.selected=this;this.addSelect();Blockly.fireUiEvent(this.workspace.getCanvas(),"blocklySelectChange")};Blockly.BlockSvg.prototype.unselect=function(){Blockly.selected=null;this.removeSelect();Blockly.fireUiEvent(this.workspace.getCanvas(),"blocklySelectChange")};Blockly.BlockSvg.prototype.mutator=null;
Blockly.BlockSvg.prototype.comment=null;Blockly.BlockSvg.prototype.warning=null;Blockly.BlockSvg.prototype.getIcons=function(){var a=[];this.mutator&&a.push(this.mutator);this.comment&&a.push(this.comment);this.warning&&a.push(this.warning);return a};Blockly.BlockSvg.onMouseUpWrapper_=null;Blockly.BlockSvg.onMouseMoveWrapper_=null;
Blockly.BlockSvg.terminateDrag_=function(){Blockly.BlockSvg.disconnectUiStop_();Blockly.BlockSvg.onMouseUpWrapper_&&(Blockly.unbindEvent_(Blockly.BlockSvg.onMouseUpWrapper_),Blockly.BlockSvg.onMouseUpWrapper_=null);Blockly.BlockSvg.onMouseMoveWrapper_&&(Blockly.unbindEvent_(Blockly.BlockSvg.onMouseMoveWrapper_),Blockly.BlockSvg.onMouseMoveWrapper_=null);var a=Blockly.selected;if(2==Blockly.dragMode_&&a){var b=a.getRelativeToSurfaceXY(),b=goog.math.Coordinate.difference(b,a.dragStartXY_),c=new Blockly.Events.Move(a);
c.oldCoordinate=a.dragStartXY_;c.recordNew();Blockly.Events.fire(c);a.moveConnections_(b.x,b.y);delete a.draggedBubbles_;a.setDragging_(!1);a.render();goog.Timer.callOnce(a.snapToGrid,Blockly.BUMP_DELAY/2,a);goog.Timer.callOnce(a.bumpNeighbours_,Blockly.BUMP_DELAY,a);Blockly.fireUiEvent(window,"resize")}Blockly.dragMode_=0;Blockly.Css.setCursor(Blockly.Css.Cursor.OPEN)};
Blockly.BlockSvg.prototype.setParent=function(a){var b=this.getSvgRoot();if(this.parentBlock_&&b){var c=this.getRelativeToSurfaceXY();this.workspace.getCanvas().appendChild(b);b.setAttribute("transform","translate("+c.x+","+c.y+")")}Blockly.Field.startCache();Blockly.BlockSvg.superClass_.setParent.call(this,a);Blockly.Field.stopCache();a&&(c=this.getRelativeToSurfaceXY(),a.getSvgRoot().appendChild(b),a=this.getRelativeToSurfaceXY(),this.moveConnections_(a.x-c.x,a.y-c.y))};
Blockly.BlockSvg.prototype.getRelativeToSurfaceXY=function(){var a=0,b=0,c=this.getSvgRoot();if(c){do var d=Blockly.getRelativeXY_(c),a=a+d.x,b=b+d.y,c=c.parentNode;while(c&&c!=this.workspace.getCanvas())}return new goog.math.Coordinate(a,b)};Blockly.BlockSvg.prototype.moveBy=function(a,b){var c=new Blockly.Events.Move(this),d=this.getRelativeToSurfaceXY();this.getSvgRoot().setAttribute("transform","translate("+(d.x+a)+","+(d.y+b)+")");this.moveConnections_(a,b);c.recordNew();Blockly.Events.fire(c)};
c.oldCoordinate=a.dragStartXY_;c.recordNew();Blockly.Events.fire(c);a.moveConnections_(b.x,b.y);delete a.draggedBubbles_;a.setDragging_(!1);a.render();var d=Blockly.Events.getGroup();setTimeout(function(){Blockly.Events.setGroup(d);a.snapToGrid();Blockly.Events.setGroup(!1)},Blockly.BUMP_DELAY/2);setTimeout(function(){Blockly.Events.setGroup(d);a.bumpNeighbours_();Blockly.Events.setGroup(!1)},Blockly.BUMP_DELAY);Blockly.fireUiEvent(window,"resize")}Blockly.dragMode_=0;Blockly.Css.setCursor(Blockly.Css.Cursor.OPEN)};
Blockly.BlockSvg.prototype.setParent=function(a){if(a!=this.parentBlock_){var b=this.getSvgRoot();if(this.parentBlock_&&b){var c=this.getRelativeToSurfaceXY();this.workspace.getCanvas().appendChild(b);b.setAttribute("transform","translate("+c.x+","+c.y+")")}Blockly.Field.startCache();Blockly.BlockSvg.superClass_.setParent.call(this,a);Blockly.Field.stopCache();a&&(c=this.getRelativeToSurfaceXY(),a.getSvgRoot().appendChild(b),a=this.getRelativeToSurfaceXY(),this.moveConnections_(a.x-c.x,a.y-c.y))}};
Blockly.BlockSvg.prototype.getRelativeToSurfaceXY=function(){var a=0,b=0,c=this.getSvgRoot();if(c){do var d=Blockly.getRelativeXY_(c),a=a+d.x,b=b+d.y,c=c.parentNode;while(c&&c!=this.workspace.getCanvas())}return new goog.math.Coordinate(a,b)};
Blockly.BlockSvg.prototype.moveBy=function(a,b){goog.asserts.assert(!this.parentBlock_,"Block has parent.");var c=new Blockly.Events.Move(this),d=this.getRelativeToSurfaceXY();this.getSvgRoot().setAttribute("transform","translate("+(d.x+a)+","+(d.y+b)+")");this.moveConnections_(a,b);c.recordNew();Blockly.Events.fire(c)};
Blockly.BlockSvg.prototype.snapToGrid=function(){if(this.workspace&&0==Blockly.dragMode_&&!this.getParent()&&!this.isInFlyout&&this.workspace.options.gridOptions&&this.workspace.options.gridOptions.snap){var a=this.workspace.options.gridOptions.spacing,b=a/2,c=this.getRelativeToSurfaceXY(),d=Math.round((c.x-b)/a)*a+b-c.x,a=Math.round((c.y-b)/a)*a+b-c.y,d=Math.round(d),a=Math.round(a);0==d&&0==a||this.moveBy(d,a)}};
Blockly.BlockSvg.prototype.getHeightWidth=function(){var a=this.height,b=this.width,c=this.getNextBlock();c?(c=c.getHeightWidth(),a+=c.height-4,b=Math.max(b,c.width)):this.nextConnection||this.outputConnection||(a+=2);return{height:a,width:b}};
Blockly.BlockSvg.prototype.getBoundingRectangle=function(){var a=this.getRelativeToSurfaceXY(this),b=this.outputConnection?Blockly.BlockSvg.TAB_WIDTH:0,c=this.getHeightWidth(),d;this.RTL?(d=new goog.math.Coordinate(a.x-(c.width-b),a.y),a=new goog.math.Coordinate(a.x+b,a.y+c.height)):(d=new goog.math.Coordinate(a.x-b,a.y),a=new goog.math.Coordinate(a.x+c.width-b,a.y+c.height));return{topLeft:d,bottomRight:a}};
Blockly.BlockSvg.prototype.setCollapsed=function(a){if(this.collapsed_!=a){for(var b=[],c=0,d;d=this.inputList[c];c++)b.push.apply(b,d.setVisible(!a));if(a){d=this.getIcons();for(c=0;c<d.length;c++)d[c].setVisible(!1);c=this.toString(Blockly.COLLAPSE_CHARS);this.appendDummyInput("_TEMP_COLLAPSED_INPUT").appendField(c).init()}else this.removeInput("_TEMP_COLLAPSED_INPUT"),this.setWarningText(null);Blockly.BlockSvg.superClass_.setCollapsed.call(this,a);b.length||(b[0]=this);if(this.rendered)for(c=0;a=
b[c];c++)a.render()}};Blockly.BlockSvg.prototype.tab=function(a,b){for(var c=[],d=0,e;e=this.inputList[d];d++){for(var f=0,g;g=e.fieldRow[f];f++)g instanceof Blockly.FieldTextInput&&c.push(g);e.connection&&(e=e.connection.targetBlock())&&c.push(e)}d=c.indexOf(a);-1==d&&(d=b?-1:c.length);(c=c[b?d+1:d-1])?c instanceof Blockly.Field?c.showEditor_():c.tab(null,b):(c=this.getParent())&&c.tab(this,b)};
Blockly.BlockSvg.prototype.onMouseDown_=function(a){if(!this.isInFlyout)if(this.workspace.markFocused(),Blockly.svgResize(this.workspace),Blockly.terminateDrag_(),this.select(),Blockly.hideChaff(),this.workspace.recordDeleteAreas(),Blockly.isRightButton(a))this.showContextMenu_(a);else if(this.isMovable()){Blockly.Events.group=Blockly.genUid();Blockly.removeAllRanges();Blockly.Css.setCursor(Blockly.Css.Cursor.CLOSED);this.dragStartXY_=this.getRelativeToSurfaceXY();this.workspace.startDrag(a,this.dragStartXY_.x,
this.dragStartXY_.y);Blockly.dragMode_=1;Blockly.BlockSvg.onMouseUpWrapper_=Blockly.bindEvent_(document,"mouseup",this,this.onMouseUp_);Blockly.BlockSvg.onMouseMoveWrapper_=Blockly.bindEvent_(document,"mousemove",this,this.onMouseMove_);this.draggedBubbles_=[];for(var b=this.getDescendants(),c=0,d;d=b[c];c++){d=d.getIcons();for(var e=0;e<d.length;e++){var f=d[e].getIconLocation();f.bubble=d[e];this.draggedBubbles_.push(f)}}}else return;a.stopPropagation()};
Blockly.BlockSvg.prototype.onMouseUp_=function(a){Blockly.terminateDrag_();Blockly.selected&&Blockly.highlightedConnection_?(Blockly.localConnection_.connect(Blockly.highlightedConnection_),this.rendered&&(Blockly.localConnection_.isSuperior()?Blockly.highlightedConnection_:Blockly.localConnection_).sourceBlock_.connectionUiEffect(),this.workspace.trashcan&&this.workspace.trashcan.close()):!this.getParent()&&Blockly.selected.isDeletable()&&this.workspace.isDeleteArea(a)&&((a=this.workspace.trashcan)&&
goog.Timer.callOnce(a.close,100,a),Blockly.selected.dispose(!1,!0),Blockly.fireUiEvent(window,"resize"));Blockly.highlightedConnection_&&(Blockly.highlightedConnection_.unhighlight(),Blockly.highlightedConnection_=null);Blockly.Css.setCursor(Blockly.Css.Cursor.OPEN);Blockly.Events.group=""};Blockly.BlockSvg.prototype.showHelp_=function(){var a=goog.isFunction(this.helpUrl)?this.helpUrl():this.helpUrl;a&&window.open(a)};
Blockly.BlockSvg.prototype.onMouseDown_=function(a){if(!this.workspace.options.readOnly){if(!this.isInFlyout)if(this.workspace.markFocused(),Blockly.svgResize(this.workspace),Blockly.terminateDrag_(),this.select(),Blockly.hideChaff(),this.workspace.recordDeleteAreas(),Blockly.isRightButton(a))this.showContextMenu_(a);else if(this.isMovable()){Blockly.Events.getGroup()||Blockly.Events.setGroup(!0);Blockly.removeAllRanges();Blockly.Css.setCursor(Blockly.Css.Cursor.CLOSED);this.dragStartXY_=this.getRelativeToSurfaceXY();
this.workspace.startDrag(a,this.dragStartXY_.x,this.dragStartXY_.y);Blockly.dragMode_=1;Blockly.BlockSvg.onMouseUpWrapper_=Blockly.bindEvent_(document,"mouseup",this,this.onMouseUp_);Blockly.BlockSvg.onMouseMoveWrapper_=Blockly.bindEvent_(document,"mousemove",this,this.onMouseMove_);this.draggedBubbles_=[];for(var b=this.getDescendants(),c=0,d;d=b[c];c++){d=d.getIcons();for(var e=0;e<d.length;e++){var f=d[e].getIconLocation();f.bubble=d[e];this.draggedBubbles_.push(f)}}}else return;a.stopPropagation()}};
Blockly.BlockSvg.prototype.onMouseUp_=function(a){Blockly.terminateDrag_();Blockly.selected&&Blockly.highlightedConnection_?(Blockly.localConnection_.connect(Blockly.highlightedConnection_),this.rendered&&(Blockly.localConnection_.isSuperior()?Blockly.highlightedConnection_:Blockly.localConnection_).getSourceBlock().connectionUiEffect(),this.workspace.trashcan&&this.workspace.trashcan.close()):!this.getParent()&&Blockly.selected.isDeletable()&&this.workspace.isDeleteArea(a)&&((a=this.workspace.trashcan)&&
goog.Timer.callOnce(a.close,100,a),Blockly.selected.dispose(!1,!0),Blockly.fireUiEvent(window,"resize"));Blockly.highlightedConnection_&&(Blockly.highlightedConnection_.unhighlight(),Blockly.highlightedConnection_=null);Blockly.Css.setCursor(Blockly.Css.Cursor.OPEN);Blockly.WidgetDiv.isVisible()||Blockly.Events.setGroup(!1)};Blockly.BlockSvg.prototype.showHelp_=function(){var a=goog.isFunction(this.helpUrl)?this.helpUrl():this.helpUrl;a&&window.open(a)};
Blockly.BlockSvg.prototype.showContextMenu_=function(a){if(!this.workspace.options.readOnly&&this.contextMenu){var b=this,c=[];if(this.isDeletable()&&this.isMovable()&&!b.isInFlyout){var d={text:Blockly.Msg.DUPLICATE_BLOCK,enabled:!0,callback:function(){Blockly.duplicate_(b)}};this.getDescendants().length>this.workspace.remainingCapacity()&&(d.enabled=!1);c.push(d);this.isEditable()&&!this.collapsed_&&this.workspace.options.comments&&(d={enabled:!goog.userAgent.IE},this.comment?(d.text=Blockly.Msg.REMOVE_COMMENT,
d.callback=function(){b.setCommentText(null)}):(d.text=Blockly.Msg.ADD_COMMENT,d.callback=function(){b.setCommentText("")}),c.push(d));if(!this.collapsed_)for(d=1;d<this.inputList.length;d++)if(this.inputList[d-1].type!=Blockly.NEXT_STATEMENT&&this.inputList[d].type!=Blockly.NEXT_STATEMENT){var d={enabled:!0},e=this.getInputsInline();d.text=e?Blockly.Msg.EXTERNAL_INPUTS:Blockly.Msg.INLINE_INPUTS;d.callback=function(){b.setInputsInline(!e)};c.push(d);break}this.workspace.options.collapse&&(this.collapsed_?
(d={enabled:!0},d.text=Blockly.Msg.EXPAND_BLOCK,d.callback=function(){b.setCollapsed(!1)}):(d={enabled:!0},d.text=Blockly.Msg.COLLAPSE_BLOCK,d.callback=function(){b.setCollapsed(!0)}),c.push(d));this.workspace.options.disable&&(d={text:this.disabled?Blockly.Msg.ENABLE_BLOCK:Blockly.Msg.DISABLE_BLOCK,enabled:!this.getInheritedDisabled(),callback:function(){b.setDisabled(!b.disabled)}},c.push(d));var d=this.getDescendants().length,f=this.getNextBlock();f&&(d-=f.getDescendants().length);d={text:1==d?
Blockly.Msg.DELETE_BLOCK:Blockly.Msg.DELETE_X_BLOCKS.replace("%1",String(d)),enabled:!0,callback:function(){b.dispose(!0,!0)}};c.push(d)}d={enabled:!(goog.isFunction(this.helpUrl)?!this.helpUrl():!this.helpUrl)};d.text=Blockly.Msg.HELP;d.callback=function(){b.showHelp_()};c.push(d);this.customContextMenu&&!b.isInFlyout&&this.customContextMenu(c);Blockly.ContextMenu.show(a,c,this.RTL);Blockly.ContextMenu.currentBlock=this}};
Blockly.BlockSvg.prototype.moveConnections_=function(a,b){if(this.rendered){for(var c=this.getConnections_(!1),d=0;d<c.length;d++)c[d].moveBy(a,b);c=this.getIcons();for(d=0;d<c.length;d++)c[d].computeIconLocation();for(d=0;d<this.childBlocks_.length;d++)this.childBlocks_[d].moveConnections_(a,b)}};Blockly.BlockSvg.prototype.setDragging_=function(a){a?this.addDragging():this.removeDragging();for(var b=0;b<this.childBlocks_.length;b++)this.childBlocks_[b].setDragging_(a)};
Blockly.BlockSvg.prototype.onMouseMove_=function(a){if(!("mousemove"==a.type&&1>=a.clientX&&0==a.clientY&&0==a.button)){Blockly.removeAllRanges();var b=this.getRelativeToSurfaceXY(),c=this.workspace.moveDrag(a),d=this.getSvgRoot();1==Blockly.dragMode_&&goog.math.Coordinate.distance(b,c)*this.workspace.scale>Blockly.DRAG_RADIUS&&(Blockly.dragMode_=2,Blockly.longStop_(),d.translate_="",d.skew_="",this.parentBlock_&&(this.setParent(null),this.disconnectUiEffect()),this.setDragging_(!0));if(2==Blockly.dragMode_){var e=
b.x-this.dragStartXY_.x,b=b.y-this.dragStartXY_.y;d.translate_="translate("+c.x+","+c.y+")";d.setAttribute("transform",d.translate_+d.skew_);for(c=0;c<this.draggedBubbles_.length;c++)d=this.draggedBubbles_[c],d.bubble.setIconLocation(d.x+e,d.y+b);for(var d=this.getConnections_(!1),f=null,g=null,h=Blockly.SNAP_RADIUS,c=0;c<d.length;c++){var k=d[c],l=k.closest(h,e,b);l.connection&&(f=l.connection,g=k,h=l.radius)}Blockly.highlightedConnection_&&Blockly.highlightedConnection_!=f&&(Blockly.highlightedConnection_.unhighlight(),
Blockly.highlightedConnection_=null,Blockly.localConnection_=null);f&&f!=Blockly.highlightedConnection_&&(f.highlight(),Blockly.highlightedConnection_=f,Blockly.localConnection_=g);this.isDeletable()&&this.workspace.isDeleteArea(a)}}a.stopPropagation()};Blockly.BlockSvg.prototype.updateMovable=function(){this.isMovable()?Blockly.addClass_(this.svgGroup_,"blocklyDraggable"):Blockly.removeClass_(this.svgGroup_,"blocklyDraggable")};
Blockly.BlockSvg.prototype.onMouseMove_=function(a){if(!("mousemove"==a.type&&1>=a.clientX&&0==a.clientY&&0==a.button)){Blockly.removeAllRanges();var b=this.getRelativeToSurfaceXY(),c=this.workspace.moveDrag(a),d=this.getSvgRoot();1==Blockly.dragMode_&&goog.math.Coordinate.distance(b,c)*this.workspace.scale>Blockly.DRAG_RADIUS&&(Blockly.dragMode_=2,Blockly.longStop_(),d.translate_="",d.skew_="",this.parentBlock_&&(this.unplug(),this.disconnectUiEffect()),this.setDragging_(!0));if(2==Blockly.dragMode_){var e=
b.x-this.dragStartXY_.x,b=b.y-this.dragStartXY_.y;d.translate_="translate("+c.x+","+c.y+")";d.setAttribute("transform",d.translate_+d.skew_);for(c=0;c<this.draggedBubbles_.length;c++)d=this.draggedBubbles_[c],d.bubble.setIconLocation(d.x+e,d.y+b);d=this.getConnections_(!1);(c=this.lastConnectionInStack_())&&c!=this.nextConnection&&d.push(c);for(var f=null,g=null,h=Blockly.SNAP_RADIUS,c=0;c<d.length;c++){var k=d[c],l=k.closest(h,e,b);l.connection&&(f=l.connection,g=k,h=l.radius)}Blockly.highlightedConnection_&&
Blockly.highlightedConnection_!=f&&(Blockly.highlightedConnection_.unhighlight(),Blockly.highlightedConnection_=null,Blockly.localConnection_=null);f&&f!=Blockly.highlightedConnection_&&(f.highlight(),Blockly.highlightedConnection_=f,Blockly.localConnection_=g);this.isDeletable()&&this.workspace.isDeleteArea(a)}}a.stopPropagation()};Blockly.BlockSvg.prototype.updateMovable=function(){this.isMovable()?Blockly.addClass_(this.svgGroup_,"blocklyDraggable"):Blockly.removeClass_(this.svgGroup_,"blocklyDraggable")};
Blockly.BlockSvg.prototype.setMovable=function(a){Blockly.BlockSvg.superClass_.setMovable.call(this,a);this.updateMovable()};Blockly.BlockSvg.prototype.setEditable=function(a){Blockly.BlockSvg.superClass_.setEditable.call(this,a);if(this.rendered)for(a=0;a<this.icons_.length;a++)this.icons_[a].updateEditable()};Blockly.BlockSvg.prototype.setShadow=function(a){Blockly.BlockSvg.superClass_.setShadow.call(this,a);this.updateColour()};Blockly.BlockSvg.prototype.getSvgRoot=function(){return this.svgGroup_};
Blockly.BlockSvg.SEP_SPACE_X=10;Blockly.BlockSvg.SEP_SPACE_Y=10;Blockly.BlockSvg.INLINE_PADDING_Y=5;Blockly.BlockSvg.MIN_BLOCK_Y=25;Blockly.BlockSvg.TAB_HEIGHT=20;Blockly.BlockSvg.TAB_WIDTH=8;Blockly.BlockSvg.NOTCH_WIDTH=30;Blockly.BlockSvg.CORNER_RADIUS=8;Blockly.BlockSvg.START_HAT=!1;Blockly.BlockSvg.START_HAT_PATH="c 30,-15 70,-15 100,0";Blockly.BlockSvg.START_HAT_HIGHLIGHT_LTR="c 17.8,-9.2 45.3,-14.9 75,-8.7 M 100.5,0.5";Blockly.BlockSvg.START_HAT_HIGHLIGHT_RTL="m 25,-8.7 c 29.7,-6.2 57.2,-0.5 75,8.7";
Blockly.BlockSvg.DISTANCE_45_INSIDE=(1-Math.SQRT1_2)*(Blockly.BlockSvg.CORNER_RADIUS-.5)+.5;Blockly.BlockSvg.DISTANCE_45_OUTSIDE=(1-Math.SQRT1_2)*(Blockly.BlockSvg.CORNER_RADIUS+.5)-.5;Blockly.BlockSvg.NOTCH_PATH_LEFT="l 6,4 3,0 6,-4";Blockly.BlockSvg.NOTCH_PATH_LEFT_HIGHLIGHT="l 6,4 3,0 6,-4";Blockly.BlockSvg.NOTCH_PATH_RIGHT="l -6,4 -3,0 -6,-4";Blockly.BlockSvg.JAGGED_TEETH="l 8,0 0,4 8,4 -16,8 8,4";Blockly.BlockSvg.JAGGED_TEETH_HEIGHT=20;Blockly.BlockSvg.JAGGED_TEETH_WIDTH=15;
Blockly.BlockSvg.TAB_PATH_DOWN="v 5 c 0,10 -"+Blockly.BlockSvg.TAB_WIDTH+",-8 -"+Blockly.BlockSvg.TAB_WIDTH+",7.5 s "+Blockly.BlockSvg.TAB_WIDTH+",-2.5 "+Blockly.BlockSvg.TAB_WIDTH+",7.5";Blockly.BlockSvg.TAB_PATH_DOWN_HIGHLIGHT_RTL="v 6.5 m -"+.97*Blockly.BlockSvg.TAB_WIDTH+",3 q -"+.05*Blockly.BlockSvg.TAB_WIDTH+",10 "+.3*Blockly.BlockSvg.TAB_WIDTH+",9.5 m "+.67*Blockly.BlockSvg.TAB_WIDTH+",-1.9 v 1.4";Blockly.BlockSvg.TOP_LEFT_CORNER_START="m 0,"+Blockly.BlockSvg.CORNER_RADIUS;
Blockly.BlockSvg.TOP_LEFT_CORNER_START_HIGHLIGHT_RTL="m "+Blockly.BlockSvg.DISTANCE_45_INSIDE+","+Blockly.BlockSvg.DISTANCE_45_INSIDE;Blockly.BlockSvg.TOP_LEFT_CORNER_START_HIGHLIGHT_LTR="m 0.5,"+(Blockly.BlockSvg.CORNER_RADIUS-.5);Blockly.BlockSvg.TOP_LEFT_CORNER="A "+Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS+" 0 0,1 "+Blockly.BlockSvg.CORNER_RADIUS+",0";
Blockly.BlockSvg.TOP_LEFT_CORNER_HIGHLIGHT="A "+(Blockly.BlockSvg.CORNER_RADIUS-.5)+","+(Blockly.BlockSvg.CORNER_RADIUS-.5)+" 0 0,1 "+Blockly.BlockSvg.CORNER_RADIUS+",0.5";Blockly.BlockSvg.INNER_TOP_LEFT_CORNER=Blockly.BlockSvg.NOTCH_PATH_RIGHT+" h -"+(Blockly.BlockSvg.NOTCH_WIDTH-15-Blockly.BlockSvg.CORNER_RADIUS)+" a "+Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS+" 0 0,0 -"+Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS;
Blockly.BlockSvg.INNER_BOTTOM_LEFT_CORNER="a "+Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS+" 0 0,0 "+Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS;Blockly.BlockSvg.INNER_TOP_LEFT_CORNER_HIGHLIGHT_RTL="a "+Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS+" 0 0,0 "+(-Blockly.BlockSvg.DISTANCE_45_OUTSIDE-.5)+","+(Blockly.BlockSvg.CORNER_RADIUS-Blockly.BlockSvg.DISTANCE_45_OUTSIDE);
Blockly.BlockSvg.INNER_BOTTOM_LEFT_CORNER_HIGHLIGHT_RTL="a "+(Blockly.BlockSvg.CORNER_RADIUS+.5)+","+(Blockly.BlockSvg.CORNER_RADIUS+.5)+" 0 0,0 "+(Blockly.BlockSvg.CORNER_RADIUS+.5)+","+(Blockly.BlockSvg.CORNER_RADIUS+.5);Blockly.BlockSvg.INNER_BOTTOM_LEFT_CORNER_HIGHLIGHT_LTR="a "+(Blockly.BlockSvg.CORNER_RADIUS+.5)+","+(Blockly.BlockSvg.CORNER_RADIUS+.5)+" 0 0,0 "+(Blockly.BlockSvg.CORNER_RADIUS-Blockly.BlockSvg.DISTANCE_45_OUTSIDE)+","+(Blockly.BlockSvg.DISTANCE_45_OUTSIDE+.5);
Blockly.BlockSvg.prototype.dispose=function(a,b){Blockly.Field.startCache();Blockly.selected==this&&Blockly.terminateDrag_();Blockly.ContextMenu.currentBlock==this&&Blockly.ContextMenu.hide();b&&this.rendered&&(this.unplug(a),this.disposeUiEffect());this.rendered=!1;Blockly.BlockSvg.superClass_.dispose.call(this,a);Blockly.Events.disable();for(var c=this.getIcons(),d=0;d<c.length;d++)c[d].dispose();Blockly.Events.enable();goog.dom.removeNode(this.svgGroup_);this.svgPathDark_=this.svgPathLight_=this.svgPath_=
Blockly.BlockSvg.prototype.dispose=function(a,b){Blockly.Field.startCache();Blockly.selected==this&&Blockly.terminateDrag_();Blockly.ContextMenu.currentBlock==this&&Blockly.ContextMenu.hide();b&&this.rendered&&(this.unplug(a),this.disposeUiEffect());this.rendered=!1;Blockly.Events.disable();for(var c=this.getIcons(),d=0;d<c.length;d++)c[d].dispose();Blockly.Events.enable();Blockly.BlockSvg.superClass_.dispose.call(this,a);goog.dom.removeNode(this.svgGroup_);this.svgPathDark_=this.svgPathLight_=this.svgPath_=
this.svgGroup_=null;Blockly.Field.stopCache()};Blockly.BlockSvg.prototype.disposeUiEffect=function(){this.workspace.playAudio("delete");var a=Blockly.getSvgXY_(this.svgGroup_,this.workspace),b=this.svgGroup_.cloneNode(!0);b.translateX_=a.x;b.translateY_=a.y;b.setAttribute("transform","translate("+b.translateX_+","+b.translateY_+")");this.workspace.getParentSvg().appendChild(b);b.bBox_=b.getBBox();Blockly.BlockSvg.disposeUiStep_(b,this.RTL,new Date,this.workspace.scale)};
Blockly.BlockSvg.disposeUiStep_=function(a,b,c,d){var e=(new Date-c)/150;1<e?goog.dom.removeNode(a):(a.setAttribute("transform","translate("+(a.translateX_+(b?-1:1)*a.bBox_.width*d/2*e)+","+(a.translateY_+a.bBox_.height*d*e)+") scale("+(1-e)*d+")"),setTimeout(function(){Blockly.BlockSvg.disposeUiStep_(a,b,c,d)},10))};
Blockly.BlockSvg.prototype.connectionUiEffect=function(){this.workspace.playAudio("click");if(!(1>this.workspace.scale)){var a=Blockly.getSvgXY_(this.svgGroup_,this.workspace);this.outputConnection?(a.x+=(this.RTL?3:-3)*this.workspace.scale,a.y+=13*this.workspace.scale):this.previousConnection&&(a.x+=(this.RTL?-23:23)*this.workspace.scale,a.y+=3*this.workspace.scale);a=Blockly.createSvgElement("circle",{cx:a.x,cy:a.y,r:0,fill:"none",stroke:"#888","stroke-width":10},this.workspace.getParentSvg());
@@ -1132,6 +1141,14 @@ Blockly.BlockSvg.prototype.setWarningText=function(a,b){this.setWarningText.pid_
e.setWarningText(a,c))},100)}else{this.isInFlyout&&(a=null);d=this.getSurroundParent();for(var f=null;d;)d.isCollapsed()&&(f=d),d=d.getSurroundParent();f&&f.setWarningText(a,"collapsed "+this.id+" "+c);d=!1;goog.isString(a)?(this.warning||(this.warning=new Blockly.Warning(this),d=!0),this.warning.setText(a,c)):this.warning&&!c?(this.warning.dispose(),d=!0):this.warning&&(d=this.warning.getText(),this.warning.setText("",c),(f=this.warning.getText())||this.warning.dispose(),d=d==f);d&&this.rendered&&
(this.render(),this.bumpNeighbours_())}};Blockly.BlockSvg.prototype.setMutator=function(a){this.mutator&&this.mutator!==a&&this.mutator.dispose();a&&(a.block_=this,this.mutator=a,a.createIcon())};Blockly.BlockSvg.prototype.setDisabled=function(a){this.disabled!=a&&(Blockly.BlockSvg.superClass_.setDisabled.call(this,a),this.rendered&&this.updateDisabled())};Blockly.BlockSvg.prototype.addSelect=function(){Blockly.addClass_(this.svgGroup_,"blocklySelected");this.svgGroup_.parentNode.appendChild(this.svgGroup_)};
Blockly.BlockSvg.prototype.removeSelect=function(){Blockly.removeClass_(this.svgGroup_,"blocklySelected")};Blockly.BlockSvg.prototype.addDragging=function(){Blockly.addClass_(this.svgGroup_,"blocklyDragging")};Blockly.BlockSvg.prototype.removeDragging=function(){Blockly.removeClass_(this.svgGroup_,"blocklyDragging")};
// Copyright 2016 Google Inc. Apache License 2.0
Blockly.BlockSvg.render={};Blockly.BlockSvg.SEP_SPACE_X=10;Blockly.BlockSvg.SEP_SPACE_Y=10;Blockly.BlockSvg.INLINE_PADDING_Y=5;Blockly.BlockSvg.MIN_BLOCK_Y=25;Blockly.BlockSvg.TAB_HEIGHT=20;Blockly.BlockSvg.TAB_WIDTH=8;Blockly.BlockSvg.NOTCH_WIDTH=30;Blockly.BlockSvg.CORNER_RADIUS=8;Blockly.BlockSvg.START_HAT=!1;Blockly.BlockSvg.START_HAT_PATH="c 30,-15 70,-15 100,0";Blockly.BlockSvg.START_HAT_HIGHLIGHT_LTR="c 17.8,-9.2 45.3,-14.9 75,-8.7 M 100.5,0.5";Blockly.BlockSvg.START_HAT_HIGHLIGHT_RTL="m 25,-8.7 c 29.7,-6.2 57.2,-0.5 75,8.7";
Blockly.BlockSvg.DISTANCE_45_INSIDE=(1-Math.SQRT1_2)*(Blockly.BlockSvg.CORNER_RADIUS-.5)+.5;Blockly.BlockSvg.DISTANCE_45_OUTSIDE=(1-Math.SQRT1_2)*(Blockly.BlockSvg.CORNER_RADIUS+.5)-.5;Blockly.BlockSvg.NOTCH_PATH_LEFT="l 6,4 3,0 6,-4";Blockly.BlockSvg.NOTCH_PATH_LEFT_HIGHLIGHT="l 6,4 3,0 6,-4";Blockly.BlockSvg.NOTCH_PATH_RIGHT="l -6,4 -3,0 -6,-4";Blockly.BlockSvg.JAGGED_TEETH="l 8,0 0,4 8,4 -16,8 8,4";Blockly.BlockSvg.JAGGED_TEETH_HEIGHT=20;Blockly.BlockSvg.JAGGED_TEETH_WIDTH=15;
Blockly.BlockSvg.TAB_PATH_DOWN="v 5 c 0,10 -"+Blockly.BlockSvg.TAB_WIDTH+",-8 -"+Blockly.BlockSvg.TAB_WIDTH+",7.5 s "+Blockly.BlockSvg.TAB_WIDTH+",-2.5 "+Blockly.BlockSvg.TAB_WIDTH+",7.5";Blockly.BlockSvg.TAB_PATH_DOWN_HIGHLIGHT_RTL="v 6.5 m -"+.97*Blockly.BlockSvg.TAB_WIDTH+",3 q -"+.05*Blockly.BlockSvg.TAB_WIDTH+",10 "+.3*Blockly.BlockSvg.TAB_WIDTH+",9.5 m "+.67*Blockly.BlockSvg.TAB_WIDTH+",-1.9 v 1.4";Blockly.BlockSvg.TOP_LEFT_CORNER_START="m 0,"+Blockly.BlockSvg.CORNER_RADIUS;
Blockly.BlockSvg.TOP_LEFT_CORNER_START_HIGHLIGHT_RTL="m "+Blockly.BlockSvg.DISTANCE_45_INSIDE+","+Blockly.BlockSvg.DISTANCE_45_INSIDE;Blockly.BlockSvg.TOP_LEFT_CORNER_START_HIGHLIGHT_LTR="m 0.5,"+(Blockly.BlockSvg.CORNER_RADIUS-.5);Blockly.BlockSvg.TOP_LEFT_CORNER="A "+Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS+" 0 0,1 "+Blockly.BlockSvg.CORNER_RADIUS+",0";
Blockly.BlockSvg.TOP_LEFT_CORNER_HIGHLIGHT="A "+(Blockly.BlockSvg.CORNER_RADIUS-.5)+","+(Blockly.BlockSvg.CORNER_RADIUS-.5)+" 0 0,1 "+Blockly.BlockSvg.CORNER_RADIUS+",0.5";Blockly.BlockSvg.INNER_TOP_LEFT_CORNER=Blockly.BlockSvg.NOTCH_PATH_RIGHT+" h -"+(Blockly.BlockSvg.NOTCH_WIDTH-15-Blockly.BlockSvg.CORNER_RADIUS)+" a "+Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS+" 0 0,0 -"+Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS;
Blockly.BlockSvg.INNER_BOTTOM_LEFT_CORNER="a "+Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS+" 0 0,0 "+Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS;Blockly.BlockSvg.INNER_TOP_LEFT_CORNER_HIGHLIGHT_RTL="a "+Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS+" 0 0,0 "+(-Blockly.BlockSvg.DISTANCE_45_OUTSIDE-.5)+","+(Blockly.BlockSvg.CORNER_RADIUS-Blockly.BlockSvg.DISTANCE_45_OUTSIDE);
Blockly.BlockSvg.INNER_BOTTOM_LEFT_CORNER_HIGHLIGHT_RTL="a "+(Blockly.BlockSvg.CORNER_RADIUS+.5)+","+(Blockly.BlockSvg.CORNER_RADIUS+.5)+" 0 0,0 "+(Blockly.BlockSvg.CORNER_RADIUS+.5)+","+(Blockly.BlockSvg.CORNER_RADIUS+.5);Blockly.BlockSvg.INNER_BOTTOM_LEFT_CORNER_HIGHLIGHT_LTR="a "+(Blockly.BlockSvg.CORNER_RADIUS+.5)+","+(Blockly.BlockSvg.CORNER_RADIUS+.5)+" 0 0,0 "+(Blockly.BlockSvg.CORNER_RADIUS-Blockly.BlockSvg.DISTANCE_45_OUTSIDE)+","+(Blockly.BlockSvg.DISTANCE_45_OUTSIDE+.5);
Blockly.BlockSvg.prototype.render=function(a){Blockly.Field.startCache();this.rendered=!0;var b=Blockly.BlockSvg.SEP_SPACE_X;this.RTL&&(b=-b);for(var c=this.getIcons(),d=0;d<c.length;d++)b=c[d].renderIcon(b);b+=this.RTL?Blockly.BlockSvg.SEP_SPACE_X:-Blockly.BlockSvg.SEP_SPACE_X;c=this.renderCompute_(b);this.renderDraw_(b,c);!1!==a&&((a=this.getParent())?a.render(!0):Blockly.fireUiEvent(window,"resize"));Blockly.Field.stopCache()};
Blockly.BlockSvg.prototype.renderFields_=function(a,b,c){c+=Blockly.BlockSvg.INLINE_PADDING_Y;this.RTL&&(b=-b);for(var d=0,e;e=a[d];d++){var f=e.getSvgRoot();f&&(this.RTL?(b-=e.renderSep+e.renderWidth,f.setAttribute("transform","translate("+b+","+c+")"),e.renderWidth&&(b-=Blockly.BlockSvg.SEP_SPACE_X)):(f.setAttribute("transform","translate("+(b+e.renderSep)+","+c+")"),e.renderWidth&&(b+=e.renderSep+e.renderWidth+Blockly.BlockSvg.SEP_SPACE_X)))}return this.RTL?-b:b};
Blockly.BlockSvg.prototype.renderCompute_=function(a){var b=this.inputList,c=[];c.rightEdge=a+2*Blockly.BlockSvg.SEP_SPACE_X;if(this.previousConnection||this.nextConnection)c.rightEdge=Math.max(c.rightEdge,Blockly.BlockSvg.NOTCH_WIDTH+Blockly.BlockSvg.SEP_SPACE_X);for(var d=0,e=0,f=!1,g=!1,h=!1,k=void 0,l=this.getInputsInline()&&!this.isCollapsed(),q=0,m;m=b[q];q++)if(m.isVisible()){var p;l&&k&&k!=Blockly.NEXT_STATEMENT&&m.type!=Blockly.NEXT_STATEMENT?p=c[c.length-1]:(k=m.type,p=[],p.type=l&&m.type!=
@@ -1157,21 +1174,28 @@ this.width=Math.max(this.width,f.statementEdge+n.connection.targetBlock().getHei
Blockly.BlockSvg.prototype.renderDrawBottom_=function(a,b,c,d){this.height=d+1;this.nextConnection&&(a.push("H",Blockly.BlockSvg.NOTCH_WIDTH+(this.RTL?.5:-.5)+" "+Blockly.BlockSvg.NOTCH_PATH_RIGHT),this.nextConnection.moveTo(this.RTL?c.x-Blockly.BlockSvg.NOTCH_WIDTH:c.x+Blockly.BlockSvg.NOTCH_WIDTH,c.y+d+1),this.nextConnection.targetConnection&&this.nextConnection.tighten_(),this.height+=4);this.squareBottomLeftCorner_?(a.push("H 0"),this.RTL||b.push("M","0.5,"+(d-.5))):(a.push("H",Blockly.BlockSvg.CORNER_RADIUS),
a.push("a",Blockly.BlockSvg.CORNER_RADIUS+","+Blockly.BlockSvg.CORNER_RADIUS+" 0 0,1 -"+Blockly.BlockSvg.CORNER_RADIUS+",-"+Blockly.BlockSvg.CORNER_RADIUS),this.RTL||(b.push("M",Blockly.BlockSvg.DISTANCE_45_INSIDE+","+(d-Blockly.BlockSvg.DISTANCE_45_INSIDE)),b.push("A",Blockly.BlockSvg.CORNER_RADIUS-.5+","+(Blockly.BlockSvg.CORNER_RADIUS-.5)+" 0 0,1 0.5,"+(d-Blockly.BlockSvg.CORNER_RADIUS))))};
Blockly.BlockSvg.prototype.renderDrawLeft_=function(a,b,c,d){this.outputConnection?(this.outputConnection.moveTo(c.x,c.y),a.push("V",Blockly.BlockSvg.TAB_HEIGHT),a.push("c 0,-10 -"+Blockly.BlockSvg.TAB_WIDTH+",8 -"+Blockly.BlockSvg.TAB_WIDTH+",-7.5 s "+Blockly.BlockSvg.TAB_WIDTH+",2.5 "+Blockly.BlockSvg.TAB_WIDTH+",-7.5"),this.RTL?(b.push("M",-.25*Blockly.BlockSvg.TAB_WIDTH+",8.4"),b.push("l",-.45*Blockly.BlockSvg.TAB_WIDTH+",-2.1")):(b.push("V",Blockly.BlockSvg.TAB_HEIGHT-1.5),b.push("m",-.92*Blockly.BlockSvg.TAB_WIDTH+
",-0.5 q "+-.19*Blockly.BlockSvg.TAB_WIDTH+",-5.5 0,-11"),b.push("m",.92*Blockly.BlockSvg.TAB_WIDTH+",1 V 0.5 H 1")),this.width+=Blockly.BlockSvg.TAB_WIDTH):this.RTL||(this.squareTopLeftCorner_?b.push("V",.5):b.push("V",Blockly.BlockSvg.CORNER_RADIUS));a.push("z")};
// Copyright 2016 Google Inc. Apache License 2.0
Blockly.Events={};Blockly.Events.group="";Blockly.Events.disabled_=0;Blockly.Events.CREATE="create";Blockly.Events.DELETE="delete";Blockly.Events.CHANGE="change";Blockly.Events.MOVE="move";Blockly.Events.FIRE_QUEUE_=[];Blockly.Events.fire=function(a){Blockly.Events.isEnabled()&&(0==Blockly.Events.FIRE_QUEUE_.length&&setTimeout(Blockly.Events.fireNow_,0),Blockly.Events.FIRE_QUEUE_.push(a))};
Blockly.Events.fireNow_=function(){for(var a=Blockly.Events.filter_(Blockly.Events.FIRE_QUEUE_),b=Blockly.Events.FIRE_QUEUE_.length=0,c;c=a[b];b++){var d=Blockly.Workspace.getById(c.workspaceId);d&&d.fireChangeListener(c)}};
Blockly.Events.filter_=function(a){a=goog.array.clone(a);for(var b=0,c;c=a[b];b++)for(var d=b+1,e;e=a[d];d++)c.type==Blockly.Events.MOVE&&e.type==Blockly.Events.MOVE&&c.blockId==e.blockId?(c.newParentId=e.newParentId,c.newInputName=e.newInputName,c.newCoordinate=e.newCoordinate,a.splice(d,1),d--):c.type==Blockly.Events.CHANGE&&e.type==Blockly.Events.CHANGE&&c.blockId==e.blockId&&c.element==e.element&&c.name==e.name&&(c.newValue=e.newValue,a.splice(d,1),d--);for(b=a.length-1;0<=b;b--)a[b].isNull()&&
a.splice(b,1);return a};Blockly.Events.disable=function(){Blockly.Events.disabled_++};Blockly.Events.enable=function(){Blockly.Events.disabled_--};Blockly.Events.isEnabled=function(){return 0==Blockly.Events.disabled_};Blockly.Events.Abstract=function(a){a.isShadow()&&console.error("Creating event for shadow block: "+a.id);this.blockId=a.id;this.workspaceId=a.workspace.id;this.group=Blockly.Events.group};Blockly.Events.Abstract.prototype.isNull=function(){return!1};
Blockly.Events.Create=function(a){Blockly.Events.Create.superClass_.constructor.call(this,a);this.xml=Blockly.Xml.blockToDomWithXY(a)};goog.inherits(Blockly.Events.Create,Blockly.Events.Abstract);Blockly.Events.Create.prototype.type=Blockly.Events.CREATE;Blockly.Events.Delete=function(a){if(a.getParent())throw"Connected blocks cannot be deleted.";Blockly.Events.Delete.superClass_.constructor.call(this,a);this.oldXml=Blockly.Xml.blockToDomWithXY(a)};goog.inherits(Blockly.Events.Delete,Blockly.Events.Abstract);
Blockly.Events.Delete.prototype.type=Blockly.Events.DELETE;Blockly.Events.Change=function(a,b,c,d,e){Blockly.Events.Change.superClass_.constructor.call(this,a);this.element=b;this.name=c;this.oldValue=d;this.newValue=e};goog.inherits(Blockly.Events.Change,Blockly.Events.Abstract);Blockly.Events.Change.prototype.type=Blockly.Events.CHANGE;Blockly.Events.Change.prototype.isNull=function(){return this.oldValue==this.newValue};
Blockly.Events.Move=function(a){Blockly.Events.Move.superClass_.constructor.call(this,a);a=this.currentLocation_();this.oldParentId=a.parentId;this.oldInputName=a.inputName;this.oldCoordinate=a.coordinate};goog.inherits(Blockly.Events.Move,Blockly.Events.Abstract);Blockly.Events.Move.prototype.type=Blockly.Events.MOVE;Blockly.Events.Move.prototype.recordNew=function(){var a=this.currentLocation_();this.newParentId=a.parentId;this.newInputName=a.inputName;this.newCoordinate=a.coordinate};
Blockly.Events.Move.prototype.currentLocation_=function(){var a=Blockly.Block.getById(this.blockId),b={},c=a.getParent();if(c){if(b.parentId=c.id,a=c.getInputWithBlock(a))b.inputName=a.name}else b.coordinate=a.getRelativeToSurfaceXY();return b};Blockly.Events.Move.prototype.isNull=function(){return this.oldParentId==this.newParentId&&this.oldInputName==this.newInputName&&goog.math.Coordinate.equals(this.oldCoordinate,this.newCoordinate)};Blockly.Msg={};goog.getMsgOrig=goog.getMsg;goog.getMsg=function(a,b){var c=goog.getMsg.blocklyMsgMap[a];c&&(a=Blockly.Msg[c]);return goog.getMsgOrig(a,b)};goog.getMsg.blocklyMsgMap={Today:"TODAY"};Blockly.FieldTextInput=function(a,b){Blockly.FieldTextInput.superClass_.constructor.call(this,a,b)};goog.inherits(Blockly.FieldTextInput,Blockly.Field);Blockly.FieldTextInput.FONTSIZE=11;Blockly.FieldTextInput.prototype.CURSOR="text";Blockly.FieldTextInput.prototype.spellcheck_=!0;Blockly.FieldTextInput.prototype.dispose=function(){Blockly.WidgetDiv.hideIfOwner(this);Blockly.FieldTextInput.superClass_.dispose.call(this)};
",-0.5 q "+-.19*Blockly.BlockSvg.TAB_WIDTH+",-5.5 0,-11"),b.push("m",.92*Blockly.BlockSvg.TAB_WIDTH+",1 V 0.5 H 1")),this.width+=Blockly.BlockSvg.TAB_WIDTH):this.RTL||(this.squareTopLeftCorner_?b.push("V",.5):b.push("V",Blockly.BlockSvg.CORNER_RADIUS));a.push("z")};Blockly.Events={};Blockly.Events.group_="";Blockly.Events.recordUndo=!0;Blockly.Events.disabled_=0;Blockly.Events.CREATE="create";Blockly.Events.DELETE="delete";Blockly.Events.CHANGE="change";Blockly.Events.MOVE="move";Blockly.Events.FIRE_QUEUE_=[];Blockly.Events.fire=function(a){Blockly.Events.isEnabled()&&(Blockly.Events.FIRE_QUEUE_.length||setTimeout(Blockly.Events.fireNow_,0),Blockly.Events.FIRE_QUEUE_.push(a))};
Blockly.Events.fireNow_=function(){for(var a=Blockly.Events.filter(Blockly.Events.FIRE_QUEUE_,!0),b=Blockly.Events.FIRE_QUEUE_.length=0,c;c=a[b];b++){var d=Blockly.Workspace.getById(c.workspaceId);d&&d.fireChangeListener(c)}};
Blockly.Events.filter=function(a,b){var c=goog.array.clone(a);b||c.reverse();for(var d=0,e;e=c[d];d++)for(var f=d+1,g;g=c[f];f++)e.type==Blockly.Events.MOVE&&g.type==Blockly.Events.MOVE&&e.blockId==g.blockId?(e.newParentId=g.newParentId,e.newInputName=g.newInputName,e.newCoordinate=g.newCoordinate,c.splice(f,1),f--):e.type==Blockly.Events.CHANGE&&g.type==Blockly.Events.CHANGE&&e.blockId==g.blockId&&e.element==g.element&&e.name==g.name&&(e.newValue=g.newValue,c.splice(f,1),f--);for(d=c.length-1;0<=
d;d--)c[d].isNull()&&c.splice(d,1);b||c.reverse();for(d=1;e=c[d];d++)e.type==Blockly.Events.CHANGE&&"mutation"==e.element&&c.unshift(c.splice(d,1)[0]);return c};Blockly.Events.disable=function(){Blockly.Events.disabled_++};Blockly.Events.enable=function(){Blockly.Events.disabled_--};Blockly.Events.isEnabled=function(){return 0==Blockly.Events.disabled_};Blockly.Events.getGroup=function(){return Blockly.Events.group_};
Blockly.Events.setGroup=function(a){Blockly.Events.group_="boolean"==typeof a?a?Blockly.genUid():"":a};Blockly.Events.Abstract=function(a){this.blockId=a.id;this.workspaceId=a.workspace.id;this.group=Blockly.Events.group_;this.recordUndo=Blockly.Events.recordUndo};Blockly.Events.Abstract.prototype.toJson=function(){var a={type:this.type,blockId:this.blockId,workspaceId:this.workspaceId};this.group&&(a.group=this.group);return a};Blockly.Events.Abstract.prototype.isNull=function(){return!1};
Blockly.Events.Create=function(a){Blockly.Events.Create.superClass_.constructor.call(this,a);this.xml=Blockly.Xml.blockToDomWithXY(a)};goog.inherits(Blockly.Events.Create,Blockly.Events.Abstract);Blockly.Events.Create.prototype.type=Blockly.Events.CREATE;Blockly.Events.Create.prototype.toJson=function(){var a=Blockly.Events.Create.superClass_.toJson.call(this);a.xml=Blockly.Xml.domToText(this.xml);return a};
Blockly.Events.Create.prototype.run=function(a){if(a){a=Blockly.Workspace.getById(this.workspaceId);var b=goog.dom.createDom("xml");b.appendChild(this.xml);Blockly.Xml.domToWorkspace(a,b)}else(a=Blockly.Block.getById(this.blockId))?a.dispose(!1,!0):console.warn("Can't delete non-existant block: "+this.blockId)};Blockly.Events.Delete=function(a){if(a.getParent())throw"Connected blocks cannot be deleted.";Blockly.Events.Delete.superClass_.constructor.call(this,a);this.oldXml=Blockly.Xml.blockToDomWithXY(a)};
goog.inherits(Blockly.Events.Delete,Blockly.Events.Abstract);Blockly.Events.Delete.prototype.type=Blockly.Events.DELETE;Blockly.Events.Delete.prototype.run=function(a){if(a)(a=Blockly.Block.getById(this.blockId))?a.dispose(!1,!0):console.warn("Can't delete non-existant block: "+this.blockId);else{a=Blockly.Workspace.getById(this.workspaceId);var b=goog.dom.createDom("xml");b.appendChild(this.oldXml);Blockly.Xml.domToWorkspace(a,b)}};
Blockly.Events.Change=function(a,b,c,d,e){Blockly.Events.Change.superClass_.constructor.call(this,a);this.element=b;this.name=c;this.oldValue=d;this.newValue=e};goog.inherits(Blockly.Events.Change,Blockly.Events.Abstract);Blockly.Events.Change.prototype.type=Blockly.Events.CHANGE;Blockly.Events.Change.prototype.toJson=function(){var a=Blockly.Events.Change.superClass_.toJson.call(this);a.element=this.element;this.name&&(a.name=this.name);a.newValue=this.newValue;return a};
Blockly.Events.Change.prototype.isNull=function(){return this.oldValue==this.newValue};
Blockly.Events.Change.prototype.run=function(a){var b=Blockly.Block.getById(this.blockId);if(b)switch(b.mutator&&b.mutator.setVisible(!1),a=a?this.newValue:this.oldValue,this.element){case "field":(b=b.getField(this.name))?b.setValue(a):console.warn("Can't set non-existant field: "+this.name);break;case "comment":b.setCommentText(a||null);break;case "collapsed":b.setCollapsed(a);break;case "disabled":b.setDisabled(a);break;case "inline":b.setInputsInline(a);break;case "mutation":var c="";b.mutationToDom&&
(c=(c=b.mutationToDom())&&Blockly.Xml.domToText(c));if(b.domToMutation){a=a||"<mutation></mutation>";var d=Blockly.Xml.textToDom("<xml>"+a+"</xml>");b.domToMutation(d.firstChild)}Blockly.Events.fire(new Blockly.Events.Change(b,"mutation",null,c,a));break;default:console.warn("Unknown change type: "+this.element)}else console.warn("Can't change non-existant block: "+this.blockId)};
Blockly.Events.Move=function(a){Blockly.Events.Move.superClass_.constructor.call(this,a);a=this.currentLocation_();this.oldParentId=a.parentId;this.oldInputName=a.inputName;this.oldCoordinate=a.coordinate};goog.inherits(Blockly.Events.Move,Blockly.Events.Abstract);Blockly.Events.Move.prototype.type=Blockly.Events.MOVE;
Blockly.Events.Move.prototype.toJson=function(){var a=Blockly.Events.Move.superClass_.toJson.call(this);this.newParentId&&(a.newParentId=this.newParentId);this.newInputName&&(a.newInputName=this.newInputName);this.newCoordinate&&(a.newCoordinate=Math.round(this.newCoordinate.x)+","+Math.round(this.newCoordinate.y));return a};Blockly.Events.Move.prototype.recordNew=function(){var a=this.currentLocation_();this.newParentId=a.parentId;this.newInputName=a.inputName;this.newCoordinate=a.coordinate};
Blockly.Events.Move.prototype.currentLocation_=function(){var a=Blockly.Block.getById(this.blockId),b={},c=a.getParent();if(c){if(b.parentId=c.id,a=c.getInputWithBlock(a))b.inputName=a.name}else b.coordinate=a.getRelativeToSurfaceXY();return b};Blockly.Events.Move.prototype.isNull=function(){return this.oldParentId==this.newParentId&&this.oldInputName==this.newInputName&&goog.math.Coordinate.equals(this.oldCoordinate,this.newCoordinate)};
Blockly.Events.Move.prototype.run=function(a){var b=Blockly.Block.getById(this.blockId);if(b){var c=a?this.newParentId:this.oldParentId,d=a?this.newInputName:this.oldInputName;a=a?this.newCoordinate:this.oldCoordinate;var e=null;if(c&&(e=Blockly.Block.getById(c),!e)){console.warn("Can't connect to non-existant block: "+c);return}b.getParent()&&b.unplug();if(a)d=b.getRelativeToSurfaceXY(),b.moveBy(a.x-d.x,a.y-d.y);else{var b=b.outputConnection||b.previousConnection,f;if(d){if(c=e.getInput(d))f=c.connection}else b.type==
Blockly.PREVIOUS_STATEMENT&&(f=e.nextConnection);f?b.connect(f):console.warn("Can't connect to non-existant input: "+d)}}else console.warn("Can't move non-existant block: "+this.blockId)};Blockly.Msg={};goog.getMsgOrig=goog.getMsg;goog.getMsg=function(a,b){var c=goog.getMsg.blocklyMsgMap[a];c&&(a=Blockly.Msg[c]);return goog.getMsgOrig(a,b)};goog.getMsg.blocklyMsgMap={Today:"TODAY"};Blockly.FieldTextInput=function(a,b){Blockly.FieldTextInput.superClass_.constructor.call(this,a,b)};goog.inherits(Blockly.FieldTextInput,Blockly.Field);Blockly.FieldTextInput.FONTSIZE=11;Blockly.FieldTextInput.prototype.CURSOR="text";Blockly.FieldTextInput.prototype.spellcheck_=!0;Blockly.FieldTextInput.prototype.dispose=function(){Blockly.WidgetDiv.hideIfOwner(this);Blockly.FieldTextInput.superClass_.dispose.call(this)};
Blockly.FieldTextInput.prototype.setValue=function(a){if(null!==a){if(this.sourceBlock_&&this.validator_){var b=this.validator_(a);null!==b&&void 0!==b&&(a=b)}Blockly.Field.prototype.setValue.call(this,a)}};Blockly.FieldTextInput.prototype.setSpellcheck=function(a){this.spellcheck_=a};
Blockly.FieldTextInput.prototype.showEditor_=function(a){var b=this.sourceBlock_.workspace;a=a||!1;if(!a&&(goog.userAgent.MOBILE||goog.userAgent.ANDROID||goog.userAgent.IPAD))b=window.prompt(Blockly.Msg.CHANGE_VALUE_TITLE,this.text_),this.sourceBlock_&&this.validator_&&(a=this.validator_(b),void 0!==a&&(b=a)),this.setValue(b);else{Blockly.WidgetDiv.show(this,this.sourceBlock_.RTL,this.widgetDispose_());var c=Blockly.WidgetDiv.DIV,d=goog.dom.createDom("input","blocklyHtmlInput");d.setAttribute("spellcheck",
this.spellcheck_);var e=Blockly.FieldTextInput.FONTSIZE*b.scale+"pt";c.style.fontSize=e;d.style.fontSize=e;Blockly.FieldTextInput.htmlInput_=d;c.appendChild(d);d.value=d.defaultValue=this.text_;d.oldValue_=null;this.validate_();this.resizeEditor_();a||(d.focus(),d.select());d.onKeyDownWrapper_=Blockly.bindEvent_(d,"keydown",this,this.onHtmlInputKeyDown_);d.onKeyUpWrapper_=Blockly.bindEvent_(d,"keyup",this,this.onHtmlInputChange_);d.onKeyPressWrapper_=Blockly.bindEvent_(d,"keypress",this,this.onHtmlInputChange_);
d.onWorkspaceChangeWrapper_=this.resizeEditor_.bind(this);b.addChangeListener(d.onWorkspaceChangeWrapper_)}};Blockly.FieldTextInput.prototype.onHtmlInputKeyDown_=function(a){var b=Blockly.FieldTextInput.htmlInput_;13==a.keyCode?Blockly.WidgetDiv.hide():27==a.keyCode?(b.value=b.defaultValue,Blockly.WidgetDiv.hide()):9==a.keyCode&&(Blockly.WidgetDiv.hide(),this.sourceBlock_.tab(this,!a.shiftKey),a.preventDefault())};
Blockly.FieldTextInput.prototype.onHtmlInputChange_=function(a){a=Blockly.FieldTextInput.htmlInput_;var b=a.value;b!==a.oldValue_?(this.sourceBlock_.setShadow(!1),a.oldValue_=b,this.setValue(b),this.validate_()):goog.userAgent.WEBKIT&&this.sourceBlock_.render();this.resizeEditor_()};
Blockly.FieldTextInput.prototype.onHtmlInputChange_=function(a){a=Blockly.FieldTextInput.htmlInput_;var b=a.value;b!==a.oldValue_?(a.oldValue_=b,this.setValue(b),this.validate_()):goog.userAgent.WEBKIT&&this.sourceBlock_.render();this.resizeEditor_()};
Blockly.FieldTextInput.prototype.validate_=function(){var a=!0;goog.asserts.assertObject(Blockly.FieldTextInput.htmlInput_);var b=Blockly.FieldTextInput.htmlInput_;this.sourceBlock_&&this.validator_&&(a=this.validator_(b.value));null===a?Blockly.addClass_(b,"blocklyInvalidInput"):Blockly.removeClass_(b,"blocklyInvalidInput")};
Blockly.FieldTextInput.prototype.resizeEditor_=function(){var a=Blockly.WidgetDiv.DIV,b=this.fieldGroup_.getBBox();a.style.width=b.width*this.sourceBlock_.workspace.scale+"px";a.style.height=b.height*this.sourceBlock_.workspace.scale+"px";b=this.getAbsoluteXY_();if(this.sourceBlock_.RTL){var c=this.getScaledBBox_();b.x+=c.width;b.x-=a.offsetWidth}b.y+=1;goog.userAgent.GECKO&&Blockly.WidgetDiv.DIV.style.top&&(--b.x,--b.y);goog.userAgent.WEBKIT&&(b.y-=3);a.style.left=b.x+"px";a.style.top=b.y+"px"};
Blockly.FieldTextInput.prototype.widgetDispose_=function(){var a=this;return function(){var b=Blockly.FieldTextInput.htmlInput_,c=b.value;if(a.sourceBlock_&&a.validator_){var d=a.validator_(c);null===d?c=b.defaultValue:void 0!==d&&(c=d)}a.setValue(c);a.sourceBlock_.rendered&&a.sourceBlock_.render();Blockly.unbindEvent_(b.onKeyDownWrapper_);Blockly.unbindEvent_(b.onKeyUpWrapper_);Blockly.unbindEvent_(b.onKeyPressWrapper_);a.sourceBlock_.workspace.removeChangeListener(b.onWorkspaceChangeWrapper_);Blockly.FieldTextInput.htmlInput_=
@@ -1182,32 +1206,32 @@ Blockly.FieldAngle.prototype.showEditor_=function(){Blockly.FieldAngle.superClas
{cx:Blockly.FieldAngle.HALF,cy:Blockly.FieldAngle.HALF,r:Blockly.FieldAngle.RADIUS,"class":"blocklyAngleCircle"},a);this.gauge_=Blockly.createSvgElement("path",{"class":"blocklyAngleGauge"},a);this.line_=Blockly.createSvgElement("line",{x1:Blockly.FieldAngle.HALF,y1:Blockly.FieldAngle.HALF,"class":"blocklyAngleLine"},a);for(var c=0;360>c;c+=15)Blockly.createSvgElement("line",{x1:Blockly.FieldAngle.HALF+Blockly.FieldAngle.RADIUS,y1:Blockly.FieldAngle.HALF,x2:Blockly.FieldAngle.HALF+Blockly.FieldAngle.RADIUS-
(0==c%45?10:5),y2:Blockly.FieldAngle.HALF,"class":"blocklyAngleMarks",transform:"rotate("+c+","+Blockly.FieldAngle.HALF+","+Blockly.FieldAngle.HALF+")"},a);a.style.marginLeft=15-Blockly.FieldAngle.RADIUS+"px";this.clickWrapper_=Blockly.bindEvent_(a,"click",this,Blockly.WidgetDiv.hide);this.moveWrapper1_=Blockly.bindEvent_(b,"mousemove",this,this.onMouseMove);this.moveWrapper2_=Blockly.bindEvent_(this.gauge_,"mousemove",this,this.onMouseMove);this.updateGraph_()}};
Blockly.FieldAngle.prototype.onMouseMove=function(a){var b=this.gauge_.ownerSVGElement.getBoundingClientRect(),c=a.clientX-b.left-Blockly.FieldAngle.HALF;a=a.clientY-b.top-Blockly.FieldAngle.HALF;b=Math.atan(-a/c);isNaN(b)||(b=goog.math.toDegrees(b),0>c?b+=180:0<a&&(b+=360),b=Blockly.FieldAngle.CLOCKWISE?Blockly.FieldAngle.OFFSET+360-b:b-Blockly.FieldAngle.OFFSET,Blockly.FieldAngle.ROUND&&(b=Math.round(b/Blockly.FieldAngle.ROUND)*Blockly.FieldAngle.ROUND),b=Blockly.FieldAngle.angleValidator(b),Blockly.FieldTextInput.htmlInput_.value=
b,this.sourceBlock_.setShadow(!1),this.setValue(b),this.validate_(),this.resizeEditor_())};Blockly.FieldAngle.prototype.setText=function(a){Blockly.FieldAngle.superClass_.setText.call(this,a);this.textElement_&&(this.updateGraph_(),this.sourceBlock_.RTL?this.textElement_.insertBefore(this.symbol_,this.textElement_.firstChild):this.textElement_.appendChild(this.symbol_),this.size_.width=0)};
b,this.setValue(b),this.validate_(),this.resizeEditor_())};Blockly.FieldAngle.prototype.setText=function(a){Blockly.FieldAngle.superClass_.setText.call(this,a);this.textElement_&&(this.updateGraph_(),this.sourceBlock_.RTL?this.textElement_.insertBefore(this.symbol_,this.textElement_.firstChild):this.textElement_.appendChild(this.symbol_),this.size_.width=0)};
Blockly.FieldAngle.prototype.updateGraph_=function(){if(this.gauge_){var a=Number(this.getText())+Blockly.FieldAngle.OFFSET,b=goog.math.toRadians(a),a=["M ",Blockly.FieldAngle.HALF,",",Blockly.FieldAngle.HALF],c=Blockly.FieldAngle.HALF,d=Blockly.FieldAngle.HALF;if(!isNaN(b)){var e=goog.math.toRadians(Blockly.FieldAngle.OFFSET),f=Math.cos(e)*Blockly.FieldAngle.RADIUS,g=Math.sin(e)*-Blockly.FieldAngle.RADIUS;Blockly.FieldAngle.CLOCKWISE&&(b=2*e-b);c+=Math.cos(b)*Blockly.FieldAngle.RADIUS;d-=Math.sin(b)*
Blockly.FieldAngle.RADIUS;b=Math.abs(Math.floor((b-e)/Math.PI)%2);Blockly.FieldAngle.CLOCKWISE&&(b=1-b);a.push(" l ",f,",",g," A ",Blockly.FieldAngle.RADIUS,",",Blockly.FieldAngle.RADIUS," 0 ",b," ",Number(Blockly.FieldAngle.CLOCKWISE)," ",c,",",d," z")}this.gauge_.setAttribute("d",a.join(""));this.line_.setAttribute("x2",c);this.line_.setAttribute("y2",d)}};
Blockly.FieldAngle.angleValidator=function(a){a=Blockly.FieldTextInput.numberValidator(a);null!==a&&(a%=360,0>a&&(a+=360),a>Blockly.FieldAngle.WRAP&&(a-=360),a=String(a));return a};Blockly.FieldCheckbox=function(a,b){Blockly.FieldCheckbox.superClass_.constructor.call(this,"",b);this.setValue(a)};goog.inherits(Blockly.FieldCheckbox,Blockly.Field);Blockly.FieldCheckbox.prototype.CURSOR="default";
Blockly.FieldCheckbox.prototype.init=function(a){this.sourceBlock_||(Blockly.FieldCheckbox.superClass_.init.call(this,a),this.checkElement_=Blockly.createSvgElement("text",{"class":"blocklyText",x:-3,y:14},this.fieldGroup_),a=document.createTextNode("\u2713"),this.checkElement_.appendChild(a),this.checkElement_.style.display=this.state_?"block":"none")};Blockly.FieldCheckbox.prototype.getValue=function(){return String(this.state_).toUpperCase()};
Blockly.FieldCheckbox.prototype.setValue=function(a){a="TRUE"==a;this.state_!==a&&(this.state_=a,this.checkElement_&&(this.checkElement_.style.display=a?"block":"none"))};Blockly.FieldCheckbox.prototype.showEditor_=function(){var a=!this.state_;if(this.sourceBlock_&&this.validator_){var b=this.validator_(a);void 0!==b&&(a=b)}null!==a&&(this.sourceBlock_.setShadow(!1),this.setValue(String(a).toUpperCase()))};Blockly.FieldColour=function(a,b){Blockly.FieldColour.superClass_.constructor.call(this,a,b);this.setText(Blockly.Field.NBSP+Blockly.Field.NBSP+Blockly.Field.NBSP)};goog.inherits(Blockly.FieldColour,Blockly.Field);Blockly.FieldColour.prototype.colours_=null;Blockly.FieldColour.prototype.columns_=0;Blockly.FieldColour.prototype.init=function(a){Blockly.FieldColour.superClass_.init.call(this,a);this.borderRect_.style.fillOpacity=1;this.setValue(this.getValue())};
Blockly.FieldCheckbox.prototype.setValue=function(a){a="TRUE"==a;this.state_!==a&&(this.sourceBlock_&&Blockly.Events.isEnabled()&&Blockly.Events.fire(new Blockly.Events.Change(this.sourceBlock_,"field",this.name,this.state_,a)),this.state_=a,this.checkElement_&&(this.checkElement_.style.display=a?"block":"none"))};Blockly.FieldCheckbox.prototype.showEditor_=function(){var a=!this.state_;if(this.sourceBlock_&&this.validator_){var b=this.validator_(a);void 0!==b&&(a=b)}null!==a&&this.setValue(String(a).toUpperCase())};Blockly.FieldColour=function(a,b){Blockly.FieldColour.superClass_.constructor.call(this,a,b);this.setText(Blockly.Field.NBSP+Blockly.Field.NBSP+Blockly.Field.NBSP)};goog.inherits(Blockly.FieldColour,Blockly.Field);Blockly.FieldColour.prototype.colours_=null;Blockly.FieldColour.prototype.columns_=0;Blockly.FieldColour.prototype.init=function(a){Blockly.FieldColour.superClass_.init.call(this,a);this.borderRect_.style.fillOpacity=1;this.setValue(this.getValue())};
Blockly.FieldColour.prototype.CURSOR="default";Blockly.FieldColour.prototype.dispose=function(){Blockly.WidgetDiv.hideIfOwner(this);Blockly.FieldColour.superClass_.dispose.call(this)};Blockly.FieldColour.prototype.getValue=function(){return this.colour_};
Blockly.FieldColour.prototype.setValue=function(a){this.sourceBlock_&&Blockly.Events.isEnabled()&&this.colour_!=a&&Blockly.Events.fire(new Blockly.Events.Change(this.sourceBlock_,"field",this.name,this.colour_,a));this.colour_=a;this.borderRect_&&(this.borderRect_.style.fill=a)};Blockly.FieldColour.prototype.getText=function(){var a=this.colour_,b=a.match(/^#(.)\1(.)\2(.)\3$/);b&&(a="#"+b[1]+b[2]+b[3]);return a};Blockly.FieldColour.COLOURS=goog.ui.ColorPicker.SIMPLE_GRID_COLORS;
Blockly.FieldColour.COLUMNS=7;Blockly.FieldColour.prototype.setColours=function(a){this.colours_=a;return this};Blockly.FieldColour.prototype.setColumns=function(a){this.columns_=a;return this};
Blockly.FieldColour.prototype.showEditor_=function(){Blockly.WidgetDiv.show(this,this.sourceBlock_.RTL,Blockly.FieldColour.widgetDispose_);var a=new goog.ui.ColorPicker;a.setSize(this.columns_||Blockly.FieldColour.COLUMNS);a.setColors(this.colours_||Blockly.FieldColour.COLOURS);var b=goog.dom.getViewportSize(),c=goog.style.getViewportPageOffset(document),d=this.getAbsoluteXY_(),e=this.getScaledBBox_();a.render(Blockly.WidgetDiv.DIV);a.setSelectedColor(this.getValue());var f=goog.style.getSize(a.getElement());
d.y=d.y+f.height+e.height>=b.height+c.y?d.y-(f.height-1):d.y+(e.height-1);this.sourceBlock_.RTL?(d.x+=e.width,d.x-=f.width,d.x<c.x&&(d.x=c.x)):d.x>b.width+c.x-f.width&&(d.x=b.width+c.x-f.width);Blockly.WidgetDiv.position(d.x,d.y,b,c,this.sourceBlock_.RTL);var g=this;Blockly.FieldColour.changeEventKey_=goog.events.listen(a,goog.ui.ColorPicker.EventType.CHANGE,function(a){a=a.target.getSelectedColor()||"#000000";Blockly.WidgetDiv.hide();if(g.sourceBlock_&&g.validator_){var b=g.validator_(a);void 0!==
b&&(a=b)}null!==a&&(g.sourceBlock_.setShadow(!1),g.setValue(a))})};Blockly.FieldColour.widgetDispose_=function(){Blockly.FieldColour.changeEventKey_&&goog.events.unlistenByKey(Blockly.FieldColour.changeEventKey_)};Blockly.FieldDropdown=function(a,b){this.menuGenerator_=a;this.trimOptions_();var c=this.getOptions_()[0];Blockly.FieldDropdown.superClass_.constructor.call(this,c[1],b)};goog.inherits(Blockly.FieldDropdown,Blockly.Field);Blockly.FieldDropdown.CHECKMARK_OVERHANG=25;Blockly.FieldDropdown.ARROW_CHAR=goog.userAgent.ANDROID?"\u25bc":"\u25be";Blockly.FieldDropdown.prototype.CURSOR="default";
b&&(a=b)}null!==a&&g.setValue(a)})};Blockly.FieldColour.widgetDispose_=function(){Blockly.FieldColour.changeEventKey_&&goog.events.unlistenByKey(Blockly.FieldColour.changeEventKey_)};Blockly.FieldDropdown=function(a,b){this.menuGenerator_=a;this.trimOptions_();var c=this.getOptions_()[0];Blockly.FieldDropdown.superClass_.constructor.call(this,c[1],b)};goog.inherits(Blockly.FieldDropdown,Blockly.Field);Blockly.FieldDropdown.CHECKMARK_OVERHANG=25;Blockly.FieldDropdown.ARROW_CHAR=goog.userAgent.ANDROID?"\u25bc":"\u25be";Blockly.FieldDropdown.prototype.CURSOR="default";
Blockly.FieldDropdown.prototype.init=function(a){this.sourceBlock_||(this.arrow_=Blockly.createSvgElement("tspan",{},null),this.arrow_.appendChild(document.createTextNode(a.RTL?Blockly.FieldDropdown.ARROW_CHAR+" ":" "+Blockly.FieldDropdown.ARROW_CHAR)),Blockly.FieldDropdown.superClass_.init.call(this,a),a=this.text_,this.text_=null,this.setText(a))};
Blockly.FieldDropdown.prototype.showEditor_=function(){Blockly.WidgetDiv.show(this,this.sourceBlock_.RTL,null);var a=this,b=new goog.ui.Menu;b.setRightToLeft(this.sourceBlock_.RTL);for(var c=this.getOptions_(),d=0;d<c.length;d++){var e=c[d][1],f=new goog.ui.MenuItem(c[d][0]);f.setRightToLeft(this.sourceBlock_.RTL);f.setValue(e);f.setCheckable(!0);b.addChild(f,!0);f.setChecked(e==this.value_)}goog.events.listen(b,goog.ui.Component.EventType.ACTION,function(b){if(b=b.target){b=b.getValue();if(a.sourceBlock_&&
a.validator_){var c=a.validator_(b);void 0!==c&&(b=c)}null!==b&&(a.sourceBlock_.setShadow(!1),a.setValue(b))}Blockly.WidgetDiv.hideIfOwner(a)});b.getHandler().listen(b.getElement(),goog.events.EventType.TOUCHSTART,function(a){this.getOwnerControl(a.target).handleMouseDown(a)});b.getHandler().listen(b.getElement(),goog.events.EventType.TOUCHEND,function(a){this.getOwnerControl(a.target).performActionInternal(a)});c=goog.dom.getViewportSize();d=goog.style.getViewportPageOffset(document);e=this.getAbsoluteXY_();
f=this.getScaledBBox_();b.render(Blockly.WidgetDiv.DIV);var g=b.getElement();Blockly.addClass_(g,"blocklyDropdownMenu");var h=goog.style.getSize(g);h.height=g.scrollHeight;e.y=e.y+h.height+f.height>=c.height+d.y?e.y-(h.height+2):e.y+f.height;this.sourceBlock_.RTL?(e.x+=f.width,e.x+=Blockly.FieldDropdown.CHECKMARK_OVERHANG,e.x<d.x+h.width&&(e.x=d.x+h.width)):(e.x-=Blockly.FieldDropdown.CHECKMARK_OVERHANG,e.x>c.width+d.x-h.width&&(e.x=c.width+d.x-h.width));Blockly.WidgetDiv.position(e.x,e.y,c,d,this.sourceBlock_.RTL);
b.setAllowAutoFocus(!0);g.focus()};
Blockly.FieldDropdown.prototype.trimOptions_=function(){this.suffixField=this.prefixField=null;var a=this.menuGenerator_;if(goog.isArray(a)&&!(2>a.length)){var b=a.map(function(a){return a[0]}),c=Blockly.shortestStringLength(b),d=Blockly.commonWordPrefix(b,c),e=Blockly.commonWordSuffix(b,c);if((d||e)&&!(c<=d+e)){d&&(this.prefixField=b[0].substring(0,d-1));e&&(this.suffixField=b[0].substr(1-e));b=[];for(c=0;c<a.length;c++){var f=a[c][0],g=a[c][1],f=f.substring(d,f.length-e);b[c]=[f,g]}this.menuGenerator_=
b}}};Blockly.FieldDropdown.prototype.getOptions_=function(){return goog.isFunction(this.menuGenerator_)?this.menuGenerator_.call(this):this.menuGenerator_};Blockly.FieldDropdown.prototype.getValue=function(){return this.value_};
a.validator_){var c=a.validator_(b);void 0!==c&&(b=c)}null!==b&&a.setValue(b)}Blockly.WidgetDiv.hideIfOwner(a)});b.getHandler().listen(b.getElement(),goog.events.EventType.TOUCHSTART,function(a){this.getOwnerControl(a.target).handleMouseDown(a)});b.getHandler().listen(b.getElement(),goog.events.EventType.TOUCHEND,function(a){this.getOwnerControl(a.target).performActionInternal(a)});c=goog.dom.getViewportSize();d=goog.style.getViewportPageOffset(document);e=this.getAbsoluteXY_();f=this.getScaledBBox_();
b.render(Blockly.WidgetDiv.DIV);var g=b.getElement();Blockly.addClass_(g,"blocklyDropdownMenu");var h=goog.style.getSize(g);h.height=g.scrollHeight;e.y=e.y+h.height+f.height>=c.height+d.y?e.y-(h.height+2):e.y+f.height;this.sourceBlock_.RTL?(e.x+=f.width,e.x+=Blockly.FieldDropdown.CHECKMARK_OVERHANG,e.x<d.x+h.width&&(e.x=d.x+h.width)):(e.x-=Blockly.FieldDropdown.CHECKMARK_OVERHANG,e.x>c.width+d.x-h.width&&(e.x=c.width+d.x-h.width));Blockly.WidgetDiv.position(e.x,e.y,c,d,this.sourceBlock_.RTL);b.setAllowAutoFocus(!0);
g.focus()};
Blockly.FieldDropdown.prototype.trimOptions_=function(){this.suffixField=this.prefixField=null;var a=this.menuGenerator_;if(goog.isArray(a)&&!(2>a.length)){var b=a.map(function(a){return a[0]}),c=Blockly.shortestStringLength(b),d=Blockly.commonWordPrefix(b,c),e=Blockly.commonWordSuffix(b,c);if((d||e)&&!(c<=d+e)){d&&(this.prefixField=b[0].substring(0,d-1));e&&(this.suffixField=b[0].substr(1-e));b=[];for(c=0;c<a.length;c++){var f=a[c][0],g=a[c][1],f=f.substring(d,f.length-e);b[c]=[f,g]}this.menuGenerator_=b}}};
Blockly.FieldDropdown.prototype.getOptions_=function(){return goog.isFunction(this.menuGenerator_)?this.menuGenerator_.call(this):this.menuGenerator_};Blockly.FieldDropdown.prototype.getValue=function(){return this.value_};
Blockly.FieldDropdown.prototype.setValue=function(a){if(null!==a&&a!==this.value_){this.sourceBlock_&&Blockly.Events.isEnabled()&&Blockly.Events.fire(new Blockly.Events.Change(this.sourceBlock_,"field",this.name,this.value_,a));this.value_=a;for(var b=this.getOptions_(),c=0;c<b.length;c++)if(b[c][1]==a){this.setText(b[c][0]);return}this.setText(a)}};
Blockly.FieldDropdown.prototype.setText=function(a){this.sourceBlock_&&this.arrow_&&(this.arrow_.style.fill=this.sourceBlock_.getColour());null!==a&&a!==this.text_&&(this.text_=a,this.updateTextNode_(),this.textElement_&&(this.sourceBlock_.RTL?this.textElement_.insertBefore(this.arrow_,this.textElement_.firstChild):this.textElement_.appendChild(this.arrow_)),this.sourceBlock_&&this.sourceBlock_.rendered&&(this.sourceBlock_.render(),this.sourceBlock_.bumpNeighbours_()))};
Blockly.FieldDropdown.prototype.dispose=function(){Blockly.WidgetDiv.hideIfOwner(this);Blockly.FieldDropdown.superClass_.dispose.call(this)};Blockly.FieldImage=function(a,b,c,d){this.sourceBlock_=null;this.height_=Number(c);this.width_=Number(b);this.size_=new goog.math.Size(this.width_,this.height_+2*Blockly.BlockSvg.INLINE_PADDING_Y);this.text_=d||"";this.setValue(a)};goog.inherits(Blockly.FieldImage,Blockly.Field);Blockly.FieldImage.prototype.rectElement_=null;Blockly.FieldImage.prototype.EDITABLE=!1;
Blockly.FieldImage.prototype.init=function(a){this.sourceBlock_||(this.sourceBlock_=a,this.fieldGroup_=Blockly.createSvgElement("g",{},null),this.visible_||(this.fieldGroup_.style.display="none"),this.imageElement_=Blockly.createSvgElement("image",{height:this.height_+"px",width:this.width_+"px"},this.fieldGroup_),this.setValue(this.src_),goog.userAgent.GECKO&&(this.rectElement_=Blockly.createSvgElement("rect",{height:this.height_+"px",width:this.width_+"px","fill-opacity":0},this.fieldGroup_)),a.getSvgRoot().appendChild(this.fieldGroup_),
a=this.rectElement_||this.imageElement_,a.tooltip=this.sourceBlock_,Blockly.Tooltip.bindMouseEvents(a))};Blockly.FieldImage.prototype.dispose=function(){goog.dom.removeNode(this.fieldGroup_);this.rectElement_=this.imageElement_=this.fieldGroup_=null};Blockly.FieldImage.prototype.setTooltip=function(a){(this.rectElement_||this.imageElement_).tooltip=a};Blockly.FieldImage.prototype.getValue=function(){return this.src_};
Blockly.FieldImage.prototype.setValue=function(a){null!==a&&(this.src_=a,this.imageElement_&&this.imageElement_.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",goog.isString(a)?a:""))};Blockly.FieldImage.prototype.setText=function(a){null!==a&&(this.text_=a)};Blockly.FieldImage.prototype.render_=function(){};Blockly.Variables={};Blockly.Variables.NAME_TYPE="VARIABLE";Blockly.Variables.allVariables=function(a){var b;if(a.getDescendants)b=a.getDescendants();else if(a.getAllBlocks)b=a.getAllBlocks();else throw"Not Block or Workspace: "+a;a=Object.create(null);for(var c=0;c<b.length;c++)if(b[c].getVars)for(var d=b[c].getVars(),e=0;e<d.length;e++){var f=d[e];f&&(a[f.toLowerCase()]=f)}b=[];for(var g in a)b.push(a[g]);return b};
Blockly.Variables.renameVariable=function(a,b,c){c=c.getAllBlocks();for(var d=0;d<c.length;d++)c[d].renameVar&&c[d].renameVar(a,b)};
Blockly.FieldImage.prototype.setValue=function(a){null!==a&&(this.src_=a,this.imageElement_&&this.imageElement_.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",goog.isString(a)?a:""))};Blockly.FieldImage.prototype.setText=function(a){null!==a&&(this.text_=a)};Blockly.FieldImage.prototype.render_=function(){};Blockly.Variables={};Blockly.Variables.NAME_TYPE="VARIABLE";Blockly.Variables.allVariables=function(a){var b;if(a.getDescendants)b=a.getDescendants();else if(a.getAllBlocks)b=a.getAllBlocks();else throw"Not Block or Workspace: "+a;a=Object.create(null);for(var c=0;c<b.length;c++)for(var d=b[c].getVars(),e=0;e<d.length;e++){var f=d[e];f&&(a[f.toLowerCase()]=f)}b=[];for(var g in a)b.push(a[g]);return b};
Blockly.Variables.renameVariable=function(a,b,c){Blockly.Events.setGroup(!0);c=c.getAllBlocks();for(var d=0;d<c.length;d++)c[d].renameVar(a,b);Blockly.Events.setGroup(!1)};
Blockly.Variables.flyoutCategory=function(a){a=Blockly.Variables.allVariables(a);a.sort(goog.string.caseInsensitiveCompare);goog.array.remove(a,Blockly.Msg.VARIABLES_DEFAULT_NAME);a.unshift(Blockly.Msg.VARIABLES_DEFAULT_NAME);for(var b=[],c=0;c<a.length;c++){if(Blockly.Blocks.variables_set){var d=goog.dom.createDom("block");d.setAttribute("type","variables_set");Blockly.Blocks.variables_get&&d.setAttribute("gap",8);var e=goog.dom.createDom("field",null,a[c]);e.setAttribute("name","VAR");d.appendChild(e);
b.push(d)}Blockly.Blocks.variables_get&&(d=goog.dom.createDom("block"),d.setAttribute("type","variables_get"),Blockly.Blocks.variables_set&&d.setAttribute("gap",24),e=goog.dom.createDom("field",null,a[c]),e.setAttribute("name","VAR"),d.appendChild(e),b.push(d))}return b};
Blockly.Variables.generateUniqueName=function(a){a=Blockly.Variables.allVariables(a);var b="";if(a.length)for(var c=1,d=0,e="ijkmnopqrstuvwxyzabcdefgh".charAt(d);!b;){for(var f=!1,g=0;g<a.length;g++)if(a[g].toLowerCase()==e){f=!0;break}f?(d++,25==d&&(d=0,c++),e="ijkmnopqrstuvwxyzabcdefgh".charAt(d),1<c&&(e+=c)):b=e}else b="i";return b};Blockly.FieldVariable=function(a,b){Blockly.FieldVariable.superClass_.constructor.call(this,Blockly.FieldVariable.dropdownCreate,b);this.setValue(a||"")};goog.inherits(Blockly.FieldVariable,Blockly.FieldDropdown);Blockly.FieldVariable.prototype.setValidator=function(a){Blockly.FieldVariable.superClass_.setValidator.call(this,a?function(b){var c=a.call(this,b);if(null===c)var d=c;else void 0===c&&(c=b),d=Blockly.FieldVariable.dropdownChange.call(this,c),void 0===d&&(d=c);return d===b?void 0:d}:Blockly.FieldVariable.dropdownChange)};
@@ -1218,8 +1242,9 @@ Blockly.FieldVariable.dropdownChange=function(a){function b(a,b){Blockly.hideCha
""))?(Blockly.Variables.renameVariable(a,a,c),a):null};Blockly.Generator=function(a){this.name_=a;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(a){a||(console.warn("No workspace specified in workspaceToCode call. Guessing."),a=Blockly.getMainWorkspace());var b=[];this.init(a);a=a.getTopBlocks(!0);for(var c=0,d;d=a[c];c++){var e=this.blockToCode(d);goog.isArray(e)&&(e=e[0]);e&&(d.outputConnection&&this.scrubNakedValue&&(e=this.scrubNakedValue(e)),b.push(e))}b=b.join("\n");b=this.finish(b);b=b.replace(/^\s+\n/,"");b=b.replace(/\n\s+$/,"\n");return b=b.replace(/[ \t]+\n/g,"\n")};
Blockly.Generator.prototype.prefixLines=function(a,b){return b+a.replace(/\n(.)/g,"\n"+b+"$1")};Blockly.Generator.prototype.allNestedComments=function(a){var b=[];a=a.getDescendants();for(var c=0;c<a.length;c++){var d=a[c].getCommentText();d&&b.push(d)}b.length&&b.push("");return b.join("\n")};
Blockly.Generator.prototype.blockToCode=function(a){if(!a)return"";if(a.disabled)return this.blockToCode(a.getNextBlock());var b=this[a.type];goog.asserts.assertFunction(b,'Language "%s" does not know how to generate code for block type "%s".',this.name_,a.type);b=b.call(a,a);if(goog.isArray(b))return[this.scrub_(a,b[0]),b[1]];if(goog.isString(b))return this.STATEMENT_PREFIX&&(b=this.STATEMENT_PREFIX.replace(/%1/g,"'"+a.id+"'")+b),this.scrub_(a,b);if(null===b)return"";goog.asserts.fail("Invalid code generated: %s",
b)};Blockly.Generator.prototype.valueToCode=function(a,b,c){isNaN(c)&&goog.asserts.fail('Expecting valid order from block "%s".',a.type);a=a.getInputTargetBlock(b);if(!a)return"";var d=this.blockToCode(a);if(""===d)return"";goog.asserts.assertArray(d,'Expecting tuple from value block "%s".',a.type);b=d[0];d=d[1];isNaN(d)&&goog.asserts.fail('Expecting valid order from value block "%s".',a.type);b&&c<=d&&(c!=d||0!=c&&99!=c)&&(b="("+b+")");return b};
Blockly.Generator.prototype.blockToCode=function(a){if(!a)return"";if(a.disabled)return this.blockToCode(a.getNextBlock());var b=this[a.type];goog.asserts.assertFunction(b,'Language "%s" does not know how to generate code for block type "%s".',this.name_,a.type);b=b.call(a,a);if(goog.isArray(b))return goog.asserts.assert(a.outputConnection,'Expecting string from statement block "%s".',a.type),[this.scrub_(a,b[0]),b[1]];if(goog.isString(b))return this.STATEMENT_PREFIX&&(b=this.STATEMENT_PREFIX.replace(/%1/g,
"'"+a.id+"'")+b),this.scrub_(a,b);if(null===b)return"";goog.asserts.fail("Invalid code generated: %s",b)};
Blockly.Generator.prototype.valueToCode=function(a,b,c){isNaN(c)&&goog.asserts.fail('Expecting valid order from block "%s".',a.type);a=a.getInputTargetBlock(b);if(!a)return"";var d=this.blockToCode(a);if(""===d)return"";goog.asserts.assertArray(d,'Expecting tuple from value block "%s".',a.type);b=d[0];d=d[1];isNaN(d)&&goog.asserts.fail('Expecting valid order from value block "%s".',a.type);b&&c<=d&&(c!=d||0!=c&&99!=c)&&(b="("+b+")");return b};
Blockly.Generator.prototype.statementToCode=function(a,b){var c=a.getInputTargetBlock(b),d=this.blockToCode(c);goog.asserts.assertString(d,'Expecting code from statement block "%s".',c&&c.type);d&&(d=this.prefixLines(d,this.INDENT));return d};Blockly.Generator.prototype.addLoopTrap=function(a,b){this.INFINITE_LOOP_TRAP&&(a=this.INFINITE_LOOP_TRAP.replace(/%1/g,"'"+b+"'")+a);this.STATEMENT_PREFIX&&(a+=this.prefixLines(this.STATEMENT_PREFIX.replace(/%1/g,"'"+b+"'"),this.INDENT));return a};
Blockly.Generator.prototype.INDENT=" ";Blockly.Generator.prototype.RESERVED_WORDS_="";Blockly.Generator.prototype.addReservedWords=function(a){this.RESERVED_WORDS_+=a+","};Blockly.Generator.prototype.FUNCTION_NAME_PLACEHOLDER_="{leCUI8hutHZI4480Dc}";Blockly.Generator.prototype.provideFunction_=function(a,b){if(!this.definitions_[a]){var c=this.variableDB_.getDistinctName(a,this.NAME_TYPE);this.functionNames_[a]=c;this.definitions_[a]=b.join("\n").replace(this.FUNCTION_NAME_PLACEHOLDER_REGEXP_,c)}return this.functionNames_[a]};Blockly.Names=function(a,b){this.variablePrefix_=b||"";this.reservedDict_=Object.create(null);if(a)for(var c=a.split(","),d=0;d<c.length;d++)this.reservedDict_[c[d]]=!0;this.reset()};Blockly.Names.prototype.reset=function(){this.db_=Object.create(null);this.dbReverse_=Object.create(null)};
Blockly.Names.prototype.getName=function(a,b){var c=a.toLowerCase()+"_"+b,d=b==Blockly.Variables.NAME_TYPE?this.variablePrefix_:"";if(c in this.db_)return d+this.db_[c];var e=this.getDistinctName(a,b);this.db_[c]=e.substr(d.length);return e};Blockly.Names.prototype.getDistinctName=function(a,b){for(var c=this.safeName_(a),d="";this.dbReverse_[c+d]||c+d in this.reservedDict_;)d=d?d+1:2;c+=d;this.dbReverse_[c]=!0;return(b==Blockly.Variables.NAME_TYPE?this.variablePrefix_:"")+c};
@@ -1228,7 +1253,8 @@ Blockly.Procedures.findLegalName=function(a,b){if(b.isInFlyout)return a;for(;!Bl
Blockly.Procedures.rename=function(a){a=a.replace(/^[\s\xa0]+|[\s\xa0]+$/g,"");a=Blockly.Procedures.findLegalName(a,this.sourceBlock_);for(var b=this.sourceBlock_.workspace.getAllBlocks(),c=0;c<b.length;c++)b[c].renameProcedure&&b[c].renameProcedure(this.text_,a);return a};
Blockly.Procedures.flyoutCategory=function(a){function b(a,b){for(var d=0;d<a.length;d++){var h=a[d][0],k=a[d][1],l=goog.dom.createDom("block");l.setAttribute("type",b);l.setAttribute("gap",16);var q=goog.dom.createDom("mutation");q.setAttribute("name",h);l.appendChild(q);for(h=0;h<k.length;h++){var m=goog.dom.createDom("arg");m.setAttribute("name",k[h]);q.appendChild(m)}c.push(l)}}var c=[];if(Blockly.Blocks.procedures_defnoreturn){var d=goog.dom.createDom("block");d.setAttribute("type","procedures_defnoreturn");
d.setAttribute("gap",16);c.push(d)}Blockly.Blocks.procedures_defreturn&&(d=goog.dom.createDom("block"),d.setAttribute("type","procedures_defreturn"),d.setAttribute("gap",16),c.push(d));Blockly.Blocks.procedures_ifreturn&&(d=goog.dom.createDom("block"),d.setAttribute("type","procedures_ifreturn"),d.setAttribute("gap",16),c.push(d));c.length&&c[c.length-1].setAttribute("gap",24);a=Blockly.Procedures.allProcedures(a);b(a[0],"procedures_callnoreturn");b(a[1],"procedures_callreturn");return c};
Blockly.Procedures.getCallers=function(a,b){for(var c=[],d=b.getAllBlocks(),e=0;e<d.length;e++)if(d[e].getProcedureCall){var f=d[e].getProcedureCall();f&&Blockly.Names.equals(f,a)&&c.push(d[e])}return c};Blockly.Procedures.disposeCallers=function(a,b){for(var c=Blockly.Procedures.getCallers(a,b),d=0;d<c.length;d++)c[d].dispose(!0,!1)};Blockly.Procedures.mutateCallers=function(a,b,c,d){a=Blockly.Procedures.getCallers(a,b);for(b=0;b<a.length;b++)a[b].setProcedureParameters(c,d)};
Blockly.Procedures.getCallers=function(a,b){for(var c=[],d=b.getAllBlocks(),e=0;e<d.length;e++)if(d[e].getProcedureCall){var f=d[e].getProcedureCall();f&&Blockly.Names.equals(f,a)&&c.push(d[e])}return c};Blockly.Procedures.disposeCallers=function(a,b){for(var c=Blockly.Procedures.getCallers(a,b),d=0;d<c.length;d++)c[d].dispose(!0,!1)};
Blockly.Procedures.mutateCallers=function(a){var b=Blockly.Events.recordUndo,c=a.getProcedureDef()[0],d=a.mutationToDom(!0);a=Blockly.Procedures.getCallers(c,a.workspace);for(var c=0,e;e=a[c];c++){var f=e.mutationToDom(),f=f&&Blockly.Xml.domToText(f);e.domToMutation(d);var g=e.mutationToDom(),g=g&&Blockly.Xml.domToText(g);f!=g&&(Blockly.Events.recordUndo=!1,Blockly.Events.fire(new Blockly.Events.Change(e,"mutation",null,f,g)),Blockly.Events.recordUndo=b)}};
Blockly.Procedures.getDefinition=function(a,b){for(var c=b.getAllBlocks(),d=0;d<c.length;d++)if(c[d].getProcedureDef){var e=c[d].getProcedureDef();if(e&&Blockly.Names.equals(e[0],a))return c[d]}return null};Blockly.Flyout=function(a){a.getMetrics=this.getMetrics_.bind(this);a.setMetrics=this.setMetrics_.bind(this);this.workspace_=new Blockly.WorkspaceSvg(a);this.workspace_.isFlyout=!0;this.RTL=!!a.RTL;this.eventWrappers_=[];this.buttons_=[];this.listeners_=[];this.permanentlyDisabled_=[]};Blockly.Flyout.prototype.autoClose=!0;Blockly.Flyout.prototype.CORNER_RADIUS=8;Blockly.Flyout.prototype.SCROLLBAR_PADDING=2;Blockly.Flyout.prototype.width_=0;Blockly.Flyout.prototype.height_=0;
Blockly.Flyout.prototype.createDom=function(){this.svgGroup_=Blockly.createSvgElement("g",{"class":"blocklyFlyout"},null);this.svgBackground_=Blockly.createSvgElement("path",{"class":"blocklyFlyoutBackground"},this.svgGroup_);this.svgGroup_.appendChild(this.workspace_.createDom());return this.svgGroup_};
Blockly.Flyout.prototype.init=function(a){this.targetWorkspace_=a;this.workspace_.targetWorkspace=a;this.scrollbar_=new Blockly.Scrollbar(this.workspace_,!1,!1);this.hide();Array.prototype.push.apply(this.eventWrappers_,Blockly.bindEvent_(this.svgGroup_,"wheel",this,this.wheel_));this.autoClose||(this.filterWrapper_=this.filterForCapacity_.bind(this),this.targetWorkspace_.addChangeListener(this.filterWrapper_));Array.prototype.push.apply(this.eventWrappers_,Blockly.bindEvent_(this.svgGroup_,"mousedown",
@@ -1251,7 +1277,7 @@ Blockly.Flyout.prototype.blockMouseDown_=function(a){var b=this;return function(
Blockly.Flyout.prototype.onMouseMove_=function(a){var b=a.clientY-this.startDragMouseY_;this.startDragMouseY_=a.clientY;a=this.getMetrics_();b=a.viewTop-b;b=Math.min(b,a.contentHeight-a.viewHeight);b=Math.max(b,0);this.scrollbar_.set(b)};
Blockly.Flyout.prototype.onMouseMoveBlock_=function(a){if("mousemove"==a.type&&1>=a.clientX&&0==a.clientY&&0==a.button)a.stopPropagation();else{Blockly.removeAllRanges();var b=a.clientX-Blockly.Flyout.startDownEvent_.clientX;a=a.clientY-Blockly.Flyout.startDownEvent_.clientY;Math.sqrt(b*b+a*a)>Blockly.DRAG_RADIUS&&Blockly.Flyout.startFlyout_.createBlockFunc_(Blockly.Flyout.startBlock_)(Blockly.Flyout.startDownEvent_)}};
Blockly.Flyout.prototype.createBlockFunc_=function(a){var b=this,c=this.targetWorkspace_;return function(d){if(!Blockly.isRightButton(d)&&!a.disabled){Blockly.Events.disable();var e=Blockly.Xml.blockToDom(a),e=Blockly.Xml.domToBlock(c,e),f=a.getSvgRoot();if(!f)throw"originBlock is not rendered.";f=Blockly.getSvgXY_(f,c);if(b.RTL){var g=c.getMetrics().viewWidth-b.width_;f.x+=g/c.scale-g}else f.x+=b.workspace_.scrollX/b.workspace_.scale-b.workspace_.scrollX;f.y+=b.workspace_.scrollY/b.workspace_.scale-
b.workspace_.scrollY;g=e.getSvgRoot();if(!g)throw"block is not rendered.";g=Blockly.getSvgXY_(g,c);g.x+=c.scrollX/c.scale-c.scrollX;g.y+=c.scrollY/c.scale-c.scrollY;c.toolbox_&&!c.scrollbar&&(g.x+=c.toolbox_.width/c.scale);e.moveBy(f.x-g.x,f.y-g.y);Blockly.Events.enable();Blockly.Events.isEnabled()&&!e.isShadow()&&Blockly.Events.fire(new Blockly.Events.Create(e));b.autoClose?b.hide():b.filterForCapacity_();e.onMouseDown_(d)}}};
b.workspace_.scrollY;g=e.getSvgRoot();if(!g)throw"block is not rendered.";g=Blockly.getSvgXY_(g,c);g.x+=c.scrollX/c.scale-c.scrollX;g.y+=c.scrollY/c.scale-c.scrollY;c.toolbox_&&!c.scrollbar&&(g.x+=c.toolbox_.width/c.scale);e.moveBy(f.x-g.x,f.y-g.y);Blockly.Events.enable();Blockly.Events.isEnabled()&&(Blockly.Events.setGroup(!0),Blockly.Events.fire(new Blockly.Events.Create(e)));b.autoClose?b.hide():b.filterForCapacity_();e.onMouseDown_(d)}}};
Blockly.Flyout.prototype.filterForCapacity_=function(){for(var a=this.targetWorkspace_.remainingCapacity(),b=this.workspace_.getTopBlocks(!1),c=0,d;d=b[c];c++)if(-1==this.permanentlyDisabled_.indexOf(d)){var e=d.getDescendants();d.setDisabled(e.length>a)}};Blockly.Flyout.prototype.getClientRect=function(){var a=this.svgGroup_.getBoundingClientRect();if(this.RTL){var b=a.left+a.width+1E9;return new goog.math.Rect(a.left,-1E9,b,2E9)}b=1E9+a.width+a.left;return new goog.math.Rect(-1E9,-1E9,b,2E9)};
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(a){this.workspace_=a};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"};
@@ -1289,9 +1315,10 @@ Blockly.Css.CONTENT=[".blocklySvg {","background-color: #fff;","outline: none;",
".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(a,b,c){Blockly.WidgetDiv.hide();Blockly.WidgetDiv.owner_=a;Blockly.WidgetDiv.dispose_=c;a=goog.style.getViewportPageOffset(document);Blockly.WidgetDiv.DIV.style.top=a.y+"px";Blockly.WidgetDiv.DIV.style.direction=b?"rtl":"ltr";Blockly.WidgetDiv.DIV.style.display="block"};
Blockly.WidgetDiv.hide=function(){Blockly.WidgetDiv.owner_&&(Blockly.WidgetDiv.DIV.style.display="none",Blockly.WidgetDiv.DIV.style.left="",Blockly.WidgetDiv.DIV.style.top="",Blockly.WidgetDiv.DIV.style.height="",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(a){Blockly.WidgetDiv.owner_==a&&Blockly.WidgetDiv.hide()};Blockly.WidgetDiv.position=function(a,b,c,d,e){b<d.y&&(b=d.y);e?a>c.width+d.x&&(a=c.width+d.x):a<d.x&&(a=d.x);Blockly.WidgetDiv.DIV.style.left=a+"px";Blockly.WidgetDiv.DIV.style.top=b+"px";Blockly.WidgetDiv.DIV.style.height=c.height-b+d.y+"px"};Blockly.inject=function(a,b){goog.isString(a)&&(a=document.getElementById(a));if(!goog.dom.contains(document,a))throw"Error: container is not in current document.";var c=Blockly.parseOptions_(b||{}),d=Blockly.createDom_(a,c),c=Blockly.createMainWorkspace_(d,c);Blockly.init_(c);c.markFocused();Blockly.bindEvent_(d,"focus",c,c.markFocused);return c};
Blockly.WidgetDiv.show=function(a,b,c){Blockly.WidgetDiv.hide();Blockly.WidgetDiv.owner_=a;Blockly.WidgetDiv.dispose_=c;a=goog.style.getViewportPageOffset(document);Blockly.WidgetDiv.DIV.style.top=a.y+"px";Blockly.WidgetDiv.DIV.style.direction=b?"rtl":"ltr";Blockly.WidgetDiv.DIV.style.display="block";Blockly.Events.setGroup(!0)};
Blockly.WidgetDiv.hide=function(){Blockly.WidgetDiv.owner_&&(Blockly.WidgetDiv.owner_=null,Blockly.WidgetDiv.DIV.style.display="none",Blockly.WidgetDiv.DIV.style.left="",Blockly.WidgetDiv.DIV.style.top="",Blockly.WidgetDiv.DIV.style.height="",Blockly.WidgetDiv.dispose_&&Blockly.WidgetDiv.dispose_(),Blockly.WidgetDiv.dispose_=null,goog.dom.removeChildren(Blockly.WidgetDiv.DIV),Blockly.Events.setGroup(!1))};Blockly.WidgetDiv.isVisible=function(){return!!Blockly.WidgetDiv.owner_};
Blockly.WidgetDiv.hideIfOwner=function(a){Blockly.WidgetDiv.owner_==a&&Blockly.WidgetDiv.hide()};Blockly.WidgetDiv.position=function(a,b,c,d,e){b<d.y&&(b=d.y);e?a>c.width+d.x&&(a=c.width+d.x):a<d.x&&(a=d.x);Blockly.WidgetDiv.DIV.style.left=a+"px";Blockly.WidgetDiv.DIV.style.top=b+"px";Blockly.WidgetDiv.DIV.style.height=c.height-b+d.y+"px"};Blockly.constants={};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:96,height:124,url:"sprites.png"};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.DRAG_RADIUS=5;Blockly.SNAP_RADIUS=20;Blockly.BUMP_DELAY=250;Blockly.COLLAPSE_CHARS=30;Blockly.LONGPRESS=750;Blockly.inject=function(a,b){goog.isString(a)&&(a=document.getElementById(a)||document.querySelector(a));if(!goog.dom.contains(document,a))throw"Error: container is not in current document.";var c=Blockly.parseOptions_(b||{}),d=Blockly.createDom_(a,c),c=Blockly.createMainWorkspace_(d,c);Blockly.init_(c);c.markFocused();Blockly.bindEvent_(d,"focus",c,c.markFocused);return c};
Blockly.parseToolboxTree_=function(a){a?("string"!=typeof a&&("undefined"==typeof XSLTProcessor&&a.outerHTML?a=a.outerHTML:a instanceof Element||(a=null)),"string"==typeof a&&(a=Blockly.Xml.textToDom(a))):a=null;return a};
Blockly.parseOptions_=function(a){var b=!!a.readOnly;if(b)var c=null,d=!1,e=!1,f=!1,g=!1,h=!1,k=!1;else c=Blockly.parseToolboxTree_(a.toolbox),d=!(!c||!c.getElementsByTagName("category").length),e=a.trashcan,void 0===e&&(e=d),f=a.collapse,void 0===f&&(f=d),g=a.comments,void 0===g&&(g=d),h=a.disable,void 0===h&&(h=d),k=a.sounds,void 0===k&&(k=!0);var l=a.scrollbars;void 0===l&&(l=d);var q=a.css;void 0===q&&(q=!0);var m=a.grid||{},p={};p.spacing=parseFloat(m.spacing)||0;p.colour=m.colour||"#888";p.length=
parseFloat(m.length)||1;p.snap=0<p.spacing&&!!m.snap;m="https://blockly-demo.appspot.com/static/media/";a.media?m=a.media:a.path&&(m=a.path+"media/");var n=a.zoom||{},r={};r.controls=void 0===n.controls?!1:!!n.controls;r.wheel=void 0===n.wheel?!1:!!n.wheel;r.startScale=void 0===n.startScale?1:parseFloat(n.startScale);r.maxScale=void 0===n.maxScale?3:parseFloat(n.maxScale);r.minScale=void 0===n.minScale?.3:parseFloat(n.minScale);r.scaleSpeed=void 0===n.scaleSpeed?1.2:parseFloat(n.scaleSpeed);n=!!a.realtime;
@@ -1317,19 +1344,17 @@ Blockly.createSvgElement=function(a,b,c,d){a=document.createElementNS(Blockly.SV
Blockly.mouseToSvg=function(a,b){var c=b.createSVGPoint();c.x=a.clientX;c.y=a.clientY;var d=b.getScreenCTM(),d=d.inverse();return c.matrixTransform(d)};Blockly.shortestStringLength=function(a){if(!a.length)return 0;for(var b=a[0].length,c=1;c<a.length;c++)b=Math.min(b,a[c].length);return b};
Blockly.commonWordPrefix=function(a,b){if(!a.length)return 0;if(1==a.length)return a[0].length;for(var c=0,d=b||Blockly.shortestStringLength(a),e=0;e<d;e++){for(var f=a[0][e],g=1;g<a.length;g++)if(f!=a[g][e])return c;" "==f&&(c=e+1)}for(g=1;g<a.length;g++)if((f=a[g][e])&&" "!=f)return c;return d};
Blockly.commonWordSuffix=function(a,b){if(!a.length)return 0;if(1==a.length)return a[0].length;for(var c=0,d=b||Blockly.shortestStringLength(a),e=0;e<d;e++){for(var f=a[0].substr(-e-1,1),g=1;g<a.length;g++)if(f!=a[g].substr(-e-1,1))return c;" "==f&&(c=e+1)}for(g=1;g<a.length;g++)if((f=a[g].charAt(a[g].length-e-1))&&" "!=f)return c;return d};Blockly.isNumber=function(a){return!!a.match(/^\s*-?\d+(\.\d+)?\s*$/)};
Blockly.tokenizeInterpolation=function(a){var b=[];a=a.split("");a.push("");for(var c=0,d=[],e=null,f=0;f<a.length;f++){var g=a[f];0==c?"%"==g?c=1:d.push(g):1==c?"%"==g?(d.push(g),c=0):"0"<=g&&"9">=g?(c=2,e=g,(g=d.join(""))&&b.push(g),d.length=0):(d.push("%",g),c=0):2==c&&("0"<=g&&"9">=g?e+=g:(b.push(parseInt(e,10)),f--,c=0))}(g=d.join(""))&&b.push(g);return b};
Blockly.genUid=function(){var a=Blockly.genUid.soup_.length,b=[];if(Blockly.genUid.crypto_){var c=new Uint32Array(20);Blockly.genUid.crypto_.getRandomValues(c);for(var d=0;20>d;d++)b[d]=Blockly.genUid.soup_.charAt(c[d]%a)}else for(d=0;20>d;d++)b[d]=Blockly.genUid.soup_.charAt(Math.random()*a);return b.join("")};Blockly.genUid.crypto_=this.crypto;Blockly.genUid.soup_="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";var CLOSURE_DEFINES={"goog.DEBUG":!1};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:96,height:124,url:"sprites.png"};Blockly.hueToRgb=function(a){return goog.color.hsvToHex(a,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(a){return{width:a.cachedWidth_,height:a.cachedHeight_}};
Blockly.tokenizeInterpolation=function(a){var b=[];a=a.split("");a.push("");for(var c=0,d=[],e=null,f=0;f<a.length;f++){var g=a[f];0==c?"%"==g?c=1:d.push(g):1==c?"%"==g?(d.push(g),c=0):"0"<=g&&"9">=g?(c=2,e=g,(g=d.join(""))&&b.push(g),d.length=0):(d.push("%",g),c=0):2==c&&("0"<=g&&"9">=g?e+=g:(b.push(parseInt(e,10)),f--,c=0))}(g=d.join(""))&&b.push(g);return b};Blockly.genUid=function(){for(var a=Blockly.genUid.soup_.length,b=[],c=0;20>c;c++)b[c]=Blockly.genUid.soup_.charAt(Math.random()*a);return b.join("")};
Blockly.genUid.soup_="!#%()*+,-./:;=?@[]^_`{|}~ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";var CLOSURE_DEFINES={"goog.DEBUG":!1};Blockly.mainWorkspace=null;Blockly.selected=null;Blockly.highlightedConnection_=null;Blockly.localConnection_=null;Blockly.clipboardXml_=null;Blockly.clipboardSource_=null;Blockly.dragMode_=0;Blockly.onTouchUpWrapper_=null;Blockly.hueToRgb=function(a){return goog.color.hsvToHex(a,Blockly.HSV_SATURATION,255*Blockly.HSV_VALUE)};Blockly.svgSize=function(a){return{width:a.cachedWidth_,height:a.cachedHeight_}};
Blockly.svgResize=function(a){for(;a.options.parentWorkspace;)a=a.options.parentWorkspace;var b=a.getParentSvg(),c=b.parentNode;if(c){var d=c.offsetWidth,c=c.offsetHeight;b.cachedWidth_!=d&&(b.setAttribute("width",d+"px"),b.cachedWidth_=d);b.cachedHeight_!=c&&(b.setAttribute("height",c+"px"),b.cachedHeight_=c);a.resize()}};
Blockly.onMouseUp_=function(a){a=Blockly.getMainWorkspace();Blockly.Css.setCursor(Blockly.Css.Cursor.OPEN);a.isScrolling=!1;Blockly.onTouchUpWrapper_&&(Blockly.unbindEvent_(Blockly.onTouchUpWrapper_),Blockly.onTouchUpWrapper_=null);Blockly.onMouseMoveWrapper_&&(Blockly.unbindEvent_(Blockly.onMouseMoveWrapper_),Blockly.onMouseMoveWrapper_=null)};
Blockly.onMouseMove_=function(a){if(!(a.touches&&2<=a.touches.length)){var b=Blockly.getMainWorkspace();if(b.isScrolling){Blockly.removeAllRanges();var c=a.clientX-b.startDragMouseX,d=a.clientY-b.startDragMouseY,e=b.startDragMetrics,f=b.startScrollX+c,g=b.startScrollY+d,f=Math.min(f,-e.contentLeft),g=Math.min(g,-e.contentTop),f=Math.max(f,e.viewWidth-e.contentLeft-e.contentWidth),g=Math.max(g,e.viewHeight-e.contentTop-e.contentHeight);b.scrollbar.set(-f-e.contentLeft,-g-e.contentTop);Math.sqrt(c*
c+d*d)>Blockly.DRAG_RADIUS&&Blockly.longStop_();a.stopPropagation()}}};
Blockly.onKeyDown_=function(a){if(!Blockly.isTargetInput_(a)){var b=!1;if(27==a.keyCode)Blockly.hideChaff();else if(8==a.keyCode||46==a.keyCode)try{Blockly.selected&&Blockly.selected.isDeletable()&&(b=!0)}finally{a.preventDefault()}else if(a.altKey||a.ctrlKey||a.metaKey)Blockly.selected&&Blockly.selected.isDeletable()&&Blockly.selected.isMovable()&&(67==a.keyCode?(Blockly.hideChaff(),Blockly.copy_(Blockly.selected)):88==a.keyCode&&(Blockly.copy_(Blockly.selected),b=!0)),86==a.keyCode&&Blockly.clipboardXml_&&
Blockly.clipboardSource_.paste(Blockly.clipboardXml_);b&&(Blockly.hideChaff(),Blockly.selected.dispose(2!=Blockly.dragMode_,!0),Blockly.highlightedConnection_&&(Blockly.highlightedConnection_.unhighlight(),Blockly.highlightedConnection_=null))}};Blockly.terminateDrag_=function(){Blockly.BlockSvg.terminateDrag_();Blockly.Flyout.terminateDrag_()};Blockly.longPid_=0;Blockly.longStart_=function(a,b){Blockly.longStop_();Blockly.longPid_=setTimeout(function(){a.button=2;b.onMouseDown_(a)},Blockly.LONGPRESS)};
Blockly.longStop_=function(){Blockly.longPid_&&(clearTimeout(Blockly.longPid_),Blockly.longPid_=0)};Blockly.copy_=function(a){var b=Blockly.Xml.blockToDom(a);2!=Blockly.dragMode_&&Blockly.Xml.deleteNext(b);var c=a.getRelativeToSurfaceXY();b.setAttribute("x",a.RTL?-c.x:c.x);b.setAttribute("y",c.y);Blockly.clipboardXml_=b;Blockly.clipboardSource_=a.workspace};
Blockly.onKeyDown_=function(a){if(!Blockly.isTargetInput_(a)){var b=!1;if(27==a.keyCode)Blockly.hideChaff();else if(8==a.keyCode||46==a.keyCode)try{Blockly.selected&&Blockly.selected.isDeletable()&&(b=!0)}finally{a.preventDefault()}else if(a.altKey||a.ctrlKey||a.metaKey)Blockly.selected&&Blockly.selected.isDeletable()&&Blockly.selected.isMovable()&&(67==a.keyCode?(Blockly.hideChaff(),Blockly.copy_(Blockly.selected)):88==a.keyCode&&(Blockly.copy_(Blockly.selected),b=!0)),86==a.keyCode?Blockly.clipboardXml_&&
Blockly.clipboardSource_.paste(Blockly.clipboardXml_):90==a.keyCode&&Blockly.mainWorkspace.undo(a.shiftKey);b&&(Blockly.hideChaff(),Blockly.selected.dispose(2!=Blockly.dragMode_,!0),Blockly.highlightedConnection_&&(Blockly.highlightedConnection_.unhighlight(),Blockly.highlightedConnection_=null))}};Blockly.terminateDrag_=function(){Blockly.BlockSvg.terminateDrag_();Blockly.Flyout.terminateDrag_()};Blockly.longPid_=0;
Blockly.longStart_=function(a,b){Blockly.longStop_();Blockly.longPid_=setTimeout(function(){a.button=2;b.onMouseDown_(a)},Blockly.LONGPRESS)};Blockly.longStop_=function(){Blockly.longPid_&&(clearTimeout(Blockly.longPid_),Blockly.longPid_=0)};Blockly.copy_=function(a){var b=Blockly.Xml.blockToDom(a);2!=Blockly.dragMode_&&Blockly.Xml.deleteNext(b);var c=a.getRelativeToSurfaceXY();b.setAttribute("x",a.RTL?-c.x:c.x);b.setAttribute("y",c.y);Blockly.clipboardXml_=b;Blockly.clipboardSource_=a.workspace};
Blockly.duplicate_=function(a){var b=Blockly.clipboardXml_,c=Blockly.clipboardSource_;Blockly.copy_(a);a.workspace.paste(Blockly.clipboardXml_);Blockly.clipboardXml_=b;Blockly.clipboardSource_=c};Blockly.onContextMenu_=function(a){Blockly.isTargetInput_(a)||a.preventDefault()};Blockly.hideChaff=function(a){Blockly.Tooltip.hide();Blockly.WidgetDiv.hide();a||(a=Blockly.getMainWorkspace(),a.toolbox_&&a.toolbox_.flyout_&&a.toolbox_.flyout_.autoClose&&a.toolbox_.clearSelection())};
Blockly.getMainWorkspaceMetrics_=function(){var a=Blockly.svgSize(this.getParentSvg());this.toolbox_&&(a.width-=this.toolbox_.width);var b=Blockly.Flyout.prototype.CORNER_RADIUS-1,c=a.width-b,d=a.height-b;try{var e=this.getCanvas().getBBox()}catch(l){return null}var f=e.width*this.scale,g=e.height*this.scale,h=e.x*this.scale,k=e.y*this.scale;this.scrollbar?(b=Math.min(h-c/2,h+f-c),c=Math.max(h+f+c/2,h+c),f=Math.min(k-d/2,k+g-d),e=Math.max(k+g+d/2,k+d)):(b=e.x,c=b+e.width,f=e.y,e=f+e.height);d=0;!this.RTL&&
this.toolbox_&&(d=this.toolbox_.width);return{viewHeight:a.height,viewWidth:a.width,contentHeight:e-f,contentWidth:c-b,viewTop:-this.scrollY,viewLeft:-this.scrollX,contentTop:f,contentLeft:b,absoluteTop:0,absoluteLeft:d}};
Blockly.getMainWorkspaceMetrics_=function(){var a=Blockly.svgSize(this.getParentSvg());this.toolbox_&&(a.width-=this.toolbox_.width);var b=Blockly.Flyout.prototype.CORNER_RADIUS-1,c=a.width-b,d=a.height-b,e=this.getBlocksBoundingBox(),f=e.width*this.scale,g=e.height*this.scale,h=e.x*this.scale,k=e.y*this.scale;this.scrollbar?(b=Math.min(h-c/2,h+f-c),c=Math.max(h+f+c/2,h+c),f=Math.min(k-d/2,k+g-d),d=Math.max(k+g+d/2,k+d)):(b=e.x,c=b+e.width,f=e.y,d=f+e.height);e=0;!this.RTL&&this.toolbox_&&(e=this.toolbox_.width);
return{viewHeight:a.height,viewWidth:a.width,contentHeight:d-f,contentWidth:c-b,viewTop:-this.scrollY,viewLeft:-this.scrollX,contentTop:f,contentLeft:b,absoluteTop:0,absoluteLeft:e}};
Blockly.setMainWorkspaceMetrics_=function(a){if(!this.scrollbar)throw"Attempt to set main workspace scroll without scrollbars.";var b=this.getMetrics();goog.isNumber(a.x)&&(this.scrollX=-b.contentWidth*a.x-b.contentLeft);goog.isNumber(a.y)&&(this.scrollY=-b.contentHeight*a.y-b.contentTop);a=this.scrollX+b.absoluteLeft;b=this.scrollY+b.absoluteTop;this.translate(a,b);this.options.gridPattern&&(this.options.gridPattern.setAttribute("x",a),this.options.gridPattern.setAttribute("y",b),goog.userAgent.IE&&
this.updateGridPattern_())};Blockly.addChangeListener=function(a){console.warn("Deprecated call to Blockly.addChangeListener, use workspace.addChangeListener instead.");return Blockly.getMainWorkspace().addChangeListener(a)};Blockly.getMainWorkspace=function(){return Blockly.mainWorkspace};goog.global.Blockly||(goog.global.Blockly={});goog.global.Blockly.getMainWorkspace=Blockly.getMainWorkspace;goog.global.Blockly.addChangeListener=Blockly.addChangeListener;
+8 -3
View File
@@ -39,12 +39,15 @@ window.BLOCKLY_BOOT = function() {
dir = window.BLOCKLY_DIR.match(/[^\/]+$/)[0];
}
goog.addDependency("../../../" + dir + "/core/block.js", ['Blockly.Block'], ['Blockly.Blocks', 'Blockly.Comment', 'Blockly.Connection', 'Blockly.Input', 'Blockly.Mutator', 'Blockly.Warning', 'Blockly.Workspace', 'Blockly.Xml', 'goog.array', 'goog.asserts', 'goog.math.Coordinate', 'goog.string']);
goog.addDependency("../../../" + dir + "/core/block_render_svg.js", ['Blockly.BlockSvg.render'], ['Blockly.BlockSvg']);
goog.addDependency("../../../" + dir + "/core/block_svg.js", ['Blockly.BlockSvg'], ['Blockly.Block', 'Blockly.ContextMenu', 'goog.Timer', 'goog.asserts', 'goog.dom', 'goog.math.Coordinate', 'goog.userAgent']);
goog.addDependency("../../../" + dir + "/core/blockly.js", ['Blockly'], ['Blockly.BlockSvg', 'Blockly.Events', 'Blockly.FieldAngle', 'Blockly.FieldCheckbox', 'Blockly.FieldColour', 'Blockly.FieldDropdown', 'Blockly.FieldImage', 'Blockly.FieldTextInput', 'Blockly.FieldVariable', 'Blockly.Generator', 'Blockly.Msg', 'Blockly.Procedures', 'Blockly.Toolbox', 'Blockly.WidgetDiv', 'Blockly.WorkspaceSvg', 'Blockly.inject', 'Blockly.utils', 'goog.color', 'goog.userAgent']);
goog.addDependency("../../../" + dir + "/core/blockly.js", ['Blockly'], ['Blockly.BlockSvg.render', 'Blockly.Events', 'Blockly.FieldAngle', 'Blockly.FieldCheckbox', 'Blockly.FieldColour', 'Blockly.FieldDropdown', 'Blockly.FieldImage', 'Blockly.FieldTextInput', 'Blockly.FieldVariable', 'Blockly.Generator', 'Blockly.Msg', 'Blockly.Procedures', 'Blockly.Toolbox', 'Blockly.WidgetDiv', 'Blockly.WorkspaceSvg', 'Blockly.constants', 'Blockly.inject', 'Blockly.utils', 'goog.color', 'goog.userAgent']);
goog.addDependency("../../../" + dir + "/core/blocks.js", ['Blockly.Blocks'], []);
goog.addDependency("../../../" + dir + "/core/bubble.js", ['Blockly.Bubble'], ['Blockly.Workspace', 'goog.dom', 'goog.math', 'goog.userAgent']);
goog.addDependency("../../../" + dir + "/core/comment.js", ['Blockly.Comment'], ['Blockly.Bubble', 'Blockly.Icon', 'goog.userAgent']);
goog.addDependency("../../../" + dir + "/core/connection.js", ['Blockly.Connection', 'Blockly.ConnectionDB'], ['goog.dom']);
goog.addDependency("../../../" + dir + "/core/connection.js", ['Blockly.Connection'], ['goog.asserts', 'goog.dom']);
goog.addDependency("../../../" + dir + "/core/connection_db.js", ['Blockly.ConnectionDB'], ['Blockly.Connection']);
goog.addDependency("../../../" + dir + "/core/constants.js", ['Blockly.constants'], []);
goog.addDependency("../../../" + dir + "/core/contextmenu.js", ['Blockly.ContextMenu'], ['goog.dom', 'goog.events', 'goog.style', 'goog.ui.Menu', 'goog.ui.MenuItem']);
goog.addDependency("../../../" + dir + "/core/css.js", ['Blockly.Css'], []);
goog.addDependency("../../../" + dir + "/core/events.js", ['Blockly.Events'], []);
@@ -76,7 +79,7 @@ goog.addDependency("../../../" + dir + "/core/variables.js", ['Blockly.Variables
goog.addDependency("../../../" + dir + "/core/warning.js", ['Blockly.Warning'], ['Blockly.Bubble', 'Blockly.Icon']);
goog.addDependency("../../../" + dir + "/core/widgetdiv.js", ['Blockly.WidgetDiv'], ['Blockly.Css', 'goog.dom', 'goog.style']);
goog.addDependency("../../../" + dir + "/core/workspace.js", ['Blockly.Workspace'], ['goog.math']);
goog.addDependency("../../../" + dir + "/core/workspace_svg.js", ['Blockly.WorkspaceSvg'], ['Blockly.ScrollbarPair', 'Blockly.Trashcan', 'Blockly.ZoomControls', 'Blockly.Workspace', 'Blockly.Xml', 'goog.dom', 'goog.math.Coordinate', 'goog.userAgent']);
goog.addDependency("../../../" + dir + "/core/workspace_svg.js", ['Blockly.WorkspaceSvg'], ['Blockly.ConnectionDB', 'Blockly.ScrollbarPair', 'Blockly.Trashcan', 'Blockly.Workspace', 'Blockly.Xml', 'Blockly.ZoomControls', 'goog.dom', 'goog.math.Coordinate', 'goog.userAgent']);
goog.addDependency("../../../" + dir + "/core/xml.js", ['Blockly.Xml'], ['goog.dom']);
goog.addDependency("../../../" + dir + "/core/zoom_controls.js", ['Blockly.ZoomControls'], ['goog.dom']);
goog.addDependency("../../alltests.js", [], []);
@@ -1583,6 +1586,7 @@ goog.addDependency("../../third_party/closure/goog/svgpan/svgpan.js", ['svgpan.S
goog.require('Blockly');
goog.require('Blockly.Block');
goog.require('Blockly.BlockSvg');
goog.require('Blockly.BlockSvg.render');
goog.require('Blockly.Blocks');
goog.require('Blockly.Bubble');
goog.require('Blockly.Comment');
@@ -1621,6 +1625,7 @@ goog.require('Blockly.Workspace');
goog.require('Blockly.WorkspaceSvg');
goog.require('Blockly.Xml');
goog.require('Blockly.ZoomControls');
goog.require('Blockly.constants');
goog.require('Blockly.inject');
goog.require('Blockly.utils');
+19 -16
View File
@@ -119,13 +119,18 @@ Blockly.Blocks['lists_create_with'] = {
itemBlock = itemBlock.nextConnection &&
itemBlock.nextConnection.targetBlock();
}
// Disconnect any children that don't belong.
for (var i = 0; i < this.itemCount_; i++) {
var connection = this.getInput('ADD' + i).connection.targetConnection;
if (connection && connections.indexOf(connection) == -1) {
connection.disconnect();
}
}
this.itemCount_ = connections.length;
this.updateShape_();
// Reconnect any child blocks.
for (var i = 0; i < this.itemCount_; i++) {
if (connections[i]) {
this.getInput('ADD' + i).connection.connect(connections[i]);
}
Blockly.Mutator.reconnect(connections[i], this, 'ADD' + i);
}
},
/**
@@ -150,28 +155,26 @@ Blockly.Blocks['lists_create_with'] = {
* @this Blockly.Block
*/
updateShape_: function() {
// Delete everything.
if (this.getInput('EMPTY')) {
if (this.itemCount_ && this.getInput('EMPTY')) {
this.removeInput('EMPTY');
} else {
var i = 0;
while (this.getInput('ADD' + i)) {
this.removeInput('ADD' + i);
i++;
}
}
// Rebuild block.
if (this.itemCount_ == 0) {
} else if (!this.itemCount_ && !this.getInput('EMPTY')) {
this.appendDummyInput('EMPTY')
.appendField(Blockly.Msg.LISTS_CREATE_EMPTY_TITLE);
} else {
for (var i = 0; i < this.itemCount_; i++) {
}
// Add new inputs.
for (var i = 0; i < this.itemCount_; i++) {
if (!this.getInput('ADD' + i)) {
var input = this.appendValueInput('ADD' + i);
if (i == 0) {
input.appendField(Blockly.Msg.LISTS_CREATE_WITH_INPUT_WITH);
}
}
}
// Remove deleted inputs.
while (this.getInput('ADD' + i)) {
this.removeInput('ADD' + i);
i++;
}
}
};
+50 -45
View File
@@ -94,17 +94,7 @@ Blockly.Blocks['controls_if'] = {
domToMutation: function(xmlElement) {
this.elseifCount_ = parseInt(xmlElement.getAttribute('elseif'), 10) || 0;
this.elseCount_ = parseInt(xmlElement.getAttribute('else'), 10) || 0;
for (var i = 1; i <= this.elseifCount_; i++) {
this.appendValueInput('IF' + i)
.setCheck('Boolean')
.appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSEIF);
this.appendStatementInput('DO' + i)
.appendField(Blockly.Msg.CONTROLS_IF_MSG_THEN);
}
if (this.elseCount_) {
this.appendStatementInput('ELSE')
.appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSE);
}
this.updateShape_();
},
/**
* Populate the mutator's dialog with this block's components.
@@ -135,44 +125,23 @@ Blockly.Blocks['controls_if'] = {
* @this Blockly.Block
*/
compose: function(containerBlock) {
// Disconnect the else input blocks and remove the inputs.
if (this.elseCount_) {
this.removeInput('ELSE');
}
this.elseCount_ = 0;
// Disconnect all the elseif input blocks and remove the inputs.
for (var i = this.elseifCount_; i > 0; i--) {
this.removeInput('IF' + i);
this.removeInput('DO' + i);
}
this.elseifCount_ = 0;
// Rebuild the block's optional inputs.
var clauseBlock = containerBlock.nextConnection.targetBlock();
// Count number of inputs.
this.elseifCount_ = 0;
this.elseCount_ = 0;
var valueConnections = [null];
var statementConnections = [null];
var elseStatementConnection = null;
while (clauseBlock) {
switch (clauseBlock.type) {
case 'controls_if_elseif':
this.elseifCount_++;
var ifInput = this.appendValueInput('IF' + this.elseifCount_)
.setCheck('Boolean')
.appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSEIF);
var doInput = this.appendStatementInput('DO' + this.elseifCount_);
doInput.appendField(Blockly.Msg.CONTROLS_IF_MSG_THEN);
// Reconnect any child blocks.
if (clauseBlock.valueConnection_) {
ifInput.connection.connect(clauseBlock.valueConnection_);
}
if (clauseBlock.statementConnection_) {
doInput.connection.connect(clauseBlock.statementConnection_);
}
valueConnections.push(clauseBlock.valueConnection_);
statementConnections.push(clauseBlock.statementConnection_);
break;
case 'controls_if_else':
this.elseCount_++;
var elseInput = this.appendStatementInput('ELSE');
elseInput.appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSE);
// Reconnect any child blocks.
if (clauseBlock.statementConnection_) {
elseInput.connection.connect(clauseBlock.statementConnection_);
}
elseStatementConnection = clauseBlock.statementConnection_;
break;
default:
throw 'Unknown block type.';
@@ -180,6 +149,13 @@ Blockly.Blocks['controls_if'] = {
clauseBlock = clauseBlock.nextConnection &&
clauseBlock.nextConnection.targetBlock();
}
this.updateShape_();
// Reconnect any child blocks.
for (var i = 1; i <= this.elseifCount_; i++) {
Blockly.Mutator.reconnect(valueConnections[i], this, 'IF' + i);
Blockly.Mutator.reconnect(statementConnections[i], this, 'DO' + i);
}
Blockly.Mutator.reconnect(elseStatementConnection, this, 'ELSE');
},
/**
* Store pointers to any connected child blocks.
@@ -211,6 +187,35 @@ Blockly.Blocks['controls_if'] = {
clauseBlock = clauseBlock.nextConnection &&
clauseBlock.nextConnection.targetBlock();
}
},
/**
* Modify this block to have the correct number of inputs.
* @private
* @this Blockly.Block
*/
updateShape_: function() {
// Delete everything.
if (this.getInput('ELSE')) {
this.removeInput('ELSE');
}
var i = 1;
while (this.getInput('IF' + i)) {
this.removeInput('IF' + i);
this.removeInput('DO' + i);
i++;
}
// Rebuild block.
for (var i = 1; i <= this.elseifCount_; i++) {
this.appendValueInput('IF' + i)
.setCheck('Boolean')
.appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSEIF);
this.appendStatementInput('DO' + i)
.appendField(Blockly.Msg.CONTROLS_IF_MSG_THEN);
}
if (this.elseCount_) {
this.appendStatementInput('ELSE')
.appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSE);
}
}
};
@@ -319,7 +324,7 @@ Blockly.Blocks['logic_compare'] = {
for (var i = 0; i < this.prevBlocks_.length; i++) {
var block = this.prevBlocks_[i];
if (block === blockA || block === blockB) {
block.setParent(null);
block.unplug();
block.bumpNeighbours_();
}
}
@@ -459,10 +464,10 @@ Blockly.Blocks['logic_ternary'] = {
var block = (i == 1) ? blockA : blockB;
if (block && !block.outputConnection.checkType_(parentConnection)) {
if (parentConnection === this.prevParentConnection_) {
this.setParent(null);
parentConnection.sourceBlock_.bumpNeighbours_();
this.unplug();
parentConnection.getSourceBlock().bumpNeighbours_();
} else {
block.setParent(null);
block.unplug();
block.bumpNeighbours_();
}
}
-40
View File
@@ -168,26 +168,6 @@ Blockly.Blocks['controls_for'] = {
thisBlock.getFieldValue('VAR'));
});
},
/**
* Return all variables referenced by this block.
* @return {!Array.<string>} List of variable names.
* @this Blockly.Block
*/
getVars: function() {
return [this.getFieldValue('VAR')];
},
/**
* Notification that a variable is renaming.
* If the name matches one of this block's variables, rename it.
* @param {string} oldName Previous name of variable.
* @param {string} newName Renamed variable.
* @this Blockly.Block
*/
renameVar: function(oldName, newName) {
if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
this.setFieldValue(newName, 'VAR');
}
},
/**
* Add menu option to create getter block for loop variable.
* @param {!Array} options List of menu options to add to.
@@ -242,26 +222,6 @@ Blockly.Blocks['controls_forEach'] = {
thisBlock.getFieldValue('VAR'));
});
},
/**
* Return all variables referenced by this block.
* @return {!Array.<string>} List of variable names.
* @this Blockly.Block
*/
getVars: function() {
return [this.getFieldValue('VAR')];
},
/**
* Notification that a variable is renaming.
* If the name matches one of this block's variables, rename it.
* @param {string} oldName Previous name of variable.
* @param {string} newName Renamed variable.
* @this Blockly.Block
*/
renameVar: function(oldName, newName) {
if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
this.setFieldValue(newName, 'VAR');
}
},
customContextMenu: Blockly.Blocks['controls_for'].customContextMenu
};
-20
View File
@@ -288,26 +288,6 @@ Blockly.Blocks['math_change'] = {
return Blockly.Msg.MATH_CHANGE_TOOLTIP.replace('%1',
thisBlock.getFieldValue('VAR'));
});
},
/**
* Return all variables referenced by this block.
* @return {!Array.<string>} List of variable names.
* @this Blockly.Block
*/
getVars: function() {
return [this.getFieldValue('VAR')];
},
/**
* Notification that a variable is renaming.
* If the name matches one of this block's variables, rename it.
* @param {string} oldName Previous name of variable.
* @param {string} newName Renamed variable.
* @this Blockly.Block
*/
renameVar: function(oldName, newName) {
if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
this.setFieldValue(newName, 'VAR');
}
}
};
+97 -80
View File
@@ -117,18 +117,30 @@ Blockly.Blocks['procedures_defnoreturn'] = {
paramString = Blockly.Msg.PROCEDURES_BEFORE_PARAMS +
' ' + this.arguments_.join(', ');
}
// The params field is deterministic based on the mutation,
// no need to fire a change event.
Blockly.Events.disable();
this.setFieldValue(paramString, 'PARAMS');
Blockly.Events.enable();
},
/**
* Create XML to represent the argument inputs.
* @param {=boolean} opt_paramIds If true include the IDs of the parameter
* quarks. Used by Blockly.Procedures.mutateCallers for reconnection.
* @return {!Element} XML storage element.
* @this Blockly.Block
*/
mutationToDom: function() {
mutationToDom: function(opt_paramIds) {
var container = document.createElement('mutation');
if (opt_paramIds) {
container.setAttribute('name', this.getFieldValue('NAME'));
}
for (var i = 0; i < this.arguments_.length; i++) {
var parameter = document.createElement('arg');
parameter.setAttribute('name', this.arguments_[i]);
if (opt_paramIds && this.paramIds_) {
parameter.setAttribute('paramId', this.paramIds_[i]);
}
container.appendChild(parameter);
}
@@ -151,6 +163,7 @@ Blockly.Blocks['procedures_defnoreturn'] = {
}
}
this.updateParams_();
Blockly.Procedures.mutateCallers(this);
// Show or hide the statement input.
this.setStatements_(xmlElement.getAttribute('statements') !== 'false');
@@ -185,8 +198,7 @@ Blockly.Blocks['procedures_defnoreturn'] = {
connection = paramBlock.nextConnection;
}
// Initialize procedure's callers with blank IDs.
Blockly.Procedures.mutateCallers(this.getFieldValue('NAME'),
this.workspace, this.arguments_, null);
Blockly.Procedures.mutateCallers(this);
return containerBlock;
},
/**
@@ -206,8 +218,7 @@ Blockly.Blocks['procedures_defnoreturn'] = {
paramBlock.nextConnection.targetBlock();
}
this.updateParams_();
Blockly.Procedures.mutateCallers(this.getFieldValue('NAME'),
this.workspace, this.arguments_, this.paramIds_);
Blockly.Procedures.mutateCallers(this);
// Show/hide the statement input.
var hasStatements = containerBlock.getFieldValue('STATEMENTS');
@@ -217,24 +228,15 @@ Blockly.Blocks['procedures_defnoreturn'] = {
if (hasStatements) {
this.setStatements_(true);
// Restore the stack, if one was saved.
var stackConnection = this.getInput('STACK').connection;
if (stackConnection.targetConnection ||
!this.statementConnection_ ||
this.statementConnection_.targetConnection ||
this.statementConnection_.sourceBlock_.workspace !=
this.workspace) {
// Block no longer exists or has been attached elsewhere.
this.statementConnection_ = null;
} else {
stackConnection.connect(this.statementConnection_);
}
Blockly.Mutator.reconnect(this.statementConnection_, this, 'STACK');
this.statementConnection_ = null;
} else {
// Save the stack, then disconnect it.
var stackConnection = this.getInput('STACK').connection;
this.statementConnection_ = stackConnection.targetConnection;
if (this.statementConnection_) {
var stackBlock = stackConnection.targetBlock();
stackBlock.setParent(null);
stackBlock.unplug();
stackBlock.bumpNeighbours_();
}
this.setStatements_(false);
@@ -448,15 +450,15 @@ Blockly.Blocks['procedures_callnoreturn'] = {
*/
init: function() {
this.appendDummyInput('TOPROW')
.appendField('', 'NAME');
.appendField(this.id, 'NAME');
this.setPreviousStatement(true);
this.setNextStatement(true);
this.setColour(Blockly.Blocks.procedures.HUE);
// Tooltip is set in domToMutation.
// Tooltip is set in renameProcedure.
this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLNORETURN_HELPURL);
this.arguments_ = [];
this.quarkConnections_ = {};
this.quarkArguments_ = null;
this.quarkIds_ = null;
},
/**
* Returns the name of the procedure this block calls.
@@ -489,74 +491,81 @@ Blockly.Blocks['procedures_callnoreturn'] = {
* @param {!Array.<string>} paramIds IDs of params (consistent for each
* parameter through the life of a mutator, regardless of param renaming),
* e.g. ['piua', 'f8b_', 'oi.o'].
* @private
* @this Blockly.Block
*/
setProcedureParameters: function(paramNames, paramIds) {
setProcedureParameters_: function(paramNames, paramIds) {
// Data structures:
// this.arguments = ['x', 'y']
// Existing param names.
// this.quarkConnections_ {piua: null, f8b_: Blockly.Connection}
// Look-up of paramIds to connections plugged into the call block.
// this.quarkArguments_ = ['piua', 'f8b_']
// this.quarkIds_ = ['piua', 'f8b_']
// Existing param IDs.
// Note that quarkConnections_ may include IDs that no longer exist, but
// which might reappear if a param is reattached in the mutator.
var defBlock = Blockly.Procedures.getDefinition(this.getProcedureCall(),
this.workspace);
var mutatorOpen = defBlock && defBlock.mutator &&
defBlock.mutator.isVisible();
if (!mutatorOpen) {
this.quarkConnections_ = {};
this.quarkIds_ = null;
}
if (!paramIds) {
// Reset the quarks (a mutator is about to open).
this.quarkConnections_ = {};
this.quarkArguments_ = null;
return;
}
if (goog.array.equals(this.arguments_, paramNames)) {
// No change.
this.quarkArguments_ = paramIds;
this.quarkIds_ = paramIds;
return;
}
this.setCollapsed(false);
if (paramIds.length != paramNames.length) {
throw 'Error: paramNames and paramIds must be the same length.';
}
if (!this.quarkArguments_) {
this.setCollapsed(false);
if (!this.quarkIds_) {
// Initialize tracking for this block.
this.quarkConnections_ = {};
if (paramNames.join('\n') == this.arguments_.join('\n')) {
// No change to the parameters, allow quarkConnections_ to be
// populated with the existing connections.
this.quarkArguments_ = paramIds;
this.quarkIds_ = paramIds;
} else {
this.quarkArguments_ = [];
this.quarkIds_ = [];
}
}
// Switch off rendering while the block is rebuilt.
var savedRendered = this.rendered;
this.rendered = false;
// Update the quarkConnections_ with existing connections.
for (var i = this.arguments_.length - 1; i >= 0; i--) {
for (var i = 0; i < this.arguments_.length; i++) {
var input = this.getInput('ARG' + i);
if (input) {
var connection = input.connection.targetConnection;
this.quarkConnections_[this.quarkArguments_[i]] = connection;
// Disconnect all argument blocks and remove all inputs.
this.removeInput('ARG' + i);
this.quarkConnections_[this.quarkIds_[i]] = connection;
if (mutatorOpen && connection &&
paramIds.indexOf(this.quarkIds_[i]) == -1) {
// This connection should no longer be attached to this block.
connection.disconnect();
connection.getSourceBlock().bumpNeighbours_();
}
}
}
// Rebuild the block's arguments.
this.arguments_ = [].concat(paramNames);
this.renderArgs_();
this.quarkArguments_ = paramIds;
this.updateShape_();
this.quarkIds_ = paramIds;
// Reconnect any child blocks.
if (this.quarkArguments_) {
if (this.quarkIds_) {
for (var i = 0; i < this.arguments_.length; i++) {
var input = this.getInput('ARG' + i);
var quarkName = this.quarkArguments_[i];
if (quarkName in this.quarkConnections_) {
var connection = this.quarkConnections_[quarkName];
if (!connection || connection.targetConnection ||
connection.sourceBlock_.workspace != this.workspace) {
var quarkId = this.quarkIds_[i];
if (quarkId in this.quarkConnections_) {
var connection = this.quarkConnections_[quarkId];
if (!Blockly.Mutator.reconnect(connection, this, 'ARG' + i)) {
// Block no longer exists or has been attached elsewhere.
delete this.quarkConnections_[quarkName];
} else {
input.connection.connect(connection);
delete this.quarkConnections_[quarkId];
}
}
}
@@ -568,28 +577,45 @@ Blockly.Blocks['procedures_callnoreturn'] = {
}
},
/**
* Render the arguments.
* @this Blockly.Block
* Modify this block to have the correct number of arguments.
* @private
* @this Blockly.Block
*/
renderArgs_: function() {
updateShape_: function() {
for (var i = 0; i < this.arguments_.length; i++) {
var input = this.appendValueInput('ARG' + i)
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(this.arguments_[i]);
input.init();
var field = this.getField('ARGNAME' + i);
if (field) {
// Ensure argument name is up to date.
// The argument name field is deterministic based on the mutation,
// no need to fire a change event.
Blockly.Events.disable();
field.setValue(this.arguments_[i]);
Blockly.Events.enable();
} else {
// Add new input.
field = new Blockly.FieldLabel(this.arguments_[i]);
var input = this.appendValueInput('ARG' + i)
.setAlign(Blockly.ALIGN_RIGHT)
.appendField(field, 'ARGNAME' + i);
input.init();
}
}
// Add 'with:' if there are parameters.
var input = this.getInput('TOPROW');
if (input) {
// Remove deleted inputs.
while (this.getInput('ARG' + i)) {
this.removeInput('ARG' + i);
i++;
}
// Add 'with:' if there are parameters, remove otherwise.
var topRow = this.getInput('TOPROW');
if (topRow) {
if (this.arguments_.length) {
if (!this.getField('WITH')) {
input.appendField(Blockly.Msg.PROCEDURES_CALL_BEFORE_PARAMS, 'WITH');
input.init();
topRow.appendField(Blockly.Msg.PROCEDURES_CALL_BEFORE_PARAMS, 'WITH');
topRow.init();
}
} else {
if (this.getField('WITH')) {
input.removeField('WITH');
topRow.removeField('WITH');
}
}
}
@@ -616,25 +642,16 @@ Blockly.Blocks['procedures_callnoreturn'] = {
*/
domToMutation: function(xmlElement) {
var name = xmlElement.getAttribute('name');
this.setFieldValue(name, 'NAME');
this.setTooltip(
(this.outputConnection ? Blockly.Msg.PROCEDURES_CALLRETURN_TOOLTIP :
Blockly.Msg.PROCEDURES_CALLNORETURN_TOOLTIP).replace('%1', name));
var def = Blockly.Procedures.getDefinition(name, this.workspace);
if (def && def.mutator && def.mutator.isVisible()) {
// Initialize caller with the mutator's IDs.
this.setProcedureParameters(def.arguments_, def.paramIds_);
} else {
var args = [];
for (var i = 0, childNode; childNode = xmlElement.childNodes[i]; i++) {
if (childNode.nodeName.toLowerCase() == 'arg') {
args.push(childNode.getAttribute('name'));
}
this.renameProcedure(this.getProcedureCall(), name);
var args = [];
var paramIds = [];
for (var i = 0, childNode; childNode = xmlElement.childNodes[i]; i++) {
if (childNode.nodeName.toLowerCase() == 'arg') {
args.push(childNode.getAttribute('name'));
paramIds.push(childNode.getAttribute('paramId'));
}
// For the second argument (paramIds) use the arguments list as a dummy
// list.
this.setProcedureParameters(args, args);
}
this.setProcedureParameters_(args, paramIds);
},
/**
* Notification that a variable is renaming.
@@ -647,7 +664,7 @@ Blockly.Blocks['procedures_callnoreturn'] = {
for (var i = 0; i < this.arguments_.length; i++) {
if (Blockly.Names.equals(oldName, this.arguments_[i])) {
this.arguments_[i] = newName;
this.getInput('ARG' + i).fieldRow[0].setValue(newName);
this.getField('ARGNAME' + i).setValue(newName);
}
}
},
@@ -683,13 +700,13 @@ Blockly.Blocks['procedures_callreturn'] = {
this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLRETURN_HELPURL);
this.arguments_ = [];
this.quarkConnections_ = {};
this.quarkArguments_ = null;
this.quarkIds_ = 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_,
setProcedureParameters_:
Blockly.Blocks['procedures_callnoreturn'].setProcedureParameters_,
updateShape_: Blockly.Blocks['procedures_callnoreturn'].updateShape_,
mutationToDom: Blockly.Blocks['procedures_callnoreturn'].mutationToDom,
domToMutation: Blockly.Blocks['procedures_callnoreturn'].domToMutation,
renameVar: Blockly.Blocks['procedures_callnoreturn'].renameVar,
+20 -41
View File
@@ -137,13 +137,18 @@ Blockly.Blocks['text_join'] = {
itemBlock = itemBlock.nextConnection &&
itemBlock.nextConnection.targetBlock();
}
// Disconnect any children that don't belong.
for (var i = 0; i < this.itemCount_; i++) {
var connection = this.getInput('ADD' + i).connection.targetConnection;
if (connection && connections.indexOf(connection) == -1) {
connection.disconnect();
}
}
this.itemCount_ = connections.length;
this.updateShape_();
// Reconnect any child blocks.
for (var i = 0; i < this.itemCount_; i++) {
if (connections[i]) {
this.getInput('ADD' + i).connection.connect(connections[i]);
}
Blockly.Mutator.reconnect(connections[i], this, 'ADD' + i);
}
},
/**
@@ -168,29 +173,27 @@ Blockly.Blocks['text_join'] = {
* @this Blockly.Block
*/
updateShape_: function() {
// Delete everything.
if (this.getInput('EMPTY')) {
if (this.itemCount_ && this.getInput('EMPTY')) {
this.removeInput('EMPTY');
} else {
var i = 0;
while (this.getInput('ADD' + i)) {
this.removeInput('ADD' + i);
i++;
}
}
// Rebuild block.
if (this.itemCount_ == 0) {
} else if (!this.itemCount_ && !this.getInput('EMPTY')) {
this.appendDummyInput('EMPTY')
.appendField(this.newQuote_(true))
.appendField(this.newQuote_(false));
} else {
for (var i = 0; i < this.itemCount_; i++) {
}
// Add new inputs.
for (var i = 0; i < this.itemCount_; i++) {
if (!this.getInput('ADD' + i)) {
var input = this.appendValueInput('ADD' + i);
if (i == 0) {
input.appendField(Blockly.Msg.TEXT_JOIN_TITLE_CREATEWITH);
}
}
}
// Remove deleted inputs.
while (this.getInput('ADD' + i)) {
this.removeInput('ADD' + i);
i++;
}
},
newQuote_: Blockly.Blocks['text'].newQuote_
};
@@ -247,26 +250,6 @@ Blockly.Blocks['text_append'] = {
return Blockly.Msg.TEXT_APPEND_TOOLTIP.replace('%1',
thisBlock.getFieldValue('VAR'));
});
},
/**
* Return all variables referenced by this block.
* @return {!Array.<string>} List of variable names.
* @this Blockly.Block
*/
getVars: function() {
return [this.getFieldValue('VAR')];
},
/**
* Notification that a variable is renaming.
* If the name matches one of this block's variables, rename it.
* @param {string} oldName Previous name of variable.
* @param {string} newName Renamed variable.
* @this Blockly.Block
*/
renameVar: function(oldName, newName) {
if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
this.setFieldValue(newName, 'VAR');
}
}
};
@@ -628,11 +611,7 @@ Blockly.Blocks['text_prompt_ext'] = {
* @this Blockly.Block
*/
updateType_: function(newOp) {
if (newOp == 'NUMBER') {
this.outputConnection.setCheck('Number');
} else {
this.outputConnection.setCheck('String');
}
this.outputConnection.setCheck(newOp == 'NUMBER' ? 'Number' : 'String');
},
/**
* Create XML to represent the output type.
-40
View File
@@ -49,26 +49,6 @@ Blockly.Blocks['variables_get'] = {
this.setTooltip(Blockly.Msg.VARIABLES_GET_TOOLTIP);
this.contextMenuMsg_ = Blockly.Msg.VARIABLES_GET_CREATE_SET;
},
/**
* Return all variables referenced by this block.
* @return {!Array.<string>} List of variable names.
* @this Blockly.Block
*/
getVars: function() {
return [this.getFieldValue('VAR')];
},
/**
* Notification that a variable is renaming.
* If the name matches one of this block's variables, rename it.
* @param {string} oldName Previous name of variable.
* @param {string} newName Renamed variable.
* @this Blockly.Block
*/
renameVar: function(oldName, newName) {
if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
this.setFieldValue(newName, 'VAR');
}
},
contextMenuType_: 'variables_set',
/**
* Add menu option to create getter/setter block for this setter/getter.
@@ -115,26 +95,6 @@ Blockly.Blocks['variables_set'] = {
});
this.contextMenuMsg_ = Blockly.Msg.VARIABLES_SET_CREATE_GET;
},
/**
* Return all variables referenced by this block.
* @return {!Array.<string>} List of variable names.
* @this Blockly.Block
*/
getVars: function() {
return [this.getFieldValue('VAR')];
},
/**
* Notification that a variable is renaming.
* If the name matches one of this block's variables, rename it.
* @param {string} oldName Previous name of variable.
* @param {string} newName Renamed variable.
* @this Blockly.Block
*/
renameVar: function(oldName, newName) {
if (Blockly.Names.equals(oldName, this.getFieldValue('VAR'))) {
this.setFieldValue(newName, 'VAR');
}
},
contextMenuType_: 'variables_get',
customContextMenu: Blockly.Blocks['variables_get'].customContextMenu
};
+41 -43
View File
@@ -10,9 +10,10 @@ 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.jsonInit({message0:Blockly.Msg.LISTS_CREATE_EMPTY_TITLE,output:"Array",colour:Blockly.Blocks.lists.HUE,tooltip:Blockly.Msg.LISTS_CREATE_EMPTY_TOOLTIP,helpUrl:Blockly.Msg.LISTS_CREATE_EMPTY_HELPURL})}};
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 a=document.createElement("mutation");a.setAttribute("items",this.itemCount_);return a},domToMutation:function(a){this.itemCount_=parseInt(a.getAttribute("items"),
10);this.updateShape_()},decompose:function(a){var b=a.newBlock("lists_create_with_container");b.initSvg();for(var c=b.getInput("STACK").connection,d=0;d<this.itemCount_;d++){var e=a.newBlock("lists_create_with_item");e.initSvg();c.connect(e.previousConnection);c=e.nextConnection}return b},compose:function(a){var b=a.getInputTargetBlock("STACK");for(a=[];b;)a.push(b.valueConnection_),b=b.nextConnection&&b.nextConnection.targetBlock();this.itemCount_=a.length;this.updateShape_();for(b=0;b<this.itemCount_;b++)a[b]&&
this.getInput("ADD"+b).connection.connect(a[b])},saveConnections:function(a){a=a.getInputTargetBlock("STACK");for(var b=0;a;){var c=this.getInput("ADD"+b);a.valueConnection_=c&&c.connection.targetConnection;b++;a=a.nextConnection&&a.nextConnection.targetBlock()}},updateShape_:function(){if(this.getInput("EMPTY"))this.removeInput("EMPTY");else for(var a=0;this.getInput("ADD"+a);)this.removeInput("ADD"+a),a++;if(0==this.itemCount_)this.appendDummyInput("EMPTY").appendField(Blockly.Msg.LISTS_CREATE_EMPTY_TITLE);
else for(a=0;a<this.itemCount_;a++){var b=this.appendValueInput("ADD"+a);0==a&&b.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}};
10);this.updateShape_()},decompose:function(a){var b=a.newBlock("lists_create_with_container");b.initSvg();for(var c=b.getInput("STACK").connection,d=0;d<this.itemCount_;d++){var e=a.newBlock("lists_create_with_item");e.initSvg();c.connect(e.previousConnection);c=e.nextConnection}return b},compose:function(a){var b=a.getInputTargetBlock("STACK");for(a=[];b;)a.push(b.valueConnection_),b=b.nextConnection&&b.nextConnection.targetBlock();for(b=0;b<this.itemCount_;b++){var c=this.getInput("ADD"+b).connection.targetConnection;
c&&-1==a.indexOf(c)&&c.disconnect()}this.itemCount_=a.length;this.updateShape_();for(b=0;b<this.itemCount_;b++)Blockly.Mutator.reconnect(a[b],this,"ADD"+b)},saveConnections:function(a){a=a.getInputTargetBlock("STACK");for(var b=0;a;){var c=this.getInput("ADD"+b);a.valueConnection_=c&&c.connection.targetConnection;b++;a=a.nextConnection&&a.nextConnection.targetBlock()}},updateShape_:function(){this.itemCount_&&this.getInput("EMPTY")?this.removeInput("EMPTY"):this.itemCount_||this.getInput("EMPTY")||
this.appendDummyInput("EMPTY").appendField(Blockly.Msg.LISTS_CREATE_EMPTY_TITLE);for(var a=0;a<this.itemCount_;a++)if(!this.getInput("ADD"+a)){var b=this.appendValueInput("ADD"+a);0==a&&b.appendField(Blockly.Msg.LISTS_CREATE_WITH_INPUT_WITH)}for(;this.getInput("ADD"+a);)this.removeInput("ADD"+a),a++}};
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.jsonInit({message0:Blockly.Msg.LISTS_REPEAT_TITLE,args0:[{type:"input_value",name:"ITEM"},{type:"input_value",name:"NUM",check:"Number"}],output:"Array",colour:Blockly.Blocks.lists.HUE,tooltip:Blockly.Msg.LISTS_REPEAT_TOOLTIP,helpUrl:Blockly.Msg.LISTS_REPEAT_HELPURL})}};
Blockly.Blocks.lists_length={init:function(){this.jsonInit({message0:Blockly.Msg.LISTS_LENGTH_TITLE,args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Number",colour:Blockly.Blocks.lists.HUE,tooltip:Blockly.Msg.LISTS_LENGTH_TOOLTIP,helpUrl:Blockly.Msg.LISTS_LENGTH_HELPURL})}};
@@ -36,30 +37,29 @@ this.setOutput(!0,"Array");this.setTooltip(function(){var b=a.getFieldValue("MOD
this.getFieldValue("MODE"));return a},domToMutation:function(a){this.updateType_(a.getAttribute("mode"))}};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 a=this;this.setTooltip(function(){if(a.elseifCount_||a.elseCount_){if(!a.elseifCount_&&
a.elseCount_)return Blockly.Msg.CONTROLS_IF_TOOLTIP_2;if(a.elseifCount_&&!a.elseCount_)return Blockly.Msg.CONTROLS_IF_TOOLTIP_3;if(a.elseifCount_&&a.elseCount_)return Blockly.Msg.CONTROLS_IF_TOOLTIP_4}else return Blockly.Msg.CONTROLS_IF_TOOLTIP_1;return""});this.elseCount_=this.elseifCount_=0},mutationToDom:function(){if(!this.elseifCount_&&!this.elseCount_)return null;var a=document.createElement("mutation");this.elseifCount_&&a.setAttribute("elseif",this.elseifCount_);this.elseCount_&&a.setAttribute("else",
1);return a},domToMutation:function(a){this.elseifCount_=parseInt(a.getAttribute("elseif"),10)||0;this.elseCount_=parseInt(a.getAttribute("else"),10)||0;for(a=1;a<=this.elseifCount_;a++)this.appendValueInput("IF"+a).setCheck("Boolean").appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSEIF),this.appendStatementInput("DO"+a).appendField(Blockly.Msg.CONTROLS_IF_MSG_THEN);this.elseCount_&&this.appendStatementInput("ELSE").appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSE)},decompose:function(a){var b=a.newBlock("controls_if_if");
b.initSvg();for(var c=b.nextConnection,d=1;d<=this.elseifCount_;d++){var e=a.newBlock("controls_if_elseif");e.initSvg();c.connect(e.previousConnection);c=e.nextConnection}this.elseCount_&&(a=a.newBlock("controls_if_else"),a.initSvg(),c.connect(a.previousConnection));return b},compose:function(a){this.elseCount_&&this.removeInput("ELSE");this.elseCount_=0;for(var b=this.elseifCount_;0<b;b--)this.removeInput("IF"+b),this.removeInput("DO"+b);this.elseifCount_=0;for(a=a.nextConnection.targetBlock();a;){switch(a.type){case "controls_if_elseif":this.elseifCount_++;
var b=this.appendValueInput("IF"+this.elseifCount_).setCheck("Boolean").appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSEIF),c=this.appendStatementInput("DO"+this.elseifCount_);c.appendField(Blockly.Msg.CONTROLS_IF_MSG_THEN);a.valueConnection_&&b.connection.connect(a.valueConnection_);a.statementConnection_&&c.connection.connect(a.statementConnection_);break;case "controls_if_else":this.elseCount_++;b=this.appendStatementInput("ELSE");b.appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSE);a.statementConnection_&&
b.connection.connect(a.statementConnection_);break;default:throw"Unknown block type.";}a=a.nextConnection&&a.nextConnection.targetBlock()}},saveConnections:function(a){a=a.nextConnection.targetBlock();for(var b=1;a;){switch(a.type){case "controls_if_elseif":var c=this.getInput("IF"+b),d=this.getInput("DO"+b);a.valueConnection_=c&&c.connection.targetConnection;a.statementConnection_=d&&d.connection.targetConnection;b++;break;case "controls_if_else":d=this.getInput("ELSE");a.statementConnection_=d&&
d.connection.targetConnection;break;default:throw"Unknown block type.";}a=a.nextConnection&&a.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.setNextStatement(!0);this.setTooltip(Blockly.Msg.CONTROLS_IF_IF_TOOLTIP);this.contextMenu=!1}};
1);return a},domToMutation:function(a){this.elseifCount_=parseInt(a.getAttribute("elseif"),10)||0;this.elseCount_=parseInt(a.getAttribute("else"),10)||0;this.updateShape_()},decompose:function(a){var b=a.newBlock("controls_if_if");b.initSvg();for(var c=b.nextConnection,d=1;d<=this.elseifCount_;d++){var e=a.newBlock("controls_if_elseif");e.initSvg();c.connect(e.previousConnection);c=e.nextConnection}this.elseCount_&&(a=a.newBlock("controls_if_else"),a.initSvg(),c.connect(a.previousConnection));return b},
compose:function(a){var b=a.nextConnection.targetBlock();this.elseCount_=this.elseifCount_=0;a=[null];for(var c=[null],d=null;b;){switch(b.type){case "controls_if_elseif":this.elseifCount_++;a.push(b.valueConnection_);c.push(b.statementConnection_);break;case "controls_if_else":this.elseCount_++;d=b.statementConnection_;break;default:throw"Unknown block type.";}b=b.nextConnection&&b.nextConnection.targetBlock()}this.updateShape_();for(b=1;b<=this.elseifCount_;b++)Blockly.Mutator.reconnect(a[b],this,
"IF"+b),Blockly.Mutator.reconnect(c[b],this,"DO"+b);Blockly.Mutator.reconnect(d,this,"ELSE")},saveConnections:function(a){a=a.nextConnection.targetBlock();for(var b=1;a;){switch(a.type){case "controls_if_elseif":var c=this.getInput("IF"+b),d=this.getInput("DO"+b);a.valueConnection_=c&&c.connection.targetConnection;a.statementConnection_=d&&d.connection.targetConnection;b++;break;case "controls_if_else":d=this.getInput("ELSE");a.statementConnection_=d&&d.connection.targetConnection;break;default:throw"Unknown block type.";
}a=a.nextConnection&&a.nextConnection.targetBlock()}},updateShape_:function(){this.getInput("ELSE")&&this.removeInput("ELSE");for(var a=1;this.getInput("IF"+a);)this.removeInput("IF"+a),this.removeInput("DO"+a),a++;for(a=1;a<=this.elseifCount_;a++)this.appendValueInput("IF"+a).setCheck("Boolean").appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSEIF),this.appendStatementInput("DO"+a).appendField(Blockly.Msg.CONTROLS_IF_MSG_THEN);this.elseCount_&&this.appendStatementInput("ELSE").appendField(Blockly.Msg.CONTROLS_IF_MSG_ELSE)}};
Blockly.Blocks.controls_if_if={init:function(){this.setColour(Blockly.Blocks.logic.HUE);this.appendDummyInput().appendField(Blockly.Msg.CONTROLS_IF_IF_TITLE_IF);this.setNextStatement(!0);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 a=this.RTL?[["=","EQ"],["\u2260","NEQ"],[">","LT"],["\u2265","LTE"],["<","GT"],["\u2264","GTE"]]:[["=","EQ"],["\u2260","NEQ"],["<","LT"],["\u2264","LTE"],[">","GT"],["\u2265","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(a),"OP");this.setInputsInline(!0);var b=this;this.setTooltip(function(){var a=
b.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}[a]});this.prevBlocks_=[null,null]},onchange:function(){var a=this.getInputTargetBlock("A"),b=this.getInputTargetBlock("B");if(a&&b&&!a.outputConnection.checkType_(b.outputConnection))for(var c=0;c<this.prevBlocks_.length;c++){var d=
this.prevBlocks_[c];if(d===a||d===b)d.setParent(null),d.bumpNeighbours_()}this.prevBlocks_[0]=a;this.prevBlocks_[1]=b}};
this.prevBlocks_[c];if(d===a||d===b)d.unplug(),d.bumpNeighbours_()}this.prevBlocks_[0]=a;this.prevBlocks_[1]=b}};
Blockly.Blocks.logic_operation={init:function(){var a=[[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(a),"OP");this.setInputsInline(!0);var b=this;this.setTooltip(function(){var a=b.getFieldValue("OP");return{AND:Blockly.Msg.LOGIC_OPERATION_TOOLTIP_AND,
OR:Blockly.Msg.LOGIC_OPERATION_TOOLTIP_OR}[a]})}};Blockly.Blocks.logic_negate={init:function(){this.jsonInit({message0:Blockly.Msg.LOGIC_NEGATE_TITLE,args0:[{type:"input_value",name:"BOOL",check:"Boolean"}],output:"Boolean",colour:Blockly.Blocks.logic.HUE,tooltip:Blockly.Msg.LOGIC_NEGATE_TOOLTIP,helpUrl:Blockly.Msg.LOGIC_NEGATE_HELPURL})}};
Blockly.Blocks.logic_boolean={init:function(){this.jsonInit({message0:"%1",args0:[{type:"field_dropdown",name:"BOOL",options:[[Blockly.Msg.LOGIC_BOOLEAN_TRUE,"TRUE"],[Blockly.Msg.LOGIC_BOOLEAN_FALSE,"FALSE"]]}],output:"Boolean",colour:Blockly.Blocks.logic.HUE,tooltip:Blockly.Msg.LOGIC_BOOLEAN_TOOLTIP,helpUrl:Blockly.Msg.LOGIC_BOOLEAN_HELPURL})}};
Blockly.Blocks.logic_null={init:function(){this.jsonInit({message0:Blockly.Msg.LOGIC_NULL,output:null,colour:Blockly.Blocks.logic.HUE,tooltip:Blockly.Msg.LOGIC_NULL_TOOLTIP,helpUrl:Blockly.Msg.LOGIC_NULL_HELPURL})}};
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(){var a=
this.getInputTargetBlock("THEN"),b=this.getInputTargetBlock("ELSE"),c=this.outputConnection.targetConnection;if((a||b)&&c)for(var d=0;2>d;d++){var e=1==d?a:b;e&&!e.outputConnection.checkType_(c)&&(c===this.prevParentConnection_?(this.setParent(null),c.sourceBlock_.bumpNeighbours_()):(e.setParent(null),e.bumpNeighbours_()))}this.prevParentConnection_=c}};Blockly.Blocks.loops={};Blockly.Blocks.loops.HUE=120;Blockly.Blocks.controls_repeat_ext={init:function(){this.jsonInit({message0:Blockly.Msg.CONTROLS_REPEAT_TITLE,args0:[{type:"input_value",name:"TIMES",check:"Number"}],previousStatement:null,nextStatement:null,colour:Blockly.Blocks.loops.HUE,tooltip:Blockly.Msg.CONTROLS_REPEAT_TOOLTIP,helpUrl:Blockly.Msg.CONTROLS_REPEAT_HELPURL});this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_REPEAT_INPUT_DO)}};
this.getInputTargetBlock("THEN"),b=this.getInputTargetBlock("ELSE"),c=this.outputConnection.targetConnection;if((a||b)&&c)for(var d=0;2>d;d++){var e=1==d?a:b;e&&!e.outputConnection.checkType_(c)&&(c===this.prevParentConnection_?(this.unplug(),c.getSourceBlock().bumpNeighbours_()):(e.unplug(),e.bumpNeighbours_()))}this.prevParentConnection_=c}};Blockly.Blocks.loops={};Blockly.Blocks.loops.HUE=120;Blockly.Blocks.controls_repeat_ext={init:function(){this.jsonInit({message0:Blockly.Msg.CONTROLS_REPEAT_TITLE,args0:[{type:"input_value",name:"TIMES",check:"Number"}],previousStatement:null,nextStatement:null,colour:Blockly.Blocks.loops.HUE,tooltip:Blockly.Msg.CONTROLS_REPEAT_TOOLTIP,helpUrl:Blockly.Msg.CONTROLS_REPEAT_HELPURL});this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_REPEAT_INPUT_DO)}};
Blockly.Blocks.controls_repeat={init:function(){this.jsonInit({message0:Blockly.Msg.CONTROLS_REPEAT_TITLE,args0:[{type:"field_input",name:"TIMES",text:"10"}],previousStatement:null,nextStatement:null,colour:Blockly.Blocks.loops.HUE,tooltip:Blockly.Msg.CONTROLS_REPEAT_TOOLTIP,helpUrl:Blockly.Msg.CONTROLS_REPEAT_HELPURL});this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_REPEAT_INPUT_DO);this.getField("TIMES").setValidator(Blockly.FieldTextInput.nonnegativeIntegerValidator)}};
Blockly.Blocks.controls_whileUntil={init:function(){var a=[[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(a),"MODE");this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_WHILEUNTIL_INPUT_DO);this.setPreviousStatement(!0);this.setNextStatement(!0);
var b=this;this.setTooltip(function(){var a=b.getFieldValue("MODE");return{WHILE:Blockly.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_WHILE,UNTIL:Blockly.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL}[a]})}};
Blockly.Blocks.controls_for={init:function(){this.jsonInit({message0:Blockly.Msg.CONTROLS_FOR_TITLE,args0:[{type:"field_variable",name:"VAR",variable:null},{type:"input_value",name:"FROM",check:"Number",align:"RIGHT"},{type:"input_value",name:"TO",check:"Number",align:"RIGHT"},{type:"input_value",name:"BY",check:"Number",align:"RIGHT"}],inputsInline:!0,previousStatement:null,nextStatement:null,colour:Blockly.Blocks.loops.HUE,helpUrl:Blockly.Msg.CONTROLS_FOR_HELPURL});this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_FOR_INPUT_DO);
var a=this;this.setTooltip(function(){return Blockly.Msg.CONTROLS_FOR_TOOLTIP.replace("%1",a.getFieldValue("VAR"))})},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(a,b){Blockly.Names.equals(a,this.getFieldValue("VAR"))&&this.setFieldValue(b,"VAR")},customContextMenu:function(a){if(!this.isCollapsed()){var b={enabled:!0},c=this.getFieldValue("VAR");b.text=Blockly.Msg.VARIABLES_SET_CREATE_GET.replace("%1",c);c=goog.dom.createDom("field",null,c);c.setAttribute("name","VAR");
c=goog.dom.createDom("block",null,c);c.setAttribute("type","variables_get");b.callback=Blockly.ContextMenu.callbackFactory(this,c);a.push(b)}}};
var a=this;this.setTooltip(function(){return Blockly.Msg.CONTROLS_FOR_TOOLTIP.replace("%1",a.getFieldValue("VAR"))})},customContextMenu:function(a){if(!this.isCollapsed()){var b={enabled:!0},c=this.getFieldValue("VAR");b.text=Blockly.Msg.VARIABLES_SET_CREATE_GET.replace("%1",c);c=goog.dom.createDom("field",null,c);c.setAttribute("name","VAR");c=goog.dom.createDom("block",null,c);c.setAttribute("type","variables_get");b.callback=Blockly.ContextMenu.callbackFactory(this,c);a.push(b)}}};
Blockly.Blocks.controls_forEach={init:function(){this.jsonInit({message0:Blockly.Msg.CONTROLS_FOREACH_TITLE,args0:[{type:"field_variable",name:"VAR",variable:null},{type:"input_value",name:"LIST",check:"Array"}],previousStatement:null,nextStatement:null,colour:Blockly.Blocks.loops.HUE,helpUrl:Blockly.Msg.CONTROLS_FOREACH_HELPURL});this.appendStatementInput("DO").appendField(Blockly.Msg.CONTROLS_FOREACH_INPUT_DO);var a=this;this.setTooltip(function(){return Blockly.Msg.CONTROLS_FOREACH_TOOLTIP.replace("%1",
a.getFieldValue("VAR"))})},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(a,b){Blockly.Names.equals(a,this.getFieldValue("VAR"))&&this.setFieldValue(b,"VAR")},customContextMenu:Blockly.Blocks.controls_for.customContextMenu};
a.getFieldValue("VAR"))})},customContextMenu:Blockly.Blocks.controls_for.customContextMenu};
Blockly.Blocks.controls_flow_statements={init:function(){var a=[[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(a),"FLOW");this.setPreviousStatement(!0);var b=this;this.setTooltip(function(){var a=b.getFieldValue("FLOW");return{BREAK:Blockly.Msg.CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK,
CONTINUE:Blockly.Msg.CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE}[a]})},onchange:function(){var a=!1,b=this;do{if(-1!=this.LOOP_TYPES.indexOf(b.type)){a=!0;break}b=b.getSurroundParent()}while(b);a?this.setWarningText(null):this.setWarningText(Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING)},LOOP_TYPES:["controls_repeat","controls_repeat_ext","controls_forEach","controls_for","controls_whileUntil"]};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");var a=this;this.setTooltip(function(){var b=a.getParent();return b&&b.tooltip||Blockly.Msg.MATH_NUMBER_TOOLTIP})}};
Blockly.Blocks.math_arithmetic={init:function(){var a=[[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(a),
@@ -71,9 +71,7 @@ b.getFieldValue("OP");return{SIN:Blockly.Msg.MATH_TRIG_TOOLTIP_SIN,COS:Blockly.M
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([["\u03c0","PI"],["e","E"],["\u03c6","GOLDEN_RATIO"],["sqrt(2)","SQRT2"],["sqrt(\u00bd)","SQRT1_2"],["\u221e","INFINITY"]]),"CONSTANT");this.setTooltip(Blockly.Msg.MATH_CONSTANT_TOOLTIP)}};
Blockly.Blocks.math_number_property={init:function(){var a=[[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");a=new Blockly.FieldDropdown(a,function(a){this.sourceBlock_.updateShape_("DIVISIBLE_BY"==
a)});this.appendDummyInput().appendField(a,"PROPERTY");this.setInputsInline(!0);this.setOutput(!0,"Boolean");this.setTooltip(Blockly.Msg.MATH_IS_TOOLTIP)},mutationToDom:function(){var a=document.createElement("mutation"),b="DIVISIBLE_BY"==this.getFieldValue("PROPERTY");a.setAttribute("divisor_input",b);return a},domToMutation:function(a){a="true"==a.getAttribute("divisor_input");this.updateShape_(a)},updateShape_:function(a){var b=this.getInput("DIVISOR");a?b||this.appendValueInput("DIVISOR").setCheck("Number"):
b&&this.removeInput("DIVISOR")}};
Blockly.Blocks.math_change={init:function(){this.jsonInit({message0:Blockly.Msg.MATH_CHANGE_TITLE,args0:[{type:"field_variable",name:"VAR",variable:Blockly.Msg.MATH_CHANGE_TITLE_ITEM},{type:"input_value",name:"DELTA",check:"Number"}],previousStatement:null,nextStatement:null,colour:Blockly.Blocks.math.HUE,helpUrl:Blockly.Msg.MATH_CHANGE_HELPURL});var a=this;this.setTooltip(function(){return Blockly.Msg.MATH_CHANGE_TOOLTIP.replace("%1",a.getFieldValue("VAR"))})},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(a,
b){Blockly.Names.equals(a,this.getFieldValue("VAR"))&&this.setFieldValue(b,"VAR")}};
b&&this.removeInput("DIVISOR")}};Blockly.Blocks.math_change={init:function(){this.jsonInit({message0:Blockly.Msg.MATH_CHANGE_TITLE,args0:[{type:"field_variable",name:"VAR",variable:Blockly.Msg.MATH_CHANGE_TITLE_ITEM},{type:"input_value",name:"DELTA",check:"Number"}],previousStatement:null,nextStatement:null,colour:Blockly.Blocks.math.HUE,helpUrl:Blockly.Msg.MATH_CHANGE_HELPURL});var a=this;this.setTooltip(function(){return Blockly.Msg.MATH_CHANGE_TOOLTIP.replace("%1",a.getFieldValue("VAR"))})}};
Blockly.Blocks.math_round={init:function(){var a=[[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(a),"OP");this.setTooltip(Blockly.Msg.MATH_ROUND_TOOLTIP)}};
Blockly.Blocks.math_on_list={init:function(){var a=[[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"]],b=this;this.setHelpUrl(Blockly.Msg.MATH_ONLIST_HELPURL);this.setColour(Blockly.Blocks.math.HUE);
this.setOutput(!0,"Number");a=new Blockly.FieldDropdown(a,function(a){b.updateType_(a)});this.appendValueInput("LIST").setCheck("Array").appendField(a,"OP");this.setTooltip(function(){var a=b.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,
@@ -84,40 +82,41 @@ Blockly.Blocks.math_random_int={init:function(){this.jsonInit({message0:Blockly.
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(){var a=new Blockly.FieldTextInput(Blockly.Msg.PROCEDURES_DEFNORETURN_PROCEDURE,Blockly.Procedures.rename);a.setSpellcheck(!1);this.appendDummyInput().appendField(Blockly.Msg.PROCEDURES_DEFNORETURN_TITLE).appendField(a,"NAME").appendField("","PARAMS");this.setMutator(new Blockly.Mutator(["procedures_mutatorarg"]));Blockly.Msg.PROCEDURES_DEFNORETURN_COMMENT&&this.setCommentText(Blockly.Msg.PROCEDURES_DEFNORETURN_COMMENT);this.setColour(Blockly.Blocks.procedures.HUE);
this.setTooltip(Blockly.Msg.PROCEDURES_DEFNORETURN_TOOLTIP);this.setHelpUrl(Blockly.Msg.PROCEDURES_DEFNORETURN_HELPURL);this.arguments_=[];this.setStatements_(!0);this.statementConnection_=null},validate:function(){var a=Blockly.Procedures.findLegalName(this.getFieldValue("NAME"),this);this.setFieldValue(a,"NAME")},setStatements_:function(a){this.hasStatements_!==a&&(a?(this.appendStatementInput("STACK").appendField(Blockly.Msg.PROCEDURES_DEFNORETURN_DO),this.getInput("RETURN")&&this.moveInputBefore("STACK",
"RETURN")):this.removeInput("STACK",!0),this.hasStatements_=a)},updateParams_:function(){for(var a=!1,b={},c=0;c<this.arguments_.length;c++){if(b["arg_"+this.arguments_[c].toLowerCase()]){a=!0;break}b["arg_"+this.arguments_[c].toLowerCase()]=!0}a?this.setWarningText(Blockly.Msg.PROCEDURES_DEF_DUPLICATE_WARNING):this.setWarningText(null);a="";this.arguments_.length&&(a=Blockly.Msg.PROCEDURES_BEFORE_PARAMS+" "+this.arguments_.join(", "));this.setFieldValue(a,"PARAMS")},mutationToDom:function(){for(var a=
document.createElement("mutation"),b=0;b<this.arguments_.length;b++){var c=document.createElement("arg");c.setAttribute("name",this.arguments_[b]);a.appendChild(c)}this.hasStatements_||a.setAttribute("statements","false");return a},domToMutation:function(a){this.arguments_=[];for(var b=0,c;c=a.childNodes[b];b++)"arg"==c.nodeName.toLowerCase()&&this.arguments_.push(c.getAttribute("name"));this.updateParams_();this.setStatements_("false"!==a.getAttribute("statements"))},decompose:function(a){var b=
a.newBlock("procedures_mutatorcontainer");b.initSvg();this.getInput("RETURN")?b.setFieldValue(this.hasStatements_?"TRUE":"FALSE","STATEMENTS"):b.getInput("STATEMENT_INPUT").setVisible(!1);for(var c=b.getInput("STACK").connection,d=0;d<this.arguments_.length;d++){var e=a.newBlock("procedures_mutatorarg");e.initSvg();e.setFieldValue(this.arguments_[d],"NAME");e.oldLocation=d;c.connect(e.previousConnection);c=e.nextConnection}Blockly.Procedures.mutateCallers(this.getFieldValue("NAME"),this.workspace,
this.arguments_,null);return b},compose:function(a){this.arguments_=[];this.paramIds_=[];for(var b=a.getInputTargetBlock("STACK");b;)this.arguments_.push(b.getFieldValue("NAME")),this.paramIds_.push(b.id),b=b.nextConnection&&b.nextConnection.targetBlock();this.updateParams_();Blockly.Procedures.mutateCallers(this.getFieldValue("NAME"),this.workspace,this.arguments_,this.paramIds_);a=a.getFieldValue("STATEMENTS");if(null!==a&&(a="TRUE"==a,this.hasStatements_!=a))if(a)this.setStatements_(!0),a=this.getInput("STACK").connection,
a.targetConnection||!this.statementConnection_||this.statementConnection_.targetConnection||this.statementConnection_.sourceBlock_.workspace!=this.workspace?this.statementConnection_=null:a.connect(this.statementConnection_);else{a=this.getInput("STACK").connection;if(this.statementConnection_=a.targetConnection)a=a.targetBlock(),a.setParent(null),a.bumpNeighbours_();this.setStatements_(!1)}},dispose:function(){var a=this.getFieldValue("NAME");Blockly.Procedures.disposeCallers(a,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(a,b){for(var c=!1,d=0;d<this.arguments_.length;d++)Blockly.Names.equals(a,this.arguments_[d])&&(this.arguments_[d]=b,c=!0);if(c&&(this.updateParams_(),this.mutator.isVisible()))for(var c=this.mutator.workspace_.getAllBlocks(),d=0,e;e=c[d];d++)"procedures_mutatorarg"==e.type&&Blockly.Names.equals(a,e.getFieldValue("NAME"))&&e.setFieldValue(b,"NAME")},
customContextMenu:function(a){var b={enabled:!0},c=this.getFieldValue("NAME");b.text=Blockly.Msg.PROCEDURES_CREATE_DO.replace("%1",c);var d=goog.dom.createDom("mutation");d.setAttribute("name",c);for(var e=0;e<this.arguments_.length;e++)c=goog.dom.createDom("arg"),c.setAttribute("name",this.arguments_[e]),d.appendChild(c);d=goog.dom.createDom("block",null,d);d.setAttribute("type",this.callType_);b.callback=Blockly.ContextMenu.callbackFactory(this,d);a.push(b);if(!this.isCollapsed())for(e=0;e<this.arguments_.length;e++)b=
{enabled:!0},c=this.arguments_[e],b.text=Blockly.Msg.VARIABLES_SET_CREATE_GET.replace("%1",c),d=goog.dom.createDom("field",null,c),d.setAttribute("name","VAR"),d=goog.dom.createDom("block",null,d),d.setAttribute("type","variables_get"),b.callback=Blockly.ContextMenu.callbackFactory(this,d),a.push(b)},callType_:"procedures_callnoreturn"};
"RETURN")):this.removeInput("STACK",!0),this.hasStatements_=a)},updateParams_:function(){for(var a=!1,b={},c=0;c<this.arguments_.length;c++){if(b["arg_"+this.arguments_[c].toLowerCase()]){a=!0;break}b["arg_"+this.arguments_[c].toLowerCase()]=!0}a?this.setWarningText(Blockly.Msg.PROCEDURES_DEF_DUPLICATE_WARNING):this.setWarningText(null);a="";this.arguments_.length&&(a=Blockly.Msg.PROCEDURES_BEFORE_PARAMS+" "+this.arguments_.join(", "));Blockly.Events.disable();this.setFieldValue(a,"PARAMS");Blockly.Events.enable()},
mutationToDom:function(a){var b=document.createElement("mutation");a&&b.setAttribute("name",this.getFieldValue("NAME"));for(var c=0;c<this.arguments_.length;c++){var d=document.createElement("arg");d.setAttribute("name",this.arguments_[c]);a&&this.paramIds_&&d.setAttribute("paramId",this.paramIds_[c]);b.appendChild(d)}this.hasStatements_||b.setAttribute("statements","false");return b},domToMutation:function(a){this.arguments_=[];for(var b=0,c;c=a.childNodes[b];b++)"arg"==c.nodeName.toLowerCase()&&
this.arguments_.push(c.getAttribute("name"));this.updateParams_();Blockly.Procedures.mutateCallers(this);this.setStatements_("false"!==a.getAttribute("statements"))},decompose:function(a){var b=a.newBlock("procedures_mutatorcontainer");b.initSvg();this.getInput("RETURN")?b.setFieldValue(this.hasStatements_?"TRUE":"FALSE","STATEMENTS"):b.getInput("STATEMENT_INPUT").setVisible(!1);for(var c=b.getInput("STACK").connection,d=0;d<this.arguments_.length;d++){var e=a.newBlock("procedures_mutatorarg");e.initSvg();
e.setFieldValue(this.arguments_[d],"NAME");e.oldLocation=d;c.connect(e.previousConnection);c=e.nextConnection}Blockly.Procedures.mutateCallers(this);return b},compose:function(a){this.arguments_=[];this.paramIds_=[];for(var b=a.getInputTargetBlock("STACK");b;)this.arguments_.push(b.getFieldValue("NAME")),this.paramIds_.push(b.id),b=b.nextConnection&&b.nextConnection.targetBlock();this.updateParams_();Blockly.Procedures.mutateCallers(this);a=a.getFieldValue("STATEMENTS");if(null!==a&&(a="TRUE"==a,
this.hasStatements_!=a))if(a)this.setStatements_(!0),Blockly.Mutator.reconnect(this.statementConnection_,this,"STACK"),this.statementConnection_=null;else{a=this.getInput("STACK").connection;if(this.statementConnection_=a.targetConnection)a=a.targetBlock(),a.unplug(),a.bumpNeighbours_();this.setStatements_(!1)}},dispose:function(){var a=this.getFieldValue("NAME");Blockly.Procedures.disposeCallers(a,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(a,b){for(var c=!1,d=0;d<this.arguments_.length;d++)Blockly.Names.equals(a,this.arguments_[d])&&(this.arguments_[d]=b,c=!0);if(c&&(this.updateParams_(),this.mutator.isVisible()))for(var c=this.mutator.workspace_.getAllBlocks(),d=0,e;e=c[d];d++)"procedures_mutatorarg"==e.type&&Blockly.Names.equals(a,e.getFieldValue("NAME"))&&e.setFieldValue(b,"NAME")},customContextMenu:function(a){var b={enabled:!0},c=this.getFieldValue("NAME");
b.text=Blockly.Msg.PROCEDURES_CREATE_DO.replace("%1",c);var d=goog.dom.createDom("mutation");d.setAttribute("name",c);for(var e=0;e<this.arguments_.length;e++)c=goog.dom.createDom("arg"),c.setAttribute("name",this.arguments_[e]),d.appendChild(c);d=goog.dom.createDom("block",null,d);d.setAttribute("type",this.callType_);b.callback=Blockly.ContextMenu.callbackFactory(this,d);a.push(b);if(!this.isCollapsed())for(e=0;e<this.arguments_.length;e++)b={enabled:!0},c=this.arguments_[e],b.text=Blockly.Msg.VARIABLES_SET_CREATE_GET.replace("%1",
c),d=goog.dom.createDom("field",null,c),d.setAttribute("name","VAR"),d=goog.dom.createDom("block",null,d),d.setAttribute("type","variables_get"),b.callback=Blockly.ContextMenu.callbackFactory(this,d),a.push(b)},callType_:"procedures_callnoreturn"};
Blockly.Blocks.procedures_defreturn={init:function(){var a=new Blockly.FieldTextInput(Blockly.Msg.PROCEDURES_DEFRETURN_PROCEDURE,Blockly.Procedures.rename);a.setSpellcheck(!1);this.appendDummyInput().appendField(Blockly.Msg.PROCEDURES_DEFRETURN_TITLE).appendField(a,"NAME").appendField("","PARAMS");this.appendValueInput("RETURN").setAlign(Blockly.ALIGN_RIGHT).appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN);this.setMutator(new Blockly.Mutator(["procedures_mutatorarg"]));Blockly.Msg.PROCEDURES_DEFRETURN_COMMENT&&
this.setCommentText(Blockly.Msg.PROCEDURES_DEFRETURN_COMMENT);this.setColour(Blockly.Blocks.procedures.HUE);this.setTooltip(Blockly.Msg.PROCEDURES_DEFRETURN_TOOLTIP);this.setHelpUrl(Blockly.Msg.PROCEDURES_DEFRETURN_HELPURL);this.arguments_=[];this.setStatements_(!0);this.statementConnection_=null},setStatements_:Blockly.Blocks.procedures_defnoreturn.setStatements_,validate:Blockly.Blocks.procedures_defnoreturn.validate,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.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.setColour(Blockly.Blocks.procedures.HUE);this.setTooltip(Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP);this.contextMenu=!1}};
Blockly.Blocks.procedures_mutatorarg={init:function(){this.appendDummyInput().appendField(Blockly.Msg.PROCEDURES_MUTATORARG_TITLE).appendField(new Blockly.FieldTextInput("x",this.validator_),"NAME");this.setPreviousStatement(!0);this.setNextStatement(!0);this.setColour(Blockly.Blocks.procedures.HUE);this.setTooltip(Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP);this.contextMenu=!1},validator_:function(a){return(a=a.replace(/[\s\xa0]+/g," ").replace(/^ | $/g,""))||null}};
Blockly.Blocks.procedures_callnoreturn={init:function(){this.appendDummyInput("TOPROW").appendField("","NAME");this.setPreviousStatement(!0);this.setNextStatement(!0);this.setColour(Blockly.Blocks.procedures.HUE);this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLNORETURN_HELPURL);this.arguments_=[];this.quarkConnections_={};this.quarkArguments_=null},getProcedureCall:function(){return this.getFieldValue("NAME")},renameProcedure:function(a,b){Blockly.Names.equals(a,this.getProcedureCall())&&(this.setFieldValue(b,
"NAME"),this.setTooltip((this.outputConnection?Blockly.Msg.PROCEDURES_CALLRETURN_TOOLTIP:Blockly.Msg.PROCEDURES_CALLNORETURN_TOOLTIP).replace("%1",b)))},setProcedureParameters:function(a,b){if(b)if(goog.array.equals(this.arguments_,a))this.quarkArguments_=b;else{this.setCollapsed(!1);if(b.length!=a.length)throw"Error: paramNames and paramIds must be the same length.";this.quarkArguments_||(this.quarkConnections_={},a.join("\n")==this.arguments_.join("\n")?this.quarkArguments_=b:this.quarkArguments_=
[]);var c=this.rendered;this.rendered=!1;for(var d=this.arguments_.length-1;0<=d;d--){var e=this.getInput("ARG"+d);if(e){var f=e.connection.targetConnection;this.quarkConnections_[this.quarkArguments_[d]]=f;this.removeInput("ARG"+d)}}this.arguments_=[].concat(a);this.renderArgs_();if(this.quarkArguments_=b)for(d=0;d<this.arguments_.length;d++){var e=this.getInput("ARG"+d),g=this.quarkArguments_[d];g in this.quarkConnections_&&(f=this.quarkConnections_[g],!f||f.targetConnection||f.sourceBlock_.workspace!=
this.workspace?delete this.quarkConnections_[g]:e.connection.connect(f))}(this.rendered=c)&&this.render()}else this.quarkConnections_={},this.quarkArguments_=null},renderArgs_:function(){for(var a=0;a<this.arguments_.length;a++){var b=this.appendValueInput("ARG"+a).setAlign(Blockly.ALIGN_RIGHT).appendField(this.arguments_[a]);b.init()}if(b=this.getInput("TOPROW"))this.arguments_.length?this.getField("WITH")||(b.appendField(Blockly.Msg.PROCEDURES_CALL_BEFORE_PARAMS,"WITH"),b.init()):this.getField("WITH")&&
b.removeField("WITH")},mutationToDom:function(){var a=document.createElement("mutation");a.setAttribute("name",this.getProcedureCall());for(var b=0;b<this.arguments_.length;b++){var c=document.createElement("arg");c.setAttribute("name",this.arguments_[b]);a.appendChild(c)}return a},domToMutation:function(a){var b=a.getAttribute("name");this.setFieldValue(b,"NAME");this.setTooltip((this.outputConnection?Blockly.Msg.PROCEDURES_CALLRETURN_TOOLTIP:Blockly.Msg.PROCEDURES_CALLNORETURN_TOOLTIP).replace("%1",
b));if((b=Blockly.Procedures.getDefinition(b,this.workspace))&&b.mutator&&b.mutator.isVisible())this.setProcedureParameters(b.arguments_,b.paramIds_);else{for(var b=[],c=0,d;d=a.childNodes[c];c++)"arg"==d.nodeName.toLowerCase()&&b.push(d.getAttribute("name"));this.setProcedureParameters(b,b)}},renameVar:function(a,b){for(var c=0;c<this.arguments_.length;c++)Blockly.Names.equals(a,this.arguments_[c])&&(this.arguments_[c]=b,this.getInput("ARG"+c).fieldRow[0].setValue(b))},customContextMenu:function(a){var b=
{enabled:!0};b.text=Blockly.Msg.PROCEDURES_HIGHLIGHT_DEF;var c=this.getProcedureCall(),d=this.workspace;b.callback=function(){var a=Blockly.Procedures.getDefinition(c,d);a&&a.select()};a.push(b)}};
Blockly.Blocks.procedures_callreturn={init:function(){this.appendDummyInput("TOPROW").appendField("","NAME");this.setOutput(!0);this.setColour(Blockly.Blocks.procedures.HUE);this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLRETURN_HELPURL);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_callnoreturn={init:function(){this.appendDummyInput("TOPROW").appendField(this.id,"NAME");this.setPreviousStatement(!0);this.setNextStatement(!0);this.setColour(Blockly.Blocks.procedures.HUE);this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLNORETURN_HELPURL);this.arguments_=[];this.quarkConnections_={};this.quarkIds_=null},getProcedureCall:function(){return this.getFieldValue("NAME")},renameProcedure:function(a,b){Blockly.Names.equals(a,this.getProcedureCall())&&(this.setFieldValue(b,
"NAME"),this.setTooltip((this.outputConnection?Blockly.Msg.PROCEDURES_CALLRETURN_TOOLTIP:Blockly.Msg.PROCEDURES_CALLNORETURN_TOOLTIP).replace("%1",b)))},setProcedureParameters_:function(a,b){var c=Blockly.Procedures.getDefinition(this.getProcedureCall(),this.workspace),d=c&&c.mutator&&c.mutator.isVisible();d||(this.quarkConnections_={},this.quarkIds_=null);if(b)if(goog.array.equals(this.arguments_,a))this.quarkIds_=b;else{if(b.length!=a.length)throw"Error: paramNames and paramIds must be the same length.";
this.setCollapsed(!1);this.quarkIds_||(this.quarkConnections_={},a.join("\n")==this.arguments_.join("\n")?this.quarkIds_=b:this.quarkIds_=[]);c=this.rendered;this.rendered=!1;for(var e=0;e<this.arguments_.length;e++){var f=this.getInput("ARG"+e);f&&(f=f.connection.targetConnection,this.quarkConnections_[this.quarkIds_[e]]=f,d&&f&&-1==b.indexOf(this.quarkIds_[e])&&(f.disconnect(),f.getSourceBlock().bumpNeighbours_()))}this.arguments_=[].concat(a);this.updateShape_();if(this.quarkIds_=b)for(e=0;e<this.arguments_.length;e++)d=
this.quarkIds_[e],d in this.quarkConnections_&&(f=this.quarkConnections_[d],Blockly.Mutator.reconnect(f,this,"ARG"+e)||delete this.quarkConnections_[d]);(this.rendered=c)&&this.render()}},updateShape_:function(){for(var a=0;a<this.arguments_.length;a++){var b=this.getField("ARGNAME"+a);b?(Blockly.Events.disable(),b.setValue(this.arguments_[a]),Blockly.Events.enable()):(b=new Blockly.FieldLabel(this.arguments_[a]),this.appendValueInput("ARG"+a).setAlign(Blockly.ALIGN_RIGHT).appendField(b,"ARGNAME"+
a).init())}for(;this.getInput("ARG"+a);)this.removeInput("ARG"+a),a++;if(a=this.getInput("TOPROW"))this.arguments_.length?this.getField("WITH")||(a.appendField(Blockly.Msg.PROCEDURES_CALL_BEFORE_PARAMS,"WITH"),a.init()):this.getField("WITH")&&a.removeField("WITH")},mutationToDom:function(){var a=document.createElement("mutation");a.setAttribute("name",this.getProcedureCall());for(var b=0;b<this.arguments_.length;b++){var c=document.createElement("arg");c.setAttribute("name",this.arguments_[b]);a.appendChild(c)}return a},
domToMutation:function(a){var b=a.getAttribute("name");this.renameProcedure(this.getProcedureCall(),b);for(var b=[],c=[],d=0,e;e=a.childNodes[d];d++)"arg"==e.nodeName.toLowerCase()&&(b.push(e.getAttribute("name")),c.push(e.getAttribute("paramId")));this.setProcedureParameters_(b,c)},renameVar:function(a,b){for(var c=0;c<this.arguments_.length;c++)Blockly.Names.equals(a,this.arguments_[c])&&(this.arguments_[c]=b,this.getField("ARGNAME"+c).setValue(b))},customContextMenu:function(a){var b={enabled:!0};
b.text=Blockly.Msg.PROCEDURES_HIGHLIGHT_DEF;var c=this.getProcedureCall(),d=this.workspace;b.callback=function(){var a=Blockly.Procedures.getDefinition(c,d);a&&a.select()};a.push(b)}};
Blockly.Blocks.procedures_callreturn={init:function(){this.appendDummyInput("TOPROW").appendField("","NAME");this.setOutput(!0);this.setColour(Blockly.Blocks.procedures.HUE);this.setHelpUrl(Blockly.Msg.PROCEDURES_CALLRETURN_HELPURL);this.arguments_=[];this.quarkConnections_={};this.quarkIds_=null},getProcedureCall:Blockly.Blocks.procedures_callnoreturn.getProcedureCall,renameProcedure:Blockly.Blocks.procedures_callnoreturn.renameProcedure,setProcedureParameters_:Blockly.Blocks.procedures_callnoreturn.setProcedureParameters_,
updateShape_:Blockly.Blocks.procedures_callnoreturn.updateShape_,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.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.setColour(Blockly.Blocks.procedures.HUE);this.setTooltip(Blockly.Msg.PROCEDURES_IFRETURN_TOOLTIP);this.setHelpUrl(Blockly.Msg.PROCEDURES_IFRETURN_HELPURL);this.hasReturnValue_=!0},
mutationToDom:function(){var a=document.createElement("mutation");a.setAttribute("value",Number(this.hasReturnValue_));return a},domToMutation:function(a){this.hasReturnValue_=1==a.getAttribute("value");this.hasReturnValue_||(this.removeInput("VALUE"),this.appendDummyInput("VALUE").appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN))},onchange:function(){var a=!1,b=this;do{if(-1!=this.FUNCTION_TYPES.indexOf(b.type)){a=!0;break}b=b.getSurroundParent()}while(b);a?("procedures_defnoreturn"==b.type&&
this.hasReturnValue_?(this.removeInput("VALUE"),this.appendDummyInput("VALUE").appendField(Blockly.Msg.PROCEDURES_DEFRETURN_RETURN),this.hasReturnValue_=!1):"procedures_defreturn"!=b.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)},FUNCTION_TYPES:["procedures_defnoreturn","procedures_defreturn"]};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");var a=this;this.setTooltip(function(){var b=a.getParent();return b&&b.tooltip||Blockly.Msg.TEXT_TEXT_TOOLTIP})},newQuote_:function(a){return new Blockly.FieldImage(a==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 a=document.createElement("mutation");a.setAttribute("items",this.itemCount_);return a},domToMutation:function(a){this.itemCount_=parseInt(a.getAttribute("items"),10);
this.updateShape_()},decompose:function(a){var b=a.newBlock("text_create_join_container");b.initSvg();for(var c=b.getInput("STACK").connection,d=0;d<this.itemCount_;d++){var e=a.newBlock("text_create_join_item");e.initSvg();c.connect(e.previousConnection);c=e.nextConnection}return b},compose:function(a){var b=a.getInputTargetBlock("STACK");for(a=[];b;)a.push(b.valueConnection_),b=b.nextConnection&&b.nextConnection.targetBlock();this.itemCount_=a.length;this.updateShape_();for(b=0;b<this.itemCount_;b++)a[b]&&
this.getInput("ADD"+b).connection.connect(a[b])},saveConnections:function(a){a=a.getInputTargetBlock("STACK");for(var b=0;a;){var c=this.getInput("ADD"+b);a.valueConnection_=c&&c.connection.targetConnection;b++;a=a.nextConnection&&a.nextConnection.targetBlock()}},updateShape_:function(){if(this.getInput("EMPTY"))this.removeInput("EMPTY");else for(var a=0;this.getInput("ADD"+a);)this.removeInput("ADD"+a),a++;if(0==this.itemCount_)this.appendDummyInput("EMPTY").appendField(this.newQuote_(!0)).appendField(this.newQuote_(!1));
else for(a=0;a<this.itemCount_;a++){var b=this.appendValueInput("ADD"+a);0==a&&b.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}};
this.updateShape_()},decompose:function(a){var b=a.newBlock("text_create_join_container");b.initSvg();for(var c=b.getInput("STACK").connection,d=0;d<this.itemCount_;d++){var e=a.newBlock("text_create_join_item");e.initSvg();c.connect(e.previousConnection);c=e.nextConnection}return b},compose:function(a){var b=a.getInputTargetBlock("STACK");for(a=[];b;)a.push(b.valueConnection_),b=b.nextConnection&&b.nextConnection.targetBlock();for(b=0;b<this.itemCount_;b++){var c=this.getInput("ADD"+b).connection.targetConnection;
c&&-1==a.indexOf(c)&&c.disconnect()}this.itemCount_=a.length;this.updateShape_();for(b=0;b<this.itemCount_;b++)Blockly.Mutator.reconnect(a[b],this,"ADD"+b)},saveConnections:function(a){a=a.getInputTargetBlock("STACK");for(var b=0;a;){var c=this.getInput("ADD"+b);a.valueConnection_=c&&c.connection.targetConnection;b++;a=a.nextConnection&&a.nextConnection.targetBlock()}},updateShape_:function(){this.itemCount_&&this.getInput("EMPTY")?this.removeInput("EMPTY"):this.itemCount_||this.getInput("EMPTY")||
this.appendDummyInput("EMPTY").appendField(this.newQuote_(!0)).appendField(this.newQuote_(!1));for(var a=0;a<this.itemCount_;a++)if(!this.getInput("ADD"+a)){var b=this.appendValueInput("ADD"+a);0==a&&b.appendField(Blockly.Msg.TEXT_JOIN_TITLE_CREATEWITH)}for(;this.getInput("ADD"+a);)this.removeInput("ADD"+a),a++},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 a=this;this.setTooltip(function(){return Blockly.Msg.TEXT_APPEND_TOOLTIP.replace("%1",a.getFieldValue("VAR"))})},
getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(a,b){Blockly.Names.equals(a,this.getFieldValue("VAR"))&&this.setFieldValue(b,"VAR")}};Blockly.Blocks.text_length={init:function(){this.jsonInit({message0:Blockly.Msg.TEXT_LENGTH_TITLE,args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Number",colour:Blockly.Blocks.texts.HUE,tooltip:Blockly.Msg.TEXT_LENGTH_TOOLTIP,helpUrl:Blockly.Msg.TEXT_LENGTH_HELPURL})}};
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 a=this;this.setTooltip(function(){return Blockly.Msg.TEXT_APPEND_TOOLTIP.replace("%1",a.getFieldValue("VAR"))})}};
Blockly.Blocks.text_length={init:function(){this.jsonInit({message0:Blockly.Msg.TEXT_LENGTH_TITLE,args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Number",colour:Blockly.Blocks.texts.HUE,tooltip:Blockly.Msg.TEXT_LENGTH_TOOLTIP,helpUrl:Blockly.Msg.TEXT_LENGTH_HELPURL})}};
Blockly.Blocks.text_isEmpty={init:function(){this.jsonInit({message0:Blockly.Msg.TEXT_ISEMPTY_TITLE,args0:[{type:"input_value",name:"VALUE",check:["String","Array"]}],output:"Boolean",colour:Blockly.Blocks.texts.HUE,tooltip:Blockly.Msg.TEXT_ISEMPTY_TOOLTIP,helpUrl:Blockly.Msg.TEXT_ISEMPTY_HELPURL})}};
Blockly.Blocks.text_indexOf={init:function(){var a=[[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(a),"END");Blockly.Msg.TEXT_INDEXOF_TAIL&&this.appendDummyInput().appendField(Blockly.Msg.TEXT_INDEXOF_TAIL);
this.setInputsInline(!0);this.setTooltip(Blockly.Msg.TEXT_INDEXOF_TOOLTIP)}};
@@ -132,10 +131,9 @@ Blockly.Blocks.text_changeCase={init:function(){var a=[[Blockly.Msg.TEXT_CHANGEC
Blockly.Blocks.text_trim={init:function(){var a=[[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(a),"MODE");this.setOutput(!0,"String");this.setTooltip(Blockly.Msg.TEXT_TRIM_TOOLTIP)}};
Blockly.Blocks.text_print={init:function(){this.jsonInit({message0:Blockly.Msg.TEXT_PRINT_TITLE,args0:[{type:"input_value",name:"TEXT"}],previousStatement:null,nextStatement:null,colour:Blockly.Blocks.texts.HUE,tooltip:Blockly.Msg.TEXT_PRINT_TOOLTIP,helpUrl:Blockly.Msg.TEXT_PRINT_HELPURL})}};
Blockly.Blocks.text_prompt_ext={init:function(){var a=[[Blockly.Msg.TEXT_PROMPT_TYPE_TEXT,"TEXT"],[Blockly.Msg.TEXT_PROMPT_TYPE_NUMBER,"NUMBER"]];this.setHelpUrl(Blockly.Msg.TEXT_PROMPT_HELPURL);this.setColour(Blockly.Blocks.texts.HUE);var b=this,a=new Blockly.FieldDropdown(a,function(a){b.updateType_(a)});this.appendValueInput("TEXT").appendField(a,"TYPE");this.setOutput(!0,"String");this.setTooltip(function(){return"TEXT"==b.getFieldValue("TYPE")?Blockly.Msg.TEXT_PROMPT_TOOLTIP_TEXT:Blockly.Msg.TEXT_PROMPT_TOOLTIP_NUMBER})},
updateType_:function(a){"NUMBER"==a?this.outputConnection.setCheck("Number"):this.outputConnection.setCheck("String")},mutationToDom:function(){var a=document.createElement("mutation");a.setAttribute("type",this.getFieldValue("TYPE"));return a},domToMutation:function(a){this.updateType_(a.getAttribute("type"))}};
updateType_:function(a){this.outputConnection.setCheck("NUMBER"==a?"Number":"String")},mutationToDom:function(){var a=document.createElement("mutation");a.setAttribute("type",this.getFieldValue("TYPE"));return a},domToMutation:function(a){this.updateType_(a.getAttribute("type"))}};
Blockly.Blocks.text_prompt={init:function(){var a=[[Blockly.Msg.TEXT_PROMPT_TYPE_TEXT,"TEXT"],[Blockly.Msg.TEXT_PROMPT_TYPE_NUMBER,"NUMBER"]],b=this;this.setHelpUrl(Blockly.Msg.TEXT_PROMPT_HELPURL);this.setColour(Blockly.Blocks.texts.HUE);a=new Blockly.FieldDropdown(a,function(a){b.updateType_(a)});this.appendDummyInput().appendField(a,"TYPE").appendField(this.newQuote_(!0)).appendField(new Blockly.FieldTextInput(""),"TEXT").appendField(this.newQuote_(!1));this.setOutput(!0,"String");b=this;this.setTooltip(function(){return"TEXT"==
b.getFieldValue("TYPE")?Blockly.Msg.TEXT_PROMPT_TOOLTIP_TEXT:Blockly.Msg.TEXT_PROMPT_TOOLTIP_NUMBER})},newQuote_:Blockly.Blocks.text.newQuote_,updateType_:Blockly.Blocks.text_prompt_ext.updateType_,mutationToDom:Blockly.Blocks.text_prompt_ext.mutationToDom,domToMutation:Blockly.Blocks.text_prompt_ext.domToMutation};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(new Blockly.FieldVariable(Blockly.Msg.VARIABLES_DEFAULT_NAME),"VAR");this.setOutput(!0);this.setTooltip(Blockly.Msg.VARIABLES_GET_TOOLTIP);this.contextMenuMsg_=Blockly.Msg.VARIABLES_GET_CREATE_SET},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(a,b){Blockly.Names.equals(a,this.getFieldValue("VAR"))&&
this.setFieldValue(b,"VAR")},contextMenuType_:"variables_set",customContextMenu:function(a){var b={enabled:!0},c=this.getFieldValue("VAR");b.text=this.contextMenuMsg_.replace("%1",c);c=goog.dom.createDom("field",null,c);c.setAttribute("name","VAR");c=goog.dom.createDom("block",null,c);c.setAttribute("type",this.contextMenuType_);b.callback=Blockly.ContextMenu.callbackFactory(this,c);a.push(b)}};
Blockly.Blocks.variables_set={init:function(){this.jsonInit({message0:Blockly.Msg.VARIABLES_SET,args0:[{type:"field_variable",name:"VAR",variable:Blockly.Msg.VARIABLES_DEFAULT_NAME},{type:"input_value",name:"VALUE"}],previousStatement:null,nextStatement:null,colour:Blockly.Blocks.variables.HUE,tooltip:Blockly.Msg.VARIABLES_SET_TOOLTIP,helpUrl:Blockly.Msg.VARIABLES_SET_HELPURL});this.contextMenuMsg_=Blockly.Msg.VARIABLES_SET_CREATE_GET},getVars:function(){return[this.getFieldValue("VAR")]},renameVar:function(a,
b){Blockly.Names.equals(a,this.getFieldValue("VAR"))&&this.setFieldValue(b,"VAR")},contextMenuType_:"variables_get",customContextMenu:Blockly.Blocks.variables_get.customContextMenu};
Blockly.Blocks.variables_get={init:function(){this.setHelpUrl(Blockly.Msg.VARIABLES_GET_HELPURL);this.setColour(Blockly.Blocks.variables.HUE);this.appendDummyInput().appendField(new Blockly.FieldVariable(Blockly.Msg.VARIABLES_DEFAULT_NAME),"VAR");this.setOutput(!0);this.setTooltip(Blockly.Msg.VARIABLES_GET_TOOLTIP);this.contextMenuMsg_=Blockly.Msg.VARIABLES_GET_CREATE_SET},contextMenuType_:"variables_set",customContextMenu:function(a){var b={enabled:!0},c=this.getFieldValue("VAR");b.text=this.contextMenuMsg_.replace("%1",
c);c=goog.dom.createDom("field",null,c);c.setAttribute("name","VAR");c=goog.dom.createDom("block",null,c);c.setAttribute("type",this.contextMenuType_);b.callback=Blockly.ContextMenu.callbackFactory(this,c);a.push(b)}};
Blockly.Blocks.variables_set={init:function(){this.jsonInit({message0:Blockly.Msg.VARIABLES_SET,args0:[{type:"field_variable",name:"VAR",variable:Blockly.Msg.VARIABLES_DEFAULT_NAME},{type:"input_value",name:"VALUE"}],previousStatement:null,nextStatement:null,colour:Blockly.Blocks.variables.HUE,tooltip:Blockly.Msg.VARIABLES_SET_TOOLTIP,helpUrl:Blockly.Msg.VARIABLES_SET_HELPURL});this.contextMenuMsg_=Blockly.Msg.VARIABLES_SET_CREATE_GET},contextMenuType_:"variables_get",customContextMenu:Blockly.Blocks.variables_get.customContextMenu};
+2
View File
@@ -33,6 +33,7 @@
# javascript_compressed.js: The compressed Javascript generator.
# python_compressed.js: The compressed Python generator.
# dart_compressed.js: The compressed Dart generator.
# lua_compressed.js: The compressed Lua generator.
# msg/js/<LANG>.js for every language <LANG> defined in msg/js/<LANG>.json.
import sys
@@ -178,6 +179,7 @@ class Gen_compressed(threading.Thread):
self.gen_generator("python")
self.gen_generator("php")
self.gen_generator("dart")
self.gen_generator("lua")
def gen_core(self):
target_filename = "blockly_compressed.js"
+75 -42
View File
@@ -121,7 +121,7 @@ Blockly.Block = function(workspace, prototypeName, opt_id) {
// Record initial inline state.
/** @type {boolean|undefined} */
this.inputsInlineDefault = this.inputsInline;
if (Blockly.Events.isEnabled() && !this.isShadow()) {
if (Blockly.Events.isEnabled()) {
Blockly.Events.fire(new Blockly.Events.Create(this));
}
// Bind an onchange function, if it exists.
@@ -168,10 +168,10 @@ Blockly.Block.prototype.colour_ = '#000000';
Blockly.Block.prototype.dispose = function(healStack) {
// Terminate onchange event calls.
if (this.onchangeWrapper_) {
this.workspace.removeChangeListener(this.onchangeWrapper_)
this.workspace.removeChangeListener(this.onchangeWrapper_);
}
this.unplug(healStack);
if (Blockly.Events.isEnabled() && !this.isShadow()) {
if (Blockly.Events.isEnabled()) {
Blockly.Events.fire(new Blockly.Events.Delete(this));
}
Blockly.Events.disable();
@@ -218,27 +218,28 @@ Blockly.Block.prototype.dispose = function(healStack) {
/**
* Unplug this block from its superior block. If this block is a statement,
* optionally reconnect the block underneath with the block on top.
* @param {boolean} healStack Disconnect child statement and reconnect stack.
* @param {boolean} opt_healStack Disconnect child statement and reconnect
* stack. Defaults to false.
*/
Blockly.Block.prototype.unplug = function(healStack) {
Blockly.Block.prototype.unplug = function(opt_healStack) {
if (this.outputConnection) {
if (this.outputConnection.targetConnection) {
// Disconnect from any superior block.
this.setParent(null);
this.outputConnection.disconnect();
}
} else {
} else if (this.previousConnection) {
var previousTarget = null;
if (this.previousConnection && this.previousConnection.targetConnection) {
if (this.previousConnection.targetConnection) {
// Remember the connection that any next statements need to connect to.
previousTarget = this.previousConnection.targetConnection;
// Detach this block from the parent's tree.
this.setParent(null);
this.previousConnection.disconnect();
}
var nextBlock = this.getNextBlock();
if (healStack && nextBlock) {
if (opt_healStack && nextBlock) {
// Disconnect the next statement.
var nextTarget = this.nextConnection.targetConnection;
nextBlock.setParent(null);
nextTarget.disconnect();
if (previousTarget && previousTarget.checkType_(nextTarget)) {
// Attach the next statement to the previous statement.
previousTarget.connect(nextTarget);
@@ -277,6 +278,25 @@ Blockly.Block.prototype.getConnections_ = function(all) {
return myConnections;
};
/**
* Walks down a stack of blocks and finds the last next connection on the stack.
* @return {Blockly.Connection} The last next connection on the stack, or null.
* @private
*/
Blockly.Block.prototype.lastConnectionInStack_ = function() {
var nextConnection = this.nextConnection;
while (nextConnection) {
var nextBlock = nextConnection.targetBlock();
if (!nextBlock) {
// Found a next connection with nothing on the other side.
return nextConnection;
}
nextConnection = nextBlock.nextConnection;
}
// Ran out of next connections.
return null;
};
/**
* Bump unconnected blocks out of alignment. Two blocks which aren't actually
* connected should not coincidentally line up on screen.
@@ -307,7 +327,7 @@ Blockly.Block.prototype.bumpNeighbours_ = function() {
// either one of them is unconnected, then there could be confusion.
if (!connection.targetConnection || !otherConnection.targetConnection) {
// Only bump blocks if they are from different tree structures.
if (otherConnection.sourceBlock_.getRootBlock() != rootBlock) {
if (otherConnection.getSourceBlock().getRootBlock() != rootBlock) {
// Always bump the inferior block.
if (connection.isSuperior()) {
otherConnection.bumpAwayFrom_(connection);
@@ -337,7 +357,7 @@ Blockly.Block.prototype.getParent = function() {
Blockly.Block.prototype.getInputWithBlock = function(block) {
for (var i = 0, input; input = this.inputList[i]; i++) {
if (input.connection && input.connection.targetBlock() == block) {
return input
return input;
}
}
return null;
@@ -401,9 +421,8 @@ Blockly.Block.prototype.getChildren = function() {
* @param {Blockly.Block} newParent New parent block.
*/
Blockly.Block.prototype.setParent = function(newParent) {
var event;
if (Blockly.Events.isEnabled() && !this.isShadow()) {
event = new Blockly.Events.Move(this);
if (newParent == this.parentBlock_) {
return;
}
if (this.parentBlock_) {
// Remove this block from the old parent's child list.
@@ -416,13 +435,13 @@ Blockly.Block.prototype.setParent = function(newParent) {
}
// Disconnect from superior blocks.
this.parentBlock_ = null;
if (this.previousConnection && this.previousConnection.targetConnection) {
this.previousConnection.disconnect();
throw 'Still connected to previous block.';
}
if (this.outputConnection && this.outputConnection.targetConnection) {
this.outputConnection.disconnect();
throw 'Still connected to parent block.';
}
this.parentBlock_ = null;
// This block hasn't actually moved on-screen, so there's no need to update
// its connection locations.
} else {
@@ -437,10 +456,6 @@ Blockly.Block.prototype.setParent = function(newParent) {
} else {
this.workspace.addTopBlock(this);
}
if (event) {
event.recordNew();
Blockly.Events.fire(event);
}
};
/**
@@ -505,23 +520,7 @@ Blockly.Block.prototype.isShadow = function() {
* @param {boolean} shadow True if a shadow.
*/
Blockly.Block.prototype.setShadow = function(shadow) {
if (this.isShadow_ == shadow) {
return; // No change.
}
this.isShadow_ = shadow;
if (Blockly.Events.isEnabled() && !shadow) {
Blockly.Events.group = Blockly.genUid();
// Fire a creation event.
Blockly.Events.fire(new Blockly.Events.Create(this));
var moveEvent = new Blockly.Events.Move(this);
// Claim that the block was at 0,0 and is being connected.
moveEvent.oldParentId = undefined;
moveEvent.oldInputName = undefined;
moveEvent.oldCoordinate = new goog.math.Coordinate(0, 0);
moveEvent.recordNew();
Blockly.Events.fire(moveEvent);
Blockly.Events.group = '';
}
};
/**
@@ -639,6 +638,39 @@ Blockly.Block.prototype.getField = function(name) {
return null;
};
/**
* Return all variables referenced by this block.
* @return {!Array.<string>} List of variable names.
*/
Blockly.Block.prototype.getVars = function() {
var vars = [];
for (var i = 0, input; input = this.inputList[i]; i++) {
for (var j = 0, field; field = input.fieldRow[j]; j++) {
if (field instanceof Blockly.FieldVariable) {
vars.push(field.getValue());
}
}
}
return vars;
};
/**
* Notification that a variable is renaming.
* If the name matches one of this block's variables, rename it.
* @param {string} oldName Previous name of variable.
* @param {string} newName Renamed variable.
*/
Blockly.Block.prototype.renameVar = function(oldName, newName) {
for (var i = 0, input; input = this.inputList[i]; i++) {
for (var j = 0, field; field = input.fieldRow[j]; j++) {
if (field instanceof Blockly.FieldVariable &&
Blockly.Names.equals(oldName, field.getValue())) {
field.setValue(newName);
}
}
}
};
/**
* Returns the language-neutral value from the field of a block.
* @param {string} name The name of the field.
@@ -1201,7 +1233,7 @@ Blockly.Block.prototype.removeInput = function(name, opt_quiet) {
if (input.name == name) {
if (input.connection && input.connection.targetConnection) {
// Disconnect any attached block.
input.connection.targetBlock().setParent(null);
input.connection.targetBlock().unplug();
}
input.dispose();
this.inputList.splice(i, 1);
@@ -1221,7 +1253,7 @@ Blockly.Block.prototype.removeInput = function(name, opt_quiet) {
/**
* Fetches the named input object.
* @param {string} name The name of the input.
* @return {Blockly.Input} The input object, or null of the input does not exist.
* @return {Blockly.Input} The input object, or null if input does not exist.
*/
Blockly.Block.prototype.getInput = function(name) {
for (var i = 0, input; input = this.inputList[i]; i++) {
@@ -1259,7 +1291,7 @@ Blockly.Block.prototype.getCommentText = function() {
Blockly.Block.prototype.setCommentText = function(text) {
if (this.comment != text) {
Blockly.Events.fire(new Blockly.Events.Change(
this, 'comment', null, this.comment, text || ''));
this, 'comment', null, this.comment, text || ''));
this.comment = text;
}
};
@@ -1295,6 +1327,7 @@ Blockly.Block.prototype.getRelativeToSurfaceXY = function() {
* @param {number} dy Vertical offset.
*/
Blockly.Block.prototype.moveBy = function(dx, dy) {
goog.asserts.assert(!this.parentBlock_, 'Block has parent.');
var event = new Blockly.Events.Move(this);
this.xy_.translate(dx, dy);
event.recordNew();
+943
View File
@@ -0,0 +1,943 @@
/**
* @license
* Visual Blocks Editor
*
* Copyright 2016 Google Inc.
* https://developers.google.com/blockly/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview Methods for graphically rendering a block as SVG.
* @author fenichel@google.com (Rachel Fenichel)
*/
'use strict';
goog.provide('Blockly.BlockSvg.render');
goog.require('Blockly.BlockSvg');
// UI constants for rendering blocks.
/**
* Horizontal space between elements.
* @const
*/
Blockly.BlockSvg.SEP_SPACE_X = 10;
/**
* Vertical space between elements.
* @const
*/
Blockly.BlockSvg.SEP_SPACE_Y = 10;
/**
* Vertical padding around inline elements.
* @const
*/
Blockly.BlockSvg.INLINE_PADDING_Y = 5;
/**
* Minimum height of a block.
* @const
*/
Blockly.BlockSvg.MIN_BLOCK_Y = 25;
/**
* Height of horizontal puzzle tab.
* @const
*/
Blockly.BlockSvg.TAB_HEIGHT = 20;
/**
* Width of horizontal puzzle tab.
* @const
*/
Blockly.BlockSvg.TAB_WIDTH = 8;
/**
* Width of vertical tab (inc left margin).
* @const
*/
Blockly.BlockSvg.NOTCH_WIDTH = 30;
/**
* Rounded corner radius.
* @const
*/
Blockly.BlockSvg.CORNER_RADIUS = 8;
/**
* Do blocks with no previous or output connections have a 'hat' on top?
* @const
*/
Blockly.BlockSvg.START_HAT = false;
/**
* Path of the top hat's curve.
* @const
*/
Blockly.BlockSvg.START_HAT_PATH = 'c 30,-15 70,-15 100,0';
/**
* Path of the top hat's curve's highlight in LTR.
* @const
*/
Blockly.BlockSvg.START_HAT_HIGHLIGHT_LTR =
'c 17.8,-9.2 45.3,-14.9 75,-8.7 M 100.5,0.5';
/**
* Path of the top hat's curve's highlight in RTL.
* @const
*/
Blockly.BlockSvg.START_HAT_HIGHLIGHT_RTL =
'm 25,-8.7 c 29.7,-6.2 57.2,-0.5 75,8.7';
/**
* Distance from shape edge to intersect with a curved corner at 45 degrees.
* Applies to highlighting on around the inside of a curve.
* @const
*/
Blockly.BlockSvg.DISTANCE_45_INSIDE = (1 - Math.SQRT1_2) *
(Blockly.BlockSvg.CORNER_RADIUS - 0.5) + 0.5;
/**
* Distance from shape edge to intersect with a curved corner at 45 degrees.
* Applies to highlighting on around the outside of a curve.
* @const
*/
Blockly.BlockSvg.DISTANCE_45_OUTSIDE = (1 - Math.SQRT1_2) *
(Blockly.BlockSvg.CORNER_RADIUS + 0.5) - 0.5;
/**
* SVG path for drawing next/previous notch from left to right.
* @const
*/
Blockly.BlockSvg.NOTCH_PATH_LEFT = 'l 6,4 3,0 6,-4';
/**
* SVG path for drawing next/previous notch from left to right with
* highlighting.
* @const
*/
Blockly.BlockSvg.NOTCH_PATH_LEFT_HIGHLIGHT = 'l 6,4 3,0 6,-4';
/**
* SVG path for drawing next/previous notch from right to left.
* @const
*/
Blockly.BlockSvg.NOTCH_PATH_RIGHT = 'l -6,4 -3,0 -6,-4';
/**
* SVG path for drawing jagged teeth at the end of collapsed blocks.
* @const
*/
Blockly.BlockSvg.JAGGED_TEETH = 'l 8,0 0,4 8,4 -16,8 8,4';
/**
* Height of SVG path for jagged teeth at the end of collapsed blocks.
* @const
*/
Blockly.BlockSvg.JAGGED_TEETH_HEIGHT = 20;
/**
* Width of SVG path for jagged teeth at the end of collapsed blocks.
* @const
*/
Blockly.BlockSvg.JAGGED_TEETH_WIDTH = 15;
/**
* SVG path for drawing a horizontal puzzle tab from top to bottom.
* @const
*/
Blockly.BlockSvg.TAB_PATH_DOWN = 'v 5 c 0,10 -' + Blockly.BlockSvg.TAB_WIDTH +
',-8 -' + Blockly.BlockSvg.TAB_WIDTH + ',7.5 s ' +
Blockly.BlockSvg.TAB_WIDTH + ',-2.5 ' + Blockly.BlockSvg.TAB_WIDTH + ',7.5';
/**
* SVG path for drawing a horizontal puzzle tab from top to bottom with
* highlighting from the upper-right.
* @const
*/
Blockly.BlockSvg.TAB_PATH_DOWN_HIGHLIGHT_RTL = 'v 6.5 m -' +
(Blockly.BlockSvg.TAB_WIDTH * 0.97) + ',3 q -' +
(Blockly.BlockSvg.TAB_WIDTH * 0.05) + ',10 ' +
(Blockly.BlockSvg.TAB_WIDTH * 0.3) + ',9.5 m ' +
(Blockly.BlockSvg.TAB_WIDTH * 0.67) + ',-1.9 v 1.4';
/**
* SVG start point for drawing the top-left corner.
* @const
*/
Blockly.BlockSvg.TOP_LEFT_CORNER_START =
'm 0,' + Blockly.BlockSvg.CORNER_RADIUS;
/**
* SVG start point for drawing the top-left corner's highlight in RTL.
* @const
*/
Blockly.BlockSvg.TOP_LEFT_CORNER_START_HIGHLIGHT_RTL =
'm ' + Blockly.BlockSvg.DISTANCE_45_INSIDE + ',' +
Blockly.BlockSvg.DISTANCE_45_INSIDE;
/**
* SVG start point for drawing the top-left corner's highlight in LTR.
* @const
*/
Blockly.BlockSvg.TOP_LEFT_CORNER_START_HIGHLIGHT_LTR =
'm 0.5,' + (Blockly.BlockSvg.CORNER_RADIUS - 0.5);
/**
* SVG path for drawing the rounded top-left corner.
* @const
*/
Blockly.BlockSvg.TOP_LEFT_CORNER =
'A ' + Blockly.BlockSvg.CORNER_RADIUS + ',' +
Blockly.BlockSvg.CORNER_RADIUS + ' 0 0,1 ' +
Blockly.BlockSvg.CORNER_RADIUS + ',0';
/**
* SVG path for drawing the highlight on the rounded top-left corner.
* @const
*/
Blockly.BlockSvg.TOP_LEFT_CORNER_HIGHLIGHT =
'A ' + (Blockly.BlockSvg.CORNER_RADIUS - 0.5) + ',' +
(Blockly.BlockSvg.CORNER_RADIUS - 0.5) + ' 0 0,1 ' +
Blockly.BlockSvg.CORNER_RADIUS + ',0.5';
/**
* SVG path for drawing the top-left corner of a statement input.
* Includes the top notch, a horizontal space, and the rounded inside corner.
* @const
*/
Blockly.BlockSvg.INNER_TOP_LEFT_CORNER =
Blockly.BlockSvg.NOTCH_PATH_RIGHT + ' h -' +
(Blockly.BlockSvg.NOTCH_WIDTH - 15 - Blockly.BlockSvg.CORNER_RADIUS) +
' a ' + Blockly.BlockSvg.CORNER_RADIUS + ',' +
Blockly.BlockSvg.CORNER_RADIUS + ' 0 0,0 -' +
Blockly.BlockSvg.CORNER_RADIUS + ',' +
Blockly.BlockSvg.CORNER_RADIUS;
/**
* SVG path for drawing the bottom-left corner of a statement input.
* Includes the rounded inside corner.
* @const
*/
Blockly.BlockSvg.INNER_BOTTOM_LEFT_CORNER =
'a ' + Blockly.BlockSvg.CORNER_RADIUS + ',' +
Blockly.BlockSvg.CORNER_RADIUS + ' 0 0,0 ' +
Blockly.BlockSvg.CORNER_RADIUS + ',' +
Blockly.BlockSvg.CORNER_RADIUS;
/**
* SVG path for drawing highlight on the top-left corner of a statement
* input in RTL.
* @const
*/
Blockly.BlockSvg.INNER_TOP_LEFT_CORNER_HIGHLIGHT_RTL =
'a ' + Blockly.BlockSvg.CORNER_RADIUS + ',' +
Blockly.BlockSvg.CORNER_RADIUS + ' 0 0,0 ' +
(-Blockly.BlockSvg.DISTANCE_45_OUTSIDE - 0.5) + ',' +
(Blockly.BlockSvg.CORNER_RADIUS -
Blockly.BlockSvg.DISTANCE_45_OUTSIDE);
/**
* SVG path for drawing highlight on the bottom-left corner of a statement
* input in RTL.
* @const
*/
Blockly.BlockSvg.INNER_BOTTOM_LEFT_CORNER_HIGHLIGHT_RTL =
'a ' + (Blockly.BlockSvg.CORNER_RADIUS + 0.5) + ',' +
(Blockly.BlockSvg.CORNER_RADIUS + 0.5) + ' 0 0,0 ' +
(Blockly.BlockSvg.CORNER_RADIUS + 0.5) + ',' +
(Blockly.BlockSvg.CORNER_RADIUS + 0.5);
/**
* SVG path for drawing highlight on the bottom-left corner of a statement
* input in LTR.
* @const
*/
Blockly.BlockSvg.INNER_BOTTOM_LEFT_CORNER_HIGHLIGHT_LTR =
'a ' + (Blockly.BlockSvg.CORNER_RADIUS + 0.5) + ',' +
(Blockly.BlockSvg.CORNER_RADIUS + 0.5) + ' 0 0,0 ' +
(Blockly.BlockSvg.CORNER_RADIUS -
Blockly.BlockSvg.DISTANCE_45_OUTSIDE) + ',' +
(Blockly.BlockSvg.DISTANCE_45_OUTSIDE + 0.5);
/**
* Render the block.
* Lays out and reflows a block based on its contents and settings.
* @param {boolean=} opt_bubble If false, just render this block.
* If true, also render block's parent, grandparent, etc. Defaults to true.
*/
Blockly.BlockSvg.prototype.render = function(opt_bubble) {
Blockly.Field.startCache();
this.rendered = true;
var cursorX = Blockly.BlockSvg.SEP_SPACE_X;
if (this.RTL) {
cursorX = -cursorX;
}
// Move the icons into position.
var icons = this.getIcons();
for (var i = 0; i < icons.length; i++) {
cursorX = icons[i].renderIcon(cursorX);
}
cursorX += this.RTL ?
Blockly.BlockSvg.SEP_SPACE_X : -Blockly.BlockSvg.SEP_SPACE_X;
// If there are no icons, cursorX will be 0, otherwise it will be the
// width that the first label needs to move over by.
var inputRows = this.renderCompute_(cursorX);
this.renderDraw_(cursorX, inputRows);
if (opt_bubble !== false) {
// Render all blocks above this one (propagate a reflow).
var parentBlock = this.getParent();
if (parentBlock) {
parentBlock.render(true);
} else {
// Top-most block. Fire an event to allow scrollbars to resize.
Blockly.fireUiEvent(window, 'resize');
}
}
Blockly.Field.stopCache();
};
/**
* Render a list of fields starting at the specified location.
* @param {!Array.<!Blockly.Field>} fieldList List of fields.
* @param {number} cursorX X-coordinate to start the fields.
* @param {number} cursorY Y-coordinate to start the fields.
* @return {number} X-coordinate of the end of the field row (plus a gap).
* @private
*/
Blockly.BlockSvg.prototype.renderFields_ =
function(fieldList, cursorX, cursorY) {
cursorY += Blockly.BlockSvg.INLINE_PADDING_Y;
if (this.RTL) {
cursorX = -cursorX;
}
for (var t = 0, field; field = fieldList[t]; t++) {
var root = field.getSvgRoot();
if (!root) {
continue;
}
if (this.RTL) {
cursorX -= field.renderSep + field.renderWidth;
root.setAttribute('transform',
'translate(' + cursorX + ',' + cursorY + ')');
if (field.renderWidth) {
cursorX -= Blockly.BlockSvg.SEP_SPACE_X;
}
} else {
root.setAttribute('transform',
'translate(' + (cursorX + field.renderSep) + ',' + cursorY + ')');
if (field.renderWidth) {
cursorX += field.renderSep + field.renderWidth +
Blockly.BlockSvg.SEP_SPACE_X;
}
}
}
return this.RTL ? -cursorX : cursorX;
};
/**
* Computes the height and widths for each row and field.
* @param {number} iconWidth Offset of first row due to icons.
* @return {!Array.<!Array.<!Object>>} 2D array of objects, each containing
* position information.
* @private
*/
Blockly.BlockSvg.prototype.renderCompute_ = function(iconWidth) {
var inputList = this.inputList;
var inputRows = [];
inputRows.rightEdge = iconWidth + Blockly.BlockSvg.SEP_SPACE_X * 2;
if (this.previousConnection || this.nextConnection) {
inputRows.rightEdge = Math.max(inputRows.rightEdge,
Blockly.BlockSvg.NOTCH_WIDTH + Blockly.BlockSvg.SEP_SPACE_X);
}
var fieldValueWidth = 0; // Width of longest external value field.
var fieldStatementWidth = 0; // Width of longest statement field.
var hasValue = false;
var hasStatement = false;
var hasDummy = false;
var lastType = undefined;
var isInline = this.getInputsInline() && !this.isCollapsed();
for (var i = 0, input; input = inputList[i]; i++) {
if (!input.isVisible()) {
continue;
}
var row;
if (!isInline || !lastType ||
lastType == Blockly.NEXT_STATEMENT ||
input.type == Blockly.NEXT_STATEMENT) {
// Create new row.
lastType = input.type;
row = [];
if (isInline && input.type != Blockly.NEXT_STATEMENT) {
row.type = Blockly.BlockSvg.INLINE;
} else {
row.type = input.type;
}
row.height = 0;
inputRows.push(row);
} else {
row = inputRows[inputRows.length - 1];
}
row.push(input);
// Compute minimum input size.
input.renderHeight = Blockly.BlockSvg.MIN_BLOCK_Y;
// The width is currently only needed for inline value inputs.
if (isInline && input.type == Blockly.INPUT_VALUE) {
input.renderWidth = Blockly.BlockSvg.TAB_WIDTH +
Blockly.BlockSvg.SEP_SPACE_X * 1.25;
} else {
input.renderWidth = 0;
}
// Expand input size if there is a connection.
if (input.connection && input.connection.targetConnection) {
var linkedBlock = input.connection.targetBlock();
var bBox = linkedBlock.getHeightWidth();
input.renderHeight = Math.max(input.renderHeight, bBox.height);
input.renderWidth = Math.max(input.renderWidth, bBox.width);
}
// Blocks have a one pixel shadow that should sometimes overhang.
if (!isInline && i == inputList.length - 1) {
// Last value input should overhang.
input.renderHeight--;
} else if (!isInline && input.type == Blockly.INPUT_VALUE &&
inputList[i + 1] && inputList[i + 1].type == Blockly.NEXT_STATEMENT) {
// Value input above statement input should overhang.
input.renderHeight--;
}
row.height = Math.max(row.height, input.renderHeight);
input.fieldWidth = 0;
if (inputRows.length == 1) {
// The first row gets shifted to accommodate any icons.
input.fieldWidth += this.RTL ? -iconWidth : iconWidth;
}
var previousFieldEditable = false;
for (var j = 0, field; field = input.fieldRow[j]; j++) {
if (j != 0) {
input.fieldWidth += Blockly.BlockSvg.SEP_SPACE_X;
}
// Get the dimensions of the field.
var fieldSize = field.getSize();
field.renderWidth = fieldSize.width;
field.renderSep = (previousFieldEditable && field.EDITABLE) ?
Blockly.BlockSvg.SEP_SPACE_X : 0;
input.fieldWidth += field.renderWidth + field.renderSep;
row.height = Math.max(row.height, fieldSize.height);
previousFieldEditable = field.EDITABLE;
}
if (row.type != Blockly.BlockSvg.INLINE) {
if (row.type == Blockly.NEXT_STATEMENT) {
hasStatement = true;
fieldStatementWidth = Math.max(fieldStatementWidth, input.fieldWidth);
} else {
if (row.type == Blockly.INPUT_VALUE) {
hasValue = true;
} else if (row.type == Blockly.DUMMY_INPUT) {
hasDummy = true;
}
fieldValueWidth = Math.max(fieldValueWidth, input.fieldWidth);
}
}
}
// Make inline rows a bit thicker in order to enclose the values.
for (var y = 0, row; row = inputRows[y]; y++) {
row.thicker = false;
if (row.type == Blockly.BlockSvg.INLINE) {
for (var z = 0, input; input = row[z]; z++) {
if (input.type == Blockly.INPUT_VALUE) {
row.height += 2 * Blockly.BlockSvg.INLINE_PADDING_Y;
row.thicker = true;
break;
}
}
}
}
// Compute the statement edge.
// This is the width of a block where statements are nested.
inputRows.statementEdge = 2 * Blockly.BlockSvg.SEP_SPACE_X +
fieldStatementWidth;
// Compute the preferred right edge. Inline blocks may extend beyond.
// This is the width of the block where external inputs connect.
if (hasStatement) {
inputRows.rightEdge = Math.max(inputRows.rightEdge,
inputRows.statementEdge + Blockly.BlockSvg.NOTCH_WIDTH);
}
if (hasValue) {
inputRows.rightEdge = Math.max(inputRows.rightEdge, fieldValueWidth +
Blockly.BlockSvg.SEP_SPACE_X * 2 + Blockly.BlockSvg.TAB_WIDTH);
} else if (hasDummy) {
inputRows.rightEdge = Math.max(inputRows.rightEdge, fieldValueWidth +
Blockly.BlockSvg.SEP_SPACE_X * 2);
}
inputRows.hasValue = hasValue;
inputRows.hasStatement = hasStatement;
inputRows.hasDummy = hasDummy;
return inputRows;
};
/**
* Draw the path of the block.
* Move the fields to the correct locations.
* @param {number} iconWidth Offset of first row due to icons.
* @param {!Array.<!Array.<!Object>>} inputRows 2D array of objects, each
* containing position information.
* @private
*/
Blockly.BlockSvg.prototype.renderDraw_ = function(iconWidth, inputRows) {
this.startHat_ = false;
// Should the top and bottom left corners be rounded or square?
if (this.outputConnection) {
this.squareTopLeftCorner_ = true;
this.squareBottomLeftCorner_ = true;
} else {
this.squareTopLeftCorner_ = false;
this.squareBottomLeftCorner_ = false;
// If this block is in the middle of a stack, square the corners.
if (this.previousConnection) {
var prevBlock = this.previousConnection.targetBlock();
if (prevBlock && prevBlock.getNextBlock() == this) {
this.squareTopLeftCorner_ = true;
}
} else if (Blockly.BlockSvg.START_HAT) {
// No output or previous connection.
this.squareTopLeftCorner_ = true;
this.startHat_ = true;
inputRows.rightEdge = Math.max(inputRows.rightEdge, 100);
}
var nextBlock = this.getNextBlock();
if (nextBlock) {
this.squareBottomLeftCorner_ = true;
}
}
// Fetch the block's coordinates on the surface for use in anchoring
// the connections.
var connectionsXY = this.getRelativeToSurfaceXY();
// Assemble the block's path.
var steps = [];
var inlineSteps = [];
// The highlighting applies to edges facing the upper-left corner.
// Since highlighting is a two-pixel wide border, it would normally overhang
// the edge of the block by a pixel. So undersize all measurements by a pixel.
var highlightSteps = [];
var highlightInlineSteps = [];
this.renderDrawTop_(steps, highlightSteps, connectionsXY,
inputRows.rightEdge);
var cursorY = this.renderDrawRight_(steps, highlightSteps, inlineSteps,
highlightInlineSteps, connectionsXY, inputRows, iconWidth);
this.renderDrawBottom_(steps, highlightSteps, connectionsXY, cursorY);
this.renderDrawLeft_(steps, highlightSteps, connectionsXY, cursorY);
var pathString = steps.join(' ') + '\n' + inlineSteps.join(' ');
this.svgPath_.setAttribute('d', pathString);
this.svgPathDark_.setAttribute('d', pathString);
pathString = highlightSteps.join(' ') + '\n' + highlightInlineSteps.join(' ');
this.svgPathLight_.setAttribute('d', pathString);
if (this.RTL) {
// Mirror the block's path.
this.svgPath_.setAttribute('transform', 'scale(-1 1)');
this.svgPathLight_.setAttribute('transform', 'scale(-1 1)');
this.svgPathDark_.setAttribute('transform', 'translate(1,1) scale(-1 1)');
}
};
/**
* Render the top edge of the block.
* @param {!Array.<string>} steps Path of block outline.
* @param {!Array.<string>} highlightSteps Path of block highlights.
* @param {!Object} connectionsXY Location of block.
* @param {number} rightEdge Minimum width of block.
* @private
*/
Blockly.BlockSvg.prototype.renderDrawTop_ =
function(steps, highlightSteps, connectionsXY, rightEdge) {
// Position the cursor at the top-left starting point.
if (this.squareTopLeftCorner_) {
steps.push('m 0,0');
highlightSteps.push('m 0.5,0.5');
if (this.startHat_) {
steps.push(Blockly.BlockSvg.START_HAT_PATH);
highlightSteps.push(this.RTL ?
Blockly.BlockSvg.START_HAT_HIGHLIGHT_RTL :
Blockly.BlockSvg.START_HAT_HIGHLIGHT_LTR);
}
} else {
steps.push(Blockly.BlockSvg.TOP_LEFT_CORNER_START);
highlightSteps.push(this.RTL ?
Blockly.BlockSvg.TOP_LEFT_CORNER_START_HIGHLIGHT_RTL :
Blockly.BlockSvg.TOP_LEFT_CORNER_START_HIGHLIGHT_LTR);
// Top-left rounded corner.
steps.push(Blockly.BlockSvg.TOP_LEFT_CORNER);
highlightSteps.push(Blockly.BlockSvg.TOP_LEFT_CORNER_HIGHLIGHT);
}
// Top edge.
if (this.previousConnection) {
steps.push('H', Blockly.BlockSvg.NOTCH_WIDTH - 15);
highlightSteps.push('H', Blockly.BlockSvg.NOTCH_WIDTH - 15);
steps.push(Blockly.BlockSvg.NOTCH_PATH_LEFT);
highlightSteps.push(Blockly.BlockSvg.NOTCH_PATH_LEFT_HIGHLIGHT);
// Create previous block connection.
var connectionX = connectionsXY.x + (this.RTL ?
-Blockly.BlockSvg.NOTCH_WIDTH : Blockly.BlockSvg.NOTCH_WIDTH);
var connectionY = connectionsXY.y;
this.previousConnection.moveTo(connectionX, connectionY);
// This connection will be tightened when the parent renders.
}
steps.push('H', rightEdge);
highlightSteps.push('H', rightEdge - 0.5);
this.width = rightEdge;
};
/**
* Render the right edge of the block.
* @param {!Array.<string>} steps Path of block outline.
* @param {!Array.<string>} highlightSteps Path of block highlights.
* @param {!Array.<string>} inlineSteps Inline block outlines.
* @param {!Array.<string>} highlightInlineSteps Inline block highlights.
* @param {!Object} connectionsXY Location of block.
* @param {!Array.<!Array.<!Object>>} inputRows 2D array of objects, each
* containing position information.
* @param {number} iconWidth Offset of first row due to icons.
* @return {number} Height of block.
* @private
*/
Blockly.BlockSvg.prototype.renderDrawRight_ = function(steps, highlightSteps,
inlineSteps, highlightInlineSteps, connectionsXY, inputRows, iconWidth) {
var cursorX;
var cursorY = 0;
var connectionX, connectionY;
for (var y = 0, row; row = inputRows[y]; y++) {
cursorX = Blockly.BlockSvg.SEP_SPACE_X;
if (y == 0) {
cursorX += this.RTL ? -iconWidth : iconWidth;
}
highlightSteps.push('M', (inputRows.rightEdge - 0.5) + ',' +
(cursorY + 0.5));
if (this.isCollapsed()) {
// Jagged right edge.
var input = row[0];
var fieldX = cursorX;
var fieldY = cursorY;
this.renderFields_(input.fieldRow, fieldX, fieldY);
steps.push(Blockly.BlockSvg.JAGGED_TEETH);
highlightSteps.push('h 8');
var remainder = row.height - Blockly.BlockSvg.JAGGED_TEETH_HEIGHT;
steps.push('v', remainder);
if (this.RTL) {
highlightSteps.push('v 3.9 l 7.2,3.4 m -14.5,8.9 l 7.3,3.5');
highlightSteps.push('v', remainder - 0.7);
}
this.width += Blockly.BlockSvg.JAGGED_TEETH_WIDTH;
} else if (row.type == Blockly.BlockSvg.INLINE) {
// Inline inputs.
for (var x = 0, input; input = row[x]; x++) {
var fieldX = cursorX;
var fieldY = cursorY;
if (row.thicker) {
// Lower the field slightly.
fieldY += Blockly.BlockSvg.INLINE_PADDING_Y;
}
// TODO: Align inline field rows (left/right/centre).
cursorX = this.renderFields_(input.fieldRow, fieldX, fieldY);
if (input.type != Blockly.DUMMY_INPUT) {
cursorX += input.renderWidth + Blockly.BlockSvg.SEP_SPACE_X;
}
if (input.type == Blockly.INPUT_VALUE) {
inlineSteps.push('M', (cursorX - Blockly.BlockSvg.SEP_SPACE_X) +
',' + (cursorY + Blockly.BlockSvg.INLINE_PADDING_Y));
inlineSteps.push('h', Blockly.BlockSvg.TAB_WIDTH - 2 -
input.renderWidth);
inlineSteps.push(Blockly.BlockSvg.TAB_PATH_DOWN);
inlineSteps.push('v', input.renderHeight + 1 -
Blockly.BlockSvg.TAB_HEIGHT);
inlineSteps.push('h', input.renderWidth + 2 -
Blockly.BlockSvg.TAB_WIDTH);
inlineSteps.push('z');
if (this.RTL) {
// Highlight right edge, around back of tab, and bottom.
highlightInlineSteps.push('M',
(cursorX - Blockly.BlockSvg.SEP_SPACE_X - 2.5 +
Blockly.BlockSvg.TAB_WIDTH - input.renderWidth) + ',' +
(cursorY + Blockly.BlockSvg.INLINE_PADDING_Y + 0.5));
highlightInlineSteps.push(
Blockly.BlockSvg.TAB_PATH_DOWN_HIGHLIGHT_RTL);
highlightInlineSteps.push('v',
input.renderHeight - Blockly.BlockSvg.TAB_HEIGHT + 2.5);
highlightInlineSteps.push('h',
input.renderWidth - Blockly.BlockSvg.TAB_WIDTH + 2);
} else {
// Highlight right edge, bottom.
highlightInlineSteps.push('M',
(cursorX - Blockly.BlockSvg.SEP_SPACE_X + 0.5) + ',' +
(cursorY + Blockly.BlockSvg.INLINE_PADDING_Y + 0.5));
highlightInlineSteps.push('v', input.renderHeight + 1);
highlightInlineSteps.push('h', Blockly.BlockSvg.TAB_WIDTH - 2 -
input.renderWidth);
// Short highlight glint at bottom of tab.
highlightInlineSteps.push('M',
(cursorX - input.renderWidth - Blockly.BlockSvg.SEP_SPACE_X +
0.9) + ',' + (cursorY + Blockly.BlockSvg.INLINE_PADDING_Y +
Blockly.BlockSvg.TAB_HEIGHT - 0.7));
highlightInlineSteps.push('l',
(Blockly.BlockSvg.TAB_WIDTH * 0.46) + ',-2.1');
}
// Create inline input connection.
if (this.RTL) {
connectionX = connectionsXY.x - cursorX -
Blockly.BlockSvg.TAB_WIDTH + Blockly.BlockSvg.SEP_SPACE_X +
input.renderWidth + 1;
} else {
connectionX = connectionsXY.x + cursorX +
Blockly.BlockSvg.TAB_WIDTH - Blockly.BlockSvg.SEP_SPACE_X -
input.renderWidth - 1;
}
connectionY = connectionsXY.y + cursorY +
Blockly.BlockSvg.INLINE_PADDING_Y + 1;
input.connection.moveTo(connectionX, connectionY);
if (input.connection.targetConnection) {
input.connection.tighten_();
}
}
}
cursorX = Math.max(cursorX, inputRows.rightEdge);
this.width = Math.max(this.width, cursorX);
steps.push('H', cursorX);
highlightSteps.push('H', cursorX - 0.5);
steps.push('v', row.height);
if (this.RTL) {
highlightSteps.push('v', row.height - 1);
}
} else if (row.type == Blockly.INPUT_VALUE) {
// External input.
var input = row[0];
var fieldX = cursorX;
var fieldY = cursorY;
if (input.align != Blockly.ALIGN_LEFT) {
var fieldRightX = inputRows.rightEdge - input.fieldWidth -
Blockly.BlockSvg.TAB_WIDTH - 2 * Blockly.BlockSvg.SEP_SPACE_X;
if (input.align == Blockly.ALIGN_RIGHT) {
fieldX += fieldRightX;
} else if (input.align == Blockly.ALIGN_CENTRE) {
fieldX += fieldRightX / 2;
}
}
this.renderFields_(input.fieldRow, fieldX, fieldY);
steps.push(Blockly.BlockSvg.TAB_PATH_DOWN);
var v = row.height - Blockly.BlockSvg.TAB_HEIGHT;
steps.push('v', v);
if (this.RTL) {
// Highlight around back of tab.
highlightSteps.push(Blockly.BlockSvg.TAB_PATH_DOWN_HIGHLIGHT_RTL);
highlightSteps.push('v', v + 0.5);
} else {
// Short highlight glint at bottom of tab.
highlightSteps.push('M', (inputRows.rightEdge - 5) + ',' +
(cursorY + Blockly.BlockSvg.TAB_HEIGHT - 0.7));
highlightSteps.push('l', (Blockly.BlockSvg.TAB_WIDTH * 0.46) +
',-2.1');
}
// Create external input connection.
connectionX = connectionsXY.x +
(this.RTL ? -inputRows.rightEdge - 1 : inputRows.rightEdge + 1);
connectionY = connectionsXY.y + cursorY;
input.connection.moveTo(connectionX, connectionY);
if (input.connection.targetConnection) {
input.connection.tighten_();
this.width = Math.max(this.width, inputRows.rightEdge +
input.connection.targetBlock().getHeightWidth().width -
Blockly.BlockSvg.TAB_WIDTH + 1);
}
} else if (row.type == Blockly.DUMMY_INPUT) {
// External naked field.
var input = row[0];
var fieldX = cursorX;
var fieldY = cursorY;
if (input.align != Blockly.ALIGN_LEFT) {
var fieldRightX = inputRows.rightEdge - input.fieldWidth -
2 * Blockly.BlockSvg.SEP_SPACE_X;
if (inputRows.hasValue) {
fieldRightX -= Blockly.BlockSvg.TAB_WIDTH;
}
if (input.align == Blockly.ALIGN_RIGHT) {
fieldX += fieldRightX;
} else if (input.align == Blockly.ALIGN_CENTRE) {
fieldX += fieldRightX / 2;
}
}
this.renderFields_(input.fieldRow, fieldX, fieldY);
steps.push('v', row.height);
if (this.RTL) {
highlightSteps.push('v', row.height - 1);
}
} else if (row.type == Blockly.NEXT_STATEMENT) {
// Nested statement.
var input = row[0];
if (y == 0) {
// If the first input is a statement stack, add a small row on top.
steps.push('v', Blockly.BlockSvg.SEP_SPACE_Y);
if (this.RTL) {
highlightSteps.push('v', Blockly.BlockSvg.SEP_SPACE_Y - 1);
}
cursorY += Blockly.BlockSvg.SEP_SPACE_Y;
}
var fieldX = cursorX;
var fieldY = cursorY;
if (input.align != Blockly.ALIGN_LEFT) {
var fieldRightX = inputRows.statementEdge - input.fieldWidth -
2 * Blockly.BlockSvg.SEP_SPACE_X;
if (input.align == Blockly.ALIGN_RIGHT) {
fieldX += fieldRightX;
} else if (input.align == Blockly.ALIGN_CENTRE) {
fieldX += fieldRightX / 2;
}
}
this.renderFields_(input.fieldRow, fieldX, fieldY);
cursorX = inputRows.statementEdge + Blockly.BlockSvg.NOTCH_WIDTH;
steps.push('H', cursorX);
steps.push(Blockly.BlockSvg.INNER_TOP_LEFT_CORNER);
steps.push('v', row.height - 2 * Blockly.BlockSvg.CORNER_RADIUS);
steps.push(Blockly.BlockSvg.INNER_BOTTOM_LEFT_CORNER);
steps.push('H', inputRows.rightEdge);
if (this.RTL) {
highlightSteps.push('M',
(cursorX - Blockly.BlockSvg.NOTCH_WIDTH +
Blockly.BlockSvg.DISTANCE_45_OUTSIDE) +
',' + (cursorY + Blockly.BlockSvg.DISTANCE_45_OUTSIDE));
highlightSteps.push(
Blockly.BlockSvg.INNER_TOP_LEFT_CORNER_HIGHLIGHT_RTL);
highlightSteps.push('v',
row.height - 2 * Blockly.BlockSvg.CORNER_RADIUS);
highlightSteps.push(
Blockly.BlockSvg.INNER_BOTTOM_LEFT_CORNER_HIGHLIGHT_RTL);
highlightSteps.push('H', inputRows.rightEdge - 0.5);
} else {
highlightSteps.push('M',
(cursorX - Blockly.BlockSvg.NOTCH_WIDTH +
Blockly.BlockSvg.DISTANCE_45_OUTSIDE) + ',' +
(cursorY + row.height - Blockly.BlockSvg.DISTANCE_45_OUTSIDE));
highlightSteps.push(
Blockly.BlockSvg.INNER_BOTTOM_LEFT_CORNER_HIGHLIGHT_LTR);
highlightSteps.push('H', inputRows.rightEdge - 0.5);
}
// Create statement connection.
connectionX = connectionsXY.x + (this.RTL ? -cursorX : cursorX + 1);
connectionY = connectionsXY.y + cursorY + 1;
input.connection.moveTo(connectionX, connectionY);
if (input.connection.targetConnection) {
input.connection.tighten_();
this.width = Math.max(this.width, inputRows.statementEdge +
input.connection.targetBlock().getHeightWidth().width);
}
if (y == inputRows.length - 1 ||
inputRows[y + 1].type == Blockly.NEXT_STATEMENT) {
// If the final input is a statement stack, add a small row underneath.
// Consecutive statement stacks are also separated by a small divider.
steps.push('v', Blockly.BlockSvg.SEP_SPACE_Y);
if (this.RTL) {
highlightSteps.push('v', Blockly.BlockSvg.SEP_SPACE_Y - 1);
}
cursorY += Blockly.BlockSvg.SEP_SPACE_Y;
}
}
cursorY += row.height;
}
if (!inputRows.length) {
cursorY = Blockly.BlockSvg.MIN_BLOCK_Y;
steps.push('V', cursorY);
if (this.RTL) {
highlightSteps.push('V', cursorY - 1);
}
}
return cursorY;
};
/**
* Render the bottom edge of the block.
* @param {!Array.<string>} steps Path of block outline.
* @param {!Array.<string>} highlightSteps Path of block highlights.
* @param {!Object} connectionsXY Location of block.
* @param {number} cursorY Height of block.
* @private
*/
Blockly.BlockSvg.prototype.renderDrawBottom_ =
function(steps, highlightSteps, connectionsXY, cursorY) {
this.height = cursorY + 1; // Add one for the shadow.
if (this.nextConnection) {
steps.push('H', (Blockly.BlockSvg.NOTCH_WIDTH + (this.RTL ? 0.5 : - 0.5)) +
' ' + Blockly.BlockSvg.NOTCH_PATH_RIGHT);
// Create next block connection.
var connectionX;
if (this.RTL) {
connectionX = connectionsXY.x - Blockly.BlockSvg.NOTCH_WIDTH;
} else {
connectionX = connectionsXY.x + Blockly.BlockSvg.NOTCH_WIDTH;
}
var connectionY = connectionsXY.y + cursorY + 1;
this.nextConnection.moveTo(connectionX, connectionY);
if (this.nextConnection.targetConnection) {
this.nextConnection.tighten_();
}
this.height += 4; // Height of tab.
}
// Should the bottom-left corner be rounded or square?
if (this.squareBottomLeftCorner_) {
steps.push('H 0');
if (!this.RTL) {
highlightSteps.push('M', '0.5,' + (cursorY - 0.5));
}
} else {
steps.push('H', Blockly.BlockSvg.CORNER_RADIUS);
steps.push('a', Blockly.BlockSvg.CORNER_RADIUS + ',' +
Blockly.BlockSvg.CORNER_RADIUS + ' 0 0,1 -' +
Blockly.BlockSvg.CORNER_RADIUS + ',-' +
Blockly.BlockSvg.CORNER_RADIUS);
if (!this.RTL) {
highlightSteps.push('M', Blockly.BlockSvg.DISTANCE_45_INSIDE + ',' +
(cursorY - Blockly.BlockSvg.DISTANCE_45_INSIDE));
highlightSteps.push('A', (Blockly.BlockSvg.CORNER_RADIUS - 0.5) + ',' +
(Blockly.BlockSvg.CORNER_RADIUS - 0.5) + ' 0 0,1 ' +
'0.5,' + (cursorY - Blockly.BlockSvg.CORNER_RADIUS));
}
}
};
/**
* Render the left edge of the block.
* @param {!Array.<string>} steps Path of block outline.
* @param {!Array.<string>} highlightSteps Path of block highlights.
* @param {!Object} connectionsXY Location of block.
* @param {number} cursorY Height of block.
* @private
*/
Blockly.BlockSvg.prototype.renderDrawLeft_ =
function(steps, highlightSteps, connectionsXY, cursorY) {
if (this.outputConnection) {
// Create output connection.
this.outputConnection.moveTo(connectionsXY.x, connectionsXY.y);
// This connection will be tightened when the parent renders.
steps.push('V', Blockly.BlockSvg.TAB_HEIGHT);
steps.push('c 0,-10 -' + Blockly.BlockSvg.TAB_WIDTH + ',8 -' +
Blockly.BlockSvg.TAB_WIDTH + ',-7.5 s ' + Blockly.BlockSvg.TAB_WIDTH +
',2.5 ' + Blockly.BlockSvg.TAB_WIDTH + ',-7.5');
if (this.RTL) {
highlightSteps.push('M', (Blockly.BlockSvg.TAB_WIDTH * -0.25) + ',8.4');
highlightSteps.push('l', (Blockly.BlockSvg.TAB_WIDTH * -0.45) + ',-2.1');
} else {
highlightSteps.push('V', Blockly.BlockSvg.TAB_HEIGHT - 1.5);
highlightSteps.push('m', (Blockly.BlockSvg.TAB_WIDTH * -0.92) +
',-0.5 q ' + (Blockly.BlockSvg.TAB_WIDTH * -0.19) +
',-5.5 0,-11');
highlightSteps.push('m', (Blockly.BlockSvg.TAB_WIDTH * 0.92) +
',1 V 0.5 H 1');
}
this.width += Blockly.BlockSvg.TAB_WIDTH;
} else if (!this.RTL) {
if (this.squareTopLeftCorner_) {
// Statement block in a stack.
highlightSteps.push('V', 0.5);
} else {
highlightSteps.push('V', Blockly.BlockSvg.CORNER_RADIUS);
}
}
steps.push('z');
};
+63 -922
View File
File diff suppressed because it is too large Load Diff
+21 -129
View File
@@ -27,7 +27,7 @@
// Top level object for Blockly.
goog.provide('Blockly');
goog.require('Blockly.BlockSvg');
goog.require('Blockly.BlockSvg.render');
goog.require('Blockly.Events');
goog.require('Blockly.FieldAngle');
goog.require('Blockly.FieldCheckbox');
@@ -45,6 +45,7 @@ goog.require('Blockly.Procedures');
goog.require('Blockly.Toolbox');
goog.require('Blockly.WidgetDiv');
goog.require('Blockly.WorkspaceSvg');
goog.require('Blockly.constants');
goog.require('Blockly.inject');
goog.require('Blockly.utils');
goog.require('goog.color');
@@ -55,97 +56,11 @@ goog.require('goog.userAgent');
var CLOSURE_DEFINES = {'goog.DEBUG': false};
/**
* Required name space for SVG elements.
* @const
* The main workspace most recently used.
* Set by Blockly.WorkspaceSvg.prototype.markFocused
* @type {Blockly.Workspace}
*/
Blockly.SVG_NS = 'http://www.w3.org/2000/svg';
/**
* Required name space for HTML elements.
* @const
*/
Blockly.HTML_NS = 'http://www.w3.org/1999/xhtml';
/**
* The richness of block colours, regardless of the hue.
* Must be in the range of 0 (inclusive) to 1 (exclusive).
*/
Blockly.HSV_SATURATION = 0.45;
/**
* The intensity of block colours, regardless of the hue.
* Must be in the range of 0 (inclusive) to 1 (exclusive).
*/
Blockly.HSV_VALUE = 0.65;
/**
* Sprited icons and images.
*/
Blockly.SPRITE = {
width: 96,
height: 124,
url: 'sprites.png'
};
/**
* Convert a hue (HSV model) into an RGB hex triplet.
* @param {number} hue Hue on a colour wheel (0-360).
* @return {string} RGB code, e.g. '#5ba65b'.
*/
Blockly.hueToRgb = function(hue) {
return goog.color.hsvToHex(hue, Blockly.HSV_SATURATION,
Blockly.HSV_VALUE * 255);
};
/**
* ENUM for a right-facing value input. E.g. 'set item to' or 'return'.
* @const
*/
Blockly.INPUT_VALUE = 1;
/**
* ENUM for a left-facing value output. E.g. 'random fraction'.
* @const
*/
Blockly.OUTPUT_VALUE = 2;
/**
* ENUM for a down-facing block stack. E.g. 'if-do' or 'else'.
* @const
*/
Blockly.NEXT_STATEMENT = 3;
/**
* ENUM for an up-facing block stack. E.g. 'break out of loop'.
* @const
*/
Blockly.PREVIOUS_STATEMENT = 4;
/**
* ENUM for an dummy input. Used to add field(s) with no input.
* @const
*/
Blockly.DUMMY_INPUT = 5;
/**
* ENUM for left alignment.
* @const
*/
Blockly.ALIGN_LEFT = -1;
/**
* ENUM for centre alignment.
* @const
*/
Blockly.ALIGN_CENTRE = 0;
/**
* ENUM for right alignment.
* @const
*/
Blockly.ALIGN_RIGHT = 1;
/**
* Lookup table for determining the opposite type of a connection.
* @const
*/
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.mainWorkspace = null;
/**
* Currently selected block.
@@ -167,38 +82,6 @@ Blockly.highlightedConnection_ = null;
*/
Blockly.localConnection_ = null;
/**
* Number of pixels the mouse must move before a drag starts.
*/
Blockly.DRAG_RADIUS = 5;
/**
* Maximum misalignment between connections for them to snap together.
*/
Blockly.SNAP_RADIUS = 20;
/**
* Delay in ms between trigger and bumping unconnected block out of alignment.
*/
Blockly.BUMP_DELAY = 250;
/**
* Number of characters to truncate a collapsed block to.
*/
Blockly.COLLAPSE_CHARS = 30;
/**
* Length in ms for a touch to become a long press.
*/
Blockly.LONGPRESS = 750;
/**
* The main workspace most recently used.
* Set by Blockly.WorkspaceSvg.prototype.markFocused
* @type {Blockly.Workspace}
*/
Blockly.mainWorkspace = null;
/**
* Contents of the local clipboard.
* @type {Element}
@@ -229,6 +112,16 @@ Blockly.dragMode_ = 0;
*/
Blockly.onTouchUpWrapper_ = null;
/**
* Convert a hue (HSV model) into an RGB hex triplet.
* @param {number} hue Hue on a colour wheel (0-360).
* @return {string} RGB code, e.g. '#5ba65b'.
*/
Blockly.hueToRgb = function(hue) {
return goog.color.hsvToHex(hue, Blockly.HSV_SATURATION,
Blockly.HSV_VALUE * 255);
};
/**
* Returns the dimensions of the specified SVG image.
* @param {!Element} svg SVG image.
@@ -368,6 +261,9 @@ Blockly.onKeyDown_ = function(e) {
if (Blockly.clipboardXml_) {
Blockly.clipboardSource_.paste(Blockly.clipboardXml_);
}
} else if (e.keyCode == 90) {
// 'z' for undo 'Z' is for redo.
Blockly.mainWorkspace.undo(e.shiftKey);
}
}
if (deleteBlock) {
@@ -521,12 +417,8 @@ Blockly.getMainWorkspaceMetrics_ = function() {
var MARGIN = Blockly.Flyout.prototype.CORNER_RADIUS - 1;
var viewWidth = svgSize.width - MARGIN;
var viewHeight = svgSize.height - MARGIN;
try {
var blockBox = this.getCanvas().getBBox();
} catch (e) {
// Firefox has trouble with hidden elements (Bug 528969).
return null;
}
var blockBox = this.getBlocksBoundingBox();
// Fix scale.
var contentWidth = blockBox.width * this.scale;
var contentHeight = blockBox.height * this.scale;
+366 -407
View File
@@ -25,8 +25,8 @@
'use strict';
goog.provide('Blockly.Connection');
goog.provide('Blockly.ConnectionDB');
goog.require('goog.asserts');
goog.require('goog.dom');
@@ -50,6 +50,136 @@ Blockly.Connection = function(source, type) {
}
};
/**
* Constants for checking whether two connections are compatible.
*/
Blockly.Connection.CAN_CONNECT = 0;
Blockly.Connection.REASON_SELF_CONNECTION = 1;
Blockly.Connection.REASON_WRONG_TYPE = 2;
Blockly.Connection.REASON_TARGET_NULL = 3;
Blockly.Connection.REASON_CHECKS_FAILED = 4;
Blockly.Connection.REASON_DIFFERENT_WORKSPACES = 5;
/**
* Connect two connections together.
* @param {!Blockly.Connection} parentConnection Connection on superior block.
* @param {!Blockly.Connection} childConnection Connection on inferior block.
*/
Blockly.Connection.connect_ = function(parentConnection, childConnection) {
var parentBlock = parentConnection.getSourceBlock();
var childBlock = childConnection.getSourceBlock();
// Disconnect any existing parent on the child connection.
if (childConnection.targetConnection) {
childConnection.disconnect();
}
if (parentConnection.targetConnection) {
// Other connection is already connected to something.
// Disconnect it and reattach it or bump it as needed.
var orphanBlock = parentConnection.targetBlock();
var shadowDom = parentConnection.getShadowDom();
// Temporarily set the shadow DOM to null so it does not respawn.
parentConnection.setShadowDom(null);
// Displaced shadow blocks dissolve rather than reattaching or bumping.
if (orphanBlock.isShadow()) {
// Save the shadow block so that field values are preserved.
shadowDom = Blockly.Xml.blockToDom(orphanBlock);
orphanBlock.dispose();
orphanBlock = null;
} else if (parentConnection.type == Blockly.INPUT_VALUE) {
// Value connections.
// If female block is already connected, disconnect and bump the male.
if (!orphanBlock.outputConnection) {
throw 'Orphan block does not have an output connection.';
}
// Attempt to reattach the orphan at the end of the newly inserted
// block. Since this block may be a row, walk down to the end
// or to the first (and only) shadow block.
var connection = Blockly.Connection.lastConnectionInRow_(
childBlock, orphanBlock);
if (connection) {
orphanBlock.outputConnection.connect(connection);
orphanBlock = null;
}
} else if (parentConnection.type == Blockly.NEXT_STATEMENT) {
// Statement connections.
// Statement blocks may be inserted into the middle of a stack.
// Split the stack.
if (!orphanBlock.previousConnection) {
throw 'Orphan block does not have a previous connection.';
}
// Attempt to reattach the orphan at the bottom of the newly inserted
// block. Since this block may be a stack, walk down to the end.
var newBlock = childBlock;
while (newBlock.nextConnection) {
if (newBlock.nextConnection.targetConnection) {
newBlock = newBlock.getNextBlock();
} else {
if (orphanBlock.previousConnection.checkType_(
newBlock.nextConnection)) {
newBlock.nextConnection.connect(orphanBlock.previousConnection);
orphanBlock = null;
}
break;
}
}
}
if (orphanBlock) {
// Unable to reattach orphan.
parentConnection.disconnect();
if (Blockly.Events.recordUndo) {
// Bump it off to the side after a moment.
var group = Blockly.Events.getGroup();
setTimeout(function() {
// Verify orphan hasn't been deleted or reconnected (user on meth).
if (orphanBlock.workspace && !orphanBlock.getParent()) {
Blockly.Events.setGroup(group);
if (orphanBlock.outputConnection) {
orphanBlock.outputConnection.bumpAwayFrom_(parentConnection);
} else if (orphanBlock.previousConnection) {
orphanBlock.previousConnection.bumpAwayFrom_(parentConnection);
}
Blockly.Events.setGroup(false);
}
}, Blockly.BUMP_DELAY);
}
}
// Restore the shadow DOM.
parentConnection.setShadowDom(shadowDom);
}
var event;
if (Blockly.Events.isEnabled()) {
event = new Blockly.Events.Move(childBlock);
}
// Establish the connections.
Blockly.Connection.connectReciprocally_(parentConnection, childConnection);
// Demote the inferior block so that one is a child of the superior one.
childBlock.setParent(parentBlock);
if (event) {
event.recordNew();
Blockly.Events.fire(event);
}
if (parentBlock.rendered) {
parentBlock.updateDisabled();
}
if (childBlock.rendered) {
childBlock.updateDisabled();
}
if (parentBlock.rendered && childBlock.rendered) {
if (parentConnection.type == Blockly.NEXT_STATEMENT ||
parentConnection.type == Blockly.PREVIOUS_STATEMENT) {
// Child block may need to square off its corners if it is in a stack.
// Rendering a child will render its parent.
childBlock.render();
} else {
// Child block does not change shape. Rendering the parent node will
// move its connected children into position.
parentBlock.render();
}
}
};
/**
* Connection this connection connects to. Null if not connected.
* @type {Blockly.Connection}
@@ -133,6 +263,14 @@ Blockly.Connection.prototype.dispose = function() {
this.dbOpposite_ = null;
};
/**
* Get the source block for this connection.
* @return {Blockly.Block} The source block, or null if there is none.
*/
Blockly.Connection.prototype.getSourceBlock = function() {
return this.sourceBlock_;
};
/**
* Does the connection belong to a superior block (higher in the source stack)?
* @return {boolean} True if connection faces down or right.
@@ -142,126 +280,163 @@ Blockly.Connection.prototype.isSuperior = function() {
this.type == Blockly.NEXT_STATEMENT;
};
/**
* Returns the distance between this connection and another connection.
* @param {!Blockly.Connection} otherConnection The other connection to measure
* the distance to.
* @return {number} The distance between connections.
*/
Blockly.Connection.prototype.distanceFrom = function(otherConnection) {
var xDiff = this.x_ - otherConnection.x_;
var yDiff = this.y_ - otherConnection.y_;
return Math.sqrt(xDiff * xDiff + yDiff * yDiff);
};
/**
* Checks whether the current connection can connect with the target
* connection.
* @param {Blockly.Connection} target Connection to check compatibility with.
* @return {number} Blockly.Connection.CAN_CONNECT if the connection is legal,
* an error code otherwise.
* @private
*/
Blockly.Connection.prototype.canConnectWithReason_ = function(target) {
if (!target) {
return Blockly.Connection.REASON_TARGET_NULL;
} else if (this.sourceBlock_ &&
target.getSourceBlock() == this.sourceBlock_) {
return Blockly.Connection.REASON_SELF_CONNECTION;
} else if (target.type != Blockly.OPPOSITE_TYPE[this.type]) {
return Blockly.Connection.REASON_WRONG_TYPE;
} else if (this.sourceBlock_ && target.getSourceBlock() &&
this.sourceBlock_.workspace !== target.getSourceBlock().workspace) {
return Blockly.Connection.REASON_DIFFERENT_WORKSPACES;
} else if (!this.checkType_(target)) {
return Blockly.Connection.REASON_CHECKS_FAILED;
}
return Blockly.Connection.CAN_CONNECT;
};
/**
* Checks whether the current connection and target connection are compatible
* and throws an exception if they are not.
* @param {Blockly.Connection} target The connection to check compatibility
* with.
* @private
*/
Blockly.Connection.prototype.checkConnection_ = function(target) {
switch (this.canConnectWithReason_(target)) {
case Blockly.Connection.CAN_CONNECT:
break;
case Blockly.Connection.REASON_SELF_CONNECTION:
throw 'Attempted to connect a block to itself.';
case Blockly.Connection.REASON_DIFFERENT_WORKSPACES:
// Usually this means one block has been deleted.
throw 'Blocks not on same workspace.';
case Blockly.Connection.REASON_WRONG_TYPE:
throw 'Attempt to connect incompatible types.';
case Blockly.Connection.REASON_TARGET_NULL:
throw 'Target connection is null.';
case Blockly.Connection.REASON_CHECKS_FAILED:
throw 'Connection checks failed.';
default:
throw 'Unknown connection failure: this should never happen!';
}
};
/**
* Check if the two connections can be dragged to connect to each other.
* @param {!Blockly.Connection} candidate A nearby connection to check.
* @param {number} maxRadius The maximum radius allowed for connections.
* @return {boolean} True if the connection is allowed, false otherwise.
*/
Blockly.Connection.prototype.isConnectionAllowed = function(candidate,
maxRadius) {
if (this.distanceFrom(candidate) > maxRadius) {
return false;
}
// Type checking.
var canConnect = this.canConnectWithReason_(candidate);
if (canConnect != Blockly.Connection.CAN_CONNECT &&
canConnect != Blockly.Connection.REASON_MUST_DISCONNECT) {
return false;
}
// Don't offer to connect an already connected left (male) value plug to
// an available right (female) value plug. Don't offer to connect the
// bottom of a statement block to one that's already connected.
if (candidate.type == Blockly.OUTPUT_VALUE ||
candidate.type == Blockly.PREVIOUS_STATEMENT) {
if (candidate.targetConnection || this.targetConnection) {
return false;
}
}
// Offering to connect the left (male) of a value block to an already
// connected value pair is ok, we'll splice it in.
// However, don't offer to splice into an unmovable block.
if (candidate.type == Blockly.INPUT_VALUE &&
candidate.targetConnection &&
!candidate.targetBlock().isMovable() &&
!candidate.targetBlock().isShadow()) {
return false;
}
// Don't let a block with no next connection bump other blocks out of the
// stack.
if (this.type == Blockly.PREVIOUS_STATEMENT &&
candidate.targetConnection &&
!this.sourceBlock_.nextConnection) {
return false;
}
// Don't let blocks try to connect to themselves or ones they nest.
var targetSourceBlock = candidate.getSourceBlock();
var sourceBlock = this.sourceBlock_;
if (targetSourceBlock && sourceBlock) {
do {
if (sourceBlock == targetSourceBlock) {
return false;
}
targetSourceBlock = targetSourceBlock.getParent();
} while (targetSourceBlock);
}
return true;
};
/**
* Connect this connection to another connection.
* @param {!Blockly.Connection} otherConnection Connection to connect to.
*/
Blockly.Connection.prototype.connect = function(otherConnection) {
if (this.sourceBlock_ == otherConnection.sourceBlock_) {
throw 'Attempted to connect a block to itself.';
if (this.targetConnection == otherConnection) {
// Already connected together. NOP.
return;
}
if (this.sourceBlock_.workspace !== otherConnection.sourceBlock_.workspace) {
throw 'Blocks are on different workspaces.';
}
if (Blockly.OPPOSITE_TYPE[this.type] != otherConnection.type) {
throw 'Attempt to connect incompatible types.';
}
if (this.targetConnection) {
throw 'Source connection already connected.';
}
if (otherConnection.targetConnection) {
// Other connection is already connected to something.
var orphanBlock = otherConnection.targetBlock();
if (orphanBlock.isShadow()) {
orphanBlock.dispose();
orphanBlock = null;
} else if (this.type == Blockly.INPUT_VALUE ||
this.type == Blockly.OUTPUT_VALUE) {
// Value connections.
// If female block is already connected, disconnect and bump the male.
orphanBlock.setParent(null);
if (!orphanBlock.outputConnection) {
throw 'Orphan block does not have an output connection.';
}
// Attempt to reattach the orphan at the end of the newly inserted
// block. Since this block may be a row, walk down to the end.
var newBlock = this.sourceBlock_;
var connection;
while (connection = Blockly.Connection.singleConnection_(
/** @type {!Blockly.Block} */ (newBlock), orphanBlock)) {
// '=' is intentional in line above.
newBlock = connection.targetBlock();
if (!newBlock || newBlock.isShadow()) {
orphanBlock.outputConnection.connect(connection);
orphanBlock = null;
break;
}
}
} else if (this.type == Blockly.PREVIOUS_STATEMENT) {
// Statement connections.
// Statement blocks may be inserted into the middle of a stack.
// Split the stack.
orphanBlock.setParent(null);
if (!orphanBlock.previousConnection) {
throw 'Orphan block does not have a previous connection.';
}
// Attempt to reattach the orphan at the bottom of the newly inserted
// block. Since this block may be a stack, walk down to the end.
var newBlock = this.sourceBlock_;
while (newBlock.nextConnection) {
if (newBlock.nextConnection.targetConnection) {
newBlock = newBlock.getNextBlock();
} else {
if (orphanBlock.previousConnection.checkType_(
newBlock.nextConnection)) {
newBlock.nextConnection.connect(orphanBlock.previousConnection);
orphanBlock = null;
}
break;
}
}
} else {
// Type is Blockly.NEXT_STATEMENT.
throw 'Can only do a mid-stack connection with the top of a block.';
}
if (orphanBlock) {
// Unable to reattach orphan. Bump it off to the side after a moment.
setTimeout(function() {
// Verify orphan hasn't been deleted or reconnected (user on meth).
if (orphanBlock.workspace && !orphanBlock.getParent()) {
orphanBlock.outputConnection.bumpAwayFrom_(otherConnection);
}
}, Blockly.BUMP_DELAY);
}
}
this.checkConnection_(otherConnection);
// Determine which block is superior (higher in the source stack).
var parentBlock, childBlock;
if (this.isSuperior()) {
// Superior block.
parentBlock = this.sourceBlock_;
childBlock = otherConnection.sourceBlock_;
Blockly.Connection.connect_(this, otherConnection);
} else {
// Inferior block.
parentBlock = otherConnection.sourceBlock_;
childBlock = this.sourceBlock_;
Blockly.Connection.connect_(otherConnection, this);
}
};
// Establish the connections.
this.targetConnection = otherConnection;
otherConnection.targetConnection = this;
// Demote the inferior block so that one is a child of the superior one.
childBlock.setParent(parentBlock);
if (parentBlock.rendered) {
parentBlock.updateDisabled();
}
if (childBlock.rendered) {
childBlock.updateDisabled();
}
if (parentBlock.rendered && childBlock.rendered) {
if (this.type == Blockly.NEXT_STATEMENT ||
this.type == Blockly.PREVIOUS_STATEMENT) {
// Child block may need to square off its corners if it is in a stack.
// Rendering a child will render its parent.
childBlock.render();
} else {
// Child block does not change shape. Rendering the parent node will
// move its connected children into position.
parentBlock.render();
}
}
/**
* Update two connections to target each other.
* @param {Blockly.Connection} first The first connection to update.
* @param {Blockly.Connection} second The second conneciton to update.
* @private
*/
Blockly.Connection.connectReciprocally_ = function(first, second) {
goog.asserts.assert(first && second, 'Cannot connect null connections.');
first.targetConnection = second;
second.targetConnection = first;
};
/**
@@ -288,35 +463,69 @@ Blockly.Connection.singleConnection_ = function(block, orphanBlock) {
return connection;
};
/**
* Walks down a row a blocks, at each stage checking if there are any
* connections that will accept the orphaned block. If at any point there
* are zero or multiple eligible connections, returns null. Otherwise
* returns the only input on the last block in the chain.
* Terminates early for shadow blocks.
* @param {!Blockly.Block} startBlock The block on which to start the search.
* @param {!Blockly.Block} orphanBlock The block that is looking for a home.
* @return {Blockly.Connection} The suitable connection point on the chain
* of blocks, or null.
* @private
*/
Blockly.Connection.lastConnectionInRow_ = function(startBlock, orphanBlock) {
var newBlock = startBlock;
var connection;
while (connection = Blockly.Connection.singleConnection_(
/** @type {!Blockly.Block} */ (newBlock), orphanBlock)) {
// '=' is intentional in line above.
newBlock = connection.targetBlock();
if (!newBlock || newBlock.isShadow()) {
return connection;
}
}
return null;
};
/**
* Disconnect this connection.
*/
Blockly.Connection.prototype.disconnect = function() {
var otherConnection = this.targetConnection;
if (!otherConnection) {
throw 'Source connection not connected.';
} else if (otherConnection.targetConnection != this) {
throw 'Target connection not connected to source connection.';
}
otherConnection.targetConnection = null;
this.targetConnection = null;
goog.asserts.assert(otherConnection, 'Source connection not connected.');
goog.asserts.assert(otherConnection.targetConnection == this,
'Target connection not connected to source connection.');
// Rerender the parent so that it may reflow.
var parentBlock, childBlock, parentConnection;
if (this.isSuperior()) {
// Superior block.
parentBlock = this.sourceBlock_;
childBlock = otherConnection.sourceBlock_;
childBlock = otherConnection.getSourceBlock();
parentConnection = this;
} else {
// Inferior block.
parentBlock = otherConnection.sourceBlock_;
parentBlock = otherConnection.getSourceBlock();
childBlock = this.sourceBlock_;
parentConnection = otherConnection;
}
var event;
if (Blockly.Events.isEnabled()) {
event = new Blockly.Events.Move(childBlock);
}
otherConnection.targetConnection = null;
this.targetConnection = null;
childBlock.setParent(null);
if (event) {
event.recordNew();
Blockly.Events.fire(event);
}
// Respawn the shadow block if there is one.
var shadow = parentConnection.getShadowDom();
if (parentBlock.workspace && !childBlock.isShadow() && shadow) {
// Respawn the shadow block.
if (parentBlock.workspace && shadow && Blockly.Events.recordUndo) {
var blockShadow =
Blockly.Xml.domToBlock(parentBlock.workspace, shadow);
if (blockShadow.outputConnection) {
@@ -329,6 +538,8 @@ Blockly.Connection.prototype.disconnect = function() {
blockShadow.initSvg();
blockShadow.render(false);
}
// Rerender the parent so that it may reflow.
if (parentBlock.rendered) {
parentBlock.render();
}
@@ -344,7 +555,7 @@ Blockly.Connection.prototype.disconnect = function() {
*/
Blockly.Connection.prototype.targetBlock = function() {
if (this.targetConnection) {
return this.targetConnection.sourceBlock_;
return this.targetConnection.getSourceBlock();
}
return null;
};
@@ -371,7 +582,7 @@ Blockly.Connection.prototype.bumpAwayFrom_ = function(staticConnection) {
if (!rootBlock.isMovable()) {
// Can't bump an uneditable block away.
// Check to see if the other block is movable.
rootBlock = staticConnection.sourceBlock_.getRootBlock();
rootBlock = staticConnection.getSourceBlock().getRootBlock();
if (!rootBlock.isMovable()) {
return;
}
@@ -407,7 +618,7 @@ Blockly.Connection.prototype.moveTo = function(x, y) {
this.y_ = y;
// Insert it into its new location in the database.
if (!this.hidden_) {
this.db_.addConnection_(this);
this.db_.addConnection(this);
}
};
@@ -420,38 +631,6 @@ Blockly.Connection.prototype.moveBy = function(dx, dy) {
this.moveTo(this.x_ + dx, this.y_ + dy);
};
/**
* Add highlighting around this connection.
*/
Blockly.Connection.prototype.highlight = function() {
var steps;
if (this.type == Blockly.INPUT_VALUE || this.type == Blockly.OUTPUT_VALUE) {
var tabWidth = this.sourceBlock_.RTL ? -Blockly.BlockSvg.TAB_WIDTH :
Blockly.BlockSvg.TAB_WIDTH;
steps = 'm 0,0 ' + Blockly.BlockSvg.TAB_PATH_DOWN + ' v 5';
} else {
steps = 'm -20,0 h 5 ' + Blockly.BlockSvg.NOTCH_PATH_LEFT + ' h 5';
}
var xy = this.sourceBlock_.getRelativeToSurfaceXY();
var x = this.x_ - xy.x;
var y = this.y_ - xy.y;
Blockly.Connection.highlightedPath_ = Blockly.createSvgElement('path',
{'class': 'blocklyHighlightedConnectionPath',
'd': steps,
transform: 'translate(' + x + ',' + y + ')' +
(this.sourceBlock_.RTL ? ' scale(-1 1)' : '')},
this.sourceBlock_.getSvgRoot());
};
/**
* Remove the highlighting around this connection.
*/
Blockly.Connection.prototype.unhighlight = function() {
goog.dom.removeNode(Blockly.Connection.highlightedPath_);
delete Blockly.Connection.highlightedPath_;
};
/**
* Move the blocks on either side of this connection right next to each other.
* @private
@@ -479,108 +658,12 @@ Blockly.Connection.prototype.tighten_ = function() {
* in the database and the current location (as a result of dragging).
* @param {number} dy Vertical offset between this connection's location
* in the database and the current location (as a result of dragging).
* @return {!{connection: ?Blockly.Connection, radius: number}} Contains two properties: 'connection' which is either
* another connection or null, and 'radius' which is the distance.
* @return {!{connection: ?Blockly.Connection, radius: number}} Contains two
* properties:' connection' which is either another connection or null,
* and 'radius' which is the distance.
*/
Blockly.Connection.prototype.closest = function(maxLimit, dx, dy) {
if (this.targetConnection) {
// Don't offer to connect to a connection that's already connected.
return {connection: null, radius: maxLimit};
}
// Determine the opposite type of connection.
var db = this.dbOpposite_;
// Since this connection is probably being dragged, add the delta.
var currentX = this.x_ + dx;
var currentY = this.y_ + dy;
// Binary search to find the closest y location.
var pointerMin = 0;
var pointerMax = db.length - 2;
var pointerMid = pointerMax;
while (pointerMin < pointerMid) {
if (db[pointerMid].y_ < currentY) {
pointerMin = pointerMid;
} else {
pointerMax = pointerMid;
}
pointerMid = Math.floor((pointerMin + pointerMax) / 2);
}
// Walk forward and back on the y axis looking for the closest x,y point.
pointerMin = pointerMid;
pointerMax = pointerMid;
var closestConnection = null;
var sourceBlock = this.sourceBlock_;
var thisConnection = this;
if (db.length) {
while (pointerMin >= 0 && checkConnection_(pointerMin)) {
pointerMin--;
}
do {
pointerMax++;
} while (pointerMax < db.length && checkConnection_(pointerMax));
}
/**
* Computes if the current connection is within the allowed radius of another
* connection.
* This function is a closure and has access to outside variables.
* @param {number} yIndex The other connection's index in the database.
* @return {boolean} True if the search needs to continue: either the current
* connection's vertical distance from the other connection is less than
* the allowed radius, or if the connection is not compatible.
* @private
*/
function checkConnection_(yIndex) {
var connection = db[yIndex];
if (connection.type == Blockly.OUTPUT_VALUE ||
connection.type == Blockly.PREVIOUS_STATEMENT) {
// Don't offer to connect an already connected left (male) value plug to
// an available right (female) value plug. Don't offer to connect the
// bottom of a statement block to one that's already connected.
if (connection.targetConnection) {
return true;
}
}
// Offering to connect the top of a statement block to an already connected
// connection is ok, we'll just insert it into the stack.
// Offering to connect the left (male) of a value block to an already
// connected value pair is ok, we'll splice it in.
// However, don't offer to splice into an unmovable block.
if (connection.type == Blockly.INPUT_VALUE &&
connection.targetConnection &&
!connection.targetBlock().isMovable() &&
!connection.targetBlock().isShadow()) {
return true;
}
// Do type checking.
if (!thisConnection.checkType_(connection)) {
return true;
}
// Don't let blocks try to connect to themselves or ones they nest.
var targetSourceBlock = connection.sourceBlock_;
do {
if (sourceBlock == targetSourceBlock) {
return true;
}
targetSourceBlock = targetSourceBlock.getParent();
} while (targetSourceBlock);
// Only connections within the maxLimit radius.
var dx = currentX - connection.x_;
var dy = currentY - connection.y_;
var r = Math.sqrt(dx * dx + dy * dy);
if (r <= maxLimit) {
closestConnection = connection;
maxLimit = r;
}
return Math.abs(dy) < maxLimit;
}
return {connection: closestConnection, radius: maxLimit};
return this.dbOpposite_.searchForClosest(this, maxLimit, dx, dy);
};
/**
@@ -599,7 +682,7 @@ Blockly.Connection.prototype.checkType_ = function(otherConnection) {
}
var otherTargetBlock = otherConnection.targetBlock();
if (otherTargetBlock && !otherTargetBlock.isMovable() &&
!otherConnection.sourceBlock_.isMovable()) {
!otherConnection.getSourceBlock().isMovable()) {
return false;
}
if (!this.check_ || !otherConnection.check_) {
@@ -633,7 +716,7 @@ Blockly.Connection.prototype.setCheck = function(check) {
// The new value type may not be compatible with the existing connection.
if (this.targetConnection && !this.checkType_(this.targetConnection)) {
var child = this.isSuperior() ? this.targetBlock() : this.sourceBlock_;
child.setParent(null);
child.unplug();
// Bump away.
this.sourceBlock_.bumpNeighbours_();
}
@@ -667,59 +750,11 @@ Blockly.Connection.prototype.getShadowDom = function() {
* @private
*/
Blockly.Connection.prototype.neighbours_ = function(maxLimit) {
// Determine the opposite type of connection.
var db = this.dbOpposite_;
var currentX = this.x_;
var currentY = this.y_;
// Binary search to find the closest y location.
var pointerMin = 0;
var pointerMax = db.length - 2;
var pointerMid = pointerMax;
while (pointerMin < pointerMid) {
if (db[pointerMid].y_ < currentY) {
pointerMin = pointerMid;
} else {
pointerMax = pointerMid;
}
pointerMid = Math.floor((pointerMin + pointerMax) / 2);
}
// Walk forward and back on the y axis looking for the closest x,y point.
pointerMin = pointerMid;
pointerMax = pointerMid;
var neighbours = [];
var sourceBlock = this.sourceBlock_;
if (db.length) {
while (pointerMin >= 0 && checkConnection_(pointerMin)) {
pointerMin--;
}
do {
pointerMax++;
} while (pointerMax < db.length && checkConnection_(pointerMax));
}
/**
* Computes if the current connection is within the allowed radius of another
* connection.
* This function is a closure and has access to outside variables.
* @param {number} yIndex The other connection's index in the database.
* @return {boolean} True if the current connection's vertical distance from
* the other connection is less than the allowed radius.
*/
function checkConnection_(yIndex) {
var dx = currentX - db[yIndex].x_;
var dy = currentY - db[yIndex].y_;
var r = Math.sqrt(dx * dx + dy * dy);
if (r <= maxLimit) {
neighbours.push(db[yIndex]);
}
return dy < maxLimit;
}
return neighbours;
return this.dbOpposite_.getNeighbours(this, maxLimit);
};
// Appearance or lack thereof.
/**
* Set whether this connections is hidden (not tracked in a database) or not.
* @param {boolean} hidden True if connection is hidden.
@@ -729,7 +764,7 @@ Blockly.Connection.prototype.setHidden = function(hidden) {
if (hidden && this.inDB_) {
this.db_.removeConnection_(this);
} else if (!hidden && !this.inDB_) {
this.db_.addConnection_(this);
this.db_.addConnection(this);
}
};
@@ -791,7 +826,7 @@ Blockly.Connection.prototype.unhideAll = function() {
for (var c = 0; c < connections.length; c++) {
renderList.push.apply(renderList, connections[c].unhideAll());
}
if (renderList.length == 0) {
if (!renderList.length) {
// Leaf block.
renderList[0] = block;
}
@@ -799,110 +834,34 @@ Blockly.Connection.prototype.unhideAll = function() {
return renderList;
};
/**
* Database of connections.
* Connections are stored in order of their vertical component. This way
* connections in an area may be looked up quickly using a binary search.
* @constructor
* Add highlighting around this connection.
*/
Blockly.ConnectionDB = function() {
};
Blockly.Connection.prototype.highlight = function() {
var steps;
if (this.type == Blockly.INPUT_VALUE || this.type == Blockly.OUTPUT_VALUE) {
var tabWidth = this.sourceBlock_.RTL ? -Blockly.BlockSvg.TAB_WIDTH :
Blockly.BlockSvg.TAB_WIDTH;
steps = 'm 0,0 ' + Blockly.BlockSvg.TAB_PATH_DOWN + ' v 5';
Blockly.ConnectionDB.prototype = new Array();
/**
* Don't inherit the constructor from Array.
* @type {!Function}
*/
Blockly.ConnectionDB.constructor = Blockly.ConnectionDB;
/**
* Add a connection to the database. Must not already exist in DB.
* @param {!Blockly.Connection} connection The connection to be added.
* @private
*/
Blockly.ConnectionDB.prototype.addConnection_ = function(connection) {
if (connection.inDB_) {
throw 'Connection already in database.';
} else {
steps = 'm -20,0 h 5 ' + Blockly.BlockSvg.NOTCH_PATH_LEFT + ' h 5';
}
if (connection.sourceBlock_.isInFlyout) {
// Don't bother maintaining a database of connections in a flyout.
return;
}
// Insert connection using binary search.
var pointerMin = 0;
var pointerMax = this.length;
while (pointerMin < pointerMax) {
var pointerMid = Math.floor((pointerMin + pointerMax) / 2);
if (this[pointerMid].y_ < connection.y_) {
pointerMin = pointerMid + 1;
} else if (this[pointerMid].y_ > connection.y_) {
pointerMax = pointerMid;
} else {
pointerMin = pointerMid;
break;
}
}
this.splice(pointerMin, 0, connection);
connection.inDB_ = true;
var xy = this.sourceBlock_.getRelativeToSurfaceXY();
var x = this.x_ - xy.x;
var y = this.y_ - xy.y;
Blockly.Connection.highlightedPath_ = Blockly.createSvgElement('path',
{'class': 'blocklyHighlightedConnectionPath',
'd': steps,
transform: 'translate(' + x + ',' + y + ')' +
(this.sourceBlock_.RTL ? ' scale(-1 1)' : '')},
this.sourceBlock_.getSvgRoot());
};
/**
* Remove a connection from the database. Must already exist in DB.
* @param {!Blockly.Connection} connection The connection to be removed.
* @private
* Remove the highlighting around this connection.
*/
Blockly.ConnectionDB.prototype.removeConnection_ = function(connection) {
if (!connection.inDB_) {
throw 'Connection not in database.';
}
connection.inDB_ = false;
// Find the connection using a binary search.
// About 10% faster than a linear search using indexOf.
var pointerMin = 0;
var pointerMax = this.length - 2;
var pointerMid = pointerMax;
while (pointerMin < pointerMid) {
if (this[pointerMid].y_ < connection.y_) {
pointerMin = pointerMid;
} else {
pointerMax = pointerMid;
}
pointerMid = Math.floor((pointerMin + pointerMax) / 2);
}
// Walk forward and back on the y axis looking for the connection.
// When found, splice it out of the array.
pointerMin = pointerMid;
pointerMax = pointerMid;
while (pointerMin >= 0 && this[pointerMin].y_ == connection.y_) {
if (this[pointerMin] == connection) {
this.splice(pointerMin, 1);
return;
}
pointerMin--;
}
do {
if (this[pointerMax] == connection) {
this.splice(pointerMax, 1);
return;
}
pointerMax++;
} while (pointerMax < this.length &&
this[pointerMax].y_ == connection.y_);
throw 'Unable to find connection in connectionDB.';
};
/**
* Initialize a set of connection DBs for a specified workspace.
* @param {!Blockly.Workspace} workspace The workspace this DB is for.
*/
Blockly.ConnectionDB.init = function(workspace) {
// Create four databases, one for each connection type.
var dbList = [];
dbList[Blockly.INPUT_VALUE] = new Blockly.ConnectionDB();
dbList[Blockly.OUTPUT_VALUE] = new Blockly.ConnectionDB();
dbList[Blockly.NEXT_STATEMENT] = new Blockly.ConnectionDB();
dbList[Blockly.PREVIOUS_STATEMENT] = new Blockly.ConnectionDB();
workspace.connectionDBList = dbList;
Blockly.Connection.prototype.unhighlight = function() {
goog.dom.removeNode(Blockly.Connection.highlightedPath_);
delete Blockly.Connection.highlightedPath_;
};
+302
View File
@@ -0,0 +1,302 @@
/**
* @license
* Visual Blocks Editor
*
* Copyright 2011 Google Inc.
* https://developers.google.com/blockly/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview Components for managing connections between blocks.
* @author fraser@google.com (Neil Fraser)
*/
'use strict';
goog.provide('Blockly.ConnectionDB');
goog.require('Blockly.Connection');
/**
* Database of connections.
* Connections are stored in order of their vertical component. This way
* connections in an area may be looked up quickly using a binary search.
* @constructor
*/
Blockly.ConnectionDB = function() {
};
Blockly.ConnectionDB.prototype = new Array();
/**
* Don't inherit the constructor from Array.
* @type {!Function}
*/
Blockly.ConnectionDB.constructor = Blockly.ConnectionDB;
/**
* Add a connection to the database. Must not already exist in DB.
* @param {!Blockly.Connection} connection The connection to be added.
*/
Blockly.ConnectionDB.prototype.addConnection = function(connection) {
if (connection.inDB_) {
throw 'Connection already in database.';
}
if (connection.getSourceBlock().isInFlyout) {
// Don't bother maintaining a database of connections in a flyout.
return;
}
var position = this.findPositionForConnection_(connection);
this.splice(position, 0, connection);
connection.inDB_ = true;
};
/**
* Find the given connection.
* Starts by doing a binary search to find the approximate location, then
* linearly searches nearby for the exact connection.
* @param {Blockly.Connection} conn The connection to find.
* @return {number} The index of the connection, or -1 if the connection was
* not found.
*/
Blockly.ConnectionDB.prototype.findConnection = function(conn) {
if (!this.length) {
return -1;
}
var bestGuess = this.findPositionForConnection_(conn);
if (bestGuess >= this.length) {
// Not in list
return -1;
}
var yPos = conn.y_;
// Walk forward and back on the y axis looking for the connection.
var pointerMin = bestGuess;
var pointerMax = bestGuess;
while (pointerMin >= 0 && this[pointerMin].y_ == yPos) {
if (this[pointerMin] == conn) {
return pointerMin;
}
pointerMin--;
}
while (pointerMax < this.length && this[pointerMax].y_ == yPos) {
if (this[pointerMax] == conn) {
return pointerMax;
}
pointerMax++;
}
return -1;
};
/**
* Finds a candidate position for inserting this connection into the list.
* This will be in the correct y order but makes no guarantees about ordering in
* the x axis.
* @param {Blockly.Connection} connection The connection to insert.
* @return {number} The candidate index.
* @private
*/
Blockly.ConnectionDB.prototype.findPositionForConnection_ =
function(connection) {
if (!this.length) {
return 0;
}
var pointerMin = 0;
var pointerMax = this.length;
while (pointerMin < pointerMax) {
var pointerMid = Math.floor((pointerMin + pointerMax) / 2);
if (this[pointerMid].y_ < connection.y_) {
pointerMin = pointerMid + 1;
} else if (this[pointerMid].y_ > connection.y_) {
pointerMax = pointerMid;
} else {
pointerMin = pointerMid;
break;
}
}
return pointerMin;
};
/**
* Remove a connection from the database. Must already exist in DB.
* @param {!Blockly.Connection} connection The connection to be removed.
* @private
*/
Blockly.ConnectionDB.prototype.removeConnection_ = function(connection) {
if (!connection.inDB_) {
throw 'Connection not in database.';
}
var removalIndex = this.findConnection(connection);
if (removalIndex == -1) {
throw 'Unable to find connection in connectionDB.';
}
connection.inDB_ = false;
this.splice(removalIndex, 1);
};
/**
* Find all nearby connections to the given connection.
* Type checking does not apply, since this function is used for bumping.
* @param {!Blockly.Connection} connection The connection whose neighbours
* should be returned.
* @param {number} maxRadius The maximum radius to another connection.
* @return {!Array.<Blockly.Connection>} List of connections.
*/
Blockly.ConnectionDB.prototype.getNeighbours = function(connection, maxRadius) {
var db = this;
var currentX = connection.x_;
var currentY = connection.y_;
// Binary search to find the closest y location.
var pointerMin = 0;
var pointerMax = db.length - 2;
var pointerMid = pointerMax;
while (pointerMin < pointerMid) {
if (db[pointerMid].y_ < currentY) {
pointerMin = pointerMid;
} else {
pointerMax = pointerMid;
}
pointerMid = Math.floor((pointerMin + pointerMax) / 2);
}
// Walk forward and back on the y axis looking for the closest x,y point.
pointerMin = pointerMid;
pointerMax = pointerMid;
var neighbours = [];
var sourceBlock = connection.getSourceBlock();
if (db.length) {
while (pointerMin >= 0 && checkConnection_(pointerMin)) {
pointerMin--;
}
do {
pointerMax++;
} while (pointerMax < db.length && checkConnection_(pointerMax));
}
/**
* Computes if the current connection is within the allowed radius of another
* connection.
* This function is a closure and has access to outside variables.
* @param {number} yIndex The other connection's index in the database.
* @return {boolean} True if the current connection's vertical distance from
* the other connection is less than the allowed radius.
*/
function checkConnection_(yIndex) {
var dx = currentX - db[yIndex].x_;
var dy = currentY - db[yIndex].y_;
var r = Math.sqrt(dx * dx + dy * dy);
if (r <= maxRadius) {
neighbours.push(db[yIndex]);
}
return dy < maxRadius;
}
return neighbours;
};
/**
* Is the candidate connection close to the reference connection.
* Extremely fast; only looks at Y distance.
* @param {number} index Index in database of candidate connection.
* @param {number} baseY Reference connection's Y value.
* @param {number} maxRadius The maximum radius to another connection.
* @return {boolean} True if connection is in range.
* @private
*/
Blockly.ConnectionDB.prototype.isInYRange_ = function(index, baseY, maxRadius) {
return (Math.abs(this[index].y_ - baseY) <= maxRadius);
};
/**
* Find the closest compatible connection to this connection.
* @param {Blockly.Connection} conn The connection searching for a compatible
* mate.
* @param {number} maxRadius The maximum radius to another connection.
* @param {number} dx Horizontal offset between this connection's location
* in the database and the current location (as a result of dragging).
* @param {number} dy Vertical offset between this connection's location
* in the database and the current location (as a result of dragging).
* @return {!{connection: ?Blockly.Connection, radius: number}} Contains two
* properties:' connection' which is either another connection or null,
* and 'radius' which is the distance.
*/
Blockly.ConnectionDB.prototype.searchForClosest = function(conn, maxRadius, dx,
dy) {
// Don't bother.
if (!this.length) {
return {connection: null, radius: maxRadius};
}
// Stash the values of x and y from before the drag.
var baseY = conn.y_;
var baseX = conn.x_;
conn.x_ = baseX + dx;
conn.y_ = baseY + dy;
// findPositionForConnection finds an index for insertion, which is always
// after any block with the same y index. We want to search both forward
// and back, so search on both sides of the index.
var closestIndex = this.findPositionForConnection_(conn);
var bestConnection = null;
var bestRadius = maxRadius;
var temp;
// Walk forward and back on the y axis looking for the closest x,y point.
var pointerMin = closestIndex - 1;
while (pointerMin >= 0 && this.isInYRange_(pointerMin, conn.y_, maxRadius)) {
temp = this[pointerMin];
if (conn.isConnectionAllowed(temp, bestRadius)) {
bestConnection = temp;
bestRadius = temp.distanceFrom(conn);
}
pointerMin--;
}
var pointerMax = closestIndex;
while (pointerMax < this.length && this.isInYRange_(pointerMax, conn.y_,
maxRadius)) {
temp = this[pointerMax];
if (conn.isConnectionAllowed(temp, bestRadius)) {
bestConnection = temp;
bestRadius = temp.distanceFrom(conn);
}
pointerMax++;
}
// Reset the values of x and y.
conn.x_ = baseX;
conn.y_ = baseY;
// If there were no valid connections, bestConnection will be null.
return {connection: bestConnection, radius: bestRadius};
};
/**
* Initialize a set of connection DBs for a specified workspace.
* @param {!Blockly.Workspace} workspace The workspace this DB is for.
*/
Blockly.ConnectionDB.init = function(workspace) {
// Create four databases, one for each connection type.
var dbList = [];
dbList[Blockly.INPUT_VALUE] = new Blockly.ConnectionDB();
dbList[Blockly.OUTPUT_VALUE] = new Blockly.ConnectionDB();
dbList[Blockly.NEXT_STATEMENT] = new Blockly.ConnectionDB();
dbList[Blockly.PREVIOUS_STATEMENT] = new Blockly.ConnectionDB();
workspace.connectionDBList = dbList;
};
+142
View File
@@ -0,0 +1,142 @@
/**
* @license
* Visual Blocks Editor
*
* Copyright 2016 Google Inc.
* https://developers.google.com/blockly/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview Blockly constants.
* @author fenichel@google.com (Rachel Fenichel)
*/
'use strict';
goog.provide('Blockly.constants');
/**
* Required name space for SVG elements.
* @const
*/
Blockly.SVG_NS = 'http://www.w3.org/2000/svg';
/**
* Required name space for HTML elements.
* @const
*/
Blockly.HTML_NS = 'http://www.w3.org/1999/xhtml';
/**
* The richness of block colours, regardless of the hue.
* Must be in the range of 0 (inclusive) to 1 (exclusive).
*/
Blockly.HSV_SATURATION = 0.45;
/**
* The intensity of block colours, regardless of the hue.
* Must be in the range of 0 (inclusive) to 1 (exclusive).
*/
Blockly.HSV_VALUE = 0.65;
/**
* Sprited icons and images.
*/
Blockly.SPRITE = {
width: 96,
height: 124,
url: 'sprites.png'
};
/**
* ENUM for a right-facing value input. E.g. 'set item to' or 'return'.
* @const
*/
Blockly.INPUT_VALUE = 1;
/**
* ENUM for a left-facing value output. E.g. 'random fraction'.
* @const
*/
Blockly.OUTPUT_VALUE = 2;
/**
* ENUM for a down-facing block stack. E.g. 'if-do' or 'else'.
* @const
*/
Blockly.NEXT_STATEMENT = 3;
/**
* ENUM for an up-facing block stack. E.g. 'break out of loop'.
* @const
*/
Blockly.PREVIOUS_STATEMENT = 4;
/**
* ENUM for an dummy input. Used to add field(s) with no input.
* @const
*/
Blockly.DUMMY_INPUT = 5;
/**
* ENUM for left alignment.
* @const
*/
Blockly.ALIGN_LEFT = -1;
/**
* ENUM for centre alignment.
* @const
*/
Blockly.ALIGN_CENTRE = 0;
/**
* ENUM for right alignment.
* @const
*/
Blockly.ALIGN_RIGHT = 1;
/**
* Lookup table for determining the opposite type of a connection.
* @const
*/
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;
/**
* Number of pixels the mouse must move before a drag starts.
*/
Blockly.DRAG_RADIUS = 5;
/**
* Maximum misalignment between connections for them to snap together.
*/
Blockly.SNAP_RADIUS = 20;
/**
* Delay in ms between trigger and bumping unconnected block out of alignment.
*/
Blockly.BUMP_DELAY = 250;
/**
* Number of characters to truncate a collapsed block to.
*/
Blockly.COLLAPSE_CHARS = 30;
/**
* Length in ms for a touch to become a long press.
*/
Blockly.LONGPRESS = 750;
+253 -11
View File
@@ -30,8 +30,15 @@ goog.provide('Blockly.Events');
/**
* Group ID for new events. Grouped events are indivisible.
* @type {string}
* @private
*/
Blockly.Events.group = '';
Blockly.Events.group_ = '';
/**
* Sets whether events should be added to the undo stack.
* @type {boolean}
*/
Blockly.Events.recordUndo = true;
/**
* Allow change events to be created and fired.
@@ -78,8 +85,8 @@ Blockly.Events.fire = function(event) {
if (!Blockly.Events.isEnabled()) {
return;
}
if (Blockly.Events.FIRE_QUEUE_.length == 0) {
// Schedule a firing of the event queue.
if (!Blockly.Events.FIRE_QUEUE_.length) {
// First event added; schedule a firing of the event queue.
setTimeout(Blockly.Events.fireNow_, 0);
}
Blockly.Events.FIRE_QUEUE_.push(event);
@@ -90,7 +97,7 @@ Blockly.Events.fire = function(event) {
* @private
*/
Blockly.Events.fireNow_ = function() {
var queue = Blockly.Events.filter_(Blockly.Events.FIRE_QUEUE_);
var queue = Blockly.Events.filter(Blockly.Events.FIRE_QUEUE_, true);
Blockly.Events.FIRE_QUEUE_.length = 0;
for (var i = 0, event; event = queue[i]; i++) {
var workspace = Blockly.Workspace.getById(event.workspaceId);
@@ -103,11 +110,15 @@ Blockly.Events.fireNow_ = function() {
/**
* Filter the queued events and merge duplicates.
* @param {!Array.<!Blockly.Events.Abstract>} queueIn Array of events.
* @param {boolean} forward True if forward (redo), false if backward (undo).
* @return {!Array.<!Blockly.Events.Abstract>} Array of filtered events.
* @private
*/
Blockly.Events.filter_ = function(queueIn) {
Blockly.Events.filter = function(queueIn, forward) {
var queue = goog.array.clone(queueIn);
if (!forward) {
// Undo is merged in reverse order.
queue.reverse();
}
// Merge duplicates. O(n^2), but n should be very small.
for (var i = 0, event1; event1 = queue[i]; i++) {
for (var j = i + 1, event2; event2 = queue[j]; j++) {
@@ -138,6 +149,18 @@ Blockly.Events.filter_ = function(queueIn) {
queue.splice(i, 1);
}
}
if (!forward) {
// Restore undo order.
queue.reverse();
}
// Move mutation events to the top of the queue.
// Intentionally skip first event.
for (var i = 1, event; event = queue[i]; i++) {
if (event.type == Blockly.Events.CHANGE &&
event.element == 'mutation') {
queue.unshift(queue.splice(i, 1)[0]);
}
}
return queue;
};
@@ -164,18 +187,53 @@ Blockly.Events.isEnabled = function() {
return Blockly.Events.disabled_ == 0;
};
/**
* Current group.
* @return {string} ID string.
*/
Blockly.Events.getGroup = function() {
return Blockly.Events.group_;
};
/**
* Start or stop a group.
* @param {boolean|string} state True to start new group, false to end group.
* String to set group explicitly.
*/
Blockly.Events.setGroup = function(state) {
if (typeof state == 'boolean') {
Blockly.Events.group_ = state ? Blockly.genUid() : '';
} else {
Blockly.Events.group_ = state;
}
};
/**
* Abstract class for an event.
* @param {!Blockly.Block} block The block.
* @constructor
*/
Blockly.Events.Abstract = function(block) {
if (block.isShadow()) {
console.error('Creating event for shadow block: ' + block.id);
}
this.blockId = block.id;
this.workspaceId = block.workspace.id;
this.group = Blockly.Events.group;
this.group = Blockly.Events.group_;
this.recordUndo = Blockly.Events.recordUndo;
};
/**
* Encode the event as JSON.
* @return {!Object} JSON representation.
*/
Blockly.Events.Abstract.prototype.toJson = function() {
var json = {
'type': this.type,
'blockId': this.blockId,
'workspaceId': this.workspaceId
};
if (this.group) {
json['group'] = this.group;
}
return json;
};
/**
@@ -204,6 +262,36 @@ goog.inherits(Blockly.Events.Create, Blockly.Events.Abstract);
*/
Blockly.Events.Create.prototype.type = Blockly.Events.CREATE;
/**
* Encode the event as JSON.
* @return {!Object} JSON representation.
*/
Blockly.Events.Create.prototype.toJson = function() {
var json = Blockly.Events.Create.superClass_.toJson.call(this);
json['xml'] = Blockly.Xml.domToText(this.xml);
return json;
};
/**
* Run a creation event.
* @param {boolean} forward True if run forward, false if run backward (undo).
*/
Blockly.Events.Create.prototype.run = function(forward) {
if (forward) {
var workspace = Blockly.Workspace.getById(this.workspaceId);
var xml = goog.dom.createDom('xml');
xml.appendChild(this.xml);
Blockly.Xml.domToWorkspace(workspace, xml);
} else {
var block = Blockly.Block.getById(this.blockId);
if (block) {
block.dispose(false, true);
} else {
console.warn("Can't delete non-existant block: " + this.blockId);
}
}
};
/**
* Class for a block deletion event.
* @param {!Blockly.Block} block The deleted block.
@@ -225,6 +313,26 @@ goog.inherits(Blockly.Events.Delete, Blockly.Events.Abstract);
*/
Blockly.Events.Delete.prototype.type = Blockly.Events.DELETE;
/**
* Run a deletion event.
* @param {boolean} forward True if run forward, false if run backward (undo).
*/
Blockly.Events.Delete.prototype.run = function(forward) {
if (forward) {
var block = Blockly.Block.getById(this.blockId);
if (block) {
block.dispose(false, true);
} else {
console.warn("Can't delete non-existant block: " + this.blockId);
}
} else {
var workspace = Blockly.Workspace.getById(this.workspaceId);
var xml = goog.dom.createDom('xml');
xml.appendChild(this.oldXml);
Blockly.Xml.domToWorkspace(workspace, xml);
}
};
/**
* Class for a block change event.
* @param {!Blockly.Block} block The changed block.
@@ -250,6 +358,20 @@ goog.inherits(Blockly.Events.Change, Blockly.Events.Abstract);
*/
Blockly.Events.Change.prototype.type = Blockly.Events.CHANGE;
/**
* Encode the event as JSON.
* @return {!Object} JSON representation.
*/
Blockly.Events.Change.prototype.toJson = function() {
var json = Blockly.Events.Change.superClass_.toJson.call(this);
json['element'] = this.element;
if (this.name) {
json['name'] = this.name;
}
json['newValue'] = this.newValue;
return json;
};
/**
* Does this event record any change of state?
* @return {boolean} True if something changed.
@@ -258,6 +380,61 @@ Blockly.Events.Change.prototype.isNull = function() {
return this.oldValue == this.newValue;
};
/**
* Run a change event.
* @param {boolean} forward True if run forward, false if run backward (undo).
*/
Blockly.Events.Change.prototype.run = function(forward) {
var block = Blockly.Block.getById(this.blockId);
if (!block) {
console.warn("Can't change non-existant block: " + this.blockId);
return;
}
if (block.mutator) {
// Close the mutator (if open) since we don't want to update it.
block.mutator.setVisible(false);
}
var value = forward ? this.newValue : this.oldValue;
switch (this.element) {
case 'field':
var field = block.getField(this.name);
if (field) {
field.setValue(value);
} else {
console.warn("Can't set non-existant field: " + this.name);
}
break;
case 'comment':
block.setCommentText(value || null);
break;
case 'collapsed':
block.setCollapsed(value);
break;
case 'disabled':
block.setDisabled(value);
break;
case 'inline':
block.setInputsInline(value);
break;
case 'mutation':
var oldMutation = '';
if (block.mutationToDom) {
var oldMutationDom = block.mutationToDom();
oldMutation = oldMutationDom && Blockly.Xml.domToText(oldMutationDom);
}
if (block.domToMutation) {
value = value || '<mutation></mutation>';
var dom = Blockly.Xml.textToDom('<xml>' + value + '</xml>');
block.domToMutation(dom.firstChild);
}
Blockly.Events.fire(new Blockly.Events.Change(
block, 'mutation', null, oldMutation, value));
break;
default:
console.warn('Unknown change type: ' + this.element);
}
};
/**
* Class for a block move event. Created before the move.
* @param {!Blockly.Block} block The moved block.
@@ -279,6 +456,25 @@ goog.inherits(Blockly.Events.Move, Blockly.Events.Abstract);
*/
Blockly.Events.Move.prototype.type = Blockly.Events.MOVE;
/**
* Encode the event as JSON.
* @return {!Object} JSON representation.
*/
Blockly.Events.Move.prototype.toJson = function() {
var json = Blockly.Events.Move.superClass_.toJson.call(this);
if (this.newParentId) {
json['newParentId'] = this.newParentId;
}
if (this.newInputName) {
json['newInputName'] = this.newInputName;
}
if (this.newCoordinate) {
json['newCoordinate'] = Math.round(this.newCoordinate.x) + ',' +
Math.round(this.newCoordinate.y);
}
return json;
};
/**
* Record the block's new location. Called after the move.
*/
@@ -303,7 +499,7 @@ Blockly.Events.Move.prototype.currentLocation_ = function() {
location.parentId = parent.id;
var input = parent.getInputWithBlock(block);
if (input) {
location.inputName = input.name
location.inputName = input.name;
}
} else {
location.coordinate = block.getRelativeToSurfaceXY();
@@ -320,3 +516,49 @@ Blockly.Events.Move.prototype.isNull = function() {
this.oldInputName == this.newInputName &&
goog.math.Coordinate.equals(this.oldCoordinate, this.newCoordinate);
};
/**
* Run a move event.
* @param {boolean} forward True if run forward, false if run backward (undo).
*/
Blockly.Events.Move.prototype.run = function(forward) {
var block = Blockly.Block.getById(this.blockId);
if (!block) {
console.warn("Can't move non-existant block: " + this.blockId);
return;
}
var parentId = forward ? this.newParentId : this.oldParentId;
var inputName = forward ? this.newInputName : this.oldInputName;
var coordinate = forward ? this.newCoordinate : this.oldCoordinate;
var parentBlock = null;
if (parentId) {
parentBlock = Blockly.Block.getById(parentId);
if (!parentBlock) {
console.warn("Can't connect to non-existant block: " + parentId);
return;
}
}
if (block.getParent()) {
block.unplug();
}
if (coordinate) {
var xy = block.getRelativeToSurfaceXY();
block.moveBy(coordinate.x - xy.x, coordinate.y - xy.y);
} else {
var blockConnection = block.outputConnection || block.previousConnection;
var parentConnection;
if (inputName) {
var input = parentBlock.getInput(inputName);
if (input) {
parentConnection = input.connection;
}
} else if (blockConnection.type == Blockly.PREVIOUS_STATEMENT) {
parentConnection = parentBlock.nextConnection;
}
if (parentConnection) {
blockConnection.connect(parentConnection);
} else {
console.warn("Can't connect to non-existant input: " + inputName);
}
}
};
+1
View File
@@ -304,6 +304,7 @@ Blockly.Field.prototype.getSize = function() {
* Returns the height and width of the field,
* accounting for the workspace scaling.
* @return {!goog.math.Size} Height and width.
* @private
*/
Blockly.Field.prototype.getScaledBBox_ = function() {
var bBox = this.borderRect_.getBBox();
-1
View File
@@ -236,7 +236,6 @@ Blockly.FieldAngle.prototype.onMouseMove = function(e) {
}
angle = Blockly.FieldAngle.angleValidator(angle);
Blockly.FieldTextInput.htmlInput_.value = angle;
this.sourceBlock_.setShadow(false);
this.setValue(angle);
this.validate_();
this.resizeEditor_();
+4 -1
View File
@@ -85,6 +85,10 @@ Blockly.FieldCheckbox.prototype.getValue = function() {
Blockly.FieldCheckbox.prototype.setValue = function(strBool) {
var newState = (strBool == 'TRUE');
if (this.state_ !== newState) {
if (this.sourceBlock_ && Blockly.Events.isEnabled()) {
Blockly.Events.fire(new Blockly.Events.Change(
this.sourceBlock_, 'field', this.name, this.state_, newState));
}
this.state_ = newState;
if (this.checkElement_) {
this.checkElement_.style.display = newState ? 'block' : 'none';
@@ -106,7 +110,6 @@ Blockly.FieldCheckbox.prototype.showEditor_ = function() {
}
}
if (newState !== null) {
this.sourceBlock_.setShadow(false);
this.setValue(String(newState).toUpperCase());
}
};
-1
View File
@@ -222,7 +222,6 @@ Blockly.FieldColour.prototype.showEditor_ = function() {
}
}
if (colour !== null) {
thisField.sourceBlock_.setShadow(false);
thisField.setValue(colour);
}
});
+2 -3
View File
@@ -39,8 +39,8 @@ goog.require('goog.userAgent');
/**
* Class for an editable dropdown field.
* @param {(!Array.<!Array.<string>>|!Function)} menuGenerator An array of options
* for a dropdown list, or a function which generates these options.
* @param {(!Array.<!Array.<string>>|!Function)} menuGenerator An array of
* options for a dropdown list, or a function which generates these options.
* @param {Function=} opt_validator A function that is executed when a new
* option is selected, with the newly selected value as its sole argument.
* If it returns a value, that value (which must be one of the options) will
@@ -118,7 +118,6 @@ Blockly.FieldDropdown.prototype.showEditor_ = function() {
}
}
if (value !== null) {
thisField.sourceBlock_.setShadow(false);
thisField.setValue(value);
}
}
-1
View File
@@ -188,7 +188,6 @@ Blockly.FieldTextInput.prototype.onHtmlInputChange_ = function(e) {
// Update source block.
var text = htmlInput.value;
if (text !== htmlInput.oldValue_) {
this.sourceBlock_.setShadow(false);
htmlInput.oldValue_ = text;
this.setValue(text);
this.validate_();
+2 -1
View File
@@ -668,7 +668,8 @@ Blockly.Flyout.prototype.createBlockFunc_ = function(originBlock) {
}
block.moveBy(xyOld.x - xyNew.x, xyOld.y - xyNew.y);
Blockly.Events.enable();
if (Blockly.Events.isEnabled() && !block.isShadow()) {
if (Blockly.Events.isEnabled()) {
Blockly.Events.setGroup(true);
Blockly.Events.fire(new Blockly.Events.Create(block));
}
if (flyout.autoClose) {
+2
View File
@@ -163,6 +163,8 @@ Blockly.Generator.prototype.blockToCode = function(block) {
var code = func.call(block, block);
if (goog.isArray(code)) {
// Value blocks return tuples of code and operator order.
goog.asserts.assert(block.outputConnection,
'Expecting string from statement block "%s".', block.type);
return [this.scrub_(block, code[0]), code[1]];
} else if (goog.isString(code)) {
if (this.STATEMENT_PREFIX) {
+4 -2
View File
@@ -35,13 +35,15 @@ goog.require('goog.userAgent');
/**
* Inject a Blockly editor into the specified container element (usually a div).
* @param {!Element|string} container Containing element or its ID.
* @param {!Element|string} container Containing element, or its ID,
* or a CSS selector.
* @param {Object=} opt_options Optional dictionary of options.
* @return {!Blockly.Workspace} Newly created main workspace.
*/
Blockly.inject = function(container, opt_options) {
if (goog.isString(container)) {
container = document.getElementById(container);
container = document.getElementById(container) ||
document.querySelector(container);
}
// Verify that the container is in document.
if (!goog.dom.contains(document, container)) {
+55 -13
View File
@@ -233,7 +233,7 @@ Blockly.Mutator.prototype.setVisible = function(visible) {
var thisMutator = this;
this.block_.saveConnections(this.rootBlock_);
this.sourceListener_ = function() {
thisMutator.block_.saveConnections(thisMutator.rootBlock_)
thisMutator.block_.saveConnections(thisMutator.rootBlock_);
};
this.block_.workspace.addChangeListener(this.sourceListener_);
}
@@ -280,29 +280,37 @@ Blockly.Mutator.prototype.workspaceChanged_ = function() {
// When the mutator's workspace changes, update the source block.
if (this.rootBlock_.workspace == this.workspace_) {
var oldMutationDom = this.block_.mutationToDom();
Blockly.Events.setGroup(true);
var block = this.block_;
var oldMutationDom = block.mutationToDom();
var oldMutation = oldMutationDom && Blockly.Xml.domToText(oldMutationDom);
// Switch off rendering while the source block is rebuilt.
var savedRendered = this.block_.rendered;
this.block_.rendered = false;
var savedRendered = block.rendered;
block.rendered = false;
// Allow the source block to rebuild itself.
this.block_.compose(this.rootBlock_);
block.compose(this.rootBlock_);
// Restore rendering and show the changes.
this.block_.rendered = savedRendered;
block.rendered = savedRendered;
// Mutation may have added some elements that need initalizing.
this.block_.initSvg();
var newMutationDom = this.block_.mutationToDom();
block.initSvg();
var newMutationDom = block.mutationToDom();
var newMutation = newMutationDom && Blockly.Xml.domToText(newMutationDom);
if (oldMutation != newMutation) {
Blockly.Events.fire(new Blockly.Events.Change(
this.block_, 'mutation', null, oldMutation, newMutation));
goog.Timer.callOnce(
this.block_.bumpNeighbours_, Blockly.BUMP_DELAY, this.block_);
block, 'mutation', null, oldMutation, newMutation));
// Ensure that any bump is part of this mutation's event group.
var group = Blockly.Events.getGroup();
setTimeout(function() {
Blockly.Events.setGroup(group);
block.bumpNeighbours_();
Blockly.Events.setGroup(false);
}, Blockly.BUMP_DELAY);
}
if (this.block_.rendered) {
this.block_.render();
if (block.rendered) {
block.render();
}
this.resizeBubble_();
Blockly.Events.setGroup(false);
}
};
@@ -333,3 +341,37 @@ Blockly.Mutator.prototype.dispose = function() {
this.block_.mutator = null;
Blockly.Icon.prototype.dispose.call(this);
};
/**
* Reconnect an block to a mutated input.
* @param {Blockly.Connection} connectionChild Connection on child block.
* @param {!Blockly.Block} block Parent block.
* @param {string} inputName Name of input on parent block.
* @return {boolean} True iff a reconnection was made, false otherwise.
*/
Blockly.Mutator.reconnect = function(connectionChild, block, inputName) {
if (!connectionChild || !connectionChild.getSourceBlock().workspace) {
return false; // No connection or block has been deleted.
}
var connectionParent = block.getInput(inputName).connection;
var currentParent = connectionChild.targetBlock();
if ((!currentParent || currentParent == block) &&
connectionParent.targetConnection != connectionChild) {
if (connectionParent.targetConnection) {
// There's already something connected here. Get rid of it.
connectionParent.disconnect();
}
connectionParent.connect(connectionChild);
return true;
}
return false;
};
// Export symbols that would otherwise be renamed by Closure compiler.
if (!goog.global['Blockly']) {
goog.global['Blockly'] = {};
}
if (!goog.global['Blockly']['Mutator']) {
goog.global['Blockly']['Mutator'] = {};
}
goog.global['Blockly']['Mutator']['reconnect'] = Blockly.Mutator.reconnect;
+21 -9
View File
@@ -251,16 +251,28 @@ Blockly.Procedures.disposeCallers = function(name, workspace) {
/**
* When a procedure definition changes its parameters, find and edit all its
* callers.
* @param {string} name Name of edited procedure definition.
* @param {!Blockly.Workspace} workspace The workspace to delete callers from.
* @param {!Array.<string>} paramNames Array of new parameter names.
* @param {!Array.<string>} paramIds Array of unique parameter IDs.
* @param {!Blockly.Block} defBlock Procedure definition block.
*/
Blockly.Procedures.mutateCallers = function(name, workspace,
paramNames, paramIds) {
var callers = Blockly.Procedures.getCallers(name, workspace);
for (var i = 0; i < callers.length; i++) {
callers[i].setProcedureParameters(paramNames, paramIds);
Blockly.Procedures.mutateCallers = function(defBlock) {
var oldRecordUndo = Blockly.Events.recordUndo;
var name = defBlock.getProcedureDef()[0];
var xmlElement = defBlock.mutationToDom(true);
var callers = Blockly.Procedures.getCallers(name, defBlock.workspace);
for (var i = 0, caller; caller = callers[i]; i++) {
var oldMutationDom = caller.mutationToDom();
var oldMutation = oldMutationDom && Blockly.Xml.domToText(oldMutationDom);
caller.domToMutation(xmlElement);
var newMutationDom = caller.mutationToDom();
var newMutation = newMutationDom && Blockly.Xml.domToText(newMutationDom);
if (oldMutation != newMutation) {
// Fire a mutation on every caller block. But don't record this as an
// undo action since it is deterministically tied to the procedure's
// definition mutation.
Blockly.Events.recordUndo = false;
Blockly.Events.fire(new Blockly.Events.Change(
caller, 'mutation', null, oldMutation, newMutation));
Blockly.Events.recordUndo = oldRecordUndo;
}
}
};
+3 -2
View File
@@ -162,8 +162,9 @@ Blockly.ScrollbarPair.prototype.set = function(x, y) {
/**
* Helper to calculate the ratio of knob value to bar length.
* @param {number} barLength The length of the scroll bar.
* @param {number} knobValue The value of the knob.
* @param {number} barLength The length of the scroll bar.
* @return {number} Ratio.
* @private
*/
Blockly.ScrollbarPair.prototype.getRatio_ = function(knobValue, barLength) {
@@ -182,7 +183,7 @@ Blockly.ScrollbarPair.prototype.getRatio_ = function(knobValue, barLength) {
* look or behave like the system's scrollbars.
* @param {!Blockly.Workspace} workspace Workspace to bind the scrollbar to.
* @param {boolean} horizontal True if horizontal, false if vertical.
* @param {boolean=} opt_pair True if the scrollbar is part of a horiz/vert pair.
* @param {boolean=} opt_pair True if scrollbar is part of a horiz/vert pair.
* @constructor
*/
Blockly.Scrollbar = function(workspace, horizontal, opt_pair) {
+2 -2
View File
@@ -190,7 +190,7 @@ Blockly.Trashcan.prototype.createDom = function() {
* @return {number} Distance from workspace bottom to the top of trashcan.
*/
Blockly.Trashcan.prototype.init = function(bottom) {
this.bottom_ = this.MARGIN_BOTTOM_ + bottom;
this.bottom_ = this.MARGIN_BOTTOM_ + bottom;
this.setOpen_(false);
return this.bottom_ + this.BODY_HEIGHT_ + this.LID_HEIGHT_;
};
@@ -237,7 +237,7 @@ Blockly.Trashcan.prototype.position = function() {
Blockly.Trashcan.prototype.getClientRect = function() {
var trashRect = this.svgGroup_.getBoundingClientRect();
return new goog.math.Rect(trashRect.left - this.MARGIN_HOTSPOT_,
trashRect.top - this.MARGIN_HOTSPOT_,
trashRect.top - this.MARGIN_HOTSPOT_,
trashRect.width + 2 * this.MARGIN_HOTSPOT_,
trashRect.height + 2 * this.MARGIN_HOTSPOT_);
+2 -20
View File
@@ -558,30 +558,12 @@ Blockly.genUid = function() {
var length = 20;
var soupLength = Blockly.genUid.soup_.length;
var id = [];
if (Blockly.genUid.crypto_) {
// Cryptographically strong randomness is supported.
var array = new Uint32Array(length);
Blockly.genUid.crypto_.getRandomValues(array);
for (var i = 0; i < length; i++) {
id[i] = Blockly.genUid.soup_.charAt(array[i] % soupLength);
}
} else {
// Fall back to Math.random for IE 10.
for (var i = 0; i < length; i++) {
id[i] = Blockly.genUid.soup_.charAt(Math.random() * soupLength);
}
for (var i = 0; i < length; i++) {
id[i] = Blockly.genUid.soup_.charAt(Math.random() * soupLength);
}
return id.join('');
};
/**
* Determine if window.crypto or global.crypto exists.
* @this {Object}
* @type {=RandomSource}
* @private
*/
Blockly.genUid.crypto_ = this.crypto;
/**
* Legal characters for the unique ID.
* Should be all on a US keyboard. No XML special characters or control codes.
+9 -11
View File
@@ -56,14 +56,12 @@ Blockly.Variables.allVariables = function(root) {
var variableHash = Object.create(null);
// Iterate through every block and add each variable to the hash.
for (var x = 0; x < blocks.length; x++) {
if (blocks[x].getVars) {
var blockVariables = blocks[x].getVars();
for (var y = 0; y < blockVariables.length; y++) {
var varName = blockVariables[y];
// Variable name may be null if the block is only half-built.
if (varName) {
variableHash[varName.toLowerCase()] = varName;
}
var blockVariables = blocks[x].getVars();
for (var y = 0; y < blockVariables.length; y++) {
var varName = blockVariables[y];
// Variable name may be null if the block is only half-built.
if (varName) {
variableHash[varName.toLowerCase()] = varName;
}
}
}
@@ -82,13 +80,13 @@ Blockly.Variables.allVariables = function(root) {
* @param {!Blockly.Workspace} workspace Workspace rename variables in.
*/
Blockly.Variables.renameVariable = function(oldName, newName, workspace) {
Blockly.Events.setGroup(true);
var blocks = workspace.getAllBlocks();
// Iterate through every block.
for (var i = 0; i < blocks.length; i++) {
if (blocks[i].renameVar) {
blocks[i].renameVar(oldName, newName);
}
blocks[i].renameVar(oldName, newName);
}
Blockly.Events.setGroup(false);
};
/**
+3 -1
View File
@@ -82,6 +82,7 @@ Blockly.WidgetDiv.show = function(newOwner, rtl, dispose) {
Blockly.WidgetDiv.DIV.style.top = xy.y + 'px';
Blockly.WidgetDiv.DIV.style.direction = rtl ? 'rtl' : 'ltr';
Blockly.WidgetDiv.DIV.style.display = 'block';
Blockly.Events.setGroup(true);
};
/**
@@ -89,14 +90,15 @@ Blockly.WidgetDiv.show = function(newOwner, rtl, dispose) {
*/
Blockly.WidgetDiv.hide = function() {
if (Blockly.WidgetDiv.owner_) {
Blockly.WidgetDiv.owner_ = null;
Blockly.WidgetDiv.DIV.style.display = 'none';
Blockly.WidgetDiv.DIV.style.left = '';
Blockly.WidgetDiv.DIV.style.top = '';
Blockly.WidgetDiv.DIV.style.height = '';
Blockly.WidgetDiv.dispose_ && Blockly.WidgetDiv.dispose_();
Blockly.WidgetDiv.owner_ = null;
Blockly.WidgetDiv.dispose_ = null;
goog.dom.removeChildren(Blockly.WidgetDiv.DIV);
Blockly.Events.setGroup(false);
}
};
+53
View File
@@ -47,6 +47,10 @@ Blockly.Workspace = function(opt_options) {
this.topBlocks_ = [];
/** @type {!Array.<!Function>} */
this.listeners_ = [];
/** @type {!Array.<!Blockly.Events.Abstract>} */
this.undoStack_ = [];
/** @type {!Array.<!Blockly.Events.Abstract>} */
this.redoStack_ = [];
};
/**
@@ -55,6 +59,12 @@ Blockly.Workspace = function(opt_options) {
*/
Blockly.Workspace.prototype.rendered = false;
/**
* Maximum number of undo events in stack.
* @type {number} 0 to turn off undo, Infinity for unlimited.
*/
Blockly.Workspace.prototype.MAX_UNDO = 1024;
/**
* Dispose of this workspace.
* Unlink from all DOM elements to prevent memory leaks.
@@ -139,9 +149,16 @@ Blockly.Workspace.prototype.getAllBlocks = function() {
* Dispose of all blocks in workspace.
*/
Blockly.Workspace.prototype.clear = function() {
var existingGroup = Blockly.Events.getGroup();
if (!existingGroup) {
Blockly.Events.setGroup(true);
}
while (this.topBlocks_.length) {
this.topBlocks_[0].dispose();
}
if (!existingGroup) {
Blockly.Events.setGroup(false);
}
};
/**
@@ -194,6 +211,35 @@ Blockly.Workspace.prototype.remainingCapacity = function() {
return this.options.maxBlocks - this.getAllBlocks().length;
};
/**
* Undo or redo the previous action.
* @param {boolean} redo False if undo, true if redo.
*/
Blockly.Workspace.prototype.undo = function(redo) {
var inputStack = redo ? this.redoStack_ : this.undoStack_;
var outputStack = redo ? this.undoStack_ : this.redoStack_;
var event = inputStack.pop();
if (!event) {
return;
}
var events = [event];
// Do another undo/redo if the next one is of the same group.
while (inputStack.length && event.group &&
event.group == inputStack[inputStack.length - 1].group) {
events.push(inputStack.pop());
}
// Push these popped events on the opposite stack.
for (var i = 0, event; event = events[i]; i++) {
outputStack.push(event);
}
events = Blockly.Events.filter(events, redo);
Blockly.Events.recordUndo = false;
for (var i = 0, event; event = events[i]; i++) {
event.run(redo);
}
Blockly.Events.recordUndo = true;
};
/**
* When something in this workspace changes, call a function.
* @param {!Function} func Function to call.
@@ -221,6 +267,13 @@ Blockly.Workspace.prototype.removeChangeListener = function(func) {
* @param {!Blockly.Events.Abstract} event Event to fire.
*/
Blockly.Workspace.prototype.fireChangeListener = function(event) {
if (event.recordUndo) {
this.undoStack_.push(event);
this.redoStack_.length = 0;
if (this.undoStack_.length > this.MAX_UNDO) {
this.undoStack_.unshift();
}
}
for (var i = 0, func; func = this.listeners_[i]; i++) {
func(event);
}
+61 -2
View File
@@ -28,11 +28,12 @@ goog.provide('Blockly.WorkspaceSvg');
// TODO(scr): Fix circular dependencies
// goog.require('Blockly.Block');
goog.require('Blockly.ConnectionDB');
goog.require('Blockly.ScrollbarPair');
goog.require('Blockly.Trashcan');
goog.require('Blockly.ZoomControls');
goog.require('Blockly.Workspace');
goog.require('Blockly.Xml');
goog.require('Blockly.ZoomControls');
goog.require('goog.dom');
goog.require('goog.math.Coordinate');
@@ -660,11 +661,52 @@ Blockly.WorkspaceSvg.prototype.onMouseWheel_ = function(e) {
e.preventDefault();
};
/**
* Calculate the bounding box for the blocks on the workspace.
*
* @return {Object} Contains the position and size of the bounding box
* containing the blocks on the workspace.
*/
Blockly.WorkspaceSvg.prototype.getBlocksBoundingBox = function() {
var topBlocks = this.getTopBlocks();
// There are no blocks, return empty rectangle.
if (!topBlocks.length) {
return {x: 0, y: 0, width: 0, height: 0};
}
// Initialize boundary using the first block.
var boundary = topBlocks[0].getBoundingRectangle();
// Start at 1 since the 0th block was used for initialization
for (var i = 1; i < topBlocks.length; i++) {
var blockBoundary = topBlocks[i].getBoundingRectangle();
if (blockBoundary.topLeft.x < boundary.topLeft.x) {
boundary.topLeft.x = blockBoundary.topLeft.x;
}
if (blockBoundary.bottomRight.x > boundary.bottomRight.x) {
boundary.bottomRight.x = blockBoundary.bottomRight.x;
}
if (blockBoundary.topLeft.y < boundary.topLeft.y) {
boundary.topLeft.y = blockBoundary.topLeft.y;
}
if (blockBoundary.bottomRight.y > boundary.bottomRight.y) {
boundary.bottomRight.y = blockBoundary.bottomRight.y;
}
}
return {
x: boundary.topLeft.x,
y: boundary.topLeft.y,
width: boundary.bottomRight.x - boundary.topLeft.x,
height: boundary.bottomRight.y - boundary.topLeft.y
};
};
/**
* Clean up the workspace by ordering all the blocks in a column.
* @private
*/
Blockly.WorkspaceSvg.prototype.cleanUp_ = function() {
Blockly.Events.setGroup(true);
var topBlocks = this.getTopBlocks(true);
var cursorY = 0;
for (var i = 0, block; block = topBlocks[i]; i++) {
@@ -674,6 +716,7 @@ Blockly.WorkspaceSvg.prototype.cleanUp_ = function() {
cursorY = block.getRelativeToSurfaceXY().y +
block.getHeightWidth().height + Blockly.BlockSvg.MIN_BLOCK_Y;
}
Blockly.Events.setGroup(false);
// Fire an event to allow scrollbars to resize.
Blockly.fireUiEvent(window, 'resize');
};
@@ -689,6 +732,20 @@ Blockly.WorkspaceSvg.prototype.showContextMenu_ = function(e) {
}
var menuOptions = [];
var topBlocks = this.getTopBlocks(true);
var eventGroup = Blockly.genUid();
// Options to undo/redo previous action.
var undoOption = {};
undoOption.text = Blockly.Msg.UNDO;
undoOption.enabled = this.undoStack_.length > 0;
undoOption.callback = this.undo.bind(this, false);
menuOptions.push(undoOption);
var redoOption = {};
redoOption.text = Blockly.Msg.REDO;
redoOption.enabled = this.redoStack_.length > 0;
redoOption.callback = this.undo.bind(this, true);
menuOptions.push(redoOption);
// Option to clean up blocks.
var cleanOption = {};
cleanOption.text = Blockly.Msg.CLEAN_UP;
@@ -776,6 +833,7 @@ Blockly.WorkspaceSvg.prototype.showContextMenu_ = function(e) {
}
};
function deleteNext() {
Blockly.Events.setGroup(eventGroup);
var block = deleteList.shift();
if (block) {
if (block.workspace) {
@@ -785,6 +843,7 @@ Blockly.WorkspaceSvg.prototype.showContextMenu_ = function(e) {
deleteNext();
}
}
Blockly.Events.setGroup(false);
}
menuOptions.push(deleteOption);
@@ -805,7 +864,7 @@ Blockly.WorkspaceSvg.prototype.loadAudio_ = function(filenames, name) {
}
try {
var audioTest = new window['Audio']();
} catch(e) {
} catch (e) {
// No browser support for Audio.
// IE can throw an error even if the Audio object exists.
return;
+8 -1
View File
@@ -281,6 +281,10 @@ Blockly.Xml.domToWorkspace = function(workspace, xml) {
// children beyond the lists' length. Trust the length, do not use the
// looping pattern of checking the index for an object.
var childCount = xml.childNodes.length;
var existingGroup = Blockly.Events.getGroup();
if (!existingGroup) {
Blockly.Events.setGroup(true);
}
for (var i = 0; i < childCount; i++) {
var xmlChild = xml.childNodes[i];
var name = xmlChild.nodeName.toLowerCase();
@@ -293,6 +297,9 @@ Blockly.Xml.domToWorkspace = function(workspace, xml) {
}
}
}
if (!existingGroup) {
Blockly.Events.setGroup(false);
}
Blockly.Field.stopCache();
};
@@ -331,7 +338,7 @@ Blockly.Xml.domToBlock = function(workspace, xmlBlock) {
Blockly.fireUiEvent(window, 'resize');
}
Blockly.Events.enable();
if (Blockly.Events.isEnabled() && !topBlock.isShadow()) {
if (Blockly.Events.isEnabled()) {
Blockly.Events.fire(new Blockly.Events.Create(topBlock));
}
return topBlock;
+3 -3
View File
@@ -98,17 +98,17 @@ Blockly.ZoomControls.prototype.createDom = function() {
<clippath id="blocklyZoomoutClipPath837493">
<rect width="32" height="32" y="77"></rect>
</clippath>
<image width="96" height="124" x="-64" y="-15" xlink:href="media/sprites.png">
<image width="96" height="124" x="-64" y="-15" xlink:href="media/sprites.png"
clip-path="url(#blocklyZoomoutClipPath837493)"></image>
<clippath id="blocklyZoominClipPath837493">
<rect width="32" height="32" y="43"></rect>
</clippath>
<image width="96" height="124" x="-32" y="-49" xlink:href="media/sprites.png">
<image width="96" height="124" x="-32" y="-49" xlink:href="media/sprites.png"
clip-path="url(#blocklyZoominClipPath837493)"></image>
<clippath id="blocklyZoomresetClipPath837493">
<rect width="32" height="32"></rect>
</clippath>
<image width="96" height="124" y="-92" xlink:href="media/sprites.png">
<image width="96" height="124" y="-92" xlink:href="media/sprites.png"
clip-path="url(#blocklyZoomresetClipPath837493)"></image>
</g>
*/
+4 -1
View File
@@ -696,7 +696,10 @@ Blockly.Blocks['colour_hue'] = {
},
validator: function(text) {
// Update the current block's colour to match.
this.sourceBlock_.setColour(text);
var hue = parseInt(text, 10);
if (!isNaN(hue)) {
this.sourceBlock_.setColour(hue);
}
},
mutationToDom: function(workspace) {
var container = document.createElement('mutation');
+3 -1
View File
@@ -258,7 +258,9 @@ function formatJavaScript_(blockType, rootBlock) {
var colourBlock = rootBlock.getInputTargetBlock('COLOUR');
if (colourBlock && !colourBlock.disabled) {
var hue = parseInt(colourBlock.getFieldValue('HUE'), 10);
code.push(' this.setColour(' + hue + ');');
if (!isNaN(hue)) {
code.push(' this.setColour(' + hue + ');');
}
}
code.push(" this.setTooltip('');");
code.push(" this.setHelpUrl('http://www.example.com/');");
+2 -1
View File
@@ -142,7 +142,7 @@
<select id="format">
<option value="JavaScript">JavaScript</option>
<option value="JSON">JSON</option>
<option value="Manual">Manual edit...</option>
<option value="Manual">Manual edit&hellip;</option>
</select>
</h3>
</td>
@@ -161,6 +161,7 @@
<option value="Python">Python</option>
<option value="PHP">PHP</option>
<option value="Dart">Dart</option>
<option value="Lua">Lua</option>
</select>
</h3>
</td>
+9 -1
View File
@@ -244,7 +244,7 @@ Code.LANG = Code.getLang();
* List of tab names.
* @private
*/
Code.TABS_ = ['blocks', 'javascript', 'php', 'python', 'dart', 'xml'];
Code.TABS_ = ['blocks', 'javascript', 'php', 'python', 'dart', 'lua', 'xml'];
Code.selected = 'blocks';
@@ -341,6 +341,14 @@ Code.renderContent = function() {
code = prettyPrintOne(code, 'dart');
content.innerHTML = code;
}
} else if (content.id == 'content_lua') {
code = Blockly.Lua.workspaceToCode(Code.workspace);
content.textContent = code;
if (typeof prettyPrintOne == 'function') {
code = content.innerHTML;
code = prettyPrintOne(code, 'lua');
content.innerHTML = code;
}
}
};
+4
View File
@@ -12,6 +12,7 @@
<script src="../../python_compressed.js"></script>
<script src="../../php_compressed.js"></script>
<script src="../../dart_compressed.js"></script>
<script src="../../lua_compressed.js"></script>
<script src="code.js"></script>
</head>
<body>
@@ -41,6 +42,8 @@
<td class="tabmin">&nbsp;</td>
<td id="tab_dart" class="taboff">Dart</td>
<td class="tabmin">&nbsp;</td>
<td id="tab_lua" class="taboff">Lua</td>
<td class="tabmin">&nbsp;</td>
<td id="tab_xml" class="taboff">XML</td>
<td class="tabmax">
<button id="trashButton" class="notext" title="...">
@@ -67,6 +70,7 @@
<pre id="content_php" class="content"></pre>
<pre id="content_python" class="content"></pre>
<pre id="content_dart" class="content"></pre>
<pre id="content_lua" class="content"></pre>
<textarea id="content_xml" class="content" wrap="off"></textarea>
<xml id="toolbox" style="display: none">
+1 -1
View File
@@ -23,7 +23,7 @@
<p>This is a simple demo of injecting Blockly into a fixed-sized 'div' element.</p>
<p>&rarr; More info on <a href="https://developers.google.com/blockly/installation/injecting-fixed-size">injecting fixed-sized Blockly</a>...</p>
<p>&rarr; More info on <a href="https://developers.google.com/blockly/installation/injecting-fixed-size">injecting fixed-sized Blockly</a>&hellip;</p>
<div id="blocklyDiv" style="height: 480px; width: 600px;"></div>
+1 -1
View File
@@ -24,7 +24,7 @@
<p>This is a simple demo of generating code from blocks.</p>
<p>&rarr; More info on <a href="https://developers.google.com/blockly/installation/code-generators">Code Generators</a>...</p>
<p>&rarr; More info on <a href="https://developers.google.com/blockly/installation/code-generators">Code Generators</a>&hellip;</p>
<p>
<button onclick="showCode()">Show JavaScript</button>
+1 -1
View File
@@ -39,7 +39,7 @@
<p>This is a demo of giving instant feedback as blocks are changed.</p>
<p>&rarr; More info on <a href="https://developers.google.com/blockly/installation/code-generators#realtime_generation">Realtime generation</a>...</p>
<p>&rarr; More info on <a href="https://developers.google.com/blockly/installation/code-generators#realtime_generation">Realtime generation</a>&hellip;</p>
<table>
<tr>
+1 -1
View File
@@ -168,7 +168,7 @@
</td>
<td>
<div><a href="code/index.html">Code Editor</a></div>
<div>Export a Blockly program into JavaScript, Python, PHP, Dart or XML.</div>
<div>Export a Blockly program into JavaScript, Python, PHP, Dart, Lua or XML.</div>
</td>
</tr>
+1 -1
View File
@@ -25,7 +25,7 @@
<p>This is a simple demo of executing code with a sandboxed JavaScript interpreter.</p>
<p>&rarr; More info on <a href="https://developers.google.com/blockly/installation/js-interpreter">JS Interpreter</a>...</p>
<p>&rarr; More info on <a href="https://developers.google.com/blockly/installation/js-interpreter">JS Interpreter</a>&hellip;</p>
<p>
<button onclick="parseCode()">Parse JavaScript</button>
+1 -1
View File
@@ -39,7 +39,7 @@
CSS or tables to create an area for it.
Next, <a href="overlay.html">inject Blockly</a> over that area.</p>
<p>&rarr; More info on <a href="https://developers.google.com/blockly/installation/injecting-resizable">injecting resizable Blockly</a>...</p>
<p>&rarr; More info on <a href="https://developers.google.com/blockly/installation/injecting-resizable">injecting resizable Blockly</a>&hellip;</p>
</td>
</tr>
<tr>
+1 -1
View File
@@ -42,7 +42,7 @@
A resize handler keeps it in position as the page changes.
</p>
<p>&rarr; More info on <a href="https://developers.google.com/blockly/installation/injecting-resizable">injecting resizable Blockly</a>...</p>
<p>&rarr; More info on <a href="https://developers.google.com/blockly/installation/injecting-resizable">injecting resizable Blockly</a>&hellip;</p>
</td>
</tr>
<tr>
+1 -1
View File
@@ -41,7 +41,7 @@
}
</script>
<p>&rarr; More info on <a href="https://developers.google.com/blockly/installation/cloud-storage">Cloud Storage</a>...</p>
<p>&rarr; More info on <a href="https://developers.google.com/blockly/installation/cloud-storage">Cloud Storage</a>&hellip;</p>
<p>
<button onclick="BlocklyStorage.link()">Save Blocks</button>
+1 -1
View File
@@ -23,7 +23,7 @@
<p>This is a demo of a complex category structure for the toolbox.</p>
<p>&rarr; More info on the <a href="https://developers.google.com/blockly/installation/toolbox">Toolbox</a>...</p>
<p>&rarr; More info on the <a href="https://developers.google.com/blockly/installation/toolbox">Toolbox</a>&hellip;</p>
<div id="blocklyDiv" style="height: 600px; width: 800px;"></div>
+188
View File
@@ -0,0 +1,188 @@
/**
* @license
* Visual Blocks Language
*
* Copyright 2016 Google Inc.
* https://developers.google.com/blockly/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview Helper functions for generating Lua for blocks.
* @author rodrigoq@google.com (Rodrigo Queiro)
* Based on Ellen Spertus's blocky-lua project.
*/
'use strict';
goog.provide('Blockly.Lua');
goog.require('Blockly.Generator');
/**
* Lua code generator.
* @type {!Blockly.Generator}
*/
Blockly.Lua = new Blockly.Generator('Lua');
/**
* List of illegal variable names.
* This is not intended to be a security feature. Blockly is 100% client-side,
* so bypassing this list is trivial. This is intended to prevent users from
* accidentally clobbering a built-in object or function.
* @private
*/
Blockly.Lua.addReservedWords(
// Special character
'_,' +
// From theoriginalbit's script:
// https://github.com/espertus/blockly-lua/issues/6
'__inext,assert,bit,colors,colours,coroutine,disk,dofile,error,fs,' +
'fetfenv,getmetatable,gps,help,io,ipairs,keys,loadfile,loadstring,math,' +
'native,next,os,paintutils,pairs,parallel,pcall,peripheral,print,' +
'printError,rawequal,rawget,rawset,read,rednet,redstone,rs,select,' +
'setfenv,setmetatable,sleep,string,table,term,textutils,tonumber,' +
'tostring,turtle,type,unpack,vector,write,xpcall,_VERSION,__indext,' +
// Not included in the script, probably because it wasn't enabled:
'HTTP,' +
// Keywords (http://www.lua.org/pil/1.3.html).
'and,break,do,else,elseif,end,false,for,function,if,in,local,nil,not,or,' +
'repeat,return,then,true,until,while,' +
// Metamethods (http://www.lua.org/manual/5.2/manual.html).
'add,sub,mul,div,mod,pow,unm,concat,len,eq,lt,le,index,newindex,call,' +
// Basic functions (http://www.lua.org/manual/5.2/manual.html, section 6.1).
'assert,collectgarbage,dofile,error,_G,getmetatable,inpairs,load,' +
'loadfile,next,pairs,pcall,print,rawequal,rawget,rawlen,rawset,select,' +
'setmetatable,tonumber,tostring,type,_VERSION,xpcall,' +
// Modules (http://www.lua.org/manual/5.2/manual.html, section 6.3).
'require,package,string,table,math,bit32,io,file,os,debug'
);
/**
* Order of operation ENUMs.
* http://www.lua.org/manual/5.3/manual.html#3.4.8
*/
Blockly.Lua.ORDER_ATOMIC = 0; // literals
// The next level was not explicit in documentation and inferred by Ellen.
Blockly.Lua.ORDER_HIGH = 1; // Function calls, tables[]
Blockly.Lua.ORDER_EXPONENTIATION = 2; // ^
Blockly.Lua.ORDER_UNARY = 3; // not # - ()
Blockly.Lua.ORDER_MULTIPLICATIVE = 4; // * / %
Blockly.Lua.ORDER_ADDITIVE = 5; // + -
Blockly.Lua.ORDER_CONCATENATION = 6; // ..
Blockly.Lua.ORDER_RELATIONAL = 7; // < > <= >= ~= ==
Blockly.Lua.ORDER_AND = 8; // and
Blockly.Lua.ORDER_OR = 9; // or
Blockly.Lua.ORDER_NONE = 99;
/**
* Initialise the database of variable names.
* @param {!Blockly.Workspace} workspace Workspace to generate code from.
*/
Blockly.Lua.init = function(workspace) {
// Create a dictionary of definitions to be printed before the code.
Blockly.Lua.definitions_ = Object.create(null);
// Create a dictionary mapping desired function names in definitions_
// to actual function names (to avoid collisions with user functions).
Blockly.Lua.functionNames_ = Object.create(null);
if (!Blockly.Lua.variableDB_) {
Blockly.Lua.variableDB_ =
new Blockly.Names(Blockly.Lua.RESERVED_WORDS_);
} else {
Blockly.Lua.variableDB_.reset();
}
};
/**
* Prepend the generated code with the variable definitions.
* @param {string} code Generated code.
* @return {string} Completed code.
*/
Blockly.Lua.finish = function(code) {
// Convert the definitions dictionary into a list.
var definitions = [];
for (var name in Blockly.Lua.definitions_) {
definitions.push(Blockly.Lua.definitions_[name]);
}
// Clean up temporary data.
delete Blockly.Lua.definitions_;
delete Blockly.Lua.functionNames_;
Blockly.Lua.variableDB_.reset();
return definitions.join('\n\n') + '\n\n\n' + code;
};
/**
* Naked values are top-level blocks with outputs that aren't plugged into
* anything. In Lua, an expression is not a legal statement, so we must assign
* the value to the (conventionally ignored) _.
* http://lua-users.org/wiki/ExpressionsAsStatements
* @param {string} line Line of generated code.
* @return {string} Legal line of code.
*/
Blockly.Lua.scrubNakedValue = function(line) {
return 'local _ = ' + line + '\n';
};
/**
* Encode a string as a properly escaped Lua string, complete with
* quotes.
* @param {string} string Text to encode.
* @return {string} Lua string.
* @private
*/
Blockly.Lua.quote_ = function(string) {
// TODO: This is a quick hack. Replace with goog.string.quote
string = string.replace(/\\/g, '\\\\')
.replace(/\n/g, '\\\n')
.replace(/'/g, '\\\'');
return '\'' + string + '\'';
};
/**
* Common tasks for generating Lua from blocks.
* Handles comments for the specified block and any connected value blocks.
* Calls any statements following this block.
* @param {!Blockly.Block} block The current block.
* @param {string} code The Lua code created for this block.
* @return {string} Lua code with comments and subsequent blocks added.
* @private
*/
Blockly.Lua.scrub_ = function(block, code) {
var commentCode = '';
// Only collect comments for blocks that aren't inline.
if (!block.outputConnection || !block.outputConnection.targetConnection) {
// Collect comment for this block.
var comment = block.getCommentText();
if (comment) {
commentCode += Blockly.Lua.prefixLines(comment, '-- ') + '\n';
}
// Collect comments for all value arguments.
// Don't collect comments for nested statements.
for (var x = 0; x < block.inputList.length; x++) {
if (block.inputList[x].type == Blockly.INPUT_VALUE) {
var childBlock = block.inputList[x].connection.targetBlock();
if (childBlock) {
comment = Blockly.Lua.allNestedComments(childBlock);
if (comment) {
commentCode += Blockly.Lua.prefixLines(comment, '-- ');
}
}
}
}
}
var nextBlock = block.nextConnection && block.nextConnection.targetBlock();
var nextCode = Blockly.Lua.blockToCode(nextBlock);
return commentCode + code + nextCode;
};
+90
View File
@@ -0,0 +1,90 @@
/**
* @license
* Visual Blocks Language
*
* Copyright 2016 Google Inc.
* https://developers.google.com/blockly/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview Generating Lua for colour blocks.
* @author rodrigoq@google.com (Rodrigo Queiro)
*/
'use strict';
goog.provide('Blockly.Lua.colour');
goog.require('Blockly.Lua');
Blockly.Lua['colour_picker'] = function(block) {
// Colour picker.
var code = '\'' + block.getFieldValue('COLOUR') + '\'';
return [code, Blockly.Lua.ORDER_ATOMIC];
};
Blockly.Lua['colour_random'] = function(block) {
// Generate a random colour.
var code = 'string.format("#%06x", math.random(0, 2^24 - 1))';
return [code, Blockly.Lua.ORDER_HIGH];
};
Blockly.Lua['colour_rgb'] = function(block) {
// Compose a colour from RGB components expressed as percentages.
var functionName = Blockly.Lua.provideFunction_(
'colour_rgb',
['function ' + Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_ + '(r, g, b)',
' r = math.floor(math.min(100, math.max(0, r)) * 2.55 + .5)',
' g = math.floor(math.min(100, math.max(0, g)) * 2.55 + .5)',
' b = math.floor(math.min(100, math.max(0, b)) * 2.55 + .5)',
' return string.format("#%02x%02x%02x", r, g, b)',
'end']);
var r = Blockly.Lua.valueToCode(block, 'RED',
Blockly.Lua.ORDER_NONE) || 0;
var g = Blockly.Lua.valueToCode(block, 'GREEN',
Blockly.Lua.ORDER_NONE) || 0;
var b = Blockly.Lua.valueToCode(block, 'BLUE',
Blockly.Lua.ORDER_NONE) || 0;
var code = functionName + '(' + r + ', ' + g + ', ' + b + ')';
return [code, Blockly.Lua.ORDER_HIGH];
};
Blockly.Lua['colour_blend'] = function(block) {
// Blend two colours together.
var functionName = Blockly.Lua.provideFunction_(
'colour_blend',
['function ' + Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_ +
'(colour1, colour2, ratio)',
' local r1 = tonumber(string.sub(colour1, 2, 3), 16)',
' local r2 = tonumber(string.sub(colour2, 2, 3), 16)',
' local g1 = tonumber(string.sub(colour1, 4, 5), 16)',
' local g2 = tonumber(string.sub(colour2, 4, 5), 16)',
' local b1 = tonumber(string.sub(colour1, 6, 7), 16)',
' local b2 = tonumber(string.sub(colour2, 6, 7), 16)',
' local ratio = math.min(1, math.max(0, ratio))',
' local r = math.floor(r1 * (1 - ratio) + r2 * ratio + .5)',
' local g = math.floor(g1 * (1 - ratio) + g2 * ratio + .5)',
' local b = math.floor(b1 * (1 - ratio) + b2 * ratio + .5)',
' return string.format("#%02x%02x%02x", r, g, b)',
'end']);
var colour1 = Blockly.Lua.valueToCode(block, 'COLOUR1',
Blockly.Lua.ORDER_NONE) || '\'#000000\'';
var colour2 = Blockly.Lua.valueToCode(block, 'COLOUR2',
Blockly.Lua.ORDER_NONE) || '\'#000000\'';
var ratio = Blockly.Lua.valueToCode(block, 'RATIO',
Blockly.Lua.ORDER_NONE) || 0;
var code = functionName + '(' + colour1 + ', ' + colour2 + ', ' + ratio + ')';
return [code, Blockly.Lua.ORDER_HIGH];
};
+363
View File
@@ -0,0 +1,363 @@
/**
* @license
* Visual Blocks Language
*
* Copyright 2016 Google Inc.
* https://developers.google.com/blockly/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview Generating Lua for list blocks.
* @author rodrigoq@google.com (Rodrigo Queiro)
*/
'use strict';
goog.provide('Blockly.Lua.lists');
goog.require('Blockly.Lua');
Blockly.Lua['lists_create_empty'] = function(block) {
// Create an empty list.
// List literals must be parenthesized before indexing into.
return ['({})', Blockly.Lua.ORDER_ATOMIC];
};
Blockly.Lua['lists_create_with'] = function(block) {
// Create a list with any number of elements of any type.
var code = new Array(block.itemCount_);
for (var n = 0; n < block.itemCount_; n++) {
code[n] = Blockly.Lua.valueToCode(block, 'ADD' + n,
Blockly.Lua.ORDER_NONE) || 'None';
}
code = '({' + code.join(', ') + '})';
return [code, Blockly.Lua.ORDER_ATOMIC];
};
Blockly.Lua['lists_repeat'] = function(block) {
// Create a list with one element repeated.
var functionName = Blockly.Lua.provideFunction_(
'create_list_repeated',
['function ' + Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_ + '(item, count)',
' local t = {}',
' for i = 1, count do',
' table.insert(t, item)',
' end',
' return t',
'end']);
var argument0 = Blockly.Lua.valueToCode(block, 'ITEM',
Blockly.Lua.ORDER_NONE) || 'None';
var argument1 = Blockly.Lua.valueToCode(block, 'NUM',
Blockly.Lua.ORDER_NONE) || '0';
var code = functionName + '(' + argument0 + ', ' + argument1 + ')';
return [code, Blockly.Lua.ORDER_HIGH];
};
Blockly.Lua['lists_length'] = function(block) {
// String or array length.
var argument0 = Blockly.Lua.valueToCode(block, 'VALUE',
Blockly.Lua.ORDER_HIGH) || '({})';
return ['#' + argument0, Blockly.Lua.ORDER_HIGH];
};
Blockly.Lua['lists_isEmpty'] = function(block) {
// Is the string null or array empty?
var argument0 = Blockly.Lua.valueToCode(block, 'VALUE',
Blockly.Lua.ORDER_HIGH) || '({})';
var code = '#' + argument0 + ' == 0';
return [code, Blockly.Lua.ORDER_RELATIONAL];
};
Blockly.Lua['lists_indexOf'] = function(block) {
// Find an item in the list.
var argument0 = Blockly.Lua.valueToCode(block, 'FIND',
Blockly.Lua.ORDER_NONE) || '\'\'';
var argument1 = Blockly.Lua.valueToCode(block, 'VALUE',
Blockly.Lua.ORDER_NONE) || '({})';
var functionName;
if (block.getFieldValue('END') == 'FIRST') {
functionName = Blockly.Lua.provideFunction_(
'first_index',
['function ' + Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_ + '(t, elem)',
' for k, v in ipairs(t) do',
' if v == elem then',
' return k',
' end',
' end',
' return 0',
'end']);
} else {
functionName = Blockly.Lua.provideFunction_(
'last_index',
['function ' + Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_ + '(t, elem)',
' for i = #t, 1, -1 do',
' if t[i] == elem then',
' return i',
' end',
' end',
' return 0',
'end']);
}
var code = functionName + '(' + argument1 + ', ' + argument0 + ')';
return [code, Blockly.Lua.ORDER_HIGH];
};
/**
* Returns an expression calculating the index into a list.
* @private
* @param {string} listname Name of the list, used to calculate length.
* @param {string} where The method of indexing, selected by dropdown in Blockly
* @param {string=} opt_at The optional offset when indexing from start/end.
* @return {string} Index expression.
*/
Blockly.Lua.lists.getIndex_ = function(listname, where, opt_at) {
if (where == 'FIRST') {
return '1';
} else if (where == 'FROM_END') {
return '#' + listname + ' + 1 - ' + opt_at;
} else if (where == 'LAST') {
return '#' + listname;
} else if (where == 'RANDOM') {
return 'math.random(#' + listname + ')';
} else {
return opt_at;
}
};
/**
* Counter for generating unique symbols.
* @private
* @type {number}
*/
Blockly.Lua.lists.gensym_counter_ = 0;
/**
* Generate a unique symbol.
* @private
* @return {string} unique symbol, eg 'G123'
*/
Blockly.Lua.lists.gensym_ = function() {
return 'G' + Blockly.Lua.lists.gensym_counter_++;
};
Blockly.Lua['lists_getIndex'] = function(block) {
// Get element at index.
// Note: Until January 2013 this block did not have MODE or WHERE inputs.
var mode = block.getFieldValue('MODE') || 'GET';
var where = block.getFieldValue('WHERE') || 'FROM_START';
var at = Blockly.Lua.valueToCode(block, 'AT',
Blockly.Lua.ORDER_ADDITIVE) || '1';
var list = Blockly.Lua.valueToCode(block, 'VALUE',
Blockly.Lua.ORDER_HIGH) || '({})';
var getIndex_ = Blockly.Lua.lists.getIndex_;
var gensym_ = Blockly.Lua.lists.gensym_;
// If `list` would be evaluated more than once (which is the case for LAST,
// FROM_END, and RANDOM) and is non-trivial, make sure to access it only once.
if ((where == 'LAST' || where == 'FROM_END' || where == 'RANDOM') &&
!list.match(/^\w+$/)) {
// `list` is an expression, so we may not evaluate it more than once.
if (mode == 'REMOVE') {
// We can use multiple statements.
var listVar = Blockly.Lua.variableDB_.getDistinctName(
'tmp_list', Blockly.Variables.NAME_TYPE);
var code = listVar + ' = ' + list + '\n' +
'table.remove(' + listVar + ', ' + getIndex_(listVar, where, at) +
')\n';
return code;
} else {
// We need to create a procedure to avoid reevaluating values.
if (mode == 'GET') {
// Note that getIndex_() ignores `at` when `where` == 'LAST' or
// 'RANDOM', so we only need one procedure for each of those 'where'
// values. The value for 'FROM_END' depends on `at`, so we will
// generate a unique procedure (name) each time.
var functionName = Blockly.Lua.provideFunction_(
'list_get_' + where.toLowerCase() +
(where == 'FROM_END' ? '_' + gensym_() : ''),
['function ' + Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_ + '(t)',
' return t[' + getIndex_('t', where, at) + ']',
'end']);
} else { // mode == 'GET_REMOVE'
// We need to create a procedure.
var functionName = Blockly.Lua.provideFunction_(
'list_remove_' + where.toLowerCase() +
(where == 'FROM_END' ? '_' + gensym_() : ''),
['function ' + Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_ + '(t)',
' return table.remove(t, ' + getIndex_('t', where, at) + ')',
'end']);
}
var code = functionName + '(' + list + ')';
return [code, Blockly.Lua.ORDER_HIGH];
}
} else {
// Either `list` is a simple variable, or we only need to refer to `list`
// once.
if (mode == 'GET') {
var code = list + '[' + getIndex_(list, where, at) + ']';
return [code, Blockly.Lua.ORDER_HIGH];
} else {
var code = 'table.remove(' + list + ', ' + getIndex_(list, where, at) +
')';
if (mode == 'GET_REMOVE') {
return [code, Blockly.Lua.ORDER_HIGH];
} else { // `mode` == 'REMOVE'
return code + '\n';
}
}
}
};
Blockly.Lua['lists_setIndex'] = function(block) {
// Set element at index.
// Note: Until February 2013 this block did not have MODE or WHERE inputs.
var list = Blockly.Lua.valueToCode(block, 'LIST',
Blockly.Lua.ORDER_HIGH) || '({})';
var mode = block.getFieldValue('MODE') || 'SET';
var where = block.getFieldValue('WHERE') || 'FROM_START';
var at = Blockly.Lua.valueToCode(block, 'AT',
Blockly.Lua.ORDER_ADDITIVE) || '1';
var value = Blockly.Lua.valueToCode(block, 'TO',
Blockly.Lua.ORDER_NONE) || 'None';
var getIndex_ = Blockly.Lua.lists.getIndex_;
// If `list` would be evaluated more than once (which is the case for LAST,
// FROM_END, and RANDOM) and is non-trivial, make sure to access it only once.
if ((where == 'LAST' || where == 'FROM_END' || where == 'RANDOM') &&
!list.match(/^\w+$/)) {
// `list` is an expression, so we may not evaluate it more than once.
if (where == 'RANDOM' || where == 'LAST') {
// In these cases, `at` is implicit. getIndex_() ignores its value.
if (mode == 'SET') {
var functionName = Blockly.Lua.provideFunction_(
'list_set_' + where.toLowerCase(),
['function ' + Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_ + '(t, val)',
' t[' + getIndex_('t', where, at) + '] = val',
'end']);
} else { // `mode` == 'INSERT'
var functionName = Blockly.Lua.provideFunction_(
'list_insert_' + where.toLowerCase(),
['function ' + Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_ + '(t, val)',
' table.insert(t, ' +
// LAST is a special case, because we want to insert
// *after* not *before*, the existing last element.
getIndex_('t', where, at) + (where == 'LAST' ? ' + 1' : '') +
', val)',
'end']);
}
var code = functionName + '(' + list + ', ' + value + ')\n';
return code;
} else { // `where` = 'FROM_END'
if (mode == 'SET') {
var functionName = Blockly.Lua.provideFunction_(
'list_set_from_end',
['function ' + Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_ +
'(t, index, val)',
' t[#t + 1 - index] = val',
'end']);
} else { // `mode` == 'INSERT'
var functionName = Blockly.Lua.provideFunction_(
'list_insert_from_end',
['function ' + Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_ +
'(t, index, val)',
' table.insert(t, #t + 1 - index, val)',
'end']);
}
var code = functionName + '(' + list + ', ' + at + ', ' + value + ')\n';
return code;
}
} else {
// It's okay to have multiple references to the list.
if (mode == 'SET') {
var code = list + '[' + getIndex_(list, where, at) + '] = ' + value;
} else { // `mode` == 'INSERT'
// LAST is a special case, because we want to insert
// *after* not *before*, the existing last element.
var code = 'table.insert(' + list + ', ' +
(getIndex_(list, where, at) + (where == 'LAST' ? ' + 1' : '')) +
', ' + value + ')';
}
return code + '\n';
}
};
Blockly.Lua['lists_getSublist'] = function(block) {
// Get sublist.
var list = Blockly.Lua.valueToCode(block, 'LIST',
Blockly.Lua.ORDER_HIGH) || '({})';
var where1 = block.getFieldValue('WHERE1');
var where2 = block.getFieldValue('WHERE2');
var at1 = Blockly.Lua.valueToCode(block, 'AT1',
Blockly.Lua.ORDER_ADDITIVE) || '1';
var at2 = Blockly.Lua.valueToCode(block, 'AT2',
Blockly.Lua.ORDER_ADDITIVE) || '1';
var getIndex_ = Blockly.Lua.lists.getIndex_;
var functionName = Blockly.Lua.provideFunction_(
'list_sublist_' + Blockly.Lua.lists.gensym_(),
['function ' + Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_ + '(source)',
' local t = {}',
' local start = ' + getIndex_('source', where1, at1),
' local finish = ' + getIndex_('source', where2, at2),
' for i = start, finish do',
' table.insert(t, source[i])',
' end',
' return t',
'end']);
var code = functionName + '(' + list + ')';
return [code, Blockly.Lua.ORDER_HIGH];
};
Blockly.Lua['lists_split'] = function(block) {
// Block for splitting text into a list, or joining a list into text.
var value_input = Blockly.Lua.valueToCode(block, 'INPUT',
Blockly.Lua.ORDER_NONE);
var value_delim = Blockly.Lua.valueToCode(block, 'DELIM',
Blockly.Lua.ORDER_NONE) || '\'\'';
var mode = block.getFieldValue('MODE');
var functionName;
if (mode == 'SPLIT') {
if (!value_input) {
value_input = '\'\'';
}
functionName = Blockly.Lua.provideFunction_(
'list_string_split',
['function ' + Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_ +
'(input, delim)',
' local t = {}',
' local pos = 1',
' while true do',
' next_delim = string.find(input, delim, pos)',
' if next_delim == nil then',
' table.insert(t, string.sub(input, pos))',
' break',
' else',
' table.insert(t, string.sub(input, pos, next_delim-1))',
' pos = next_delim + #delim',
' end',
' end',
' return t',
'end']);
} else if (mode == 'JOIN') {
if (!value_input) {
value_input = '({})';
}
functionName = 'table.concat';
} else {
throw 'Unknown mode: ' + mode;
}
var code = functionName + '(' + value_input + ', ' + value_delim + ')';
return [code, Blockly.Lua.ORDER_HIGH];
};
+125
View File
@@ -0,0 +1,125 @@
/**
* @license
* Visual Blocks Language
*
* Copyright 2016 Google Inc.
* https://developers.google.com/blockly/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview Generating Lua for logic blocks.
* @author rodrigoq@google.com (Rodrigo Queiro)
*/
'use strict';
goog.provide('Blockly.Lua.logic');
goog.require('Blockly.Lua');
Blockly.Lua['controls_if'] = function(block) {
// If/elseif/else condition.
var n = 0;
var argument = Blockly.Lua.valueToCode(block, 'IF' + n,
Blockly.Lua.ORDER_NONE) || 'false';
var branch = Blockly.Lua.statementToCode(block, 'DO' + n);
var code = 'if ' + argument + ' then\n' + branch;
for (n = 1; n <= block.elseifCount_; n++) {
argument = Blockly.Lua.valueToCode(block, 'IF' + n,
Blockly.Lua.ORDER_NONE) || 'false';
branch = Blockly.Lua.statementToCode(block, 'DO' + n);
code += ' elseif ' + argument + ' then\n' + branch;
}
if (block.elseCount_) {
branch = Blockly.Lua.statementToCode(block, 'ELSE');
code += ' else\n' + branch;
}
return code + 'end\n';
};
Blockly.Lua['logic_compare'] = function(block) {
// Comparison operator.
var OPERATORS = {
'EQ': '==',
'NEQ': '~=',
'LT': '<',
'LTE': '<=',
'GT': '>',
'GTE': '>='
};
var operator = OPERATORS[block.getFieldValue('OP')];
var argument0 = Blockly.Lua.valueToCode(block, 'A',
Blockly.Lua.ORDER_RELATIONAL) || '0';
var argument1 = Blockly.Lua.valueToCode(block, 'B',
Blockly.Lua.ORDER_RELATIONAL) || '0';
var code = argument0 + ' ' + operator + ' ' + argument1;
return [code, Blockly.Lua.ORDER_RELATIONAL];
};
Blockly.Lua['logic_operation'] = function(block) {
// Operations 'and', 'or'.
var operator = (block.getFieldValue('OP') == 'AND') ? 'and' : 'or';
var order = (operator == 'and') ? Blockly.Lua.ORDER_AND :
Blockly.Lua.ORDER_OR;
var argument0 = Blockly.Lua.valueToCode(block, 'A', order);
var argument1 = Blockly.Lua.valueToCode(block, 'B', order);
if (!argument0 && !argument1) {
// If there are no arguments, then the return value is false.
argument0 = 'false';
argument1 = 'false';
} else {
// Single missing arguments have no effect on the return value.
var defaultArgument = (operator == 'and') ? 'true' : 'false';
if (!argument0) {
argument0 = defaultArgument;
}
if (!argument1) {
argument1 = defaultArgument;
}
}
var code = argument0 + ' ' + operator + ' ' + argument1;
return [code, order];
};
Blockly.Lua['logic_negate'] = function(block) {
// Negation.
var argument0 = Blockly.Lua.valueToCode(block, 'BOOL',
Blockly.Lua.ORDER_UNARY) || 'true';
var code = 'not ' + argument0;
return [code, Blockly.Lua.ORDER_UNARY];
};
Blockly.Lua['logic_boolean'] = function(block) {
// Boolean values true and false.
var code = (block.getFieldValue('BOOL') == 'TRUE') ? 'true' : 'false';
return [code, Blockly.Lua.ORDER_ATOMIC];
};
Blockly.Lua['logic_null'] = function(block) {
// Null data type.
return ['nil', Blockly.Lua.ORDER_ATOMIC];
};
Blockly.Lua['logic_ternary'] = function(block) {
// Ternary operator.
var value_if = Blockly.Lua.valueToCode(block, 'IF',
Blockly.Lua.ORDER_AND) || 'false';
var value_then = Blockly.Lua.valueToCode(block, 'THEN',
Blockly.Lua.ORDER_AND) || 'nil';
var value_else = Blockly.Lua.valueToCode(block, 'ELSE',
Blockly.Lua.ORDER_OR) || 'nil';
var code = value_if + ' and ' + value_then + ' or ' + value_else;
return [code, Blockly.Lua.ORDER_OR];
};
+166
View File
@@ -0,0 +1,166 @@
/**
* @license
* Visual Blocks Language
*
* Copyright 2016 Google Inc.
* https://developers.google.com/blockly/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview Generating Lua for loop blocks.
* @author rodrigoq@google.com (Rodrigo Queiro)
*/
'use strict';
goog.provide('Blockly.Lua.loops');
goog.require('Blockly.Lua');
/**
* This is the text used to implement a <pre>continue</pre>.
* It is also used to recognise <pre>continue</pre>s in generated code so that
* the appropriate label can be put at the end of the loop body.
* @const {string}
*/
Blockly.Lua.CONTINUE_STATEMENT = 'goto continue\n';
/**
* If the loop body contains a "goto continue" statement, add a continue label
* to the loop body. Slightly inefficient, as continue labels will be generated
* in all outer loops, but this is safer than duplicating the logic of
* blockToCode.
*
* @param {string} branch Generated code of the loop body
* @return {string} Generated label or '' if unnecessary
*/
Blockly.Lua.addContinueLabel = function(branch) {
if (branch.indexOf(Blockly.Lua.CONTINUE_STATEMENT) > -1) {
return branch + Blockly.Lua.INDENT + '::continue::\n';
} else {
return branch;
}
};
Blockly.Lua['controls_repeat'] = function(block) {
// Repeat n times (internal number).
var repeats = parseInt(block.getFieldValue('TIMES'), 10);
var branch = Blockly.Lua.statementToCode(block, 'DO') || '';
branch = Blockly.Lua.addContinueLabel(branch);
var loopVar = Blockly.Lua.variableDB_.getDistinctName(
'count', Blockly.Variables.NAME_TYPE);
var code = 'for ' + loopVar + ' = 1, ' + repeats + ' do\n' + branch + 'end\n';
return code;
};
Blockly.Lua['controls_repeat_ext'] = function(block) {
// Repeat n times (external number).
var repeats = Blockly.Lua.valueToCode(block, 'TIMES',
Blockly.Lua.ORDER_NONE) || '0';
if (Blockly.isNumber(repeats)) {
repeats = parseInt(repeats, 10);
} else {
repeats = 'math.floor(' + repeats + ')';
}
var branch = Blockly.Lua.statementToCode(block, 'DO') || '\n';
branch = Blockly.Lua.addContinueLabel(branch);
var loopVar = Blockly.Lua.variableDB_.getDistinctName(
'count', Blockly.Variables.NAME_TYPE);
var code = 'for ' + loopVar + ' = 1, ' + repeats + ' do\n' +
branch + 'end\n';
return code;
};
Blockly.Lua['controls_whileUntil'] = function(block) {
// Do while/until loop.
var until = block.getFieldValue('MODE') == 'UNTIL';
var argument0 = Blockly.Lua.valueToCode(block, 'BOOL',
until ? Blockly.Lua.ORDER_UNARY :
Blockly.Lua.ORDER_NONE) || 'false';
var branch = Blockly.Lua.statementToCode(block, 'DO') || '\n';
branch = Blockly.Lua.addLoopTrap(branch, block.id);
branch = Blockly.Lua.addContinueLabel(branch);
if (until) {
argument0 = 'not ' + argument0;
}
return 'while ' + argument0 + ' do\n' + branch + 'end\n';
};
Blockly.Lua['controls_for'] = function(block) {
// For loop.
var variable0 = Blockly.Lua.variableDB_.getName(
block.getFieldValue('VAR'), Blockly.Variables.NAME_TYPE);
var startVar = Blockly.Lua.valueToCode(block, 'FROM',
Blockly.Lua.ORDER_NONE) || '0';
var endVar = Blockly.Lua.valueToCode(block, 'TO',
Blockly.Lua.ORDER_NONE) || '0';
var increment = Blockly.Lua.valueToCode(block, 'BY',
Blockly.Lua.ORDER_NONE) || '1';
var branch = Blockly.Lua.statementToCode(block, 'DO') || '\n';
branch = Blockly.Lua.addLoopTrap(branch, block.id);
branch = Blockly.Lua.addContinueLabel(branch);
var code = '';
var incValue;
if (Blockly.isNumber(startVar) && Blockly.isNumber(endVar) &&
Blockly.isNumber(increment)) {
// All arguments are simple numbers.
var up = parseFloat(startVar) <= parseFloat(endVar);
var step = Math.abs(parseFloat(increment));
incValue = (up ? '' : '-') + step;
} else {
code = '';
// Determine loop direction at start, in case one of the bounds
// changes during loop execution.
incValue = Blockly.Lua.variableDB_.getDistinctName(
variable0 + '_inc', Blockly.Variables.NAME_TYPE);
code += incValue + ' = ';
if (Blockly.isNumber(increment)) {
code += Math.abs(increment) + '\n';
} else {
code += 'math.abs(' + increment + ')\n';
}
code += 'if (' + startVar + ') > (' + endVar + ') then\n';
code += Blockly.Lua.INDENT + incValue + ' = -' + incValue + '\n';
code += 'end\n';
}
code += 'for ' + variable0 + ' = ' + startVar + ', ' + endVar +
', ' + incValue;
code += ' do\n' + branch + 'end\n';
return code;
};
Blockly.Lua['controls_forEach'] = function(block) {
// For each loop.
var variable0 = Blockly.Lua.variableDB_.getName(
block.getFieldValue('VAR'), Blockly.Variables.NAME_TYPE);
var argument0 = Blockly.Lua.valueToCode(block, 'LIST',
Blockly.Lua.ORDER_NONE) || '{}';
var branch = Blockly.Lua.statementToCode(block, 'DO') || '\n';
branch = Blockly.Lua.addContinueLabel(branch);
var code = 'for _, ' + variable0 + ' in ipairs(' + argument0 + ') do \n' +
branch + 'end\n';
return code;
};
Blockly.Lua['controls_flow_statements'] = function(block) {
// Flow statements: continue, break.
switch (block.getFieldValue('FLOW')) {
case 'BREAK':
return 'break\n';
case 'CONTINUE':
return Blockly.Lua.CONTINUE_STATEMENT;
}
throw 'Unknown flow statement.';
};
+425
View File
@@ -0,0 +1,425 @@
/**
* @license
* Visual Blocks Language
*
* Copyright 2016 Google Inc.
* https://developers.google.com/blockly/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview Generating Lua for math blocks.
* @author rodrigoq@google.com (Rodrigo Queiro)
*/
'use strict';
goog.provide('Blockly.Lua.math');
goog.require('Blockly.Lua');
Blockly.Lua['math_number'] = function(block) {
// Numeric value.
var code = parseFloat(block.getFieldValue('NUM'));
var order = code < 0 ? Blockly.Lua.ORDER_UNARY :
Blockly.Lua.ORDER_ATOMIC;
return [code, order];
};
Blockly.Lua['math_arithmetic'] = function(block) {
// Basic arithmetic operators, and power.
var OPERATORS = {
ADD: [' + ', Blockly.Lua.ORDER_ADDITIVE],
MINUS: [' - ', Blockly.Lua.ORDER_ADDITIVE],
MULTIPLY: [' * ', Blockly.Lua.ORDER_MULTIPLICATIVE],
DIVIDE: [' / ', Blockly.Lua.ORDER_MULTIPLICATIVE],
POWER: [' ^ ', Blockly.Lua.ORDER_EXPONENTIATION]
};
var tuple = OPERATORS[block.getFieldValue('OP')];
var operator = tuple[0];
var order = tuple[1];
var argument0 = Blockly.Lua.valueToCode(block, 'A', order) || '0';
var argument1 = Blockly.Lua.valueToCode(block, 'B', order) || '0';
var code = argument0 + operator + argument1;
return [code, order];
};
Blockly.Lua['math_single'] = function(block) {
// Math operators with single operand.
var operator = block.getFieldValue('OP');
var code;
var arg;
if (operator == 'NEG') {
// Negation is a special case given its different operator precedence.
arg = Blockly.Lua.valueToCode(block, 'NUM',
Blockly.Lua.ORDER_UNARY) || '0';
return ['-' + arg, Blockly.Lua.ORDER_UNARY];
}
if (operator == 'SIN' || operator == 'COS' || operator == 'TAN') {
arg = Blockly.Lua.valueToCode(block, 'NUM',
Blockly.Lua.ORDER_MULTIPLICATIVE) || '0';
} else {
arg = Blockly.Lua.valueToCode(block, 'NUM',
Blockly.Lua.ORDER_NONE) || '0';
}
switch (operator) {
case 'ABS':
code = 'math.abs(' + arg + ')';
break;
case 'ROOT':
code = 'math.sqrt(' + arg + ')';
break;
case 'LN':
code = 'math.log(' + arg + ')';
break;
case 'LOG10':
code = 'math.log10(' + arg + ')';
break;
case 'EXP':
code = 'math.exp(' + arg + ')';
break;
case 'POW10':
code = 'math.pow(10,' + arg + ')';
break;
case 'ROUND':
// This rounds up. Blockly does not specify rounding direction.
code = 'math.floor(' + arg + ' + .5)';
break;
case 'ROUNDUP':
code = 'math.ceil(' + arg + ')';
break;
case 'ROUNDDOWN':
code = 'math.floor(' + arg + ')';
break;
case 'SIN':
code = 'math.sin(math.rad(' + arg + '))';
break;
case 'COS':
code = 'math.cos(math.rad(' + arg + '))';
break;
case 'TAN':
code = 'math.tan(math.rad(' + arg + '))';
break;
case 'ASIN':
code = 'math.deg(math.asin(' + arg + '))';
break;
case 'ACOS':
code = 'math.deg(math.acos(' + arg + '))';
break;
case 'ATAN':
code = 'math.deg(math.atan(' + arg + '))';
break;
default:
throw 'Unknown math operator: ' + operator;
}
return [code, Blockly.Lua.ORDER_HIGH];
};
Blockly.Lua['math_constant'] = function(block) {
// Constants: PI, E, the Golden Ratio, sqrt(2), 1/sqrt(2), INFINITY.
var CONSTANTS = {
PI: ['math.pi', Blockly.Lua.ORDER_HIGH],
E: ['math.exp(1)', Blockly.Lua.ORDER_HIGH],
GOLDEN_RATIO: ['(1 + math.sqrt(5)) / 2', Blockly.Lua.ORDER_MULTIPLICATIVE],
SQRT2: ['math.sqrt(2)', Blockly.Lua.ORDER_HIGH],
SQRT1_2: ['math.sqrt(1 / 2)', Blockly.Lua.ORDER_HIGH],
INFINITY: ['math.huge', Blockly.Lua.ORDER_HIGH]
};
return CONSTANTS[block.getFieldValue('CONSTANT')];
};
Blockly.Lua['math_number_property'] = function(block) {
// Check if a number is even, odd, prime, whole, positive, or negative
// or if it is divisible by certain number. Returns true or false.
var number_to_check = Blockly.Lua.valueToCode(block, 'NUMBER_TO_CHECK',
Blockly.Lua.ORDER_MULTIPLICATIVE) || '0';
var dropdown_property = block.getFieldValue('PROPERTY');
var code;
if (dropdown_property == 'PRIME') {
// Prime is a special case as it is not a one-liner test.
var functionName = Blockly.Lua.provideFunction_(
'math_isPrime',
['function ' + Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_ + '(n)',
' -- https://en.wikipedia.org/wiki/Primality_test#Naive_methods',
' if n == 2 or n == 3 then',
' return true',
' end',
' -- False if n is NaN, negative, is 1, or not whole.',
' -- And false if n is divisible by 2 or 3.',
' if not(n > 1) or n % 1 ~= 0 or n % 2 == 0 or n % 3 == 0 then',
' return false',
' end',
' -- Check all the numbers of form 6k +/- 1, up to sqrt(n).',
' for x = 6, math.sqrt(n) + 1.5, 6 do',
' if n % (x - 1) == 0 or n % (x + 1) == 0 then',
' return false',
' end',
' end',
' return true',
'end']);
code = functionName + '(' + number_to_check + ')';
return [code, Blockly.Lua.ORDER_HIGH];
}
switch (dropdown_property) {
case 'EVEN':
code = number_to_check + ' % 2 == 0';
break;
case 'ODD':
code = number_to_check + ' % 2 == 1';
break;
case 'WHOLE':
code = number_to_check + ' % 1 == 0';
break;
case 'POSITIVE':
code = number_to_check + ' > 0';
break;
case 'NEGATIVE':
code = number_to_check + ' < 0';
break;
case 'DIVISIBLE_BY':
var divisor = Blockly.Lua.valueToCode(block, 'DIVISOR',
Blockly.Lua.ORDER_MULTIPLICATIVE);
// If 'divisor' is some code that evals to 0, Lua will produce a nan.
// Let's produce nil if we can determine this at compile-time.
if (!divisor || divisor == '0') {
return ['nil', Blockly.Lua.ORDER_ATOMIC];
}
// The normal trick to implement ?: with and/or doesn't work here:
// divisor == 0 and nil or number_to_check % divisor == 0
// because nil is false, so allow a runtime failure. :-(
code = number_to_check + ' % ' + divisor + ' == 0';
break;
}
return [code, Blockly.Lua.ORDER_RELATIONAL];
};
Blockly.Lua['math_change'] = function(block) {
// Add to a variable in place.
var argument0 = Blockly.Lua.valueToCode(block, 'DELTA',
Blockly.Lua.ORDER_ADDITIVE) || '0';
var varName = Blockly.Lua.variableDB_.getName(
block.getFieldValue('VAR'), Blockly.Variables.NAME_TYPE);
return varName + ' = ' + varName + ' + ' + argument0 + '\n';
};
// Rounding functions have a single operand.
Blockly.Lua['math_round'] = Blockly.Lua['math_single'];
// Trigonometry functions have a single operand.
Blockly.Lua['math_trig'] = Blockly.Lua['math_single'];
Blockly.Lua['math_on_list'] = function(block) {
// Math functions for lists.
var func = block.getFieldValue('OP');
var list = Blockly.Lua.valueToCode(block, 'LIST',
Blockly.Lua.ORDER_NONE) || '{}';
var functionName;
// Functions needed in more than one case.
function provideSum() {
return Blockly.Lua.provideFunction_(
'math_sum',
['function ' + Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_ + '(t)',
' local result = 0',
' for _, v in ipairs(t) do',
' result = result + v',
' end',
' return result',
'end']);
}
switch (func) {
case 'SUM':
functionName = provideSum();
break;
case 'MIN':
// Returns 0 for the empty list.
functionName = Blockly.Lua.provideFunction_(
'math_min',
['function ' + Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_ + '(t)',
' if #t == 0 then',
' return 0',
' end',
' local result = math.huge',
' for _, v in ipairs(t) do',
' if v < result then',
' result = v',
' end',
' end',
' return result',
'end']);
break;
case 'AVERAGE':
// Returns 0 for the empty list.
functionName = Blockly.Lua.provideFunction_(
'math_average',
['function ' + Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_ + '(t)',
' if #t == 0 then',
' return 0',
' end',
' return ' + provideSum() + '(t) / #t',
'end']);
break;
case 'MAX':
// Returns 0 for the empty list.
functionName = Blockly.Lua.provideFunction_(
'math_max',
['function ' + Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_ + '(t)',
' if #t == 0 then',
' return 0',
' end',
' local result = -math.huge',
' for _, v in ipairs(t) do',
' if v > result then',
' result = v',
' end',
' end',
' return result',
'end']);
break;
case 'MEDIAN':
functionName = Blockly.Lua.provideFunction_(
'math_median',
// This operation excludes non-numbers.
['function ' + Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_ + '(t)',
' -- Source: http://lua-users.org/wiki/SimpleStats',
' if #t == 0 then',
' return 0',
' end',
' local temp={}',
' for _, v in ipairs(t) do',
' if type(v) == "number" then',
' table.insert(temp, v)',
' end',
' end',
' table.sort(temp)',
' if #temp % 2 == 0 then',
' return (temp[#temp/2] + temp[(#temp/2)+1]) / 2',
' else',
' return temp[math.ceil(#temp/2)]',
' end',
'end']);
break;
case 'MODE':
functionName = Blockly.Lua.provideFunction_(
'math_modes',
// As a list of numbers can contain more than one mode,
// the returned result is provided as an array.
// The Lua version includes non-numbers.
['function ' + Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_ + '(t)',
' -- Source: http://lua-users.org/wiki/SimpleStats',
' local counts={}',
' for _, v in ipairs(t) do',
' if counts[v] == nil then',
' counts[v] = 1',
' else',
' counts[v] = counts[v] + 1',
' end',
' end',
' local biggestCount = 0',
' for _, v in pairs(counts) do',
' if v > biggestCount then',
' biggestCount = v',
' end',
' end',
' local temp={}',
' for k, v in pairs(counts) do',
' if v == biggestCount then',
' table.insert(temp, k)',
' end',
' end',
' return temp',
'end']);
break;
case 'STD_DEV':
functionName = Blockly.Lua.provideFunction_(
'math_standard_deviation',
['function ' + Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_ + '(t)',
' local m',
' local vm',
' local total = 0',
' local count = 0',
' local result',
' m = #t == 0 and 0 or ' + provideSum() + '(t) / #t',
' for _, v in ipairs(t) do',
" if type(v) == 'number' then",
' vm = v - m',
' total = total + (vm * vm)',
' count = count + 1',
' end',
' end',
' result = math.sqrt(total / (count-1))',
' return result',
'end']);
break;
case 'RANDOM':
functionName = Blockly.Lua.provideFunction_(
'math_random_list',
['function ' + Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_ + '(t)',
' if #t == 0 then',
' return nil',
' end',
' return t[math.random(#t)]',
'end']);
break;
default:
throw 'Unknown operator: ' + func;
}
return [functionName + '(' + list + ')', Blockly.Lua.ORDER_HIGH];
};
Blockly.Lua['math_modulo'] = function(block) {
// Remainder computation.
var argument0 = Blockly.Lua.valueToCode(block, 'DIVIDEND',
Blockly.Lua.ORDER_MULTIPLICATIVE) || '0';
var argument1 = Blockly.Lua.valueToCode(block, 'DIVISOR',
Blockly.Lua.ORDER_MULTIPLICATIVE) || '0';
var code = argument0 + ' % ' + argument1;
return [code, Blockly.Lua.ORDER_MULTIPLICATIVE];
};
Blockly.Lua['math_constrain'] = function(block) {
// Constrain a number between two limits.
var argument0 = Blockly.Lua.valueToCode(block, 'VALUE',
Blockly.Lua.ORDER_NONE) || '0';
var argument1 = Blockly.Lua.valueToCode(block, 'LOW',
Blockly.Lua.ORDER_NONE) || '-math.huge';
var argument2 = Blockly.Lua.valueToCode(block, 'HIGH',
Blockly.Lua.ORDER_NONE) || 'math.huge';
var code = 'math.min(math.max(' + argument0 + ', ' + argument1 + '), ' +
argument2 + ')';
return [code, Blockly.Lua.ORDER_HIGH];
};
Blockly.Lua['math_random_int'] = function(block) {
// Random integer between [X] and [Y].
var argument0 = Blockly.Lua.valueToCode(block, 'FROM',
Blockly.Lua.ORDER_NONE) || '0';
var argument1 = Blockly.Lua.valueToCode(block, 'TO',
Blockly.Lua.ORDER_NONE) || '0';
var code = 'math.random(' + argument0 + ', ' + argument1 + ')';
return [code, Blockly.Lua.ORDER_HIGH];
};
Blockly.Lua['math_random_float'] = function(block) {
// Random fraction between 0 and 1.
return ['math.random()', Blockly.Lua.ORDER_HIGH];
};
+110
View File
@@ -0,0 +1,110 @@
/**
* @license
* Visual Blocks Language
*
* Copyright 2016 Google Inc.
* https://developers.google.com/blockly/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview Generating Lua for procedure blocks.
* @author rodrigoq@google.com (Rodrigo Queiro)
*/
'use strict';
goog.provide('Blockly.Lua.procedures');
goog.require('Blockly.Lua');
Blockly.Lua['procedures_defreturn'] = function(block) {
// Define a procedure with a return value.
var funcName = Blockly.Lua.variableDB_.getName(
block.getFieldValue('NAME'), Blockly.Procedures.NAME_TYPE);
var branch = Blockly.Lua.statementToCode(block, 'STACK');
if (Blockly.Lua.STATEMENT_PREFIX) {
branch = Blockly.Lua.prefixLines(
Blockly.Lua.STATEMENT_PREFIX.replace(/%1/g,
'\'' + block.id + '\''), Blockly.Lua.INDENT) + branch;
}
if (Blockly.Lua.INFINITE_LOOP_TRAP) {
branch = Blockly.Lua.INFINITE_LOOP_TRAP.replace(/%1/g,
'\'' + block.id + '\'') + branch;
}
var returnValue = Blockly.Lua.valueToCode(block, 'RETURN',
Blockly.Lua.ORDER_NONE) || '';
if (returnValue) {
returnValue = ' return ' + returnValue + '\n';
} else if (!branch) {
branch = '';
}
var args = [];
for (var x = 0; x < block.arguments_.length; x++) {
args[x] = Blockly.Lua.variableDB_.getName(block.arguments_[x],
Blockly.Variables.NAME_TYPE);
}
var code = 'function ' + funcName + '(' + args.join(', ') + ')\n' +
branch + returnValue + 'end\n';
code = Blockly.Lua.scrub_(block, code);
Blockly.Lua.definitions_[funcName] = code;
return null;
};
// Defining a procedure without a return value uses the same generator as
// a procedure with a return value.
Blockly.Lua['procedures_defnoreturn'] =
Blockly.Lua['procedures_defreturn'];
Blockly.Lua['procedures_callreturn'] = function(block) {
// Call a procedure with a return value.
var funcName = Blockly.Lua.variableDB_.getName(
block.getFieldValue('NAME'), Blockly.Procedures.NAME_TYPE);
var args = [];
for (var x = 0; x < block.arguments_.length; x++) {
args[x] = Blockly.Lua.valueToCode(block, 'ARG' + x,
Blockly.Lua.ORDER_NONE) || 'nil';
}
var code = funcName + '(' + args.join(', ') + ')';
return [code, Blockly.Lua.ORDER_HIGH];
};
Blockly.Lua['procedures_callnoreturn'] = function(block) {
// Call a procedure with no return value.
var funcName = Blockly.Lua.variableDB_.getName(
block.getFieldValue('NAME'), Blockly.Procedures.NAME_TYPE);
var args = [];
for (var x = 0; x < block.arguments_.length; x++) {
args[x] = Blockly.Lua.valueToCode(block, 'ARG' + x,
Blockly.Lua.ORDER_NONE) || 'nil';
}
var code = funcName + '(' + args.join(', ') + ')\n';
return code;
};
Blockly.Lua['procedures_ifreturn'] = function(block) {
// Conditionally return value from a procedure.
var condition = Blockly.Lua.valueToCode(block, 'CONDITION',
Blockly.Lua.ORDER_NONE) || 'false';
var code = 'if ' + condition + ' then\n';
if (block.hasReturnValue_) {
var value = Blockly.Lua.valueToCode(block, 'VALUE',
Blockly.Lua.ORDER_NONE) || 'nil';
code += ' return ' + value + '\n';
} else {
code += ' return\n';
}
code += 'end\n';
return code;
};
+293
View File
@@ -0,0 +1,293 @@
/**
* @license
* Visual Blocks Language
*
* Copyright 2016 Google Inc.
* https://developers.google.com/blockly/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview Generating Lua for text blocks.
* @author rodrigoq@google.com (Rodrigo Queiro)
*/
'use strict';
goog.provide('Blockly.Lua.texts');
goog.require('Blockly.Lua');
Blockly.Lua['text'] = function(block) {
// Text value.
var code = Blockly.Lua.quote_(block.getFieldValue('TEXT'));
return [code, Blockly.Lua.ORDER_ATOMIC];
};
Blockly.Lua['text_join'] = function(block) {
// Create a string made up of any number of elements of any type.
if (block.itemCount_ == 0) {
return ['\'\'', Blockly.Lua.ORDER_ATOMIC];
} else if (block.itemCount_ == 1) {
var argument0 = Blockly.Lua.valueToCode(block, 'ADD0',
Blockly.Lua.ORDER_NONE) || '\'\'';
var code = argument0;
return [code, Blockly.Lua.ORDER_HIGH];
} else if (block.itemCount_ == 2) {
var argument0 = Blockly.Lua.valueToCode(block, 'ADD0',
Blockly.Lua.ORDER_NONE) || '\'\'';
var argument1 = Blockly.Lua.valueToCode(block, 'ADD1',
Blockly.Lua.ORDER_NONE) || '\'\'';
var code = argument0 + ' .. ' + argument1;
return [code, Blockly.Lua.ORDER_UNARY];
} else {
var code = [];
for (var n = 0; n < block.itemCount_; n++) {
code[n] = Blockly.Lua.valueToCode(block, 'ADD' + n,
Blockly.Lua.ORDER_NONE) || '\'\'';
}
code = 'table.concat({' + code.join(', ') + '})';
return [code, Blockly.Lua.ORDER_HIGH];
}
};
Blockly.Lua['text_append'] = function(block) {
// Append to a variable in place.
var varName = Blockly.Lua.variableDB_.getName(
block.getFieldValue('VAR'), Blockly.Variables.NAME_TYPE);
var argument0 = Blockly.Lua.valueToCode(block, 'TEXT',
Blockly.Lua.ORDER_NONE) || '\'\'';
return varName + ' = ' + varName + ' .. ' + argument0 + '\n';
};
Blockly.Lua['text_length'] = function(block) {
// String or array length.
var argument0 = Blockly.Lua.valueToCode(block, 'VALUE',
Blockly.Lua.ORDER_HIGH) || '\'\'';
return ['#' + argument0, Blockly.Lua.ORDER_HIGH];
};
Blockly.Lua['text_isEmpty'] = function(block) {
// Is the string null or array empty?
var argument0 = Blockly.Lua.valueToCode(block, 'VALUE',
Blockly.Lua.ORDER_HIGH) || '\'\'';
return ['#' + argument0 + ' == 0', Blockly.Lua.ORDER_RELATIONAL];
};
Blockly.Lua['text_indexOf'] = function(block) {
// Search the text for a substring.
var operator = block.getFieldValue('END') == 'FIRST' ?
'indexOf' : 'lastIndexOf';
var substr = Blockly.Lua.valueToCode(block, 'FIND',
Blockly.Lua.ORDER_NONE) || '\'\'';
var str = Blockly.Lua.valueToCode(block, 'VALUE',
Blockly.Lua.ORDER_NONE) || '\'\'';
if (block.getFieldValue('END') == 'FIRST') {
var functionName = Blockly.Lua.provideFunction_(
'firstIndexOf',
['function ' + Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_ +
'(str, substr) ',
' local i = string.find(str, substr, 1, true)',
' if i == nil then',
' return 0',
' else',
' return i',
' end',
'end']);
} else {
var functionName = Blockly.Lua.provideFunction_(
'lastIndexOf',
['function ' + Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_ +
'(str, substr)',
' local i = string.find(string.reverse(str), ' +
'string.reverse(substr), 1, true)',
' if i then',
' return #str + 2 - i - #substr',
' end',
' return 0',
'end']);
}
var code = functionName + '(' + str + ', ' + substr + ')';
return [code, Blockly.Lua.ORDER_HIGH];
};
Blockly.Lua['text_charAt'] = function(block) {
// Get letter at index.
// Note: Until January 2013 this block did not have the WHERE input.
var where = block.getFieldValue('WHERE') || 'FROM_START';
var at = Blockly.Lua.valueToCode(block, 'AT',
Blockly.Lua.ORDER_UNARY) || '1';
var text = Blockly.Lua.valueToCode(block, 'VALUE',
Blockly.Lua.ORDER_NONE) || '\'\'';
var code;
if (where == 'RANDOM') {
var functionName = Blockly.Lua.provideFunction_(
'text_random_letter',
['function ' + Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_ + '(str)',
' local index = math.random(string.len(str))',
' return string.sub(str, index, index)',
'end']);
code = functionName + '(' + text + ')';
} else {
if (where == 'FIRST') {
var start = '1';
} else if (where == 'LAST') {
var start = '-1';
} else {
if (where == 'FROM_START') {
var start = at;
} else if (where == 'FROM_END') {
var start = '-' + at;
} else {
throw 'Unhandled option (text_charAt).';
}
}
if (start.match(/^-?\w*$/)) {
code = 'string.sub(' + text + ', ' + start + ', ' + start + ')';
} else {
// use function to avoid reevaluation
var functionName = Blockly.Lua.provideFunction_(
'text_char_at',
['function ' + Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_ +
'(str, index)',
' return string.sub(str, index, index)',
'end']);
code = functionName + '(' + text + ', ' + start + ')';
}
}
return [code, Blockly.Lua.ORDER_HIGH];
};
Blockly.Lua['text_getSubstring'] = function(block) {
// Get substring.
var text = Blockly.Lua.valueToCode(block, 'STRING',
Blockly.Lua.ORDER_NONE) || '\'\'';
// Get start index.
var where1 = block.getFieldValue('WHERE1');
var at1 = Blockly.Lua.valueToCode(block, 'AT1',
Blockly.Lua.ORDER_UNARY) || '1';
if (where1 == 'FIRST') {
var start = 1;
} else if (where1 == 'FROM_START') {
var start = at1;
} else if (where1 == 'FROM_END') {
var start = '-' + at1;
} else {
throw 'Unhandled option (text_getSubstring)';
}
// Get end index.
var where2 = block.getFieldValue('WHERE2');
var at2 = Blockly.Lua.valueToCode(block, 'AT2',
Blockly.Lua.ORDER_UNARY) || '1';
if (where2 == 'LAST') {
var end = -1;
} else if (where2 == 'FROM_START') {
var end = at2;
} else if (where2 == 'FROM_END') {
var end = '-' + at2;
} else {
throw 'Unhandled option (text_getSubstring)';
}
var code = 'string.sub(' + text + ', ' + start + ', ' + end + ')';
return [code, Blockly.Lua.ORDER_HIGH];
};
Blockly.Lua['text_changeCase'] = function(block) {
// Change capitalization.
var operator = block.getFieldValue('CASE');
var argument0 = Blockly.Lua.valueToCode(block, 'TEXT',
Blockly.Lua.ORDER_NONE) || '\'\'';
if (operator == 'UPPERCASE') {
var functionName = 'string.upper';
} else if (operator == 'LOWERCASE') {
var functionName = 'string.lower';
} else if (operator == 'TITLECASE') {
var functionName = Blockly.Lua.provideFunction_(
'text_titlecase',
// There are shorter versions at
// http://lua-users.org/wiki/SciteTitleCase
// that do not preserve whitespace.
['function ' + Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_ + '(str)',
' local buf = {}',
' local inWord = false',
' for i = 1, #str do',
' local c = string.sub(str, i, i)',
' if inWord then',
' table.insert(buf, string.lower(c))',
' if string.find(c, "%s") then',
' inWord = false',
' end',
' else',
' table.insert(buf, string.upper(c))',
' inWord = true',
' end',
' end',
' return table.concat(buf)',
'end']);
}
var code = functionName + '(' + argument0 + ')';
return [code, Blockly.Lua.ORDER_HIGH];
};
Blockly.Lua['text_trim'] = function(block) {
// Trim spaces.
var OPERATORS = {
LEFT: '^%s*(,-)',
RIGHT: '(.-)%s*$',
BOTH: '^%s*(.-)%s*$'
};
var operator = OPERATORS[block.getFieldValue('MODE')];
var text = Blockly.Lua.valueToCode(block, 'TEXT',
Blockly.Lua.ORDER_NONE) || '\'\'';
var code = 'string.gsub(' + text + ', "' + operator + '", "%1")';
return [code, Blockly.Lua.ORDER_HIGH];
};
Blockly.Lua['text_print'] = function(block) {
// Print statement.
var argument0 = Blockly.Lua.valueToCode(block, 'TEXT',
Blockly.Lua.ORDER_NONE) || '\'\'';
return 'print(' + argument0 + ')\n';
};
Blockly.Lua['text_prompt_ext'] = function(block) {
// Prompt function.
if (block.getField('TEXT')) {
// Internal message.
var msg = Blockly.Lua.quote_(block.getFieldValue('TEXT'));
} else {
// External message.
var msg = Blockly.Lua.valueToCode(block, 'TEXT',
Blockly.Lua.ORDER_NONE) || '\'\'';
}
var functionName = Blockly.Lua.provideFunction_(
'text_prompt',
['function ' + Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_ + '(msg)',
' io.write(msg)',
' io.flush()',
' return io.read()',
'end']);
var code = functionName + '(' + msg + ')';
var toNumber = block.getFieldValue('TYPE') == 'NUMBER';
if (toNumber) {
code = 'tonumber(' + code + ', 10)';
}
return [code, Blockly.Lua.ORDER_HIGH];
};
Blockly.Lua['text_prompt'] = Blockly.Lua['text_prompt_ext'];
+46
View File
@@ -0,0 +1,46 @@
/**
* @license
* Visual Blocks Language
*
* Copyright 2016 Google Inc.
* https://developers.google.com/blockly/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @fileoverview Generating Lua for variable blocks.
* @author rodrigoq@google.com (Rodrigo Queiro)
*/
'use strict';
goog.provide('Blockly.Lua.variables');
goog.require('Blockly.Lua');
Blockly.Lua['variables_get'] = function(block) {
// Variable getter.
var code = Blockly.Lua.variableDB_.getName(block.getFieldValue('VAR'),
Blockly.Variables.NAME_TYPE);
return [code, Blockly.Lua.ORDER_ATOMIC];
};
Blockly.Lua['variables_set'] = function(block) {
// Variable setter.
var argument0 = Blockly.Lua.valueToCode(block, 'VALUE',
Blockly.Lua.ORDER_NONE) || '0';
var varName = Blockly.Lua.variableDB_.getName(
block.getFieldValue('VAR'), Blockly.Variables.NAME_TYPE);
return varName + ' = ' + argument0 + '\n';
};
+72
View File
@@ -0,0 +1,72 @@
// Do not edit this file; automatically generated by build.py.
'use strict';
// Copyright 2016 Google Inc. Apache License 2.0
Blockly.Lua=new Blockly.Generator("Lua");Blockly.Lua.addReservedWords("_,__inext,assert,bit,colors,colours,coroutine,disk,dofile,error,fs,fetfenv,getmetatable,gps,help,io,ipairs,keys,loadfile,loadstring,math,native,next,os,paintutils,pairs,parallel,pcall,peripheral,print,printError,rawequal,rawget,rawset,read,rednet,redstone,rs,select,setfenv,setmetatable,sleep,string,table,term,textutils,tonumber,tostring,turtle,type,unpack,vector,write,xpcall,_VERSION,__indext,HTTP,and,break,do,else,elseif,end,false,for,function,if,in,local,nil,not,or,repeat,return,then,true,until,while,add,sub,mul,div,mod,pow,unm,concat,len,eq,lt,le,index,newindex,call,assert,collectgarbage,dofile,error,_G,getmetatable,inpairs,load,loadfile,next,pairs,pcall,print,rawequal,rawget,rawlen,rawset,select,setmetatable,tonumber,tostring,type,_VERSION,xpcall,require,package,string,table,math,bit32,io,file,os,debug");
Blockly.Lua.ORDER_ATOMIC=0;Blockly.Lua.ORDER_HIGH=1;Blockly.Lua.ORDER_EXPONENTIATION=2;Blockly.Lua.ORDER_UNARY=3;Blockly.Lua.ORDER_MULTIPLICATIVE=4;Blockly.Lua.ORDER_ADDITIVE=5;Blockly.Lua.ORDER_CONCATENATION=6;Blockly.Lua.ORDER_RELATIONAL=7;Blockly.Lua.ORDER_AND=8;Blockly.Lua.ORDER_OR=9;Blockly.Lua.ORDER_NONE=99;
Blockly.Lua.init=function(a){Blockly.Lua.definitions_=Object.create(null);Blockly.Lua.functionNames_=Object.create(null);Blockly.Lua.variableDB_?Blockly.Lua.variableDB_.reset():Blockly.Lua.variableDB_=new Blockly.Names(Blockly.Lua.RESERVED_WORDS_)};Blockly.Lua.finish=function(a){var b=[],c;for(c in Blockly.Lua.definitions_)b.push(Blockly.Lua.definitions_[c]);delete Blockly.Lua.definitions_;delete Blockly.Lua.functionNames_;Blockly.Lua.variableDB_.reset();return b.join("\n\n")+"\n\n\n"+a};
Blockly.Lua.scrubNakedValue=function(a){return"local _ = "+a+"\n"};Blockly.Lua.quote_=function(a){a=a.replace(/\\/g,"\\\\").replace(/\n/g,"\\\n").replace(/'/g,"\\'");return"'"+a+"'"};
Blockly.Lua.scrub_=function(a,b){var c="";if(!a.outputConnection||!a.outputConnection.targetConnection){var d=a.getCommentText();d&&(c+=Blockly.Lua.prefixLines(d,"-- ")+"\n");for(var e=0;e<a.inputList.length;e++)a.inputList[e].type==Blockly.INPUT_VALUE&&(d=a.inputList[e].connection.targetBlock())&&(d=Blockly.Lua.allNestedComments(d))&&(c+=Blockly.Lua.prefixLines(d,"-- "))}e=a.nextConnection&&a.nextConnection.targetBlock();e=Blockly.Lua.blockToCode(e);return c+b+e};Blockly.Lua.colour={};Blockly.Lua.colour_picker=function(a){return["'"+a.getFieldValue("COLOUR")+"'",Blockly.Lua.ORDER_ATOMIC]};Blockly.Lua.colour_random=function(a){return['string.format("#%06x", math.random(0, 2^24 - 1))',Blockly.Lua.ORDER_HIGH]};
Blockly.Lua.colour_rgb=function(a){var b=Blockly.Lua.provideFunction_("colour_rgb",["function "+Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(r, g, b)"," r = math.floor(math.min(100, math.max(0, r)) * 2.55 + .5)"," g = math.floor(math.min(100, math.max(0, g)) * 2.55 + .5)"," b = math.floor(math.min(100, math.max(0, b)) * 2.55 + .5)",' return string.format("#%02x%02x%02x", r, g, b)',"end"]),c=Blockly.Lua.valueToCode(a,"RED",Blockly.Lua.ORDER_NONE)||0,d=Blockly.Lua.valueToCode(a,"GREEN",Blockly.Lua.ORDER_NONE)||
0;a=Blockly.Lua.valueToCode(a,"BLUE",Blockly.Lua.ORDER_NONE)||0;return[b+"("+c+", "+d+", "+a+")",Blockly.Lua.ORDER_HIGH]};
Blockly.Lua.colour_blend=function(a){var b=Blockly.Lua.provideFunction_("colour_blend",["function "+Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(colour1, colour2, ratio)"," local r1 = tonumber(string.sub(colour1, 2, 3), 16)"," local r2 = tonumber(string.sub(colour2, 2, 3), 16)"," local g1 = tonumber(string.sub(colour1, 4, 5), 16)"," local g2 = tonumber(string.sub(colour2, 4, 5), 16)"," local b1 = tonumber(string.sub(colour1, 6, 7), 16)"," local b2 = tonumber(string.sub(colour2, 6, 7), 16)"," local ratio = math.min(1, math.max(0, ratio))",
" local r = math.floor(r1 * (1 - ratio) + r2 * ratio + .5)"," local g = math.floor(g1 * (1 - ratio) + g2 * ratio + .5)"," local b = math.floor(b1 * (1 - ratio) + b2 * ratio + .5)",' return string.format("#%02x%02x%02x", r, g, b)',"end"]),c=Blockly.Lua.valueToCode(a,"COLOUR1",Blockly.Lua.ORDER_NONE)||"'#000000'",d=Blockly.Lua.valueToCode(a,"COLOUR2",Blockly.Lua.ORDER_NONE)||"'#000000'";a=Blockly.Lua.valueToCode(a,"RATIO",Blockly.Lua.ORDER_NONE)||0;return[b+"("+c+", "+d+", "+a+")",Blockly.Lua.ORDER_HIGH]};Blockly.Lua.lists={};Blockly.Lua.lists_create_empty=function(a){return["({})",Blockly.Lua.ORDER_ATOMIC]};Blockly.Lua.lists_create_with=function(a){for(var b=Array(a.itemCount_),c=0;c<a.itemCount_;c++)b[c]=Blockly.Lua.valueToCode(a,"ADD"+c,Blockly.Lua.ORDER_NONE)||"None";b="({"+b.join(", ")+"})";return[b,Blockly.Lua.ORDER_ATOMIC]};
Blockly.Lua.lists_repeat=function(a){var b=Blockly.Lua.provideFunction_("create_list_repeated",["function "+Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(item, count)"," local t = {}"," for i = 1, count do"," table.insert(t, item)"," end"," return t","end"]),c=Blockly.Lua.valueToCode(a,"ITEM",Blockly.Lua.ORDER_NONE)||"None";a=Blockly.Lua.valueToCode(a,"NUM",Blockly.Lua.ORDER_NONE)||"0";return[b+"("+c+", "+a+")",Blockly.Lua.ORDER_HIGH]};
Blockly.Lua.lists_length=function(a){return["#"+(Blockly.Lua.valueToCode(a,"VALUE",Blockly.Lua.ORDER_HIGH)||"({})"),Blockly.Lua.ORDER_HIGH]};Blockly.Lua.lists_isEmpty=function(a){return["#"+(Blockly.Lua.valueToCode(a,"VALUE",Blockly.Lua.ORDER_HIGH)||"({})")+" == 0",Blockly.Lua.ORDER_RELATIONAL]};
Blockly.Lua.lists_indexOf=function(a){var b=Blockly.Lua.valueToCode(a,"FIND",Blockly.Lua.ORDER_NONE)||"''",c=Blockly.Lua.valueToCode(a,"VALUE",Blockly.Lua.ORDER_NONE)||"({})";return[("FIRST"==a.getFieldValue("END")?Blockly.Lua.provideFunction_("first_index",["function "+Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(t, elem)"," for k, v in ipairs(t) do"," if v == elem then"," return k"," end"," end"," return 0","end"]):Blockly.Lua.provideFunction_("last_index",["function "+Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+
"(t, elem)"," for i = #t, 1, -1 do"," if t[i] == elem then"," return i"," end"," end"," return 0","end"]))+"("+c+", "+b+")",Blockly.Lua.ORDER_HIGH]};Blockly.Lua.lists.getIndex_=function(a,b,c){return"FIRST"==b?"1":"FROM_END"==b?"#"+a+" + 1 - "+c:"LAST"==b?"#"+a:"RANDOM"==b?"math.random(#"+a+")":c};Blockly.Lua.lists.gensym_counter_=0;Blockly.Lua.lists.gensym_=function(){return"G"+Blockly.Lua.lists.gensym_counter_++};
Blockly.Lua.lists_getIndex=function(a){var b=a.getFieldValue("MODE")||"GET",c=a.getFieldValue("WHERE")||"FROM_START",d=Blockly.Lua.valueToCode(a,"AT",Blockly.Lua.ORDER_ADDITIVE)||"1";a=Blockly.Lua.valueToCode(a,"VALUE",Blockly.Lua.ORDER_HIGH)||"({})";var e=Blockly.Lua.lists.getIndex_,f=Blockly.Lua.lists.gensym_;if("LAST"!=c&&"FROM_END"!=c&&"RANDOM"!=c||a.match(/^\w+$/)){if("GET"==b)return c=a+"["+e(a,c,d)+"]",[c,Blockly.Lua.ORDER_HIGH];c="table.remove("+a+", "+e(a,c,d)+")";return"GET_REMOVE"==b?[c,
Blockly.Lua.ORDER_HIGH]:c+"\n"}if("REMOVE"==b)return b=Blockly.Lua.variableDB_.getDistinctName("tmp_list",Blockly.Variables.NAME_TYPE),c=b+" = "+a+"\ntable.remove("+b+", "+e(b,c,d)+")\n";c=("GET"==b?Blockly.Lua.provideFunction_("list_get_"+c.toLowerCase()+("FROM_END"==c?"_"+f():""),["function "+Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(t)"," return t["+e("t",c,d)+"]","end"]):Blockly.Lua.provideFunction_("list_remove_"+c.toLowerCase()+("FROM_END"==c?"_"+f():""),["function "+Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+
"(t)"," return table.remove(t, "+e("t",c,d)+")","end"]))+"("+a+")";return[c,Blockly.Lua.ORDER_HIGH]};
Blockly.Lua.lists_setIndex=function(a){var b=Blockly.Lua.valueToCode(a,"LIST",Blockly.Lua.ORDER_HIGH)||"({})",c=a.getFieldValue("MODE")||"SET",d=a.getFieldValue("WHERE")||"FROM_START",e=Blockly.Lua.valueToCode(a,"AT",Blockly.Lua.ORDER_ADDITIVE)||"1";a=Blockly.Lua.valueToCode(a,"TO",Blockly.Lua.ORDER_NONE)||"None";var f=Blockly.Lua.lists.getIndex_;if("LAST"!=d&&"FROM_END"!=d&&"RANDOM"!=d||b.match(/^\w+$/))return b="SET"==c?b+"["+f(b,d,e)+"] = "+a:"table.insert("+b+", "+(f(b,d,e)+("LAST"==d?" + 1":
""))+", "+a+")",b+"\n";"RANDOM"==d||"LAST"==d?(c="SET"==c?Blockly.Lua.provideFunction_("list_set_"+d.toLowerCase(),["function "+Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(t, val)"," t["+f("t",d,e)+"] = val","end"]):Blockly.Lua.provideFunction_("list_insert_"+d.toLowerCase(),["function "+Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(t, val)"," table.insert(t, "+f("t",d,e)+("LAST"==d?" + 1":"")+", val)","end"]),b=c+"("+b+", "+a+")\n"):(c="SET"==c?Blockly.Lua.provideFunction_("list_set_from_end",["function "+
Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(t, index, val)"," t[#t + 1 - index] = val","end"]):Blockly.Lua.provideFunction_("list_insert_from_end",["function "+Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(t, index, val)"," table.insert(t, #t + 1 - index, val)","end"]),b=c+"("+b+", "+e+", "+a+")\n");return b};
Blockly.Lua.lists_getSublist=function(a){var b=Blockly.Lua.valueToCode(a,"LIST",Blockly.Lua.ORDER_HIGH)||"({})",c=a.getFieldValue("WHERE1"),d=a.getFieldValue("WHERE2"),e=Blockly.Lua.valueToCode(a,"AT1",Blockly.Lua.ORDER_ADDITIVE)||"1";a=Blockly.Lua.valueToCode(a,"AT2",Blockly.Lua.ORDER_ADDITIVE)||"1";var f=Blockly.Lua.lists.getIndex_;return[Blockly.Lua.provideFunction_("list_sublist_"+Blockly.Lua.lists.gensym_(),["function "+Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(source)"," local t = {}"," local start = "+
f("source",c,e)," local finish = "+f("source",d,a)," for i = start, finish do"," table.insert(t, source[i])"," end"," return t","end"])+"("+b+")",Blockly.Lua.ORDER_HIGH]};
Blockly.Lua.lists_split=function(a){var b=Blockly.Lua.valueToCode(a,"INPUT",Blockly.Lua.ORDER_NONE),c=Blockly.Lua.valueToCode(a,"DELIM",Blockly.Lua.ORDER_NONE)||"''";a=a.getFieldValue("MODE");if("SPLIT"==a)b||(b="''"),a=Blockly.Lua.provideFunction_("list_string_split",["function "+Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(input, delim)"," local t = {}"," local pos = 1"," while true do"," next_delim = string.find(input, delim, pos)"," if next_delim == nil then"," table.insert(t, string.sub(input, pos))",
" break"," else"," table.insert(t, string.sub(input, pos, next_delim-1))"," pos = next_delim + #delim"," end"," end"," return t","end"]);else if("JOIN"==a)b||(b="({})"),a="table.concat";else throw"Unknown mode: "+a;return[a+"("+b+", "+c+")",Blockly.Lua.ORDER_HIGH]};Blockly.Lua.logic={};Blockly.Lua.controls_if=function(a){for(var b=0,c=Blockly.Lua.valueToCode(a,"IF"+b,Blockly.Lua.ORDER_NONE)||"false",d=Blockly.Lua.statementToCode(a,"DO"+b),e="if "+c+" then\n"+d,b=1;b<=a.elseifCount_;b++)c=Blockly.Lua.valueToCode(a,"IF"+b,Blockly.Lua.ORDER_NONE)||"false",d=Blockly.Lua.statementToCode(a,"DO"+b),e+=" elseif "+c+" then\n"+d;a.elseCount_&&(d=Blockly.Lua.statementToCode(a,"ELSE"),e+=" else\n"+d);return e+"end\n"};
Blockly.Lua.logic_compare=function(a){var b={EQ:"==",NEQ:"~=",LT:"<",LTE:"<=",GT:">",GTE:">="}[a.getFieldValue("OP")],c=Blockly.Lua.valueToCode(a,"A",Blockly.Lua.ORDER_RELATIONAL)||"0";a=Blockly.Lua.valueToCode(a,"B",Blockly.Lua.ORDER_RELATIONAL)||"0";return[c+" "+b+" "+a,Blockly.Lua.ORDER_RELATIONAL]};
Blockly.Lua.logic_operation=function(a){var b="AND"==a.getFieldValue("OP")?"and":"or",c="and"==b?Blockly.Lua.ORDER_AND:Blockly.Lua.ORDER_OR,d=Blockly.Lua.valueToCode(a,"A",c);a=Blockly.Lua.valueToCode(a,"B",c);if(d||a){var e="and"==b?"true":"false";d||(d=e);a||(a=e)}else a=d="false";return[d+" "+b+" "+a,c]};Blockly.Lua.logic_negate=function(a){return["not "+(Blockly.Lua.valueToCode(a,"BOOL",Blockly.Lua.ORDER_UNARY)||"true"),Blockly.Lua.ORDER_UNARY]};
Blockly.Lua.logic_boolean=function(a){return["TRUE"==a.getFieldValue("BOOL")?"true":"false",Blockly.Lua.ORDER_ATOMIC]};Blockly.Lua.logic_null=function(a){return["nil",Blockly.Lua.ORDER_ATOMIC]};Blockly.Lua.logic_ternary=function(a){var b=Blockly.Lua.valueToCode(a,"IF",Blockly.Lua.ORDER_AND)||"false",c=Blockly.Lua.valueToCode(a,"THEN",Blockly.Lua.ORDER_AND)||"nil";a=Blockly.Lua.valueToCode(a,"ELSE",Blockly.Lua.ORDER_OR)||"nil";return[b+" and "+c+" or "+a,Blockly.Lua.ORDER_OR]};Blockly.Lua.loops={};Blockly.Lua.CONTINUE_STATEMENT="goto continue\n";Blockly.Lua.addContinueLabel=function(a){return-1<a.indexOf(Blockly.Lua.CONTINUE_STATEMENT)?a+Blockly.Lua.INDENT+"::continue::\n":a};Blockly.Lua.controls_repeat=function(a){var b=parseInt(a.getFieldValue("TIMES"),10);a=Blockly.Lua.statementToCode(a,"DO")||"";a=Blockly.Lua.addContinueLabel(a);return"for "+Blockly.Lua.variableDB_.getDistinctName("count",Blockly.Variables.NAME_TYPE)+" = 1, "+b+" do\n"+a+"end\n"};
Blockly.Lua.controls_repeat_ext=function(a){var b=Blockly.Lua.valueToCode(a,"TIMES",Blockly.Lua.ORDER_NONE)||"0",b=Blockly.isNumber(b)?parseInt(b,10):"math.floor("+b+")";a=Blockly.Lua.statementToCode(a,"DO")||"\n";a=Blockly.Lua.addContinueLabel(a);return"for "+Blockly.Lua.variableDB_.getDistinctName("count",Blockly.Variables.NAME_TYPE)+" = 1, "+b+" do\n"+a+"end\n"};
Blockly.Lua.controls_whileUntil=function(a){var b="UNTIL"==a.getFieldValue("MODE"),c=Blockly.Lua.valueToCode(a,"BOOL",b?Blockly.Lua.ORDER_UNARY:Blockly.Lua.ORDER_NONE)||"false",d=Blockly.Lua.statementToCode(a,"DO")||"\n",d=Blockly.Lua.addLoopTrap(d,a.id),d=Blockly.Lua.addContinueLabel(d);b&&(c="not "+c);return"while "+c+" do\n"+d+"end\n"};
Blockly.Lua.controls_for=function(a){var b=Blockly.Lua.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE),c=Blockly.Lua.valueToCode(a,"FROM",Blockly.Lua.ORDER_NONE)||"0",d=Blockly.Lua.valueToCode(a,"TO",Blockly.Lua.ORDER_NONE)||"0",e=Blockly.Lua.valueToCode(a,"BY",Blockly.Lua.ORDER_NONE)||"1",f=Blockly.Lua.statementToCode(a,"DO")||"\n",f=Blockly.Lua.addLoopTrap(f,a.id),f=Blockly.Lua.addContinueLabel(f);a="";var g;Blockly.isNumber(c)&&Blockly.isNumber(d)&&Blockly.isNumber(e)?(g=
parseFloat(c)<=parseFloat(d),e=Math.abs(parseFloat(e)),g=(g?"":"-")+e):(a="",g=Blockly.Lua.variableDB_.getDistinctName(b+"_inc",Blockly.Variables.NAME_TYPE),a+=g+" = ",a=Blockly.isNumber(e)?a+(Math.abs(e)+"\n"):a+("math.abs("+e+")\n"),a=a+("if ("+c+") > ("+d+") then\n")+(Blockly.Lua.INDENT+g+" = -"+g+"\n"),a+="end\n");a+="for "+b+" = "+c+", "+d+", "+g;return a+=" do\n"+f+"end\n"};
Blockly.Lua.controls_forEach=function(a){var b=Blockly.Lua.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE),c=Blockly.Lua.valueToCode(a,"LIST",Blockly.Lua.ORDER_NONE)||"{}";a=Blockly.Lua.statementToCode(a,"DO")||"\n";a=Blockly.Lua.addContinueLabel(a);return"for _, "+b+" in ipairs("+c+") do \n"+a+"end\n"};
Blockly.Lua.controls_flow_statements=function(a){switch(a.getFieldValue("FLOW")){case "BREAK":return"break\n";case "CONTINUE":return Blockly.Lua.CONTINUE_STATEMENT}throw"Unknown flow statement.";};Blockly.Lua.math={};Blockly.Lua.math_number=function(a){a=parseFloat(a.getFieldValue("NUM"));return[a,0>a?Blockly.Lua.ORDER_UNARY:Blockly.Lua.ORDER_ATOMIC]};
Blockly.Lua.math_arithmetic=function(a){var b={ADD:[" + ",Blockly.Lua.ORDER_ADDITIVE],MINUS:[" - ",Blockly.Lua.ORDER_ADDITIVE],MULTIPLY:[" * ",Blockly.Lua.ORDER_MULTIPLICATIVE],DIVIDE:[" / ",Blockly.Lua.ORDER_MULTIPLICATIVE],POWER:[" ^ ",Blockly.Lua.ORDER_EXPONENTIATION]}[a.getFieldValue("OP")],c=b[0],b=b[1],d=Blockly.Lua.valueToCode(a,"A",b)||"0";a=Blockly.Lua.valueToCode(a,"B",b)||"0";return[d+c+a,b]};
Blockly.Lua.math_single=function(a){var b=a.getFieldValue("OP");if("NEG"==b)return a=Blockly.Lua.valueToCode(a,"NUM",Blockly.Lua.ORDER_UNARY)||"0",["-"+a,Blockly.Lua.ORDER_UNARY];a="SIN"==b||"COS"==b||"TAN"==b?Blockly.Lua.valueToCode(a,"NUM",Blockly.Lua.ORDER_MULTIPLICATIVE)||"0":Blockly.Lua.valueToCode(a,"NUM",Blockly.Lua.ORDER_NONE)||"0";switch(b){case "ABS":b="math.abs("+a+")";break;case "ROOT":b="math.sqrt("+a+")";break;case "LN":b="math.log("+a+")";break;case "LOG10":b="math.log10("+a+")";break;
case "EXP":b="math.exp("+a+")";break;case "POW10":b="math.pow(10,"+a+")";break;case "ROUND":b="math.floor("+a+" + .5)";break;case "ROUNDUP":b="math.ceil("+a+")";break;case "ROUNDDOWN":b="math.floor("+a+")";break;case "SIN":b="math.sin(math.rad("+a+"))";break;case "COS":b="math.cos(math.rad("+a+"))";break;case "TAN":b="math.tan(math.rad("+a+"))";break;case "ASIN":b="math.deg(math.asin("+a+"))";break;case "ACOS":b="math.deg(math.acos("+a+"))";break;case "ATAN":b="math.deg(math.atan("+a+"))";break;default:throw"Unknown math operator: "+
b;}return[b,Blockly.Lua.ORDER_HIGH]};Blockly.Lua.math_constant=function(a){return{PI:["math.pi",Blockly.Lua.ORDER_HIGH],E:["math.exp(1)",Blockly.Lua.ORDER_HIGH],GOLDEN_RATIO:["(1 + math.sqrt(5)) / 2",Blockly.Lua.ORDER_MULTIPLICATIVE],SQRT2:["math.sqrt(2)",Blockly.Lua.ORDER_HIGH],SQRT1_2:["math.sqrt(1 / 2)",Blockly.Lua.ORDER_HIGH],INFINITY:["math.huge",Blockly.Lua.ORDER_HIGH]}[a.getFieldValue("CONSTANT")]};
Blockly.Lua.math_number_property=function(a){var b=Blockly.Lua.valueToCode(a,"NUMBER_TO_CHECK",Blockly.Lua.ORDER_MULTIPLICATIVE)||"0",c=a.getFieldValue("PROPERTY"),d;if("PRIME"==c)return d=Blockly.Lua.provideFunction_("math_isPrime",["function "+Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(n)"," -- https://en.wikipedia.org/wiki/Primality_test#Naive_methods"," if n == 2 or n == 3 then"," return true"," end"," -- False if n is NaN, negative, is 1, or not whole."," -- And false if n is divisible by 2 or 3.",
" if not(n > 1) or n % 1 ~= 0 or n % 2 == 0 or n % 3 == 0 then"," return false"," end"," -- Check all the numbers of form 6k +/- 1, up to sqrt(n)."," for x = 6, math.sqrt(n) + 1.5, 6 do"," if n % (x - 1) == 0 or n % (x + 1) == 0 then"," return false"," end"," end"," return true","end"])+"("+b+")",[d,Blockly.Lua.ORDER_HIGH];switch(c){case "EVEN":d=b+" % 2 == 0";break;case "ODD":d=b+" % 2 == 1";break;case "WHOLE":d=b+" % 1 == 0";break;case "POSITIVE":d=b+" > 0";break;case "NEGATIVE":d=
b+" < 0";break;case "DIVISIBLE_BY":a=Blockly.Lua.valueToCode(a,"DIVISOR",Blockly.Lua.ORDER_MULTIPLICATIVE);if(!a||"0"==a)return["nil",Blockly.Lua.ORDER_ATOMIC];d=b+" % "+a+" == 0"}return[d,Blockly.Lua.ORDER_RELATIONAL]};Blockly.Lua.math_change=function(a){var b=Blockly.Lua.valueToCode(a,"DELTA",Blockly.Lua.ORDER_ADDITIVE)||"0";a=Blockly.Lua.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE);return a+" = "+a+" + "+b+"\n"};Blockly.Lua.math_round=Blockly.Lua.math_single;
Blockly.Lua.math_trig=Blockly.Lua.math_single;
Blockly.Lua.math_on_list=function(a){function b(){return Blockly.Lua.provideFunction_("math_sum",["function "+Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(t)"," local result = 0"," for _, v in ipairs(t) do"," result = result + v"," end"," return result","end"])}var c=a.getFieldValue("OP");a=Blockly.Lua.valueToCode(a,"LIST",Blockly.Lua.ORDER_NONE)||"{}";switch(c){case "SUM":c=b();break;case "MIN":c=Blockly.Lua.provideFunction_("math_min",["function "+Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(t)",
" if #t == 0 then"," return 0"," end"," local result = math.huge"," for _, v in ipairs(t) do"," if v < result then"," result = v"," end"," end"," return result","end"]);break;case "AVERAGE":c=Blockly.Lua.provideFunction_("math_average",["function "+Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(t)"," if #t == 0 then"," return 0"," end"," return "+b()+"(t) / #t","end"]);break;case "MAX":c=Blockly.Lua.provideFunction_("math_max",["function "+Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+
"(t)"," if #t == 0 then"," return 0"," end"," local result = -math.huge"," for _, v in ipairs(t) do"," if v > result then"," result = v"," end"," end"," return result","end"]);break;case "MEDIAN":c=Blockly.Lua.provideFunction_("math_median",["function "+Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(t)"," -- Source: http://lua-users.org/wiki/SimpleStats"," if #t == 0 then"," return 0"," end"," local temp={}"," for _, v in ipairs(t) do",' if type(v) == "number" then'," table.insert(temp, v)",
" end"," end"," table.sort(temp)"," if #temp % 2 == 0 then"," return (temp[#temp/2] + temp[(#temp/2)+1]) / 2"," else"," return temp[math.ceil(#temp/2)]"," end","end"]);break;case "MODE":c=Blockly.Lua.provideFunction_("math_modes",["function "+Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(t)"," -- Source: http://lua-users.org/wiki/SimpleStats"," local counts={}"," for _, v in ipairs(t) do"," if counts[v] == nil then"," counts[v] = 1"," else"," counts[v] = counts[v] + 1",
" end"," end"," local biggestCount = 0"," for _, v in pairs(counts) do"," if v > biggestCount then"," biggestCount = v"," end"," end"," local temp={}"," for k, v in pairs(counts) do"," if v == biggestCount then"," table.insert(temp, k)"," end"," end"," return temp","end"]);break;case "STD_DEV":c=Blockly.Lua.provideFunction_("math_standard_deviation",["function "+Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(t)"," local m"," local vm"," local total = 0"," local count = 0",
" local result"," m = #t == 0 and 0 or "+b()+"(t) / #t"," for _, v in ipairs(t) do"," if type(v) == 'number' then"," vm = v - m"," total = total + (vm * vm)"," count = count + 1"," end"," end"," result = math.sqrt(total / (count-1))"," return result","end"]);break;case "RANDOM":c=Blockly.Lua.provideFunction_("math_random_list",["function "+Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(t)"," if #t == 0 then"," return nil"," end"," return t[math.random(#t)]","end"]);break;
default:throw"Unknown operator: "+c;}return[c+"("+a+")",Blockly.Lua.ORDER_HIGH]};Blockly.Lua.math_modulo=function(a){var b=Blockly.Lua.valueToCode(a,"DIVIDEND",Blockly.Lua.ORDER_MULTIPLICATIVE)||"0";a=Blockly.Lua.valueToCode(a,"DIVISOR",Blockly.Lua.ORDER_MULTIPLICATIVE)||"0";return[b+" % "+a,Blockly.Lua.ORDER_MULTIPLICATIVE]};
Blockly.Lua.math_constrain=function(a){var b=Blockly.Lua.valueToCode(a,"VALUE",Blockly.Lua.ORDER_NONE)||"0",c=Blockly.Lua.valueToCode(a,"LOW",Blockly.Lua.ORDER_NONE)||"-math.huge";a=Blockly.Lua.valueToCode(a,"HIGH",Blockly.Lua.ORDER_NONE)||"math.huge";return["math.min(math.max("+b+", "+c+"), "+a+")",Blockly.Lua.ORDER_HIGH]};
Blockly.Lua.math_random_int=function(a){var b=Blockly.Lua.valueToCode(a,"FROM",Blockly.Lua.ORDER_NONE)||"0";a=Blockly.Lua.valueToCode(a,"TO",Blockly.Lua.ORDER_NONE)||"0";return["math.random("+b+", "+a+")",Blockly.Lua.ORDER_HIGH]};Blockly.Lua.math_random_float=function(a){return["math.random()",Blockly.Lua.ORDER_HIGH]};Blockly.Lua.procedures={};
Blockly.Lua.procedures_defreturn=function(a){var b=Blockly.Lua.variableDB_.getName(a.getFieldValue("NAME"),Blockly.Procedures.NAME_TYPE),c=Blockly.Lua.statementToCode(a,"STACK");Blockly.Lua.STATEMENT_PREFIX&&(c=Blockly.Lua.prefixLines(Blockly.Lua.STATEMENT_PREFIX.replace(/%1/g,"'"+a.id+"'"),Blockly.Lua.INDENT)+c);Blockly.Lua.INFINITE_LOOP_TRAP&&(c=Blockly.Lua.INFINITE_LOOP_TRAP.replace(/%1/g,"'"+a.id+"'")+c);var d=Blockly.Lua.valueToCode(a,"RETURN",Blockly.Lua.ORDER_NONE)||"";d?d=" return "+d+"\n":
c||(c="");for(var e=[],f=0;f<a.arguments_.length;f++)e[f]=Blockly.Lua.variableDB_.getName(a.arguments_[f],Blockly.Variables.NAME_TYPE);c="function "+b+"("+e.join(", ")+")\n"+c+d+"end\n";c=Blockly.Lua.scrub_(a,c);Blockly.Lua.definitions_[b]=c;return null};Blockly.Lua.procedures_defnoreturn=Blockly.Lua.procedures_defreturn;
Blockly.Lua.procedures_callreturn=function(a){for(var b=Blockly.Lua.variableDB_.getName(a.getFieldValue("NAME"),Blockly.Procedures.NAME_TYPE),c=[],d=0;d<a.arguments_.length;d++)c[d]=Blockly.Lua.valueToCode(a,"ARG"+d,Blockly.Lua.ORDER_NONE)||"nil";return[b+"("+c.join(", ")+")",Blockly.Lua.ORDER_HIGH]};
Blockly.Lua.procedures_callnoreturn=function(a){for(var b=Blockly.Lua.variableDB_.getName(a.getFieldValue("NAME"),Blockly.Procedures.NAME_TYPE),c=[],d=0;d<a.arguments_.length;d++)c[d]=Blockly.Lua.valueToCode(a,"ARG"+d,Blockly.Lua.ORDER_NONE)||"nil";return b+"("+c.join(", ")+")\n"};
Blockly.Lua.procedures_ifreturn=function(a){var b="if "+(Blockly.Lua.valueToCode(a,"CONDITION",Blockly.Lua.ORDER_NONE)||"false")+" then\n";a.hasReturnValue_?(a=Blockly.Lua.valueToCode(a,"VALUE",Blockly.Lua.ORDER_NONE)||"nil",b+=" return "+a+"\n"):b+=" return\n";return b+"end\n"};Blockly.Lua.texts={};Blockly.Lua.text=function(a){return[Blockly.Lua.quote_(a.getFieldValue("TEXT")),Blockly.Lua.ORDER_ATOMIC]};
Blockly.Lua.text_join=function(a){if(0==a.itemCount_)return["''",Blockly.Lua.ORDER_ATOMIC];if(1==a.itemCount_){var b=Blockly.Lua.valueToCode(a,"ADD0",Blockly.Lua.ORDER_NONE)||"''";return[b,Blockly.Lua.ORDER_HIGH]}if(2==a.itemCount_)return b=Blockly.Lua.valueToCode(a,"ADD0",Blockly.Lua.ORDER_NONE)||"''",a=Blockly.Lua.valueToCode(a,"ADD1",Blockly.Lua.ORDER_NONE)||"''",[b+" .. "+a,Blockly.Lua.ORDER_UNARY];for(var b=[],c=0;c<a.itemCount_;c++)b[c]=Blockly.Lua.valueToCode(a,"ADD"+c,Blockly.Lua.ORDER_NONE)||
"''";b="table.concat({"+b.join(", ")+"})";return[b,Blockly.Lua.ORDER_HIGH]};Blockly.Lua.text_append=function(a){var b=Blockly.Lua.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE);a=Blockly.Lua.valueToCode(a,"TEXT",Blockly.Lua.ORDER_NONE)||"''";return b+" = "+b+" .. "+a+"\n"};Blockly.Lua.text_length=function(a){return["#"+(Blockly.Lua.valueToCode(a,"VALUE",Blockly.Lua.ORDER_HIGH)||"''"),Blockly.Lua.ORDER_HIGH]};
Blockly.Lua.text_isEmpty=function(a){return["#"+(Blockly.Lua.valueToCode(a,"VALUE",Blockly.Lua.ORDER_HIGH)||"''")+" == 0",Blockly.Lua.ORDER_RELATIONAL]};
Blockly.Lua.text_indexOf=function(a){a.getFieldValue("END");var b=Blockly.Lua.valueToCode(a,"FIND",Blockly.Lua.ORDER_NONE)||"''",c=Blockly.Lua.valueToCode(a,"VALUE",Blockly.Lua.ORDER_NONE)||"''";return[("FIRST"==a.getFieldValue("END")?Blockly.Lua.provideFunction_("firstIndexOf",["function "+Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(str, substr) "," local i = string.find(str, substr, 1, true)"," if i == nil then"," return 0"," else"," return i"," end","end"]):Blockly.Lua.provideFunction_("lastIndexOf",
["function "+Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(str, substr)"," local i = string.find(string.reverse(str), string.reverse(substr), 1, true)"," if i then"," return #str + 2 - i - #substr"," end"," return 0","end"]))+"("+c+", "+b+")",Blockly.Lua.ORDER_HIGH]};
Blockly.Lua.text_charAt=function(a){var b=a.getFieldValue("WHERE")||"FROM_START",c=Blockly.Lua.valueToCode(a,"AT",Blockly.Lua.ORDER_UNARY)||"1";a=Blockly.Lua.valueToCode(a,"VALUE",Blockly.Lua.ORDER_NONE)||"''";if("RANDOM"==b)b=Blockly.Lua.provideFunction_("text_random_letter",["function "+Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(str)"," local index = math.random(string.len(str))"," return string.sub(str, index, index)","end"]),a=b+"("+a+")";else{if("FIRST"==b)c="1";else if("LAST"==b)c="-1";else if("FROM_START"!=
b)if("FROM_END"==b)c="-"+c;else throw"Unhandled option (text_charAt).";c.match(/^-?\w*$/)?a="string.sub("+a+", "+c+", "+c+")":(b=Blockly.Lua.provideFunction_("text_char_at",["function "+Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(str, index)"," return string.sub(str, index, index)","end"]),a=b+"("+a+", "+c+")")}return[a,Blockly.Lua.ORDER_HIGH]};
Blockly.Lua.text_getSubstring=function(a){var b=Blockly.Lua.valueToCode(a,"STRING",Blockly.Lua.ORDER_NONE)||"''",c=a.getFieldValue("WHERE1"),d=Blockly.Lua.valueToCode(a,"AT1",Blockly.Lua.ORDER_UNARY)||"1";if("FIRST"==c)c=1;else if("FROM_START"==c)c=d;else if("FROM_END"==c)c="-"+d;else throw"Unhandled option (text_getSubstring)";d=a.getFieldValue("WHERE2");a=Blockly.Lua.valueToCode(a,"AT2",Blockly.Lua.ORDER_UNARY)||"1";if("LAST"==d)a=-1;else if("FROM_START"!=d)if("FROM_END"==d)a="-"+a;else throw"Unhandled option (text_getSubstring)";
return["string.sub("+b+", "+c+", "+a+")",Blockly.Lua.ORDER_HIGH]};
Blockly.Lua.text_changeCase=function(a){var b=a.getFieldValue("CASE");a=Blockly.Lua.valueToCode(a,"TEXT",Blockly.Lua.ORDER_NONE)||"''";if("UPPERCASE"==b)var c="string.upper";else"LOWERCASE"==b?c="string.lower":"TITLECASE"==b&&(c=Blockly.Lua.provideFunction_("text_titlecase",["function "+Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(str)"," local buf = {}"," local inWord = false"," for i = 1, #str do"," local c = string.sub(str, i, i)"," if inWord then"," table.insert(buf, string.lower(c))",
' if string.find(c, "%s") then'," inWord = false"," end"," else"," table.insert(buf, string.upper(c))"," inWord = true"," end"," end"," return table.concat(buf)","end"]));return[c+"("+a+")",Blockly.Lua.ORDER_HIGH]};Blockly.Lua.text_trim=function(a){var b={LEFT:"^%s*(,-)",RIGHT:"(.-)%s*$",BOTH:"^%s*(.-)%s*$"}[a.getFieldValue("MODE")];return["string.gsub("+(Blockly.Lua.valueToCode(a,"TEXT",Blockly.Lua.ORDER_NONE)||"''")+', "'+b+'", "%1")',Blockly.Lua.ORDER_HIGH]};
Blockly.Lua.text_print=function(a){return"print("+(Blockly.Lua.valueToCode(a,"TEXT",Blockly.Lua.ORDER_NONE)||"''")+")\n"};
Blockly.Lua.text_prompt_ext=function(a){var b=a.getField("TEXT")?Blockly.Lua.quote_(a.getFieldValue("TEXT")):Blockly.Lua.valueToCode(a,"TEXT",Blockly.Lua.ORDER_NONE)||"''",b=Blockly.Lua.provideFunction_("text_prompt",["function "+Blockly.Lua.FUNCTION_NAME_PLACEHOLDER_+"(msg)"," io.write(msg)"," io.flush()"," return io.read()","end"])+"("+b+")";"NUMBER"==a.getFieldValue("TYPE")&&(b="tonumber("+b+", 10)");return[b,Blockly.Lua.ORDER_HIGH]};Blockly.Lua.text_prompt=Blockly.Lua.text_prompt_ext;Blockly.Lua.variables={};Blockly.Lua.variables_get=function(a){return[Blockly.Lua.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE),Blockly.Lua.ORDER_ATOMIC]};Blockly.Lua.variables_set=function(a){var b=Blockly.Lua.valueToCode(a,"VALUE",Blockly.Lua.ORDER_NONE)||"0";return Blockly.Lua.variableDB_.getName(a.getFieldValue("VAR"),Blockly.Variables.NAME_TYPE)+" = "+b+"\n"};
+2
View File
@@ -289,6 +289,7 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "اسم الإدخال:";
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "Add an input to the function."; // untranslated
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "المدخلات";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "Add, remove, or reorder inputs to this function."; // untranslated
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "ازل التعليق";
Blockly.Msg.RENAME_VARIABLE = "إعادة تسمية المتغير...";
Blockly.Msg.RENAME_VARIABLE_TITLE = "إعادة تسمية كافة المتغيرات '%1' إلى:";
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "إزالة الفراغات من الجا
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "إزالة الفراغات من الجانب الأيمن من";
Blockly.Msg.TEXT_TRIM_TOOLTIP = "يرجع نسخة من النص مع حذف من أحد أو كلا الفراغات من أطرافه.";
Blockly.Msg.TODAY = "اليوم";
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "البند";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "انشئ 'التعيين %1'";
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get"; // untranslated
+2
View File
@@ -289,6 +289,7 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "Giriş adı:";
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "Add an input to the function."; // untranslated
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "girişlər";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "Add, remove, or reorder inputs to this function."; // untranslated
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "Şərhi sil";
Blockly.Msg.RENAME_VARIABLE = "Dəyişənin adını dəyiş...";
Blockly.Msg.RENAME_VARIABLE_TITLE = "Bütün '%1' dəyişənlərinin adını buna dəyiş:";
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "Boşluqlari yalnız sol tərəfdən pozun
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "Boşluqları yalnız sağ tərəfdən pozun";
Blockly.Msg.TEXT_TRIM_TOOLTIP = "Mətnin hər iki və ya yalnız bir tərəfdən olan boşluqları pozulmuş surətini qaytarın.";
Blockly.Msg.TODAY = "Bugün";
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "element";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "'%1 - i təyin et' - i yarat";
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get"; // untranslated
+2
View File
@@ -289,6 +289,7 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "инеү исеме:";
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "Add an input to the function."; // untranslated
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "инеү";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "Add, remove, or reorder inputs to this function."; // untranslated
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "Аңлатмаларҙы юйырға";
Blockly.Msg.RENAME_VARIABLE = "Үҙгәреүсәндең исемен алмаштырырға...";
Blockly.Msg.RENAME_VARIABLE_TITLE = "Бөтә '%1' үҙгәреүсәндәрҙең исемен ошолай алмаштырырға:";
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "trim spaces from left side of"; // untra
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "trim spaces from right side of"; // untranslated
Blockly.Msg.TEXT_TRIM_TOOLTIP = "Return a copy of the text with spaces removed from one or both ends."; // untranslated
Blockly.Msg.TODAY = "Бөгөн";
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "элемент";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "Create 'set %1'"; // untranslated
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get"; // untranslated
+2
View File
@@ -289,6 +289,7 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "نام ورودی:";
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "اضافه کردن ورودی به تابع.";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "ورودی‌ها";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "افزودن، حذف یا دوباره مرتب‌کردن ورودی این تابع.";
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "حذف نظر";
Blockly.Msg.RENAME_VARIABLE = "تغییر نام متغیر...";
Blockly.Msg.RENAME_VARIABLE_TITLE = "تغییر نام همهٔ متغیرهای «%1» به:";
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "تراشیدن فاصله‌ها از ط
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "تراشیدن فاصله‌ها از طرف چپ";
Blockly.Msg.TEXT_TRIM_TOOLTIP = "کپی از متن با فاصله‌های حذف‌شده از یک یا هر دو پایان باز می‌گرداند.";
Blockly.Msg.TODAY = "Today"; // untranslated
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "مورد";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "درست‌کردن «تنظیم %1»";
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get"; // untranslated
+2
View File
@@ -289,6 +289,7 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "назва парамэтру:";
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "Дадаць уваходныя парамэтры ў функцыю.";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "парамэтры";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "Дадаць, выдаліць ці запісаць чаргу ўваходных парамэтраў для гэтай функцыі.";
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "Выдаліць камэнтар";
Blockly.Msg.RENAME_VARIABLE = "Перайменаваць зьменную…";
Blockly.Msg.RENAME_VARIABLE_TITLE = "Перайменаваць усе назвы зьменных '%1' на:";
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "абрэзаць прабелы зь ле
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "абрэзаць прабелы з правага боку";
Blockly.Msg.TEXT_TRIM_TOOLTIP = "Вяртае копію тэксту з прабеламі, выдаленымі ад аднаго ці абодвух бакоў.";
Blockly.Msg.TODAY = "Сёньня";
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "аб’ект";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "Стварыць блёк «усталяваць %1»";
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get"; // untranslated
+2
View File
@@ -289,6 +289,7 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "име на параметър";
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "Добавяне на параметър към функцията.";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "вход";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "Добави, премахни или пренареди входните параметри за тази функция.";
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "Премахни коментар";
Blockly.Msg.RENAME_VARIABLE = "Преименувай променливата...";
Blockly.Msg.RENAME_VARIABLE_TITLE = "Преименувай всички '%1' променливи на:";
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "премахни интервалите
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "премахни интервалите отдясно";
Blockly.Msg.TEXT_TRIM_TOOLTIP = "Върни копие на текста с пемахнати интервали от диния или двата края.";
Blockly.Msg.TODAY = "Днес";
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "елемент";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "Създай \"промени стойността на %1\"";
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get"; // untranslated
+2
View File
@@ -289,6 +289,7 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "ইনপুটের নাম:";
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "ক্রিয়াতে একটি ইনপুট যোগ করুন।";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "inputs"; // untranslated
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "Add, remove, or reorder inputs to this function."; // untranslated
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "মন্তব্য সরাও";
Blockly.Msg.RENAME_VARIABLE = "চলকের নাম পরিবর্তন...";
Blockly.Msg.RENAME_VARIABLE_TITLE = "Rename all '%1' variables to:"; // untranslated
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "বামপাশ থেকে খাল
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "ডানপাশ থেকে খালি অংশ ছাটাই";
Blockly.Msg.TEXT_TRIM_TOOLTIP = "Return a copy of the text with spaces removed from one or both ends."; // untranslated
Blockly.Msg.TODAY = "আজ";
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "পদ";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "Create 'set %1'"; // untranslated
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get"; // untranslated
+4 -2
View File
@@ -10,7 +10,7 @@ Blockly.Msg.ADD_COMMENT = "Ouzhpennañ un evezhiadenn";
Blockly.Msg.AUTH = "Roit aotre, mar plij, d'an arload-mañ evit gallout saveteiñ ho labour ha reiñ aotre dezhañ da rannañ ho labour ganimp.";
Blockly.Msg.CHANGE_VALUE_TITLE = "Kemmañ an dalvoudenn :";
Blockly.Msg.CHAT = "Flapañ gant ho kenlabourer en ur skrivañ er voest-se !";
Blockly.Msg.CLEAN_UP = "Clean up Blocks"; // untranslated
Blockly.Msg.CLEAN_UP = "Naetaat ar bloc'hoù";
Blockly.Msg.COLLAPSE_ALL = "Bihanaat ar bloc'hoù";
Blockly.Msg.COLLAPSE_BLOCK = "Bihanaat ar bloc'h";
Blockly.Msg.COLOUR_BLEND_COLOUR1 = "liv 1";
@@ -271,7 +271,7 @@ Blockly.Msg.PROCEDURES_CALLRETURN_HELPURL = "https://en.wikipedia.org/wiki/Proce
Blockly.Msg.PROCEDURES_CALLRETURN_TOOLTIP = "Seveniñ an arc'hwel '%1' termenet gant an implijer hag implijout e zisoc'h.";
Blockly.Msg.PROCEDURES_CALL_BEFORE_PARAMS = "gant :";
Blockly.Msg.PROCEDURES_CREATE_DO = "Krouiñ '%1'";
Blockly.Msg.PROCEDURES_DEFNORETURN_COMMENT = "Describe this function..."; // untranslated
Blockly.Msg.PROCEDURES_DEFNORETURN_COMMENT = "Deskrivañ an arc'hwel-mañ...";
Blockly.Msg.PROCEDURES_DEFNORETURN_DO = ""; // untranslated
Blockly.Msg.PROCEDURES_DEFNORETURN_HELPURL = "https://en.wikipedia.org/wiki/Procedure_%28computer_science%29"; // untranslated
Blockly.Msg.PROCEDURES_DEFNORETURN_PROCEDURE = "ober un dra bennak";
@@ -289,6 +289,7 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "Anv ar moned";
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "Ouzhpennañ ur moned d'an arc'hwel.";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "Monedoù";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "Ouzhpennañ, lemel, pe adkempenn monedoù an arc'hwel-mañ.";
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "Lemel an evezhiadenn kuit";
Blockly.Msg.RENAME_VARIABLE = "Adenvel an argemmenn...";
Blockly.Msg.RENAME_VARIABLE_TITLE = "Adenvel an holl argemmennoù '%1' e :";
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "Lemel an esaouennoù eus an tu kleiz";
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "Lemel an esaouennoù eus an tu dehou";
Blockly.Msg.TEXT_TRIM_TOOLTIP = "Distreiñ un eilenn eus an destenn gant an esaouennoù lamet eus un tu pe eus an daou du";
Blockly.Msg.TODAY = "Hiziv";
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "elfenn";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "Krouiñ 'termenañ %1'";
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get"; // untranslated
+2
View File
@@ -289,6 +289,7 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "nom d'entrada:";
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "Afegir una entrada per la funció.";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "entrades";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "Afegir, eliminar o canviar l'ordre de les entrades per aquesta funció.";
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "Elimina el comentari";
Blockly.Msg.RENAME_VARIABLE = "Reanomena variable...";
Blockly.Msg.RENAME_VARIABLE_TITLE = "Reanomena totes les variables '%1' a:";
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "retalla espais de l'esquerra de";
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "retalla espais de la dreta de";
Blockly.Msg.TEXT_TRIM_TOOLTIP = "Retorna una còpia del text on s'han esborrat els espais d'un o dels dos extrems.";
Blockly.Msg.TODAY = "Today"; // untranslated
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "element";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "Crea 'modifica %1'";
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get"; // untranslated
+5 -3
View File
@@ -172,7 +172,7 @@ Blockly.Msg.LOGIC_OPERATION_OR = "nebo";
Blockly.Msg.LOGIC_OPERATION_TOOLTIP_AND = "Vrátí hodnotu pravda, pokud oba dva vstupy jsou pravdivé.";
Blockly.Msg.LOGIC_OPERATION_TOOLTIP_OR = "Vrátí hodnotu pravda, pokud alespoň jeden ze vstupů má hodnotu pravda.";
Blockly.Msg.LOGIC_TERNARY_CONDITION = "test";
Blockly.Msg.LOGIC_TERNARY_HELPURL = "https://en.wikipedia.org/wiki/%3F:"; // untranslated
Blockly.Msg.LOGIC_TERNARY_HELPURL = "https://cs.wikipedia.org/wiki/Ternární operátor (programování)";
Blockly.Msg.LOGIC_TERNARY_IF_FALSE = "pokud nepravda";
Blockly.Msg.LOGIC_TERNARY_IF_TRUE = "pokud pravda";
Blockly.Msg.LOGIC_TERNARY_TOOLTIP = "Zkontroluje podmínku v \"testu\". Když je podmínka pravda, vrátí hodnotu \"pokud pravda\"; v opačném případě vrátí hodnotu \"pokud nepravda\".";
@@ -273,11 +273,11 @@ Blockly.Msg.PROCEDURES_CALL_BEFORE_PARAMS = "s:";
Blockly.Msg.PROCEDURES_CREATE_DO = "Vytvořit '%1'";
Blockly.Msg.PROCEDURES_DEFNORETURN_COMMENT = "Popište tuto funkci...";
Blockly.Msg.PROCEDURES_DEFNORETURN_DO = ""; // untranslated
Blockly.Msg.PROCEDURES_DEFNORETURN_HELPURL = "https://en.wikipedia.org/wiki/Procedure_%28computer_science%29"; // untranslated
Blockly.Msg.PROCEDURES_DEFNORETURN_HELPURL = "https://cs.wikipedia.org/w/index.php?title=Funkce_(programování)";
Blockly.Msg.PROCEDURES_DEFNORETURN_PROCEDURE = "proveď něco";
Blockly.Msg.PROCEDURES_DEFNORETURN_TITLE = "k provedení";
Blockly.Msg.PROCEDURES_DEFNORETURN_TOOLTIP = "Vytvořit funkci bez výstupu.";
Blockly.Msg.PROCEDURES_DEFRETURN_HELPURL = "https://en.wikipedia.org/wiki/Procedure_%28computer_science%29"; // untranslated
Blockly.Msg.PROCEDURES_DEFRETURN_HELPURL = "https://cs.wikipedia.org/w/index.php?title=Funkce_(programování)";
Blockly.Msg.PROCEDURES_DEFRETURN_RETURN = "navrátit";
Blockly.Msg.PROCEDURES_DEFRETURN_TOOLTIP = "Vytvořit funkci s výstupem.";
Blockly.Msg.PROCEDURES_DEF_DUPLICATE_WARNING = "Upozornění: Tato funkce má duplicitní parametry.";
@@ -289,6 +289,7 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "vstupní jméno:";
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "Přidat vstupy do funkce.";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "vstupy";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "Přidat, odebrat nebo změnit pořadí vstupů této funkce.";
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "Odstranit komentář";
Blockly.Msg.RENAME_VARIABLE = "Přejmenovat proměnnou...";
Blockly.Msg.RENAME_VARIABLE_TITLE = "Přejmenuj všech '%1' proměnných na:";
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "odstranit mezery z levé strany";
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "odstranit mezery z pravé strany";
Blockly.Msg.TEXT_TRIM_TOOLTIP = "Vrátí kopii textu s odstraněnými mezerami z jednoho nebo obou konců.";
Blockly.Msg.TODAY = "Dnes";
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "položka";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "Vytvořit \"nastavit %1\"";
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get"; // untranslated
+2
View File
@@ -289,6 +289,7 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "parameternavn:";
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "Tilføj en parameter til funktionen.";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "parametre";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "Tilføje, fjerne eller ændre rækkefølgen af parametre til denne funktion.";
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "Fjern kommentar";
Blockly.Msg.RENAME_VARIABLE = "Omdøb variabel...";
Blockly.Msg.RENAME_VARIABLE_TITLE = "Omdøb alle '%1' variabler til:";
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "fjern mellemrum fra venstre side af";
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "fjern mellemrum fra højre side af";
Blockly.Msg.TEXT_TRIM_TOOLTIP = "Returner en kopi af teksten med mellemrum fjernet fra den ene eller begge sider.";
Blockly.Msg.TODAY = "I dag";
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "element";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "Opret 'sæt %1'";
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get"; // untranslated
+2
View File
@@ -289,6 +289,7 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "Variable:";
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "Eine Eingabe zur Funktion hinzufügen.";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "Parameter";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "Die Eingaben zu dieser Funktion hinzufügen, entfernen oder neu anordnen.";
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "Kommentar entfernen";
Blockly.Msg.RENAME_VARIABLE = "Variable umbenennen...";
Blockly.Msg.RENAME_VARIABLE_TITLE = "Alle \"%1\" Variablen umbenennen in:";
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "entferne Leerzeichen vom Anfang (links)";
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "entferne Leerzeichen vom Ende (rechts)";
Blockly.Msg.TEXT_TRIM_TOOLTIP = "Entfernt Leerzeichen vom Anfang und / oder Ende eines Textes.";
Blockly.Msg.TODAY = "Heute";
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "Element";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "Erzeuge \"Schreibe %1\"";
Blockly.Msg.VARIABLES_GET_HELPURL = "https://de.wikipedia.org/wiki/Variable_%28Programmierung%29";
+2
View File
@@ -289,6 +289,7 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "όνομα εισόδου:";
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "Πρόσθεσε μια είσοδος στη συνάρτηση";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "είσοδοι";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "Προσθέτει, αφαιρεί ή αναδιατάσσει εισόδους σε αυτήν τη λειτουργία";
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "Αφαίρεσε Το Σχόλιο";
Blockly.Msg.RENAME_VARIABLE = "Μετονόμασε τη μεταβλητή...";
Blockly.Msg.RENAME_VARIABLE_TITLE = "Μετονόμασε όλες τις μεταβλητές «%1» σε:";
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "περίκοψε τα κενά από τ
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "περίκοψε τα κενά από την δεξιά πλευρά του";
Blockly.Msg.TEXT_TRIM_TOOLTIP = "Επιστρέφει ένα αντίγραφο του κειμένου με αφαιρεμένα τα κενά από το ένα ή και τα δύο άκρα.";
Blockly.Msg.TODAY = "Σήμερα";
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "αντικείμενο";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "Δημιούργησε «όρισε %1»";
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get"; // untranslated
+2
View File
@@ -289,6 +289,7 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "input name:";
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "Add an input to the function.";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "inputs";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "Add, remove, or reorder inputs to this function.";
Blockly.Msg.REDO = "Redo";
Blockly.Msg.REMOVE_COMMENT = "Remove Comment";
Blockly.Msg.RENAME_VARIABLE = "Rename variable...";
Blockly.Msg.RENAME_VARIABLE_TITLE = "Rename all '%1' variables to:";
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "trim spaces from left side of";
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "trim spaces from right side of";
Blockly.Msg.TEXT_TRIM_TOOLTIP = "Return a copy of the text with spaces removed from one or both ends.";
Blockly.Msg.TODAY = "Today";
Blockly.Msg.UNDO = "Undo";
Blockly.Msg.VARIABLES_DEFAULT_NAME = "item";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "Create 'set %1'";
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get";
+2
View File
@@ -289,6 +289,7 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "nombre de entrada:";
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "Añadir una entrada a la función.";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "entradas";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "Añadir, eliminar o reordenar entradas para esta función.";
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "Eliminar comentario";
Blockly.Msg.RENAME_VARIABLE = "Renombrar la variable…";
Blockly.Msg.RENAME_VARIABLE_TITLE = "Renombrar todas las variables «%1» a:";
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "quitar espacios iniciales de";
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "quitar espacios finales de";
Blockly.Msg.TEXT_TRIM_TOOLTIP = "Devuelve una copia del texto sin los espacios de uno o ambos extremos.";
Blockly.Msg.TODAY = "Hoy";
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "elemento";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "Crear 'establecer %1'";
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get"; // untranslated
+2
View File
@@ -289,6 +289,7 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "نام ورودی:";
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "اضافه کردن ورودی به تابع.";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "ورودی‌ها";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "افزودن، حذف یا دوباره مرتب‌کردن ورودی این تابع.";
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "حذف نظر";
Blockly.Msg.RENAME_VARIABLE = "تغییر نام متغیر...";
Blockly.Msg.RENAME_VARIABLE_TITLE = "تغییر نام همهٔ متغیرهای «%1» به:";
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "تراشیدن فاصله‌ها از ط
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "تراشیدن فاصله‌ها از طرف چپ";
Blockly.Msg.TEXT_TRIM_TOOLTIP = "کپی از متن با فاصله‌های حذف‌شده از یک یا هر دو پایان باز می‌گرداند.";
Blockly.Msg.TODAY = "امروز";
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "مورد";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "درست‌کردن «تنظیم %1»";
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get"; // untranslated
+2
View File
@@ -289,6 +289,7 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "syötteen nimi:";
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "Lisää sisääntulon funktioon.";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "syötteet";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "Lisää, poista tai järjestele uudelleen tämän toiminnon tulot.";
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "Poista kommentti";
Blockly.Msg.RENAME_VARIABLE = "Nimeä uudelleen muuttuja...";
Blockly.Msg.RENAME_VARIABLE_TITLE = "Nimeä uudelleen kaikki '%1' muuttujaa:";
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "poistaa välilyönnit vasemmalta puolelta
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "poistaa välilyönnit oikealta puolelta";
Blockly.Msg.TEXT_TRIM_TOOLTIP = "Palauttaa kopion tekstistä siten, että välilyönnit on poistettu yhdestä tai molemmista päistä.";
Blockly.Msg.TODAY = "Tänään";
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "kohde";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "Luo 'aseta %1'";
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get"; // untranslated
+12 -10
View File
@@ -9,7 +9,7 @@ goog.require('Blockly.Msg');
Blockly.Msg.ADD_COMMENT = "Ajouter un commentaire";
Blockly.Msg.AUTH = "Veuillez autoriser cette application à permettre la sauvegarde de votre travail et à lautoriser à la partager.";
Blockly.Msg.CHANGE_VALUE_TITLE = "Modifier la valeur :";
Blockly.Msg.CHAT = "Discuter avec votre collaborateur en tapant dans cette zone !";
Blockly.Msg.CHAT = "Discutez avec votre collaborateur en tapant dans cette zone !";
Blockly.Msg.CLEAN_UP = "Nettoyer les blocs";
Blockly.Msg.COLLAPSE_ALL = "Réduire les blocs";
Blockly.Msg.COLLAPSE_BLOCK = "Réduire le bloc";
@@ -29,19 +29,19 @@ Blockly.Msg.COLOUR_RGB_GREEN = "vert";
Blockly.Msg.COLOUR_RGB_HELPURL = "http://www.december.com/html/spec/colorper.html";
Blockly.Msg.COLOUR_RGB_RED = "rouge";
Blockly.Msg.COLOUR_RGB_TITLE = "colorer avec";
Blockly.Msg.COLOUR_RGB_TOOLTIP = "Créer une couleur avec la quantité spécifiée de rouge, vert et bleu. Ces valeurs doivent être comprises entre 0 et 100.";
Blockly.Msg.COLOUR_RGB_TOOLTIP = "Créer une couleur avec la quantité spécifiée de rouge, vert et bleu. Les valeurs doivent être comprises entre 0 et 100.";
Blockly.Msg.CONTROLS_FLOW_STATEMENTS_HELPURL = "https://github.com/google/blockly/wiki/Loops#loop-termination-blocks"; // untranslated
Blockly.Msg.CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK = "sortir de la boucle";
Blockly.Msg.CONTROLS_FLOW_STATEMENTS_OPERATOR_CONTINUE = "continuer avec la prochaine itération de la boucle";
Blockly.Msg.CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK = "quitter la boucle";
Blockly.Msg.CONTROLS_FLOW_STATEMENTS_OPERATOR_CONTINUE = "passer à litération de boucle suivante";
Blockly.Msg.CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK = "Sortir de la boucle englobante.";
Blockly.Msg.CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE = "Sauter le reste de cette boucle, et poursuivre avec litération suivante.";
Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING = "Attention : Ce bloc ne devrait être utilisé que dans une boucle.";
Blockly.Msg.CONTROLS_FOREACH_HELPURL = "https://github.com/google/blockly/wiki/Loops#for-each"; // untranslated
Blockly.Msg.CONTROLS_FOREACH_TITLE = "pour chaque élément %1 dans la liste %2";
Blockly.Msg.CONTROLS_FOREACH_TOOLTIP = "Pour chaque élément dans une liste, donner la valeur de l’élément à la variable '%1', puis exécuter certains ordres.";
Blockly.Msg.CONTROLS_FOREACH_TOOLTIP = "Pour chaque élément dune liste, assigner la valeur de l’élément à la variable '%1', puis exécuter des instructions.";
Blockly.Msg.CONTROLS_FOR_HELPURL = "https://github.com/google/blockly/wiki/Loops#count-with"; // untranslated
Blockly.Msg.CONTROLS_FOR_TITLE = "compter avec %1 de %2 à %3 par %4";
Blockly.Msg.CONTROLS_FOR_TOOLTIP = "Faire en sorte que la variable « %1 » prenne ses valeurs depuis le nombre de début jusquau nombre de fin, en sincrémentant de lintervalle spécifié, et exécuter les ordres spécifiés.";
Blockly.Msg.CONTROLS_FOR_TOOLTIP = "Faire prendre à la variable « %1 » les valeurs depuis le nombre de début jusquau nombre de fin, en sincrémentant du pas spécifié, et exécuter les instructions spécifiées.";
Blockly.Msg.CONTROLS_IF_ELSEIF_TOOLTIP = "Ajouter une condition au bloc si.";
Blockly.Msg.CONTROLS_IF_ELSE_TOOLTIP = "Ajouter une condition finale fourre-tout au bloc si.";
Blockly.Msg.CONTROLS_IF_HELPURL = "https://github.com/google/blockly/wiki/IfElse"; // untranslated
@@ -56,12 +56,12 @@ Blockly.Msg.CONTROLS_IF_TOOLTIP_4 = "Si la première valeur est vraie, alors ex
Blockly.Msg.CONTROLS_REPEAT_HELPURL = "http://fr.wikipedia.org/wiki/Boucle_for";
Blockly.Msg.CONTROLS_REPEAT_INPUT_DO = "faire";
Blockly.Msg.CONTROLS_REPEAT_TITLE = "répéter %1 fois";
Blockly.Msg.CONTROLS_REPEAT_TOOLTIP = "Exécuter certains ordres plusieurs fois.";
Blockly.Msg.CONTROLS_REPEAT_TOOLTIP = "Exécuter des instructions plusieurs fois.";
Blockly.Msg.CONTROLS_WHILEUNTIL_HELPURL = "https://github.com/google/blockly/wiki/Loops#repeat"; // untranslated
Blockly.Msg.CONTROLS_WHILEUNTIL_OPERATOR_UNTIL = "répéter jusqu’à";
Blockly.Msg.CONTROLS_WHILEUNTIL_OPERATOR_WHILE = "répéter tant que";
Blockly.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL = "Tant quune valeur est fausse, alors exécuter certains ordres.";
Blockly.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_WHILE = "Tant quune valeur est vraie, alors exécuter certains ordres.";
Blockly.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL = "Tant quune valeur est fausse, alors exécuter des instructions.";
Blockly.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_WHILE = "Tant quune valeur est vraie, alors exécuter des instructions.";
Blockly.Msg.DELETE_ALL_BLOCKS = "Supprimer ces %1 blocs?";
Blockly.Msg.DELETE_BLOCK = "Supprimer le bloc";
Blockly.Msg.DELETE_X_BLOCKS = "Supprimer %1 blocs";
@@ -289,9 +289,10 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "nom de lentrée :";
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "Ajouter une entrée à la fonction.";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "entrées";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "Ajouter, supprimer, ou réarranger les entrées de cette fonction.";
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "Supprimer un commentaire";
Blockly.Msg.RENAME_VARIABLE = "Renommer la variable…";
Blockly.Msg.RENAME_VARIABLE_TITLE = "Renommer toutes les variables '%1' en :";
Blockly.Msg.RENAME_VARIABLE_TITLE = "Renommer toutes les variables « %1 » en :";
Blockly.Msg.TEXT_APPEND_APPENDTEXT = "ajouter le texte";
Blockly.Msg.TEXT_APPEND_HELPURL = "https://github.com/google/blockly/wiki/Text#text-modification"; // untranslated
Blockly.Msg.TEXT_APPEND_TO = "à";
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "supprimer les espaces du côté gauche";
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "supprimer les espaces du côté droit";
Blockly.Msg.TEXT_TRIM_TOOLTIP = "Renvoyer une copie du texte avec les espaces supprimés dun bout ou des deux.";
Blockly.Msg.TODAY = "Aujourd'hui";
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "élément";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "Créer 'fixer %1'";
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get"; // untranslated
+19 -17
View File
@@ -118,7 +118,7 @@ Blockly.Msg.LISTS_GET_SUBLIST_TOOLTIP = "יוצרת עותק של חלק מסו
Blockly.Msg.LISTS_INDEX_OF_FIRST = "מחזירה את המיקום הראשון של פריט ברשימה";
Blockly.Msg.LISTS_INDEX_OF_HELPURL = "https://github.com/google/blockly/wiki/Lists#getting-items-from-a-list"; // untranslated
Blockly.Msg.LISTS_INDEX_OF_LAST = "מחזירה את המיקום האחרון של פריט ברשימה";
Blockly.Msg.LISTS_INDEX_OF_TOOLTIP = "מחזירה את האינדקס של המופע ראשון/אחרון של הפריט ברשימה. מחזירה 0 אם טקסט אינו נמצא.";
Blockly.Msg.LISTS_INDEX_OF_TOOLTIP = "מחזירה את האינדקס של המופע ראשון/אחרון של הפריט ברשימה. מחזירה 0 אם הפריט אינו נמצא.";
Blockly.Msg.LISTS_INLIST = "ברשימה";
Blockly.Msg.LISTS_ISEMPTY_HELPURL = "https://github.com/google/blockly/wiki/Lists#is-empty"; // untranslated
Blockly.Msg.LISTS_ISEMPTY_TITLE = "%1 הוא ריק";
@@ -162,7 +162,7 @@ Blockly.Msg.LOGIC_COMPARE_TOOLTIP_LTE = "תחזיר אמת אם הקלט הרא
Blockly.Msg.LOGIC_COMPARE_TOOLTIP_NEQ = "תחזיר אמת אם שני הקלטים אינם שווים זה לזה.";
Blockly.Msg.LOGIC_NEGATE_HELPURL = "https://github.com/google/blockly/wiki/Logic#not"; // untranslated
Blockly.Msg.LOGIC_NEGATE_TITLE = "לא %1";
Blockly.Msg.LOGIC_NEGATE_TOOLTIP = "Returns true if the input is false. Returns false if the input is true."; // untranslated
Blockly.Msg.LOGIC_NEGATE_TOOLTIP = "החזר אמת אם הקלט הוא שקר. החזר שקר אם הקלט אמת.";
Blockly.Msg.LOGIC_NULL = "null";
Blockly.Msg.LOGIC_NULL_HELPURL = "https://en.wikipedia.org/wiki/Nullable_type"; // untranslated
Blockly.Msg.LOGIC_NULL_TOOLTIP = "תחזיר ריק.";
@@ -179,10 +179,10 @@ Blockly.Msg.LOGIC_TERNARY_TOOLTIP = "בדוק את התנאי ב'מבחן'. אם
Blockly.Msg.MATH_ADDITION_SYMBOL = "+";
Blockly.Msg.MATH_ARITHMETIC_HELPURL = "https://he.wikipedia.org/wiki/ארבע_פעולות_החשבון";
Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_ADD = "תחזיר את סכום שני המספרים.";
Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_DIVIDE = "Return the quotient of the two numbers."; // untranslated
Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_DIVIDE = "החזרת המנה של שני המספרים.";
Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_MINUS = "החזרת ההפרש בין שני מספרים.";
Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_MULTIPLY = "החזרת תוצאת הכפל בין שני מספרים.";
Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_POWER = "Return the first number raised to the power of the second number."; // untranslated
Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_POWER = "החזרת המספר הראשון בחזקת המספר השני.";
Blockly.Msg.MATH_CHANGE_HELPURL = "https://en.wikipedia.org/wiki/Programming_idiom#Incrementing_a_counter"; // untranslated
Blockly.Msg.MATH_CHANGE_TITLE = "change %1 by %2"; // untranslated
Blockly.Msg.MATH_CHANGE_TOOLTIP = "הוסף מספר למשתנה '%1'.";
@@ -204,7 +204,7 @@ Blockly.Msg.MATH_MODULO_HELPURL = "https://en.wikipedia.org/wiki/Modulo_operatio
Blockly.Msg.MATH_MODULO_TITLE = "שארית החילוק %1 ÷ %2";
Blockly.Msg.MATH_MODULO_TOOLTIP = "החזרת השארית מחלוקת שני המספרים.";
Blockly.Msg.MATH_MULTIPLICATION_SYMBOL = "×";
Blockly.Msg.MATH_NUMBER_HELPURL = "https://en.wikipedia.org/wiki/Number"; // untranslated
Blockly.Msg.MATH_NUMBER_HELPURL = "https://he.wikipedia.org/wiki/מספר_ממשי";
Blockly.Msg.MATH_NUMBER_TOOLTIP = "מספר.";
Blockly.Msg.MATH_ONLIST_HELPURL = ""; // untranslated
Blockly.Msg.MATH_ONLIST_OPERATOR_AVERAGE = "ממוצע של רשימה";
@@ -235,30 +235,30 @@ Blockly.Msg.MATH_ROUND_OPERATOR_ROUND = "עיגול";
Blockly.Msg.MATH_ROUND_OPERATOR_ROUNDDOWN = "עיגול למטה";
Blockly.Msg.MATH_ROUND_OPERATOR_ROUNDUP = "עיגול למעלה";
Blockly.Msg.MATH_ROUND_TOOLTIP = "עיגול מספר למעלה או למטה.";
Blockly.Msg.MATH_SINGLE_HELPURL = "https://en.wikipedia.org/wiki/Square_root"; // untranslated
Blockly.Msg.MATH_SINGLE_HELPURL = "https://he.wikipedia.org/wiki/שורש_ריבועי";
Blockly.Msg.MATH_SINGLE_OP_ABSOLUTE = "ערך מוחלט";
Blockly.Msg.MATH_SINGLE_OP_ROOT = "שורש ריבועי";
Blockly.Msg.MATH_SINGLE_TOOLTIP_ABS = "החזרת הערך המוחלט של מספר.";
Blockly.Msg.MATH_SINGLE_TOOLTIP_EXP = "Return e to the power of a number."; // untranslated
Blockly.Msg.MATH_SINGLE_TOOLTIP_EXP = "החזרת e בחזקת מספר.";
Blockly.Msg.MATH_SINGLE_TOOLTIP_LN = "החזרת הלוגריתם הטבעי של מספר.";
Blockly.Msg.MATH_SINGLE_TOOLTIP_LOG10 = "Return the base 10 logarithm of a number."; // untranslated
Blockly.Msg.MATH_SINGLE_TOOLTIP_LOG10 = "החזרת הלוגריתם לפי בסיס עשר של מספר.";
Blockly.Msg.MATH_SINGLE_TOOLTIP_NEG = "החזרת הערך הנגדי של מספר.";
Blockly.Msg.MATH_SINGLE_TOOLTIP_POW10 = "Return 10 to the power of a number."; // untranslated
Blockly.Msg.MATH_SINGLE_TOOLTIP_ROOT = "Return the square root of a number."; // untranslated
Blockly.Msg.MATH_SINGLE_TOOLTIP_POW10 = "החזרת 10 בחזקת מספר.";
Blockly.Msg.MATH_SINGLE_TOOLTIP_ROOT = "החזרת השורש הריבועי של מספר.";
Blockly.Msg.MATH_SUBTRACTION_SYMBOL = "-";
Blockly.Msg.MATH_TRIG_ACOS = "acos";
Blockly.Msg.MATH_TRIG_ASIN = "asin";
Blockly.Msg.MATH_TRIG_ATAN = "atan";
Blockly.Msg.MATH_TRIG_COS = "cos";
Blockly.Msg.MATH_TRIG_HELPURL = "https://en.wikipedia.org/wiki/Trigonometric_functions"; // untranslated
Blockly.Msg.MATH_TRIG_HELPURL = "https://he.wikipedia.org/wiki/פונקציות_טריגונומטריות";
Blockly.Msg.MATH_TRIG_SIN = "sin";
Blockly.Msg.MATH_TRIG_TAN = "tan";
Blockly.Msg.MATH_TRIG_TOOLTIP_ACOS = "Return the arccosine of a number."; // untranslated
Blockly.Msg.MATH_TRIG_TOOLTIP_ASIN = "Return the arcsine of a number."; // untranslated
Blockly.Msg.MATH_TRIG_TOOLTIP_ATAN = "Return the arctangent of a number."; // untranslated
Blockly.Msg.MATH_TRIG_TOOLTIP_COS = "Return the cosine of a degree (not radian)."; // untranslated
Blockly.Msg.MATH_TRIG_TOOLTIP_SIN = "Return the sine of a degree (not radian)."; // untranslated
Blockly.Msg.MATH_TRIG_TOOLTIP_TAN = "Return the tangent of a degree (not radian)."; // untranslated
Blockly.Msg.MATH_TRIG_TOOLTIP_COS = "החזרת הקוסינוס של מעלה (לא רדיאן).";
Blockly.Msg.MATH_TRIG_TOOLTIP_SIN = "החזרת הסינוס של מעלה (לא רדיאן).";
Blockly.Msg.MATH_TRIG_TOOLTIP_TAN = "החזרת הטנגס של מעלה (לא רדיאן).";
Blockly.Msg.ME = "אותי";
Blockly.Msg.NEW_VARIABLE = "משתנה חדש...";
Blockly.Msg.NEW_VARIABLE_TITLE = "שם המשתנה החדש:";
@@ -289,7 +289,8 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "שם הקלט:";
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "הוסף קלט לפונקציה";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "מקורות קלט";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "הוסף, הסר או סדר מחדש קלטים לפונקציה זו";
Blockly.Msg.REMOVE_COMMENT = "הסר הערה";
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "הסר תגובה";
Blockly.Msg.RENAME_VARIABLE = "שנה את שם המשתנה...";
Blockly.Msg.RENAME_VARIABLE_TITLE = "שנה את שם כל '%1' המשתנים ל:";
Blockly.Msg.TEXT_APPEND_APPENDTEXT = "הוספת טקסט";
@@ -313,8 +314,8 @@ Blockly.Msg.TEXT_CHARAT_TOOLTIP = "Returns the letter at the specified position.
Blockly.Msg.TEXT_CREATE_JOIN_ITEM_TOOLTIP = "Add an item to the text."; // untranslated
Blockly.Msg.TEXT_CREATE_JOIN_TITLE_JOIN = "צירוף";
Blockly.Msg.TEXT_CREATE_JOIN_TOOLTIP = "Add, remove, or reorder sections to reconfigure this text block."; // untranslated
Blockly.Msg.TEXT_GET_SUBSTRING_END_FROM_END = "to letter # from end"; // untranslated
Blockly.Msg.TEXT_GET_SUBSTRING_END_FROM_START = "to letter #"; // untranslated
Blockly.Msg.TEXT_GET_SUBSTRING_END_FROM_END = "לאות # מהסוף";
Blockly.Msg.TEXT_GET_SUBSTRING_END_FROM_START = "לאות #";
Blockly.Msg.TEXT_GET_SUBSTRING_END_LAST = "to last letter"; // untranslated
Blockly.Msg.TEXT_GET_SUBSTRING_HELPURL = "https://github.com/google/blockly/wiki/Text#extracting-a-region-of-text"; // untranslated
Blockly.Msg.TEXT_GET_SUBSTRING_INPUT_IN_TEXT = "in text"; // untranslated
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "למחוק רווחים מימין";
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "למחוק רווחים משמאל";
Blockly.Msg.TEXT_TRIM_TOOLTIP = "להחזיר עותק של הטקסט לאחר מחיקת רווחים מאחד או משני הקצוות.";
Blockly.Msg.TODAY = "היום";
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "פריט";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "ליצור 'הגדר %1'";
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get"; // untranslated
+2
View File
@@ -289,6 +289,7 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "इनपुट का नाम:";
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "फंगक्शन को इनपुट प्रदान करें।";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "इनपुट";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "Add, remove, or reorder inputs to this function."; // untranslated
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "टिप्पणी हटायें";
Blockly.Msg.RENAME_VARIABLE = "चर का नाम बदलें...";
Blockly.Msg.RENAME_VARIABLE_TITLE = "सभी '%1' चरों के नाम बदलें:";
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "रिक्त स्थान को
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "रिक्त स्थान को इस टेक्स्ट के दाईं तरफ से निकालें";
Blockly.Msg.TEXT_TRIM_TOOLTIP = "Return a copy of the text with spaces removed from one or both ends."; // untranslated
Blockly.Msg.TODAY = "आज";
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "आइटम";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "सेट '%1' बनाएँ";
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get"; // untranslated
+2
View File
@@ -289,6 +289,7 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "Markiear Funktionsblock";
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "Generier/erzeich \"Uffruf %1\"";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "Parameter";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "Variable:";
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "Kommentar entferne";
Blockly.Msg.RENAME_VARIABLE = "Die neie Variable sei Noome:";
Blockly.Msg.RENAME_VARIABLE_TITLE = "All \"%1\" Variable umbenenne in:";
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "entferne Leerzeiche von Oonfang Seite";
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "entferne Leerzeiche von End Seite von";
Blockly.Msg.TEXT_TRIM_TOOLTIP = "Entfernt Leerzeiche vom Oonfang und / orrer End von en Text.";
Blockly.Msg.TODAY = "Today"; // untranslated
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "Element";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "Generier/erzeiche \"Schreibe %1\"";
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get"; // untranslated
+2
View File
@@ -289,6 +289,7 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "változó:";
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "Bemenet hozzáadása a függvényhez.";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "paraméterek";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "Bemenetek hozzáadása, eltávolítása vagy átrendezése ehhez a függvényhez.";
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "Megjegyzés törlése";
Blockly.Msg.RENAME_VARIABLE = "Változó átnevezése...";
Blockly.Msg.RENAME_VARIABLE_TITLE = "Minden \"%1\" változó átnevezése erre:";
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "szóközök levágása az elejéről";
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "szóközök levágása a végéről";
Blockly.Msg.TEXT_TRIM_TOOLTIP = "Levágja a megadott szöveg végeiről a szóközöket.";
Blockly.Msg.TODAY = "Ma";
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "változó";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "Készíts \"%1=\"";
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get"; // untranslated
+2
View File
@@ -289,6 +289,7 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "nomine del entrata:";
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "Adder un entrata al function.";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "entratas";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "Adder, remover o reordinar le entratas pro iste function.";
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "Remover commento";
Blockly.Msg.RENAME_VARIABLE = "Renominar variabile...";
Blockly.Msg.RENAME_VARIABLE_TITLE = "Renominar tote le variabiles '%1' a:";
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "remover spatios del sinistre latere de";
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "remover spatios del dextre latere de";
Blockly.Msg.TEXT_TRIM_TOOLTIP = "Retornar un copia del texto con spatios eliminate de un extremitate o ambes.";
Blockly.Msg.TODAY = "Hodie";
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "cosa";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "Crea 'mitter %1'";
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get"; // untranslated
+115 -113
View File
@@ -6,19 +6,19 @@ goog.provide('Blockly.Msg.id');
goog.require('Blockly.Msg');
Blockly.Msg.ADD_COMMENT = "Tambahkan sebuah comment";
Blockly.Msg.ADD_COMMENT = "Tambahkan Komentar";
Blockly.Msg.AUTH = "Silakan mengotorisasi aplikasi ini untuk memungkinkan pekerjaan Anda dapat disimpan dan digunakan bersama.";
Blockly.Msg.CHANGE_VALUE_TITLE = "Ubah nilai:";
Blockly.Msg.CHAT = "Chatting dengan kolaborator anda dengan mengetikkan di kotak ini!";
Blockly.Msg.CLEAN_UP = "Clean up Blocks"; // untranslated
Blockly.Msg.CLEAN_UP = "Bersihkan Blok";
Blockly.Msg.COLLAPSE_ALL = "Ciutkan Blok";
Blockly.Msg.COLLAPSE_BLOCK = "Ciutkan Blok";
Blockly.Msg.COLOUR_BLEND_COLOUR1 = "Warna 1";
Blockly.Msg.COLOUR_BLEND_COLOUR2 = "Warna 2";
Blockly.Msg.COLOUR_BLEND_COLOUR1 = "warna 1";
Blockly.Msg.COLOUR_BLEND_COLOUR2 = "warna 2";
Blockly.Msg.COLOUR_BLEND_HELPURL = "http://meyerweb.com/eric/tools/color-blend/";
Blockly.Msg.COLOUR_BLEND_RATIO = "rasio";
Blockly.Msg.COLOUR_BLEND_TITLE = "Tertutup";
Blockly.Msg.COLOUR_BLEND_TOOLTIP = "mencampur dua warna secara bersamaan dengan perbandingan (0.0-1.0).";
Blockly.Msg.COLOUR_BLEND_TITLE = "campur";
Blockly.Msg.COLOUR_BLEND_TOOLTIP = "Campur dua warna secara bersamaan dengan perbandingan (0.0 - 1.0).";
Blockly.Msg.COLOUR_PICKER_HELPURL = "https://en.wikipedia.org/wiki/Color";
Blockly.Msg.COLOUR_PICKER_TOOLTIP = "Pilih warna dari daftar warna.";
Blockly.Msg.COLOUR_RANDOM_HELPURL = "http://randomcolour.com"; // untranslated
@@ -31,57 +31,57 @@ Blockly.Msg.COLOUR_RGB_RED = "merah";
Blockly.Msg.COLOUR_RGB_TITLE = "Dengan warna";
Blockly.Msg.COLOUR_RGB_TOOLTIP = "Buatlah warna dengan jumlah yang ditentukan dari merah, hijau dan biru. Semua nilai harus antarai 0 sampai 100.";
Blockly.Msg.CONTROLS_FLOW_STATEMENTS_HELPURL = "https://github.com/google/blockly/wiki/Loops#loop-termination-blocks"; // untranslated
Blockly.Msg.CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK = "Keluar dari perulangan";
Blockly.Msg.CONTROLS_FLOW_STATEMENTS_OPERATOR_CONTINUE = "Lanjutkan dengan langkah penggulangan berikutnya";
Blockly.Msg.CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK = "Keluar sementara dari perulanggan.";
Blockly.Msg.CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE = "Abaikan sisa dari loop ini, dan lanjutkan dengan iterasi berikutnya.";
Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING = "Peringatan: Blok ini hanya dapat digunakan dalam loop.";
Blockly.Msg.CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK = "keluar dari perulangan";
Blockly.Msg.CONTROLS_FLOW_STATEMENTS_OPERATOR_CONTINUE = "lanjutkan dengan langkah perulangan berikutnya";
Blockly.Msg.CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK = "Keluar dari perulangan.";
Blockly.Msg.CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE = "Abaikan sisa dari perulangan ini, dan lanjutkan dengan langkah berikutnya.";
Blockly.Msg.CONTROLS_FLOW_STATEMENTS_WARNING = "Peringatan: Blok ini hanya dapat digunakan dalam perulangan.";
Blockly.Msg.CONTROLS_FOREACH_HELPURL = "https://github.com/google/blockly/wiki/Loops#for-each"; // untranslated
Blockly.Msg.CONTROLS_FOREACH_TITLE = "untuk setiap item %1 di dalam list %2";
Blockly.Msg.CONTROLS_FOREACH_TOOLTIP = "Untuk tiap-tiap item di dalam list, tetapkan variabel '%1' ke dalam item, selanjutnya kerjakan beberapa statement.";
Blockly.Msg.CONTROLS_FOR_HELPURL = "https://github.com/google/blockly/wiki/Loops#count-with"; // untranslated
Blockly.Msg.CONTROLS_FOR_TITLE = "Cacah dengan %1 dari %2 ke %3 dengan step / penambahan %4";
Blockly.Msg.CONTROLS_FOR_TOOLTIP = "Menggunakan variabel \"%1\" dengan mengambil nilai dari batas awal hingga ke batas akhir, dengan interval tertentu, dan mengerjakan block tertentu.";
Blockly.Msg.CONTROLS_IF_ELSEIF_TOOLTIP = "tambahkan prasyarat ke dalam blok IF.";
Blockly.Msg.CONTROLS_IF_ELSE_TOOLTIP = "Terakhir, tambahkan tangkap-semua kondisi kedalam blok jika (if).";
Blockly.Msg.CONTROLS_IF_ELSEIF_TOOLTIP = "Tambahkan prasyarat ke dalam blok IF.";
Blockly.Msg.CONTROLS_IF_ELSE_TOOLTIP = "Terakhir, tambahkan kondisi tangkap-semua kedalam blok IF.";
Blockly.Msg.CONTROLS_IF_HELPURL = "https://github.com/google/blockly/wiki/IfElse"; // untranslated
Blockly.Msg.CONTROLS_IF_IF_TOOLTIP = "Menambahkan, menghapus, atau menyusun kembali bagian untuk mengkonfigurasi blok IF ini.";
Blockly.Msg.CONTROLS_IF_MSG_ELSE = "else";
Blockly.Msg.CONTROLS_IF_MSG_ELSEIF = "else if";
Blockly.Msg.CONTROLS_IF_MSG_IF = "Jika";
Blockly.Msg.CONTROLS_IF_TOOLTIP_1 = "jika nilainya benar maka kerjakan perintah berikutnya.";
Blockly.Msg.CONTROLS_IF_TOOLTIP_2 = "jika nilainya benar, maka kerjakan blok perintah yang pertama. Jika tidak, kerjakan blok perintah yang kedua.";
Blockly.Msg.CONTROLS_IF_TOOLTIP_3 = "Jika nilai pertama adalah benar (true), maka lakukan perintah-perintah yang berada didalam blok pertama. Jika nilai kedua adalah benar (true), maka lakukan perintah-perintah yang berada didalam blok kedua.";
Blockly.Msg.CONTROLS_IF_TOOLTIP_4 = "Jika blok pertama adalah benar (true), maka lakukan perintah-perintah yang berada didalam blok pertama. Atau jika blok kedua adalah benar (true), maka lakukan perintah-perintah yang berada didalam blok kedua.";
Blockly.Msg.CONTROLS_IF_IF_TOOLTIP = "Tambahkan, hapus, atau susun kembali bagian untuk mengkonfigurasi blok IF ini.";
Blockly.Msg.CONTROLS_IF_MSG_ELSE = "lainnya";
Blockly.Msg.CONTROLS_IF_MSG_ELSEIF = "atau jika";
Blockly.Msg.CONTROLS_IF_MSG_IF = "jika";
Blockly.Msg.CONTROLS_IF_TOOLTIP_1 = "Jika nilainya benar, maka lakukan beberapa perintah.";
Blockly.Msg.CONTROLS_IF_TOOLTIP_2 = "Jika nilainya benar, maka kerjakan perintah blok pertama. Jika tidak, kerjakan perintah blok kedua.";
Blockly.Msg.CONTROLS_IF_TOOLTIP_3 = "Jika nilai pertama benar, maka kerjakan perintah blok pertama. Sebaliknya, jika nilai kedua benar, kerjakan perintah blok kedua.";
Blockly.Msg.CONTROLS_IF_TOOLTIP_4 = "Jika nilai pertama benar, maka kerjakan perintah blok pertama. Sebaliknya, jika nilai kedua benar, kerjakan perintah blok kedua. Jika dua-duanya tidak benar, kerjakan perintah blok terakhir.";
Blockly.Msg.CONTROLS_REPEAT_HELPURL = "https://en.wikipedia.org/wiki/For_loop";
Blockly.Msg.CONTROLS_REPEAT_INPUT_DO = "kerjakan";
Blockly.Msg.CONTROLS_REPEAT_TITLE = "ulangi %1 kali";
Blockly.Msg.CONTROLS_REPEAT_TOOLTIP = "Lakukan beberapa perintah beberapa kali.";
Blockly.Msg.CONTROLS_WHILEUNTIL_HELPURL = "https://github.com/google/blockly/wiki/Loops#repeat"; // untranslated
Blockly.Msg.CONTROLS_WHILEUNTIL_OPERATOR_UNTIL = "Ulangi sampai";
Blockly.Msg.CONTROLS_WHILEUNTIL_OPERATOR_WHILE = "Ulangi jika";
Blockly.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL = "Jika sementara nilai tidak benar (false), maka lakukan beberapa perintah.";
Blockly.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_WHILE = "Jika sementara nilai benar (true), maka lakukan beberapa perintah.";
Blockly.Msg.DELETE_ALL_BLOCKS = "Delete all %1 blocks?"; // untranslated
Blockly.Msg.CONTROLS_WHILEUNTIL_OPERATOR_UNTIL = "ulangi sampai";
Blockly.Msg.CONTROLS_WHILEUNTIL_OPERATOR_WHILE = "ulangi jika";
Blockly.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL = "Selagi nilainya salah, maka lakukan beberapa perintah.";
Blockly.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_WHILE = "Selagi nilainya benar, maka lakukan beberapa perintah.";
Blockly.Msg.DELETE_ALL_BLOCKS = "Hapus semua %1 blok?";
Blockly.Msg.DELETE_BLOCK = "Hapus Blok";
Blockly.Msg.DELETE_X_BLOCKS = "Hapus %1 Blok";
Blockly.Msg.DISABLE_BLOCK = "Nonaktifkan Blok";
Blockly.Msg.DUPLICATE_BLOCK = "Duplikat";
Blockly.Msg.ENABLE_BLOCK = "Aktifkan Blok";
Blockly.Msg.EXPAND_ALL = "Kembangkan blok-blok";
Blockly.Msg.EXPAND_ALL = "Kembangkan Blok";
Blockly.Msg.EXPAND_BLOCK = "Kembangkan Blok";
Blockly.Msg.EXTERNAL_INPUTS = "Input-input eksternal";
Blockly.Msg.EXTERNAL_INPUTS = "Input Eksternal";
Blockly.Msg.HELP = "Bantuan";
Blockly.Msg.INLINE_INPUTS = "Input inline";
Blockly.Msg.INLINE_INPUTS = "Input Inline";
Blockly.Msg.LISTS_CREATE_EMPTY_HELPURL = "https://github.com/google/blockly/wiki/Lists#create-empty-list";
Blockly.Msg.LISTS_CREATE_EMPTY_TITLE = "buat list kosong";
Blockly.Msg.LISTS_CREATE_EMPTY_TOOLTIP = "Mengembalikan daftar, dengan panjang 0, tidak berisi data";
Blockly.Msg.LISTS_CREATE_EMPTY_TOOLTIP = "Kembalikan list, dengan panjang 0, tidak berisi data";
Blockly.Msg.LISTS_CREATE_WITH_CONTAINER_TITLE_ADD = "list";
Blockly.Msg.LISTS_CREATE_WITH_CONTAINER_TOOLTIP = "Tambahkan, hapus, atau susun ulang bagian untuk mengkonfigurasi blok LIST (daftar) ini.";
Blockly.Msg.LISTS_CREATE_WITH_CONTAINER_TOOLTIP = "Tambahkan, hapus, atau susun ulang bagian untuk mengkonfigurasi blok list ini.";
Blockly.Msg.LISTS_CREATE_WITH_HELPURL = "https://github.com/google/blockly/wiki/Lists#create-list-with"; // untranslated
Blockly.Msg.LISTS_CREATE_WITH_INPUT_WITH = "buat daftar (list) dengan";
Blockly.Msg.LISTS_CREATE_WITH_ITEM_TOOLTIP = "Tambahkan sebuah item ke daftar (list).";
Blockly.Msg.LISTS_CREATE_WITH_TOOLTIP = "Buat sebuah daftar (list) dengan sejumlah item.";
Blockly.Msg.LISTS_CREATE_WITH_INPUT_WITH = "buat list dengan";
Blockly.Msg.LISTS_CREATE_WITH_ITEM_TOOLTIP = "Tambahkan sebuah item ke list.";
Blockly.Msg.LISTS_CREATE_WITH_TOOLTIP = "Buat sebuah list dengan sejumlah item.";
Blockly.Msg.LISTS_GET_INDEX_FIRST = "pertama";
Blockly.Msg.LISTS_GET_INDEX_FROM_END = "# dari akhir";
Blockly.Msg.LISTS_GET_INDEX_FROM_START = "#";
@@ -91,44 +91,44 @@ Blockly.Msg.LISTS_GET_INDEX_LAST = "terakhir";
Blockly.Msg.LISTS_GET_INDEX_RANDOM = "acak";
Blockly.Msg.LISTS_GET_INDEX_REMOVE = "Hapus";
Blockly.Msg.LISTS_GET_INDEX_TAIL = ""; // untranslated
Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_FIRST = "Kembalikan item pertama dalam daftar (list).";
Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_FROM_END = "Sisipkan item ke dalam posisi yang telah ditentukan didalam list (daftar). Item pertama adalah item yang terakhir.";
Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_FROM_START = "Sisipkan item ke dalam posisi yang telah ditentukan didalam list (daftar). Item pertama adalah item terakhir (yg paling akhir).";
Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_LAST = "Mengembalikan item pertama dalam list (daftar).";
Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_RANDOM = "Mengembalikan item acak dalam list (daftar).";
Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FIRST = "Menghilangkan dan mengembalikan item pertama dalam list (daftar).";
Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FROM_END = "Menghilangkan dan mengembalikan barang di posisi tertentu dalam list (daftar). #1 adalah item terakhir.";
Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FROM_START = "Menghilangkan dan mengembalikan barang di posisi tertentu dalam list (daftar). #1 adalah item pertama.";
Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_LAST = "Menghilangkan dan mengembalikan item terakhir dalam list (daftar).";
Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_RANDOM = "Menghilangkan dan mengembalikan barang dengan acak dalam list (daftar).";
Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FIRST = "Menghapus item pertama dalam daftar.";
Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FROM_END = "Menghapus item dengan posisi tertentu dalam daftar. Item pertama adalah item yang terakhir.";
Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FROM_START = "Menghapus item dengan posisi tertentu dalam daftar. Item pertama adalah item yang terakhir.";
Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_LAST = "Menghapus item terakhir dalam daftar.";
Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_RANDOM = "Menghapus sebuah item secara acak dalam list.";
Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_FIRST = "Kembalikan item pertama dalam list.";
Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_FROM_END = "Kembalikan item di posisi tertentu dalam list. #1 adalah item terakhir.";
Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_FROM_START = "Kembalikan item di posisi tertentu dalam list. #1 adalah item pertama.";
Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_LAST = "Kembalikan item terakhir dalam list.";
Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_RANDOM = "Kembalikan item acak dalam list.";
Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FIRST = "Hapus dan kembalikan item pertama dalam list.";
Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FROM_END = "Hapus dan kembalikan item di posisi tertentu dalam list. #1 adalah item terakhir.";
Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_FROM_START = "Hapus dan kembalikan item di posisi tertentu dalam list. #1 adalah item pertama.";
Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_LAST = "Hapus dan kembalikan item terakhir dalam list.";
Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_GET_REMOVE_RANDOM = "Hapus dan kembalikan item acak dalam list.";
Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FIRST = "Hapus item pertama dalam list.";
Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FROM_END = "Hapus item di posisi tertentu dalam list. #1 adalah item terakhir.";
Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_FROM_START = "Hapus item di posisi tertentu dalam list. #1 adalah item pertama.";
Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_LAST = "Hapus item terakhir dalam list.";
Blockly.Msg.LISTS_GET_INDEX_TOOLTIP_REMOVE_RANDOM = "Hapus sebuah item acak dalam list.";
Blockly.Msg.LISTS_GET_SUBLIST_END_FROM_END = "ke # dari akhir";
Blockly.Msg.LISTS_GET_SUBLIST_END_FROM_START = "ke #";
Blockly.Msg.LISTS_GET_SUBLIST_END_LAST = "ke yang paling akhir";
Blockly.Msg.LISTS_GET_SUBLIST_HELPURL = "https://github.com/google/blockly/wiki/Lists#getting-a-sublist"; // untranslated
Blockly.Msg.LISTS_GET_SUBLIST_START_FIRST = "Dapatkan bagian pertama dari list";
Blockly.Msg.LISTS_GET_SUBLIST_START_FROM_END = "Dapatkan bagian list nomor # dari akhir";
Blockly.Msg.LISTS_GET_SUBLIST_START_FROM_START = "Dapatkan bagian daftar dari #";
Blockly.Msg.LISTS_GET_SUBLIST_START_FIRST = "dapatkan sub-list dari pertama";
Blockly.Msg.LISTS_GET_SUBLIST_START_FROM_END = "dapatkan sub-list dari nomor # dari akhir";
Blockly.Msg.LISTS_GET_SUBLIST_START_FROM_START = "dapatkan sub-list dari #";
Blockly.Msg.LISTS_GET_SUBLIST_TAIL = ""; // untranslated
Blockly.Msg.LISTS_GET_SUBLIST_TOOLTIP = "Membuat salinan dari bagian tertentu dari list.";
Blockly.Msg.LISTS_GET_SUBLIST_TOOLTIP = "Buat salinan bagian tertentu dari list.";
Blockly.Msg.LISTS_INDEX_OF_FIRST = "cari kejadian pertama item";
Blockly.Msg.LISTS_INDEX_OF_HELPURL = "https://github.com/google/blockly/wiki/Lists#getting-items-from-a-list"; // untranslated
Blockly.Msg.LISTS_INDEX_OF_LAST = "Cari kejadian terakhir item";
Blockly.Msg.LISTS_INDEX_OF_TOOLTIP = "Mengembalikan indeks dari kejadian pertama/terakhir item dalam daftar. Menghasilkan 0 jika teks tidak ditemukan.";
Blockly.Msg.LISTS_INLIST = "dalam daftar";
Blockly.Msg.LISTS_INDEX_OF_LAST = "cari kejadian terakhir item";
Blockly.Msg.LISTS_INDEX_OF_TOOLTIP = "Kembalikan indeks dari item pertama/terakhir kali muncul dalam list. Kembalikan 0 jika item tidak ditemukan.";
Blockly.Msg.LISTS_INLIST = "dalam list";
Blockly.Msg.LISTS_ISEMPTY_HELPURL = "https://github.com/google/blockly/wiki/Lists#is-empty"; // untranslated
Blockly.Msg.LISTS_ISEMPTY_TITLE = "%1 kosong";
Blockly.Msg.LISTS_ISEMPTY_TOOLTIP = "Mengembalikan nilai benar (true) jika list kosong.";
Blockly.Msg.LISTS_ISEMPTY_TOOLTIP = "Kembalikan benar jika list kosong.";
Blockly.Msg.LISTS_LENGTH_HELPURL = "https://github.com/google/blockly/wiki/Lists#length-of"; // untranslated
Blockly.Msg.LISTS_LENGTH_TITLE = "panjang dari %1";
Blockly.Msg.LISTS_LENGTH_TOOLTIP = "Mengembalikan panjang daftar.";
Blockly.Msg.LISTS_LENGTH_TOOLTIP = "Kembalikan panjang list.";
Blockly.Msg.LISTS_REPEAT_HELPURL = "https://github.com/google/blockly/wiki/Lists#create-list-with"; // untranslated
Blockly.Msg.LISTS_REPEAT_TITLE = "membuat daftar dengan item %1 diulang %2 kali";
Blockly.Msg.LISTS_REPEAT_TOOLTIP = "Ciptakan daftar yang terdiri dari nilai yang diberikan diulang jumlah waktu yang ditentukan.";
Blockly.Msg.LISTS_REPEAT_TITLE = "buat list dengan item %1 diulang %2 kali";
Blockly.Msg.LISTS_REPEAT_TOOLTIP = "Buat sebuah list yang terdiri dari nilai yang diberikan diulang sebanyak jumlah yang ditentukan.";
Blockly.Msg.LISTS_SET_INDEX_HELPURL = "https://github.com/google/blockly/wiki/Lists#in-list--set"; // untranslated
Blockly.Msg.LISTS_SET_INDEX_INPUT_TO = "sebagai";
Blockly.Msg.LISTS_SET_INDEX_INSERT = "sisipkan di";
@@ -144,38 +144,38 @@ Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_SET_FROM_START = "Tetapkan item ke dalam pos
Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_SET_LAST = "Menetapkan item terakhir dalam list.";
Blockly.Msg.LISTS_SET_INDEX_TOOLTIP_SET_RANDOM = "Tetapkan secara acak sebuah item dalam list.";
Blockly.Msg.LISTS_SPLIT_HELPURL = "https://github.com/google/blockly/wiki/Lists#splitting-strings-and-joining-lists"; // untranslated
Blockly.Msg.LISTS_SPLIT_LIST_FROM_TEXT = "membuat daftar dari teks";
Blockly.Msg.LISTS_SPLIT_TEXT_FROM_LIST = "buat teks dari daftar";
Blockly.Msg.LISTS_SPLIT_LIST_FROM_TEXT = "buat list dari teks";
Blockly.Msg.LISTS_SPLIT_TEXT_FROM_LIST = "buat teks dari list";
Blockly.Msg.LISTS_SPLIT_TOOLTIP_JOIN = "Gabung daftar teks menjadi satu teks, yang dipisahkan oleh pembatas.";
Blockly.Msg.LISTS_SPLIT_TOOLTIP_SPLIT = "Membagi teks ke dalam daftar teks, pisahkan pada setiap pembatas.";
Blockly.Msg.LISTS_SPLIT_WITH_DELIMITER = "dengan pembatas";
Blockly.Msg.LOGIC_BOOLEAN_FALSE = "Salah";
Blockly.Msg.LOGIC_BOOLEAN_FALSE = "salah";
Blockly.Msg.LOGIC_BOOLEAN_HELPURL = "https://github.com/google/blockly/wiki/Logic#values"; // untranslated
Blockly.Msg.LOGIC_BOOLEAN_TOOLTIP = "Mengembalikan betul (true) atau salah (false).";
Blockly.Msg.LOGIC_BOOLEAN_TRUE = "Benar";
Blockly.Msg.LOGIC_BOOLEAN_TOOLTIP = "Kembalikan benar atau salah.";
Blockly.Msg.LOGIC_BOOLEAN_TRUE = "benar";
Blockly.Msg.LOGIC_COMPARE_HELPURL = "https://en.wikipedia.org/wiki/Inequality_(mathematics)";
Blockly.Msg.LOGIC_COMPARE_TOOLTIP_EQ = "Mengembalikan betul jika input kedua-duanya sama dengan satu sama lain.";
Blockly.Msg.LOGIC_COMPARE_TOOLTIP_GT = "Mengembalikan nilai benar (true) jika input yang pertama lebih besar dari input yang kedua.";
Blockly.Msg.LOGIC_COMPARE_TOOLTIP_GTE = "Mengembalikan nilai benar (true) jika input yang pertama lebih besar dari atau sama dengan input yang kedua.";
Blockly.Msg.LOGIC_COMPARE_TOOLTIP_LT = "Mengembalikan nilai benar (true) jika input yang pertama lebih kecil dari input yang kedua.";
Blockly.Msg.LOGIC_COMPARE_TOOLTIP_LTE = "Mengembalikan nilai benar (true) jika input yang pertama lebih kecil atau sama dengan input yang kedua .";
Blockly.Msg.LOGIC_COMPARE_TOOLTIP_NEQ = "Mengembalikan nilai benar (true) jika kedua input tidak sama satu dengan yang lain.";
Blockly.Msg.LOGIC_COMPARE_TOOLTIP_EQ = "Kembalikan benar jika kedua input sama satu dengan lainnya.";
Blockly.Msg.LOGIC_COMPARE_TOOLTIP_GT = "Kembalikan benar jika input pertama lebih besar dari input kedua.";
Blockly.Msg.LOGIC_COMPARE_TOOLTIP_GTE = "Kembalikan benar jika input pertama lebih besar dari atau sama dengan input kedua.";
Blockly.Msg.LOGIC_COMPARE_TOOLTIP_LT = "Kembalikan benar jika input pertama lebih kecil dari input kedua.";
Blockly.Msg.LOGIC_COMPARE_TOOLTIP_LTE = "Kembalikan benar jika input pertama lebih kecil atau sama dengan input kedua .";
Blockly.Msg.LOGIC_COMPARE_TOOLTIP_NEQ = "Kembalikan benar jika kedua input tidak sama satu dengan lainnya.";
Blockly.Msg.LOGIC_NEGATE_HELPURL = "https://github.com/google/blockly/wiki/Logic#not"; // untranslated
Blockly.Msg.LOGIC_NEGATE_TITLE = "bukan (not) %1";
Blockly.Msg.LOGIC_NEGATE_TOOLTIP = "Mengembalikan nilai benar (true) jika input false. Mengembalikan nilai salah (false) jika input true.";
Blockly.Msg.LOGIC_NEGATE_TOOLTIP = "Kembalikan benar jika input salah. Kembalikan salah jika input benar.";
Blockly.Msg.LOGIC_NULL = "null";
Blockly.Msg.LOGIC_NULL_HELPURL = "https://en.wikipedia.org/wiki/Nullable_type";
Blockly.Msg.LOGIC_NULL_TOOLTIP = "mengembalikan kosong.";
Blockly.Msg.LOGIC_NULL_TOOLTIP = "Kembalikan null.";
Blockly.Msg.LOGIC_OPERATION_AND = "dan";
Blockly.Msg.LOGIC_OPERATION_HELPURL = "https://github.com/google/blockly/wiki/Logic#logical-operations"; // untranslated
Blockly.Msg.LOGIC_OPERATION_OR = "atau";
Blockly.Msg.LOGIC_OPERATION_TOOLTIP_AND = "Kembalikan betul jika kedua-dua input adalah betul.";
Blockly.Msg.LOGIC_OPERATION_TOOLTIP_OR = "Mengembalikan nilai benar (true) jika setidaknya salah satu masukan nilainya benar (true).";
Blockly.Msg.LOGIC_OPERATION_TOOLTIP_AND = "Kembalikan benar jika kedua input adalah benar.";
Blockly.Msg.LOGIC_OPERATION_TOOLTIP_OR = "Kembalikan benar jika minimal satu input nilainya benar.";
Blockly.Msg.LOGIC_TERNARY_CONDITION = "test";
Blockly.Msg.LOGIC_TERNARY_HELPURL = "https://en.wikipedia.org/wiki/%3F:";
Blockly.Msg.LOGIC_TERNARY_IF_FALSE = "jika tidak benar (false)";
Blockly.Msg.LOGIC_TERNARY_IF_TRUE = "jika benar (true)";
Blockly.Msg.LOGIC_TERNARY_TOOLTIP = "Periksa kondisi di \"test\". Jika kondisi benar (true), mengembalikan nilai \"jika benar\" ; Jik sebaliknya akan mengembalikan nilai \"jika salah\".";
Blockly.Msg.LOGIC_TERNARY_IF_FALSE = "jika salah";
Blockly.Msg.LOGIC_TERNARY_IF_TRUE = "jika benar";
Blockly.Msg.LOGIC_TERNARY_TOOLTIP = "Periksa kondisi di 'test'. Jika kondisi benar, kembalikan nilai 'if true'; jika sebaliknya kembalikan nilai 'if false'.";
Blockly.Msg.MATH_ADDITION_SYMBOL = "+";
Blockly.Msg.MATH_ARITHMETIC_HELPURL = "https://id.wikipedia.org/wiki/Aritmetika";
Blockly.Msg.MATH_ARITHMETIC_TOOLTIP_ADD = "Kembalikan jumlah dari kedua angka.";
@@ -192,48 +192,48 @@ Blockly.Msg.MATH_CONSTRAIN_HELPURL = "https://en.wikipedia.org/wiki/Clamping_%28
Blockly.Msg.MATH_CONSTRAIN_TITLE = "Batasi %1 rendah %2 tinggi %3";
Blockly.Msg.MATH_CONSTRAIN_TOOLTIP = "Batasi angka antara batas yang ditentukan (inklusif).";
Blockly.Msg.MATH_DIVISION_SYMBOL = "÷";
Blockly.Msg.MATH_IS_DIVISIBLE_BY = "dibagi oleh";
Blockly.Msg.MATH_IS_DIVISIBLE_BY = "dapat dibagi oleh";
Blockly.Msg.MATH_IS_EVEN = "adalah bilangan genap";
Blockly.Msg.MATH_IS_NEGATIVE = "adalah bilangan negatif";
Blockly.Msg.MATH_IS_NEGATIVE = "adalah bilangan negatif";
Blockly.Msg.MATH_IS_ODD = "adalah bilangan ganjil";
Blockly.Msg.MATH_IS_POSITIVE = "adalah bilangan positif";
Blockly.Msg.MATH_IS_POSITIVE = "adalah bilangan positif";
Blockly.Msg.MATH_IS_PRIME = "adalah bilangan pokok";
Blockly.Msg.MATH_IS_TOOLTIP = "Periksa apakah angka adalah bilangan genap, bilangan pokok, bilangan bulat, bilangan positif, bilangan negatif, atau apakan bisa dibagi oleh angka tertentu. Mengembalikan benar (true) atau salah (false).";
Blockly.Msg.MATH_IS_TOOLTIP = "Periksa apakah angka adalah bilangan genap, bilangan ganjil, bilangan pokok, bilangan bulat, bilangan positif, bilangan negatif, atau apakan bisa dibagi oleh angka tertentu. Kembalikan benar atau salah.";
Blockly.Msg.MATH_IS_WHOLE = "adalah bilangan bulat";
Blockly.Msg.MATH_MODULO_HELPURL = "https://en.wikipedia.org/wiki/Modulo_operation";
Blockly.Msg.MATH_MODULO_TITLE = "sisa %1 ÷ %2";
Blockly.Msg.MATH_MODULO_TITLE = "sisa dari %1 ÷ %2";
Blockly.Msg.MATH_MODULO_TOOLTIP = "Kembalikan sisa dari pembagian ke dua angka.";
Blockly.Msg.MATH_MULTIPLICATION_SYMBOL = "×";
Blockly.Msg.MATH_NUMBER_HELPURL = "https://en.wikipedia.org/wiki/Number";
Blockly.Msg.MATH_NUMBER_TOOLTIP = "Suatu angka.";
Blockly.Msg.MATH_ONLIST_HELPURL = ""; // untranslated
Blockly.Msg.MATH_ONLIST_OPERATOR_AVERAGE = "rata-rata dari list (daftar)";
Blockly.Msg.MATH_ONLIST_OPERATOR_MAX = "maximum dari list (daftar)";
Blockly.Msg.MATH_ONLIST_OPERATOR_MEDIAN = "median dari list (daftar)";
Blockly.Msg.MATH_ONLIST_OPERATOR_MIN = "minimum dari list (daftar)";
Blockly.Msg.MATH_ONLIST_OPERATOR_MODE = "mode-mode dari list (daftar)";
Blockly.Msg.MATH_ONLIST_OPERATOR_RANDOM = "item acak dari list (daftar)";
Blockly.Msg.MATH_ONLIST_OPERATOR_STD_DEV = "deviasi standar dari list (daftar)";
Blockly.Msg.MATH_ONLIST_OPERATOR_SUM = "jumlah dari list (daftar)";
Blockly.Msg.MATH_ONLIST_TOOLTIP_AVERAGE = "Kembalikan rata-rata (mean aritmetik) dari nilai numerik dari list (daftar).";
Blockly.Msg.MATH_ONLIST_OPERATOR_AVERAGE = "rata-rata dari list";
Blockly.Msg.MATH_ONLIST_OPERATOR_MAX = "maksimum dari list";
Blockly.Msg.MATH_ONLIST_OPERATOR_MEDIAN = "median dari list";
Blockly.Msg.MATH_ONLIST_OPERATOR_MIN = "minimum dari list";
Blockly.Msg.MATH_ONLIST_OPERATOR_MODE = "mode-mode dari list";
Blockly.Msg.MATH_ONLIST_OPERATOR_RANDOM = "item acak dari list";
Blockly.Msg.MATH_ONLIST_OPERATOR_STD_DEV = "deviasi standar dari list";
Blockly.Msg.MATH_ONLIST_OPERATOR_SUM = "jumlah dari list";
Blockly.Msg.MATH_ONLIST_TOOLTIP_AVERAGE = "Kembalikan rata-rata (mean aritmetik) dari nilai numerik dari list.";
Blockly.Msg.MATH_ONLIST_TOOLTIP_MAX = "Kembalikan angka terbesar dari list.";
Blockly.Msg.MATH_ONLIST_TOOLTIP_MEDIAN = "Kembalikan median dari list.";
Blockly.Msg.MATH_ONLIST_TOOLTIP_MIN = "Kembalikan angka terkecil dari list.";
Blockly.Msg.MATH_ONLIST_TOOLTIP_MODE = "Kembalikan list berisi item-item yang paling umum dari dalam list.";
Blockly.Msg.MATH_ONLIST_TOOLTIP_RANDOM = "Kembalikan element acak dari list.";
Blockly.Msg.MATH_ONLIST_TOOLTIP_MODE = "Kembalikan list berisi item yang paling umum dari dalam list.";
Blockly.Msg.MATH_ONLIST_TOOLTIP_RANDOM = "Kembalikan elemen acak dari list.";
Blockly.Msg.MATH_ONLIST_TOOLTIP_STD_DEV = "Kembalikan standard deviasi dari list.";
Blockly.Msg.MATH_ONLIST_TOOLTIP_SUM = "Kembalikan jumlah dari seluruh bilangan dari list.";
Blockly.Msg.MATH_POWER_SYMBOL = "^";
Blockly.Msg.MATH_RANDOM_FLOAT_HELPURL = "https://en.wikipedia.org/wiki/Random_number_generation";
Blockly.Msg.MATH_RANDOM_FLOAT_TITLE_RANDOM = "Nilai pecahan acak";
Blockly.Msg.MATH_RANDOM_FLOAT_TOOLTIP = "Mengembalikan nilai acak pecahan antara 0.0 (inklusif) dan 1.0 (ekslusif).";
Blockly.Msg.MATH_RANDOM_FLOAT_TITLE_RANDOM = "nilai pecahan acak";
Blockly.Msg.MATH_RANDOM_FLOAT_TOOLTIP = "Kembalikan nilai pecahan acak antara 0.0 (inklusif) dan 1.0 (eksklusif).";
Blockly.Msg.MATH_RANDOM_INT_HELPURL = "https://en.wikipedia.org/wiki/Random_number_generation";
Blockly.Msg.MATH_RANDOM_INT_TITLE = "acak bulat dari %1 sampai %2";
Blockly.Msg.MATH_RANDOM_INT_TOOLTIP = "Mengembalikan bilangan acak antara dua batas yang ditentukan, inklusif.";
Blockly.Msg.MATH_RANDOM_INT_TOOLTIP = "Kembalikan bilangan acak antara dua batas yang ditentukan, inklusif.";
Blockly.Msg.MATH_ROUND_HELPURL = "https://en.wikipedia.org/wiki/Rounding";
Blockly.Msg.MATH_ROUND_OPERATOR_ROUND = "membulatkan";
Blockly.Msg.MATH_ROUND_OPERATOR_ROUNDDOWN = "membulatkan kebawah";
Blockly.Msg.MATH_ROUND_OPERATOR_ROUNDUP = "mengumpulkan";
Blockly.Msg.MATH_ROUND_OPERATOR_ROUNDUP = "membulatkan keatas";
Blockly.Msg.MATH_ROUND_TOOLTIP = "Bulatkan suatu bilangan naik atau turun.";
Blockly.Msg.MATH_SINGLE_HELPURL = "https://en.wikipedia.org/wiki/Square_root";
Blockly.Msg.MATH_SINGLE_OP_ABSOLUTE = "mutlak";
@@ -256,12 +256,12 @@ Blockly.Msg.MATH_TRIG_TAN = "tan";
Blockly.Msg.MATH_TRIG_TOOLTIP_ACOS = "Kembalikan acosine dari angka.";
Blockly.Msg.MATH_TRIG_TOOLTIP_ASIN = "Kembalikan asin dari angka.";
Blockly.Msg.MATH_TRIG_TOOLTIP_ATAN = "Kembalikan atan dari angka.";
Blockly.Msg.MATH_TRIG_TOOLTIP_COS = "Kembalikan cos dari derajat (bukan radian).";
Blockly.Msg.MATH_TRIG_TOOLTIP_COS = "Kembalikan cosinus dari derajat (bukan radian).";
Blockly.Msg.MATH_TRIG_TOOLTIP_SIN = "Kembalikan sinus dari derajat (bukan radian).";
Blockly.Msg.MATH_TRIG_TOOLTIP_TAN = "Kembalikan tangen dari derajat (tidak radian).";
Blockly.Msg.MATH_TRIG_TOOLTIP_TAN = "Kembalikan tangen dari derajat (bukan radian).";
Blockly.Msg.ME = "Saya";
Blockly.Msg.NEW_VARIABLE = "Pembolehubah baru...";
Blockly.Msg.NEW_VARIABLE_TITLE = "Nama pembolehubah baru:";
Blockly.Msg.NEW_VARIABLE = "Variabel baru...";
Blockly.Msg.NEW_VARIABLE_TITLE = "Nama variabel baru:";
Blockly.Msg.ORDINAL_NUMBER_SUFFIX = ""; // untranslated
Blockly.Msg.PROCEDURES_ALLOW_STATEMENTS = "memungkinkan pernyataan";
Blockly.Msg.PROCEDURES_BEFORE_PARAMS = "dengan:";
@@ -271,15 +271,15 @@ Blockly.Msg.PROCEDURES_CALLRETURN_HELPURL = "https://en.wikipedia.org/wiki/Proce
Blockly.Msg.PROCEDURES_CALLRETURN_TOOLTIP = "Menjalankan fungsi '%1' yang ditetapkan pengguna dan menggunakan outputnya.";
Blockly.Msg.PROCEDURES_CALL_BEFORE_PARAMS = "dengan:";
Blockly.Msg.PROCEDURES_CREATE_DO = "Buat '%1'";
Blockly.Msg.PROCEDURES_DEFNORETURN_COMMENT = "Describe this function..."; // untranslated
Blockly.Msg.PROCEDURES_DEFNORETURN_COMMENT = "Jelaskan fungsi ini...";
Blockly.Msg.PROCEDURES_DEFNORETURN_DO = ""; // untranslated
Blockly.Msg.PROCEDURES_DEFNORETURN_HELPURL = "https://en.wikipedia.org/wiki/Procedure_%28computer_science%29";
Blockly.Msg.PROCEDURES_DEFNORETURN_PROCEDURE = "buat sesuatu";
Blockly.Msg.PROCEDURES_DEFNORETURN_TITLE = "untuk";
Blockly.Msg.PROCEDURES_DEFNORETURN_TOOLTIP = "Menciptakan sebuah fungsi dengan tiada output.";
Blockly.Msg.PROCEDURES_DEFNORETURN_TOOLTIP = "Buat sebuah fungsi tanpa output.";
Blockly.Msg.PROCEDURES_DEFRETURN_HELPURL = "https://en.wikipedia.org/wiki/Procedure_%28computer_science%29";
Blockly.Msg.PROCEDURES_DEFRETURN_RETURN = "kembali";
Blockly.Msg.PROCEDURES_DEFRETURN_TOOLTIP = "Menciptakan sebuah fungsi dengan satu output.";
Blockly.Msg.PROCEDURES_DEFRETURN_TOOLTIP = "Buat sebuah fungsi dengan satu output.";
Blockly.Msg.PROCEDURES_DEF_DUPLICATE_WARNING = "Peringatan: Fungsi ini memiliki parameter duplikat.";
Blockly.Msg.PROCEDURES_HIGHLIGHT_DEF = "Sorot definisi fungsi";
Blockly.Msg.PROCEDURES_IFRETURN_HELPURL = "http://c2.com/cgi/wiki?GuardClause"; // untranslated
@@ -289,8 +289,9 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "masukan Nama:";
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "Tambahkan masukan ke fungsi.";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "input";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "Menambah, menghapus, atau menyusun ulang masukan untuk fungsi ini.";
Blockly.Msg.REMOVE_COMMENT = "Hapus komentar";
Blockly.Msg.RENAME_VARIABLE = "namai ulang variabel...";
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "Hapus Komentar";
Blockly.Msg.RENAME_VARIABLE = "Ubah nama variabel...";
Blockly.Msg.RENAME_VARIABLE_TITLE = "Ubah nama semua variabel '%1' menjadi:";
Blockly.Msg.TEXT_APPEND_APPENDTEXT = "tambahkan teks";
Blockly.Msg.TEXT_APPEND_HELPURL = "https://github.com/google/blockly/wiki/Text#text-modification"; // untranslated
@@ -322,7 +323,7 @@ Blockly.Msg.TEXT_GET_SUBSTRING_START_FIRST = "ambil bagian teks (substring) dari
Blockly.Msg.TEXT_GET_SUBSTRING_START_FROM_END = "ambil bagian teks (substring) dari huruf ke # dari terakhir";
Blockly.Msg.TEXT_GET_SUBSTRING_START_FROM_START = "ambil bagian teks (substring) dari huruf no #";
Blockly.Msg.TEXT_GET_SUBSTRING_TAIL = ""; // untranslated
Blockly.Msg.TEXT_GET_SUBSTRING_TOOLTIP = "Mengembalikan spesifik bagian dari teks.";
Blockly.Msg.TEXT_GET_SUBSTRING_TOOLTIP = "Kembalikan spesifik bagian dari teks.";
Blockly.Msg.TEXT_INDEXOF_HELPURL = "https://github.com/google/blockly/wiki/Text#finding-text"; // untranslated
Blockly.Msg.TEXT_INDEXOF_INPUT_INTEXT = "dalam teks";
Blockly.Msg.TEXT_INDEXOF_OPERATOR_FIRST = "temukan kejadian pertama dalam teks";
@@ -331,9 +332,9 @@ Blockly.Msg.TEXT_INDEXOF_TAIL = ""; // untranslated
Blockly.Msg.TEXT_INDEXOF_TOOLTIP = "Kembalikan indeks pertama dan terakhir dari kejadian pertama/terakhir dari teks pertama dalam teks kedua. Kembalikan 0 jika teks tidak ditemukan.";
Blockly.Msg.TEXT_ISEMPTY_HELPURL = "https://github.com/google/blockly/wiki/Text#checking-for-empty-text"; // untranslated
Blockly.Msg.TEXT_ISEMPTY_TITLE = "%1 kosong";
Blockly.Msg.TEXT_ISEMPTY_TOOLTIP = "Kembalikan benar (true) jika teks yang disediakan kosong.";
Blockly.Msg.TEXT_ISEMPTY_TOOLTIP = "Kembalikan benar jika teks yang disediakan kosong.";
Blockly.Msg.TEXT_JOIN_HELPURL = "https://github.com/google/blockly/wiki/Text#text-creation"; // untranslated
Blockly.Msg.TEXT_JOIN_TITLE_CREATEWITH = "Buat teks dengan";
Blockly.Msg.TEXT_JOIN_TITLE_CREATEWITH = "buat teks dengan";
Blockly.Msg.TEXT_JOIN_TOOLTIP = "Buat teks dengan cara gabungkan sejumlah item.";
Blockly.Msg.TEXT_LENGTH_HELPURL = "https://github.com/google/blockly/wiki/Text#text-modification"; // untranslated
Blockly.Msg.TEXT_LENGTH_TITLE = "panjang dari %1";
@@ -354,12 +355,13 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "pangkas ruang dari sisi kiri";
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "pangkas ruang dari sisi kanan";
Blockly.Msg.TEXT_TRIM_TOOLTIP = "Kembali salinan teks dengan spasi dihapus dari satu atau kedua ujungnya.";
Blockly.Msg.TODAY = "Hari ini";
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "item";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "Membuat 'tetapkan %1'";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "Buat 'set %1'";
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get"; // untranslated
Blockly.Msg.VARIABLES_GET_TOOLTIP = "Mengembalikan nilai variabel ini.";
Blockly.Msg.VARIABLES_GET_TOOLTIP = "Kembalikan nilai variabel ini.";
Blockly.Msg.VARIABLES_SET = "tetapkan %1 untuk %2";
Blockly.Msg.VARIABLES_SET_CREATE_GET = "Membuat 'dapatkan %1'";
Blockly.Msg.VARIABLES_SET_CREATE_GET = "Buat 'get %1'";
Blockly.Msg.VARIABLES_SET_HELPURL = "https://github.com/google/blockly/wiki/Variables#set"; // untranslated
Blockly.Msg.VARIABLES_SET_TOOLTIP = "tetapkan variabel ini dengan input yang sama.";
Blockly.Msg.PROCEDURES_DEFRETURN_TITLE = Blockly.Msg.PROCEDURES_DEFNORETURN_TITLE;
+2
View File
@@ -289,6 +289,7 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "heiti inntaks:";
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "Bæta inntaki við fallið.";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "inntök";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "Bæta við, fjarlægja eða umraða inntökum fyrir þetta fall.";
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "Fjarlægja skýringu";
Blockly.Msg.RENAME_VARIABLE = "Endurnefna breytu...";
Blockly.Msg.RENAME_VARIABLE_TITLE = "Endurnefna allar '%1' breyturnar:";
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "eyða bilum vinstra megin við";
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "eyða bilum hægra megin við";
Blockly.Msg.TEXT_TRIM_TOOLTIP = "Skila afriti af textanum þar sem möguleg bil við báða enda hafa verið fjarlægð.";
Blockly.Msg.TODAY = "Í dag";
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "atriði";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "Búa til 'stilla %1'";
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get";
+2
View File
@@ -289,6 +289,7 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "nome inputː";
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "Aggiungi un input alla funzione.";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "input";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "Aggiungi, rimuovi o riordina input alla funzione.";
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "Rimuovi commento";
Blockly.Msg.RENAME_VARIABLE = "Rinomina variabile...";
Blockly.Msg.RENAME_VARIABLE_TITLE = "Rinomina tutte le variabili '%1' in:";
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "rimuovi spazi a sinistra";
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "rimuovi spazi a destra";
Blockly.Msg.TEXT_TRIM_TOOLTIP = "Restituisce una copia del testo con gli spazi rimossi ad uno o entrambe le estremità.";
Blockly.Msg.TODAY = "Oggi";
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "elemento";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "Crea 'imposta %1'";
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get"; // untranslated
+2
View File
@@ -289,6 +289,7 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "入力名:";
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "Add an input to the function."; // untranslated
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "入力";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "Add, remove, or reorder inputs to this function."; // untranslated
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "コメントを削除";
Blockly.Msg.RENAME_VARIABLE = "変数の名前を変更.";
Blockly.Msg.RENAME_VARIABLE_TITLE = "%1の変数すべてを名前変更します。";
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "左端のスペースを取り除く";
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "右端のスペースを取り除く";
Blockly.Msg.TEXT_TRIM_TOOLTIP = "スペースを 1 つまたは両方の端から削除したのち、テキストのコピーを返します。";
Blockly.Msg.TODAY = "今日";
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "項目";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "'セット%1を作成します。";
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get"; // untranslated
+2
View File
@@ -289,6 +289,7 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "매개 변수:";
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "함수에 값을 더합니다.";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "매개 변수들";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "이 함수를 추가, 삭제, 혹은 재정렬합니다.";
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "내용 제거";
Blockly.Msg.RENAME_VARIABLE = "변수 이름 바꾸기:";
Blockly.Msg.RENAME_VARIABLE_TITLE = "'%1' 변수 이름을 바꾸기:";
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "왼쪽의 공백 문자 제거";
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "오른쪽의 공백 문자 제거";
Blockly.Msg.TEXT_TRIM_TOOLTIP = "문장의 왼쪽/오른쪽/양쪽에서 스페이스 문자를 제거해 돌려줍니다.";
Blockly.Msg.TODAY = "오늘";
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "항목";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "'집합 %1' 생성";
Blockly.Msg.VARIABLES_GET_HELPURL = "https://ko.wikipedia.org/wiki/%EB%B3%80%EC%88%98_(%EC%BB%B4%ED%93%A8%ED%84%B0_%EA%B3%BC%ED%95%99)";
+2
View File
@@ -289,6 +289,7 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "input name:"; // untranslated
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "Add an input to the function."; // untranslated
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "inputs"; // untranslated
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "Add, remove, or reorder inputs to this function."; // untranslated
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "Bemierkunge ewechhuelen";
Blockly.Msg.RENAME_VARIABLE = "Variabel ëmbenennen...";
Blockly.Msg.RENAME_VARIABLE_TITLE = "All '%1' Variabelen ëmbenennen op:";
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "trim spaces from left side of"; // untra
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "trim spaces from right side of"; // untranslated
Blockly.Msg.TEXT_TRIM_TOOLTIP = "Return a copy of the text with spaces removed from one or both ends."; // untranslated
Blockly.Msg.TODAY = "Haut";
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "Element";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "Create 'set %1'"; // untranslated
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get"; // untranslated
+2
View File
@@ -289,6 +289,7 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "نام ورودی:";
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "اضافه کردن ورودی به تابع.";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "ورودی‌ها";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "افزودن، حذف یا دوباره مرتب‌کردن ورودی این تابع.";
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "پاک کردن گةپةل/قِسةل";
Blockly.Msg.RENAME_VARIABLE = "تغییر نام متغیر...";
Blockly.Msg.RENAME_VARIABLE_TITLE = "تغییر نام همهٔ متغیرهای «%1» به:";
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "تراشیدن فاصله‌ها از ط
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "تراشیدن فاصله‌ها از طرف چپ";
Blockly.Msg.TEXT_TRIM_TOOLTIP = "کپی از متن با فاصله‌های حذف‌شده از یک یا هر دو پایان باز می‌گرداند.";
Blockly.Msg.TODAY = "ایمڕۆ";
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "آیتم";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "درست‌کردن «تنظیم %1»";
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get"; // untranslated
+2
View File
@@ -289,6 +289,7 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "نوم داده:";
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "Add an input to the function."; // untranslated
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "داده یا";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "Add, remove, or reorder inputs to this function."; // untranslated
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "نظر جا وه جا کو";
Blockly.Msg.RENAME_VARIABLE = "د نو نوم نیائن آلشتگر...";
Blockly.Msg.RENAME_VARIABLE_TITLE = "د نو نوم نیائن %1 د تموم آلشتگریا د:";
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "trim spaces from left side of"; // untra
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "trim spaces from right side of"; // untranslated
Blockly.Msg.TEXT_TRIM_TOOLTIP = "Return a copy of the text with spaces removed from one or both ends."; // untranslated
Blockly.Msg.TODAY = "ئمروٙ";
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "قلم";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "Create 'set %1'"; // untranslated
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get"; // untranslated
+3 -1
View File
@@ -62,7 +62,7 @@ Blockly.Msg.CONTROLS_WHILEUNTIL_OPERATOR_UNTIL = "kartok, kol pasieksi";
Blockly.Msg.CONTROLS_WHILEUNTIL_OPERATOR_WHILE = "kartok kol";
Blockly.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL = "Kartoja veiksmus, kol bus pasiekta nurodyta sąlyga.";
Blockly.Msg.CONTROLS_WHILEUNTIL_TOOLTIP_WHILE = "Kartoja veiksmus, kol sąlyga tenkinama.";
Blockly.Msg.DELETE_ALL_BLOCKS = "Delete all %1 blocks?"; // untranslated
Blockly.Msg.DELETE_ALL_BLOCKS = "Ištrinti visus %1 blokus?";
Blockly.Msg.DELETE_BLOCK = "Ištrinti bloką";
Blockly.Msg.DELETE_X_BLOCKS = "Ištrinti %1 blokus";
Blockly.Msg.DISABLE_BLOCK = "Išjungti bloką";
@@ -289,6 +289,7 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "parametro pavadinimas:";
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "Pridėti funkcijos parametrą (gaunamų duomenų pavadinimą).";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "gaunami duomenys (parametrai)";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "Tvarkyti komandos gaunamus duomenis (parametrus).";
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "Pašalinti komentarą";
Blockly.Msg.RENAME_VARIABLE = "Pervardyti kintamajį...";
Blockly.Msg.RENAME_VARIABLE_TITLE = "Pervadinti visus '%1' kintamuosius į:";
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "išvalyk tarpus pradžioje";
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "išvalyk tarpus pabaigoje";
Blockly.Msg.TEXT_TRIM_TOOLTIP = "Return a copy of the text with spaces removed from one or both ends."; // untranslated
Blockly.Msg.TODAY = "Šiandien";
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "elementas";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "Sukurk \"priskirk %1\"";
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get"; // untranslated
+2
View File
@@ -289,6 +289,7 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "input name:"; // untranslated
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "Add an input to the function."; // untranslated
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "inputs"; // untranslated
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "Add, remove, or reorder inputs to this function."; // untranslated
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "Отстрани коментар";
Blockly.Msg.RENAME_VARIABLE = "Преименувај променлива...";
Blockly.Msg.RENAME_VARIABLE_TITLE = "Преименувај ги сите променливи „%1“ во:";
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "trim spaces from left side of"; // untra
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "trim spaces from right side of"; // untranslated
Blockly.Msg.TEXT_TRIM_TOOLTIP = "Return a copy of the text with spaces removed from one or both ends."; // untranslated
Blockly.Msg.TODAY = "Today"; // untranslated
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "елемент";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "Create 'set %1'"; // untranslated
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get"; // untranslated
+2
View File
@@ -289,6 +289,7 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "Nama input:";
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "Tambah satu input pada fungsi.";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "Input-input";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "Tambah, alih keluar atau susun semula input pada fungsi ini.";
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "Padamkan Komen";
Blockly.Msg.RENAME_VARIABLE = "Tukar nama pembolehubah...";
Blockly.Msg.RENAME_VARIABLE_TITLE = "Tukar nama semua pembolehubah '%1' kepada:";
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "mengurangkan ruang dari sebelah kiri";
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "mengurangkan kawasan dari sisi kanan";
Blockly.Msg.TEXT_TRIM_TOOLTIP = "Kembali salinan teks dengan ruang yang dikeluarkan daripada satu atau hujung kedua belah.";
Blockly.Msg.TODAY = "Hari ini";
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "Perkara";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "Hasilkan 'set %1'";
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get"; // untranslated
+2
View File
@@ -289,6 +289,7 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "Navn på parameter:";
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "Legg til en input til funksjonen.";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "parametere";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "Legg til, fjern eller endre rekkefølgen på input til denne funksjonen.";
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "Fjern kommentar";
Blockly.Msg.RENAME_VARIABLE = "Gi nytt navn til variabel...";
Blockly.Msg.RENAME_VARIABLE_TITLE = "Endre navnet til alle '%1' variabler til:";
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "fjern mellomrom fra venstre side av";
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "fjern mellomrom fra høyre side av";
Blockly.Msg.TEXT_TRIM_TOOLTIP = "Returner en kopi av teksten med mellomrom fjernet fra en eller begge sidene.";
Blockly.Msg.TODAY = "I dag";
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "element";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "Opprett 'sett %1'";
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get"; // untranslated
+2
View File
@@ -289,6 +289,7 @@ Blockly.Msg.PROCEDURES_MUTATORARG_TITLE = "invoernaam:";
Blockly.Msg.PROCEDURES_MUTATORARG_TOOLTIP = "Een invoer aan de functie toevoegen.";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TITLE = "ingangen";
Blockly.Msg.PROCEDURES_MUTATORCONTAINER_TOOLTIP = "Invoer van deze functie toevoegen, verwijderen of herordenen.";
Blockly.Msg.REDO = "Redo"; // untranslated
Blockly.Msg.REMOVE_COMMENT = "Opmerking verwijderen";
Blockly.Msg.RENAME_VARIABLE = "Variabele hernoemen...";
Blockly.Msg.RENAME_VARIABLE_TITLE = "Alle variabelen \"%1\" hernoemen naar:";
@@ -354,6 +355,7 @@ Blockly.Msg.TEXT_TRIM_OPERATOR_LEFT = "spaties van de linkerkant verwijderen van
Blockly.Msg.TEXT_TRIM_OPERATOR_RIGHT = "spaties van de rechterkant verwijderen van";
Blockly.Msg.TEXT_TRIM_TOOLTIP = "Geeft een kopie van de tekst met verwijderde spaties van één of beide kanten.";
Blockly.Msg.TODAY = "Vandaag";
Blockly.Msg.UNDO = "Undo"; // untranslated
Blockly.Msg.VARIABLES_DEFAULT_NAME = "item";
Blockly.Msg.VARIABLES_GET_CREATE_SET = "Maak \"verander %1\"";
Blockly.Msg.VARIABLES_GET_HELPURL = "https://github.com/google/blockly/wiki/Variables#get";

Some files were not shown because too many files have changed in this diff Show More