diff --git a/Animation.js b/Animation.js index 1e06c4849..20f967a48 100644 --- a/Animation.js +++ b/Animation.js @@ -168,6 +168,7 @@ function newAnimation () { } function clearBrowserCanvas () { + if (canWeDraw === false) { return } browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.WHITE + ', 1)' browserCanvasContext.clearRect(0, 0, browserCanvas.width, browserCanvas.height) } diff --git a/Canvas.js b/Canvas.js index 7fa8989fd..4dd01deb8 100644 --- a/Canvas.js +++ b/Canvas.js @@ -3,7 +3,6 @@ let browserCanvasContext // The context of the canvas object. let stepsInitializationCounter = 0 // This counter the initialization steps required to be able to turn off the splash screen. let marketInitializationCounter = 0 // This counter the initialization of markets required to be able to turn off the splash screen. -let splashScreenNeeded = true function newCanvas () { const MODULE_NAME = 'Canvas' @@ -38,6 +37,7 @@ function newCanvas () { panelsSpace: undefined, cockpitSpace: undefined, designSpace: undefined, + splashScreen: undefined, animation: undefined, mouse: undefined, shorcutNumbers: new Map(), @@ -47,7 +47,6 @@ function newCanvas () { thisObject.eventHandler = newEventHandler() - let splashScreen let lastContainerMouseOver let lastShortcutKeyRejection @@ -87,7 +86,7 @@ function newCanvas () { browserCanvas.removeEventListener('keydown', onKeyDown, false) browserCanvas.removeEventListener('keyup', onKeyUp, false) - splashScreen = undefined + thisObject.splashScreen = undefined lastContainerMouseOver = undefined hisObject.mouse = undefined @@ -125,8 +124,7 @@ function newCanvas () { thisObject.sideSpace = newSideSpace() thisObject.sideSpace.initialize() - splashScreen = newSplashScreen() - splashScreen.initialize() + thisObject.splashScreen = newSplashScreen() let animation = newAnimation() animation.initialize() @@ -149,7 +147,7 @@ function newCanvas () { animation.addCallBackFunction('Design Space Draw', thisObject.designSpace.draw) animation.addCallBackFunction('Top Space Draw', thisObject.topSpace.draw) animation.addCallBackFunction('Side Space Draw', thisObject.sideSpace.draw) - animation.addCallBackFunction('Splash Screen Draw', splashScreen.draw) + animation.addCallBackFunction('Splash Screen Draw', thisObject.splashScreen.draw) animation.start() } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) } diff --git a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js index a376f5806..4a56efdc2 100644 --- a/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js +++ b/DesignSpace/Workspace/FunctionLibraries/UiObjectsFromNodes.js @@ -14,7 +14,7 @@ function newUiObjectsFromNodes () { return thisObject - function recreateWorkspace (node, replacingCurrentWorkspace) { + function recreateWorkspace (node, replacingCurrentWorkspace, callBackFunction) { mapOfNodes = new Map() tasksToRun = [] sessionsToRun = [] @@ -145,6 +145,10 @@ function newUiObjectsFromNodes () { // We give a few seconds for the tasks to start setTimeout(runSessions, 10000) } + + if (callBackFunction !== undefined) { + callBackFunction() // The recreation of the workspace is complete + } } } @@ -238,7 +242,7 @@ function newUiObjectsFromNodes () { switch (property.type) { case 'node': { if (property.name !== previousPropertyName) { - setTimeout(createUiObjectFromNode, 1, node[property.name], node, node, positionOffset) + createUiObjectFromNode(node[property.name], node, node, positionOffset) previousPropertyName = property.name } } @@ -247,7 +251,7 @@ function newUiObjectsFromNodes () { let nodePropertyArray = node[property.name] for (let m = 0; m < nodePropertyArray.length; m++) { let arrayItem = nodePropertyArray[m] - setTimeout(createUiObjectFromNode, 1, arrayItem, node, node, positionOffset) + createUiObjectFromNode(arrayItem, node, node, positionOffset) } } break diff --git a/DesignSpace/Workspace/Workspace.js b/DesignSpace/Workspace/Workspace.js index f50e50f4d..4e0758bd4 100644 --- a/DesignSpace/Workspace/Workspace.js +++ b/DesignSpace/Workspace/Workspace.js @@ -94,23 +94,26 @@ function newWorkspace () { if (err && err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) { canvas.cockpitSpace.setStatus('Could not load the last Workspace used, called "' + lastUsedWorkspace + '". Will switch to the default Workspace instead.', 500, canvas.cockpitSpace.statusTypes.WARNING) thisObject.workspaceNode = getWorkspace() // This is the default workspace that comes with the system. - finishInitialization() + recreateWorkspace() return } thisObject.workspaceNode = JSON.parse(text) - finishInitialization() + recreateWorkspace() } } else { thisObject.workspaceNode = getWorkspace() // This is the default workspace that comes with the system. - finishInitialization() + recreateWorkspace() + } + + function recreateWorkspace () { + functionLibraryUiObjectsFromNodes.recreateWorkspace(thisObject.workspaceNode, false, finishInitialization) } function finishInitialization () { - functionLibraryUiObjectsFromNodes.recreateWorkspace(thisObject.workspaceNode) setupEventsServerClients() thisObject.enabled = true canvas.cockpitSpace.initializePosition() - + canvas.splashScreen.initialize() setInterval(saveWorkspace, 60000) } } catch (err) { diff --git a/Globals.js b/Globals.js index cc1ec296a..b0a7414fa 100644 --- a/Globals.js +++ b/Globals.js @@ -224,6 +224,8 @@ const TIME_MACHINE_HEIGHT = 8; let mediaRecorder // to downloadText canvas animation as a mediaRecorder let areWeRecording = false +let canWeDraw = false // This global variable regulates when spaces can or can not draw their contents. + function toRadians(angle) { return angle * (Math.PI / 180); } diff --git a/Spaces/ChartingSpace.js b/Spaces/ChartingSpace.js index a3959971c..afbca8ce9 100644 --- a/Spaces/ChartingSpace.js +++ b/Spaces/ChartingSpace.js @@ -406,6 +406,7 @@ function newChartingSpace () { } function draw () { + if (canWeDraw === false) { return } if (thisObject.visible === false) { return } drawBackground() diff --git a/Spaces/CockpitSpace.js b/Spaces/CockpitSpace.js index 33be244fa..af67991f7 100644 --- a/Spaces/CockpitSpace.js +++ b/Spaces/CockpitSpace.js @@ -207,6 +207,7 @@ } function draw () { + if (canWeDraw === false) { return } thisObject.container.frame.draw(false, false) drawBackground() diff --git a/Spaces/DesignSpace.js b/Spaces/DesignSpace.js index db26f42ca..305e1d532 100644 --- a/Spaces/DesignSpace.js +++ b/Spaces/DesignSpace.js @@ -334,6 +334,7 @@ function newDesignSpace () { } function draw () { + if (canWeDraw === false) { return } if (thisObject.sidePanel !== undefined) { thisObject.sidePanel.draw() } diff --git a/Spaces/FloatingSpace.js b/Spaces/FloatingSpace.js index 7664b7fc5..cb94ebc2d 100644 --- a/Spaces/FloatingSpace.js +++ b/Spaces/FloatingSpace.js @@ -415,6 +415,7 @@ function newFloatingSpace () { } function draw () { + if (canWeDraw === false) { return } if (visible === false) { return } drawBackground() thisObject.floatingLayer.draw() diff --git a/Spaces/PanelsSpace.js b/Spaces/PanelsSpace.js index 28ffa303f..e752631d1 100644 --- a/Spaces/PanelsSpace.js +++ b/Spaces/PanelsSpace.js @@ -336,6 +336,7 @@ function newPanelsSpace () { } function draw () { + if (canWeDraw === false) { return } if (thisObject.visible !== true) { return } thisObject.container.frame.draw(false, false) diff --git a/Spaces/SideSpace.js b/Spaces/SideSpace.js index 43b01ce6b..4ef872909 100644 --- a/Spaces/SideSpace.js +++ b/Spaces/SideSpace.js @@ -55,6 +55,7 @@ function newSideSpace () { } function draw () { + if (canWeDraw === false) { return } if (isInitialized === false) { return } borders() thisObject.sidePanelTab.draw() diff --git a/Spaces/TopSpace.js b/Spaces/TopSpace.js index 905a93894..a7dcf5e62 100644 --- a/Spaces/TopSpace.js +++ b/Spaces/TopSpace.js @@ -54,6 +54,7 @@ function newTopSpace () { } function draw () { + if (canWeDraw === false) { return } thisObject.container.frame.draw(false, false) drawBackground() diff --git a/SplashScreen.js b/SplashScreen.js index 55508957f..34b7c9589 100644 --- a/SplashScreen.js +++ b/SplashScreen.js @@ -13,7 +13,7 @@ function newSplashScreen () { initialize: initialize } - var container = newContainer() + let container = newContainer() container.initialize() thisObject.container = container @@ -31,21 +31,22 @@ function newSplashScreen () { let logo let canDrawLogo = false + let isInitialized = false + let splashScreenNeeded = true return thisObject function initialize () { logo = new Image() - logo.onload = onImageLoad function onImageLoad () { canDrawLogo = true } - logo.src = window.canvasApp.urlPrefix + 'Images/superalgos-logo.png' - canvas.eventHandler.listenToEvent('Browser Resized', resize) + + isInitialized = true } function resize () { @@ -54,6 +55,7 @@ function newSplashScreen () { } function draw () { + if (isInitialized === false) { return } if (splashScreenNeeded === false) { stepsInitializationCounter = 100 canDrawLogo = false @@ -101,6 +103,7 @@ function newSplashScreen () { if (stepsInitializationCounter > 99) { splashScreenNeeded = false + canWeDraw = true stepsInitializationCounter = 99 }