Skip to content

Commit be74d83

Browse files
authored
Merge pull request binary-com#1622 from sam-binary/misc-blocks
misc block error
2 parents dbe7c3c + d47b1ab commit be74d83

File tree

4 files changed

+48
-0
lines changed

4 files changed

+48
-0
lines changed

src/botPage/view/blockly/blocks/tools/total_profit.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff 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
};
1326
Blockly.JavaScript.total_profit = () => ['Bot.getTotalProfit()', Blockly.JavaScript.ORDER_ATOMIC];

src/botPage/view/blockly/blocks/tools/total_runs.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff 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
};
1326
Blockly.JavaScript.total_runs = () => ['Bot.getTotalRuns()', Blockly.JavaScript.ORDER_ATOMIC];

src/botPage/view/blockly/blocks/trade/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ Blockly.Blocks.trade = {
106106
replaceInitializationBlocks(this, ev);
107107
resetTradeFields(this, ev);
108108
}
109+
109110
decorateTrade(ev);
110111
},
111112
};

src/botPage/view/blockly/customBlockly.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,3 +403,24 @@ const originalCustomContextLoopFn =
403403
Blockly.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+
};

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy