File tree Expand file tree Collapse file tree 4 files changed +48
-0
lines changed Expand file tree Collapse file tree 4 files changed +48
-0
lines changed Original file line number Diff line number Diff line change @@ -9,5 +9,18 @@ Blockly.Blocks.total_profit = {
9
9
this . setTooltip ( translate ( 'Returns the total profit' ) ) ;
10
10
this . setHelpUrl ( 'https://github.com/binary-com/binary-bot/wiki' ) ;
11
11
} ,
12
+ onchange : function onchange ( ev ) {
13
+ if ( ! this . workspace || this . isInFlyout || this . workspace . isDragging ( ) ) {
14
+ return ;
15
+ }
16
+
17
+ if ( ev . type === Blockly . Events . MOVE ) {
18
+ const inputStatement = this . getRootInputTargetBlock ( ) ;
19
+
20
+ if ( inputStatement === 'INITIALIZATION' ) {
21
+ this . unplug ( true ) ;
22
+ }
23
+ }
24
+ } ,
12
25
} ;
13
26
Blockly . JavaScript . total_profit = ( ) => [ 'Bot.getTotalProfit()' , Blockly . JavaScript . ORDER_ATOMIC ] ;
Original file line number Diff line number Diff line change @@ -9,5 +9,18 @@ Blockly.Blocks.total_runs = {
9
9
this . setTooltip ( translate ( 'Returns the number of runs since the beginning' ) ) ;
10
10
this . setHelpUrl ( 'https://github.com/binary-com/binary-bot/wiki' ) ;
11
11
} ,
12
+ onchange : function onchange ( ev ) {
13
+ if ( ! this . workspace || this . isInFlyout || this . workspace . isDragging ( ) ) {
14
+ return ;
15
+ }
16
+
17
+ if ( ev . type === Blockly . Events . MOVE ) {
18
+ const inputStatement = this . getRootInputTargetBlock ( ) ;
19
+
20
+ if ( inputStatement === 'INITIALIZATION' ) {
21
+ this . unplug ( true ) ;
22
+ }
23
+ }
24
+ } ,
12
25
} ;
13
26
Blockly . JavaScript . total_runs = ( ) => [ 'Bot.getTotalRuns()' , Blockly . JavaScript . ORDER_ATOMIC ] ;
Original file line number Diff line number Diff line change @@ -106,6 +106,7 @@ Blockly.Blocks.trade = {
106
106
replaceInitializationBlocks ( this , ev ) ;
107
107
resetTradeFields ( this , ev ) ;
108
108
}
109
+
109
110
decorateTrade ( ev ) ;
110
111
} ,
111
112
} ;
Original file line number Diff line number Diff line change @@ -403,3 +403,24 @@ const originalCustomContextLoopFn =
403
403
Blockly . Constants . Loops . CUSTOM_CONTEXT_MENU_CREATE_VARIABLES_GET_MIXIN . customContextMenu = function ( options ) {
404
404
addDownloadOption ( originalCustomContextLoopFn . bind ( this ) , options , this ) ;
405
405
} ;
406
+
407
+ /**
408
+ * Return the parent block or null if this block is at the top level.
409
+ * @return {Blockly.Block } The block that holds the current block.
410
+ */
411
+ Blockly . Block . prototype . getRootInputTargetBlock = function ( ) {
412
+ let inputName ;
413
+ let currentBlock = this . getParent ( ) ;
414
+
415
+ while ( currentBlock ) {
416
+ const rootBlock = this . getRootBlock ( ) ;
417
+ const currentInput = rootBlock . getInputWithBlock ( currentBlock ) ;
418
+
419
+ if ( currentInput && currentInput . name ) {
420
+ inputName = currentInput . name ;
421
+ }
422
+ currentBlock = currentBlock . getParent ( ) ;
423
+ }
424
+
425
+ return inputName ;
426
+ } ;
You can’t perform that action at this time.
0 commit comments