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 = {
99 this . setTooltip ( translate ( 'Returns the total profit' ) ) ;
1010 this . setHelpUrl ( 'https://github.com/binary-com/binary-bot/wiki' ) ;
1111 } ,
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+ } ,
1225} ;
1326Blockly . 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 = {
99 this . setTooltip ( translate ( 'Returns the number of runs since the beginning' ) ) ;
1010 this . setHelpUrl ( 'https://github.com/binary-com/binary-bot/wiki' ) ;
1111 } ,
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+ } ,
1225} ;
1326Blockly . 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 = {
106106 replaceInitializationBlocks ( this , ev ) ;
107107 resetTradeFields ( this , ev ) ;
108108 }
109+
109110 decorateTrade ( ev ) ;
110111 } ,
111112} ;
Original file line number Diff line number Diff line change @@ -403,3 +403,24 @@ const originalCustomContextLoopFn =
403403Blockly . Constants . Loops . CUSTOM_CONTEXT_MENU_CREATE_VARIABLES_GET_MIXIN . customContextMenu = function ( options ) {
404404 addDownloadOption ( originalCustomContextLoopFn . bind ( this ) , options , this ) ;
405405} ;
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