Topic Navigation
This commit is contained in:
1 parent
922d8cd196
commit
c201d01ce2
1 file changed
+63
-43
@@ -109,6 +109,7 @@ function newSuperalgosDocsDocumentPage() {
|
||||
function buildHtmlPage() {
|
||||
let definitionImagesArray = []
|
||||
let hierarchyImagesArray = []
|
||||
let orderedTopicPageIndexArray = []
|
||||
let HTML = ''
|
||||
|
||||
HTML = HTML + '<section id="docs-search-results-div" class="docs-search-page-container">'
|
||||
@@ -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 + '<div id="docs-main-title-div" class="docs-title-table"><div class="docs-table-cell"><h2 class="docs-h2" id="' + UI.projects.superalgos.spaces.docsSpace.objectBeingRendered.type.toLowerCase().replace(' ', '-') + '" > ' + titleLabel + '</h2></div><div id="projectImageDiv" class="docs-image-container"/></div></div>'
|
||||
|
||||
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 + '<p><center>'
|
||||
if (previousPage !== undefined) {
|
||||
HTML = HTML + '(Previous) <a class="docs-link" onClick="UI.projects.superalgos.spaces.docsSpace.navigateTo(\'' + UI.projects.superalgos.spaces.docsSpace.objectBeingRendered.project + '\', \'' + 'Topic' + '\', \'' + previousPage.type.replace(/'/g, 'AMPERSAND') + '\')">' + previousPage.type + '</a>'
|
||||
}
|
||||
HTML = HTML + ' Current Page: ' + docsSchemaDocument.pageNumber + ' '
|
||||
if (nextPage !== undefined) {
|
||||
HTML = HTML + '<a class="docs-link" onClick="UI.projects.superalgos.spaces.docsSpace.navigateTo(\'' + UI.projects.superalgos.spaces.docsSpace.objectBeingRendered.project + '\', \'' + 'Topic' + '\', \'' + nextPage.type.replace(/'/g, 'AMPERSAND') + '\')">' + nextPage.type + '</a> (Next)'
|
||||
}
|
||||
HTML = HTML + '</center></p>'
|
||||
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: "<h3>" + docsSchemaDocument.topic + " TOC</H3>"
|
||||
}
|
||||
let paragraph
|
||||
|
||||
HTML = HTML = HTML + '<div class="docs-topic-index">' // 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 + '<p><a onClick="UI.projects.superalgos.spaces.docsSpace.navigateTo(\'' + UI.projects.superalgos.spaces.docsSpace.objectBeingRendered.project + '\', \'' + 'Topic' + '\', \'' + arrayItem.type.replace(/'/g, 'AMPERSAND') + '\')">' + paragraph.text + '</a></p>'
|
||||
HTML = HTML + '<p><a class="docs-link" onClick="UI.projects.superalgos.spaces.docsSpace.navigateTo(\'' + UI.projects.superalgos.spaces.docsSpace.objectBeingRendered.project + '\', \'' + 'Topic' + '\', \'' + arrayItem.type.replace(/'/g, 'AMPERSAND') + '\')">' + paragraph.text + '</a></p>'
|
||||
}
|
||||
|
||||
HTML = HTML = HTML + '</div>' // 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++
|
||||
|
||||
Reference in new issue
Block a user