From 3619802f33e88bff69929e941e9d65ff187fe6e1 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 21 May 2019 10:49:16 +0200 Subject: [PATCH 1/8] Download for conditions, situations and phases implemented --- FloatingSpace/StrategyPartConstructor.js | 50 ++++++++++++++++--- StrategySpace/Workspace.js | 62 ++++++++++++++++++++++++ 2 files changed, 105 insertions(+), 7 deletions(-) diff --git a/FloatingSpace/StrategyPartConstructor.js b/FloatingSpace/StrategyPartConstructor.js index 55d8e1342..f010175d2 100644 --- a/FloatingSpace/StrategyPartConstructor.js +++ b/FloatingSpace/StrategyPartConstructor.js @@ -346,7 +346,7 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: 40, + angle: -60, dontShowAtFullscreen: true }, { @@ -360,7 +360,7 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: 0 + angle: -20 }, { action: 'Delete Phase', @@ -372,7 +372,19 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: -40 + angle: 20 + }, + { + action: 'Download', + actionFunction: payload.onMenuItemClick, + label: 'Download', + visible: false, + iconPathOn: 'upload', + iconPathOff: 'upload', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 60 }] break } @@ -402,7 +414,7 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: 20 + angle: -40 }, { action: 'Delete Situation', @@ -414,7 +426,19 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: -20 + angle: 0 + }, + { + action: 'Download', + actionFunction: payload.onMenuItemClick, + label: 'Download', + visible: false, + iconPathOn: 'upload', + iconPathOff: 'upload', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 40 }] break } @@ -448,7 +472,7 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: 20, + angle: -40, dontShowAtFullscreen: true }, { @@ -461,7 +485,19 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: -20 + angle: 0 + }, + { + action: 'Download', + actionFunction: payload.onMenuItemClick, + label: 'Download', + visible: false, + iconPathOn: 'upload', + iconPathOff: 'upload', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 40 }] break } diff --git a/StrategySpace/Workspace.js b/StrategySpace/Workspace.js index 4d2780a16..911470e55 100644 --- a/StrategySpace/Workspace.js +++ b/StrategySpace/Workspace.js @@ -269,6 +269,13 @@ function newWorkspace () { case 'Edit Code': + break + case 'Download': + + let text = JSON.stringify(getProtocolNode(payload.node)) + let fileName = payload.node.type + '.' + payload.node.name + '.json' + download(fileName, text) + break case 'Add Phase': { @@ -407,4 +414,59 @@ function newWorkspace () { node.payload = undefined node.cleaned = true } + + function download (filename, text) { + let element = document.createElement('a') + element.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text)) + element.setAttribute('download', filename) + element.style.display = 'none' + document.body.appendChild(element) + element.click() + document.body.removeChild(element) + } + + function getProtocolNode (node) { + switch (node.type) { + case 'Condition': + { + let condition = { + type: node.type, + name: node.name, + code: node.code + } + return condition + break + } + case 'Situation': { + let situation = { + type: node.type, + name: node.name, + conditions: [] + } + + for (let m = 0; m < node.conditions.length; m++) { + let condition = getProtocolNode(node.conditions[m]) + situation.conditions.push(condition) + } + return situation + break + } + case 'Phase': { + let phase = { + type: node.type, + subType: node.subType, + name: node.name, + code: node.code, + situations: [] + } + + for (let m = 0; m < node.situations.length; m++) { + let situation = getProtocolNode(node.situations[m]) + phase.situations.push(situation) + } + return phase + break + } + } + } } From ff132b4e2b09e023199c2384128effb986256b79 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 21 May 2019 11:12:37 +0200 Subject: [PATCH 2/8] Stop and Take Profit can be downlaoded --- FloatingSpace/StrategyPartConstructor.js | 28 +++++++++++++++-- StrategySpace/Workspace.js | 39 +++++++++++++++++++++++- 2 files changed, 64 insertions(+), 3 deletions(-) diff --git a/FloatingSpace/StrategyPartConstructor.js b/FloatingSpace/StrategyPartConstructor.js index f010175d2..fb58e0b87 100644 --- a/FloatingSpace/StrategyPartConstructor.js +++ b/FloatingSpace/StrategyPartConstructor.js @@ -282,7 +282,19 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: 0 + angle: -20 + }, + { + action: 'Download', + actionFunction: payload.onMenuItemClick, + label: 'Download', + visible: false, + iconPathOn: 'upload', + iconPathOff: 'upload', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 20 }] break } @@ -312,7 +324,19 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: 0 + angle: -20 + }, + { + action: 'Download', + actionFunction: payload.onMenuItemClick, + label: 'Download', + visible: false, + iconPathOn: 'upload', + iconPathOff: 'upload', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 20 }] break } diff --git a/StrategySpace/Workspace.js b/StrategySpace/Workspace.js index 911470e55..60fddc367 100644 --- a/StrategySpace/Workspace.js +++ b/StrategySpace/Workspace.js @@ -273,7 +273,13 @@ function newWorkspace () { case 'Download': let text = JSON.stringify(getProtocolNode(payload.node)) - let fileName = payload.node.type + '.' + payload.node.name + '.json' + let nodeName = payload.node.name + if (nodeName === undefined) { + nodeName = '' + } else { + nodeName = '.' + nodeName + } + let fileName = payload.node.type + nodeName + '.json' download(fileName, text) break @@ -467,6 +473,37 @@ function newWorkspace () { return phase break } + case 'Stop': { + let stop = { + type: node.type, + subType: node.subType, + name: node.name, + phases: [] + } + + for (let m = 0; m < node.phases.length; m++) { + let phase = getProtocolNode(node.phases[m]) + stop.phases.push(phase) + } + return stop + break + } + case 'Take Profit': { + let takeProfit = { + type: node.type, + subType: node.subType, + name: node.name, + phases: [] + } + + for (let m = 0; m < node.phases.length; m++) { + let phase = getProtocolNode(node.phases[m]) + takeProfit.phases.push(phase) + } + return takeProfit + break + } } } } + From 73f78908370c9cc75655145b9f05844b5a55a4e1 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 21 May 2019 11:26:03 +0200 Subject: [PATCH 3/8] Events can download --- FloatingSpace/StrategyPartConstructor.js | 42 ++++++++++++++++++++-- StrategySpace/Workspace.js | 46 +++++++++++++++++++++++- 2 files changed, 84 insertions(+), 4 deletions(-) diff --git a/FloatingSpace/StrategyPartConstructor.js b/FloatingSpace/StrategyPartConstructor.js index fb58e0b87..40f37a09b 100644 --- a/FloatingSpace/StrategyPartConstructor.js +++ b/FloatingSpace/StrategyPartConstructor.js @@ -192,7 +192,19 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: 0 + angle: -20 + }, + { + action: 'Download', + actionFunction: payload.onMenuItemClick, + label: 'Download', + visible: false, + iconPathOn: 'upload', + iconPathOff: 'upload', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 20 }] break } @@ -222,7 +234,19 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: 0 + angle: -20 + }, + { + action: 'Download', + actionFunction: payload.onMenuItemClick, + label: 'Download', + visible: false, + iconPathOn: 'upload', + iconPathOff: 'upload', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 20 }] break } @@ -252,7 +276,19 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: 0 + angle: -20 + }, + { + action: 'Download', + actionFunction: payload.onMenuItemClick, + label: 'Download', + visible: false, + iconPathOn: 'upload', + iconPathOff: 'upload', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 20 }] break } diff --git a/StrategySpace/Workspace.js b/StrategySpace/Workspace.js index 60fddc367..ad4e38160 100644 --- a/StrategySpace/Workspace.js +++ b/StrategySpace/Workspace.js @@ -503,7 +503,51 @@ function newWorkspace () { return takeProfit break } + case 'Trade Entry Event': { + let event = { + type: node.type, + subType: node.subType, + name: node.name, + situations: [] + } + + for (let m = 0; m < node.situations.length; m++) { + let situation = getProtocolNode(node.situations[m]) + event.situations.push(situation) + } + return event + break + } + case 'Strategy Entry Event': { + let event = { + type: node.type, + subType: node.subType, + name: node.name, + situations: [] + } + + for (let m = 0; m < node.situations.length; m++) { + let situation = getProtocolNode(node.situations[m]) + event.situations.push(situation) + } + return event + break + } + case 'Strategy Exit Event': { + let event = { + type: node.type, + subType: node.subType, + name: node.name, + situations: [] + } + + for (let m = 0; m < node.situations.length; m++) { + let situation = getProtocolNode(node.situations[m]) + event.situations.push(situation) + } + return event + break + } } } } - From 632b49ad16cece2393c3aa61a9b8924c8c90be78 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 21 May 2019 11:41:34 +0200 Subject: [PATCH 4/8] Everything can be downloaded now --- FloatingSpace/StrategyPartConstructor.js | 36 ++++++++++++++++++++---- StrategySpace/Workspace.js | 29 +++++++++++++++++++ 2 files changed, 59 insertions(+), 6 deletions(-) diff --git a/FloatingSpace/StrategyPartConstructor.js b/FloatingSpace/StrategyPartConstructor.js index 40f37a09b..92583dfb7 100644 --- a/FloatingSpace/StrategyPartConstructor.js +++ b/FloatingSpace/StrategyPartConstructor.js @@ -81,7 +81,7 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: -60 + angle: -80 }, { action: 'Save Trading System', @@ -96,7 +96,7 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: -20 + angle: -40 }, { action: 'New Strategy', @@ -109,7 +109,7 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: 20 + angle: 0 }, { action: 'Open Settings', @@ -121,7 +121,19 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: 60 + angle: 40 + }, + { + action: 'Download', + actionFunction: payload.onMenuItemClick, + label: 'Download', + visible: false, + iconPathOn: 'upload', + iconPathOff: 'upload', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 80 }] break } @@ -150,7 +162,7 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: -20 + angle: -40 }, { action: 'Open Settings', @@ -162,7 +174,19 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: 20 + angle: 0 + }, + { + action: 'Download', + actionFunction: payload.onMenuItemClick, + label: 'Download', + visible: false, + iconPathOn: 'upload', + iconPathOff: 'upload', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: 40 }] break } diff --git a/StrategySpace/Workspace.js b/StrategySpace/Workspace.js index ad4e38160..d0e5dc976 100644 --- a/StrategySpace/Workspace.js +++ b/StrategySpace/Workspace.js @@ -548,6 +548,35 @@ function newWorkspace () { return event break } + case 'Strategy': { + let strategy = { + type: node.type, + subType: node.subType, + name: node.name, + entryPoint: getProtocolNode(node.entryPoint), + exitPoint: getProtocolNode(node.exitPoint), + sellPoint: getProtocolNode(node.sellPoint), + stopLoss: getProtocolNode(node.stopLoss), + buyOrder: getProtocolNode(node.buyOrder) + } + return strategy + break + } + case 'Trading System': { + let tradingSystem = { + type: node.type, + subType: node.subType, + name: node.name, + strategies: [] + } + + for (let m = 0; m < node.strategies.length; m++) { + let strategy = getProtocolNode(node.strategies[m]) + tradingSystem.strategies.push(strategy) + } + return tradingSystem + break + } } } } From c74d375d203587c9d1841f05952be942a1b2fe06 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 21 May 2019 12:26:53 +0200 Subject: [PATCH 5/8] Delete Strategy Implemented --- FloatingSpace/StrategyPartConstructor.js | 26 ++++++++-------- StrategySpace/Workspace.js | 38 ++++++++++++++++++++++++ 2 files changed, 51 insertions(+), 13 deletions(-) diff --git a/FloatingSpace/StrategyPartConstructor.js b/FloatingSpace/StrategyPartConstructor.js index 92583dfb7..498ce0834 100644 --- a/FloatingSpace/StrategyPartConstructor.js +++ b/FloatingSpace/StrategyPartConstructor.js @@ -152,18 +152,6 @@ function newStrategyPartConstructor () { currentRadius: 0, angle: -135 }, - { - action: 'Delete Strategy', - actionFunction: payload.onMenuItemClick, - label: 'Delete This Strategy', - visible: false, - iconPathOn: 'trash', - iconPathOff: 'trash', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - }, { action: 'Open Settings', actionFunction: payload.onMenuItemClick, @@ -174,7 +162,19 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: 0 + angle: -40 + }, + { + action: 'Delete Strategy', + actionFunction: payload.onMenuItemClick, + label: 'Delete This Strategy', + visible: false, + iconPathOn: 'trash', + iconPathOff: 'trash', + rawRadius: 8, + targetRadius: 0, + currentRadius: 0, + angle: -0 }, { action: 'Download', diff --git a/StrategySpace/Workspace.js b/StrategySpace/Workspace.js index d0e5dc976..693d55112 100644 --- a/StrategySpace/Workspace.js +++ b/StrategySpace/Workspace.js @@ -326,6 +326,10 @@ function newWorkspace () { createPart('Condition', condition.name, condition, situation, situation, 'Condition') } break + case 'Delete Strategy': { + deleteStrategy(payload.node) + break + } case 'Delete Phase': { deletePhase(payload.node) break @@ -343,6 +347,40 @@ function newWorkspace () { } } + function deleteStrategy (node) { + let payload = node.payload + for (let j = 0; j < payload.parentNode.strategies.length; j++) { + let strategy = payload.parentNode.strategies[j] + if (strategy.id === node.id) { + deleteEvent(strategy.entryPoint) + deleteEvent(strategy.exitPoint) + deleteEvent(strategy.sellPoint) + deleteManagedItem(strategy.stopLoss) + deleteManagedItem(strategy.buyOrder) + destroyPart(strategy) + payload.parentNode.strategies.splice(j, 1) + cleanNode(strategy) + return + } + } + } + + function deleteEvent (node) { + while (node.situations.length > 0) { + deleteSituation(node.situations[0]) + } + destroyPart(node) + cleanNode(node) + } + + function deleteManagedItem (node) { + while (node.phases.length > 0) { + deletePhase(node.phases[0]) + } + destroyPart(node) + cleanNode(node) + } + function deletePhase (node) { let payload = node.payload for (let k = 0; k < payload.parentNode.phases.length; k++) { From da34289a91e9712b44f1074ced75dad5f0945b14 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 21 May 2019 12:34:35 +0200 Subject: [PATCH 6/8] Menues Reorg --- FloatingSpace/StrategyPartConstructor.js | 42 ++---------------------- 1 file changed, 3 insertions(+), 39 deletions(-) diff --git a/FloatingSpace/StrategyPartConstructor.js b/FloatingSpace/StrategyPartConstructor.js index 498ce0834..687a01332 100644 --- a/FloatingSpace/StrategyPartConstructor.js +++ b/FloatingSpace/StrategyPartConstructor.js @@ -71,18 +71,6 @@ function newStrategyPartConstructor () { currentRadius: 0, angle: -135 }, - { - action: 'Reload Trading System', - actionFunction: payload.onMenuItemClick, - label: 'Reload', - visible: false, - iconPathOn: 'vector', - iconPathOff: 'vector', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -80 - }, { action: 'Save Trading System', actionFunction: payload.onMenuItemClick, @@ -111,18 +99,6 @@ function newStrategyPartConstructor () { currentRadius: 0, angle: 0 }, - { - action: 'Open Settings', - actionFunction: payload.onMenuItemClick, - label: 'Settings', - visible: false, - iconPathOn: 'tools', - iconPathOff: 'tools', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: 40 - }, { action: 'Download', actionFunction: payload.onMenuItemClick, @@ -133,7 +109,7 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: 80 + angle: 40 }] break } @@ -152,18 +128,6 @@ function newStrategyPartConstructor () { currentRadius: 0, angle: -135 }, - { - action: 'Open Settings', - actionFunction: payload.onMenuItemClick, - label: 'Settings', - visible: false, - iconPathOn: 'tools', - iconPathOff: 'tools', - rawRadius: 8, - targetRadius: 0, - currentRadius: 0, - angle: -40 - }, { action: 'Delete Strategy', actionFunction: payload.onMenuItemClick, @@ -174,7 +138,7 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: -0 + angle: -20 }, { action: 'Download', @@ -186,7 +150,7 @@ function newStrategyPartConstructor () { rawRadius: 8, targetRadius: 0, currentRadius: 0, - angle: 40 + angle: 20 }] break } From 69f48964af04616aa43d305e7d607ee0f83751c7 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 21 May 2019 13:03:56 +0200 Subject: [PATCH 7/8] Can Add new Strategies --- StrategySpace/Workspace.js | 115 +++++++++++-------------------------- 1 file changed, 35 insertions(+), 80 deletions(-) diff --git a/StrategySpace/Workspace.js b/StrategySpace/Workspace.js index 693d55112..03d21d91a 100644 --- a/StrategySpace/Workspace.js +++ b/StrategySpace/Workspace.js @@ -175,73 +175,7 @@ function newWorkspace () { } function destroyStrategyParts () { - let strategy = thisObject.tradingSystem - destroyPart(strategy) - destroyPart(strategy.entryPoint) - for (let k = 0; k < strategy.entryPoint.situations.length; k++) { - let situation = strategy.entryPoint.situations[k] - destroyPart(situation) - - for (let m = 0; m < situation.conditions.length; m++) { - let condition = situation.conditions[m] - destroyPart(condition) - } - } - - destroyPart(strategy.exitPoint) - for (let k = 0; k < strategy.exitPoint.situations.length; k++) { - let situation = strategy.exitPoint.situations[k] - destroyPart(situation) - - for (let m = 0; m < situation.conditions.length; m++) { - let condition = situation.conditions[m] - destroyPart(condition) - } - } - - destroyPart(strategy.sellPoint) - for (let k = 0; k < strategy.sellPoint.situations.length; k++) { - let situation = strategy.sellPoint.situations[k] - destroyPart(situation) - - for (let m = 0; m < situation.conditions.length; m++) { - let condition = situation.conditions[m] - destroyPart(condition) - } - } - - destroyPart(strategy.stopLoss) - for (let p = 0; p < strategy.stopLoss.phases.length; p++) { - let phase = strategy.stopLoss.phases[p] - destroyPart(strategy.stopLoss) - - for (let k = 0; k < phase.situations.length; k++) { - let situation = phase.situations[k] - destroyPart(situation) - - for (let m = 0; m < situation.conditions.length; m++) { - let condition = situation.conditions[m] - destroyPart(condition) - } - } - } - - destroyPart(strategy.buyOrder) - for (let p = 0; p < strategy.buyOrder.phases.length; p++) { - let phase = strategy.buyOrder.phases[p] - destroyPart(strategy.buyOrder) - - for (let k = 0; k < phase.situations.length; k++) { - let situation = phase.situations[k] - destroyPart(situation) - - for (let m = 0; m < situation.conditions.length; m++) { - let condition = situation.conditions[m] - destroyPart(condition) - } - } - } } async function onMenuItemClick (payload, action) { @@ -253,20 +187,6 @@ function newWorkspace () { break } - case 'Open Settings': - break - case 'Delete Strategy': - - break - - case 'Reload Strategy': - - break - - case 'Save Strategy': - - break - case 'Edit Code': break @@ -283,6 +203,40 @@ function newWorkspace () { download(fileName, text) break + + case 'New Strategy': + { + let strategyParent = payload.node + + let strategy = { + name: 'New Strategy', + active: true, + entryPoint: { + situations: [] + }, + exitPoint: { + situations: [] + }, + sellPoint: { + situations: [] + }, + stopLoss: { + phases: [] + }, + buyOrder: { + phases: [] + } + } + + strategyParent.strategies.push(strategy) + createPart('Strategy', strategy.name, strategy, strategyParent, strategyParent, 'Strategy') + createPart('Strategy Entry Event', '', strategy.entryPoint, strategy, strategy) + createPart('Strategy Exit Event', '', strategy.exitPoint, strategy, strategy) + createPart('Trade Entry Event', '', strategy.sellPoint, strategy, strategy) + createPart('Stop', '', strategy.stopLoss, strategy, strategy) + createPart('Take Profit', '', strategy.buyOrder, strategy, strategy) + } + break case 'Add Phase': { let phaseParent = payload.node @@ -618,3 +572,4 @@ function newWorkspace () { } } } + From 89443d2a6d5794733b60ad56f717c3539bb98aea Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Tue, 21 May 2019 14:58:43 +0200 Subject: [PATCH 8/8] BUG FIXED deleting strategies --- StrategySpace/Workspace.js | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/StrategySpace/Workspace.js b/StrategySpace/Workspace.js index 03d21d91a..c118b191a 100644 --- a/StrategySpace/Workspace.js +++ b/StrategySpace/Workspace.js @@ -340,17 +340,9 @@ function newWorkspace () { for (let k = 0; k < payload.parentNode.phases.length; k++) { let phase = payload.parentNode.phases[k] if (phase.id === node.id) { - for (let j = 0; j < phase.situations.length; j++) { - let situation = phase.situations[j] - for (let i = 0; i < situation.conditions.length; i++) { - let condition = situation.conditions[i] - destroyPart(condition) - cleanNode(condition) - } - situation.conditions = [] - destroyPart(situation) - phase.situations.splice(j, 1) - cleanNode(situation) + while (phase.situations.length > 0) { + let situation = phase.situations[0] + deleteSituation(situation) } phase.situations = [] /* Before deleting this phase we need to give its chainParent to the next phase down the chain */ @@ -371,10 +363,9 @@ function newWorkspace () { for (let j = 0; j < payload.parentNode.situations.length; j++) { let situation = payload.parentNode.situations[j] if (situation.id === node.id) { - for (let i = 0; i < situation.conditions.length; i++) { - let condition = situation.conditions[i] - destroyPart(condition) - cleanNode(condition) + while (situation.conditions.length > 0) { + let condition = situation.conditions[0] + deleteCondition(condition) } situation.conditions = [] destroyPart(situation) @@ -572,4 +563,3 @@ function newWorkspace () { } } } -