diff --git a/ChartingSpace/PlottersManager.js b/ChartingSpace/PlottersManager.js index a0002b6fa..e660e48de 100644 --- a/ChartingSpace/PlottersManager.js +++ b/ChartingSpace/PlottersManager.js @@ -99,7 +99,7 @@ function newPlottersManager () { for (let i = 0; i < layer.definition.referenceParent.referenceParent.datasets.length; i++) { let dataset = layer.definition.referenceParent.referenceParent.datasets[i] - switch (dataset.code.type) { + switch (dataset.config.type) { case 'Market Files': { storage.onMarketFileLoadedLayerEventsSubscriptionId = storage.eventHandler.listenToEvent('Market File Loaded', layer.onMarketFileLoaded) } @@ -125,8 +125,8 @@ function newPlottersManager () { } } - let baseAsset = layer.definition.referenceParent.parentNode.referenceParent.baseAsset.referenceParent.code.codeName - let quotedAsset = layer.definition.referenceParent.parentNode.referenceParent.quotedAsset.referenceParent.code.codeName + let baseAsset = layer.definition.referenceParent.parentNode.referenceParent.baseAsset.referenceParent.config.codeName + let quotedAsset = layer.definition.referenceParent.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName let market = { baseAsset: baseAsset, quotedAsset: quotedAsset @@ -146,8 +146,8 @@ function newPlottersManager () { } } - let host = layer.networkNode.code.host - let webPort = layer.networkNode.code.webPort + let host = layer.networkNode.config.host + let webPort = layer.networkNode.config.webPort if (host === undefined) { host = 'localhost' } if (webPort === undefined) { webPort = window.location.port } @@ -174,10 +174,10 @@ function newPlottersManager () { /* Now we have all the initial data loaded and ready to be delivered to the new instance of the plotter. */ let plotter - if (plotterModule.code.isLegacy !== true) { + if (plotterModule.config.isLegacy !== true) { plotter = newPlotter() } else { - plotter = getNewPlotter(dataMine.code.codeName, plotterModule.parentNode.code.codeName, plotterModule.code.codeName) + plotter = getNewPlotter(dataMine.config.codeName, plotterModule.parentNode.config.codeName, plotterModule.config.codeName) } plotter.container.connectToParent(thisObject.container, true, true, false, true, true, true, false, false, true) @@ -203,9 +203,9 @@ function newPlottersManager () { let panel = plotterModule.panels[i] let parameters = { - dataMine: dataMine.code.codeName, - plotterCodeName: plotterModule.parentNode.code.codeName, - moduleCodeName: plotterModule.code.codeName, + dataMine: dataMine.config.codeName, + plotterCodeName: plotterModule.parentNode.config.codeName, + moduleCodeName: plotterModule.config.codeName, panelNode: panel } diff --git a/ChartingSpace/Viewport.js b/ChartingSpace/Viewport.js index 4f60172be..5bd837de8 100644 --- a/ChartingSpace/Viewport.js +++ b/ChartingSpace/Viewport.js @@ -369,10 +369,10 @@ function newViewport () { /* Save the zoom at the node config, so that the user can change it if he wishes to. */ try { - let code = JSON.parse(thisObject.payload.node.code) - code.zoom = (thisObject.zoomTargetLevel - MIN_ZOOM_LEVEL) / (MAX_ZOOM_LEVEL - MIN_ZOOM_LEVEL) * 100 - code.zoom = code.zoom.toFixed(2) - thisObject.payload.node.code = JSON.stringify(code) + let config = JSON.parse(thisObject.payload.node.config) + config.zoom = (thisObject.zoomTargetLevel - MIN_ZOOM_LEVEL) / (MAX_ZOOM_LEVEL - MIN_ZOOM_LEVEL) * 100 + config.zoom = config.zoom.toFixed(2) + thisObject.payload.node.config = JSON.stringify(config) } catch (err) { // we ignore errors here since most likely they will be parsing errors. } @@ -383,18 +383,18 @@ function newViewport () { /* Read the zoom level from the node config */ try { - let code = JSON.parse(thisObject.payload.node.code) + let config = JSON.parse(thisObject.payload.node.config) - if (isNaN(code.zoom) || code.zoom === null || code.zoom === undefined) { + if (isNaN(config.zoom) || config.zoom === null || config.zoom === undefined) { saveObjectState() return } - code.zoom = code.zoom / 100 * (MAX_ZOOM_LEVEL - MIN_ZOOM_LEVEL) + MIN_ZOOM_LEVEL - if (code.zoom < MIN_ZOOM_LEVEL) { code.zoom = MIN_ZOOM_LEVEL } - if (code.zoom > MAX_ZOOM_LEVEL) { code.zoom = MAX_ZOOM_LEVEL } + config.zoom = config.zoom / 100 * (MAX_ZOOM_LEVEL - MIN_ZOOM_LEVEL) + MIN_ZOOM_LEVEL + if (config.zoom < MIN_ZOOM_LEVEL) { config.zoom = MIN_ZOOM_LEVEL } + if (config.zoom > MAX_ZOOM_LEVEL) { config.zoom = MAX_ZOOM_LEVEL } - if (code.zoom.toFixed(2) !== thisObject.zoomTargetLevel.toFixed(2)) { - newZoomLevel(code.zoom) + if (config.zoom.toFixed(2) !== thisObject.zoomTargetLevel.toFixed(2)) { + newZoomLevel(config.zoom) } else { saveObjectState() } diff --git a/DesignSpace/Workspace/FunctionLibraries/CCXTFunctions.js b/DesignSpace/Workspace/FunctionLibraries/CCXTFunctions.js index e89b15e3b..047c4dcf3 100644 --- a/DesignSpace/Workspace/FunctionLibraries/CCXTFunctions.js +++ b/DesignSpace/Workspace/FunctionLibraries/CCXTFunctions.js @@ -44,7 +44,7 @@ function newCCXTFunctions () { if (existingExchange === undefined) { let newExchange = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Crypto Exchange') newExchange.name = exchange.name - newExchange.code = '{ \n\"codeName\": \"' + exchange.id + '\"\n}' + newExchange.config = '{ \n\"codeName\": \"' + exchange.id + '\"\n}' newExchange.payload.floatingObject.collapseToggle() newExchange.exchangeAssets.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180 newExchange.exchangeMarkets.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180 @@ -114,7 +114,7 @@ function newCCXTFunctions () { function addAsset (name) { let newAsseet = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Asset') newAsseet.name = name - newAsseet.code = '{ \n\"codeName\": \"' + name + '\"\n}' + newAsseet.config = '{ \n\"codeName\": \"' + name + '\"\n}' } } } @@ -182,7 +182,7 @@ function newCCXTFunctions () { function addMarket (name, baseAsset, quotedAsset) { let newMarket = functionLibraryUiObjectsFromNodes.addUIObject(node, 'Market') newMarket.name = name - newMarket.code = '{ \n\"codeName\": \"' + name + '\"\n}' + newMarket.config = '{ \n\"codeName\": \"' + name + '\"\n}' newMarket.payload.floatingObject.angleToParent = ANGLE_TO_PARENT.RANGE_180 newMarket.payload.floatingObject.distanceToParent = DISTANCE_TO_PARENT.PARENT_050X newMarket.payload.floatingObject.arrangementStyle = ARRANGEMENT_STYLE.CONCAVE diff --git a/DesignSpace/Workspace/FunctionLibraries/NodeCloning.js b/DesignSpace/Workspace/FunctionLibraries/NodeCloning.js index 6b7d1559f..6de8afad8 100644 --- a/DesignSpace/Workspace/FunctionLibraries/NodeCloning.js +++ b/DesignSpace/Workspace/FunctionLibraries/NodeCloning.js @@ -19,12 +19,13 @@ function newNodeCloning () { function cloneNode (node) { if (node === undefined) { return } - let nodeDefinition = getNodeDefinition (node) + let nodeDefinition = getNodeDefinition(node) if (nodeDefinition !== undefined) { let object = { type: node.type, name: node.name, - code: node.code + code: node.code, + config: node.config } /* Children Nodes */ @@ -71,12 +72,13 @@ function newNodeCloning () { function redirectReferenceParents (node) { if (node === undefined) { return } - let nodeDefinition = getNodeDefinition (node) + let nodeDefinition = getNodeDefinition(node) if (nodeDefinition !== undefined) { let object = { type: node.type, name: node.name, - code: node.code + code: node.code, + config: node.config } /* Children Nodes */ diff --git a/DesignSpace/Workspace/FunctionLibraries/ProtocolNode.js b/DesignSpace/Workspace/FunctionLibraries/ProtocolNode.js index c351819bf..a6a533549 100644 --- a/DesignSpace/Workspace/FunctionLibraries/ProtocolNode.js +++ b/DesignSpace/Workspace/FunctionLibraries/ProtocolNode.js @@ -9,17 +9,18 @@ function newProtocolNode () { } return thisObject - function getProtocolNode (node, removePersonalData, parseCode, includeIds, includePayload, includeReferencesInSavedPayload, lightingPath) { + function getProtocolNode (node, removePersonalData, parseConfig, includeIds, includePayload, includeReferencesInSavedPayload, lightingPath) { if (node === undefined) { return } if (node.payload === undefined) { return } - let nodeDefinition = getNodeDefinition (node) + let nodeDefinition = getNodeDefinition(node) if (nodeDefinition !== undefined) { if (removePersonalData === true && nodeDefinition.isPersonalData === true) { return } let object = { type: node.type, name: node.name, - code: node.code + code: node.code, + config: node.config } /* Children Nodes */ @@ -31,11 +32,11 @@ function newProtocolNode () { case 'node': { if (node[property.name] !== undefined) { if (lightingPath === undefined) { - object[property.name] = getProtocolNode(node[property.name], removePersonalData, parseCode, includeIds, includeReferencesInSavedPayload, includePayload) + object[property.name] = getProtocolNode(node[property.name], removePersonalData, parseConfig, includeIds, includeReferencesInSavedPayload, includePayload) } else { let newLightingPath = getNewLightingPath(lightingPath, node.type, property.childType) if (newLightingPath !== undefined) { - object[property.name] = getProtocolNode(node[property.name], removePersonalData, parseCode, includeIds, includePayload, includeReferencesInSavedPayload, newLightingPath) + object[property.name] = getProtocolNode(node[property.name], removePersonalData, parseConfig, includeIds, includePayload, includeReferencesInSavedPayload, newLightingPath) } } } @@ -47,7 +48,7 @@ function newProtocolNode () { let nodePropertyArray = node[property.name] object[property.name] = [] for (let m = 0; m < nodePropertyArray.length; m++) { - let protocolNode = getProtocolNode(nodePropertyArray[m], removePersonalData, parseCode, includeIds, includeReferencesInSavedPayload, includePayload) + let protocolNode = getProtocolNode(nodePropertyArray[m], removePersonalData, parseConfig, includeIds, includeReferencesInSavedPayload, includePayload) if (protocolNode !== undefined) { object[property.name].push(protocolNode) } @@ -58,7 +59,7 @@ function newProtocolNode () { let nodePropertyArray = node[property.name] object[property.name] = [] for (let m = 0; m < nodePropertyArray.length; m++) { - let protocolNode = getProtocolNode(nodePropertyArray[m], removePersonalData, parseCode, includeIds, includePayload, includeReferencesInSavedPayload, newLightingPath) + let protocolNode = getProtocolNode(nodePropertyArray[m], removePersonalData, parseConfig, includeIds, includePayload, includeReferencesInSavedPayload, newLightingPath) if (protocolNode !== undefined) { object[property.name].push(protocolNode) } @@ -76,25 +77,25 @@ function newProtocolNode () { if (node.payload.parentNode !== undefined) { let newLightingPath = getNewLightingPath(lightingPath, node.type, node.payload.parentNode.type) if (newLightingPath !== undefined) { - object.parentNode = getProtocolNode(node.payload.parentNode, removePersonalData, parseCode, includeIds, includePayload, includeReferencesInSavedPayload, newLightingPath) + object.parentNode = getProtocolNode(node.payload.parentNode, removePersonalData, parseConfig, includeIds, includePayload, includeReferencesInSavedPayload, newLightingPath) } } if (node.payload.referenceParent !== undefined) { let newLightingPath = getNewLightingPath(lightingPath, node.type, node.payload.referenceParent.type) if (newLightingPath !== undefined) { - object.referenceParent = getProtocolNode(node.payload.referenceParent, removePersonalData, parseCode, includeIds, includePayload, includeReferencesInSavedPayload, newLightingPath) + object.referenceParent = getProtocolNode(node.payload.referenceParent, removePersonalData, parseConfig, includeIds, includePayload, includeReferencesInSavedPayload, newLightingPath) } } - if (parseCode && object.code !== undefined && nodeDefinition.editors !== undefined) { + if (parseConfig && object.config !== undefined && nodeDefinition.editors !== undefined) { if (nodeDefinition.editors.config === true) { try { - object.code = JSON.parse(node.code) + object.config = JSON.parse(node.config) } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] getProtocolNode -> default -> err = ' + err.stack) } if (ERROR_LOG === true) { logger.write('[ERROR] getProtocolNode -> default -> node.type = ' + node.type) } if (ERROR_LOG === true) { logger.write('[ERROR] getProtocolNode -> default -> node.name = ' + node.name) } - if (ERROR_LOG === true) { logger.write('[ERROR] getProtocolNode -> default -> node.code = ' + node.code) } + if (ERROR_LOG === true) { logger.write('[ERROR] getProtocolNode -> default -> node.config = ' + node.config) } if (ERROR_LOG === true) { logger.write('[ERROR] getProtocolNode -> default -> node.id = ' + node.id) } } } diff --git a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js index db40e3f0f..81490f399 100644 --- a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -26,14 +26,14 @@ function newUiObjectsFromNodes () { function addIncludedNodes () { let blobService = newFileStorage() - // if (node.code === undefined) { - node.code = '{ \n"includeDataMines": ["Masters", "Sparta", "TradingEngines"],\n"includeTradingSystems": ["Sparta-WHB-BTC-USDT", "Example-ETH-USDT", "Sparta-BRR-BTC-USDT"],\n"includeSuperScripts": ["Masters"]\n }' + // if (node.config === undefined) { + node.config = '{ \n"includeDataMines": ["Masters", "Sparta", "TradingEngines"],\n"includeTradingSystems": ["Sparta-WHB-BTC-USDT", "Example-ETH-USDT", "Sparta-BRR-BTC-USDT"],\n"includeSuperScripts": ["Masters"]\n }' // } - let code = JSON.parse(node.code) - let includeDataMines = code.includeDataMines - let includeTradingSystems = code.includeTradingSystems - let includeSuperScripts = code.includeSuperScripts + let config = JSON.parse(node.config) + let includeDataMines = config.includeDataMines + let includeTradingSystems = config.includeTradingSystems + let includeSuperScripts = config.includeSuperScripts let totalIncluded = 0 @@ -49,9 +49,9 @@ function newUiObjectsFromNodes () { for (let i = 0; i < node.rootNodes.length; i++) { let rootNode = node.rootNodes[i] if (rootNode.type === 'Data Mine') { - if (rootNode.code !== undefined) { - let code = JSON.parse(rootNode.code) - if (code.name === name) { + if (rootNode.config !== undefined) { + let config = JSON.parse(rootNode.config) + if (config.name === name) { rootNodes.splice(i, 1) } } @@ -78,9 +78,9 @@ function newUiObjectsFromNodes () { for (let i = 0; i < node.rootNodes.length; i++) { let rootNode = node.rootNodes[i] if (rootNode.type === 'Trading System') { - if (rootNode.code !== undefined) { - let code = JSON.parse(rootNode.code) - if (code.name === name) { + if (rootNode.config !== undefined) { + let config = JSON.parse(rootNode.config) + if (config.name === name) { rootNodes.splice(i, 1) } } @@ -107,9 +107,9 @@ function newUiObjectsFromNodes () { for (let i = 0; i < node.rootNodes.length; i++) { let rootNode = node.rootNodes[i] if (rootNode.type === 'Super Scripts') { - if (rootNode.code !== undefined) { - let code = JSON.parse(rootNode.code) - if (code.name === name) { + if (rootNode.config !== undefined) { + let config = JSON.parse(rootNode.config) + if (config.name === name) { rootNodes.splice(i, 1) } } @@ -179,10 +179,23 @@ function newUiObjectsFromNodes () { } } + function migrateCodeToConfig (node, nodeDefinition) { + if (nodeDefinition.editors !== undefined) { + if (nodeDefinition.editors.config === true) { + if (node.code !== undefined) { + node.config = node.code + node.code = undefined + } + } + } + } + function createUiObjectFromNode (node, parentNode, chainParent, positionOffset) { /* Get node definition */ - let nodeDefinition = getNodeDefinition (node) + let nodeDefinition = getNodeDefinition(node) if (nodeDefinition !== undefined) { + migrateCodeToConfig(node, nodeDefinition) + /* Resolve Initial Values */ if (nodeDefinition.initialValues !== undefined) { if (nodeDefinition.initialValues.code !== undefined) { @@ -190,12 +203,17 @@ function newUiObjectsFromNodes () { node.code = nodeDefinition.initialValues.code } } + if (nodeDefinition.initialValues.config !== undefined) { + if (node.config === undefined) { + node.config = nodeDefinition.initialValues.config + } + } } /* For the cases where an node is not chained to its parent but to the one at the parent before it at its collection */ if (nodeDefinition.chainedToSameType === true) { if (parentNode !== undefined) { - let parentNodeDefinition = getNodeDefinition (parentNode) + let parentNodeDefinition = getNodeDefinition(parentNode) if (parentNodeDefinition !== undefined) { if (parentNodeDefinition.properties !== undefined) { for (let i = 0; i < parentNodeDefinition.properties.length; i++) { @@ -263,12 +281,12 @@ function newUiObjectsFromNodes () { type: type } - let parentNodeDefinition = getNodeDefinition (parentNode) + let parentNodeDefinition = getNodeDefinition(parentNode) if (parentNodeDefinition === undefined) { console.log('Cannot addUIOBject from parent of ' + type + ' because that type it is not defined at the APP_SCHEMA.') } /* Resolve Initial Values */ - let nodeDefinition = getNodeDefinition (object) + let nodeDefinition = getNodeDefinition(object) if (nodeDefinition === undefined) { console.log('Cannot addUIOBject of ' + type + ' because that type it is not defined at the APP_SCHEMA.') @@ -279,6 +297,11 @@ function newUiObjectsFromNodes () { object.code = nodeDefinition.initialValues.code } } + if (nodeDefinition.initialValues !== undefined) { + if (nodeDefinition.initialValues.config !== undefined) { + object.config = nodeDefinition.initialValues.config + } + } if (nodeDefinition.isHierarchyHead === true) { parentNode.rootNodes.push(object) @@ -321,6 +344,9 @@ function newUiObjectsFromNodes () { if (nodeDefinition.initialValues.code !== undefined) { object.code = nodeDefinition.initialValues.code } + if (nodeDefinition.initialValues.config !== undefined) { + object.config = nodeDefinition.initialValues.config + } } } @@ -393,7 +419,7 @@ function newUiObjectsFromNodes () { } function addMissingChildren (node) { - let nodeDefinition = getNodeDefinition (node) + let nodeDefinition = getNodeDefinition(node) /* Connect to Parent */ if (nodeDefinition.properties !== undefined) { diff --git a/DesignSpace/Workspace/Workspace.js b/DesignSpace/Workspace/Workspace.js index c386ffea1..4882502b8 100644 --- a/DesignSpace/Workspace/Workspace.js +++ b/DesignSpace/Workspace/Workspace.js @@ -148,9 +148,9 @@ function newWorkspace () { let webSocketsPort /* At this point the node does not have the payload property yet, that is why we have to do this manually */ try { - let code = JSON.parse(networkNode.code) - host = code.host - webSocketsPort = code.webSocketsPort + let config = JSON.parse(networkNode.config) + host = config.host + webSocketsPort = config.webSocketsPort } catch (err) { console.log('[ERROR] networkNode ' + networkNode.name + ' has an invalid configuration. Cannot know the host name and webSocketsPort.') return @@ -345,7 +345,7 @@ function newWorkspace () { let nodes = [] for (let i = 0; i < thisObject.workspaceNode.rootNodes.length; i++) { let rootNode = thisObject.workspaceNode.rootNodes[i] - let nodeDefinition = getNodeDefinition (rootNode) + let nodeDefinition = getNodeDefinition(rootNode) if (nodeDefinition !== undefined) { if (nodeDefinition.isHierarchyHead === true) { nodes.push(rootNode) @@ -601,7 +601,7 @@ function newWorkspace () { break case 'Open Documentation': { - let definition = getNodeDefinition (payload.node) + let definition = getNodeDefinition(payload.node) if (definition !== undefined) { if (definition.docURL !== undefined) { let newTab = window.open(definition.docURL, '_blank') diff --git a/FloatingSpace/ConfigEditor.js b/FloatingSpace/ConfigEditor.js index b25331644..8cb2ffb83 100644 --- a/FloatingSpace/ConfigEditor.js +++ b/FloatingSpace/ConfigEditor.js @@ -52,10 +52,10 @@ function newConfigEditor () { thisObject.visible = false let textArea = document.getElementById('textArea') textArea.style.display = 'none' - thisObject.payload.node.code = textArea.value + thisObject.payload.node.config = textArea.value try { - let code = JSON.parse(thisObject.payload.node.code) + let config = JSON.parse(thisObject.payload.node.config) } catch (err) { thisObject.payload.uiObject.setErrorMessage(err.message, 10) } @@ -72,7 +72,7 @@ function newConfigEditor () { thisObject.payload.uiObject.setErrorMessage('', 0) let textArea = document.getElementById('textArea') - textArea.value = payload.node.code + textArea.value = payload.node.config textArea.style = 'resize: none;' + ' border: none;' + ' outline: none;' + @@ -94,7 +94,7 @@ function newConfigEditor () { if (thisObject.visible === true) { if (point.x === VERY_LARGE_NUMBER) { /* The the mouse leaves the canvas, and event of mouse over with a ridiculous coordinate is triggered so that - anyone can react. In our case, the code editor has a text area that is not part of the canvas, so the event is + anyone can react. In our case, the config editor has a text area that is not part of the canvas, so the event is triggered. We compensate recognizing this coordinate and returning our container. */ return thisObject.container } diff --git a/FloatingSpace/UiObject.js b/FloatingSpace/UiObject.js index 976550a98..00740dcd9 100644 --- a/FloatingSpace/UiObject.js +++ b/FloatingSpace/UiObject.js @@ -363,7 +363,7 @@ function newUiObject () { } function childrenRunningPhysics () { - let nodeDefinition = getNodeDefinition (thisObject.payload.node) + let nodeDefinition = getNodeDefinition(thisObject.payload.node) if (nodeDefinition.properties === undefined) { return } let monitorChildrenRunning = false for (let i = 0; i < nodeDefinition.properties.length; i++) { @@ -407,7 +407,7 @@ function newUiObject () { let nearbyFloatingObjects = thisObject.payload.floatingObject.nearbyFloatingObjects let compatibleTypes - let nodeDefinition = getNodeDefinition (thisObject.payload.node) + let nodeDefinition = getNodeDefinition(thisObject.payload.node) if (nodeDefinition !== undefined) { if (nodeDefinition.chainAttachesTo !== undefined) { compatibleTypes = nodeDefinition.chainAttachesTo.compatibleTypes @@ -429,10 +429,10 @@ function newUiObject () { let nearbyNode = floatingObject.payload.node if (compatibleTypes.indexOf('->' + nearbyNode.type + '->') >= 0) { /* Discard App Schema defined objects with busy coonection ports */ - nodeDefinition = getNodeDefinition (thisObject.payload.node) + nodeDefinition = getNodeDefinition(thisObject.payload.node) if (nodeDefinition !== undefined) { let mustContinue = false - let parentNodeDefinition = getNodeDefinition (nearbyNode) + let parentNodeDefinition = getNodeDefinition(nearbyNode) if (parentNodeDefinition !== undefined) { if (parentNodeDefinition.properties !== undefined) { for (let j = 0; j < parentNodeDefinition.properties.length; j++) { @@ -560,7 +560,7 @@ function newUiObject () { let nearbyFloatingObjects = thisObject.payload.floatingObject.nearbyFloatingObjects let compatibleTypes - let nodeDefinition = getNodeDefinition (thisObject.payload.node) + let nodeDefinition = getNodeDefinition(thisObject.payload.node) if (nodeDefinition !== undefined) { if (nodeDefinition.referenceAttachesTo !== undefined) { compatibleTypes = nodeDefinition.referenceAttachesTo.compatibleTypes @@ -842,7 +842,7 @@ function newUiObject () { function iconPhysics () { icon = canvas.designSpace.iconByUiObjectType.get(thisObject.payload.node.type) - let nodeDefinition = getNodeDefinition (thisObject.payload.node) + let nodeDefinition = getNodeDefinition(thisObject.payload.node) if (nodeDefinition.alternativeIcons !== undefined) { let nodeToUse = thisObject.payload.node if (nodeDefinition.alternativeIcons === 'Use Reference Parent') { @@ -859,15 +859,15 @@ function newUiObject () { } } } - nodeDefinition = getNodeDefinition (nodeToUse) - let code = nodeToUse.code + nodeDefinition = getNodeDefinition(nodeToUse) + let config = nodeToUse.config try { - code = JSON.parse(code) + config = JSON.parse(config) let alternativeIcon let iconName for (let i = 0; i < nodeDefinition.alternativeIcons.length; i++) { alternativeIcon = nodeDefinition.alternativeIcons[i] - if (alternativeIcon.codeName === code.codeName) { + if (alternativeIcon.codeName === config.codeName) { iconName = alternativeIcon.iconName } } @@ -1261,7 +1261,7 @@ function newUiObject () { if (canvas.floatingSpace.inMapMode === true) { labelPoint.y = labelPoint.y - 20 - let nodeDefinition = getNodeDefinition (thisObject.payload.node) + let nodeDefinition = getNodeDefinition(thisObject.payload.node) if (nodeDefinition !== undefined) { if (nodeDefinition.isHierarchyHead !== true) { return @@ -1578,7 +1578,7 @@ function newUiObject () { browserCanvasContext.fill() - let nodeDefinition = getNodeDefinition (thisObject.payload.node) + let nodeDefinition = getNodeDefinition(thisObject.payload.node) if (nodeDefinition !== undefined) { if (nodeDefinition.isHierarchyHead === true) { VISIBLE_RADIUS = thisObject.payload.floatingObject.currentHierarchyRing * 2.8 @@ -1760,7 +1760,7 @@ function newUiObject () { let totalImageSize = additionalImageSize + thisObject.payload.floatingObject.currentImageSize if (canvas.floatingSpace.inMapMode === true) { totalImageSize = canvas.floatingSpace.transformImagesizeToMap(totalImageSize) - let nodeDefinition = getNodeDefinition (thisObject.payload.node) + let nodeDefinition = getNodeDefinition(thisObject.payload.node) if (nodeDefinition !== undefined) { if (nodeDefinition.isHierarchyHead !== true) { totalImageSize = totalImageSize / 4 diff --git a/Panels/Layer.js b/Panels/Layer.js index cd2e8c063..c1ac56823 100644 --- a/Panels/Layer.js +++ b/Panels/Layer.js @@ -200,7 +200,7 @@ function newLayer () { /* Get ready to draw this layer */ thisObject.baseAsset = thisObject.definition.referenceParent.parentNode.referenceParent.baseAsset.referenceParent thisObject.quotedAsset = thisObject.definition.referenceParent.parentNode.referenceParent.quotedAsset.referenceParent - thisObject.market = thisObject.baseAsset.code.codeName + '/' + thisObject.quotedAsset.code.codeName + thisObject.market = thisObject.baseAsset.config.codeName + '/' + thisObject.quotedAsset.config.codeName thisObject.exchange = thisObject.definition.referenceParent.parentNode.referenceParent.parentNode.parentNode /* Some basic validations. */ @@ -226,8 +226,8 @@ function newLayer () { thisObject.exchangeIcon = getIcon(thisObject.exchange) - if (thisObject.plotterModule.code.icon !== undefined) { - thisObject.plotterTypeIcon = canvas.designSpace.iconCollection.get(thisObject.plotterModule.code.icon) + if (thisObject.plotterModule.config.icon !== undefined) { + thisObject.plotterTypeIcon = canvas.designSpace.iconCollection.get(thisObject.plotterModule.config.icon) } thisObject.baseAssetIcon = getIcon(thisObject.baseAsset) @@ -240,12 +240,12 @@ function newLayer () { } function getIcon (node) { - let nodeDefinition = getNodeDefinition (node) + let nodeDefinition = getNodeDefinition(node) let iconName if (nodeDefinition.alternativeIcons !== undefined) { for (let i = 0; i < nodeDefinition.alternativeIcons.length; i++) { alternativeIcon = nodeDefinition.alternativeIcons[i] - if (alternativeIcon.codeName === node.code.codeName) { + if (alternativeIcon.codeName === node.config.codeName) { iconName = alternativeIcon.iconName } } diff --git a/Panels/PlotterPanel.js b/Panels/PlotterPanel.js index e50ebebde..14f1fe5ba 100644 --- a/Panels/PlotterPanel.js +++ b/Panels/PlotterPanel.js @@ -151,24 +151,24 @@ function newPlotterPanel () { } } - if (panelData.code.valueDecimals !== undefined) { + if (panelData.config.valueDecimals !== undefined) { if (value !== undefined) { if (isNaN(value) === false) { - value = dynamicDecimals(value, panelData.code.valueDecimals) + value = dynamicDecimals(value, panelData.config.valueDecimals) } } } - if (panelData.code.labelText !== undefined) { - labelText = panelData.code.labelText + if (panelData.config.labelText !== undefined) { + labelText = panelData.config.labelText } - if (panelData.code.labelPosition !== undefined) { - labelPosition = panelData.code.labelPosition + if (panelData.config.labelPosition !== undefined) { + labelPosition = panelData.config.labelPosition } - if (panelData.code.valuePosition !== undefined) { - valuePosition = panelData.code.valuePosition + if (panelData.config.valuePosition !== undefined) { + valuePosition = panelData.config.valuePosition } printLabel(labelText, X_AXIS, UI_PANEL.HEIGHT.NORMAL * labelPosition / 100 / heightFactor, '0.60', undefined, undefined, true, thisObject.container, thisObject.fitFunction) diff --git a/Plotter.js b/Plotter.js index ff1bf1368..ca72ed893 100644 --- a/Plotter.js +++ b/Plotter.js @@ -277,8 +277,8 @@ function newPlotter () { let record = {} for (let j = 0; j < recordDefinition.properties.length; j++) { let property = recordDefinition.properties[j] - if (property.code.isCalculated !== true) { - record[property.code.codeName] = dataFile[i][j] + if (property.config.isCalculated !== true) { + record[property.config.codeName] = dataFile[i][j] } } @@ -310,7 +310,7 @@ function newPlotter () { timeFrame: timeFrame, ONE_DAY_IN_MILISECONDS: ONE_DAY_IN_MILISECONDS } - let variable = {} // This is the structure where the user will define its own variables that will be shared across different code blocks and formulas. + let variable = {} // This is the structure where the user will define its own variables that will be shared across different config blocks and formulas. let results = [] /* This is Initialization Code */ @@ -345,13 +345,13 @@ function newPlotter () { /* For each calculated property we apply its formula */ for (let j = 0; j < recordDefinition.properties.length; j++) { let property = recordDefinition.properties[j] - if (property.code.isCalculated === true) { + if (property.config.isCalculated === true) { if (property.formula !== undefined) { if (property.formula.code !== undefined) { try { let newValue = eval(property.formula.code) let currentRecord = product - currentRecord[property.code.codeName] = newValue + currentRecord[property.config.codeName] = newValue } catch (err) { logger.write('[ERROR] calculationsProcedure -> loop -> formula -> Error executing User Code. Error = ' + err.stack.stack) logger.write('[ERROR] calculationsProcedure -> loop -> formula -> Error executing User Code. product = ' + JSON.stringify(product)) @@ -622,9 +622,9 @@ function newPlotter () { } else { /* Get the default style if exists */ if (polygon.polygonBody.style !== undefined) { - if (polygon.polygonBody.style.code !== undefined) { - if (polygon.polygonBody.style.code.default !== undefined) { - let bodyStyle = polygon.polygonBody.style.code.default + if (polygon.polygonBody.style.config !== undefined) { + if (polygon.polygonBody.style.config.default !== undefined) { + let bodyStyle = polygon.polygonBody.style.config.default if (bodyStyle.opacity !== undefined) { fillStyle.opacity = bodyStyle.opacity } if (bodyStyle.paletteColor !== undefined) { fillStyle.paletteColor = eval(bodyStyle.paletteColor) } } @@ -637,7 +637,7 @@ function newPlotter () { let value = eval(condition.code) if (value === true) { if (condition.style !== undefined) { - let bodyStyle = condition.style.code + let bodyStyle = condition.style.config if (bodyStyle.opacity !== undefined) { fillStyle.opacity = bodyStyle.opacity } if (bodyStyle.paletteColor !== undefined) { fillStyle.paletteColor = eval(bodyStyle.paletteColor) } } @@ -646,8 +646,8 @@ function newPlotter () { } /* Get the atMousePosition style if exists */ if (polygon.polygonBody.style !== undefined) { - if (polygon.polygonBody.style.code.atMousePosition !== undefined) { - let atMousePositionStyleDefinition = polygon.polygonBody.style.code.atMousePosition + if (polygon.polygonBody.style.config.atMousePosition !== undefined) { + let atMousePositionStyleDefinition = polygon.polygonBody.style.config.atMousePosition let atMousePositionStyle = {} if (atMousePositionStyleDefinition.opacity !== undefined) { atMousePositionStyle.opacity = atMousePositionStyleDefinition.opacity } if (atMousePositionStyleDefinition.paletteColor !== undefined) { atMousePositionStyle.paletteColor = eval(atMousePositionStyleDefinition.paletteColor) } @@ -677,9 +677,9 @@ function newPlotter () { } else { /* Get the default style if exists */ if (polygon.polygonBorder.style !== undefined) { - if (polygon.polygonBorder.style.code !== undefined) { - if (polygon.polygonBorder.style.code.default !== undefined) { - let borderStyle = polygon.polygonBorder.style.code.default + if (polygon.polygonBorder.style.config !== undefined) { + if (polygon.polygonBorder.style.config.default !== undefined) { + let borderStyle = polygon.polygonBorder.style.config.default if (borderStyle.opacity !== undefined) { strokeStyle.opacity = borderStyle.opacity } if (borderStyle.paletteColor !== undefined) { strokeStyle.paletteColor = eval(borderStyle.paletteColor) } if (borderStyle.lineWidth !== undefined) { strokeStyle.lineWidth = borderStyle.lineWidth } @@ -694,7 +694,7 @@ function newPlotter () { let value = eval(condition.code) if (value === true) { if (condition.style !== undefined) { - let borderStyle = condition.style.code + let borderStyle = condition.style.config if (borderStyle.opacity !== undefined) { strokeStyle.opacity = borderStyle.opacity } if (borderStyle.paletteColor !== undefined) { strokeStyle.paletteColor = eval(borderStyle.paletteColor) } if (borderStyle.lineWidth !== undefined) { strokeStyle.lineWidth = borderStyle.lineWidth } @@ -705,8 +705,8 @@ function newPlotter () { } /* Get the atMousePosition style if exists */ if (polygon.polygonBorder.style !== undefined) { - if (polygon.polygonBorder.style.code.atMousePosition !== undefined) { - let atMousePositionStyleDefinition = polygon.polygonBorder.style.code.atMousePosition + if (polygon.polygonBorder.style.config.atMousePosition !== undefined) { + let atMousePositionStyleDefinition = polygon.polygonBorder.style.config.atMousePosition let atMousePositionStyle = {} if (atMousePositionStyleDefinition.opacity !== undefined) { atMousePositionStyle.opacity = atMousePositionStyleDefinition.opacity } if (atMousePositionStyleDefinition.paletteColor !== undefined) { atMousePositionStyle.paletteColor = eval(atMousePositionStyleDefinition.paletteColor) } diff --git a/ProductStorage.js b/ProductStorage.js index 68c76ef1b..57c8e6b8a 100644 --- a/ProductStorage.js +++ b/ProductStorage.js @@ -85,7 +85,7 @@ function newProductStorage (name) { for (let i = 0; i < product.datasets.length; i++) { let dataset = product.datasets[i] - switch (dataset.code.type) { + switch (dataset.config.type) { case 'Market Files': { dataSetsToLoad++ @@ -122,7 +122,7 @@ function newProductStorage (name) { } break default: - if (ERROR_LOG === true) { logger.write('[WARN] initialize -> dataset with no type defined or type not supported -> dataset.code.type = ' + dataset.code.type) } + if (ERROR_LOG === true) { logger.write('[WARN] initialize -> dataset with no type defined or type not supported -> dataset.config.type = ' + dataset.config.type) } } function onMarketFileReady (err, pCaller) { diff --git a/Scales/RateScale.js b/Scales/RateScale.js index 6964143fd..93ca0cf9d 100644 --- a/Scales/RateScale.js +++ b/Scales/RateScale.js @@ -255,12 +255,12 @@ function newRateScale () { function saveObjectState () { try { - let code = JSON.parse(thisObject.payload.node.code) - code.minValue = coordinateSystem.min.y - code.maxValue = coordinateSystem.max.y - code.autoMinScale = coordinateSystem.autoMinYScale - code.autoMaxScale = coordinateSystem.autoMaxYScale - thisObject.payload.node.code = JSON.stringify(code, null, 4) + let config = JSON.parse(thisObject.payload.node.config) + config.minValue = coordinateSystem.min.y + config.maxValue = coordinateSystem.max.y + config.autoMinScale = coordinateSystem.autoMinYScale + config.autoMaxScale = coordinateSystem.autoMaxYScale + thisObject.payload.node.config = JSON.stringify(config, null, 4) } catch (err) { // we ignore errors here since most likely they will be parsing errors. } @@ -268,29 +268,29 @@ function newRateScale () { function readObjectState () { try { - let code = JSON.parse(thisObject.payload.node.code) + let config = JSON.parse(thisObject.payload.node.config) if ( - (isNaN(code.minValue) || code.minValue === null || code.minValue === undefined) || - (isNaN(code.maxValue) || code.maxValue === null || code.maxValue === undefined) + (isNaN(config.minValue) || config.minValue === null || config.minValue === undefined) || + (isNaN(config.maxValue) || config.maxValue === null || config.maxValue === undefined) ) { // not using this value } else { if ( - thisObject.minValue !== code.minValue || - thisObject.maxValue !== code.maxValue || - coordinateSystem.autoMinYScale !== code.autoMinScale || - coordinateSystem.autoMaxYScale !== code.autoMaxScale + thisObject.minValue !== config.minValue || + thisObject.maxValue !== config.maxValue || + coordinateSystem.autoMinYScale !== config.autoMinScale || + coordinateSystem.autoMaxYScale !== config.autoMaxScale ) { - thisObject.minValue = code.minValue - thisObject.maxValue = code.maxValue + thisObject.minValue = config.minValue + thisObject.maxValue = config.maxValue coordinateSystem.min.y = thisObject.minValue coordinateSystem.max.y = thisObject.maxValue - if (code.autoMinScale !== undefined && (code.autoMinScale === true || code.autoMinScale === false) && code.autoMaxScale !== undefined && (code.autoMaxScale === true || code.autoMaxScale === false)) { - coordinateSystem.autoMinYScale = code.autoMinScale - coordinateSystem.autoMaxYScale = code.autoMaxScale - autoScaleButton.setStatus(code.autoMinScale, code.autoMaxScale) + if (config.autoMinScale !== undefined && (config.autoMinScale === true || config.autoMinScale === false) && config.autoMaxScale !== undefined && (config.autoMaxScale === true || config.autoMaxScale === false)) { + coordinateSystem.autoMinYScale = config.autoMinScale + coordinateSystem.autoMaxYScale = config.autoMaxScale + autoScaleButton.setStatus(config.autoMinScale, config.autoMaxScale) } coordinateSystem.recalculateScale() diff --git a/Scales/TimeFrameScale.js b/Scales/TimeFrameScale.js index 89fdebc8e..3d0d41cd0 100644 --- a/Scales/TimeFrameScale.js +++ b/Scales/TimeFrameScale.js @@ -313,9 +313,9 @@ function newTimeFrameScale () { function saveObjectState () { try { - let code = JSON.parse(thisObject.payload.node.code) - code.value = timeFrameLabel - thisObject.payload.node.code = JSON.stringify(code) + let config = JSON.parse(thisObject.payload.node.config) + config.value = timeFrameLabel + thisObject.payload.node.config = JSON.stringify(config) } catch (err) { // we ignore errors here since most likely they will be parsing errors. } @@ -323,14 +323,14 @@ function newTimeFrameScale () { function readObjectState () { try { - let code = JSON.parse(thisObject.payload.node.code) - if (code.value !== timeFrameLabel) { + let config = JSON.parse(thisObject.payload.node.config) + if (config.value !== timeFrameLabel) { let found = false for (let i = 0; i < timeFramesMasterArray.length; i++) { let timeFrameArray = timeFramesMasterArray[i] for (let j = 0; j < timeFrameArray.length; j++) { let record = timeFrameArray[j] - if (code.value === record[1]) { + if (config.value === record[1]) { filePeriodIndex = i timeFrameIndex = j found = true diff --git a/Scales/TimeScale.js b/Scales/TimeScale.js index 00d52c530..90ee96fb0 100644 --- a/Scales/TimeScale.js +++ b/Scales/TimeScale.js @@ -172,12 +172,12 @@ function newTimeScale () { function saveObjectState () { try { - let code = JSON.parse(thisObject.payload.node.code) - code.fromDate = (new Date(coordinateSystem.min.x)).toISOString() - code.toDate = (new Date(coordinateSystem.max.x)).toISOString() - code.autoMinScale = coordinateSystem.autoMinXScale - code.autoMaxScale = coordinateSystem.autoMaxXScale - thisObject.payload.node.code = JSON.stringify(code, null, 4) + let config = JSON.parse(thisObject.payload.node.config) + config.fromDate = (new Date(coordinateSystem.min.x)).toISOString() + config.toDate = (new Date(coordinateSystem.max.x)).toISOString() + config.autoMinScale = coordinateSystem.autoMinXScale + config.autoMaxScale = coordinateSystem.autoMaxXScale + thisObject.payload.node.config = JSON.stringify(config, null, 4) } catch (err) { // we ignore errors here since most likely they will be parsing errors. } @@ -185,24 +185,24 @@ function newTimeScale () { function readObjectState () { try { - let code = JSON.parse(thisObject.payload.node.code) + let config = JSON.parse(thisObject.payload.node.config) if ( - (isNaN(Date.parse(code.fromDate)) || code.fromDate === null || code.fromDate === undefined) || - (isNaN(Date.parse(code.toDate)) || code.toDate === null || code.toDate === undefined) + (isNaN(Date.parse(config.fromDate)) || config.fromDate === null || config.fromDate === undefined) || + (isNaN(Date.parse(config.toDate)) || config.toDate === null || config.toDate === undefined) ) { // not using this value } else { - if (thisObject.fromDate !== Date.parse(code.fromDate) || thisObject.toDate !== Date.parse(code.toDate)) { - thisObject.fromDate = Date.parse(code.fromDate) - thisObject.toDate = Date.parse(code.toDate) + if (thisObject.fromDate !== Date.parse(config.fromDate) || thisObject.toDate !== Date.parse(config.toDate)) { + thisObject.fromDate = Date.parse(config.fromDate) + thisObject.toDate = Date.parse(config.toDate) coordinateSystem.min.x = thisObject.fromDate coordinateSystem.max.x = thisObject.toDate - if (code.autoMinScale !== undefined && (code.autoMinScale === true || code.autoMinScale === false) && code.autoMaxScale !== undefined && (code.autoMaxScale === true || code.autoMaxScale === false)) { - coordinateSystem.autoMinXScale = code.autoMinScale - coordinateSystem.autoMaxXScale = code.autoMaxScale - autoScaleButton.setStatus(code.autoMinScale, code.autoMaxScale) + if (config.autoMinScale !== undefined && (config.autoMinScale === true || config.autoMinScale === false) && config.autoMaxScale !== undefined && (config.autoMaxScale === true || config.autoMaxScale === false)) { + coordinateSystem.autoMinXScale = config.autoMinScale + coordinateSystem.autoMaxXScale = config.autoMaxScale + autoScaleButton.setStatus(config.autoMinScale, config.autoMaxScale) } coordinateSystem.recalculateScale() } diff --git a/Spaces/PanelsSpace.js b/Spaces/PanelsSpace.js index e752631d1..a634fa26e 100644 --- a/Spaces/PanelsSpace.js +++ b/Spaces/PanelsSpace.js @@ -50,14 +50,14 @@ function newPanelsSpace () { } case 'Plotter Panel': { - if (pParameters.panelNode.code.isLegacy !== true) { + if (pParameters.panelNode.config.isLegacy !== true) { panel = newPlotterPanel() panel.fitFunction = canvas.chartingSpace.fitFunction panel.container.isVisibleFunction = canvas.chartingSpace.isThisPointVisible panel.session = pSession panel.initialize(pParameters.panelNode) } else { - panel = getNewPlotterPanel(pParameters.dataMine, pParameters.plotterCodeName, pParameters.moduleCodeName, pParameters.panelNode.code.codeName) + panel = getNewPlotterPanel(pParameters.dataMine, pParameters.plotterCodeName, pParameters.moduleCodeName, pParameters.panelNode.config.codeName) panel.fitFunction = canvas.chartingSpace.fitFunction panel.container.isVisibleFunction = canvas.chartingSpace.isThisPointVisible panel.session = pSession diff --git a/Utilities/NodeConfig.js b/Utilities/NodeConfig.js index 50473c906..482e1ae3e 100644 --- a/Utilities/NodeConfig.js +++ b/Utilities/NodeConfig.js @@ -1,8 +1,8 @@ function savePropertyAtNodeConfig (payload, propertyName, value) { try { - let code = JSON.parse(payload.node.code) - code[propertyName] = value - payload.node.code = JSON.stringify(code, null, 4) + let config = JSON.parse(payload.node.config) + config[propertyName] = value + payload.node.config = JSON.stringify(config, null, 4) } catch (err) { // we ignore errors here since most likely they will be parsing errors. } @@ -10,8 +10,8 @@ function savePropertyAtNodeConfig (payload, propertyName, value) { function loadPropertyFromNodeConfig (payload, propertyName) { try { - let code = JSON.parse(payload.node.code) - return code[propertyName] + let config = JSON.parse(payload.node.config) + return config[propertyName] } catch (err) { // we ignore errors here since most likely they will be parsing errors. }