2017-09-25 09:37:41 +00:00
// Do not edit this file; automatically generated by build.py.
'use strict' ;
2018-08-17 13:32:56 +00:00
Blockly . Blocks . colour = { } ; Blockly . Constants = { } ; Blockly . Constants . Colour = { } ; Blockly . Constants . Colour . HUE = 20 ;
2018-01-16 21:13:23 +00:00
Blockly . defineBlocksWithJsonArray ( [ { type : "colour_picker" , message0 : "%1" , args0 : [ { type : "field_colour" , name : "COLOUR" , colour : "#ff0000" } ] , output : "Colour" , colour : "%{BKY_COLOUR_HUE}" , helpUrl : "%{BKY_COLOUR_PICKER_HELPURL}" , tooltip : "%{BKY_COLOUR_PICKER_TOOLTIP}" , extensions : [ "parent_tooltip_when_inline" ] } , { type : "colour_random" , message0 : "%{BKY_COLOUR_RANDOM_TITLE}" , output : "Colour" , colour : "%{BKY_COLOUR_HUE}" , helpUrl : "%{BKY_COLOUR_RANDOM_HELPURL}" , tooltip : "%{BKY_COLOUR_RANDOM_TOOLTIP}" } , { type : "colour_rgb" , message0 : "%{BKY_COLOUR_RGB_TITLE} %{BKY_COLOUR_RGB_RED} %1 %{BKY_COLOUR_RGB_GREEN} %2 %{BKY_COLOUR_RGB_BLUE} %3" ,
args0 : [ { type : "input_value" , name : "RED" , check : "Number" , align : "RIGHT" } , { type : "input_value" , name : "GREEN" , check : "Number" , align : "RIGHT" } , { type : "input_value" , name : "BLUE" , check : "Number" , align : "RIGHT" } ] , output : "Colour" , colour : "%{BKY_COLOUR_HUE}" , helpUrl : "%{BKY_COLOUR_RGB_HELPURL}" , tooltip : "%{BKY_COLOUR_RGB_TOOLTIP}" } , { type : "colour_blend" , message0 : "%{BKY_COLOUR_BLEND_TITLE} %{BKY_COLOUR_BLEND_COLOUR1} %1 %{BKY_COLOUR_BLEND_COLOUR2} %2 %{BKY_COLOUR_BLEND_RATIO} %3" , args0 : [ { type : "input_value" , name : "COLOUR1" ,
2018-08-17 13:32:56 +00:00
check : "Colour" , align : "RIGHT" } , { type : "input_value" , name : "COLOUR2" , check : "Colour" , align : "RIGHT" } , { type : "input_value" , name : "RATIO" , check : "Number" , align : "RIGHT" } ] , output : "Colour" , colour : "%{BKY_COLOUR_HUE}" , helpUrl : "%{BKY_COLOUR_BLEND_HELPURL}" , tooltip : "%{BKY_COLOUR_BLEND_TOOLTIP}" } ] ) ; Blockly . Blocks . lists = { } ; Blockly . Constants . Lists = { } ; Blockly . Constants . Lists . HUE = 260 ;
2018-01-16 21:13:23 +00:00
Blockly . defineBlocksWithJsonArray ( [ { type : "lists_create_empty" , message0 : "%{BKY_LISTS_CREATE_EMPTY_TITLE}" , output : "Array" , colour : "%{BKY_LISTS_HUE}" , tooltip : "%{BKY_LISTS_CREATE_EMPTY_TOOLTIP}" , helpUrl : "%{BKY_LISTS_CREATE_EMPTY_HELPURL}" } , { type : "lists_repeat" , message0 : "%{BKY_LISTS_REPEAT_TITLE}" , args0 : [ { type : "input_value" , name : "ITEM" } , { type : "input_value" , name : "NUM" , check : "Number" } ] , output : "Array" , colour : "%{BKY_LISTS_HUE}" , tooltip : "%{BKY_LISTS_REPEAT_TOOLTIP}" , helpUrl : "%{BKY_LISTS_REPEAT_HELPURL}" } , { type : "lists_reverse" ,
message0 : "%{BKY_LISTS_REVERSE_MESSAGE0}" , args0 : [ { type : "input_value" , name : "LIST" , check : "Array" } ] , output : "Array" , inputsInline : ! 0 , colour : "%{BKY_LISTS_HUE}" , tooltip : "%{BKY_LISTS_REVERSE_TOOLTIP}" , helpUrl : "%{BKY_LISTS_REVERSE_HELPURL}" } , { type : "lists_isEmpty" , message0 : "%{BKY_LISTS_ISEMPTY_TITLE}" , args0 : [ { type : "input_value" , name : "VALUE" , check : [ "String" , "Array" ] } ] , output : "Boolean" , colour : "%{BKY_LISTS_HUE}" , tooltip : "%{BKY_LISTS_ISEMPTY_TOOLTIP}" , helpUrl : "%{BKY_LISTS_ISEMPTY_HELPURL}" } , { type : "lists_length" ,
message0 : "%{BKY_LISTS_LENGTH_TITLE}" , args0 : [ { type : "input_value" , name : "VALUE" , check : [ "String" , "Array" ] } ] , output : "Number" , colour : "%{BKY_LISTS_HUE}" , tooltip : "%{BKY_LISTS_LENGTH_TOOLTIP}" , helpUrl : "%{BKY_LISTS_LENGTH_HELPURL}" } ] ) ;
2018-08-17 13:32:56 +00:00
Blockly . Blocks . lists _create _with = { init : function ( ) { this . setHelpUrl ( Blockly . Msg . LISTS _CREATE _WITH _HELPURL ) ; this . setColour ( Blockly . Msg . 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" ) ,
2018-01-16 21:13:23 +00:00
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 ;
2017-09-25 09:37:41 +00:00
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 ++ } } ;
2018-08-17 13:32:56 +00:00
Blockly . Blocks . lists _create _with _container = { init : function ( ) { this . setColour ( Blockly . Msg . 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 . Msg . 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 _indexOf = { init : function ( ) { var a = [ [ Blockly . Msg . LISTS _INDEX _OF _FIRST , "FIRST" ] , [ Blockly . Msg . LISTS _INDEX _OF _LAST , "LAST" ] ] ; this . setHelpUrl ( Blockly . Msg . LISTS _INDEX _OF _HELPURL ) ; this . setColour ( Blockly . Msg . LISTS _HUE ) ; this . setOutput ( ! 0 , "Number" ) ; this . appendValueInput ( "VALUE" ) . setCheck ( "Array" ) . appendField ( Blockly . Msg . LISTS _INDEX _OF _INPUT _IN _LIST ) ; this . appendValueInput ( "FIND" ) . appendField ( new Blockly . FieldDropdown ( a ) , "END" ) ; this . setInputsInline ( ! 0 ) ; var b = this ; this . setTooltip ( function ( ) { return Blockly . Msg . LISTS _INDEX _OF _TOOLTIP . replace ( "%1" ,
2018-01-16 21:13:23 +00:00
b . workspace . options . oneBasedIndex ? "0" : "-1" ) } ) } } ;
2018-08-17 13:32:56 +00:00
Blockly . Blocks . lists _getIndex = { init : function ( ) { var a = [ [ Blockly . Msg . LISTS _GET _INDEX _GET , "GET" ] , [ Blockly . Msg . LISTS _GET _INDEX _GET _REMOVE , "GET_REMOVE" ] , [ Blockly . Msg . LISTS _GET _INDEX _REMOVE , "REMOVE" ] ] ; this . WHERE _OPTIONS = [ [ Blockly . Msg . LISTS _GET _INDEX _FROM _START , "FROM_START" ] , [ Blockly . Msg . LISTS _GET _INDEX _FROM _END , "FROM_END" ] , [ Blockly . Msg . LISTS _GET _INDEX _FIRST , "FIRST" ] , [ Blockly . Msg . LISTS _GET _INDEX _LAST , "LAST" ] , [ Blockly . Msg . LISTS _GET _INDEX _RANDOM , "RANDOM" ] ] ; this . setHelpUrl ( Blockly . Msg . LISTS _GET _INDEX _HELPURL ) ; this . setColour ( Blockly . Msg . LISTS _HUE ) ;
2018-01-16 21:13:23 +00:00
a = new Blockly . FieldDropdown ( a , function ( a ) { this . sourceBlock _ . updateStatement _ ( "REMOVE" == a ) } ) ; this . appendValueInput ( "VALUE" ) . setCheck ( "Array" ) . appendField ( Blockly . Msg . LISTS _GET _INDEX _INPUT _IN _LIST ) ; this . appendDummyInput ( ) . appendField ( a , "MODE" ) . appendField ( "" , "SPACE" ) ; this . appendDummyInput ( "AT" ) ; Blockly . Msg . LISTS _GET _INDEX _TAIL && this . appendDummyInput ( "TAIL" ) . appendField ( Blockly . Msg . LISTS _GET _INDEX _TAIL ) ; this . setInputsInline ( ! 0 ) ; this . setOutput ( ! 0 ) ; this . updateAt _ ( ! 0 ) ; var b = this ; this . setTooltip ( function ( ) { var a =
b . getFieldValue ( "MODE" ) , d = b . getFieldValue ( "WHERE" ) , e = "" ; switch ( a + " " + d ) { case "GET FROM_START" : case "GET FROM_END" : e = Blockly . Msg . LISTS _GET _INDEX _TOOLTIP _GET _FROM ; break ; case "GET FIRST" : e = Blockly . Msg . LISTS _GET _INDEX _TOOLTIP _GET _FIRST ; break ; case "GET LAST" : e = Blockly . Msg . LISTS _GET _INDEX _TOOLTIP _GET _LAST ; break ; case "GET RANDOM" : e = Blockly . Msg . LISTS _GET _INDEX _TOOLTIP _GET _RANDOM ; break ; case "GET_REMOVE FROM_START" : case "GET_REMOVE FROM_END" : e = Blockly . Msg . LISTS _GET _INDEX _TOOLTIP _GET _REMOVE _FROM ; break ; case "GET_REMOVE FIRST" : e =
Blockly . Msg . LISTS _GET _INDEX _TOOLTIP _GET _REMOVE _FIRST ; break ; case "GET_REMOVE LAST" : e = Blockly . Msg . LISTS _GET _INDEX _TOOLTIP _GET _REMOVE _LAST ; break ; case "GET_REMOVE RANDOM" : e = Blockly . Msg . LISTS _GET _INDEX _TOOLTIP _GET _REMOVE _RANDOM ; break ; case "REMOVE FROM_START" : case "REMOVE FROM_END" : e = Blockly . Msg . LISTS _GET _INDEX _TOOLTIP _REMOVE _FROM ; break ; case "REMOVE FIRST" : e = Blockly . Msg . LISTS _GET _INDEX _TOOLTIP _REMOVE _FIRST ; break ; case "REMOVE LAST" : e = Blockly . Msg . LISTS _GET _INDEX _TOOLTIP _REMOVE _LAST ; break ; case "REMOVE RANDOM" : e =
Blockly . Msg . LISTS _GET _INDEX _TOOLTIP _REMOVE _RANDOM } if ( "FROM_START" == d || "FROM_END" == d ) e += " " + ( "FROM_START" == d ? Blockly . Msg . LISTS _INDEX _FROM _START _TOOLTIP : Blockly . Msg . LISTS _INDEX _FROM _END _TOOLTIP ) . replace ( "%1" , b . workspace . options . oneBasedIndex ? "#1" : "#0" ) ; return e } ) } , mutationToDom : function ( ) { var a = document . createElement ( "mutation" ) ; a . setAttribute ( "statement" , ! this . outputConnection ) ; var b = this . getInput ( "AT" ) . type == Blockly . INPUT _VALUE ; a . setAttribute ( "at" , b ) ; return a } , domToMutation : function ( a ) { var b = "true" ==
a . getAttribute ( "statement" ) ; this . updateStatement _ ( b ) ; a = "false" != a . getAttribute ( "at" ) ; this . updateAt _ ( a ) } , updateStatement _ : function ( a ) { a != ! this . outputConnection && ( this . unplug ( ! 0 , ! 0 ) , a ? ( this . setOutput ( ! 1 ) , this . setPreviousStatement ( ! 0 ) , this . setNextStatement ( ! 0 ) ) : ( this . setPreviousStatement ( ! 1 ) , this . setNextStatement ( ! 1 ) , this . setOutput ( ! 0 ) ) ) } , updateAt _ : function ( a ) { this . removeInput ( "AT" ) ; this . removeInput ( "ORDINAL" , ! 0 ) ; a ? ( this . appendValueInput ( "AT" ) . setCheck ( "Number" ) , Blockly . Msg . ORDINAL _NUMBER _SUFFIX && this . appendDummyInput ( "ORDINAL" ) . appendField ( Blockly . Msg . ORDINAL _NUMBER _SUFFIX ) ) :
this . appendDummyInput ( "AT" ) ; var b = new Blockly . FieldDropdown ( this . WHERE _OPTIONS , function ( b ) { var c = "FROM_START" == b || "FROM_END" == b ; if ( c != a ) { var e = this . sourceBlock _ ; e . updateAt _ ( c ) ; e . setFieldValue ( b , "WHERE" ) ; return null } } ) ; this . getInput ( "AT" ) . appendField ( b , "WHERE" ) ; Blockly . Msg . LISTS _GET _INDEX _TAIL && this . moveInputBefore ( "TAIL" , null ) } } ;
2018-08-17 13:32:56 +00:00
Blockly . Blocks . lists _setIndex = { init : function ( ) { var a = [ [ Blockly . Msg . LISTS _SET _INDEX _SET , "SET" ] , [ Blockly . Msg . LISTS _SET _INDEX _INSERT , "INSERT" ] ] ; this . WHERE _OPTIONS = [ [ Blockly . Msg . LISTS _GET _INDEX _FROM _START , "FROM_START" ] , [ Blockly . Msg . LISTS _GET _INDEX _FROM _END , "FROM_END" ] , [ Blockly . Msg . LISTS _GET _INDEX _FIRST , "FIRST" ] , [ Blockly . Msg . LISTS _GET _INDEX _LAST , "LAST" ] , [ Blockly . Msg . LISTS _GET _INDEX _RANDOM , "RANDOM" ] ] ; this . setHelpUrl ( Blockly . Msg . LISTS _SET _INDEX _HELPURL ) ; this . setColour ( Blockly . Msg . LISTS _HUE ) ; this . appendValueInput ( "LIST" ) . setCheck ( "Array" ) . appendField ( Blockly . Msg . LISTS _SET _INDEX _INPUT _IN _LIST ) ;
2018-01-16 21:13:23 +00:00
this . appendDummyInput ( ) . appendField ( new Blockly . FieldDropdown ( a ) , "MODE" ) . appendField ( "" , "SPACE" ) ; this . appendDummyInput ( "AT" ) ; this . appendValueInput ( "TO" ) . appendField ( Blockly . Msg . LISTS _SET _INDEX _INPUT _TO ) ; this . setInputsInline ( ! 0 ) ; this . setPreviousStatement ( ! 0 ) ; this . setNextStatement ( ! 0 ) ; this . setTooltip ( Blockly . Msg . LISTS _SET _INDEX _TOOLTIP ) ; this . updateAt _ ( ! 0 ) ; var b = this ; this . setTooltip ( function ( ) { var a = b . getFieldValue ( "MODE" ) , d = b . getFieldValue ( "WHERE" ) , e = "" ; switch ( a + " " + d ) { case "SET FROM_START" : case "SET FROM_END" : e =
Blockly . Msg . LISTS _SET _INDEX _TOOLTIP _SET _FROM ; break ; case "SET FIRST" : e = Blockly . Msg . LISTS _SET _INDEX _TOOLTIP _SET _FIRST ; break ; case "SET LAST" : e = Blockly . Msg . LISTS _SET _INDEX _TOOLTIP _SET _LAST ; break ; case "SET RANDOM" : e = Blockly . Msg . LISTS _SET _INDEX _TOOLTIP _SET _RANDOM ; break ; case "INSERT FROM_START" : case "INSERT FROM_END" : e = Blockly . Msg . LISTS _SET _INDEX _TOOLTIP _INSERT _FROM ; break ; case "INSERT FIRST" : e = Blockly . Msg . LISTS _SET _INDEX _TOOLTIP _INSERT _FIRST ; break ; case "INSERT LAST" : e = Blockly . Msg . LISTS _SET _INDEX _TOOLTIP _INSERT _LAST ;
break ; case "INSERT RANDOM" : e = Blockly . Msg . LISTS _SET _INDEX _TOOLTIP _INSERT _RANDOM } if ( "FROM_START" == d || "FROM_END" == d ) e += " " + Blockly . Msg . LISTS _INDEX _FROM _START _TOOLTIP . replace ( "%1" , b . workspace . options . oneBasedIndex ? "#1" : "#0" ) ; return e } ) } , mutationToDom : function ( ) { var a = document . createElement ( "mutation" ) , b = this . getInput ( "AT" ) . type == Blockly . INPUT _VALUE ; a . setAttribute ( "at" , b ) ; return a } , domToMutation : function ( a ) { a = "false" != a . getAttribute ( "at" ) ; this . updateAt _ ( a ) } , updateAt _ : function ( a ) { this . removeInput ( "AT" ) ;
this . removeInput ( "ORDINAL" , ! 0 ) ; a ? ( this . appendValueInput ( "AT" ) . setCheck ( "Number" ) , Blockly . Msg . ORDINAL _NUMBER _SUFFIX && this . appendDummyInput ( "ORDINAL" ) . appendField ( Blockly . Msg . ORDINAL _NUMBER _SUFFIX ) ) : this . appendDummyInput ( "AT" ) ; var b = new Blockly . FieldDropdown ( this . WHERE _OPTIONS , function ( b ) { var c = "FROM_START" == b || "FROM_END" == b ; if ( c != a ) { var e = this . sourceBlock _ ; e . updateAt _ ( c ) ; e . setFieldValue ( b , "WHERE" ) ; return null } } ) ; this . moveInputBefore ( "AT" , "TO" ) ; this . getInput ( "ORDINAL" ) && this . moveInputBefore ( "ORDINAL" ,
2017-09-25 09:37:41 +00:00
"TO" ) ; this . getInput ( "AT" ) . appendField ( b , "WHERE" ) } } ;
2018-08-17 13:32:56 +00:00
Blockly . Blocks . lists _getSublist = { init : function ( ) { this . WHERE _OPTIONS _1 = [ [ Blockly . Msg . LISTS _GET _SUBLIST _START _FROM _START , "FROM_START" ] , [ Blockly . Msg . LISTS _GET _SUBLIST _START _FROM _END , "FROM_END" ] , [ Blockly . Msg . LISTS _GET _SUBLIST _START _FIRST , "FIRST" ] ] ; this . WHERE _OPTIONS _2 = [ [ Blockly . Msg . LISTS _GET _SUBLIST _END _FROM _START , "FROM_START" ] , [ Blockly . Msg . LISTS _GET _SUBLIST _END _FROM _END , "FROM_END" ] , [ Blockly . Msg . LISTS _GET _SUBLIST _END _LAST , "LAST" ] ] ; this . setHelpUrl ( Blockly . Msg . LISTS _GET _SUBLIST _HELPURL ) ; this . setColour ( Blockly . Msg . LISTS _HUE ) ;
2017-09-25 09:37:41 +00:00
this . appendValueInput ( "LIST" ) . setCheck ( "Array" ) . appendField ( Blockly . Msg . LISTS _GET _SUBLIST _INPUT _IN _LIST ) ; this . appendDummyInput ( "AT1" ) ; this . appendDummyInput ( "AT2" ) ; Blockly . Msg . LISTS _GET _SUBLIST _TAIL && this . appendDummyInput ( "TAIL" ) . appendField ( Blockly . Msg . LISTS _GET _SUBLIST _TAIL ) ; this . setInputsInline ( ! 0 ) ; this . setOutput ( ! 0 , "Array" ) ; this . updateAt _ ( 1 , ! 0 ) ; this . updateAt _ ( 2 , ! 0 ) ; this . setTooltip ( Blockly . Msg . LISTS _GET _SUBLIST _TOOLTIP ) } , mutationToDom : function ( ) { var a = document . createElement ( "mutation" ) , b = this . getInput ( "AT1" ) . type ==
Blockly . INPUT _VALUE ; a . setAttribute ( "at1" , b ) ; b = this . getInput ( "AT2" ) . type == Blockly . INPUT _VALUE ; a . setAttribute ( "at2" , b ) ; return a } , domToMutation : function ( a ) { var b = "true" == a . getAttribute ( "at1" ) ; a = "true" == a . getAttribute ( "at2" ) ; this . updateAt _ ( 1 , b ) ; this . updateAt _ ( 2 , a ) } , updateAt _ : function ( a , b ) { this . removeInput ( "AT" + a ) ; this . removeInput ( "ORDINAL" + a , ! 0 ) ; b ? ( this . appendValueInput ( "AT" + a ) . setCheck ( "Number" ) , Blockly . Msg . ORDINAL _NUMBER _SUFFIX && this . appendDummyInput ( "ORDINAL" + a ) . appendField ( Blockly . Msg . ORDINAL _NUMBER _SUFFIX ) ) :
2018-08-17 13:32:56 +00:00
this . appendDummyInput ( "AT" + a ) ; var c = new Blockly . FieldDropdown ( this [ "WHERE_OPTIONS_" + a ] , function ( c ) { var e = "FROM_START" == c || "FROM_END" == c ; if ( e != b ) { var d = this . sourceBlock _ ; d . updateAt _ ( a , e ) ; d . setFieldValue ( c , "WHERE" + a ) ; return null } } ) ; this . getInput ( "AT" + a ) . appendField ( c , "WHERE" + a ) ; 1 == a && ( this . moveInputBefore ( "AT1" , "AT2" ) , this . getInput ( "ORDINAL1" ) && this . moveInputBefore ( "ORDINAL1" , "AT2" ) ) ; Blockly . Msg . LISTS _GET _SUBLIST _TAIL && this . moveInputBefore ( "TAIL" , null ) } } ;
Blockly . Blocks . lists _sort = { init : function ( ) { this . jsonInit ( { message0 : Blockly . Msg . LISTS _SORT _TITLE , args0 : [ { type : "field_dropdown" , name : "TYPE" , options : [ [ Blockly . Msg . LISTS _SORT _TYPE _NUMERIC , "NUMERIC" ] , [ Blockly . Msg . LISTS _SORT _TYPE _TEXT , "TEXT" ] , [ Blockly . Msg . LISTS _SORT _TYPE _IGNORECASE , "IGNORE_CASE" ] ] } , { type : "field_dropdown" , name : "DIRECTION" , options : [ [ Blockly . Msg . LISTS _SORT _ORDER _ASCENDING , "1" ] , [ Blockly . Msg . LISTS _SORT _ORDER _DESCENDING , "-1" ] ] } , { type : "input_value" , name : "LIST" , check : "Array" } ] , output : "Array" , colour : Blockly . Msg . LISTS _HUE ,
2017-09-25 09:37:41 +00:00
tooltip : Blockly . Msg . LISTS _SORT _TOOLTIP , helpUrl : Blockly . Msg . LISTS _SORT _HELPURL } ) } } ;
2018-08-17 13:32:56 +00:00
Blockly . Blocks . lists _split = { init : function ( ) { var a = this , b = new Blockly . FieldDropdown ( [ [ Blockly . Msg . LISTS _SPLIT _LIST _FROM _TEXT , "SPLIT" ] , [ Blockly . Msg . LISTS _SPLIT _TEXT _FROM _LIST , "JOIN" ] ] , function ( b ) { a . updateType _ ( b ) } ) ; this . setHelpUrl ( Blockly . Msg . LISTS _SPLIT _HELPURL ) ; this . setColour ( Blockly . Msg . LISTS _HUE ) ; this . appendValueInput ( "INPUT" ) . setCheck ( "String" ) . appendField ( b , "MODE" ) ; this . appendValueInput ( "DELIM" ) . setCheck ( "String" ) . appendField ( Blockly . Msg . LISTS _SPLIT _WITH _DELIMITER ) ; this . setInputsInline ( ! 0 ) ; this . setOutput ( ! 0 ,
"Array" ) ; this . setTooltip ( function ( ) { var b = a . getFieldValue ( "MODE" ) ; if ( "SPLIT" == b ) return Blockly . Msg . LISTS _SPLIT _TOOLTIP _SPLIT ; if ( "JOIN" == b ) return Blockly . Msg . LISTS _SPLIT _TOOLTIP _JOIN ; throw "Unknown mode: " + b ; } ) } , updateType _ : function ( a ) { "SPLIT" == a ? ( this . outputConnection . setCheck ( "Array" ) , this . getInput ( "INPUT" ) . setCheck ( "String" ) ) : ( this . outputConnection . setCheck ( "String" ) , this . getInput ( "INPUT" ) . setCheck ( "Array" ) ) } , mutationToDom : function ( ) { var a = document . createElement ( "mutation" ) ; a . setAttribute ( "mode" ,
this . getFieldValue ( "MODE" ) ) ; return a } , domToMutation : function ( a ) { this . updateType _ ( a . getAttribute ( "mode" ) ) } } ; Blockly . Blocks . logic = { } ; Blockly . Constants . Logic = { } ; Blockly . Constants . Logic . HUE = 210 ;
2018-01-16 21:13:23 +00:00
Blockly . defineBlocksWithJsonArray ( [ { type : "logic_boolean" , message0 : "%1" , args0 : [ { type : "field_dropdown" , name : "BOOL" , options : [ [ "%{BKY_LOGIC_BOOLEAN_TRUE}" , "TRUE" ] , [ "%{BKY_LOGIC_BOOLEAN_FALSE}" , "FALSE" ] ] } ] , output : "Boolean" , colour : "%{BKY_LOGIC_HUE}" , tooltip : "%{BKY_LOGIC_BOOLEAN_TOOLTIP}" , helpUrl : "%{BKY_LOGIC_BOOLEAN_HELPURL}" } , { type : "controls_if" , message0 : "%{BKY_CONTROLS_IF_MSG_IF} %1" , args0 : [ { type : "input_value" , name : "IF0" , check : "Boolean" } ] , message1 : "%{BKY_CONTROLS_IF_MSG_THEN} %1" , args1 : [ { type : "input_statement" ,
name : "DO0" } ] , previousStatement : null , nextStatement : null , colour : "%{BKY_LOGIC_HUE}" , helpUrl : "%{BKY_CONTROLS_IF_HELPURL}" , mutator : "controls_if_mutator" , extensions : [ "controls_if_tooltip" ] } , { type : "controls_ifelse" , message0 : "%{BKY_CONTROLS_IF_MSG_IF} %1" , args0 : [ { type : "input_value" , name : "IF0" , check : "Boolean" } ] , message1 : "%{BKY_CONTROLS_IF_MSG_THEN} %1" , args1 : [ { type : "input_statement" , name : "DO0" } ] , message2 : "%{BKY_CONTROLS_IF_MSG_ELSE} %1" , args2 : [ { type : "input_statement" , name : "ELSE" } ] , previousStatement : null , nextStatement : null ,
2018-08-17 13:32:56 +00:00
colour : "%{BKY_LOGIC_HUE}" , tooltip : "%{BKYCONTROLS_IF_TOOLTIP_2}" , helpUrl : "%{BKY_CONTROLS_IF_HELPURL}" , extensions : [ "controls_if_tooltip" ] } , { type : "logic_compare" , message0 : "%1 %2 %3" , args0 : [ { type : "input_value" , name : "A" } , { type : "field_dropdown" , name : "OP" , options : [ [ "=" , "EQ" ] , [ "\u2260" , "NEQ" ] , [ "\u200f<" , "LT" ] , [ "\u200f\u2264" , "LTE" ] , [ "\u200f>" , "GT" ] , [ "\u200f\u2265" , "GTE" ] ] } , { type : "input_value" , name : "B" } ] , inputsInline : ! 0 , output : "Boolean" , colour : "%{BKY_LOGIC_HUE}" , helpUrl : "%{BKY_LOGIC_COMPARE_HELPURL}" , extensions : [ "logic_compare" ,
2018-01-16 21:13:23 +00:00
"logic_op_tooltip" ] } , { type : "logic_operation" , message0 : "%1 %2 %3" , args0 : [ { type : "input_value" , name : "A" , check : "Boolean" } , { type : "field_dropdown" , name : "OP" , options : [ [ "%{BKY_LOGIC_OPERATION_AND}" , "AND" ] , [ "%{BKY_LOGIC_OPERATION_OR}" , "OR" ] ] } , { type : "input_value" , name : "B" , check : "Boolean" } ] , inputsInline : ! 0 , output : "Boolean" , colour : "%{BKY_LOGIC_HUE}" , helpUrl : "%{BKY_LOGIC_OPERATION_HELPURL}" , extensions : [ "logic_op_tooltip" ] } , { type : "logic_negate" , message0 : "%{BKY_LOGIC_NEGATE_TITLE}" , args0 : [ { type : "input_value" , name : "BOOL" ,
check : "Boolean" } ] , output : "Boolean" , colour : "%{BKY_LOGIC_HUE}" , tooltip : "%{BKY_LOGIC_NEGATE_TOOLTIP}" , helpUrl : "%{BKY_LOGIC_NEGATE_HELPURL}" } , { type : "logic_null" , message0 : "%{BKY_LOGIC_NULL}" , output : null , colour : "%{BKY_LOGIC_HUE}" , tooltip : "%{BKY_LOGIC_NULL_TOOLTIP}" , helpUrl : "%{BKY_LOGIC_NULL_HELPURL}" } , { type : "logic_ternary" , message0 : "%{BKY_LOGIC_TERNARY_CONDITION} %1" , args0 : [ { type : "input_value" , name : "IF" , check : "Boolean" } ] , message1 : "%{BKY_LOGIC_TERNARY_IF_TRUE} %1" , args1 : [ { type : "input_value" , name : "THEN" } ] ,
message2 : "%{BKY_LOGIC_TERNARY_IF_FALSE} %1" , args2 : [ { type : "input_value" , name : "ELSE" } ] , output : null , colour : "%{BKY_LOGIC_HUE}" , tooltip : "%{BKY_LOGIC_TERNARY_TOOLTIP}" , helpUrl : "%{BKY_LOGIC_TERNARY_HELPURL}" , extensions : [ "logic_ternary" ] } ] ) ;
Blockly . defineBlocksWithJsonArray ( [ { type : "controls_if_if" , message0 : "%{BKY_CONTROLS_IF_IF_TITLE_IF}" , nextStatement : null , enableContextMenu : ! 1 , colour : "%{BKY_LOGIC_HUE}" , tooltip : "%{BKY_CONTROLS_IF_IF_TOOLTIP}" } , { type : "controls_if_elseif" , message0 : "%{BKY_CONTROLS_IF_ELSEIF_TITLE_ELSEIF}" , previousStatement : null , nextStatement : null , enableContextMenu : ! 1 , colour : "%{BKY_LOGIC_HUE}" , tooltip : "%{BKY_CONTROLS_IF_ELSEIF_TOOLTIP}" } , { type : "controls_if_else" , message0 : "%{BKY_CONTROLS_IF_ELSE_TITLE_ELSE}" , previousStatement : null ,
enableContextMenu : ! 1 , colour : "%{BKY_LOGIC_HUE}" , tooltip : "%{BKY_CONTROLS_IF_ELSE_TOOLTIP}" } ] ) ; Blockly . Constants . Logic . TOOLTIPS _BY _OP = { EQ : "%{BKY_LOGIC_COMPARE_TOOLTIP_EQ}" , NEQ : "%{BKY_LOGIC_COMPARE_TOOLTIP_NEQ}" , LT : "%{BKY_LOGIC_COMPARE_TOOLTIP_LT}" , LTE : "%{BKY_LOGIC_COMPARE_TOOLTIP_LTE}" , GT : "%{BKY_LOGIC_COMPARE_TOOLTIP_GT}" , GTE : "%{BKY_LOGIC_COMPARE_TOOLTIP_GTE}" , AND : "%{BKY_LOGIC_OPERATION_TOOLTIP_AND}" , OR : "%{BKY_LOGIC_OPERATION_TOOLTIP_OR}" } ;
Blockly . Extensions . register ( "logic_op_tooltip" , Blockly . Extensions . buildTooltipForDropdown ( "OP" , Blockly . Constants . Logic . TOOLTIPS _BY _OP ) ) ;
Blockly . Constants . Logic . CONTROLS _IF _MUTATOR _MIXIN = { elseifCount _ : 0 , elseCount _ : 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 ; 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 . Extensions . registerMutator ( "controls_if_mutator" , Blockly . Constants . Logic . CONTROLS _IF _MUTATOR _MIXIN , null , [ "controls_if_elseif" , "controls_if_else" ] ) ;
Blockly . Constants . Logic . CONTROLS _IF _TOOLTIP _EXTENSION = function ( ) { this . setTooltip ( function ( ) { if ( this . elseifCount _ || this . elseCount _ ) { if ( ! this . elseifCount _ && this . elseCount _ ) return Blockly . Msg . CONTROLS _IF _TOOLTIP _2 ; if ( this . elseifCount _ && ! this . elseCount _ ) return Blockly . Msg . CONTROLS _IF _TOOLTIP _3 ; if ( this . elseifCount _ && this . elseCount _ ) return Blockly . Msg . CONTROLS _IF _TOOLTIP _4 } else return Blockly . Msg . CONTROLS _IF _TOOLTIP _1 ; return "" } . bind ( this ) ) } ; Blockly . Extensions . register ( "controls_if_tooltip" , Blockly . Constants . Logic . CONTROLS _IF _TOOLTIP _EXTENSION ) ;
2018-08-17 13:32:56 +00:00
Blockly . Constants . Logic . LOGIC _COMPARE _ONCHANGE _MIXIN = { onchange : function ( a ) { this . prevBlocks _ || ( this . prevBlocks _ = [ null , null ] ) ; var b = this . getInputTargetBlock ( "A" ) , c = this . getInputTargetBlock ( "B" ) ; b && c && ! b . outputConnection . checkType _ ( c . outputConnection ) && ( Blockly . Events . setGroup ( a . group ) , a = this . prevBlocks _ [ 0 ] , a !== b && ( b . unplug ( ) , a && ! a . isShadow ( ) && this . getInput ( "A" ) . connection . connect ( a . outputConnection ) ) , b = this . prevBlocks _ [ 1 ] , b !== c && ( c . unplug ( ) , b && ! b . isShadow ( ) && this . getInput ( "B" ) . connection . connect ( b . outputConnection ) ) ,
this . bumpNeighbours _ ( ) , Blockly . Events . setGroup ( ! 1 ) ) ; this . prevBlocks _ [ 0 ] = this . getInputTargetBlock ( "A" ) ; this . prevBlocks _ [ 1 ] = this . getInputTargetBlock ( "B" ) } } ; Blockly . Constants . Logic . LOGIC _COMPARE _EXTENSION = function ( ) { this . mixin ( Blockly . Constants . Logic . LOGIC _COMPARE _ONCHANGE _MIXIN ) } ; Blockly . Extensions . register ( "logic_compare" , Blockly . Constants . Logic . LOGIC _COMPARE _EXTENSION ) ;
2018-01-16 21:13:23 +00:00
Blockly . Constants . Logic . LOGIC _TERNARY _ONCHANGE _MIXIN = { prevParentConnection _ : null , onchange : function ( a ) { var b = this . getInputTargetBlock ( "THEN" ) , c = this . getInputTargetBlock ( "ELSE" ) , d = this . outputConnection . targetConnection ; if ( ( b || c ) && d ) for ( var e = 0 ; 2 > e ; e ++ ) { var f = 1 == e ? b : c ; f && ! f . outputConnection . checkType _ ( d ) && ( Blockly . Events . setGroup ( a . group ) , d === this . prevParentConnection _ ? ( this . unplug ( ) , d . getSourceBlock ( ) . bumpNeighbours _ ( ) ) : ( f . unplug ( ) , f . bumpNeighbours _ ( ) ) , Blockly . Events . setGroup ( ! 1 ) ) } this . prevParentConnection _ =
2018-08-17 13:32:56 +00:00
d } } ; Blockly . Extensions . registerMixin ( "logic_ternary" , Blockly . Constants . Logic . LOGIC _TERNARY _ONCHANGE _MIXIN ) ; Blockly . Blocks . loops = { } ; Blockly . Constants . Loops = { } ; Blockly . Constants . Loops . HUE = 120 ;
2018-01-16 21:13:23 +00:00
Blockly . defineBlocksWithJsonArray ( [ { type : "controls_repeat_ext" , message0 : "%{BKY_CONTROLS_REPEAT_TITLE}" , args0 : [ { type : "input_value" , name : "TIMES" , check : "Number" } ] , message1 : "%{BKY_CONTROLS_REPEAT_INPUT_DO} %1" , args1 : [ { type : "input_statement" , name : "DO" } ] , previousStatement : null , nextStatement : null , colour : "%{BKY_LOOPS_HUE}" , tooltip : "%{BKY_CONTROLS_REPEAT_TOOLTIP}" , helpUrl : "%{BKY_CONTROLS_REPEAT_HELPURL}" } , { type : "controls_repeat" , message0 : "%{BKY_CONTROLS_REPEAT_TITLE}" , args0 : [ { type : "field_number" , name : "TIMES" ,
value : 10 , min : 0 , precision : 1 } ] , message1 : "%{BKY_CONTROLS_REPEAT_INPUT_DO} %1" , args1 : [ { type : "input_statement" , name : "DO" } ] , previousStatement : null , nextStatement : null , colour : "%{BKY_LOOPS_HUE}" , tooltip : "%{BKY_CONTROLS_REPEAT_TOOLTIP}" , helpUrl : "%{BKY_CONTROLS_REPEAT_HELPURL}" } , { type : "controls_whileUntil" , message0 : "%1 %2" , args0 : [ { type : "field_dropdown" , name : "MODE" , options : [ [ "%{BKY_CONTROLS_WHILEUNTIL_OPERATOR_WHILE}" , "WHILE" ] , [ "%{BKY_CONTROLS_WHILEUNTIL_OPERATOR_UNTIL}" , "UNTIL" ] ] } , { type : "input_value" , name : "BOOL" ,
check : "Boolean" } ] , message1 : "%{BKY_CONTROLS_REPEAT_INPUT_DO} %1" , args1 : [ { type : "input_statement" , name : "DO" } ] , previousStatement : null , nextStatement : null , colour : "%{BKY_LOOPS_HUE}" , helpUrl : "%{BKY_CONTROLS_WHILEUNTIL_HELPURL}" , extensions : [ "controls_whileUntil_tooltip" ] } , { type : "controls_for" , message0 : "%{BKY_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" } ] , message1 : "%{BKY_CONTROLS_REPEAT_INPUT_DO} %1" , args1 : [ { type : "input_statement" , name : "DO" } ] , inputsInline : ! 0 , previousStatement : null , nextStatement : null , colour : "%{BKY_LOOPS_HUE}" , helpUrl : "%{BKY_CONTROLS_FOR_HELPURL}" , extensions : [ "contextMenu_newGetVariableBlock" , "controls_for_tooltip" ] } , { type : "controls_forEach" , message0 : "%{BKY_CONTROLS_FOREACH_TITLE}" , args0 : [ { type : "field_variable" , name : "VAR" , variable : null } , { type : "input_value" , name : "LIST" , check : "Array" } ] , message1 : "%{BKY_CONTROLS_REPEAT_INPUT_DO} %1" ,
args1 : [ { type : "input_statement" , name : "DO" } ] , previousStatement : null , nextStatement : null , colour : "%{BKY_LOOPS_HUE}" , helpUrl : "%{BKY_CONTROLS_FOREACH_HELPURL}" , extensions : [ "contextMenu_newGetVariableBlock" , "controls_forEach_tooltip" ] } , { type : "controls_flow_statements" , message0 : "%1" , args0 : [ { type : "field_dropdown" , name : "FLOW" , options : [ [ "%{BKY_CONTROLS_FLOW_STATEMENTS_OPERATOR_BREAK}" , "BREAK" ] , [ "%{BKY_CONTROLS_FLOW_STATEMENTS_OPERATOR_CONTINUE}" , "CONTINUE" ] ] } ] , previousStatement : null , colour : "%{BKY_LOOPS_HUE}" ,
helpUrl : "%{BKY_CONTROLS_FLOW_STATEMENTS_HELPURL}" , extensions : [ "controls_flow_tooltip" , "controls_flow_in_loop_check" ] } ] ) ; Blockly . Constants . Loops . WHILE _UNTIL _TOOLTIPS = { WHILE : "%{BKY_CONTROLS_WHILEUNTIL_TOOLTIP_WHILE}" , UNTIL : "%{BKY_CONTROLS_WHILEUNTIL_TOOLTIP_UNTIL}" } ; Blockly . Extensions . register ( "controls_whileUntil_tooltip" , Blockly . Extensions . buildTooltipForDropdown ( "MODE" , Blockly . Constants . Loops . WHILE _UNTIL _TOOLTIPS ) ) ;
Blockly . Constants . Loops . BREAK _CONTINUE _TOOLTIPS = { BREAK : "%{BKY_CONTROLS_FLOW_STATEMENTS_TOOLTIP_BREAK}" , CONTINUE : "%{BKY_CONTROLS_FLOW_STATEMENTS_TOOLTIP_CONTINUE}" } ; Blockly . Extensions . register ( "controls_flow_tooltip" , Blockly . Extensions . buildTooltipForDropdown ( "FLOW" , Blockly . Constants . Loops . BREAK _CONTINUE _TOOLTIPS ) ) ;
2018-08-17 13:32:56 +00:00
Blockly . Constants . Loops . CUSTOM _CONTEXT _MENU _CREATE _VARIABLES _GET _MIXIN = { customContextMenu : function ( a ) { if ( ! this . isInFlyout ) { var b = this . getField ( "VAR" ) . getVariable ( ) , c = b . name ; if ( ! this . isCollapsed ( ) && null != c ) { var d = { enabled : ! 0 } ; d . text = Blockly . Msg . VARIABLES _SET _CREATE _GET . replace ( "%1" , c ) ; b = Blockly . Variables . generateVariableFieldDom ( b ) ; b = goog . dom . createDom ( "block" , null , b ) ; b . setAttribute ( "type" , "variables_get" ) ; d . callback = Blockly . ContextMenu . callbackFactory ( this , b ) ; a . push ( d ) } } } } ;
Blockly . Extensions . registerMixin ( "contextMenu_newGetVariableBlock" , Blockly . Constants . Loops . CUSTOM _CONTEXT _MENU _CREATE _VARIABLES _GET _MIXIN ) ; Blockly . Extensions . register ( "controls_for_tooltip" , Blockly . Extensions . buildTooltipWithFieldText ( "%{BKY_CONTROLS_FOR_TOOLTIP}" , "VAR" ) ) ; Blockly . Extensions . register ( "controls_forEach_tooltip" , Blockly . Extensions . buildTooltipWithFieldText ( "%{BKY_CONTROLS_FOREACH_TOOLTIP}" , "VAR" ) ) ;
2018-01-16 21:13:23 +00:00
Blockly . Constants . Loops . CONTROL _FLOW _IN _LOOP _CHECK _MIXIN = { LOOP _TYPES : [ "controls_repeat" , "controls_repeat_ext" , "controls_forEach" , "controls_for" , "controls_whileUntil" ] , onchange : function ( ) { if ( this . workspace . isDragging && ! this . workspace . isDragging ( ) ) { 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 . isInFlyout || this . setDisabled ( ! 1 ) ) : ( this . setWarningText ( Blockly . Msg . CONTROLS _FLOW _STATEMENTS _WARNING ) , this . isInFlyout ||
2018-08-17 13:32:56 +00:00
this . getInheritedDisabled ( ) || this . setDisabled ( ! 0 ) ) } } } ; Blockly . Extensions . registerMixin ( "controls_flow_in_loop_check" , Blockly . Constants . Loops . CONTROL _FLOW _IN _LOOP _CHECK _MIXIN ) ; Blockly . Blocks . math = { } ; Blockly . Constants . Math = { } ; Blockly . Constants . Math . HUE = 230 ;
2018-01-16 21:13:23 +00:00
Blockly . defineBlocksWithJsonArray ( [ { type : "math_number" , message0 : "%1" , args0 : [ { type : "field_number" , name : "NUM" , value : 0 } ] , output : "Number" , colour : "%{BKY_MATH_HUE}" , helpUrl : "%{BKY_MATH_NUMBER_HELPURL}" , tooltip : "%{BKY_MATH_NUMBER_TOOLTIP}" , extensions : [ "parent_tooltip_when_inline" ] } , { type : "math_arithmetic" , message0 : "%1 %2 %3" , args0 : [ { type : "input_value" , name : "A" , check : "Number" } , { type : "field_dropdown" , name : "OP" , options : [ [ "%{BKY_MATH_ADDITION_SYMBOL}" , "ADD" ] , [ "%{BKY_MATH_SUBTRACTION_SYMBOL}" , "MINUS" ] , [ "%{BKY_MATH_MULTIPLICATION_SYMBOL}" ,
"MULTIPLY" ] , [ "%{BKY_MATH_DIVISION_SYMBOL}" , "DIVIDE" ] , [ "%{BKY_MATH_POWER_SYMBOL}" , "POWER" ] ] } , { type : "input_value" , name : "B" , check : "Number" } ] , inputsInline : ! 0 , output : "Number" , colour : "%{BKY_MATH_HUE}" , helpUrl : "%{BKY_MATH_ARITHMETIC_HELPURL}" , extensions : [ "math_op_tooltip" ] } , { type : "math_single" , message0 : "%1 %2" , args0 : [ { type : "field_dropdown" , name : "OP" , options : [ [ "%{BKY_MATH_SINGLE_OP_ROOT}" , "ROOT" ] , [ "%{BKY_MATH_SINGLE_OP_ABSOLUTE}" , "ABS" ] , [ "-" , "NEG" ] , [ "ln" , "LN" ] , [ "log10" , "LOG10" ] , [ "e^" , "EXP" ] , [ "10^" , "POW10" ] ] } ,
{ type : "input_value" , name : "NUM" , check : "Number" } ] , output : "Number" , colour : "%{BKY_MATH_HUE}" , helpUrl : "%{BKY_MATH_SINGLE_HELPURL}" , extensions : [ "math_op_tooltip" ] } , { type : "math_trig" , message0 : "%1 %2" , args0 : [ { type : "field_dropdown" , name : "OP" , options : [ [ "%{BKY_MATH_TRIG_SIN}" , "SIN" ] , [ "%{BKY_MATH_TRIG_COS}" , "COS" ] , [ "%{BKY_MATH_TRIG_TAN}" , "TAN" ] , [ "%{BKY_MATH_TRIG_ASIN}" , "ASIN" ] , [ "%{BKY_MATH_TRIG_ACOS}" , "ACOS" ] , [ "%{BKY_MATH_TRIG_ATAN}" , "ATAN" ] ] } , { type : "input_value" , name : "NUM" , check : "Number" } ] , output : "Number" , colour : "%{BKY_MATH_HUE}" ,
helpUrl : "%{BKY_MATH_TRIG_HELPURL}" , extensions : [ "math_op_tooltip" ] } , { type : "math_constant" , message0 : "%1" , args0 : [ { type : "field_dropdown" , name : "CONSTANT" , options : [ [ "\u03c0" , "PI" ] , [ "e" , "E" ] , [ "\u03c6" , "GOLDEN_RATIO" ] , [ "sqrt(2)" , "SQRT2" ] , [ "sqrt(\u00bd)" , "SQRT1_2" ] , [ "\u221e" , "INFINITY" ] ] } ] , output : "Number" , colour : "%{BKY_MATH_HUE}" , tooltip : "%{BKY_MATH_CONSTANT_TOOLTIP}" , helpUrl : "%{BKY_MATH_CONSTANT_HELPURL}" } , { type : "math_number_property" , message0 : "%1 %2" , args0 : [ { type : "input_value" , name : "NUMBER_TO_CHECK" , check : "Number" } ,
{ type : "field_dropdown" , name : "PROPERTY" , options : [ [ "%{BKY_MATH_IS_EVEN}" , "EVEN" ] , [ "%{BKY_MATH_IS_ODD}" , "ODD" ] , [ "%{BKY_MATH_IS_PRIME}" , "PRIME" ] , [ "%{BKY_MATH_IS_WHOLE}" , "WHOLE" ] , [ "%{BKY_MATH_IS_POSITIVE}" , "POSITIVE" ] , [ "%{BKY_MATH_IS_NEGATIVE}" , "NEGATIVE" ] , [ "%{BKY_MATH_IS_DIVISIBLE_BY}" , "DIVISIBLE_BY" ] ] } ] , inputsInline : ! 0 , output : "Boolean" , colour : "%{BKY_MATH_HUE}" , tooltip : "%{BKY_MATH_IS_TOOLTIP}" , mutator : "math_is_divisibleby_mutator" } , { type : "math_change" , message0 : "%{BKY_MATH_CHANGE_TITLE}" , args0 : [ { type : "field_variable" ,
name : "VAR" , variable : "%{BKY_MATH_CHANGE_TITLE_ITEM}" } , { type : "input_value" , name : "DELTA" , check : "Number" } ] , previousStatement : null , nextStatement : null , colour : "%{BKY_VARIABLES_HUE}" , helpUrl : "%{BKY_MATH_CHANGE_HELPURL}" , extensions : [ "math_change_tooltip" ] } , { type : "math_round" , message0 : "%1 %2" , args0 : [ { type : "field_dropdown" , name : "OP" , options : [ [ "%{BKY_MATH_ROUND_OPERATOR_ROUND}" , "ROUND" ] , [ "%{BKY_MATH_ROUND_OPERATOR_ROUNDUP}" , "ROUNDUP" ] , [ "%{BKY_MATH_ROUND_OPERATOR_ROUNDDOWN}" , "ROUNDDOWN" ] ] } , { type : "input_value" ,
name : "NUM" , check : "Number" } ] , output : "Number" , colour : "%{BKY_MATH_HUE}" , helpUrl : "%{BKY_MATH_ROUND_HELPURL}" , tooltip : "%{BKY_MATH_ROUND_TOOLTIP}" } , { type : "math_on_list" , message0 : "%1 %2" , args0 : [ { type : "field_dropdown" , name : "OP" , options : [ [ "%{BKY_MATH_ONLIST_OPERATOR_SUM}" , "SUM" ] , [ "%{BKY_MATH_ONLIST_OPERATOR_MIN}" , "MIN" ] , [ "%{BKY_MATH_ONLIST_OPERATOR_MAX}" , "MAX" ] , [ "%{BKY_MATH_ONLIST_OPERATOR_AVERAGE}" , "AVERAGE" ] , [ "%{BKY_MATH_ONLIST_OPERATOR_MEDIAN}" , "MEDIAN" ] , [ "%{BKY_MATH_ONLIST_OPERATOR_MODE}" , "MODE" ] , [ "%{BKY_MATH_ONLIST_OPERATOR_STD_DEV}" ,
"STD_DEV" ] , [ "%{BKY_MATH_ONLIST_OPERATOR_RANDOM}" , "RANDOM" ] ] } , { type : "input_value" , name : "LIST" , check : "Array" } ] , output : "Number" , colour : "%{BKY_MATH_HUE}" , helpUrl : "%{BKY_MATH_ONLIST_HELPURL}" , mutator : "math_modes_of_list_mutator" , extensions : [ "math_op_tooltip" ] } , { type : "math_modulo" , message0 : "%{BKY_MATH_MODULO_TITLE}" , args0 : [ { type : "input_value" , name : "DIVIDEND" , check : "Number" } , { type : "input_value" , name : "DIVISOR" , check : "Number" } ] , inputsInline : ! 0 , output : "Number" , colour : "%{BKY_MATH_HUE}" , tooltip : "%{BKY_MATH_MODULO_TOOLTIP}" ,
helpUrl : "%{BKY_MATH_MODULO_HELPURL}" } , { type : "math_constrain" , message0 : "%{BKY_MATH_CONSTRAIN_TITLE}" , args0 : [ { type : "input_value" , name : "VALUE" , check : "Number" } , { type : "input_value" , name : "LOW" , check : "Number" } , { type : "input_value" , name : "HIGH" , check : "Number" } ] , inputsInline : ! 0 , output : "Number" , colour : "%{BKY_MATH_HUE}" , tooltip : "%{BKY_MATH_CONSTRAIN_TOOLTIP}" , helpUrl : "%{BKY_MATH_CONSTRAIN_HELPURL}" } , { type : "math_random_int" , message0 : "%{BKY_MATH_RANDOM_INT_TITLE}" , args0 : [ { type : "input_value" , name : "FROM" , check : "Number" } ,
{ type : "input_value" , name : "TO" , check : "Number" } ] , inputsInline : ! 0 , output : "Number" , colour : "%{BKY_MATH_HUE}" , tooltip : "%{BKY_MATH_RANDOM_INT_TOOLTIP}" , helpUrl : "%{BKY_MATH_RANDOM_INT_HELPURL}" } , { type : "math_random_float" , message0 : "%{BKY_MATH_RANDOM_FLOAT_TITLE_RANDOM}" , output : "Number" , colour : "%{BKY_MATH_HUE}" , tooltip : "%{BKY_MATH_RANDOM_FLOAT_TOOLTIP}" , helpUrl : "%{BKY_MATH_RANDOM_FLOAT_HELPURL}" } ] ) ;
Blockly . Constants . Math . TOOLTIPS _BY _OP = { ADD : "%{BKY_MATH_ARITHMETIC_TOOLTIP_ADD}" , MINUS : "%{BKY_MATH_ARITHMETIC_TOOLTIP_MINUS}" , MULTIPLY : "%{BKY_MATH_ARITHMETIC_TOOLTIP_MULTIPLY}" , DIVIDE : "%{BKY_MATH_ARITHMETIC_TOOLTIP_DIVIDE}" , POWER : "%{BKY_MATH_ARITHMETIC_TOOLTIP_POWER}" , ROOT : "%{BKY_MATH_SINGLE_TOOLTIP_ROOT}" , ABS : "%{BKY_MATH_SINGLE_TOOLTIP_ABS}" , NEG : "%{BKY_MATH_SINGLE_TOOLTIP_NEG}" , LN : "%{BKY_MATH_SINGLE_TOOLTIP_LN}" , LOG10 : "%{BKY_MATH_SINGLE_TOOLTIP_LOG10}" , EXP : "%{BKY_MATH_SINGLE_TOOLTIP_EXP}" , POW10 : "%{BKY_MATH_SINGLE_TOOLTIP_POW10}" ,
SIN : "%{BKY_MATH_TRIG_TOOLTIP_SIN}" , COS : "%{BKY_MATH_TRIG_TOOLTIP_COS}" , TAN : "%{BKY_MATH_TRIG_TOOLTIP_TAN}" , ASIN : "%{BKY_MATH_TRIG_TOOLTIP_ASIN}" , ACOS : "%{BKY_MATH_TRIG_TOOLTIP_ACOS}" , ATAN : "%{BKY_MATH_TRIG_TOOLTIP_ATAN}" , SUM : "%{BKY_MATH_ONLIST_TOOLTIP_SUM}" , MIN : "%{BKY_MATH_ONLIST_TOOLTIP_MIN}" , MAX : "%{BKY_MATH_ONLIST_TOOLTIP_MAX}" , AVERAGE : "%{BKY_MATH_ONLIST_TOOLTIP_AVERAGE}" , MEDIAN : "%{BKY_MATH_ONLIST_TOOLTIP_MEDIAN}" , MODE : "%{BKY_MATH_ONLIST_TOOLTIP_MODE}" , STD _DEV : "%{BKY_MATH_ONLIST_TOOLTIP_STD_DEV}" , RANDOM : "%{BKY_MATH_ONLIST_TOOLTIP_RANDOM}" } ;
Blockly . Extensions . register ( "math_op_tooltip" , Blockly . Extensions . buildTooltipForDropdown ( "OP" , Blockly . Constants . Math . TOOLTIPS _BY _OP ) ) ;
Blockly . Constants . Math . IS _DIVISIBLEBY _MUTATOR _MIXIN = { 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" ) } } ;
2018-08-17 13:32:56 +00:00
Blockly . Constants . Math . IS _DIVISIBLE _MUTATOR _EXTENSION = function ( ) { this . getField ( "PROPERTY" ) . setValidator ( function ( a ) { this . sourceBlock _ . updateShape _ ( "DIVISIBLE_BY" == a ) } ) } ; Blockly . Extensions . registerMutator ( "math_is_divisibleby_mutator" , Blockly . Constants . Math . IS _DIVISIBLEBY _MUTATOR _MIXIN , Blockly . Constants . Math . IS _DIVISIBLE _MUTATOR _EXTENSION ) ; Blockly . Extensions . register ( "math_change_tooltip" , Blockly . Extensions . buildTooltipWithFieldText ( "%{BKY_MATH_CHANGE_TOOLTIP}" , "VAR" ) ) ;
Blockly . Constants . Math . LIST _MODES _MUTATOR _MIXIN = { updateType _ : function ( a ) { "MODE" == a ? this . outputConnection . setCheck ( "Array" ) : this . outputConnection . setCheck ( "Number" ) } , mutationToDom : function ( ) { var a = document . createElement ( "mutation" ) ; a . setAttribute ( "op" , this . getFieldValue ( "OP" ) ) ; return a } , domToMutation : function ( a ) { this . updateType _ ( a . getAttribute ( "op" ) ) } } ; Blockly . Constants . Math . LIST _MODES _MUTATOR _EXTENSION = function ( ) { this . getField ( "OP" ) . setValidator ( function ( a ) { this . updateType _ ( a ) } . bind ( this ) ) } ;
Blockly . Extensions . registerMutator ( "math_modes_of_list_mutator" , Blockly . Constants . Math . LIST _MODES _MUTATOR _MIXIN , Blockly . Constants . Math . LIST _MODES _MUTATOR _EXTENSION ) ; Blockly . Blocks . procedures = { } ;
Blockly . Blocks . procedures _defnoreturn = { init : function ( ) { var a = new Blockly . FieldTextInput ( "" , 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" ] ) ) ; ( this . workspace . options . comments || this . workspace . options . parentWorkspace && this . workspace . options . parentWorkspace . options . comments ) && Blockly . Msg . PROCEDURES _DEFNORETURN _COMMENT && this . setCommentText ( Blockly . Msg . PROCEDURES _DEFNORETURN _COMMENT ) ;
this . setColour ( Blockly . Msg . PROCEDURES _HUE ) ; this . setTooltip ( Blockly . Msg . PROCEDURES _DEFNORETURN _TOOLTIP ) ; this . setHelpUrl ( Blockly . Msg . PROCEDURES _DEFNORETURN _HELPURL ) ; this . arguments _ = [ ] ; this . argumentVarModels _ = [ ] ; this . setStatements _ ( ! 0 ) ; this . statementConnection _ = null } , 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 ( ", " ) ) ; Blockly . Events . disable ( ) ; try { this . setFieldValue ( a , "PARAMS" ) } finally { Blockly . Events . enable ( ) } } , mutationToDom : function ( a ) { var b =
document . createElement ( "mutation" ) ; a && b . setAttribute ( "name" , this . getFieldValue ( "NAME" ) ) ; for ( var c = 0 ; c < this . argumentVarModels _ . length ; c ++ ) { var d = document . createElement ( "arg" ) , e = this . argumentVarModels _ [ c ] ; d . setAttribute ( "name" , e . name ) ; d . setAttribute ( "varId" , e . getId ( ) ) ; 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 _ = [ ] ; this . argumentVarModels _ = [ ] ; for ( var b = 0 , c ; c =
a . childNodes [ b ] ; b ++ ) if ( "arg" == c . nodeName . toLowerCase ( ) ) { var d = c . getAttribute ( "name" ) ; c = c . getAttribute ( "varId" ) ; this . arguments _ . push ( d ) ; d = Blockly . Variables . getOrCreateVariablePackage ( this . workspace , c , d , "" ) ; this . argumentVarModels _ . push ( d ) } 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 _ = [ ] ; this . argumentVarModels _ = [ ] ; for ( var b = a . getInputTargetBlock ( "STACK" ) ; b ; ) { var c = b . getFieldValue ( "NAME" ) ;
this . arguments _ . push ( c ) ; c = this . workspace . getVariable ( c , "" ) ; this . argumentVarModels _ . push ( c ) ; 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 ) } } , getProcedureDef : function ( ) { return [ this . getFieldValue ( "NAME" ) , this . arguments _ , ! 1 ] } , getVars : function ( ) { return this . arguments _ } , getVarModels : function ( ) { return this . argumentVarModels _ } , renameVarById : function ( a , b ) { var c = this . workspace . getVariableById ( a ) ; if ( "" == c . type ) { c = c . name ; for ( var d = this . workspace . getVariableById ( b ) , e = ! 1 , f = 0 ; f < this . argumentVarModels _ . length ; f ++ ) this . argumentVarModels _ [ f ] . getId ( ) == a && ( this . arguments _ [ f ] =
d . name , this . argumentVarModels _ [ f ] = d , e = ! 0 ) ; e && this . displayRenamedVar _ ( c , d . name ) } } , updateVarName : function ( a ) { for ( var b = a . name , c = ! 1 , d = 0 ; d < this . argumentVarModels _ . length ; d ++ ) if ( this . argumentVarModels _ [ d ] . getId ( ) == a . getId ( ) ) { var e = this . arguments _ [ d ] ; this . arguments _ [ d ] = b ; c = ! 0 } c && this . displayRenamedVar _ ( e , b ) } , displayRenamedVar _ : function ( a , b ) { this . updateParams _ ( ) ; if ( 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 ) { if ( ! this . isInFlyout ) { 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 ) ; c = goog . dom . createDom ( "block" , null , d ) ; c . setAttribute ( "type" , this . callType _ ) ; b . callback = Blockly . ContextMenu . callbackFactory ( this ,
c ) ; a . push ( b ) ; if ( ! this . isCollapsed ( ) ) for ( e = 0 ; e < this . argumentVarModels _ . length ; e ++ ) b = { enabled : ! 0 } , d = this . argumentVarModels _ [ e ] , c = d . name , b . text = Blockly . Msg . VARIABLES _SET _CREATE _GET . replace ( "%1" , c ) , c = Blockly . Variables . generateVariableFieldDom ( d ) , c = goog . dom . createDom ( "block" , null , c ) , c . setAttribute ( "type" , "variables_get" ) , b . callback = Blockly . ContextMenu . callbackFactory ( this , c ) , a . push ( b ) } } , callType _ : "procedures_callnoreturn" } ;
2017-09-25 09:37:41 +00:00
Blockly . Blocks . procedures _defreturn = { init : function ( ) { var a = new Blockly . FieldTextInput ( "" , 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" ] ) ) ; ( this . workspace . options . comments || this . workspace . options . parentWorkspace &&
2018-08-17 13:32:56 +00:00
this . workspace . options . parentWorkspace . options . comments ) && Blockly . Msg . PROCEDURES _DEFRETURN _COMMENT && this . setCommentText ( Blockly . Msg . PROCEDURES _DEFRETURN _COMMENT ) ; this . setColour ( Blockly . Msg . PROCEDURES _HUE ) ; this . setTooltip ( Blockly . Msg . PROCEDURES _DEFRETURN _TOOLTIP ) ; this . setHelpUrl ( Blockly . Msg . PROCEDURES _DEFRETURN _HELPURL ) ; this . arguments _ = [ ] ; this . argumentVarModels _ = [ ] ; this . setStatements _ ( ! 0 ) ; this . statementConnection _ = null } , setStatements _ : Blockly . Blocks . procedures _defnoreturn . setStatements _ , updateParams _ : Blockly . Blocks . procedures _defnoreturn . updateParams _ ,
mutationToDom : Blockly . Blocks . procedures _defnoreturn . mutationToDom , domToMutation : Blockly . Blocks . procedures _defnoreturn . domToMutation , decompose : Blockly . Blocks . procedures _defnoreturn . decompose , compose : Blockly . Blocks . procedures _defnoreturn . compose , getProcedureDef : function ( ) { return [ this . getFieldValue ( "NAME" ) , this . arguments _ , ! 0 ] } , getVars : Blockly . Blocks . procedures _defnoreturn . getVars , getVarModels : Blockly . Blocks . procedures _defnoreturn . getVarModels , renameVarById : Blockly . Blocks . procedures _defnoreturn . renameVarById ,
updateVarName : Blockly . Blocks . procedures _defnoreturn . updateVarName , displayRenamedVar _ : Blockly . Blocks . procedures _defnoreturn . displayRenamedVar _ , 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 . Msg . PROCEDURES _HUE ) ; this . setTooltip ( Blockly . Msg . PROCEDURES _MUTATORCONTAINER _TOOLTIP ) ; this . contextMenu = ! 1 } } ;
Blockly . Blocks . procedures _mutatorarg = { init : function ( ) { var a = new Blockly . FieldTextInput ( "x" , this . validator _ ) ; a . oldShowEditorFn _ = a . showEditor _ ; a . showEditor _ = function ( ) { this . createdVariables _ = [ ] ; this . oldShowEditorFn _ ( ) } ; this . appendDummyInput ( ) . appendField ( Blockly . Msg . PROCEDURES _MUTATORARG _TITLE ) . appendField ( a , "NAME" ) ; this . setPreviousStatement ( ! 0 ) ; this . setNextStatement ( ! 0 ) ; this . setColour ( Blockly . Msg . PROCEDURES _HUE ) ; this . setTooltip ( Blockly . Msg . PROCEDURES _MUTATORARG _TOOLTIP ) ; this . contextMenu = ! 1 ; a . onFinishEditing _ =
this . deleteIntermediateVars _ ; a . createdVariables _ = [ ] ; a . onFinishEditing _ ( "x" ) } , validator _ : function ( a ) { var b = Blockly . Mutator . findParentWs ( this . sourceBlock _ . workspace ) ; a = a . replace ( /[\s\xa0]+/g , " " ) . replace ( /^ | $/g , "" ) ; if ( ! a ) return null ; var c = b . getVariable ( a , "" ) ; c && c . name != a && b . renameVarById ( c . getId ( ) , a ) ; c || ( c = b . createVariable ( a , "" ) ) && this . createdVariables _ && this . createdVariables _ . push ( c ) ; return a } , deleteIntermediateVars _ : function ( a ) { var b = Blockly . Mutator . findParentWs ( this . sourceBlock _ . workspace ) ; if ( b ) for ( var c =
0 ; c < this . createdVariables _ . length ; c ++ ) { var d = this . createdVariables _ [ c ] ; d . name != a && b . deleteVariableById ( d . getId ( ) ) } } } ;
Blockly . Blocks . procedures _callnoreturn = { init : function ( ) { this . appendDummyInput ( "TOPROW" ) . appendField ( this . id , "NAME" ) ; this . setPreviousStatement ( ! 0 ) ; this . setNextStatement ( ! 0 ) ; this . setColour ( Blockly . Msg . PROCEDURES _HUE ) ; this . setHelpUrl ( Blockly . Msg . PROCEDURES _CALLNORETURN _HELPURL ) ; this . arguments _ = [ ] ; this . argumentVarModels _ = [ ] ; 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 . argumentVarModels _ = [ ] ; for ( e = 0 ; e < this . arguments _ . length ; e ++ ) d =
Blockly . Variables . getOrCreateVariablePackage ( this . workspace , null , this . arguments _ [ e ] , "" ) , this . argumentVarModels _ . push ( d ) ; 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 ) ; if ( b ) { Blockly . Events . disable ( ) ;
try { b . setValue ( this . arguments _ [ a ] ) } finally { Blockly . Events . enable ( ) } } else 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 ) ; b = [ ] ; for ( var 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 ) } , getVarModels : function ( ) { return this . argumentVarModels _ } ,
onchange : function ( a ) { if ( this . workspace && ! this . workspace . isFlyout ) if ( a . type == Blockly . Events . BLOCK _CREATE && - 1 != a . ids . indexOf ( this . id ) ) { var b = this . getProcedureCall ( ) ; b = Blockly . Procedures . getDefinition ( b , this . workspace ) ; ! b || b . type == this . defType _ && JSON . stringify ( b . arguments _ ) == JSON . stringify ( this . arguments _ ) || ( b = null ) ; if ( ! b ) { Blockly . Events . setGroup ( a . group ) ; a = goog . dom . createDom ( "xml" ) ; b = goog . dom . createDom ( "block" ) ; b . setAttribute ( "type" , this . defType _ ) ; var c = this . getRelativeToSurfaceXY ( ) , d = c . y + 2 * Blockly . SNAP _RADIUS ;
b . setAttribute ( "x" , c . x + Blockly . SNAP _RADIUS * ( this . RTL ? - 1 : 1 ) ) ; b . setAttribute ( "y" , d ) ; c = this . mutationToDom ( ) ; b . appendChild ( c ) ; c = goog . dom . createDom ( "field" ) ; c . setAttribute ( "name" , "NAME" ) ; c . appendChild ( document . createTextNode ( this . getProcedureCall ( ) ) ) ; b . appendChild ( c ) ; a . appendChild ( b ) ; Blockly . Xml . domToWorkspace ( a , this . workspace ) ; Blockly . Events . setGroup ( ! 1 ) } } else a . type == Blockly . Events . BLOCK _DELETE && ( b = this . getProcedureCall ( ) , b = Blockly . Procedures . getDefinition ( b , this . workspace ) , b || ( Blockly . Events . setGroup ( a . group ) ,
this . dispose ( ! 0 , ! 1 ) , Blockly . Events . setGroup ( ! 1 ) ) ) } , 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 && ( d . centerOnBlock ( a . id ) , a . select ( ) ) } ; a . push ( b ) } , defType _ : "procedures_defnoreturn" } ;
Blockly . Blocks . procedures _callreturn = { init : function ( ) { this . appendDummyInput ( "TOPROW" ) . appendField ( "" , "NAME" ) ; this . setOutput ( ! 0 ) ; this . setColour ( Blockly . Msg . 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 , getVarModels : Blockly . Blocks . procedures _callnoreturn . getVarModels , onchange : Blockly . Blocks . procedures _callnoreturn . onchange , customContextMenu : Blockly . Blocks . procedures _callnoreturn . customContextMenu , defType _ : "procedures_defreturn" } ;
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 . Msg . 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 ( ) { if ( this . workspace . isDragging && ! this . workspace . isDragging ( ) ) { 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 . isInFlyout || this . setDisabled ( ! 1 ) ) : ( this . setWarningText ( Blockly . Msg . PROCEDURES _IFRETURN _WARNING ) , this . isInFlyout || this . getInheritedDisabled ( ) ||
this . setDisabled ( ! 0 ) ) } } , FUNCTION _TYPES : [ "procedures_defnoreturn" , "procedures_defreturn" ] } ; Blockly . Blocks . texts = { } ; Blockly . Constants . Text = { } ; Blockly . Constants . Text . HUE = 160 ;
2018-01-16 21:13:23 +00:00
Blockly . defineBlocksWithJsonArray ( [ { type : "text" , message0 : "%1" , args0 : [ { type : "field_input" , name : "TEXT" , text : "" } ] , output : "String" , colour : "%{BKY_TEXTS_HUE}" , helpUrl : "%{BKY_TEXT_TEXT_HELPURL}" , tooltip : "%{BKY_TEXT_TEXT_TOOLTIP}" , extensions : [ "text_quotes" , "parent_tooltip_when_inline" ] } , { type : "text_join" , message0 : "" , output : "String" , colour : "%{BKY_TEXTS_HUE}" , helpUrl : "%{BKY_TEXT_JOIN_HELPURL}" , tooltip : "%{BKY_TEXT_JOIN_TOOLTIP}" , mutator : "text_join_mutator" } , { type : "text_create_join_container" , message0 : "%{BKY_TEXT_CREATE_JOIN_TITLE_JOIN} %1 %2" ,
2018-08-17 13:32:56 +00:00
args0 : [ { type : "input_dummy" } , { type : "input_statement" , name : "STACK" } ] , colour : "%{BKY_TEXTS_HUE}" , tooltip : "%{BKY_TEXT_CREATE_JOIN_TOOLTIP}" , enableContextMenu : ! 1 } , { type : "text_create_join_item" , message0 : "%{BKY_TEXT_CREATE_JOIN_ITEM_TITLE_ITEM}" , previousStatement : null , nextStatement : null , colour : "%{BKY_TEXTS_HUE}" , tooltip : "%{BKY_TEXT_CREATE_JOIN_ITEM_TOOLTIP}" , enableContextMenu : ! 1 } , { type : "text_append" , message0 : "%{BKY_TEXT_APPEND_TITLE}" , args0 : [ { type : "field_variable" , name : "VAR" , variable : "%{BKY_TEXT_APPEND_VARIABLE}" } ,
2018-01-16 21:13:23 +00:00
{ type : "input_value" , name : "TEXT" } ] , previousStatement : null , nextStatement : null , colour : "%{BKY_TEXTS_HUE}" , extensions : [ "text_append_tooltip" ] } , { type : "text_length" , message0 : "%{BKY_TEXT_LENGTH_TITLE}" , args0 : [ { type : "input_value" , name : "VALUE" , check : [ "String" , "Array" ] } ] , output : "Number" , colour : "%{BKY_TEXTS_HUE}" , tooltip : "%{BKY_TEXT_LENGTH_TOOLTIP}" , helpUrl : "%{BKY_TEXT_LENGTH_HELPURL}" } , { type : "text_isEmpty" , message0 : "%{BKY_TEXT_ISEMPTY_TITLE}" , args0 : [ { type : "input_value" , name : "VALUE" , check : [ "String" , "Array" ] } ] ,
output : "Boolean" , colour : "%{BKY_TEXTS_HUE}" , tooltip : "%{BKY_TEXT_ISEMPTY_TOOLTIP}" , helpUrl : "%{BKY_TEXT_ISEMPTY_HELPURL}" } , { type : "text_indexOf" , message0 : "%{BKY_TEXT_INDEXOF_TITLE}" , args0 : [ { type : "input_value" , name : "VALUE" , check : "String" } , { type : "field_dropdown" , name : "END" , options : [ [ "%{BKY_TEXT_INDEXOF_OPERATOR_FIRST}" , "FIRST" ] , [ "%{BKY_TEXT_INDEXOF_OPERATOR_LAST}" , "LAST" ] ] } , { type : "input_value" , name : "FIND" , check : "String" } ] , output : "Number" , colour : "%{BKY_TEXTS_HUE}" , helpUrl : "%{BKY_TEXT_INDEXOF_HELPURL}" , inputsInline : ! 0 ,
extensions : [ "text_indexOf_tooltip" ] } , { type : "text_charAt" , message0 : "%{BKY_TEXT_CHARAT_TITLE}" , args0 : [ { type : "input_value" , name : "VALUE" , check : "String" } , { type : "field_dropdown" , name : "WHERE" , options : [ [ "%{BKY_TEXT_CHARAT_FROM_START}" , "FROM_START" ] , [ "%{BKY_TEXT_CHARAT_FROM_END}" , "FROM_END" ] , [ "%{BKY_TEXT_CHARAT_FIRST}" , "FIRST" ] , [ "%{BKY_TEXT_CHARAT_LAST}" , "LAST" ] , [ "%{BKY_TEXT_CHARAT_RANDOM}" , "RANDOM" ] ] } ] , output : "String" , colour : "%{BKY_TEXTS_HUE}" , helpUrl : "%{BKY_TEXT_CHARAT_HELPURL}" , inputsInline : ! 0 , mutator : "text_charAt_mutator" } ] ) ;
2018-08-17 13:32:56 +00:00
Blockly . Blocks . text _getSubstring = { init : function ( ) { this . WHERE _OPTIONS _1 = [ [ Blockly . Msg . TEXT _GET _SUBSTRING _START _FROM _START , "FROM_START" ] , [ Blockly . Msg . TEXT _GET _SUBSTRING _START _FROM _END , "FROM_END" ] , [ Blockly . Msg . TEXT _GET _SUBSTRING _START _FIRST , "FIRST" ] ] ; this . WHERE _OPTIONS _2 = [ [ Blockly . Msg . TEXT _GET _SUBSTRING _END _FROM _START , "FROM_START" ] , [ Blockly . Msg . TEXT _GET _SUBSTRING _END _FROM _END , "FROM_END" ] , [ Blockly . Msg . TEXT _GET _SUBSTRING _END _LAST , "LAST" ] ] ; this . setHelpUrl ( Blockly . Msg . TEXT _GET _SUBSTRING _HELPURL ) ; this . setColour ( Blockly . Msg . TEXTS _HUE ) ;
2017-09-25 09:37:41 +00:00
this . appendValueInput ( "STRING" ) . setCheck ( "String" ) . appendField ( Blockly . Msg . TEXT _GET _SUBSTRING _INPUT _IN _TEXT ) ; this . appendDummyInput ( "AT1" ) ; this . appendDummyInput ( "AT2" ) ; Blockly . Msg . TEXT _GET _SUBSTRING _TAIL && this . appendDummyInput ( "TAIL" ) . appendField ( Blockly . Msg . TEXT _GET _SUBSTRING _TAIL ) ; this . setInputsInline ( ! 0 ) ; this . setOutput ( ! 0 , "String" ) ; this . updateAt _ ( 1 , ! 0 ) ; this . updateAt _ ( 2 , ! 0 ) ; this . setTooltip ( Blockly . Msg . TEXT _GET _SUBSTRING _TOOLTIP ) } , mutationToDom : function ( ) { var a = document . createElement ( "mutation" ) ,
b = this . getInput ( "AT1" ) . type == Blockly . INPUT _VALUE ; a . setAttribute ( "at1" , b ) ; b = this . getInput ( "AT2" ) . type == Blockly . INPUT _VALUE ; a . setAttribute ( "at2" , b ) ; return a } , domToMutation : function ( a ) { var b = "true" == a . getAttribute ( "at1" ) ; a = "true" == a . getAttribute ( "at2" ) ; this . updateAt _ ( 1 , b ) ; this . updateAt _ ( 2 , a ) } , updateAt _ : function ( a , b ) { this . removeInput ( "AT" + a ) ; this . removeInput ( "ORDINAL" + a , ! 0 ) ; b ? ( this . appendValueInput ( "AT" + a ) . setCheck ( "Number" ) , Blockly . Msg . ORDINAL _NUMBER _SUFFIX && this . appendDummyInput ( "ORDINAL" + a ) . appendField ( Blockly . Msg . ORDINAL _NUMBER _SUFFIX ) ) :
2018-08-17 13:32:56 +00:00
this . appendDummyInput ( "AT" + a ) ; 2 == a && Blockly . Msg . TEXT _GET _SUBSTRING _TAIL && ( this . removeInput ( "TAIL" , ! 0 ) , this . appendDummyInput ( "TAIL" ) . appendField ( Blockly . Msg . TEXT _GET _SUBSTRING _TAIL ) ) ; var c = new Blockly . FieldDropdown ( this [ "WHERE_OPTIONS_" + a ] , function ( c ) { var d = "FROM_START" == c || "FROM_END" == c ; if ( d != b ) { var f = this . sourceBlock _ ; f . updateAt _ ( a , d ) ; f . setFieldValue ( c , "WHERE" + a ) ; return null } } ) ; this . getInput ( "AT" + a ) . appendField ( c , "WHERE" + a ) ; 1 == a && ( this . moveInputBefore ( "AT1" , "AT2" ) , this . getInput ( "ORDINAL1" ) && this . moveInputBefore ( "ORDINAL1" ,
"AT2" ) ) } } ; Blockly . Blocks . text _changeCase = { init : function ( ) { var a = [ [ Blockly . Msg . TEXT _CHANGECASE _OPERATOR _UPPERCASE , "UPPERCASE" ] , [ Blockly . Msg . TEXT _CHANGECASE _OPERATOR _LOWERCASE , "LOWERCASE" ] , [ Blockly . Msg . TEXT _CHANGECASE _OPERATOR _TITLECASE , "TITLECASE" ] ] ; this . setHelpUrl ( Blockly . Msg . TEXT _CHANGECASE _HELPURL ) ; this . setColour ( Blockly . Msg . TEXTS _HUE ) ; this . appendValueInput ( "TEXT" ) . setCheck ( "String" ) . appendField ( new Blockly . FieldDropdown ( a ) , "CASE" ) ; this . setOutput ( ! 0 , "String" ) ; this . setTooltip ( Blockly . Msg . TEXT _CHANGECASE _TOOLTIP ) } } ;
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 . Msg . 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 . Msg . 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 . Msg . 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 } ) } ,
2017-09-25 09:37:41 +00:00
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" ) ) } } ;
2018-08-17 13:32:56 +00:00
Blockly . Blocks . text _prompt = { init : function ( ) { this . mixin ( Blockly . Constants . Text . QUOTE _IMAGE _MIXIN ) ; 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 . Msg . 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 ) ) ;
2018-01-16 21:13:23 +00:00
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 _ : Blockly . Blocks . text _prompt _ext . updateType _ , mutationToDom : Blockly . Blocks . text _prompt _ext . mutationToDom , domToMutation : Blockly . Blocks . text _prompt _ext . domToMutation } ;
2018-08-17 13:32:56 +00:00
Blockly . Blocks . text _count = { init : function ( ) { this . jsonInit ( { message0 : Blockly . Msg . TEXT _COUNT _MESSAGE0 , args0 : [ { type : "input_value" , name : "SUB" , check : "String" } , { type : "input_value" , name : "TEXT" , check : "String" } ] , output : "Number" , inputsInline : ! 0 , colour : Blockly . Msg . TEXTS _HUE , tooltip : Blockly . Msg . TEXT _COUNT _TOOLTIP , helpUrl : Blockly . Msg . TEXT _COUNT _HELPURL } ) } } ;
Blockly . Blocks . text _replace = { init : function ( ) { this . jsonInit ( { message0 : Blockly . Msg . TEXT _REPLACE _MESSAGE0 , args0 : [ { type : "input_value" , name : "FROM" , check : "String" } , { type : "input_value" , name : "TO" , check : "String" } , { type : "input_value" , name : "TEXT" , check : "String" } ] , output : "String" , inputsInline : ! 0 , colour : Blockly . Msg . TEXTS _HUE , tooltip : Blockly . Msg . TEXT _REPLACE _TOOLTIP , helpUrl : Blockly . Msg . TEXT _REPLACE _HELPURL } ) } } ;
Blockly . Blocks . text _reverse = { init : function ( ) { this . jsonInit ( { message0 : Blockly . Msg . TEXT _REVERSE _MESSAGE0 , args0 : [ { type : "input_value" , name : "TEXT" , check : "String" } ] , output : "String" , inputsInline : ! 0 , colour : Blockly . Msg . TEXTS _HUE , tooltip : Blockly . Msg . TEXT _REVERSE _TOOLTIP , helpUrl : Blockly . Msg . TEXT _REVERSE _HELPURL } ) } } ;
2018-01-16 21:13:23 +00:00
Blockly . Constants . Text . QUOTE _IMAGE _MIXIN = { QUOTE _IMAGE _LEFT _DATAURI : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAn0lEQVQI1z3OMa5BURSF4f/cQhAKjUQhuQmFNwGJEUi0RKN5rU7FHKhpjEH3TEMtkdBSCY1EIv8r7nFX9e29V7EBAOvu7RPjwmWGH/VuF8CyN9/OAdvqIXYLvtRaNjx9mMTDyo+NjAN1HNcl9ZQ5oQMM3dgDUqDo1l8DzvwmtZN7mnD+PkmLa+4mhrxVA9fRowBWmVBhFy5gYEjKMfz9AylsaRRgGzvZAAAAAElFTkSuQmCC" , QUOTE _IMAGE _RIGHT _DATAURI : "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAKCAQAAAAqJXdxAAAAqUlEQVQI1z3KvUpCcRiA8ef9E4JNHhI0aFEacm1o0BsI0Slx8wa8gLauoDnoBhq7DcfWhggONDmJJgqCPA7neJ7p934EOOKOnM8Q7PDElo/4x4lFb2DmuUjcUzS3URnGib9qaPNbuXvBO3sGPHJDRG6fGVdMSeWDP2q99FQdFrz26Gu5Tq7dFMzUvbXy8KXeAj57cOklgA+u1B5AoslLtGIHQMaCVnwDnADZIFIrXsoXrgAAAABJRU5ErkJggg==" ,
QUOTE _IMAGE _WIDTH : 12 , QUOTE _IMAGE _HEIGHT : 12 , quoteField _ : function ( a ) { for ( var b = 0 , c ; c = this . inputList [ b ] ; b ++ ) for ( var d = 0 , e ; e = c . fieldRow [ d ] ; d ++ ) if ( a == e . name ) { c . insertFieldAt ( d , this . newQuote _ ( ! 0 ) ) ; c . insertFieldAt ( d + 2 , this . newQuote _ ( ! 1 ) ) ; return } console . warn ( 'field named "' + a + '" not found in ' + this . toDevString ( ) ) } , newQuote _ : function ( a ) { a = this . RTL ? ! a : a ; return new Blockly . FieldImage ( a ? this . QUOTE _IMAGE _LEFT _DATAURI : this . QUOTE _IMAGE _RIGHT _DATAURI , this . QUOTE _IMAGE _WIDTH , this . QUOTE _IMAGE _HEIGHT , a ? "\u201c" : "\u201d" ) } } ;
Blockly . Constants . Text . TEXT _QUOTES _EXTENSION = function ( ) { this . mixin ( Blockly . Constants . Text . QUOTE _IMAGE _MIXIN ) ; this . quoteField _ ( "TEXT" ) } ;
Blockly . Constants . Text . TEXT _JOIN _MUTATOR _MIXIN = { 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 ( ) ; 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" +
2018-08-17 13:32:56 +00:00
a ) ; ) this . removeInput ( "ADD" + a ) , a ++ } } ; Blockly . Constants . Text . TEXT _JOIN _EXTENSION = function ( ) { this . mixin ( Blockly . Constants . Text . QUOTE _IMAGE _MIXIN ) ; this . itemCount _ = 2 ; this . updateShape _ ( ) ; this . setMutator ( new Blockly . Mutator ( [ "text_create_join_item" ] ) ) } ; Blockly . Extensions . register ( "text_append_tooltip" , Blockly . Extensions . buildTooltipWithFieldText ( "%{BKY_TEXT_APPEND_TOOLTIP}" , "VAR" ) ) ;
2018-01-16 21:13:23 +00:00
Blockly . Constants . Text . TEXT _INDEXOF _TOOLTIP _EXTENSION = function ( ) { var a = this ; this . setTooltip ( function ( ) { return Blockly . Msg . TEXT _INDEXOF _TOOLTIP . replace ( "%1" , a . workspace . options . oneBasedIndex ? "0" : "-1" ) } ) } ;
Blockly . Constants . Text . TEXT _CHARAT _MUTATOR _MIXIN = { mutationToDom : function ( ) { var a = document . createElement ( "mutation" ) ; a . setAttribute ( "at" , ! ! this . isAt _ ) ; return a } , domToMutation : function ( a ) { a = "false" != a . getAttribute ( "at" ) ; this . updateAt _ ( a ) } , updateAt _ : function ( a ) { this . removeInput ( "AT" , ! 0 ) ; this . removeInput ( "ORDINAL" , ! 0 ) ; a && ( this . appendValueInput ( "AT" ) . setCheck ( "Number" ) , Blockly . Msg . ORDINAL _NUMBER _SUFFIX && this . appendDummyInput ( "ORDINAL" ) . appendField ( Blockly . Msg . ORDINAL _NUMBER _SUFFIX ) ) ; Blockly . Msg . TEXT _CHARAT _TAIL &&
( this . removeInput ( "TAIL" , ! 0 ) , this . appendDummyInput ( "TAIL" ) . appendField ( Blockly . Msg . TEXT _CHARAT _TAIL ) ) ; this . isAt _ = a } } ;
Blockly . Constants . Text . TEXT _CHARAT _EXTENSION = function ( ) { this . getField ( "WHERE" ) . setValidator ( function ( a ) { var b = "FROM_START" == a || "FROM_END" == a ; if ( b != this . isAt _ ) { var d = this . sourceBlock _ ; d . updateAt _ ( b ) ; d . setFieldValue ( a , "WHERE" ) ; return null } } ) ; this . updateAt _ ( ! 0 ) ; var a = this ; this . setTooltip ( function ( ) { var b = a . getFieldValue ( "WHERE" ) , c = Blockly . Msg . TEXT _CHARAT _TOOLTIP ; ( "FROM_START" == b || "FROM_END" == b ) && ( b = "FROM_START" == b ? Blockly . Msg . LISTS _INDEX _FROM _START _TOOLTIP : Blockly . Msg . LISTS _INDEX _FROM _END _TOOLTIP ) &&
2018-08-17 13:32:56 +00:00
( c += " " + b . replace ( "%1" , a . workspace . options . oneBasedIndex ? "#1" : "#0" ) ) ; return c } ) } ; Blockly . Extensions . register ( "text_indexOf_tooltip" , Blockly . Constants . Text . TEXT _INDEXOF _TOOLTIP _EXTENSION ) ; Blockly . Extensions . register ( "text_quotes" , Blockly . Constants . Text . TEXT _QUOTES _EXTENSION ) ; Blockly . Extensions . registerMutator ( "text_join_mutator" , Blockly . Constants . Text . TEXT _JOIN _MUTATOR _MIXIN , Blockly . Constants . Text . TEXT _JOIN _EXTENSION ) ;
Blockly . Extensions . registerMutator ( "text_charAt_mutator" , Blockly . Constants . Text . TEXT _CHARAT _MUTATOR _MIXIN , Blockly . Constants . Text . TEXT _CHARAT _EXTENSION ) ; Blockly . Blocks . variables = { } ; Blockly . Constants . Variables = { } ; Blockly . Constants . Variables . HUE = 330 ;
2018-01-16 21:13:23 +00:00
Blockly . defineBlocksWithJsonArray ( [ { type : "variables_get" , message0 : "%1" , args0 : [ { type : "field_variable" , name : "VAR" , variable : "%{BKY_VARIABLES_DEFAULT_NAME}" } ] , output : null , colour : "%{BKY_VARIABLES_HUE}" , helpUrl : "%{BKY_VARIABLES_GET_HELPURL}" , tooltip : "%{BKY_VARIABLES_GET_TOOLTIP}" , extensions : [ "contextMenu_variableSetterGetter" ] } , { type : "variables_set" , message0 : "%{BKY_VARIABLES_SET}" , args0 : [ { type : "field_variable" , name : "VAR" , variable : "%{BKY_VARIABLES_DEFAULT_NAME}" } , { type : "input_value" , name : "VALUE" } ] , previousStatement : null ,
nextStatement : null , colour : "%{BKY_VARIABLES_HUE}" , tooltip : "%{BKY_VARIABLES_SET_TOOLTIP}" , helpUrl : "%{BKY_VARIABLES_SET_HELPURL}" , extensions : [ "contextMenu_variableSetterGetter" ] } ] ) ;
2018-08-17 13:32:56 +00:00
Blockly . Constants . Variables . CUSTOM _CONTEXT _MENU _VARIABLE _GETTER _SETTER _MIXIN = { customContextMenu : function ( a ) { if ( ! this . isInFlyout ) { if ( "variables_get" == this . type ) var b = "variables_set" , c = Blockly . Msg . VARIABLES _GET _CREATE _SET ; else b = "variables_get" , c = Blockly . Msg . VARIABLES _SET _CREATE _GET ; var d = { enabled : 0 < this . workspace . remainingCapacity ( ) } , e = this . getField ( "VAR" ) . getText ( ) ; d . text = c . replace ( "%1" , e ) ; c = goog . dom . createDom ( "field" , null , e ) ; c . setAttribute ( "name" , "VAR" ) ; c = goog . dom . createDom ( "block" , null , c ) ; c . setAttribute ( "type" ,
b ) ; d . callback = Blockly . ContextMenu . callbackFactory ( this , c ) ; a . push ( d ) } } } ; Blockly . Extensions . registerMixin ( "contextMenu_variableSetterGetter" , Blockly . Constants . Variables . CUSTOM _CONTEXT _MENU _VARIABLE _GETTER _SETTER _MIXIN ) ;
Blockly . Constants . VariablesDynamic = { } ; Blockly . Constants . VariablesDynamic . HUE = 310 ;
Blockly . defineBlocksWithJsonArray ( [ { type : "variables_get_dynamic" , message0 : "%1" , args0 : [ { type : "field_variable" , name : "VAR" , variable : "%{BKY_VARIABLES_DEFAULT_NAME}" } ] , output : null , colour : "%{BKY_VARIABLES_DYNAMIC_HUE}" , helpUrl : "%{BKY_VARIABLES_GET_HELPURL}" , tooltip : "%{BKY_VARIABLES_GET_TOOLTIP}" , extensions : [ "contextMenu_variableDynamicSetterGetter" ] } , { type : "variables_set_dynamic" , message0 : "%{BKY_VARIABLES_SET}" , args0 : [ { type : "field_variable" , name : "VAR" , variable : "%{BKY_VARIABLES_DEFAULT_NAME}" } , { type : "input_value" ,
name : "VALUE" } ] , previousStatement : null , nextStatement : null , colour : "%{BKY_VARIABLES_DYNAMIC_HUE}" , tooltip : "%{BKY_VARIABLES_SET_TOOLTIP}" , helpUrl : "%{BKY_VARIABLES_SET_HELPURL}" , extensions : [ "contextMenu_variableDynamicSetterGetter" ] } ] ) ;
Blockly . Constants . VariablesDynamic . CUSTOM _CONTEXT _MENU _VARIABLE _GETTER _SETTER _MIXIN = { customContextMenu : function ( a ) { if ( ! this . isInFlyout ) { if ( "variables_get_dynamic" == this . type ) { var b = "variables_set_dynamic" ; var c = Blockly . Msg . VARIABLES _GET _CREATE _SET } else b = "variables_get_dynamic" , c = Blockly . Msg . VARIABLES _SET _CREATE _GET ; var d = { enabled : 0 < this . workspace . remainingCapacity ( ) } , e = this . getField ( "VAR" ) . getText ( ) ; d . text = c . replace ( "%1" , e ) ; c = goog . dom . createDom ( "field" , null , e ) ; c . setAttribute ( "name" , "VAR" ) ; c = goog . dom . createDom ( "block" ,
null , c ) ; c . setAttribute ( "type" , b ) ; d . callback = Blockly . ContextMenu . callbackFactory ( this , c ) ; a . push ( d ) } } , onchange : function ( ) { var a = this . getFieldValue ( "VAR" ) ; a = this . workspace . getVariableById ( a ) ; "variables_get_dynamic" == this . type ? this . outputConnection . setCheck ( a . type ) : this . getInput ( "VALUE" ) . connection . setCheck ( a . type ) } } ; Blockly . Extensions . registerMixin ( "contextMenu_variableDynamicSetterGetter" , Blockly . Constants . VariablesDynamic . CUSTOM _CONTEXT _MENU _VARIABLE _GETTER _SETTER _MIXIN ) ;