From ea7af51a628e4442bacbc1d10733589e3803526f Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 14 Oct 2020 10:07:48 +0200 Subject: [PATCH] Some Improvements --- FloatingSpace/UiObjectConstructor.js | 52 ++++++++++++++-------------- PostLoader.js | 8 ++--- 2 files changed, 29 insertions(+), 31 deletions(-) diff --git a/FloatingSpace/UiObjectConstructor.js b/FloatingSpace/UiObjectConstructor.js index 75bc43eb0..b42cfe186 100644 --- a/FloatingSpace/UiObjectConstructor.js +++ b/FloatingSpace/UiObjectConstructor.js @@ -174,34 +174,34 @@ function newUiObjectConstructor() { uiObject.isVisibleFunction = canvas.floatingSpace.isThisPointVisible let menuItemsInitialValues = getMenuItemsInitialValues(uiObject, floatingObject, payload) - for (let i = 0; i < APP_SCHEMA_ARRAY.length; i++) { - let schemaNode = APP_SCHEMA_ARRAY[i] - if (schemaNode.type === payload.node.type) { - let menuItems = schemaNode.menuItems - for (let j = 0; j < menuItems.length; j++) { - let item = menuItems[j] - item.angle = undefined - if (item.action.indexOf('Add Missing Children') >= 0) { - item.action = 'Add Missing Children' - } - if (item.action.indexOf('Delete ') >= 0) { - // item.action = 'Delete UI Object' - } - if (item.action.indexOf('Configure ') >= 0) { - if (schemaNode.editors.config === true) { - // item.actionFunction = 'uiObject.configEditor.activate' - } - } - if (item.action.indexOf('Edit ') >= 0) { - if (schemaNode.editors.code === true) { - // item.actionFunction = 'uiObject.codeEditor.activate' - } - } - if (item.actionFunction === undefined) { - // item.actionFunction = 'payload.onMenuItemClick' - } + let schemaNode = APP_SCHEMA_MAP.get(payload.node.type) + if (schemaNode === undefined) { + console.log(payload.node.type + ' node found at App Schema. This node will not be created. ') + return + } + let menuItems = schemaNode.menuItems + for (let j = 0; j < menuItems.length; j++) { + let item = menuItems[j] + item.angle = undefined + if (item.action.indexOf('Add Missing Children') >= 0) { + item.action = 'Add Missing Children' + } + if (item.action.indexOf('Delete ') >= 0) { + // item.action = 'Delete UI Object' + } + if (item.action.indexOf('Configure ') >= 0) { + if (schemaNode.editors.config === true) { + // item.actionFunction = 'uiObject.configEditor.activate' } } + if (item.action.indexOf('Edit ') >= 0) { + if (schemaNode.editors.code === true) { + // item.actionFunction = 'uiObject.codeEditor.activate' + } + } + if (item.actionFunction === undefined) { + // item.actionFunction = 'payload.onMenuItemClick' + } } uiObject.initialize(payload, menuItemsInitialValues) diff --git a/PostLoader.js b/PostLoader.js index 1341bedd7..9125e3e9e 100644 --- a/PostLoader.js +++ b/PostLoader.js @@ -18,8 +18,6 @@ function newDashboard() { start: start } - const DEBUG_START_UP_DELAY = 0 // 3000; // This is a waiting time in case there is a need to debug the very first steps of initialization, to be able to hit F12 on time. - return thisObject function start() { @@ -54,14 +52,14 @@ function newDashboard() { if (canvas !== undefined) { canvas.finalize() } - setTimeout(delayedStart, DEBUG_START_UP_DELAY) + startSuperalgos() } } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] start -> err = ' + err.stack) } } } - function delayedStart() { + function startSuperalgos() { try { /* For now, we are supporting only one market. */ @@ -78,7 +76,7 @@ function newDashboard() { canvas = newCanvas() canvas.initialize() } catch (err) { - if (ERROR_LOG === true) { logger.write('[ERROR] delayedStart -> err = ' + err.stack) } + if (ERROR_LOG === true) { logger.write('[ERROR] startSuperalgos -> err = ' + err.stack) } } }