Tutorials Implemented at the Docs

This commit is contained in:
Luis Fernando Molina committed 2021-01-07 09:59:54 +01:00
1 parent 4c3b825caf
commit 75009ec4ec
9 files changed
+379 -13

No files matched your search

+58
View File
@@ -464,6 +464,60 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
}
break
}
case 'Save-Tutorial-Schema': {
getBody(processRequest)
async function processRequest(body) {
try {
let docsSchema = JSON.parse(body)
let project = requestParameters[3]
let filePath = global.env.PATH_TO_PROJECTS + '/' + project + '/Schemas/Docs-Tutorials'
const fs = require('fs')
fs.rmdir(filePath, { recursive: true }, onDirDeleted)
function onDirDeleted(err) {
if (err && err.code === 'EBUSY') {
throw ('Can not delete the folder ' + filePath + ' because a file in it is open by some other program.')
}
try {
fs.mkdirSync(filePath)
} catch (err) {
if (err.code !== 'EEXIST') {
throw (err)
}
}
for (let i = 0; i < docsSchema.length; i++) {
let schemaDocument = docsSchema[i]
let fileContent = JSON.stringify(schemaDocument, undefined, 4)
let pageNumber = '00' + schemaDocument.pageNumber
let fileName = schemaDocument.tutorial.toLowerCase() + '-' + pageNumber.substring(pageNumber.length - 3, pageNumber.length) + '-' + schemaDocument.type.toLowerCase()
for (let j = 0; j < 10; j++) {
fileName = fileName.replace(' ', '-')
}
fileName = fileName + '.json'
fs.writeFileSync(filePath + '/' + fileName, fileContent)
}
respondWithContent(JSON.stringify(global.DEFAULT_OK_RESPONSE), httpResponse)
}
} catch (err) {
console.log('[ERROR] httpInterface -> Docs -> Save-Tutorial-Schema -> Method call produced an error.')
console.log('[ERROR] httpInterface -> Docs -> Save-Tutorial-Schema -> err.stack = ' + err.stack)
console.log('[ERROR] httpInterface -> Docs -> Save-Tutorial-Schema -> Params Received = ' + body)
let error = {
result: 'Fail Because',
message: err.message,
stack: err.stack
}
respondWithContent(JSON.stringify(error), httpResponse)
}
}
break
}
case 'Save-Book-Schema': {
getBody(processRequest)
@@ -1225,6 +1279,10 @@ exports.newHttpInterface = function newHttpInterface(WEB_SERVER, DATA_FILE_SERVE
folder = 'Docs-Topics'
break
}
case 'DocsTutorialSchema': {
folder = 'Docs-Tutorials'
break
}
case 'DocsBookSchema': {
folder = 'Docs-Books'
break
@@ -0,0 +1,14 @@
{
"tutorial": "Test Tut",
"pageNumber": "1",
"type": "First Page",
"definition": {
"text": "Write here a summary for this tutorial page."
},
"paragraphs": [
{
"style": "Text",
"text": "Left click and Edit to enter edit mode and change this text. ENTER to write new paragraphs. ESC to exit edit mode."
}
]
}
@@ -136,6 +136,10 @@ function newSuperalgosDocsCommmandInterface() {
docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsTopicSchema.get(type)
break
}
case 'tutorial': {
docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema.get(type)
break
}
case 'book': {
docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsBookSchema.get(type)
break
@@ -213,6 +217,15 @@ function newSuperalgosDocsCommmandInterface() {
addTopic(splittedPrimaryCommand[3], splittedSecondaryCommand[0], splittedSecondaryCommand[1], splittedSecondaryCommand[2])
return
}
case 'tutorial': {
let splittedSecondaryCommand = secondaryCommand.split('->')
if (splittedSecondaryCommand.length < 3) {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Error Too Few Parameters', 'Anchor Too Few Paramenters')
return
}
addTutorial(splittedPrimaryCommand[3], splittedSecondaryCommand[0], splittedSecondaryCommand[1], splittedSecondaryCommand[2])
return
}
case 'book': {
addBook(splittedPrimaryCommand[3], secondaryCommand)
return
@@ -282,6 +295,15 @@ function newSuperalgosDocsCommmandInterface() {
deleteTopic(splittedPrimaryCommand[3], splittedSecondaryCommand[0], splittedSecondaryCommand[1], splittedSecondaryCommand[2])
return
}
case 'tutorial': {
let splittedSecondaryCommand = secondaryCommand.split('->')
if (splittedSecondaryCommand.length < 3) {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Error Too Few Parameters', 'Anchor Too Few Paramenters')
return
}
deleteTutorial(splittedPrimaryCommand[3], splittedSecondaryCommand[0], splittedSecondaryCommand[1], splittedSecondaryCommand[2])
return
}
case 'book': {
deleteBook(splittedPrimaryCommand[3], secondaryCommand)
return
@@ -334,6 +356,10 @@ function newSuperalgosDocsCommmandInterface() {
httpRequest(JSON.stringify(docsSchema), 'Docs/Save-Topic-Schema/' + project, onResponse)
requestsSent++
docsSchema = SCHEMAS_BY_PROJECT.get(project).array.docsTutorialSchema
httpRequest(JSON.stringify(docsSchema), 'Docs/Save-Tutorial-Schema/' + project, onResponse)
requestsSent++
docsSchema = SCHEMAS_BY_PROJECT.get(project).array.docsBookSchema
httpRequest(JSON.stringify(docsSchema), 'Docs/Save-Book-Schema/' + project, onResponse)
requestsSent++
@@ -438,6 +464,34 @@ function newSuperalgosDocsCommmandInterface() {
UI.projects.superalgos.spaces.docsSpace.navigateTo(project, 'Topic', type)
}
function addTutorial(project, tutorial, type, pageNumber) {
let template = {
tutorial: tutorial,
pageNumber: pageNumber,
type: type,
definition: { text: "Write here a summary for this tutorial page." },
paragraphs: [
{
style: "Text",
text: UI.projects.superalgos.globals.docs.NEW_PARAGRAPH_TEXT
}
]
}
if (SCHEMAS_BY_PROJECT.get(project) === undefined) {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Error Project Does Not Exist', 'Anchor Project Does Not Exist')
return
}
let exist = SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema.get(type)
if (exist !== undefined) {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Error Page Already Exists', 'Anchor Page Already Exists')
return
}
SCHEMAS_BY_PROJECT.get(project).array.docsTutorialSchema.push(template)
SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema.set(type, template)
UI.projects.superalgos.spaces.docsSpace.navigateTo(project, 'Tutorial', type)
}
function addBook(project, type) {
let template = {
type: type,
@@ -543,6 +597,38 @@ function newSuperalgosDocsCommmandInterface() {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Message Deleting Succeed')
}
function deleteTutorial(project, tutorial, type, pageNumber) {
if (SCHEMAS_BY_PROJECT.get(project) === undefined) {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Error Project Does Not Exist', 'Anchor Project Does Not Exist')
return
}
let exist = SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema.get(type)
if (exist === undefined) {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Error Page Does Not Exist', 'Anchor Page Does Not Exist')
return
} else {
if (exist.pageNumber !== pageNumber) {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Error Page Number Mismatch', 'Anchor Page Number Mismatch')
return
}
if (exist.tutorial !== tutorial) {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Error Tutorial Mismatch', 'Anchor Tutorial Mismatch')
return
}
}
SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema.delete(type)
for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.docsTutorialSchema.length; i++) {
docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).array.docsTutorialSchema[i]
if (docsSchemaDocument.type === type) {
docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).array.docsTutorialSchema.splice(i, 1)
break
}
}
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Message Deleting Succeed')
}
function deleteBook(project, type) {
if (SCHEMAS_BY_PROJECT.get(project) === undefined) {
UI.projects.superalgos.spaces.docsSpace.navigateTo('Superalgos', 'Topic', 'Docs Error Project Does Not Exist', 'Anchor Project Does Not Exist')
@@ -16,7 +16,7 @@ function newSuperalgosDocSpace() {
currentDocumentBeingRendered: undefined,
previousDocumentBeingRendered: undefined,
currentBookBeingRendered: undefined,
paragraphMap: undefined, // Here we will store a map of paragraphs from the Docs Node, Concept, Topics or Books Schema in order to find it when we need to update them.
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,
@@ -45,6 +45,10 @@ function newSuperalgosDocsDocumentPage() {
thisObject.docsSchemaDocument = SCHEMAS_BY_PROJECT.get(UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.project).map.docsTopicSchema.get(UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.type)
break
}
case 'Tutorial': {
thisObject.docsSchemaDocument = SCHEMAS_BY_PROJECT.get(UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.project).map.docsTutorialSchema.get(UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.type)
break
}
case 'Workspace': {
thisObject.docsSchemaDocument = SCHEMAS_BY_PROJECT.get(UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.project).map.workspaceSchema.get(UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.nodeId)
break
@@ -119,6 +123,7 @@ function newSuperalgosDocsDocumentPage() {
let definitionImagesArray = []
let hierarchyImagesArray = []
let orderedTopicPageIndexArray = []
let orderedTutorialPageIndexArray = []
let HTML = ''
HTML = HTML + '<section id="docs-search-results-div" class="docs-search-page-container">'
@@ -145,12 +150,23 @@ function newSuperalgosDocsDocumentPage() {
if (UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.category === 'Topic') {
buildOrderedTopicPageIndex(thisObject.docsSchemaDocument.topic)
generatePreviousAndNextPageNavigation()
generateTopicPreviousAndNextPageNavigation()
/* Topic Title */
titleLabel = thisObject.docsSchemaDocument.topic + ' Topic Content'
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.currentDocumentBeingRendered.type.toLowerCase().replace(' ', '-') + '" > ' + titleLabel + '</h2></div><div id="projectImageDiv" class="docs-image-container"/></div></div>'
generateMultiPageIndex()
generateTopicMultiPageIndex()
}
if (UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.category === 'Tutorial') {
buildOrderedTutorialPageIndex(thisObject.docsSchemaDocument.tutorial)
generateTutorialPreviousAndNextPageNavigation()
/* Tutorial Title */
titleLabel = thisObject.docsSchemaDocument.tutorial + ' Tutorial Content'
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.currentDocumentBeingRendered.type.toLowerCase().replace(' ', '-') + '" > ' + titleLabel + '</h2></div><div id="projectImageDiv" class="docs-image-container"/></div></div>'
generateTutorialMultiPageIndex()
}
HTML = HTML + '</div>' // Common Style Container Ends
@@ -183,7 +199,7 @@ function newSuperalgosDocsDocumentPage() {
/* We will test if we can draw an image here or not*/
let testElement = UI.projects.superalgos.spaces.designSpace.getIconByProjectAndType(project, type)
if ((category === 'Topic' || category === 'Concept' || category === 'Book') && testElement === undefined) {
if ((category === 'Topic' || category === 'Tutorial' || category === 'Concept' || category === 'Book') && testElement === undefined) {
HTML = HTML + '<div id="definition-summary-editable-paragraph" class="docs-summary"><b>Summary:</b> ' + UI.projects.superalgos.utilities.docs.addToolTips(definitionText, UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.type) + '</div>'
} else {
HTML = HTML + '<div class="docs-definition-table">'
@@ -231,7 +247,7 @@ function newSuperalgosDocsDocumentPage() {
}
}
function generatePreviousAndNextPageNavigation() {
function generateTopicPreviousAndNextPageNavigation() {
let previousPage
let nextPage
@@ -256,7 +272,7 @@ function newSuperalgosDocsDocumentPage() {
}
}
function generateMultiPageIndex() {
function generateTopicMultiPageIndex() {
/*
We will go through all the schema docuents array for the current project and pick
the documents that share the same key thatn the document we are rendering now.
@@ -277,6 +293,80 @@ function newSuperalgosDocsDocumentPage() {
}
}
function buildOrderedTutorialPageIndex(tutorial) {
orderedTutorialPageIndexArray = []
let schemaArray = SCHEMAS_BY_PROJECT.get(UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.project).array.docsTutorialSchema
for (let i = 0; i < schemaArray.length; i++) {
let arrayItem = schemaArray[i]
if (arrayItem.tutorial === tutorial) {
let itemAdded = false
if (orderedTutorialPageIndexArray.length === 0) {
orderedTutorialPageIndexArray.push(arrayItem)
itemAdded = true
} else {
for (let j = 0; j < orderedTutorialPageIndexArray.length; j++) {
let orderedArrayItem = orderedTutorialPageIndexArray[j]
if (Number(arrayItem.pageNumber) < Number(orderedArrayItem.pageNumber)) {
orderedTutorialPageIndexArray.splice(j, 0, arrayItem)
itemAdded = true
break
}
}
}
if (itemAdded === false) {
orderedTutorialPageIndexArray.push(arrayItem)
}
}
}
}
function generateTutorialPreviousAndNextPageNavigation() {
let previousPage
let nextPage
for (let i = 0; i < orderedTutorialPageIndexArray.length; i++) {
let arrayItem = orderedTutorialPageIndexArray[i]
if (thisObject.docsSchemaDocument.type === arrayItem.type) {
previousPage = orderedTutorialPageIndexArray[i - 1]
nextPage = orderedTutorialPageIndexArray[i + 1]
HTML = HTML + '<div class="docs-tutorial-navigation"><div>'
if (previousPage !== undefined) {
HTML = HTML + '<span" onClick="UI.projects.superalgos.spaces.docsSpace.navigateTo(\'' + UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.project + '\', \'' + 'Tutorial' + '\', \'' + previousPage.type.replace(/'/g, 'AMPERSAND') + '\')"><button>' + previousPage.type + '</button></span>'
}
HTML = HTML + '</div><div> << Current Page: ' + thisObject.docsSchemaDocument.pageNumber + ' >> </div><div>'
if (nextPage !== undefined) {
HTML = HTML + '<span" onClick="UI.projects.superalgos.spaces.docsSpace.navigateTo(\'' + UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.project + '\', \'' + 'Tutorial' + '\', \'' + nextPage.type.replace(/'/g, 'AMPERSAND') + '\')"><button>' + nextPage.type + '</button></span>'
}
HTML = HTML + '</div></div>'
return
}
}
}
function generateTutorialMultiPageIndex() {
/*
We will go through all the schema docuents array for the current project and pick
the documents that share the same key thatn the document we are rendering now.
With the info on those picked document we will build the index.
*/
let key = 'auto-generated-index-paragraph-' + autoGeneratedParagraphIndex
let paragraph
for (let i = 0; i < orderedTutorialPageIndexArray.length; i++) {
let arrayItem = orderedTutorialPageIndexArray[i]
key = 'auto-generated-index-paragraph-' + autoGeneratedParagraphIndex
paragraph = {
style: "Title",
text: "" + arrayItem.type + ""
}
autoGeneratedParagraphIndex++
HTML = HTML + '<p>' + arrayItem.pageNumber + '. ' + '<a class="docs-link" onClick="UI.projects.superalgos.spaces.docsSpace.navigateTo(\'' + UI.projects.superalgos.spaces.docsSpace.currentDocumentBeingRendered.project + '\', \'' + 'Tutorial' + '\', \'' + arrayItem.type.replace(/'/g, 'AMPERSAND') + '\')">' + paragraph.text + '</a></p>'
}
}
function addContent() {
HTML = HTML + '<div id="docs-content">'
if (thisObject.docsSchemaDocument.paragraphs !== undefined) {
@@ -357,11 +447,15 @@ function newSuperalgosDocsDocumentPage() {
includedSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsTopicSchema.get(type)
break
}
case 'Tutorial': {
includedSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema.get(type)
break
}
case 'Book': {
includedSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsBookSchema.get(type)
break
}
default: return 'Category provided (' + category + ') not valid. Use Node, Concept, Topic or Book instead.'
default: return 'Category provided (' + category + ') not valid. Use Node, Concept, Topic, Tutorial or Book instead.'
}
if (includedSchemaDocument === undefined) {
return category + ' document ' + type + ' not found at project ' + project
@@ -451,7 +545,7 @@ function newSuperalgosDocsDocumentPage() {
autoGeneratedParagraphIndex++
}
generateMultiPageIndex()
generateTopicMultiPageIndex()
}
}
@@ -57,6 +57,17 @@ function newSuperalgosDocsSearchEngine() {
indexDocument(documentIndex)
thisObject.docsIndex.push(documentIndex)
}
/* Search in Tutorials */
for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.docsTutorialSchema.length; i++) {
documentIndex = {
phraseCount: {}, // here we have an object with properties matching it paragraph style, and each property is a map of phrases and their total count.
docsSchemaDocument: SCHEMAS_BY_PROJECT.get(project).array.docsTutorialSchema[i],
category: 'Tutorial',
project: project
}
indexDocument(documentIndex)
thisObject.docsIndex.push(documentIndex)
}
/* Search in Books */
for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.docsBookSchema.length; i++) {
documentIndex = {
@@ -94,6 +105,13 @@ function newSuperalgosDocsSearchEngine() {
}
indexParagraph(paragraph)
}
if (documentIndex.docsSchemaDocument.tutorial !== undefined) {
let paragraph = {
style: 'Tutorial',
text: documentIndex.docsSchemaDocument.tutorial
}
indexParagraph(paragraph)
}
if (documentIndex.docsSchemaDocument.type !== undefined) {
let paragraph = {
style: 'Type',
@@ -44,12 +44,21 @@ function newSuperalgosDocsSearchResultsPage() {
documentPoints = documentPoints + thisPhraseCount * 200
}
}
if (documentIndex.docsSchemaDocument.tutorial !== undefined) {
if (key === UI.projects.superalgos.utilities.strings.cleanTextOfCommonWordEndings(documentIndex.docsSchemaDocument.tutorial.toLowerCase())) {
documentPoints = documentPoints + thisPhraseCount * 200
}
}
switch (style) {
case 'topic': {
documentPoints = documentPoints + thisPhraseCount * 100
break
}
case 'tutorial': {
documentPoints = documentPoints + thisPhraseCount * 100
break
}
case 'type': {
documentPoints = documentPoints + thisPhraseCount * 50
break
@@ -185,7 +194,7 @@ function newSuperalgosDocsSearchResultsPage() {
}
function buildHTML() {
const tabs = ['All', 'Nodes', 'Concepts', 'Topics', 'Books', 'Workspace']
const tabs = ['All', 'Nodes', 'Concepts', 'Topics', 'Tutorials', 'Books', 'Workspace']
let HTML = ''
HTML = HTML + '<section id="docs-search-results-div" class="docs-search-page-container">'
HTML = HTML + UI.projects.superalgos.spaces.docsSpace.mainSearchPage.addSearchHeader()
@@ -246,10 +255,19 @@ function newSuperalgosDocsSearchResultsPage() {
HTML = HTML + '<p class="docs-search-result-content-record-project-category">' + result.documentIndex.project + ' > ' + result.documentIndex.category + path + '</p>'
let mainLink = ''
if (result.documentIndex.docsSchemaDocument.topic === undefined) {
mainLink = result.documentIndex.docsSchemaDocument.type
} else {
mainLink = result.documentIndex.docsSchemaDocument.topic + ' - Page ' + result.documentIndex.docsSchemaDocument.pageNumber + ' - ' + result.documentIndex.docsSchemaDocument.type
switch (result.documentIndex.docsSchemaDocument.type) {
case 'Topic': {
mainLink = result.documentIndex.docsSchemaDocument.topic + ' - Page ' + result.documentIndex.docsSchemaDocument.pageNumber + ' - ' + result.documentIndex.docsSchemaDocument.type
break
}
case 'Tutorial': {
mainLink = result.documentIndex.docsSchemaDocument.tutorial + ' - Page ' + result.documentIndex.docsSchemaDocument.pageNumber + ' - ' + result.documentIndex.docsSchemaDocument.type
break
}
default: {
mainLink = result.documentIndex.docsSchemaDocument.type
}
}
HTML = HTML + '<p><a onClick="UI.projects.superalgos.spaces.docsSpace.navigateTo(\'' + result.documentIndex.project + '\', \'' + result.documentIndex.category + '\', \'' + result.documentIndex.docsSchemaDocument.type.replace(/'/g, 'AMPERSAND') + '\', ' + undefined + ' ,\'' + result.documentIndex.docsSchemaDocument.nodeId + '\')" class="docs-search-result-content-record-title">' + mainLink + '</a></p>'
+56
View File
@@ -396,6 +396,11 @@ function newSuperalgosUtilitiesDocs() {
found = true
break
}
docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema.get(type)
if (docsSchemaDocument !== undefined) {
found = true
break
}
docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsBookSchema.get(type)
if (docsSchemaDocument !== undefined) {
found = true
@@ -608,6 +613,57 @@ function newSuperalgosUtilitiesDocs() {
break
}
/* Search in docsTutorialSchema */
if (SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema.get(cleanPhrase5) !== undefined) {
if (cleanPhrase5 !== excludedType) {
taggedText = taggedText + phrase5.replace(cleanPhrase5, TAGGING_STRING_SEPARATOR + 'Tutorial' + '|' + cleanPhrase5 + '|' + project + TAGGING_STRING_SEPARATOR) + ' '
} else {
taggedText = taggedText + phrase5 + ' '
}
i = i + 4
found = true
break
}
if (SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema.get(cleanPhrase4) !== undefined) {
if (cleanPhrase4 !== excludedType) {
taggedText = taggedText + phrase4.replace(cleanPhrase4, TAGGING_STRING_SEPARATOR + 'Tutorial' + '|' + cleanPhrase4 + '|' + project + TAGGING_STRING_SEPARATOR) + ' '
} else {
taggedText = taggedText + phrase4 + ' '
}
i = i + 3
found = true
break
}
if (SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema.get(cleanPhrase3) !== undefined) {
if (cleanPhrase3 !== excludedType) {
taggedText = taggedText + phrase3.replace(cleanPhrase3, TAGGING_STRING_SEPARATOR + 'Tutorial' + '|' + cleanPhrase3 + '|' + project + TAGGING_STRING_SEPARATOR) + ' '
} else {
taggedText = taggedText + phrase3 + ' '
}
i = i + 2
found = true
break
}
if (SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema.get(cleanPhrase2) !== undefined) {
if (cleanPhrase2 !== excludedType) {
taggedText = taggedText + phrase2.replace(cleanPhrase2, TAGGING_STRING_SEPARATOR + 'Tutorial' + '|' + cleanPhrase2 + '|' + project + TAGGING_STRING_SEPARATOR) + ' '
} else {
taggedText = taggedText + phrase2 + ' '
}
i = i + 1
found = true
break
}
if (SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema.get(cleanPhrase1) !== undefined) {
if (cleanPhrase1 !== excludedType) {
taggedText = taggedText + phrase1.replace(cleanPhrase1, TAGGING_STRING_SEPARATOR + 'Tutorial' + '|' + cleanPhrase1 + '|' + project + TAGGING_STRING_SEPARATOR) + ' '
} else {
taggedText = taggedText + phrase1 + ' '
}
found = true
break
}
/* Search in docsBookSchema */
if (SCHEMAS_BY_PROJECT.get(project).map.docsBookSchema.get(cleanPhrase5) !== undefined) {
if (cleanPhrase5 !== excludedType) {
+22
View File
@@ -43,6 +43,7 @@ function newAppPostLoader() {
docsNodeSchema: [],
docsConceptSchema: [],
docsTopicSchema: [],
docsTutorialSchema: [],
docsBookSchema: []
},
map: {
@@ -50,6 +51,7 @@ function newAppPostLoader() {
docsNodeSchema: new Map(),
docsConceptSchema: new Map(),
docsTopicSchema: new Map(),
docsTutorialSchema: new Map(),
docsBookSchema: new Map()
}
}
@@ -135,6 +137,26 @@ function newAppPostLoader() {
if (webServerResponses === totalWebServerCalls) { startCanvas() }
}
totalWebServerCalls++
httpRequest(undefined, 'Schema/' + project + '/DocsTutorialSchema', onResponseTutorialSchema)
function onResponseTutorialSchema(err, schema) {
try {
schemas.array.docsTutorialSchema = JSON.parse(schema)
for (let j = 0; j < schemas.array.docsTutorialSchema.length; j++) {
let schemaDocument = schemas.array.docsTutorialSchema[j]
let key = schemaDocument.type
schemas.map.docsTutorialSchema.set(key, schemaDocument)
}
} catch (err) {
console.log(err.stack)
}
webServerResponses++
if (webServerResponses === totalWebServerCalls) { startCanvas() }
}
totalWebServerCalls++
httpRequest(undefined, 'Schema/' + project + '/DocsBookSchema', onResponseBookSchema)