From a95be2c2b874da3b4dadda39ef81e18fb5e76214 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Fri, 18 Dec 2020 12:58:09 +0100 Subject: [PATCH] Repositioning Working --- .../UI/Spaces/Design-Space/Workspace.js | 10 +- .../UI/Spaces/Docs-Space/DocsSpace.js | 108 ++++++++++-------- 2 files changed, 67 insertions(+), 51 deletions(-) diff --git a/Projects/Superalgos/UI/Spaces/Design-Space/Workspace.js b/Projects/Superalgos/UI/Spaces/Design-Space/Workspace.js index 56ae450a6..8e746fcc3 100644 --- a/Projects/Superalgos/UI/Spaces/Design-Space/Workspace.js +++ b/Projects/Superalgos/UI/Spaces/Design-Space/Workspace.js @@ -6,6 +6,7 @@ function newWorkspace() { let thisObject = { + isInitialized: false, workspaceNode: undefined, container: undefined, enabled: false, @@ -42,7 +43,6 @@ function newWorkspace() { thisObject.nodeChildren = newNodeChildren() let savingWorkspaceIntervalId - let isInitialized = false let workingAtTask = 0 let circularProgressBar = newBusyProgressBar() circularProgressBar.fitFunction = UI.projects.superalgos.spaces.floatingSpace.fitIntoVisibleArea @@ -105,7 +105,7 @@ function newWorkspace() { UI.projects.superalgos.spaces.cockpitSpace.initializePosition() CAN_SPACES_DRAW = true savingWorkspaceIntervalId = setInterval(saveWorkspace, 60000) - isInitialized = true + thisObject.isInitialized = true } } catch (err) { if (ERROR_LOG === true) { logger.write('[ERROR] initialize -> err = ' + err.stack) } @@ -141,7 +141,7 @@ function newWorkspace() { let workspace = UI.projects.superalgos.spaces.designSpace.workspace.workspaceNode /* Validation if it is too early to save. */ - if (isInitialized === false) { return } + if (thisObject.isInitialized === false) { return } /* Validation of 2 sessions opened at the same time. */ let savedSessionTimestamp = window.localStorage.getItem('Session Timestamp') @@ -241,7 +241,7 @@ function newWorkspace() { switch (workingAtTask) { case 1: - isInitialized = false + thisObject.isInitialized = false console.log('[INFO] Replacing Workspace Procedure Started') console.log('[INFO] Deleting Workspace ' + thisObject.workspaceNode.name + '. This might take a few minutes depending on the size of the workspace.') UI.projects.superalgos.spaces.tutorialSpace.stop() @@ -292,7 +292,7 @@ function newWorkspace() { console.log('[INFO] Replacing Workspace Procedure Finished') workingAtTask = 0 circularProgressBar.visible = false - isInitialized = true + thisObject.isInitialized = true saveWorkspace() break } diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js b/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js index 19a677ffd..a5fc0f862 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js @@ -39,7 +39,7 @@ function newSuperalgosDocSpace() { let schemaDocument let menuLabelsMap = new Map() let searchPhrase - let docsIndex + let docsIndex = [] return thisObject @@ -263,7 +263,7 @@ function newSuperalgosDocSpace() { } function cleanTextForSearch(text) { - let result = text + let result = replaceSpecialCharactersForSpaces(text) result = result.replaceAll(' ', '') result = result.replaceAll('s', '') result = result.replaceAll('ing', '') @@ -273,6 +273,49 @@ function newSuperalgosDocSpace() { return result } + function replaceSpecialCharactersForSpaces(text) { + let result = text + result= result.replaceAll('. ', ' ') + result= result.replaceAll(', ', ' ') + result= result.replaceAll('- ', ' ') + result= result.replaceAll('/ ', ' ') + result= result.replaceAll('_ ', ' ') + result= result.replaceAll(': ', ' ') + result= result.replaceAll('; ', ' ') + result= result.replaceAll('( ', ' ') + result= result.replaceAll(') ', ' ') + result= result.replaceAll('{ ', ' ') + result= result.replaceAll('} ', ' ') + result= result.replaceAll('[ ', ' ') + result= result.replaceAll('] ', ' ') + result= result.replaceAll('" ', ' ') + result= result.replaceAll('\\n ', ' ') + result= result.replaceAll('\\ ', ' ') + + result= result.replaceAll('.', ' ') + result= result.replaceAll(',', ' ') + result= result.replaceAll('-', ' ') + result= result.replaceAll('/', ' ') + result= result.replaceAll('_', ' ') + result= result.replaceAll(':', ' ') + result= result.replaceAll(';', ' ') + result= result.replaceAll('(', ' ') + result= result.replaceAll(')', ' ') + result= result.replaceAll('{', ' ') + result= result.replaceAll('}', ' ') + result= result.replaceAll('[', ' ') + result= result.replaceAll(']', ' ') + result= result.replaceAll('"', ' ') + result= result.replaceAll('\\n', ' ') + result= result.replaceAll("\\", ' ') + + result= result.replaceAll('@', ' ') + result= result.replaceAll(' ', ' ') + result= result.replaceAll(' ', ' ') + result= result.replaceAll(' ', ' ') + return result + } + function finalize() { canvas.eventHandler.stopListening(browserResizedEventSubscriptionId) thisObject.sidePanelTab.container.eventHandler.stopListening(openingEventSubscriptionId) @@ -521,11 +564,6 @@ function newSuperalgosDocSpace() { function onOpening() { - docsIndex = [] - - setUpWorkspaceSchemas() - setUpSearchEngine() - if (objectBeingRendered === undefined) { renderSearchPage() } else { @@ -693,44 +731,7 @@ function newSuperalgosDocSpace() { documentIndex.phraseCount[style] = stylePhraseCount } - text = text.replaceAll('. ', ' ') - text = text.replaceAll(', ', ' ') - text = text.replaceAll('- ', ' ') - text = text.replaceAll('/ ', ' ') - text = text.replaceAll('_ ', ' ') - text = text.replaceAll(': ', ' ') - text = text.replaceAll('; ', ' ') - text = text.replaceAll('( ', ' ') - text = text.replaceAll(') ', ' ') - text = text.replaceAll('{ ', ' ') - text = text.replaceAll('} ', ' ') - text = text.replaceAll('[ ', ' ') - text = text.replaceAll('] ', ' ') - text = text.replaceAll('" ', ' ') - text = text.replaceAll('\\n ', ' ') - text = text.replaceAll('\\ ', ' ') - - text = text.replaceAll('.', ' ') - text = text.replaceAll(',', ' ') - text = text.replaceAll('-', ' ') - text = text.replaceAll('/', ' ') - text = text.replaceAll('_', ' ') - text = text.replaceAll(':', ' ') - text = text.replaceAll(';', ' ') - text = text.replaceAll('(', ' ') - text = text.replaceAll(')', ' ') - text = text.replaceAll('{', ' ') - text = text.replaceAll('}', ' ') - text = text.replaceAll('[', ' ') - text = text.replaceAll(']', ' ') - text = text.replaceAll('"', ' ') - text = text.replaceAll('\\n', ' ') - text = text.replaceAll("\\", ' ') - - text = text.replaceAll('@', ' ') - text = text.replaceAll(' ', ' ') - text = text.replaceAll(' ', ' ') - text = text.replaceAll(' ', ' ') + text = replaceSpecialCharactersForSpaces(text) let splittedText = text.split(' ') @@ -1106,7 +1107,11 @@ function newSuperalgosDocSpace() { if (objectBeingRendered.category !== 'Workspace') { return } let node = await UI.projects.superalgos.spaces.designSpace.workspace.getNodeById(schemaDocument.key) - UI.projects.superalgos.spaces.floatingSpace.positionAtNode(node) + node.payload.floatingObject.unCollapseParent() + setTimeout(positionAtNode, 1000, node) + function positionAtNode(node) { + UI.projects.superalgos.spaces.floatingSpace.positionAtNode(node) + } } function buildHtmlPage() { @@ -2494,6 +2499,7 @@ function newSuperalgosDocSpace() { function physics() { thisObject.sidePanelTab.physics() docsAppDivPhysics() + finishInitializePhysics() function docsAppDivPhysics() { let docsSpaceDiv = document.getElementById('docs-space-div') @@ -2510,6 +2516,16 @@ function newSuperalgosDocSpace() { 'width: ' + thisObject.container.frame.width + 'px;' + 'height: ' + thisObject.container.frame.height + 'px' } + + function finishInitializePhysics() { + if (UI.projects.superalgos.spaces.designSpace.workspace === undefined) {return} + if (UI.projects.superalgos.spaces.designSpace.workspace.isInitialized === false) {return} + + if (docsIndex.length === 0) { + setUpWorkspaceSchemas() + setUpSearchEngine() + } + } } function draw() {