From c201d01ce2120ec20029242c5b5d5fe55bd36629 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 2 Jan 2021 13:09:01 +0100 Subject: [PATCH] Topic Navigation --- .../UI/Spaces/Docs-Space/DocumentPage.js | 106 +++++++++++------- 1 file changed, 63 insertions(+), 43 deletions(-) diff --git a/Projects/Superalgos/UI/Spaces/Docs-Space/DocumentPage.js b/Projects/Superalgos/UI/Spaces/Docs-Space/DocumentPage.js index 512a63fd1..bf3879041 100644 --- a/Projects/Superalgos/UI/Spaces/Docs-Space/DocumentPage.js +++ b/Projects/Superalgos/UI/Spaces/Docs-Space/DocumentPage.js @@ -109,6 +109,7 @@ function newSuperalgosDocsDocumentPage() { function buildHtmlPage() { let definitionImagesArray = [] let hierarchyImagesArray = [] + let orderedTopicPageIndexArray = [] let HTML = '' HTML = HTML + '
' @@ -133,8 +134,11 @@ function newSuperalgosDocsDocumentPage() { if (UI.projects.superalgos.spaces.docsSpace.objectBeingRendered.category === 'Topic') { + + buildOrderedTopicPageIndex() + generatePreviousAndNextPageNavigation() /* Topic Title */ - titleLabel = docsSchemaDocument.topic + ' - Page ' + docsSchemaDocument.pageNumber + titleLabel = docsSchemaDocument.topic + ' Topic' HTML = HTML + '

' + titleLabel + '

' generateMultiPageIndex() @@ -186,6 +190,58 @@ function newSuperalgosDocsDocumentPage() { } } + function buildOrderedTopicPageIndex() { + let schemaArray = SCHEMAS_BY_PROJECT.get(UI.projects.superalgos.spaces.docsSpace.objectBeingRendered.project).array.docsTopicSchema + for (let i = 0; i < schemaArray.length; i++) { + let arrayItem = schemaArray[i] + + if (arrayItem.topic === docsSchemaDocument.topic) { + let itemAdded = false + if (orderedTopicPageIndexArray.length === 0) { + orderedTopicPageIndexArray.push(arrayItem) + itemAdded = true + } else { + for (let j = 0; j < orderedTopicPageIndexArray.length; j++) { + let orderedArrayItem = orderedTopicPageIndexArray[j] + if (Number(arrayItem.pageNumber) < Number(orderedArrayItem.pageNumber)) { + orderedTopicPageIndexArray.splice(j, 0, arrayItem) + itemAdded = true + break + } + } + } + if (itemAdded === false) { + orderedTopicPageIndexArray.push(arrayItem) + } + } + } + } + + function generatePreviousAndNextPageNavigation() { + let previousPage + let nextPage + + for (let i = 0; i < orderedTopicPageIndexArray.length; i++) { + let arrayItem = orderedTopicPageIndexArray[i] + + if (docsSchemaDocument.type === arrayItem.type) { + previousPage = orderedTopicPageIndexArray[i - 1] + nextPage = orderedTopicPageIndexArray[i + 1] + + HTML = HTML + '

' + if (previousPage !== undefined) { + HTML = HTML + '(Previous) ' + previousPage.type + '' + } + HTML = HTML + ' Current Page: ' + docsSchemaDocument.pageNumber + ' ' + if (nextPage !== undefined) { + HTML = HTML + '' + nextPage.type + ' (Next)' + } + HTML = HTML + '

' + return + } + } + } + function generateMultiPageIndex() { /* We will go through all the schema docuents array for the current project and pick @@ -193,53 +249,17 @@ function newSuperalgosDocsDocumentPage() { With the info on those picked document we will build the index. */ let key = 'auto-generated-index-paragraph-' + autoGeneratedParagraphIndex - let paragraph = { - style: "Title", - text: "

" + docsSchemaDocument.topic + " TOC

" - } + let paragraph - HTML = HTML = HTML + '
' // Container for title and index - - renderParagraph(paragraph, key) - autoGeneratedParagraphIndex++ - - let orderedIndexArray = [] - let schemaArray = SCHEMAS_BY_PROJECT.get(UI.projects.superalgos.spaces.docsSpace.objectBeingRendered.project).array.docsTopicSchema - for (let i = 0; i < schemaArray.length; i++) { - let arrayItem = schemaArray[i] - - if (arrayItem.topic === docsSchemaDocument.topic) { - let itemAdded = false - if (orderedIndexArray.length === 0) { - orderedIndexArray.push(arrayItem) - itemAdded = true - } else { - for (let j = 0; j < orderedIndexArray.length; j++) { - let orderedArrayItem = orderedIndexArray[j] - if (Number(arrayItem.pageNumber) < Number(orderedArrayItem.pageNumber)) { - orderedIndexArray.splice(j, 0, arrayItem) - itemAdded = true - break - } - } - } - if (itemAdded === false) { - orderedIndexArray.push(arrayItem) - } - - } - } - - for (let i = 0; i < orderedIndexArray.length; i++) { - let arrayItem = orderedIndexArray[i] - paragraph + for (let i = 0; i < orderedTopicPageIndexArray.length; i++) { + let arrayItem = orderedTopicPageIndexArray[i] key = 'auto-generated-index-paragraph-' + autoGeneratedParagraphIndex paragraph = { style: "Title", text: "" + arrayItem.pageNumber + '. ' + arrayItem.type + "" } autoGeneratedParagraphIndex++ - HTML = HTML + '

' + paragraph.text + '

' + HTML = HTML + '

' + paragraph.text + '

' } HTML = HTML = HTML + '
' // END Container for title and index @@ -593,7 +613,7 @@ function newSuperalgosDocsDocumentPage() { autoGeneratedParagraphIndex++ paragraph = { style: "Text", - text: "The " + appSchemaDocument.type + " Node has the following Node Menu items:" + text: "The " + appSchemaDocument.type + " node has the following Node Menu items:" } renderParagraph(paragraph, key) autoGeneratedParagraphIndex++ @@ -646,7 +666,7 @@ function newSuperalgosDocsDocumentPage() { autoGeneratedParagraphIndex++ paragraph = { style: "Text", - text: "The " + appSchemaDocument.type + " Node has the following childrenNodesProperties which hold the Node Children at runtime:" + text: "The " + appSchemaDocument.type + " node has the following childrenNodesProperties which hold the Node Children at runtime:" } renderParagraph(paragraph, key) autoGeneratedParagraphIndex++