diff --git a/Projects/Superalgos/UI/Function-Libraries/UiObjectsFromNodes.js b/Projects/Superalgos/UI/Function-Libraries/UiObjectsFromNodes.js index e930061a3..4a4a654ce 100644 --- a/Projects/Superalgos/UI/Function-Libraries/UiObjectsFromNodes.js +++ b/Projects/Superalgos/UI/Function-Libraries/UiObjectsFromNodes.js @@ -162,10 +162,10 @@ function newSuperalgosFunctionLibraryUiObjectsFromNodes() { if (i < node.rootNodes.length) { rootNode = node.rootNodes[i] UI.projects.superalgos.utilities.creditsPage.changeStatus("Connecting children nodes from " + rootNode.name + " - " + rootNode.type + "...") - setTimeout(loopBody, 0) + setTimeout(loopBody, 100) } else { UI.projects.superalgos.utilities.creditsPage.changeStatus("Setting up the Docs Search Engine Index...") - setTimeout(endLoop) + setTimeout(endLoop, 100) } } } diff --git a/Projects/Superalgos/UI/Spaces/Design-Space/Workspace.js b/Projects/Superalgos/UI/Spaces/Design-Space/Workspace.js index 01a960403..0b5f19699 100644 --- a/Projects/Superalgos/UI/Spaces/Design-Space/Workspace.js +++ b/Projects/Superalgos/UI/Spaces/Design-Space/Workspace.js @@ -111,8 +111,14 @@ function newWorkspace() { thisObject.enabled = true UI.projects.superalgos.spaces.cockpitSpace.initializePosition() CAN_SPACES_DRAW = true - savingWorkspaceIntervalId = setInterval(saveWorkspace, 60000) + + /* + We will help the Docs Space finish its initialization, since it is + waiting for the workspace to be done. + */ + UI.projects.superalgos.spaces.docsSpace.searchEngine.setUpSearchEngine() thisObject.isInitialized = true + savingWorkspaceIntervalId = setInterval(saveWorkspace, 60000) UI.projects.superalgos.utilities.creditsPage.changeStatus("Displaying the UI...") } } catch (err) { diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js b/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js index 1c1e9a357..f61cbfbba 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/CommandInterface.js @@ -452,7 +452,6 @@ function newSuperalgosDocsCommmandInterface() { setTimeout(startReindexingProcess, 100) function startReindexingProcess() { - UI.projects.superalgos.spaces.docsSpace.setUpWorkspaceSchemas() UI.projects.superalgos.spaces.docsSpace.searchEngine.setUpSearchEngine() UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Message - Reindexing Succeed') diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js b/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js index 74b880fe5..4348dc086 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/DocsSpace.js @@ -20,7 +20,6 @@ function newSuperalgosDocSpace() { currentBookBeingRendered: undefined, paragraphMap: undefined, // Here we will store a map of paragraphs from the Docs Node, Concept, Topics, Tutorials or Books Schema in order to find it when we need to update them. textArea: undefined, - setUpWorkspaceSchemas: setUpWorkspaceSchemas, changeLanguage: changeLanguage, changeActiveBranch: changeActiveBranch, changeContributionsBranch: changeContributionsBranch, @@ -256,73 +255,6 @@ function newSuperalgosDocSpace() { } } - function setUpWorkspaceSchemas() { - /* - We will scan the whole workspace and create an array with all of its nodes. - */ - let rootNodes = UI.projects.superalgos.spaces.designSpace.workspace.workspaceNode.rootNodes - let allNodesFound = [] - for (let i = 0; i < rootNodes.length; i++) { - let rootNode = rootNodes[i] - if (rootNode !== null) { - let nodeArray = UI.projects.superalgos.utilities.branches.nodeBranchToArray(rootNode) - allNodesFound = allNodesFound.concat(nodeArray) - } - } - /* - We will create a document for each node, so that can later be indexed into the search engine. - */ - for (let j = 0; j < PROJECTS_ARRAY.length; j++) { - let project = PROJECTS_ARRAY[j] - SCHEMAS_BY_PROJECT.get(project).array.workspaceSchema = [] - SCHEMAS_BY_PROJECT.get(project).map.workspaceSchema = new Map() - - for (let i = 0; i < allNodesFound.length; i++) { - let node = allNodesFound[i] - - if (node.project === project) { - let nodeNameTypePath = UI.projects.superalgos.utilities.hierarchy.getNodeNameTypePath(node) - - let docsSchemaDocument = { - nodeId: node.id, - nodeNameTypePath: nodeNameTypePath, - type: node.type, - definition: { text: node.name }, - paragraphs: [] - } - if (node.config !== undefined) { - let paragraph - paragraph = { - style: "Title", - text: "Config" - } - docsSchemaDocument.paragraphs.push(paragraph) - paragraph = { - style: "Json", - text: node.config - } - docsSchemaDocument.paragraphs.push(paragraph) - } - if (node.code !== undefined) { - let paragraph - paragraph = { - style: "Title", - text: "Code" - } - docsSchemaDocument.paragraphs.push(paragraph) - paragraph = { - style: "Javascript", - text: node.code - } - docsSchemaDocument.paragraphs.push(paragraph) - } - SCHEMAS_BY_PROJECT.get(project).array.workspaceSchema.push(docsSchemaDocument) - SCHEMAS_BY_PROJECT.get(project).map.workspaceSchema.set(node.id, docsSchemaDocument) - } - } - } - } - function onClosing() { UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered = undefined thisObject.isVisible = false @@ -422,7 +354,6 @@ function newSuperalgosDocSpace() { function physics() { thisObject.sidePanelTab.physics() docsAppDivPhysics() - finishInitializePhysics() function docsAppDivPhysics() { let docsSpaceDiv = document.getElementById('docs-space-div') @@ -439,16 +370,6 @@ 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 (thisObject.searchEngine && thisObject.searchEngine.docsIndex && thisObject.searchEngine.docsIndex.length === 0) { - setUpWorkspaceSchemas() - thisObject.searchEngine.setUpSearchEngine() - } - } } function draw() { diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/SearchEngine.js b/Projects/Superalgos/UI/Spaces/Docs-Space/SearchEngine.js index ed16e6ef0..05f6b8f4b 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/SearchEngine.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/SearchEngine.js @@ -17,6 +17,8 @@ function newSuperalgosDocsSearchEngine() { } function setUpSearchEngine() { + + setUpWorkspaceSchemas() thisObject.docsIndex = [] for (let j = 0; j < PROJECTS_ARRAY.length; j++) { @@ -189,4 +191,71 @@ function newSuperalgosDocsSearchEngine() { } } } + + function setUpWorkspaceSchemas() { + /* + We will scan the whole workspace and create an array with all of its nodes. + */ + let rootNodes = UI.projects.superalgos.spaces.designSpace.workspace.workspaceNode.rootNodes + let allNodesFound = [] + for (let i = 0; i < rootNodes.length; i++) { + let rootNode = rootNodes[i] + if (rootNode !== null) { + let nodeArray = UI.projects.superalgos.utilities.branches.nodeBranchToArray(rootNode) + allNodesFound = allNodesFound.concat(nodeArray) + } + } + /* + We will create a document for each node, so that can later be indexed into the search engine. + */ + for (let j = 0; j < PROJECTS_ARRAY.length; j++) { + let project = PROJECTS_ARRAY[j] + SCHEMAS_BY_PROJECT.get(project).array.workspaceSchema = [] + SCHEMAS_BY_PROJECT.get(project).map.workspaceSchema = new Map() + + for (let i = 0; i < allNodesFound.length; i++) { + let node = allNodesFound[i] + + if (node.project === project) { + let nodeNameTypePath = UI.projects.superalgos.utilities.hierarchy.getNodeNameTypePath(node) + + let docsSchemaDocument = { + nodeId: node.id, + nodeNameTypePath: nodeNameTypePath, + type: node.type, + definition: { text: node.name }, + paragraphs: [] + } + if (node.config !== undefined) { + let paragraph + paragraph = { + style: "Title", + text: "Config" + } + docsSchemaDocument.paragraphs.push(paragraph) + paragraph = { + style: "Json", + text: node.config + } + docsSchemaDocument.paragraphs.push(paragraph) + } + if (node.code !== undefined) { + let paragraph + paragraph = { + style: "Title", + text: "Code" + } + docsSchemaDocument.paragraphs.push(paragraph) + paragraph = { + style: "Javascript", + text: node.code + } + docsSchemaDocument.paragraphs.push(paragraph) + } + SCHEMAS_BY_PROJECT.get(project).array.workspaceSchema.push(docsSchemaDocument) + SCHEMAS_BY_PROJECT.get(project).map.workspaceSchema.set(node.id, docsSchemaDocument) + } + } + } + } } \ No newline at end of file diff --git a/UI/Utilities.js b/UI/Utilities.js index cceb334ae..28b38e590 100644 --- a/UI/Utilities.js +++ b/UI/Utilities.js @@ -18,16 +18,17 @@ function dynamicDecimals(value, minDecimals) { minDecimals = 0 } let decimals = 0 - if (value < 1) { decimals = 2 } - - if (Math.abs(Math.trunc(value * 10)) < 1) { decimals = 4 } - if (Math.abs(Math.trunc(value * 100)) < 1) { decimals = 5 } - if (Math.abs(Math.trunc(value * 1000)) < 1) { decimals = 6 } - if (Math.abs(Math.trunc(value * 10000)) < 1) { decimals = 7 } - if (Math.abs(Math.trunc(value * 100000)) < 1) { decimals = 8 } - if (Math.abs(Math.trunc(value * 1000000)) < 1) { decimals = 9 } - if (Math.abs(Math.trunc(value * 10000000)) < 1) { decimals = 10 } - if (Math.abs(Math.trunc(value * 100000000000)) < 1) { value = 0; decimals = 0 } + if (value < 1) { decimals = 3 } + else if (value < 10) { decimals = 2 } + else if (value < 100) { decimals = 1 } + else if (Math.abs(Math.trunc(value * 10)) < 1) { decimals = 4 } + else if (Math.abs(Math.trunc(value * 100)) < 1) { decimals = 5 } + else if (Math.abs(Math.trunc(value * 1000)) < 1) { decimals = 6 } + else if (Math.abs(Math.trunc(value * 10000)) < 1) { decimals = 7 } + else if (Math.abs(Math.trunc(value * 100000)) < 1) { decimals = 8 } + else if (Math.abs(Math.trunc(value * 1000000)) < 1) { decimals = 9 } + else if (Math.abs(Math.trunc(value * 10000000)) < 1) { decimals = 10 } + else if (Math.abs(Math.trunc(value * 100000000000)) < 1) { value = 0; decimals = 0 } if (decimals < minDecimals) { decimals = minDecimals }