Merge Develop into Master
This commit is contained in:
1 parent
2d7ed1d085
commit
2bb78c50fb
4223 files changed
+1207152
-16544
No files matched your search
@@ -0,0 +1,26 @@
|
||||
function newEducationActionSwitch() {
|
||||
|
||||
let thisObject = {
|
||||
executeAction: executeAction,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
return thisObject
|
||||
|
||||
function finalize() {
|
||||
|
||||
}
|
||||
|
||||
function initialize() {
|
||||
/* Nothing to initialize since a Function Library does not hold any state. */
|
||||
}
|
||||
|
||||
async function executeAction(action) {
|
||||
switch (action.name) {
|
||||
case 'Action Name': {
|
||||
// Example: return UI.projects.foundations.functionLibraries.onFocus.getNodeThatIsOnFocus(action.node)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
function newEducationGlobalsDocs() {
|
||||
let thisObject = {
|
||||
NEW_PARAGRAPH_TEXT: "Right click and Edit to enter edit mode and change this text. ENTER to write new paragraphs. ESC to exit edit mode. Then you can use docs.save to save your changes and app.contribute to send it to the main repository.",
|
||||
DEFAULT_LANGUAGE: 'EN',
|
||||
DEFAULT_CURRENT_BRANCH: 'master',
|
||||
DEFAULT_CONTRIBUTIONS_BRANCH: 'develop',
|
||||
DOCS_SPACE_WIDTH: 900
|
||||
}
|
||||
return thisObject
|
||||
}
|
||||
@@ -0,0 +1,997 @@
|
||||
function newFoundationsDocsCommmandInterface() {
|
||||
let thisObject = {
|
||||
command: undefined,
|
||||
detectCommands: detectCommands,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
return thisObject
|
||||
|
||||
function initialize() {
|
||||
|
||||
}
|
||||
|
||||
function finalize() {
|
||||
|
||||
}
|
||||
|
||||
function detectCommands() {
|
||||
if (detectAppCommands() === true) { return }
|
||||
if (detectDocsCommands() === true) { return }
|
||||
|
||||
/* If we can not detect any app or docs commands, then we assume the users is running a search query */
|
||||
UI.projects.education.spaces.docsSpace.searchResultsPage.render()
|
||||
}
|
||||
|
||||
function detectAppCommands() {
|
||||
if (checkContributeCommand() === undefined) { return true }
|
||||
if (checkUpdateCommand() === undefined) { return true }
|
||||
|
||||
function checkContributeCommand() {
|
||||
if (UI.projects.education.spaces.docsSpace.commandInterface.command.toLowerCase() === 'app.help app.contribute') {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'App Contribute Command')
|
||||
return
|
||||
}
|
||||
if (UI.projects.education.spaces.docsSpace.commandInterface.command.indexOf('App.Contribute') !== 0 && UI.projects.education.spaces.docsSpace.commandInterface.command.indexOf('app.contribute') !== 0) { return 'Not Contribute Commands' }
|
||||
|
||||
/* Set up the commit message */
|
||||
let message = UI.projects.education.spaces.docsSpace.commandInterface.command.trim().substring(UI.projects.education.spaces.docsSpace.commandInterface.command.indexOf(' ') + 1, UI.projects.education.spaces.docsSpace.commandInterface.command.length)
|
||||
if (message.toLowerCase() === 'app.contribute') {
|
||||
message = 'This is my contribution to Superalgos'
|
||||
}
|
||||
|
||||
/* Find the Username and Password */
|
||||
let apisNode = UI.projects.foundations.spaces.designSpace.workspace.getHierarchyHeadByNodeType('APIs')
|
||||
if (apisNode === undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'App Error - Github Credentials Missing', 'Anchor Github Credentials Missing')
|
||||
return
|
||||
}
|
||||
if (apisNode.githubAPI === undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'App Error - Github Credentials Missing', 'Anchor Github Credentials Missing')
|
||||
return
|
||||
}
|
||||
|
||||
let config = JSON.parse(apisNode.githubAPI.config)
|
||||
if (config.username === undefined || config.username === "") {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'App Error - Github Credentials Missing', 'Anchor Github Credentials Missing')
|
||||
return
|
||||
}
|
||||
if (config.token === undefined || config.token === "") {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'App Error - Github Credentials Missing', 'Anchor Github Credentials Missing')
|
||||
return
|
||||
}
|
||||
|
||||
message = message.replaceAll('#', '_HASHTAG_')
|
||||
message = message.replaceAll('/', '_SLASH_')
|
||||
|
||||
httpRequest(
|
||||
undefined,
|
||||
'App/Contribute/' +
|
||||
message + '/' +
|
||||
config.username + '/' +
|
||||
config.token + '/' +
|
||||
UI.projects.education.spaces.docsSpace.currentBranch + '/' +
|
||||
UI.projects.education.spaces.docsSpace.contributionsBranch
|
||||
, onResponse)
|
||||
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'App Message - Creating Pull Request')
|
||||
|
||||
return
|
||||
|
||||
function onResponse(err, data) {
|
||||
/* Lets check the result of the call through the http interface */
|
||||
data = JSON.parse(data)
|
||||
if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result && data.result === GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'App Message - Contribution Done')
|
||||
} else {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo(
|
||||
data.docs.project,
|
||||
data.docs.category,
|
||||
data.docs.type,
|
||||
data.docs.anchor,
|
||||
undefined,
|
||||
data.docs.placeholder
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkUpdateCommand() {
|
||||
if (UI.projects.education.spaces.docsSpace.commandInterface.command.toLowerCase() === 'app.help app.update') {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'App Update Command')
|
||||
return
|
||||
}
|
||||
if (UI.projects.education.spaces.docsSpace.commandInterface.command.indexOf('App.Update') !== 0 && UI.projects.education.spaces.docsSpace.commandInterface.command.indexOf('app.update') !== 0) { return 'Not Update Commands' }
|
||||
|
||||
httpRequest(undefined, 'App/Update/' + UI.projects.education.spaces.docsSpace.currentBranch, onResponse)
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'App Message - Updating Your Local App')
|
||||
|
||||
return
|
||||
|
||||
function onResponse(err, data) {
|
||||
/* Lets check the result of the call through the http interface */
|
||||
data = JSON.parse(data)
|
||||
if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result && data.result === GLOBAL.CUSTOM_OK_RESPONSE.result) {
|
||||
if (data.message.summary.changes + data.message.summary.deletions + data.message.summary.insertions > 0) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'App Message - Update Done - New Version Found')
|
||||
} else {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'App Message - Update Done - Already Up-To-Date')
|
||||
}
|
||||
} else {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo(
|
||||
data.docs.project,
|
||||
data.docs.category,
|
||||
data.docs.type,
|
||||
data.docs.anchor,
|
||||
undefined,
|
||||
data.docs.placeholder
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function detectDocsCommands() {
|
||||
|
||||
if (checkHelpCommand() === undefined) { return true }
|
||||
if (checkGotoCommand() === undefined) { return true }
|
||||
if (checkAddCommand() === undefined) { return true }
|
||||
if (checkDeleteCommand() === undefined) { return true }
|
||||
if (checkRepaginateCommand() === undefined) { return true }
|
||||
if (checkUReIndexCommand() === undefined) { return true }
|
||||
if (checkUSaveCommand() === undefined) { return true }
|
||||
|
||||
function checkHelpCommand() {
|
||||
if (UI.projects.education.spaces.docsSpace.commandInterface.command.toLowerCase() === 'docs.help') {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Help Command')
|
||||
return
|
||||
}
|
||||
return 'Not Help Command'
|
||||
}
|
||||
|
||||
function checkGotoCommand() {
|
||||
if (UI.projects.education.spaces.docsSpace.commandInterface.command.toLowerCase() === 'docs.help docs.goto') {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Goto Command')
|
||||
return
|
||||
}
|
||||
if (UI.projects.education.spaces.docsSpace.commandInterface.command.indexOf('Docs.Goto') !== 0 && UI.projects.education.spaces.docsSpace.commandInterface.command.indexOf('docs.goto') !== 0) { return 'Not Goto Command' }
|
||||
|
||||
let splittedCommand = UI.projects.education.spaces.docsSpace.commandInterface.command.split(' ')
|
||||
|
||||
if (splittedCommand[1] === undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Too Few Parameters', 'Anchor Too Few Parameters')
|
||||
return
|
||||
}
|
||||
let secondaryCommand = UI.projects.education.spaces.docsSpace.commandInterface.command.substring(UI.projects.education.spaces.docsSpace.commandInterface.command.indexOf(' ') + 1, UI.projects.education.spaces.docsSpace.commandInterface.command.length)
|
||||
let splittedSecondaryCommand = secondaryCommand.split('->')
|
||||
let project = splittedSecondaryCommand[0]
|
||||
let category = splittedSecondaryCommand[1]
|
||||
let type = splittedSecondaryCommand[2]
|
||||
let anchor = splittedSecondaryCommand[3]
|
||||
|
||||
if (SCHEMAS_BY_PROJECT.get(project) === undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Project Does Not Exist', 'Anchor Project Does Not Exist')
|
||||
return
|
||||
}
|
||||
let docsSchemaDocument
|
||||
switch (category.toLowerCase()) {
|
||||
case 'node': {
|
||||
docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsNodeSchema.get(type)
|
||||
break
|
||||
}
|
||||
case 'concept': {
|
||||
docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsConceptSchema.get(type)
|
||||
break
|
||||
}
|
||||
case 'topic': {
|
||||
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 'review': {
|
||||
docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsReviewSchema.get(type)
|
||||
break
|
||||
}
|
||||
case 'book': {
|
||||
docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsBookSchema.get(type)
|
||||
break
|
||||
}
|
||||
default: {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Category Not Valid', 'Anchor Category Not Valid')
|
||||
return
|
||||
}
|
||||
}
|
||||
if (docsSchemaDocument === undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Page Not Found', 'Anchor Page Not Found')
|
||||
return
|
||||
}
|
||||
if (docsSchemaDocument.paragraphs === undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Page With No Paragraphs', 'Anchor Page With No Paragraphs')
|
||||
return
|
||||
}
|
||||
UI.projects.education.spaces.docsSpace.navigateTo(project, category, type, anchor, undefined)
|
||||
|
||||
}
|
||||
|
||||
function checkAddCommand() {
|
||||
if (UI.projects.education.spaces.docsSpace.commandInterface.command.toLowerCase() === 'docs.help docs.add') {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Add Command')
|
||||
return
|
||||
}
|
||||
if (UI.projects.education.spaces.docsSpace.commandInterface.command.indexOf('Docs.Add') !== 0 && UI.projects.education.spaces.docsSpace.commandInterface.command.indexOf('docs.add') !== 0) { return 'Not Add Command' }
|
||||
|
||||
if (UI.projects.education.spaces.docsSpace.language !== UI.projects.education.globals.docs.DEFAULT_LANGUAGE) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Only In English', 'Anchor Only In English')
|
||||
return
|
||||
}
|
||||
|
||||
let splittedCommand = UI.projects.education.spaces.docsSpace.commandInterface.command.split(': ')
|
||||
if (splittedCommand[1] === undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Missing Colon', 'Anchor Missing Colon')
|
||||
return
|
||||
}
|
||||
let primaryCommand = splittedCommand[0]
|
||||
let secondaryCommand = splittedCommand[1]
|
||||
|
||||
let splittedPrimaryCommand = primaryCommand.split(' ')
|
||||
|
||||
if (splittedPrimaryCommand[0].toLowerCase() === 'docs.add') {
|
||||
if (splittedPrimaryCommand[2] !== 'to') {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Missing To', 'Anchor Missing To')
|
||||
return
|
||||
}
|
||||
|
||||
if (splittedPrimaryCommand.length < 4) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Too Few Parameters', 'Anchor Too Few Parameters')
|
||||
return
|
||||
}
|
||||
|
||||
if (secondaryCommand === '') {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Category Not Valid', 'Anchor Category Not Valid')
|
||||
return
|
||||
}
|
||||
|
||||
switch (splittedPrimaryCommand[1].toLowerCase()) {
|
||||
case 'node': {
|
||||
addNode(splittedPrimaryCommand[3], secondaryCommand)
|
||||
return
|
||||
}
|
||||
case 'concept': {
|
||||
addConcept(splittedPrimaryCommand[3], secondaryCommand)
|
||||
return
|
||||
}
|
||||
case 'topic': {
|
||||
let splittedSecondaryCommand = secondaryCommand.split('->')
|
||||
if (splittedSecondaryCommand.length < 2) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Too Few Parameters', 'Anchor Too Few Parameters')
|
||||
return
|
||||
}
|
||||
addTopic(splittedPrimaryCommand[3], splittedSecondaryCommand[0], splittedSecondaryCommand[1], splittedSecondaryCommand[2])
|
||||
return
|
||||
}
|
||||
case 'tutorial': {
|
||||
let splittedSecondaryCommand = secondaryCommand.split('->')
|
||||
if (splittedSecondaryCommand.length < 2) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Too Few Parameters', 'Anchor Too Few Parameters')
|
||||
return
|
||||
}
|
||||
addTutorial(splittedPrimaryCommand[3], splittedSecondaryCommand[0], splittedSecondaryCommand[1], splittedSecondaryCommand[2])
|
||||
return
|
||||
}
|
||||
case 'review': {
|
||||
let splittedSecondaryCommand = secondaryCommand.split('->')
|
||||
if (splittedSecondaryCommand.length < 2) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Too Few Parameters', 'Anchor Too Few Parameters')
|
||||
return
|
||||
}
|
||||
addReview(splittedPrimaryCommand[3], splittedSecondaryCommand[0], splittedSecondaryCommand[1], splittedSecondaryCommand[2])
|
||||
return
|
||||
}
|
||||
case 'book': {
|
||||
addBook(splittedPrimaryCommand[3], secondaryCommand)
|
||||
return
|
||||
}
|
||||
default: {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Category Not Valid', 'Anchor Category Not Valid')
|
||||
return
|
||||
}
|
||||
}
|
||||
return 'Not Add Command'
|
||||
}
|
||||
}
|
||||
|
||||
function checkDeleteCommand() {
|
||||
if (UI.projects.education.spaces.docsSpace.commandInterface.command.toLowerCase() === 'docs.help docs.delete') {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Delete Command')
|
||||
return
|
||||
}
|
||||
if (UI.projects.education.spaces.docsSpace.commandInterface.command.indexOf('Docs.Delete') !== 0 && UI.projects.education.spaces.docsSpace.commandInterface.command.indexOf('docs.delete') !== 0) { return 'Not Delete Command' }
|
||||
|
||||
if (UI.projects.education.spaces.docsSpace.language !== UI.projects.education.globals.docs.DEFAULT_LANGUAGE) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Only In English', 'Anchor Only In English')
|
||||
return
|
||||
}
|
||||
|
||||
let splittedCommand = UI.projects.education.spaces.docsSpace.commandInterface.command.split(': ')
|
||||
if (splittedCommand[1] === undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Missing Colon', 'Anchor Missing Colon')
|
||||
return
|
||||
}
|
||||
let primaryCommand = splittedCommand[0]
|
||||
let secondaryCommand = splittedCommand[1]
|
||||
|
||||
let splittedPrimaryCommand = primaryCommand.split(' ')
|
||||
|
||||
if (splittedPrimaryCommand[0].toLowerCase() === 'docs.delete') {
|
||||
if (splittedPrimaryCommand[2] !== 'from') {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Missing From', 'Anchor Missing From')
|
||||
return
|
||||
}
|
||||
|
||||
if (splittedPrimaryCommand.length < 4) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Too Few Parameters', 'Anchor Too Few Parameters')
|
||||
return
|
||||
}
|
||||
|
||||
if (secondaryCommand === '') {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Category Not Valid', 'Anchor Category Not Valid')
|
||||
return
|
||||
}
|
||||
|
||||
switch (splittedPrimaryCommand[1].toLowerCase()) {
|
||||
case 'node': {
|
||||
deleteNode(splittedPrimaryCommand[3], secondaryCommand)
|
||||
return
|
||||
}
|
||||
case 'concept': {
|
||||
deleteConcept(splittedPrimaryCommand[3], secondaryCommand)
|
||||
return
|
||||
}
|
||||
case 'topic': {
|
||||
let splittedSecondaryCommand = secondaryCommand.split('->')
|
||||
if (splittedSecondaryCommand.length < 3) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Too Few Parameters', 'Anchor Too Few Parameters')
|
||||
return
|
||||
}
|
||||
deleteTopic(splittedPrimaryCommand[3], splittedSecondaryCommand[0], splittedSecondaryCommand[1], splittedSecondaryCommand[2])
|
||||
return
|
||||
}
|
||||
case 'tutorial': {
|
||||
let splittedSecondaryCommand = secondaryCommand.split('->')
|
||||
if (splittedSecondaryCommand.length < 3) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Too Few Parameters', 'Anchor Too Few Parameters')
|
||||
return
|
||||
}
|
||||
deleteTutorial(splittedPrimaryCommand[3], splittedSecondaryCommand[0], splittedSecondaryCommand[1], splittedSecondaryCommand[2])
|
||||
return
|
||||
}
|
||||
case 'review': {
|
||||
let splittedSecondaryCommand = secondaryCommand.split('->')
|
||||
if (splittedSecondaryCommand.length < 3) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Too Few Parameters', 'Anchor Too Few Parameters')
|
||||
return
|
||||
}
|
||||
deleteReview(splittedPrimaryCommand[3], splittedSecondaryCommand[0], splittedSecondaryCommand[1], splittedSecondaryCommand[2])
|
||||
return
|
||||
}
|
||||
case 'book': {
|
||||
deleteBook(splittedPrimaryCommand[3], secondaryCommand)
|
||||
return
|
||||
}
|
||||
default: {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Category Not Valid', 'Anchor Category Not Valid')
|
||||
return
|
||||
}
|
||||
}
|
||||
return 'Not Delete Command'
|
||||
}
|
||||
}
|
||||
|
||||
function checkRepaginateCommand() {
|
||||
if (UI.projects.education.spaces.docsSpace.commandInterface.command.toLowerCase() === 'docs.help docs.repaginate') {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Repaginate Command')
|
||||
return
|
||||
}
|
||||
if (UI.projects.education.spaces.docsSpace.commandInterface.command.indexOf('Docs.Repaginate') !== 0 && UI.projects.education.spaces.docsSpace.commandInterface.command.indexOf('docs.repaginate') !== 0) { return 'Not Repaginate Command' }
|
||||
|
||||
let splittedCommand = UI.projects.education.spaces.docsSpace.commandInterface.command.split(': ')
|
||||
if (splittedCommand[1] === undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Missing Colon', 'Anchor Missing Colon')
|
||||
return
|
||||
}
|
||||
let primaryCommand = splittedCommand[0]
|
||||
let secondaryCommand = splittedCommand[1]
|
||||
|
||||
let splittedPrimaryCommand = primaryCommand.split(' ')
|
||||
|
||||
if (splittedPrimaryCommand[0].toLowerCase() === 'docs.repaginate') {
|
||||
if (splittedPrimaryCommand[2] !== 'from') {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Missing From', 'Anchor Missing From')
|
||||
return
|
||||
}
|
||||
|
||||
if (splittedPrimaryCommand.length < 4) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Too Few Parameters', 'Anchor Too Few Parameters')
|
||||
return
|
||||
}
|
||||
|
||||
if (secondaryCommand === '') {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Category Not Valid', 'Anchor Category Not Valid')
|
||||
return
|
||||
}
|
||||
|
||||
switch (splittedPrimaryCommand[1].toLowerCase()) {
|
||||
case 'node': {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Category Not Valid', 'Anchor Category Not Valid')
|
||||
return
|
||||
}
|
||||
case 'concept': {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Category Not Valid', 'Anchor Category Not Valid')
|
||||
return
|
||||
}
|
||||
case 'topic': {
|
||||
repaginate(splittedPrimaryCommand[3], 'Topic', secondaryCommand)
|
||||
return
|
||||
}
|
||||
case 'tutorial': {
|
||||
repaginate(splittedPrimaryCommand[3], 'Tutorial', secondaryCommand)
|
||||
return
|
||||
}
|
||||
case 'review': {
|
||||
repaginate(splittedPrimaryCommand[3], 'Review', secondaryCommand)
|
||||
return
|
||||
}
|
||||
case 'book': {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Category Not Valid', 'Anchor Category Not Valid')
|
||||
return
|
||||
}
|
||||
default: {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Category Not Valid', 'Anchor Category Not Valid')
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkUReIndexCommand() {
|
||||
if (UI.projects.education.spaces.docsSpace.commandInterface.command.toLowerCase() === 'docs.help docs.reindex') {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Reindex Command')
|
||||
return
|
||||
}
|
||||
if (UI.projects.education.spaces.docsSpace.commandInterface.command.indexOf('Docs.Reindex') !== 0 && UI.projects.education.spaces.docsSpace.commandInterface.command.indexOf('docs.reindex') !== 0) { return 'Not Reindex Command' }
|
||||
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Message - Reindexing Started')
|
||||
setTimeout(startReindexingProcess, 100)
|
||||
|
||||
function startReindexingProcess() {
|
||||
UI.projects.education.spaces.docsSpace.searchEngine.setUpSearchEngine(onFinish)
|
||||
|
||||
function onFinish() {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Message - Reindexing Done')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function checkUSaveCommand() {
|
||||
if (UI.projects.education.spaces.docsSpace.commandInterface.command.toLowerCase() === 'docs.help docs.save') {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Save Command')
|
||||
return
|
||||
}
|
||||
if (UI.projects.education.spaces.docsSpace.commandInterface.command.indexOf('Docs.Save') !== 0 && UI.projects.education.spaces.docsSpace.commandInterface.command.indexOf('docs.save') !== 0) { return 'Not Save Command' }
|
||||
|
||||
let requestsSent = 0
|
||||
let responseCount = 0
|
||||
let okResponses = 0
|
||||
for (let j = 0; j < PROJECTS_SCHEMA.length; j++) {
|
||||
let docsSchema
|
||||
let project = PROJECTS_SCHEMA[j].name
|
||||
|
||||
docsSchema = SCHEMAS_BY_PROJECT.get(project).array.docsNodeSchema
|
||||
httpRequest(JSON.stringify(docsSchema), 'Docs/Save-Node-Schema/' + project, onResponse)
|
||||
requestsSent++
|
||||
|
||||
docsSchema = SCHEMAS_BY_PROJECT.get(project).array.docsConceptSchema
|
||||
httpRequest(JSON.stringify(docsSchema), 'Docs/Save-Concept-Schema/' + project, onResponse)
|
||||
requestsSent++
|
||||
|
||||
docsSchema = SCHEMAS_BY_PROJECT.get(project).array.docsTopicSchema
|
||||
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.docsReviewSchema
|
||||
httpRequest(JSON.stringify(docsSchema), 'Docs/Save-Review-Schema/' + project, onResponse)
|
||||
requestsSent++
|
||||
|
||||
docsSchema = SCHEMAS_BY_PROJECT.get(project).array.docsBookSchema
|
||||
httpRequest(JSON.stringify(docsSchema), 'Docs/Save-Book-Schema/' + project, onResponse)
|
||||
requestsSent++
|
||||
}
|
||||
|
||||
function onResponse(err, data) {
|
||||
/* Lets check the result of the call through the http interface */
|
||||
data = JSON.parse(data)
|
||||
if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result && data.result === GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
okResponses++
|
||||
}
|
||||
responseCount++
|
||||
|
||||
if (responseCount === requestsSent) {
|
||||
if (responseCount === okResponses) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Message - Saving Done')
|
||||
afterSaving()
|
||||
} else {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Changes Not Saved', 'Anchor Changes Not Saved')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function afterSaving() {
|
||||
/*
|
||||
Since all the changes where saved, we need to remove the change flags at the different shcema documents.
|
||||
We also need to remove from the arrays the deleted items.
|
||||
*/
|
||||
for (let j = 0; j < PROJECTS_SCHEMA.length; j++) {
|
||||
let project = PROJECTS_SCHEMA[j].name
|
||||
let documents
|
||||
|
||||
/* Nodes */
|
||||
documents = []
|
||||
for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.docsNodeSchema.length; i++) {
|
||||
docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).array.docsNodeSchema[i]
|
||||
docsSchemaDocument.updated = undefined
|
||||
docsSchemaDocument.created = undefined
|
||||
|
||||
if (docsSchemaDocument.deleted === true) {
|
||||
SCHEMAS_BY_PROJECT.get(project).map.docsNodeSchema.delete(docsSchemaDocument.type)
|
||||
} else {
|
||||
documents.push(docsSchemaDocument)
|
||||
}
|
||||
}
|
||||
SCHEMAS_BY_PROJECT.get(project).array.docsNodeSchema = documents
|
||||
|
||||
/* Concepts */
|
||||
documents = []
|
||||
for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.docsConceptSchema.length; i++) {
|
||||
docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).array.docsConceptSchema[i]
|
||||
docsSchemaDocument.updated = undefined
|
||||
docsSchemaDocument.created = undefined
|
||||
|
||||
if (docsSchemaDocument.deleted === true) {
|
||||
SCHEMAS_BY_PROJECT.get(project).map.docsConceptSchema.delete(docsSchemaDocument.type)
|
||||
} else {
|
||||
documents.push(docsSchemaDocument)
|
||||
}
|
||||
}
|
||||
SCHEMAS_BY_PROJECT.get(project).array.docsConceptSchema = documents
|
||||
|
||||
/* Topics */
|
||||
documents = []
|
||||
for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.docsTopicSchema.length; i++) {
|
||||
docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).array.docsTopicSchema[i]
|
||||
docsSchemaDocument.updated = undefined
|
||||
docsSchemaDocument.created = undefined
|
||||
|
||||
if (docsSchemaDocument.deleted === true) {
|
||||
SCHEMAS_BY_PROJECT.get(project).map.docsTopicSchema.delete(docsSchemaDocument.type)
|
||||
} else {
|
||||
documents.push(docsSchemaDocument)
|
||||
}
|
||||
}
|
||||
SCHEMAS_BY_PROJECT.get(project).array.docsTopicSchema = documents
|
||||
|
||||
/* Tutorials */
|
||||
documents = []
|
||||
for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.docsTutorialSchema.length; i++) {
|
||||
docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).array.docsTutorialSchema[i]
|
||||
docsSchemaDocument.updated = undefined
|
||||
docsSchemaDocument.created = undefined
|
||||
|
||||
if (docsSchemaDocument.deleted === true) {
|
||||
SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema.delete(docsSchemaDocument.type)
|
||||
} else {
|
||||
documents.push(docsSchemaDocument)
|
||||
}
|
||||
}
|
||||
SCHEMAS_BY_PROJECT.get(project).array.docsTutorialSchema = documents
|
||||
|
||||
/* Reviews */
|
||||
documents = []
|
||||
for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.docsReviewSchema.length; i++) {
|
||||
docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).array.docsReviewSchema[i]
|
||||
docsSchemaDocument.updated = undefined
|
||||
docsSchemaDocument.created = undefined
|
||||
|
||||
if (docsSchemaDocument.deleted === true) {
|
||||
SCHEMAS_BY_PROJECT.get(project).map.docsReviewSchema.delete(docsSchemaDocument.type)
|
||||
} else {
|
||||
documents.push(docsSchemaDocument)
|
||||
}
|
||||
}
|
||||
SCHEMAS_BY_PROJECT.get(project).array.docsReviewSchema = documents
|
||||
|
||||
/* Books */
|
||||
documents = []
|
||||
for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.docsBookSchema.length; i++) {
|
||||
docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).array.docsBookSchema[i]
|
||||
docsSchemaDocument.updated = undefined
|
||||
docsSchemaDocument.created = undefined
|
||||
|
||||
if (docsSchemaDocument.deleted === true) {
|
||||
SCHEMAS_BY_PROJECT.get(project).map.docsBookSchema.delete(docsSchemaDocument.type)
|
||||
} else {
|
||||
documents.push(docsSchemaDocument)
|
||||
}
|
||||
}
|
||||
SCHEMAS_BY_PROJECT.get(project).array.docsBookSchema = documents
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function repaginate(project, category, query) {
|
||||
if (SCHEMAS_BY_PROJECT.get(project) === undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Project Does Not Exist', 'Anchor Project Does Not Exist')
|
||||
return
|
||||
}
|
||||
|
||||
let orderedArray = UI.projects.education.utilities.docs.buildOrderedPageIndex(
|
||||
project,
|
||||
category,
|
||||
query
|
||||
)
|
||||
|
||||
if (orderedArray.length === 0) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'No Matching Topic, Tutorial or Review Found')
|
||||
return
|
||||
}
|
||||
|
||||
let pageNumber = 1
|
||||
for (let i = 0; i < orderedArray.length; i++) {
|
||||
schemaDocument = orderedArray[i]
|
||||
schemaDocument.pageNumber = pageNumber
|
||||
pageNumber++
|
||||
schemaDocument.updated = true
|
||||
}
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Message - Repagination Done')
|
||||
}
|
||||
|
||||
function addNode(project, type) {
|
||||
let template = {
|
||||
created: true,
|
||||
type: type,
|
||||
definition: { text: "Write a definition for this Node." },
|
||||
paragraphs: [
|
||||
{
|
||||
style: "Text",
|
||||
text: UI.projects.education.globals.docs.NEW_PARAGRAPH_TEXT
|
||||
}
|
||||
]
|
||||
}
|
||||
if (SCHEMAS_BY_PROJECT.get(project) === undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Project Does Not Exist', 'Anchor Project Does Not Exist')
|
||||
return
|
||||
}
|
||||
let exist = SCHEMAS_BY_PROJECT.get(project).map.docsNodeSchema.get(type)
|
||||
if (exist !== undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Page Already Exists', 'Anchor Page Already Exists')
|
||||
return
|
||||
}
|
||||
|
||||
SCHEMAS_BY_PROJECT.get(project).array.docsNodeSchema.push(template)
|
||||
SCHEMAS_BY_PROJECT.get(project).map.docsNodeSchema.set(type, template)
|
||||
UI.projects.education.spaces.docsSpace.navigateTo(project, 'Node', type)
|
||||
}
|
||||
|
||||
function addConcept(project, type) {
|
||||
let template = {
|
||||
created: true,
|
||||
type: type,
|
||||
definition: { text: "Write a summary / definition for this Concept." },
|
||||
paragraphs: [
|
||||
{
|
||||
style: "Text",
|
||||
text: UI.projects.education.globals.docs.NEW_PARAGRAPH_TEXT
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
if (SCHEMAS_BY_PROJECT.get(project) === undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Project Does Not Exist', 'Anchor Project Does Not Exist')
|
||||
return
|
||||
}
|
||||
let exist = SCHEMAS_BY_PROJECT.get(project).map.docsConceptSchema.get(type)
|
||||
if (exist !== undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Page Already Exists', 'Anchor Page Already Exists')
|
||||
return
|
||||
}
|
||||
|
||||
SCHEMAS_BY_PROJECT.get(project).array.docsConceptSchema.push(template)
|
||||
SCHEMAS_BY_PROJECT.get(project).map.docsConceptSchema.set(type, template)
|
||||
UI.projects.education.spaces.docsSpace.navigateTo(project, 'Concept', type)
|
||||
}
|
||||
|
||||
function addTopic(project, topic, type, pageNumber) {
|
||||
if (pageNumber === undefined) {
|
||||
|
||||
let orderedArray = UI.projects.education.utilities.docs.buildOrderedPageIndex(
|
||||
project,
|
||||
'Topic',
|
||||
topic
|
||||
)
|
||||
|
||||
pageNumber = orderedArray.length + 1
|
||||
}
|
||||
|
||||
let template = {
|
||||
created: true,
|
||||
topic: topic,
|
||||
pageNumber: pageNumber,
|
||||
type: type,
|
||||
definition: { text: "Write a summary for this topic page." },
|
||||
paragraphs: [
|
||||
{
|
||||
style: "Text",
|
||||
text: UI.projects.education.globals.docs.NEW_PARAGRAPH_TEXT
|
||||
}
|
||||
]
|
||||
}
|
||||
if (SCHEMAS_BY_PROJECT.get(project) === undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Project Does Not Exist', 'Anchor Project Does Not Exist')
|
||||
return
|
||||
}
|
||||
let exist = SCHEMAS_BY_PROJECT.get(project).map.docsTopicSchema.get(type)
|
||||
if (exist !== undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Page Already Exists', 'Anchor Page Already Exists')
|
||||
return
|
||||
}
|
||||
|
||||
SCHEMAS_BY_PROJECT.get(project).array.docsTopicSchema.push(template)
|
||||
SCHEMAS_BY_PROJECT.get(project).map.docsTopicSchema.set(type, template)
|
||||
UI.projects.education.spaces.docsSpace.navigateTo(project, 'Topic', type)
|
||||
}
|
||||
|
||||
function addTutorial(project, tutorial, type, pageNumber) {
|
||||
if (pageNumber === undefined) {
|
||||
|
||||
let orderedArray = UI.projects.education.utilities.docs.buildOrderedPageIndex(
|
||||
project,
|
||||
'Tutorial',
|
||||
tutorial
|
||||
)
|
||||
|
||||
pageNumber = orderedArray.length + 1
|
||||
}
|
||||
|
||||
let template = {
|
||||
created: true,
|
||||
tutorial: tutorial,
|
||||
pageNumber: pageNumber,
|
||||
type: type,
|
||||
definition: { text: "Write a summary for this tutorial page." },
|
||||
paragraphs: [
|
||||
{
|
||||
style: "Text",
|
||||
text: UI.projects.education.globals.docs.NEW_PARAGRAPH_TEXT
|
||||
}
|
||||
]
|
||||
}
|
||||
if (SCHEMAS_BY_PROJECT.get(project) === undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', '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.education.spaces.docsSpace.navigateTo('Foundations', '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.education.spaces.docsSpace.navigateTo(project, 'Tutorial', type)
|
||||
}
|
||||
|
||||
function addReview(project, review, type, pageNumber) {
|
||||
if (pageNumber === undefined) {
|
||||
|
||||
let orderedArray = UI.projects.education.utilities.docs.buildOrderedPageIndex(
|
||||
project,
|
||||
'Review',
|
||||
review
|
||||
)
|
||||
|
||||
pageNumber = orderedArray.length + 1
|
||||
}
|
||||
|
||||
let template = {
|
||||
created: true,
|
||||
review: review,
|
||||
pageNumber: pageNumber,
|
||||
type: type,
|
||||
definition: { text: "Write a summary for this review page." },
|
||||
paragraphs: [
|
||||
{
|
||||
style: "Text",
|
||||
text: UI.projects.education.globals.docs.NEW_PARAGRAPH_TEXT
|
||||
}
|
||||
]
|
||||
}
|
||||
if (SCHEMAS_BY_PROJECT.get(project) === undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Project Does Not Exist', 'Anchor Project Does Not Exist')
|
||||
return
|
||||
}
|
||||
let exist = SCHEMAS_BY_PROJECT.get(project).map.docsReviewSchema.get(type)
|
||||
if (exist !== undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Page Already Exists', 'Anchor Page Already Exists')
|
||||
return
|
||||
}
|
||||
|
||||
SCHEMAS_BY_PROJECT.get(project).array.docsReviewSchema.push(template)
|
||||
SCHEMAS_BY_PROJECT.get(project).map.docsReviewSchema.set(type, template)
|
||||
UI.projects.education.spaces.docsSpace.navigateTo(project, 'Review', type)
|
||||
}
|
||||
|
||||
function addBook(project, type) {
|
||||
let template = {
|
||||
created: true,
|
||||
type: type,
|
||||
definition: { text: "Write a summary / definition for this Book." },
|
||||
paragraphs: [
|
||||
{
|
||||
style: "Text",
|
||||
text: UI.projects.education.globals.docs.NEW_PARAGRAPH_TEXT
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
if (SCHEMAS_BY_PROJECT.get(project) === undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Project Does Not Exist', 'Anchor Project Does Not Exist')
|
||||
return
|
||||
}
|
||||
let exist = SCHEMAS_BY_PROJECT.get(project).map.docsBookSchema.get(type)
|
||||
if (exist !== undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Page Already Exists', 'Anchor Page Already Exists')
|
||||
return
|
||||
}
|
||||
|
||||
SCHEMAS_BY_PROJECT.get(project).array.docsBookSchema.push(template)
|
||||
SCHEMAS_BY_PROJECT.get(project).map.docsBookSchema.set(type, template)
|
||||
UI.projects.education.spaces.docsSpace.navigateTo(project, 'Book', type)
|
||||
}
|
||||
|
||||
function deleteNode(project, type) {
|
||||
if (SCHEMAS_BY_PROJECT.get(project) === undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Project Does Not Exist', 'Anchor Project Does Not Exist')
|
||||
return
|
||||
}
|
||||
let exist = SCHEMAS_BY_PROJECT.get(project).map.docsNodeSchema.get(type)
|
||||
if (exist === undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Page Does Not Exist', 'Anchor Page Does Not Exist')
|
||||
return
|
||||
}
|
||||
|
||||
let schemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsNodeSchema.get(type)
|
||||
schemaDocument.deleted = true
|
||||
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Message - Deleting Done')
|
||||
}
|
||||
|
||||
function deleteConcept(project, type) {
|
||||
if (SCHEMAS_BY_PROJECT.get(project) === undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Project Does Not Exist', 'Anchor Project Does Not Exist')
|
||||
return
|
||||
}
|
||||
let exist = SCHEMAS_BY_PROJECT.get(project).map.docsConceptSchema.get(type)
|
||||
if (exist === undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Page Does Not Exist', 'Anchor Page Does Not Exist')
|
||||
return
|
||||
}
|
||||
|
||||
let schemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsConceptSchema.get(type)
|
||||
schemaDocument.deleted = true
|
||||
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Message - Deleting Done')
|
||||
}
|
||||
|
||||
function deleteTopic(project, topic, type, pageNumber) {
|
||||
if (SCHEMAS_BY_PROJECT.get(project) === undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Project Does Not Exist', 'Anchor Project Does Not Exist')
|
||||
return
|
||||
}
|
||||
let exist = SCHEMAS_BY_PROJECT.get(project).map.docsTopicSchema.get(type)
|
||||
if (exist === undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Page Does Not Exist', 'Anchor Page Does Not Exist')
|
||||
return
|
||||
} else {
|
||||
if (exist.pageNumber !== pageNumber) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Page Number Mismatch', 'Anchor Page Number Mismatch')
|
||||
return
|
||||
}
|
||||
if (exist.topic !== topic) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Topic Mismatch', 'Anchor Topic Mismatch')
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
let schemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsTopicSchema.get(type)
|
||||
schemaDocument.deleted = true
|
||||
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Message - Deleting Done')
|
||||
}
|
||||
|
||||
function deleteTutorial(project, tutorial, type, pageNumber) {
|
||||
if (SCHEMAS_BY_PROJECT.get(project) === undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', '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.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Page Does Not Exist', 'Anchor Page Does Not Exist')
|
||||
return
|
||||
} else {
|
||||
if (exist.pageNumber !== pageNumber) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Page Number Mismatch', 'Anchor Page Number Mismatch')
|
||||
return
|
||||
}
|
||||
if (exist.tutorial !== tutorial) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Tutorial Mismatch', 'Anchor Tutorial Mismatch')
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
let schemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema.get(type)
|
||||
schemaDocument.deleted = true
|
||||
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Message - Deleting Done')
|
||||
}
|
||||
|
||||
function deleteReview(project, review, type, pageNumber) {
|
||||
if (SCHEMAS_BY_PROJECT.get(project) === undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Project Does Not Exist', 'Anchor Project Does Not Exist')
|
||||
return
|
||||
}
|
||||
let exist = SCHEMAS_BY_PROJECT.get(project).map.docsReviewSchema.get(type)
|
||||
if (exist === undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Page Does Not Exist', 'Anchor Page Does Not Exist')
|
||||
return
|
||||
} else {
|
||||
if (exist.pageNumber !== pageNumber) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Page Number Mismatch', 'Anchor Page Number Mismatch')
|
||||
return
|
||||
}
|
||||
if (exist.review !== review) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Review Mismatch', 'Anchor Review Mismatch')
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
let schemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsReviewSchema.get(type)
|
||||
schemaDocument.deleted = true
|
||||
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Message - Deleting Done')
|
||||
}
|
||||
|
||||
function deleteBook(project, type) {
|
||||
if (SCHEMAS_BY_PROJECT.get(project) === undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Project Does Not Exist', 'Anchor Project Does Not Exist')
|
||||
return
|
||||
}
|
||||
let exist = SCHEMAS_BY_PROJECT.get(project).map.docsBookSchema.get(type)
|
||||
if (exist === undefined) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Error - Page Does Not Exist', 'Anchor Page Does Not Exist')
|
||||
return
|
||||
}
|
||||
|
||||
let schemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsBookSchema.get(type)
|
||||
schemaDocument.deleted = true
|
||||
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs Message - Deleting Done')
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,460 @@
|
||||
function newFoundationsDocsContextMenu() {
|
||||
let thisObject = {
|
||||
selectedParagraph: undefined,
|
||||
getSelection: getSelection,
|
||||
removeContextMenuFromScreen: removeContextMenuFromScreen,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
let selectedParagraphData = ''
|
||||
let selectedParagraphIndex = ''
|
||||
let selectedParagraphHeight = 0
|
||||
|
||||
return thisObject
|
||||
|
||||
function initialize() {
|
||||
setUpContextMenu()
|
||||
}
|
||||
|
||||
function finalize() {
|
||||
|
||||
}
|
||||
|
||||
function setUpContextMenu() {
|
||||
window.contextMenu = {
|
||||
editParagraph: editParagraph,
|
||||
deleteParagraph: deleteParagraph,
|
||||
toJavascript: toJavascript,
|
||||
toJson: toJson,
|
||||
toText: toText,
|
||||
toTitle: toTitle,
|
||||
toSubtitle: toSubtitle,
|
||||
toNote: toNote,
|
||||
toWarning: toWarning,
|
||||
toError: toError,
|
||||
toImportant: toImportant,
|
||||
toSuccess: toSuccess,
|
||||
toCallout: toCallout,
|
||||
toSummary: toSummary,
|
||||
toList: toList,
|
||||
toTable: toTable,
|
||||
toHierarchy: toHierarchy,
|
||||
toGif: toGif,
|
||||
toPng: toPng,
|
||||
toAnchor: toAnchor,
|
||||
toBlock: toBlock,
|
||||
toInclude: toInclude,
|
||||
toPlaceholder: toPlaceholder,
|
||||
toChapter: toChapter,
|
||||
toSection: toSection,
|
||||
copyLink: copyLink,
|
||||
toWebPageLink: toWebPageLink,
|
||||
toYouTubeVideo: toYouTubeVideo
|
||||
}
|
||||
|
||||
function editParagraph() {
|
||||
removeContextMenuFromScreen()
|
||||
showHTMLTextArea()
|
||||
|
||||
function showHTMLTextArea() {
|
||||
if (UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph === undefined) { return }
|
||||
|
||||
/*
|
||||
When in editing mode, some type of paragraphs need to extend
|
||||
the text area style so that while editing, it looks and feel
|
||||
like the non editing style of the paragraph. For those we
|
||||
add an extra style class.
|
||||
*/
|
||||
let extraClassName = ''
|
||||
if (UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id.indexOf('definition') >= 0) {
|
||||
extraClassName = ' ' + ''
|
||||
}
|
||||
if (UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id.indexOf('title') >= 0) {
|
||||
extraClassName = ' ' + 'docs-h3'
|
||||
}
|
||||
if (UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id.indexOf('subtitle') >= 0) {
|
||||
extraClassName = ' ' + 'docs-h4'
|
||||
}
|
||||
if (UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id.indexOf('note') >= 0) {
|
||||
extraClassName = ' ' + 'docs-alert-note'
|
||||
}
|
||||
if (UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id.indexOf('success') >= 0) {
|
||||
extraClassName = ' ' + 'docs-alert-success'
|
||||
}
|
||||
if (UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id.indexOf('important') >= 0) {
|
||||
extraClassName = ' ' + 'docs-alert-important'
|
||||
}
|
||||
if (UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id.indexOf('warning') >= 0) {
|
||||
extraClassName = ' ' + 'docs-alert-warning'
|
||||
}
|
||||
if (UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id.indexOf('error') >= 0) {
|
||||
extraClassName = ' ' + 'docs-alert-error'
|
||||
}
|
||||
if (UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id.indexOf('javascript') >= 0) {
|
||||
extraClassName = ' ' + 'language-javascript'
|
||||
}
|
||||
if (UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id.indexOf('json') >= 0) {
|
||||
extraClassName = ' ' + 'language-json'
|
||||
}
|
||||
|
||||
UI.projects.education.spaces.docsSpace.textArea = document.createElement('textarea');
|
||||
UI.projects.education.spaces.docsSpace.textArea.id = "UI.projects.education.spaces.docsSpace.textArea";
|
||||
UI.projects.education.spaces.docsSpace.textArea.spellcheck = false;
|
||||
UI.projects.education.spaces.docsSpace.textArea.className = "docs-text-area" + extraClassName
|
||||
UI.projects.education.spaces.docsSpace.textArea.style.height = selectedParagraphHeight
|
||||
UI.projects.education.spaces.docsSpace.textArea.value = selectedParagraphData
|
||||
UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.innerHTML = ""
|
||||
UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.appendChild(UI.projects.education.spaces.docsSpace.textArea)
|
||||
UI.projects.education.spaces.docsSpace.textArea.style.display = 'block'
|
||||
UI.projects.education.spaces.docsSpace.textArea.focus()
|
||||
removeContextMenuFromScreen()
|
||||
UI.projects.education.spaces.docsSpace.enterEditMode()
|
||||
}
|
||||
}
|
||||
|
||||
function deleteParagraph() {
|
||||
if (selectedParagraphIndex === undefined) { return }
|
||||
if (selectedParagraphIndex === 0) { return }
|
||||
UI.projects.education.spaces.docsSpace.documentPage.docsSchemaDocument.paragraphs.splice(selectedParagraphIndex, 1)
|
||||
removeContextMenuFromScreen()
|
||||
UI.projects.education.spaces.docsSpace.documentPage.docsSchemaDocument.updated = true
|
||||
UI.projects.education.spaces.docsSpace.documentPage.render()
|
||||
}
|
||||
|
||||
function toJavascript() {
|
||||
let docSchemaParagraph = UI.projects.education.spaces.docsSpace.paragraphMap.get(UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id)
|
||||
replaceStyle(docSchemaParagraph, 'Javascript')
|
||||
}
|
||||
|
||||
function toJson() {
|
||||
let docSchemaParagraph = UI.projects.education.spaces.docsSpace.paragraphMap.get(UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id)
|
||||
replaceStyle(docSchemaParagraph, 'Json')
|
||||
}
|
||||
|
||||
function toText() {
|
||||
let docSchemaParagraph = UI.projects.education.spaces.docsSpace.paragraphMap.get(UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id)
|
||||
replaceStyle(docSchemaParagraph, 'Text')
|
||||
}
|
||||
|
||||
function toTitle() {
|
||||
let docSchemaParagraph = UI.projects.education.spaces.docsSpace.paragraphMap.get(UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id)
|
||||
replaceStyle(docSchemaParagraph, 'Title')
|
||||
}
|
||||
|
||||
function toSubtitle() {
|
||||
let docSchemaParagraph = UI.projects.education.spaces.docsSpace.paragraphMap.get(UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id)
|
||||
replaceStyle(docSchemaParagraph, 'Subtitle')
|
||||
}
|
||||
|
||||
function toNote() {
|
||||
let docSchemaParagraph = UI.projects.education.spaces.docsSpace.paragraphMap.get(UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id)
|
||||
replaceStyle(docSchemaParagraph, 'Note')
|
||||
}
|
||||
|
||||
function toWarning() {
|
||||
let docSchemaParagraph = UI.projects.education.spaces.docsSpace.paragraphMap.get(UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id)
|
||||
replaceStyle(docSchemaParagraph, 'Warning')
|
||||
}
|
||||
|
||||
function toError() {
|
||||
let docSchemaParagraph = UI.projects.education.spaces.docsSpace.paragraphMap.get(UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id)
|
||||
replaceStyle(docSchemaParagraph, 'Error')
|
||||
}
|
||||
|
||||
function toImportant() {
|
||||
let docSchemaParagraph = UI.projects.education.spaces.docsSpace.paragraphMap.get(UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id)
|
||||
replaceStyle(docSchemaParagraph, 'Important')
|
||||
}
|
||||
|
||||
function toSuccess() {
|
||||
let docSchemaParagraph = UI.projects.education.spaces.docsSpace.paragraphMap.get(UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id)
|
||||
replaceStyle(docSchemaParagraph, 'Success')
|
||||
}
|
||||
|
||||
function toCallout() {
|
||||
let docSchemaParagraph = UI.projects.education.spaces.docsSpace.paragraphMap.get(UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id)
|
||||
replaceStyle(docSchemaParagraph, 'Callout')
|
||||
}
|
||||
|
||||
function toSummary() {
|
||||
let docSchemaParagraph = UI.projects.education.spaces.docsSpace.paragraphMap.get(UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id)
|
||||
replaceStyle(docSchemaParagraph, 'Summary')
|
||||
}
|
||||
|
||||
function toSection() {
|
||||
let docSchemaParagraph = UI.projects.education.spaces.docsSpace.paragraphMap.get(UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id)
|
||||
replaceStyle(docSchemaParagraph, 'Section')
|
||||
}
|
||||
|
||||
function toList() {
|
||||
let docSchemaParagraph = UI.projects.education.spaces.docsSpace.paragraphMap.get(UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id)
|
||||
replaceStyle(docSchemaParagraph, 'List')
|
||||
}
|
||||
|
||||
function toTable() {
|
||||
let docSchemaParagraph = UI.projects.education.spaces.docsSpace.paragraphMap.get(UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id)
|
||||
replaceStyle(docSchemaParagraph, 'Table')
|
||||
}
|
||||
|
||||
function toHierarchy() {
|
||||
let docSchemaParagraph = UI.projects.education.spaces.docsSpace.paragraphMap.get(UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id)
|
||||
replaceStyle(docSchemaParagraph, 'Hierarchy')
|
||||
}
|
||||
|
||||
function toGif() {
|
||||
let docSchemaParagraph = UI.projects.education.spaces.docsSpace.paragraphMap.get(UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id)
|
||||
replaceStyle(docSchemaParagraph, 'Gif')
|
||||
}
|
||||
|
||||
function toPng() {
|
||||
let docSchemaParagraph = UI.projects.education.spaces.docsSpace.paragraphMap.get(UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id)
|
||||
replaceStyle(docSchemaParagraph, 'Png')
|
||||
}
|
||||
|
||||
function toAnchor() {
|
||||
let docSchemaParagraph = UI.projects.education.spaces.docsSpace.paragraphMap.get(UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id)
|
||||
replaceStyle(docSchemaParagraph, 'Anchor')
|
||||
}
|
||||
|
||||
function toBlock() {
|
||||
let docSchemaParagraph = UI.projects.education.spaces.docsSpace.paragraphMap.get(UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id)
|
||||
replaceStyle(docSchemaParagraph, 'Block')
|
||||
}
|
||||
|
||||
function toInclude() {
|
||||
let docSchemaParagraph = UI.projects.education.spaces.docsSpace.paragraphMap.get(UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id)
|
||||
replaceStyle(docSchemaParagraph, 'Include')
|
||||
}
|
||||
|
||||
function toPlaceholder() {
|
||||
let docSchemaParagraph = UI.projects.education.spaces.docsSpace.paragraphMap.get(UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id)
|
||||
replaceStyle(docSchemaParagraph, 'Placeholder')
|
||||
}
|
||||
|
||||
function toChapter() {
|
||||
let docSchemaParagraph = UI.projects.education.spaces.docsSpace.paragraphMap.get(UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id)
|
||||
replaceStyle(docSchemaParagraph, 'Chapter')
|
||||
}
|
||||
|
||||
function toWebPageLink() {
|
||||
let docSchemaParagraph = UI.projects.education.spaces.docsSpace.paragraphMap.get(UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id)
|
||||
replaceStyle(docSchemaParagraph, 'Link')
|
||||
}
|
||||
|
||||
function toYouTubeVideo() {
|
||||
let docSchemaParagraph = UI.projects.education.spaces.docsSpace.paragraphMap.get(UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id)
|
||||
replaceStyle(docSchemaParagraph, 'Youtube')
|
||||
}
|
||||
|
||||
function copyLink() {
|
||||
let docSchemaParagraph = UI.projects.education.spaces.docsSpace.paragraphMap.get(UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph.id)
|
||||
let clipboard
|
||||
switch (docSchemaParagraph.style) {
|
||||
case 'Anchor': {
|
||||
clipboard = "docs.goto " + UI.projects.education.spaces.docsSpace.currentDocumentBeingRendered.project + '->' + UI.projects.education.spaces.docsSpace.currentDocumentBeingRendered.category + '->' + UI.projects.education.spaces.docsSpace.currentDocumentBeingRendered.type + '->' + docSchemaParagraph.text
|
||||
break
|
||||
}
|
||||
case 'Block': {
|
||||
clipboard = UI.projects.education.spaces.docsSpace.currentDocumentBeingRendered.project + '->' + UI.projects.education.spaces.docsSpace.currentDocumentBeingRendered.category + '->' + UI.projects.education.spaces.docsSpace.currentDocumentBeingRendered.type + '->' + docSchemaParagraph.text
|
||||
break
|
||||
}
|
||||
default: {
|
||||
clipboard = docSchemaParagraph.text
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
UI.projects.foundations.utilities.clipboard.copyTextToClipboard(clipboard)
|
||||
removeContextMenuFromScreen()
|
||||
}
|
||||
|
||||
function replaceStyle(docSchemaParagraph, style) {
|
||||
if (docSchemaParagraph.style !== style) {
|
||||
UI.projects.education.spaces.docsSpace.documentPage.docsSchemaDocument.updated = true
|
||||
docSchemaParagraph.style = style
|
||||
removeContextMenuFromScreen()
|
||||
UI.projects.education.spaces.docsSpace.documentPage.render()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function removeContextMenuFromScreen() {
|
||||
const outClick = document.getElementById('docs-space-div')
|
||||
const menu = document.getElementById('menu')
|
||||
menu.classList.remove('show')
|
||||
outClick.style.display = "none"
|
||||
}
|
||||
|
||||
function getSelection() {
|
||||
let selection = window.getSelection()
|
||||
|
||||
/*
|
||||
We need to locate the parent node that it is a Paragraph,
|
||||
otherwise we could end up in an inner html element.
|
||||
*/
|
||||
let paragraphNode = selection.anchorNode
|
||||
|
||||
if (paragraphNode.id !== undefined && paragraphNode.parentNode.className === "docs-tooltip") {
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
for (let i = 1; i < 10; i++) {
|
||||
if (paragraphNode === undefined || paragraphNode === null) { return false }
|
||||
if (paragraphNode.id === undefined || paragraphNode.id.indexOf('editable-paragraph') < 0) {
|
||||
paragraphNode = paragraphNode.parentNode
|
||||
if (paragraphNode === undefined) { return false }
|
||||
}
|
||||
}
|
||||
if (paragraphNode === undefined || paragraphNode === null || paragraphNode.id === undefined || paragraphNode.id.indexOf('editable-paragraph') < 0) {
|
||||
return false
|
||||
}
|
||||
/*
|
||||
Get the dimenssions of the current paragraph to help us to define the dimenssions of the text area.
|
||||
*/
|
||||
UI.projects.education.spaces.docsSpace.contextMenu.selectedParagraph = paragraphNode
|
||||
selectedParagraphHeight = paragraphNode.getClientRects()[0].height
|
||||
if (selectedParagraphHeight < 30) { selectedParagraphHeight = 30 }
|
||||
/*
|
||||
We need to clean the Tool Tips text that might be at the paragraph selected.
|
||||
To not destroy the DOM structure we will use a clone.
|
||||
*/
|
||||
paragraphNode = paragraphNode.cloneNode(true)
|
||||
scanNodeChildren(paragraphNode)
|
||||
function scanNodeChildren(node) {
|
||||
if (node.childNodes === undefined) { return }
|
||||
for (let i = 0; i < node.childNodes.length; i++) {
|
||||
let childNode = node.childNodes[i]
|
||||
if (childNode.className === "docs-tooltip") {
|
||||
childNode.innerText = childNode.childNodes[0].data
|
||||
} else {
|
||||
scanNodeChildren(childNode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Reset this */
|
||||
selectedParagraphIndex = undefined
|
||||
/*
|
||||
Depending on the Style of Paragraph we will need to remove
|
||||
some info from the innerText.
|
||||
*/
|
||||
if (paragraphNode.id.indexOf('definition-') >= 0) {
|
||||
if (paragraphNode.id.indexOf('-summary') >= 0) {
|
||||
selectedParagraphData = paragraphNode.innerText.trim().substring(9, paragraphNode.innerText.length)
|
||||
} else {
|
||||
selectedParagraphData = paragraphNode.innerText.trim()
|
||||
}
|
||||
return true
|
||||
}
|
||||
/*
|
||||
Remeber the Selected Paragraph Index
|
||||
*/
|
||||
let splittedId = paragraphNode.id.split('-')
|
||||
selectedParagraphIndex = splittedId[splittedId.length - 2]
|
||||
/*
|
||||
Check the style of the Paragraph
|
||||
*/
|
||||
if (paragraphNode.id.indexOf('-text') >= 0) {
|
||||
selectedParagraphData = paragraphNode.innerText.trim()
|
||||
return true
|
||||
}
|
||||
if (paragraphNode.id.indexOf('-title') >= 0) {
|
||||
selectedParagraphData = paragraphNode.innerText.trim()
|
||||
return true
|
||||
}
|
||||
if (paragraphNode.id.indexOf('-subtitle') >= 0) {
|
||||
selectedParagraphData = paragraphNode.innerText.trim()
|
||||
return true
|
||||
}
|
||||
if (paragraphNode.id.indexOf('-note') >= 0) {
|
||||
selectedParagraphData = paragraphNode.innerText.trim().substring(6, paragraphNode.innerText.length)
|
||||
return true
|
||||
}
|
||||
if (paragraphNode.id.indexOf('-success') >= 0) {
|
||||
selectedParagraphData = paragraphNode.innerText.trim().substring(5, paragraphNode.innerText.length)
|
||||
return true
|
||||
}
|
||||
if (paragraphNode.id.indexOf('-important') >= 0) {
|
||||
selectedParagraphData = paragraphNode.innerText.trim().substring(11, paragraphNode.innerText.length)
|
||||
return true
|
||||
}
|
||||
if (paragraphNode.id.indexOf('-warning') >= 0) {
|
||||
selectedParagraphData = paragraphNode.innerText.trim().substring(9, paragraphNode.innerText.length)
|
||||
return true
|
||||
}
|
||||
if (paragraphNode.id.indexOf('-error') >= 0) {
|
||||
selectedParagraphData = paragraphNode.innerText.trim().substring(7, paragraphNode.innerText.length)
|
||||
return true
|
||||
}
|
||||
if (paragraphNode.id.indexOf('-list') >= 0) {
|
||||
selectedParagraphData = paragraphNode.innerText.trim()
|
||||
return true
|
||||
}
|
||||
if (paragraphNode.id.indexOf('-table') >= 0) {
|
||||
selectedParagraphData = UI.projects.education.utilities.docs.reverseParseTable(paragraphNode)
|
||||
return true
|
||||
}
|
||||
if (paragraphNode.id.indexOf('-hierarchy') >= 0) {
|
||||
selectedParagraphData = UI.projects.education.utilities.docs.reverseParseHierarchy(paragraphNode.innerHTML)
|
||||
return true
|
||||
}
|
||||
if (paragraphNode.id.indexOf('-gif') >= 0) {
|
||||
selectedParagraphData = UI.projects.education.utilities.docs.reverseParseGIF(paragraphNode.innerHTML)
|
||||
return true
|
||||
}
|
||||
if (paragraphNode.id.indexOf('-png') >= 0) {
|
||||
selectedParagraphData = UI.projects.education.utilities.docs.reverseParsePNG(paragraphNode.innerHTML)
|
||||
return true
|
||||
}
|
||||
if (paragraphNode.id.indexOf('-javascript') >= 0) {
|
||||
selectedParagraphData = paragraphNode.innerText.trim().substring(0, paragraphNode.innerText.length)
|
||||
return true
|
||||
}
|
||||
if (paragraphNode.id.indexOf('-json') >= 0) {
|
||||
selectedParagraphData = paragraphNode.innerText.trim().substring(0, paragraphNode.innerText.length)
|
||||
return true
|
||||
}
|
||||
if (paragraphNode.id.indexOf('-callout') >= 0) {
|
||||
selectedParagraphData = paragraphNode.innerText.trim()
|
||||
return true
|
||||
}
|
||||
if (paragraphNode.id.indexOf('-summary') >= 0) {
|
||||
selectedParagraphData = paragraphNode.innerText.trim().substring(9, paragraphNode.innerText.length)
|
||||
return true
|
||||
}
|
||||
if (paragraphNode.id.indexOf('-anchor') >= 0) {
|
||||
selectedParagraphData = paragraphNode.innerText.trim()
|
||||
return true
|
||||
}
|
||||
if (paragraphNode.id.indexOf('-section') >= 0) {
|
||||
selectedParagraphData = paragraphNode.innerText.trim()
|
||||
return true
|
||||
}
|
||||
if (paragraphNode.id.indexOf('-block') >= 0) {
|
||||
selectedParagraphData = paragraphNode.innerText.trim()
|
||||
return true
|
||||
}
|
||||
if (paragraphNode.id.indexOf('-include') >= 0) {
|
||||
selectedParagraphData = paragraphNode.innerText.trim()
|
||||
return true
|
||||
}
|
||||
if (paragraphNode.id.indexOf('-placeholder') >= 0) {
|
||||
selectedParagraphData = paragraphNode.innerText.trim()
|
||||
return true
|
||||
}
|
||||
if (paragraphNode.id.indexOf('-chapter') >= 0) {
|
||||
selectedParagraphData = paragraphNode.innerText.trim()
|
||||
return true
|
||||
}
|
||||
if (paragraphNode.id.indexOf('-link') >= 0) {
|
||||
selectedParagraphData = UI.projects.education.utilities.docs.reverseParseLink(paragraphNode.innerHTML)
|
||||
return true
|
||||
}
|
||||
if (paragraphNode.id.indexOf('-youtube') >= 0) {
|
||||
selectedParagraphData = UI.projects.education.utilities.docs.reverseParseYoutube(paragraphNode.innerHTML)
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,529 @@
|
||||
function newEducationDocSpace() {
|
||||
const MODULE_NAME = 'Doc Space'
|
||||
let thisObject = {
|
||||
isVisible: undefined,
|
||||
sidePanelTab: undefined,
|
||||
container: undefined,
|
||||
searchEngine: undefined,
|
||||
mainSearchPage: undefined,
|
||||
searchResultsPage: undefined,
|
||||
footer: undefined,
|
||||
documentPage: undefined,
|
||||
commandInterface: undefined,
|
||||
contextMenu: undefined,
|
||||
language: undefined,
|
||||
currentBranch: undefined,
|
||||
contributionsBranch: undefined,
|
||||
menuLabelsMap: undefined,
|
||||
currentDocumentBeingRendered: undefined,
|
||||
previousDocumentBeingRendered: undefined,
|
||||
currentBookBeingRendered: undefined,
|
||||
paragraphMap: undefined, // Here we will store a map of paragraphs from the Docs Node, Concept, Topics, Tutorials, Reviews or Books Schema in order to find it when we need to update them.
|
||||
textArea: undefined,
|
||||
sharePage: sharePage,
|
||||
changeLanguage: changeLanguage,
|
||||
changeCurrentBranch: changeCurrentBranch,
|
||||
changeContributionsBranch: changeContributionsBranch,
|
||||
enterEditMode: enterEditMode,
|
||||
exitEditMode: exitEditMode,
|
||||
openSpaceAreaAndNavigateTo: openSpaceAreaAndNavigateTo,
|
||||
navigateTo: navigateTo,
|
||||
searchPage: searchPage,
|
||||
scrollToElement: scrollToElement,
|
||||
physics: physics,
|
||||
draw: draw,
|
||||
getContainer: getContainer,
|
||||
initialize: initialize,
|
||||
finalize: finalize,
|
||||
reset: reset
|
||||
}
|
||||
|
||||
let isInitialized = false
|
||||
|
||||
thisObject.container = newContainer()
|
||||
thisObject.container.name = MODULE_NAME
|
||||
thisObject.container.initialize()
|
||||
thisObject.container.isClickeable = true
|
||||
thisObject.container.isDraggeable = false
|
||||
thisObject.container.detectMouseOver = true
|
||||
thisObject.container.status = 'hidden'
|
||||
|
||||
resize()
|
||||
|
||||
let browserResizedEventSubscriptionId
|
||||
let openingEventSubscriptionId
|
||||
let closingEventSubscriptionId
|
||||
|
||||
return thisObject
|
||||
|
||||
async function initialize() {
|
||||
let promise = new Promise((resolve, reject) => {
|
||||
|
||||
thisObject.menuLabelsMap = new Map()
|
||||
|
||||
setupSidePanelTab()
|
||||
setUpMenuItemsMap()
|
||||
setupUserLanguage()
|
||||
|
||||
thisObject.searchEngine = newFoundationsDocsSearchEngine()
|
||||
thisObject.mainSearchPage = newFoundationsDocsMainSearchPage()
|
||||
thisObject.searchResultsPage = newFoundationsDocsSearchResultsPage()
|
||||
thisObject.documentPage = newFoundationsDocsDocumentPage()
|
||||
thisObject.footer = newFoundationsDocsFooter()
|
||||
thisObject.commandInterface = newFoundationsDocsCommmandInterface()
|
||||
thisObject.contextMenu = newFoundationsDocsContextMenu()
|
||||
|
||||
thisObject.searchEngine.initialize()
|
||||
thisObject.mainSearchPage.initialize()
|
||||
thisObject.searchResultsPage.initialize()
|
||||
thisObject.documentPage.initialize()
|
||||
thisObject.footer.initialize()
|
||||
thisObject.commandInterface.initialize()
|
||||
thisObject.contextMenu.initialize()
|
||||
|
||||
setupCurrentBranch()
|
||||
setupContributionsBranch()
|
||||
|
||||
isInitialized = true
|
||||
|
||||
UI.projects.foundations.utilities.statusBar.changeStatus("Setting up Docs Search Engine...")
|
||||
setTimeout(setUpSearchEngine, 100)
|
||||
|
||||
function setUpSearchEngine() {
|
||||
thisObject.searchEngine.setUpSearchEngine(whenFinished)
|
||||
function whenFinished() {
|
||||
resolve()
|
||||
}
|
||||
}
|
||||
|
||||
function setupCurrentBranch() {
|
||||
/*
|
||||
Getting the currentBranch
|
||||
*/
|
||||
let workspace = UI.projects.foundations.spaces.designSpace.workspace.workspaceNode
|
||||
|
||||
httpRequest(undefined, 'App/Branch', onResponse)
|
||||
/*
|
||||
Deleting what was is here because is not longer used...
|
||||
*/
|
||||
window.localStorage.removeItem('Current Branch')
|
||||
UI.projects.foundations.utilities.nodeConfig.saveConfigProperty(workspace.payload, 'currentBranch', undefined)
|
||||
|
||||
function onResponse(err, data) {
|
||||
/* Lets check the result of the call through the http interface */
|
||||
data = JSON.parse(data)
|
||||
if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result && data.result === GLOBAL.CUSTOM_OK_RESPONSE.result) {
|
||||
let currentBranch = data.message.current
|
||||
UI.projects.education.spaces.docsSpace.currentBranch = currentBranch
|
||||
} else {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo(
|
||||
data.docs.project,
|
||||
data.docs.category,
|
||||
data.docs.type,
|
||||
data.docs.anchor,
|
||||
undefined,
|
||||
data.docs.placeholder
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setupContributionsBranch() {
|
||||
/*
|
||||
Getting the contributionsBranch
|
||||
*/
|
||||
let workspace = UI.projects.foundations.spaces.designSpace.workspace.workspaceNode
|
||||
let contributionsBranch = UI.projects.foundations.utilities.nodeConfig.loadConfigProperty(workspace.payload, 'contributionsBranch')
|
||||
|
||||
if (contributionsBranch === undefined) {
|
||||
UI.projects.foundations.utilities.nodeConfig.saveConfigProperty(workspace.payload, 'contributionsBranch', UI.projects.education.globals.docs.DEFAULT_CONTRIBUTIONS_BRANCH)
|
||||
UI.projects.education.spaces.docsSpace.contributionsBranch = UI.projects.education.globals.docs.DEFAULT_CONTRIBUTIONS_BRANCH
|
||||
} else {
|
||||
UI.projects.education.spaces.docsSpace.contributionsBranch = contributionsBranch
|
||||
}
|
||||
/*
|
||||
Every time this setup occurs, we will automatically change to the contributionsBranch of the workspace.
|
||||
*/
|
||||
changeContributionsBranch(UI.projects.education.spaces.docsSpace.contributionsBranch, true)
|
||||
/*
|
||||
Deleting what was is here because is not longer used...
|
||||
*/
|
||||
window.localStorage.removeItem('Contributions Branch')
|
||||
}
|
||||
|
||||
function setupUserLanguage() {
|
||||
/*
|
||||
Getting the used preferred languague
|
||||
*/
|
||||
let workspace = UI.projects.foundations.spaces.designSpace.workspace.workspaceNode
|
||||
let docsLanguage = UI.projects.foundations.utilities.nodeConfig.loadConfigProperty(workspace.payload, 'docsLanguage')
|
||||
|
||||
if (docsLanguage === undefined) {
|
||||
UI.projects.foundations.utilities.nodeConfig.saveConfigProperty(workspace.payload, 'docsLanguage', UI.projects.education.globals.docs.DEFAULT_LANGUAGE)
|
||||
UI.projects.education.spaces.docsSpace.language = UI.projects.education.globals.docs.DEFAULT_LANGUAGE
|
||||
} else {
|
||||
UI.projects.education.spaces.docsSpace.language = docsLanguage
|
||||
}
|
||||
/*
|
||||
Deleting what was is here because is not longer used...
|
||||
*/
|
||||
window.localStorage.removeItem('Docs Language')
|
||||
}
|
||||
|
||||
function setupSidePanelTab() {
|
||||
thisObject.sidePanelTab = UI.projects.foundations.spaces.sideSpace.createSidePanelTab(thisObject.container, 'Education', 'docs-tab', 'Docs', 'right')
|
||||
|
||||
openingEventSubscriptionId = thisObject.sidePanelTab.container.eventHandler.listenToEvent('opening', onOpening)
|
||||
closingEventSubscriptionId = thisObject.sidePanelTab.container.eventHandler.listenToEvent('closing', onClosing)
|
||||
|
||||
browserResizedEventSubscriptionId = canvas.eventHandler.listenToEvent('Browser Resized', resize)
|
||||
}
|
||||
|
||||
function setUpMenuItemsMap() {
|
||||
/*
|
||||
Here we will put put all the menu item labels of all nodes at all
|
||||
app schemas into a single map, that will allow us to know when a phrase
|
||||
is a label of a menu and then change its style.
|
||||
*/
|
||||
for (let i = 0; i < PROJECTS_SCHEMA.length; i++) {
|
||||
let project = PROJECTS_SCHEMA[i].name
|
||||
let appSchemaArray = SCHEMAS_BY_PROJECT.get(project).array.appSchema
|
||||
|
||||
for (let j = 0; j < appSchemaArray.length; j++) {
|
||||
let docsSchemaDocument = appSchemaArray[j]
|
||||
|
||||
if (docsSchemaDocument.menuItems === undefined) { continue }
|
||||
for (let k = 0; k < docsSchemaDocument.menuItems.length; k++) {
|
||||
let menuItem = docsSchemaDocument.menuItems[k]
|
||||
thisObject.menuLabelsMap.set(menuItem.label, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
return promise
|
||||
}
|
||||
|
||||
function finalize() {
|
||||
canvas.eventHandler.stopListening(browserResizedEventSubscriptionId)
|
||||
thisObject.sidePanelTab.container.eventHandler.stopListening(openingEventSubscriptionId)
|
||||
thisObject.sidePanelTab.container.eventHandler.stopListening(closingEventSubscriptionId)
|
||||
|
||||
thisObject.searchEngine.finalize()
|
||||
thisObject.mainSearchPage.finalize()
|
||||
thisObject.searchResultsPage.finalize()
|
||||
thisObject.documentPage.finalize()
|
||||
thisObject.footer.finalize()
|
||||
thisObject.commandInterface.finalize()
|
||||
thisObject.contextMenu.finalize()
|
||||
|
||||
thisObject.searchEngine = undefined
|
||||
thisObject.mainSearchPage = undefined
|
||||
thisObject.searchResultsPage = undefined
|
||||
thisObject.documentPage = undefined
|
||||
thisObject.footer = undefined
|
||||
thisObject.commandInterface = undefined
|
||||
thisObject.contextMenu = undefined
|
||||
|
||||
thisObject.currentDocumentBeingRendered = undefined
|
||||
thisObject.previousDocumentBeingRendered = undefined
|
||||
thisObject.paragraphMap = undefined
|
||||
thisObject.menuLabelsMap = undefined
|
||||
isInitialized = false
|
||||
}
|
||||
|
||||
async function reset() {
|
||||
finalize()
|
||||
await initialize()
|
||||
}
|
||||
|
||||
function changeCurrentBranch(branch, doNotNavigate) {
|
||||
httpRequest(undefined, 'App/Checkout/' + branch, onResponse)
|
||||
if (doNotNavigate !== true) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Switching Branches - Changing Current Branch')
|
||||
}
|
||||
|
||||
function onResponse(err, data) {
|
||||
/* Lets check the result of the call through the http interface */
|
||||
data = JSON.parse(data)
|
||||
if (err.result === GLOBAL.DEFAULT_OK_RESPONSE.result && data.result === GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
UI.projects.education.spaces.docsSpace.currentBranch = branch
|
||||
let workspace = UI.projects.foundations.spaces.designSpace.workspace.workspaceNode
|
||||
UI.projects.foundations.utilities.nodeConfig.saveConfigProperty(workspace.payload, 'currentBranch', branch)
|
||||
|
||||
if (doNotNavigate === true) { return }
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Switching Branches - Current Branch Changed')
|
||||
} else {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo(
|
||||
data.docs.project,
|
||||
data.docs.category,
|
||||
data.docs.type,
|
||||
data.docs.anchor,
|
||||
undefined,
|
||||
data.docs.placeholder
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function changeContributionsBranch(branch, doNotNavigate) {
|
||||
UI.projects.education.spaces.docsSpace.contributionsBranch = branch
|
||||
let workspace = UI.projects.foundations.spaces.designSpace.workspace.workspaceNode
|
||||
UI.projects.foundations.utilities.nodeConfig.saveConfigProperty(workspace.payload, 'contributionsBranch', branch)
|
||||
|
||||
if (doNotNavigate !== true) {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Switching Branches - Contributions Branch Changed')
|
||||
}
|
||||
}
|
||||
|
||||
function changeLanguage(pLanguage) {
|
||||
UI.projects.education.spaces.docsSpace.language = pLanguage
|
||||
let languageLabel = UI.projects.education.utilities.languages.getLaguageLabel(UI.projects.education.spaces.docsSpace.language)
|
||||
UI.projects.education.spaces.docsSpace.navigateTo('Foundations', 'Topic', 'Docs In ' + languageLabel)
|
||||
|
||||
let workspace = UI.projects.foundations.spaces.designSpace.workspace.workspaceNode
|
||||
UI.projects.foundations.utilities.nodeConfig.saveConfigProperty(workspace.payload, 'docsLanguage', UI.projects.education.spaces.docsSpace.language)
|
||||
}
|
||||
|
||||
function sharePage() {
|
||||
let clipboard = "docs.goto " + UI.projects.education.spaces.docsSpace.currentDocumentBeingRendered.project + '->' + UI.projects.education.spaces.docsSpace.currentDocumentBeingRendered.category + '->' + UI.projects.education.spaces.docsSpace.currentDocumentBeingRendered.type
|
||||
UI.projects.foundations.utilities.clipboard.copyTextToClipboard(clipboard)
|
||||
}
|
||||
|
||||
function onKeyDown(event) {
|
||||
/*
|
||||
When an editor is on focus we will only
|
||||
take care of a few combinations of key strokes
|
||||
so as to tell the editor container when the user
|
||||
would like to close the editor. ESC key exits edit mode.
|
||||
*/
|
||||
if (event.key === 'Escape') {
|
||||
UI.projects.education.spaces.docsSpace.exitEditMode()
|
||||
}
|
||||
}
|
||||
|
||||
function enterEditMode() {
|
||||
EDITOR_ON_FOCUS = true
|
||||
window.editorController = {
|
||||
onKeyDown: onKeyDown
|
||||
}
|
||||
}
|
||||
|
||||
function exitEditMode() {
|
||||
if (EDITOR_ON_FOCUS === true) {
|
||||
thisObject.documentPage.exitEditMode()
|
||||
UI.projects.education.spaces.docsSpace.documentPage.render()
|
||||
EDITOR_ON_FOCUS = false
|
||||
}
|
||||
}
|
||||
|
||||
function onOpening() {
|
||||
thisObject.isVisible = true
|
||||
if (UI.projects.education.spaces.docsSpace.currentDocumentBeingRendered === undefined) {
|
||||
thisObject.mainSearchPage.render()
|
||||
|
||||
} else {
|
||||
UI.projects.education.spaces.docsSpace.navigateTo(
|
||||
UI.projects.education.spaces.docsSpace.currentDocumentBeingRendered.project,
|
||||
UI.projects.education.spaces.docsSpace.currentDocumentBeingRendered.category,
|
||||
UI.projects.education.spaces.docsSpace.currentDocumentBeingRendered.type,
|
||||
UI.projects.education.spaces.docsSpace.currentDocumentBeingRendered.anchor,
|
||||
UI.projects.education.spaces.docsSpace.currentDocumentBeingRendered.nodeId,
|
||||
UI.projects.education.spaces.docsSpace.currentDocumentBeingRendered.placeholder
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
function onClosing() {
|
||||
thisObject.contextMenu.removeContextMenuFromScreen()
|
||||
thisObject.isVisible = false
|
||||
}
|
||||
|
||||
function scrollToElement(htmlElementId) {
|
||||
let myElement = document.getElementById(htmlElementId)
|
||||
if (myElement) {
|
||||
let topPos = myElement.offsetTop
|
||||
let scrollingDiv = document.getElementById('docs-space-div')
|
||||
scrollingDiv.scrollTop = topPos
|
||||
}
|
||||
}
|
||||
|
||||
function openSpaceAreaAndNavigateTo(project, category, type, anchor, nodeId, placeholder) {
|
||||
|
||||
getReadyToNavigate(project, category, type, anchor, nodeId, placeholder)
|
||||
|
||||
thisObject.sidePanelTab.open()
|
||||
}
|
||||
|
||||
function searchPage() {
|
||||
UI.projects.education.spaces.docsSpace.currentDocumentBeingRendered = undefined
|
||||
thisObject.mainSearchPage.render()
|
||||
}
|
||||
|
||||
function navigateTo(project, category, type, anchor, nodeId, placeholder) {
|
||||
|
||||
EDITOR_ON_FOCUS = false // forced exit
|
||||
UI.projects.education.spaces.docsSpace.paragraphMap = new Map()
|
||||
|
||||
getReadyToNavigate(project, category, type, anchor, nodeId, placeholder)
|
||||
|
||||
UI.projects.education.spaces.docsSpace.documentPage.render()
|
||||
|
||||
/*
|
||||
Here we will check if we need to position the page at a particular anchor or at the top.
|
||||
*/
|
||||
if (UI.projects.education.spaces.docsSpace.currentDocumentBeingRendered.anchor !== undefined) {
|
||||
scrollToElement('docs-anchor-' + UI.projects.education.spaces.docsSpace.currentDocumentBeingRendered.anchor.toLowerCase().replaceAll(' ', '-'))
|
||||
UI.projects.education.spaces.docsSpace.currentDocumentBeingRendered.anchor = undefined
|
||||
} else {
|
||||
scrollToElement('docs-space-div')
|
||||
}
|
||||
}
|
||||
|
||||
function getReadyToNavigate(project, category, type, anchor, nodeId, placeholder) {
|
||||
/* Replace the current object with this */
|
||||
if (UI.projects.education.spaces.docsSpace.currentDocumentBeingRendered !== undefined) {
|
||||
UI.projects.education.spaces.docsSpace.previousDocumentBeingRendered = JSON.parse(JSON.stringify(UI.projects.education.spaces.docsSpace.currentDocumentBeingRendered))
|
||||
}
|
||||
|
||||
if (category === 'Book') {
|
||||
UI.projects.education.spaces.docsSpace.currentBookBeingRendered = {
|
||||
project: project,
|
||||
category: category,
|
||||
type: type.replace('AMPERSAND', '\''),
|
||||
anchor: anchor,
|
||||
nodeId: nodeId,
|
||||
placeholder: placeholder
|
||||
}
|
||||
}
|
||||
|
||||
UI.projects.education.spaces.docsSpace.currentDocumentBeingRendered = {
|
||||
project: project,
|
||||
category: category,
|
||||
type: type.replace('AMPERSAND', '\''),
|
||||
anchor: anchor,
|
||||
nodeId: nodeId,
|
||||
placeholder: placeholder
|
||||
}
|
||||
}
|
||||
|
||||
function resize() {
|
||||
thisObject.container.frame.width = UI.projects.education.globals.docs.DOCS_SPACE_WIDTH
|
||||
thisObject.container.frame.height = browserCanvas.height // - TOP_SPACE_HEIGHT
|
||||
thisObject.container.frame.position.x = browserCanvas.width
|
||||
thisObject.container.frame.position.y = 0 // TOP_SPACE_HEIGHT
|
||||
|
||||
if (thisObject.sidePanelTab !== undefined) {
|
||||
thisObject.sidePanelTab.resize()
|
||||
}
|
||||
}
|
||||
|
||||
function getContainer(point, purpose) {
|
||||
if (thisObject.sidePanelTab === undefined) { return }
|
||||
let container
|
||||
|
||||
container = thisObject.sidePanelTab.getContainer(point, purpose)
|
||||
if (container !== undefined) { return container }
|
||||
|
||||
if (thisObject.container.frame.isThisPointHere(point, true) === true) {
|
||||
return thisObject.container
|
||||
} else {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
function physics() {
|
||||
docsAppDivPhysics()
|
||||
|
||||
function docsAppDivPhysics() {
|
||||
let docsSpaceDiv = document.getElementById('docs-space-div')
|
||||
docsAppDivPosition = {
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
docsAppDivPosition = thisObject.container.frame.frameThisPoint(docsAppDivPosition)
|
||||
docsSpaceDiv.style = ' ' +
|
||||
'overflow-y: scroll;' +
|
||||
'overflow-x: hidden;' +
|
||||
'position:fixed; top:' + docsAppDivPosition.y + 'px; ' +
|
||||
'left:' + docsAppDivPosition.x + 'px; z-index:1; ' +
|
||||
'width: ' + thisObject.container.frame.width + 'px;' +
|
||||
'height: ' + thisObject.container.frame.height + 'px'
|
||||
}
|
||||
}
|
||||
|
||||
function draw() {
|
||||
if (CAN_SPACES_DRAW === false) { return }
|
||||
if (isInitialized === false) { return }
|
||||
borders()
|
||||
}
|
||||
|
||||
function borders() {
|
||||
let point1
|
||||
let point2
|
||||
let point3
|
||||
let point4
|
||||
|
||||
point1 = {
|
||||
x: 0,
|
||||
y: 0
|
||||
}
|
||||
|
||||
point2 = {
|
||||
x: thisObject.container.frame.width,
|
||||
y: 0
|
||||
}
|
||||
|
||||
point3 = {
|
||||
x: thisObject.container.frame.width,
|
||||
y: thisObject.container.frame.height
|
||||
}
|
||||
|
||||
point4 = {
|
||||
x: 0,
|
||||
y: thisObject.container.frame.height
|
||||
}
|
||||
|
||||
point1 = thisObject.container.frame.frameThisPoint(point1)
|
||||
point2 = thisObject.container.frame.frameThisPoint(point2)
|
||||
point3 = thisObject.container.frame.frameThisPoint(point3)
|
||||
point4 = thisObject.container.frame.frameThisPoint(point4)
|
||||
|
||||
browserCanvasContext.setLineDash([]) // Resets Line Dash
|
||||
browserCanvasContext.beginPath()
|
||||
browserCanvasContext.moveTo(point1.x, point1.y)
|
||||
browserCanvasContext.lineTo(point2.x, point2.y)
|
||||
browserCanvasContext.lineTo(point3.x, point3.y)
|
||||
browserCanvasContext.lineTo(point4.x, point4.y)
|
||||
browserCanvasContext.lineTo(point1.x, point1.y)
|
||||
browserCanvasContext.closePath()
|
||||
|
||||
let opacity = 1
|
||||
|
||||
browserCanvasContext.fillStyle = 'rgba(' + UI_COLOR.LIGHT_GREY + ', ' + opacity + ''
|
||||
browserCanvasContext.fill()
|
||||
|
||||
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.GREY + ', ' + opacity + ''
|
||||
browserCanvasContext.lineWidth = 0.3
|
||||
browserCanvasContext.stroke()
|
||||
|
||||
/* Shadow */
|
||||
|
||||
if (thisObject.container.status !== 'hidden') {
|
||||
for (let i = 0; i <= 30; i++) {
|
||||
opacity = 1 - (i / 300) - 0.95
|
||||
|
||||
browserCanvasContext.setLineDash([]) // Resets Line Dash
|
||||
browserCanvasContext.beginPath()
|
||||
browserCanvasContext.moveTo(point2.x + i, point2.y)
|
||||
browserCanvasContext.lineTo(point3.x + i, point3.y)
|
||||
browserCanvasContext.closePath()
|
||||
|
||||
browserCanvasContext.strokeStyle = 'rgba(' + UI_COLOR.BLACK + ', ' + opacity + ''
|
||||
browserCanvasContext.lineWidth = 1
|
||||
browserCanvasContext.stroke()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,248 @@
|
||||
function newFoundationsDocsFooter() {
|
||||
let thisObject = {
|
||||
addFooter: addFooter,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
return thisObject
|
||||
|
||||
function initialize() {
|
||||
|
||||
}
|
||||
|
||||
function finalize() {
|
||||
|
||||
}
|
||||
|
||||
function addFooter() {
|
||||
|
||||
let HTML = ''
|
||||
|
||||
HTML = HTML + '<div id="docs-footer" class="docs-node-html-footer-container">' // Container Starts
|
||||
|
||||
// Buttons Section
|
||||
|
||||
HTML = HTML + '<div class="docs-node-html-footer-table">'
|
||||
HTML = HTML + '<div class="docs-footer-row">'
|
||||
|
||||
HTML = HTML + '<div class="docs-footer-cell style="white-space: nowrap; overflow-x: auto;" >' // white-space: nowrap; overflow-x: auto; prevents line breaks when combined with display: inline-block;" in the child elements
|
||||
|
||||
if (UI.projects.education.spaces.docsSpace.currentDocumentBeingRendered !== undefined) {
|
||||
HTML = HTML + '<span style="float: right; display: inline-block;" onClick="UI.projects.education.spaces.docsSpace.sharePage()"><button>SHARE</button></span>'
|
||||
}
|
||||
HTML = HTML + '<span style="float: right; display: inline-block;" onClick="UI.projects.education.spaces.docsSpace.scrollToElement(\'docs-space-div\')"><button>TO TOP</button></span>'
|
||||
if (UI.projects.education.spaces.docsSpace.previousDocumentBeingRendered !== undefined) {
|
||||
HTML = HTML + '<span style="float: right; display: inline-block;" onClick="UI.projects.education.spaces.docsSpace.navigateTo(\'' + UI.projects.education.spaces.docsSpace.previousDocumentBeingRendered.project + '\', \'' + UI.projects.education.spaces.docsSpace.previousDocumentBeingRendered.category + '\', \'' + UI.projects.education.spaces.docsSpace.previousDocumentBeingRendered.type + '\')"><button>BACK</button></span>'
|
||||
}
|
||||
if (UI.projects.education.spaces.docsSpace.currentBookBeingRendered !== undefined) {
|
||||
HTML = HTML + '<span style="float: right; display: inline-block;" onClick="UI.projects.education.spaces.docsSpace.navigateTo(\'' + UI.projects.education.spaces.docsSpace.currentBookBeingRendered.project + '\', \'' + UI.projects.education.spaces.docsSpace.currentBookBeingRendered.category + '\', \'' + UI.projects.education.spaces.docsSpace.currentBookBeingRendered.type + '\')"><button>TO BOOK</button></span>'
|
||||
}
|
||||
|
||||
HTML = HTML + '<span style="float: right; display: inline-block;" onClick="UI.projects.education.spaces.docsSpace.navigateTo(\'' + 'Foundations' + '\', \'' + 'Book' + '\', \'' + 'Reviews' + '\')"><button>REVIEWS</button></span>'
|
||||
HTML = HTML + '<span style="float: right; display: inline-block;" onClick="UI.projects.education.spaces.docsSpace.navigateTo(\'' + 'Foundations' + '\', \'' + 'Book' + '\', \'' + 'Community Data Mines' + '\')"><button>DATA MINES</button></span>'
|
||||
HTML = HTML + '<span style="float: right; display: inline-block;" onClick="UI.projects.education.spaces.docsSpace.navigateTo(\'' + 'Foundations' + '\', \'' + 'Book' + '\', \'' + 'First Steps Tutorials' + '\')"><button>TUTORIALS</button></span>'
|
||||
HTML = HTML + '<span style="float: right; display: inline-block;" onClick="UI.projects.education.spaces.docsSpace.navigateTo(\'' + 'Foundations' + '\', \'' + 'Book' + '\', \'' + 'User Manual' + '\')"><button>USER MANUAL</button></span>'
|
||||
|
||||
HTML = HTML + '</div>'
|
||||
|
||||
HTML = HTML + '</div>'
|
||||
HTML = HTML + '</div>'
|
||||
|
||||
// Language Section
|
||||
|
||||
HTML = HTML + '<div class="docs-node-html-footer-table">'
|
||||
HTML = HTML + '<div class="docs-footer-row">'
|
||||
|
||||
HTML = HTML + '<div class="docs-footer-cell" style="white-space: nowrap; overflow-x: auto; ">'
|
||||
HTML = HTML + '<h3 style="display: inline-block;">Help Superalgos Speak Your Language!</h3>'
|
||||
HTML = HTML + '</div>'
|
||||
|
||||
HTML = HTML + '</div>'
|
||||
HTML = HTML + '</div>'
|
||||
|
||||
HTML = HTML + '<div class="docs-node-html-footer-table">'
|
||||
HTML = HTML + '<div class="docs-footer-row">'
|
||||
|
||||
HTML = HTML + '<div class="docs-footer-cell">'
|
||||
HTML = HTML + '<h4>Multi-language Docs</h4>'
|
||||
HTML = HTML + 'We produce the original Docs in English and you get the content in your preferred language only when translations are available. When not, you get the default content, in English.'
|
||||
HTML = HTML + '</div>'
|
||||
|
||||
let languageCode = UI.projects.education.spaces.docsSpace.language
|
||||
|
||||
HTML = HTML + '<div class="docs-footer-cell">'
|
||||
HTML = HTML + '<h4>Choose Your Language</h4>'
|
||||
HTML = HTML + 'Click on your preferred language:<br/>'
|
||||
|
||||
HTML = HTML + '<a href="#" onClick="UI.projects.education.spaces.docsSpace.changeLanguage(\'EN\')"><img src="Images/Languages/EN.png" title="English" class="docs-footer-language'
|
||||
if (languageCode === 'EN') {
|
||||
HTML = HTML + '-selected'
|
||||
}
|
||||
HTML = HTML + '"></a>'
|
||||
|
||||
HTML = HTML + '<a href="#" onClick="UI.projects.education.spaces.docsSpace.changeLanguage(\'ES\')"><img src="Images/Languages/ES.png" title="Spanish" class="docs-footer-language'
|
||||
if (languageCode === 'ES') {
|
||||
HTML = HTML + '-selected'
|
||||
}
|
||||
HTML = HTML + '"></a>'
|
||||
|
||||
HTML = HTML + '<a href="#" onClick="UI.projects.education.spaces.docsSpace.changeLanguage(\'RU\')"><img src="Images/Languages/RU.png" title="Russian" class="docs-footer-language'
|
||||
if (languageCode === 'RU') {
|
||||
HTML = HTML + '-selected'
|
||||
}
|
||||
HTML = HTML + '"></a>'
|
||||
|
||||
HTML = HTML + '<a href="#" onClick="UI.projects.education.spaces.docsSpace.changeLanguage(\'IT\')"><img src="Images/Languages/IT.png" title="Italian" class="docs-footer-language'
|
||||
if (languageCode === 'IT') {
|
||||
HTML = HTML + '-selected'
|
||||
}
|
||||
HTML = HTML + '"></a>'
|
||||
|
||||
HTML = HTML + '<a href="#" onClick="UI.projects.education.spaces.docsSpace.changeLanguage(\'DE\')"><img src="Images/Languages/DE.png" title="German" class="docs-footer-language'
|
||||
if (languageCode === 'DE') {
|
||||
HTML = HTML + '-selected'
|
||||
}
|
||||
HTML = HTML + '"></a>'
|
||||
|
||||
HTML = HTML + '<a href="#" onClick="UI.projects.education.spaces.docsSpace.changeLanguage(\'FR\')"><img src="Images/Languages/FR.png" title="French" class="docs-footer-language'
|
||||
if (languageCode === 'FR') {
|
||||
HTML = HTML + '-selected'
|
||||
}
|
||||
HTML = HTML + '"></a>'
|
||||
|
||||
HTML = HTML + '<a href="#" onClick="UI.projects.education.spaces.docsSpace.changeLanguage(\'CN\')"><img src="Images/Languages/CN.png" title="Simplified Chinese-Mandarin" class="docs-footer-language'
|
||||
if (languageCode === 'CN') {
|
||||
HTML = HTML + '-selected'
|
||||
}
|
||||
HTML = HTML + '"></a>'
|
||||
|
||||
HTML = HTML + '<a href="#" onClick="UI.projects.education.spaces.docsSpace.changeLanguage(\'ID\')"><img src="Images/Languages/ID.png" title="Bahasa" class="docs-footer-language'
|
||||
if (languageCode === 'ID') {
|
||||
HTML = HTML + '-selected'
|
||||
}
|
||||
HTML = HTML + '"></a>'
|
||||
|
||||
HTML = HTML + '<a href="#" onClick="UI.projects.education.spaces.docsSpace.changeLanguage(\'TR\')"><img src="Images/Languages/TR.png" title="Turkish" class="docs-footer-language'
|
||||
if (languageCode === 'TR') {
|
||||
HTML = HTML + '-selected'
|
||||
}
|
||||
HTML = HTML + '"></a>'
|
||||
|
||||
HTML = HTML + '</div>'
|
||||
|
||||
HTML = HTML + '<div class="docs-footer-cell">'
|
||||
HTML = HTML + '<h4>Contribute Translations</h4>'
|
||||
HTML = HTML + 'Earn tokens by helping translate the Docs and tutorials to your native language! Search the Docs for How to Contribute Translations and join the Superalgos Docs Group to coordinate with other contributors...'
|
||||
HTML = HTML + '</div>'
|
||||
|
||||
HTML = HTML + '</div>'
|
||||
HTML = HTML + '</div>'
|
||||
|
||||
// GitHub Section
|
||||
|
||||
HTML = HTML + '<div class="docs-node-html-footer-table">'
|
||||
HTML = HTML + '<div class="docs-footer-row">'
|
||||
|
||||
HTML = HTML + '<div class="docs-footer-cell" style="white-space: nowrap; overflow-x: auto; ">'
|
||||
HTML = HTML + '<h3 style="display: inline-block;">Manage Your Superalgos Setup and Contributions!</h3>'
|
||||
HTML = HTML + '</div>'
|
||||
|
||||
HTML = HTML + '</div>'
|
||||
HTML = HTML + '</div>'
|
||||
|
||||
HTML = HTML + '<div class="docs-node-html-footer-table">'
|
||||
|
||||
HTML = HTML + '<div class="docs-footer-row">'
|
||||
HTML = HTML + '<div class="docs-footer-cell">'
|
||||
HTML = HTML + '<h4>About Your Deployment</h4>'
|
||||
HTML = HTML + 'Superalgos may run from different branches in the repository. The <code class="docs-footer-code">Master</code> branch features the stable version, and the <code class="docs-footer-code">Develop</code> branch the version in development. Use the <code class="docs-footer-code">Plugins-Docs</code> branch to contribute plugins and to the Docs.'
|
||||
HTML = HTML + '</div>'
|
||||
|
||||
HTML = HTML + '<div class="docs-footer-cell">'
|
||||
HTML = HTML + '<h4>Choose the Current Branch</h4>'
|
||||
HTML = HTML + 'You are currently running on the <code class="docs-footer-code">' + UI.projects.foundations.utilities.gitBranches.getBranchLabel(UI.projects.education.spaces.docsSpace.currentBranch) + '</code> branch. Switch to:'
|
||||
HTML = HTML + '<ul>'
|
||||
HTML = HTML + '<li><a href="#" onClick="UI.projects.education.spaces.docsSpace.changeCurrentBranch(\'master\')">Master</a></li>'
|
||||
HTML = HTML + '<li><a href="#" onClick="UI.projects.education.spaces.docsSpace.changeCurrentBranch(\'develop\')">Develop</a></li>'
|
||||
HTML = HTML + '<li><a href="#" onClick="UI.projects.education.spaces.docsSpace.changeCurrentBranch(\'plugins-docs\')">Plugins-Docs</a></li>'
|
||||
HTML = HTML + '<li><a href="#" onClick="UI.projects.education.spaces.docsSpace.changeCurrentBranch(\'next-version\')">Next-Version</a></li>'
|
||||
HTML = HTML + '</ul>'
|
||||
HTML = HTML + '</div>'
|
||||
|
||||
HTML = HTML + '<div class="docs-footer-cell">'
|
||||
HTML = HTML + '<h4>Contributions Branch</h4>'
|
||||
HTML = HTML + 'You are currently contributing to the <code class="docs-footer-code">' + UI.projects.foundations.utilities.gitBranches.getBranchLabel(UI.projects.education.spaces.docsSpace.contributionsBranch) + '</code> branch. Switch to:'
|
||||
HTML = HTML + '<ul>'
|
||||
HTML = HTML + '<li><a href="#" onClick="UI.projects.education.spaces.docsSpace.changeContributionsBranch(\'master\')">Master</code></li>'
|
||||
HTML = HTML + '<li><a href="#" onClick="UI.projects.education.spaces.docsSpace.changeContributionsBranch(\'develop\')">Develop</a></li>'
|
||||
HTML = HTML + '<li><a href="#" onClick="UI.projects.education.spaces.docsSpace.changeContributionsBranch(\'plugins-docs\')">Plugins-Docs</a></li>'
|
||||
HTML = HTML + '<li><a href="#" onClick="UI.projects.education.spaces.docsSpace.changeContributionsBranch(\'next-version\')">Next-Version</a></li>'
|
||||
|
||||
HTML = HTML + '</ul>'
|
||||
HTML = HTML + '</ul>'
|
||||
HTML = HTML + '</div>'
|
||||
|
||||
HTML = HTML + '</div>'
|
||||
HTML = HTML + '</div>'
|
||||
|
||||
// Community Section
|
||||
|
||||
HTML = HTML + '<div class="docs-node-html-footer-table">'
|
||||
HTML = HTML + '<div class="docs-footer-row">'
|
||||
HTML = HTML + '<div class="docs-footer-cell" style="white-space: nowrap; overflow-x: auto; ">'
|
||||
HTML = HTML + '<h3 style="display: inline-block;">Meet the Community and the Team!</h3>'
|
||||
HTML = HTML + '</div>'
|
||||
HTML = HTML + '</div>'
|
||||
HTML = HTML + '</div>'
|
||||
|
||||
HTML = HTML + '<div class="docs-node-html-footer-table">'
|
||||
|
||||
HTML = HTML + '<div class="docs-footer-row">'
|
||||
HTML = HTML + '<div class="docs-footer-cell">'
|
||||
HTML = HTML + '<h4>Join the Conversation</h4>'
|
||||
HTML = HTML + '<p>We have a new <a href="https://discord.gg/CGeKC6WQQb" target="_blank">Discord Server</a> with multiple channels, or you may join the original individual Telegram groups listed to the right.</p>'
|
||||
HTML = HTML + '</div>'
|
||||
|
||||
HTML = HTML + '<div class="docs-footer-cell">'
|
||||
HTML = HTML + '<h4>In Telegram</h4>'
|
||||
HTML = HTML + '<ul>'
|
||||
HTML = HTML + '<li><a href="https://t.me/superalgoscommunity" target="_blank">Community Group</a></li>'
|
||||
HTML = HTML + '<li><a href="https://t.me/superalgossupport" target="_blank">Technical Support Group</a></li>'
|
||||
HTML = HTML + '<li><a href="https://t.me/superalgosdevelop" target="_blank">Developers Group</a></li>'
|
||||
HTML = HTML + '<li><a href="https://t.me/superalgosmachinelearning" target="_blank">Machine Learning Group</a></li>'
|
||||
HTML = HTML + '<li><a href="https://t.me/superalgosdocs" target="_blank">Docs Group</a></li>'
|
||||
HTML = HTML + '<li><a href="https://t.me/superalgosuxui" target="_blank">UX/UI Design Group</a></li>'
|
||||
HTML = HTML + '<li><a href="https://t.me/superalgoscollaborations" target="_blank">Collaborations Group</a></li>'
|
||||
HTML = HTML + '<li><a href="https://t.me/superalgoscodebase" target="_blank">Codebase Learning Group</a></li>'
|
||||
HTML = HTML + '<li><a href="https://t.me/superalgos_es" target="_blank">Hablemos en Español!</a></li>'
|
||||
HTML = HTML + '<li><a href="https://t.me/superalgos_ru" target="_blank">Говорим по русски!</a></li>'
|
||||
HTML = HTML + '</ul>'
|
||||
HTML = HTML + '</div>'
|
||||
|
||||
HTML = HTML + '<div class="docs-footer-cell">'
|
||||
HTML = HTML + '<h4>Other Resources</h4>'
|
||||
HTML = HTML + '<ul>'
|
||||
HTML = HTML + '<li><a href="https://t.me/superalgos" target="_blank">Official Announcements</a></li>'
|
||||
HTML = HTML + '<li><a href="https://superalgos.org" target="_blank">Features and Functionality</a></li>'
|
||||
HTML = HTML + '<li><a href="https://github.com/Superalgos/Superalgos" target="_blank">Main Github Repository</a></li>'
|
||||
HTML = HTML + '<li><a href="https://www.youtube.com/c/superalgos" target="_blank">Subscribe in YouTube</a></li>'
|
||||
HTML = HTML + '<li><a href="https://twitter.com/superalgos" target="_blank">Follow us on Twitter</a></li>'
|
||||
HTML = HTML + '<li><a href="https://www.facebook.com/superalgos" target="_blank">Connect on Facebook</a></li>'
|
||||
HTML = HTML + '<li><a href="https://medium.com/Superalgos/" target="_blank">Read the Blog</a></li>'
|
||||
HTML = HTML + '</ul>'
|
||||
HTML = HTML + '</div>'
|
||||
HTML = HTML + '</div>'
|
||||
|
||||
HTML = HTML + '<div class="docs-footer-row">'
|
||||
HTML = HTML + '<div class="docs-footer-cell">'
|
||||
HTML = HTML + '<img src="Images/superalgos-logo-white.png" width="200 px">'
|
||||
HTML = HTML + '</div>'
|
||||
HTML = HTML + '</div>'
|
||||
HTML = HTML + '</div>'
|
||||
|
||||
HTML = HTML + '</div>' // Container Ends
|
||||
|
||||
return HTML
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
function newFoundationsDocsMainSearchPage() {
|
||||
let thisObject = {
|
||||
addSearchHeader: addSearchHeader,
|
||||
detectEnterOnSearchBox: detectEnterOnSearchBox,
|
||||
setFocusOnSearchBox: setFocusOnSearchBox,
|
||||
render: render,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
return thisObject
|
||||
|
||||
function initialize() {
|
||||
|
||||
}
|
||||
|
||||
function finalize() {
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
let HTML = ''
|
||||
HTML = HTML + '<div id="docs-search-page-div">'
|
||||
HTML = HTML + '<center><img src="Images/superalgos-logo.png" class="docs-image-logo-search" width=400></center>'
|
||||
HTML = HTML + '<center><div class="docs-font-normal docs-search-box"><input class="docs-search-input" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></input></div></center>'
|
||||
HTML = HTML + '</div>'
|
||||
let docsContentDiv = document.getElementById('docs-content-div')
|
||||
docsContentDiv.innerHTML = HTML + UI.projects.education.spaces.docsSpace.footer.addFooter()
|
||||
|
||||
UI.projects.education.spaces.docsSpace.mainSearchPage.detectEnterOnSearchBox()
|
||||
UI.projects.education.spaces.docsSpace.mainSearchPage.setFocusOnSearchBox()
|
||||
}
|
||||
|
||||
function addSearchHeader() {
|
||||
let HTML = ''
|
||||
// Logo & Search Box
|
||||
HTML = HTML + '<div class="docs-search-results-header">'
|
||||
HTML = HTML + '<div class="docs-image-logo-search-results"><img src="Images/superalgos-logo.png" width=200></div>'
|
||||
HTML = HTML + '<div class="docs-search-results-box">'
|
||||
HTML = HTML + '<input class="docs-search-input" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"></input>'
|
||||
HTML = HTML + '</div>'
|
||||
HTML = HTML + '</div>'
|
||||
|
||||
return HTML
|
||||
}
|
||||
|
||||
function detectEnterOnSearchBox() {
|
||||
const element = document.getElementsByClassName("docs-search-input")[0]
|
||||
if (UI.projects.education.spaces.docsSpace.commandInterface.command !== undefined) {
|
||||
element.value = UI.projects.education.spaces.docsSpace.commandInterface.command
|
||||
}
|
||||
element.addEventListener("keyup", function (event) {
|
||||
if (event.key === "Enter" || event.keyCode === 13) {
|
||||
UI.projects.education.spaces.docsSpace.exitEditMode()
|
||||
UI.projects.education.spaces.docsSpace.currentBookBeingRendered = undefined
|
||||
UI.projects.education.spaces.docsSpace.currentDocumentBeingRendered = undefined
|
||||
UI.projects.education.spaces.docsSpace.contextMenu.removeContextMenuFromScreen()
|
||||
UI.projects.education.spaces.docsSpace.commandInterface.command = element.value.trim()
|
||||
UI.projects.education.spaces.docsSpace.commandInterface.detectCommands()
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function setFocusOnSearchBox() {
|
||||
const element = document.getElementsByClassName("docs-search-input")[0]
|
||||
element.focus()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,340 @@
|
||||
function newFoundationsDocsSearchEngine() {
|
||||
let thisObject = {
|
||||
docsIndex: undefined,
|
||||
setUpSearchEngine: setUpSearchEngine,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
return thisObject
|
||||
|
||||
function initialize() {
|
||||
thisObject.docsIndex = []
|
||||
}
|
||||
|
||||
function finalize() {
|
||||
thisObject.docsIndex = undefined
|
||||
}
|
||||
|
||||
function setUpSearchEngine(callbackFunction) {
|
||||
|
||||
/*
|
||||
This is a way to avoid indexing the docs, if the user does not want to.
|
||||
*/
|
||||
let docsSpaceNode = UI.projects.foundations.spaces.designSpace.workspace.getHierarchyHeadByNodeType('Docs Space')
|
||||
if (docsSpaceNode !== undefined) {
|
||||
if (docsSpaceNode.spaceSettings !== undefined) {
|
||||
let indexContent = UI.projects.foundations.utilities.nodeConfig.loadConfigProperty(docsSpaceNode.spaceSettings.payload, 'indexContent')
|
||||
if (indexContent === false) {
|
||||
callbackFunction()
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let totalAsyncCallsMade = 0
|
||||
let totalAsyncCallsFinished = 0
|
||||
|
||||
setUpWorkspaceSchemas()
|
||||
thisObject.docsIndex = []
|
||||
|
||||
for (let j = 0; j < PROJECTS_SCHEMA.length; j++) {
|
||||
let project = PROJECTS_SCHEMA[j].name
|
||||
|
||||
let documentIndex
|
||||
|
||||
totalAsyncCallsMade++
|
||||
totalAsyncCallsMade++
|
||||
totalAsyncCallsMade++
|
||||
totalAsyncCallsMade++
|
||||
totalAsyncCallsMade++
|
||||
totalAsyncCallsMade++
|
||||
totalAsyncCallsMade++
|
||||
|
||||
setTimeout(searchInNodes, 10)
|
||||
setTimeout(searchInConcepts, 20)
|
||||
setTimeout(searchInNTopics, 30)
|
||||
setTimeout(searchInTutorials, 40)
|
||||
setTimeout(searchInReviews, 50)
|
||||
setTimeout(searchInBooks, 60)
|
||||
setTimeout(searchInWorkspaces, 70)
|
||||
|
||||
function searchInNodes() {
|
||||
/* Search in Nodes */
|
||||
for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.docsNodeSchema.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.docsNodeSchema[i],
|
||||
category: 'Node',
|
||||
project: project
|
||||
}
|
||||
indexDocument(documentIndex)
|
||||
thisObject.docsIndex.push(documentIndex)
|
||||
}
|
||||
asyncCallFinished()
|
||||
}
|
||||
function searchInConcepts() {
|
||||
/* Search in Concepts */
|
||||
for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.docsConceptSchema.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.docsConceptSchema[i],
|
||||
category: 'Concept',
|
||||
project: project
|
||||
}
|
||||
indexDocument(documentIndex)
|
||||
thisObject.docsIndex.push(documentIndex)
|
||||
}
|
||||
asyncCallFinished()
|
||||
}
|
||||
function searchInNTopics() {
|
||||
/* Search in Topics */
|
||||
for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.docsTopicSchema.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.docsTopicSchema[i],
|
||||
category: 'Topic',
|
||||
project: project
|
||||
}
|
||||
indexDocument(documentIndex)
|
||||
thisObject.docsIndex.push(documentIndex)
|
||||
}
|
||||
asyncCallFinished()
|
||||
}
|
||||
function searchInTutorials() {
|
||||
/* 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)
|
||||
}
|
||||
asyncCallFinished()
|
||||
}
|
||||
function searchInReviews() {
|
||||
/* Search in Reviews */
|
||||
for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.docsReviewSchema.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.docsReviewSchema[i],
|
||||
category: 'Review',
|
||||
project: project
|
||||
}
|
||||
indexDocument(documentIndex)
|
||||
thisObject.docsIndex.push(documentIndex)
|
||||
}
|
||||
asyncCallFinished()
|
||||
}
|
||||
function searchInBooks() {
|
||||
/* Search in Books */
|
||||
for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.docsBookSchema.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.docsBookSchema[i],
|
||||
category: 'Book',
|
||||
project: project
|
||||
}
|
||||
indexDocument(documentIndex)
|
||||
thisObject.docsIndex.push(documentIndex)
|
||||
}
|
||||
asyncCallFinished()
|
||||
}
|
||||
function searchInWorkspaces() {
|
||||
/* Search in Workspace */
|
||||
for (let i = 0; i < SCHEMAS_BY_PROJECT.get(project).array.workspaceSchema.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.workspaceSchema[i],
|
||||
category: 'Workspace',
|
||||
project: project
|
||||
}
|
||||
indexDocument(documentIndex)
|
||||
thisObject.docsIndex.push(documentIndex)
|
||||
}
|
||||
asyncCallFinished()
|
||||
}
|
||||
|
||||
function asyncCallFinished() {
|
||||
totalAsyncCallsFinished++
|
||||
if (totalAsyncCallsMade === totalAsyncCallsFinished) {
|
||||
callbackFunction()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function indexDocument(documentIndex) {
|
||||
|
||||
if (documentIndex.docsSchemaDocument === undefined) {
|
||||
return
|
||||
}
|
||||
|
||||
if (documentIndex.docsSchemaDocument.topic !== undefined) {
|
||||
let paragraph = {
|
||||
style: 'Topic',
|
||||
text: documentIndex.docsSchemaDocument.topic
|
||||
}
|
||||
indexParagraph(paragraph)
|
||||
}
|
||||
if (documentIndex.docsSchemaDocument.tutorial !== undefined) {
|
||||
let paragraph = {
|
||||
style: 'Tutorial',
|
||||
text: documentIndex.docsSchemaDocument.tutorial
|
||||
}
|
||||
indexParagraph(paragraph)
|
||||
}
|
||||
if (documentIndex.docsSchemaDocument.review !== undefined) {
|
||||
let paragraph = {
|
||||
style: 'Review',
|
||||
text: documentIndex.docsSchemaDocument.review
|
||||
}
|
||||
indexParagraph(paragraph)
|
||||
}
|
||||
if (documentIndex.docsSchemaDocument.type !== undefined) {
|
||||
let paragraph = {
|
||||
style: 'Type',
|
||||
text: documentIndex.docsSchemaDocument.type
|
||||
}
|
||||
indexParagraph(paragraph)
|
||||
}
|
||||
if (documentIndex.docsSchemaDocument.definition !== undefined) {
|
||||
let paragraph = {
|
||||
style: 'Definition',
|
||||
text: documentIndex.docsSchemaDocument.definition.text,
|
||||
translations: documentIndex.docsSchemaDocument.definition.translations
|
||||
}
|
||||
indexParagraph(paragraph)
|
||||
indexAllTranslations(paragraph)
|
||||
}
|
||||
if (documentIndex.docsSchemaDocument.paragraphs !== undefined) {
|
||||
for (let k = 0; k < documentIndex.docsSchemaDocument.paragraphs.length; k++) {
|
||||
let paragraph = documentIndex.docsSchemaDocument.paragraphs[k]
|
||||
indexParagraph(paragraph)
|
||||
indexAllTranslations(paragraph)
|
||||
}
|
||||
}
|
||||
|
||||
function indexAllTranslations(paragraph) {
|
||||
if (paragraph.translations === undefined) { return }
|
||||
for (i = 0; i < paragraph.translations.length; i++) {
|
||||
let translation = paragraph.translations[i]
|
||||
translation.style = paragraph.style
|
||||
indexParagraph(translation)
|
||||
}
|
||||
}
|
||||
|
||||
function indexParagraph(paragraph) {
|
||||
if (paragraph.text === undefined) {
|
||||
return
|
||||
}
|
||||
if (paragraph.style === undefined) {
|
||||
return
|
||||
}
|
||||
|
||||
let text = paragraph.text.toLowerCase()
|
||||
let style = paragraph.style.toLowerCase()
|
||||
let stylePhraseCount = documentIndex.phraseCount[style]
|
||||
|
||||
if (stylePhraseCount === undefined) {
|
||||
stylePhraseCount = new Map()
|
||||
documentIndex.phraseCount[style] = stylePhraseCount
|
||||
}
|
||||
|
||||
text = UI.projects.foundations.utilities.strings.replaceSpecialCharactersForSpaces(text)
|
||||
|
||||
let splittedText = text.split(' ')
|
||||
|
||||
for (n = 0; n < splittedText.length; n++) {
|
||||
let phrase = ''
|
||||
for (let m = 0; m < 10; m++) {
|
||||
let word = splittedText[n + m]
|
||||
if (word !== undefined) {
|
||||
if (m === 0) {
|
||||
phrase = phrase + word
|
||||
} else {
|
||||
phrase = phrase + ' ' + word
|
||||
}
|
||||
let key = UI.projects.foundations.utilities.strings.cleanTextOfCommonWordEndings(phrase)
|
||||
|
||||
let thisPhraseCount = stylePhraseCount.get(key)
|
||||
if (thisPhraseCount === undefined) { thisPhraseCount = 0 }
|
||||
thisPhraseCount++
|
||||
|
||||
stylePhraseCount.set(key, thisPhraseCount)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function setUpWorkspaceSchemas() {
|
||||
/*
|
||||
We will scan the whole workspace and create an array with all of its nodes.
|
||||
*/
|
||||
let rootNodes = UI.projects.foundations.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.foundations.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_SCHEMA.length; j++) {
|
||||
let project = PROJECTS_SCHEMA[j].name
|
||||
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.foundations.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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,329 @@
|
||||
function newFoundationsDocsSearchResultsPage() {
|
||||
let thisObject = {
|
||||
render: render,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
return thisObject
|
||||
|
||||
function initialize() {
|
||||
|
||||
}
|
||||
|
||||
function finalize() {
|
||||
|
||||
}
|
||||
|
||||
function render() {
|
||||
|
||||
let resultsArary = []
|
||||
let initialTime = new Date()
|
||||
buildResultsArray()
|
||||
buildHTML()
|
||||
|
||||
function buildResultsArray() {
|
||||
for (let i = 0; i < UI.projects.education.spaces.docsSpace.searchEngine.docsIndex.length; i++) {
|
||||
let documentIndex = UI.projects.education.spaces.docsSpace.searchEngine.docsIndex[i]
|
||||
let documentPoints = 0
|
||||
|
||||
for (const style in documentIndex.phraseCount) {
|
||||
let key = UI.projects.foundations.utilities.strings.cleanTextOfCommonWordEndings(UI.projects.education.spaces.docsSpace.commandInterface.command.toLowerCase())
|
||||
let thisPhraseCount = documentIndex.phraseCount[style].get(key)
|
||||
if (thisPhraseCount === undefined) {
|
||||
thisPhraseCount = 0
|
||||
}
|
||||
|
||||
if (documentIndex.docsSchemaDocument.type !== undefined) {
|
||||
if (key === UI.projects.foundations.utilities.strings.cleanTextOfCommonWordEndings(documentIndex.docsSchemaDocument.type.toLowerCase())) {
|
||||
documentPoints = documentPoints + thisPhraseCount * 100
|
||||
}
|
||||
}
|
||||
if (documentIndex.docsSchemaDocument.topic !== undefined) {
|
||||
if (key === UI.projects.foundations.utilities.strings.cleanTextOfCommonWordEndings(documentIndex.docsSchemaDocument.topic.toLowerCase())) {
|
||||
documentPoints = documentPoints + thisPhraseCount * 200
|
||||
}
|
||||
}
|
||||
if (documentIndex.docsSchemaDocument.tutorial !== undefined) {
|
||||
if (key === UI.projects.foundations.utilities.strings.cleanTextOfCommonWordEndings(documentIndex.docsSchemaDocument.tutorial.toLowerCase())) {
|
||||
documentPoints = documentPoints + thisPhraseCount * 200
|
||||
}
|
||||
}
|
||||
if (documentIndex.docsSchemaDocument.review !== undefined) {
|
||||
if (key === UI.projects.foundations.utilities.strings.cleanTextOfCommonWordEndings(documentIndex.docsSchemaDocument.review.toLowerCase())) {
|
||||
documentPoints = documentPoints + thisPhraseCount * 200
|
||||
}
|
||||
}
|
||||
|
||||
switch (style) {
|
||||
case 'topic': {
|
||||
documentPoints = documentPoints + thisPhraseCount * 100
|
||||
break
|
||||
}
|
||||
case 'tutorial': {
|
||||
documentPoints = documentPoints + thisPhraseCount * 100
|
||||
break
|
||||
}
|
||||
case 'review': {
|
||||
documentPoints = documentPoints + thisPhraseCount * 100
|
||||
break
|
||||
}
|
||||
case 'type': {
|
||||
documentPoints = documentPoints + thisPhraseCount * 50
|
||||
break
|
||||
}
|
||||
case 'definition': {
|
||||
documentPoints = documentPoints + thisPhraseCount * 9
|
||||
break
|
||||
}
|
||||
case 'title': {
|
||||
documentPoints = documentPoints + thisPhraseCount * 10
|
||||
break
|
||||
}
|
||||
case 'subtitle': {
|
||||
documentPoints = documentPoints + thisPhraseCount * 8
|
||||
break
|
||||
}
|
||||
case 'text': {
|
||||
documentPoints = documentPoints + thisPhraseCount * 2
|
||||
break
|
||||
}
|
||||
case 'list': {
|
||||
documentPoints = documentPoints + thisPhraseCount * 2
|
||||
break
|
||||
}
|
||||
case 'note': {
|
||||
documentPoints = documentPoints + thisPhraseCount * 4
|
||||
break
|
||||
}
|
||||
case 'warning': {
|
||||
documentPoints = documentPoints + thisPhraseCount * 6
|
||||
break
|
||||
}
|
||||
case 'error': {
|
||||
documentPoints = documentPoints + thisPhraseCount * 6
|
||||
break
|
||||
}
|
||||
case 'important': {
|
||||
documentPoints = documentPoints + thisPhraseCount * 7
|
||||
break
|
||||
}
|
||||
case 'success': {
|
||||
documentPoints = documentPoints + thisPhraseCount * 5
|
||||
break
|
||||
}
|
||||
case 'callout': {
|
||||
documentPoints = documentPoints + thisPhraseCount * 5
|
||||
break
|
||||
}
|
||||
case 'summary': {
|
||||
documentPoints = documentPoints + thisPhraseCount * 6
|
||||
break
|
||||
}
|
||||
case 'section': {
|
||||
documentPoints = documentPoints + thisPhraseCount * 8
|
||||
break
|
||||
}
|
||||
case 'table': {
|
||||
documentPoints = documentPoints + thisPhraseCount * 3
|
||||
break
|
||||
}
|
||||
case 'hierarchy': {
|
||||
documentPoints = documentPoints + thisPhraseCount * 3
|
||||
break
|
||||
}
|
||||
case 'json': {
|
||||
documentPoints = documentPoints + thisPhraseCount * 2
|
||||
break
|
||||
}
|
||||
case 'javascript': {
|
||||
documentPoints = documentPoints + thisPhraseCount * 2
|
||||
break
|
||||
}
|
||||
case 'gif': {
|
||||
documentPoints = documentPoints + thisPhraseCount * 1
|
||||
break
|
||||
}
|
||||
case 'png': {
|
||||
documentPoints = documentPoints + thisPhraseCount * 1
|
||||
break
|
||||
}
|
||||
case 'anchor': {
|
||||
documentPoints = documentPoints + thisPhraseCount * 0
|
||||
break
|
||||
}
|
||||
case 'block': {
|
||||
documentPoints = documentPoints + thisPhraseCount * 0
|
||||
break
|
||||
}
|
||||
case 'include': {
|
||||
documentPoints = documentPoints + thisPhraseCount * 0
|
||||
break
|
||||
}
|
||||
case 'placeholder': {
|
||||
documentPoints = documentPoints + thisPhraseCount * 0
|
||||
break
|
||||
}
|
||||
case 'link': {
|
||||
documentPoints = documentPoints + thisPhraseCount * 1
|
||||
break
|
||||
}
|
||||
case 'youtube': {
|
||||
documentPoints = documentPoints + thisPhraseCount * 1
|
||||
break
|
||||
}
|
||||
case 'chapter': {
|
||||
documentPoints = documentPoints + thisPhraseCount * 8
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (documentPoints === 0) { continue } // No matches anywhere
|
||||
|
||||
let result = {
|
||||
documentIndex: documentIndex,
|
||||
documentPoints: documentPoints
|
||||
}
|
||||
let added = false
|
||||
|
||||
if (resultsArary.length === 0) {
|
||||
resultsArary.push(result)
|
||||
added = true
|
||||
} else {
|
||||
for (let j = 0; j < resultsArary.length; j++) {
|
||||
let thisResult = resultsArary[j]
|
||||
if (result.documentPoints > thisResult.documentPoints) {
|
||||
resultsArary.splice(j, 0, result)
|
||||
added = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if (added === false) {
|
||||
resultsArary.push(result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function buildHTML() {
|
||||
const tabs = ['All', 'Nodes', 'Concepts', 'Topics', 'Tutorials', 'Reviews', 'Books', 'Workspace']
|
||||
let HTML = ''
|
||||
HTML = HTML + '<section id="docs-search-results-div" class="docs-search-page-container">'
|
||||
HTML = HTML + UI.projects.education.spaces.docsSpace.mainSearchPage.addSearchHeader()
|
||||
|
||||
// Tabs
|
||||
HTML = HTML + '<div class="docs-search-results-header-tabs-container">'
|
||||
let checked = ' checked=""'
|
||||
for (let i = 0; i < tabs.length; i++) {
|
||||
let tab = tabs[i]
|
||||
HTML = HTML + '<input id="docs-tab' + (i + 1) + '" type="radio" name="tabs"' + checked + '><label for="docs-tab' + (i + 1) + '">' + tab + '</label>'
|
||||
checked = ''
|
||||
}
|
||||
|
||||
// Results
|
||||
HTML = HTML + '<div class="docs-search-result-content">'
|
||||
|
||||
let totalResults = new Map()
|
||||
for (let i = 0; i < tabs.length; i++) {
|
||||
let tab = tabs[i]
|
||||
HTML = HTML + '<div id="content' + (i + 1) + '">'
|
||||
HTML = HTML + '<p> ' + tab.toUpperCase() + '_TOTAL_RESULTS results (' + tab.toUpperCase() + '_TOTAL_SECONDS seconds)</p>'
|
||||
|
||||
let resultCounter = 0
|
||||
for (let j = 0; j < resultsArary.length; j++) {
|
||||
let result = resultsArary[j]
|
||||
|
||||
if (tab !== 'All') {
|
||||
if (tab.indexOf(result.documentIndex.category) < 0) {
|
||||
continue
|
||||
}
|
||||
}
|
||||
resultCounter++
|
||||
|
||||
/* Lets see if we can show a path */
|
||||
let path = ''
|
||||
if (result.documentIndex.docsSchemaDocument.nodeNameTypePath !== undefined) {
|
||||
let linkLabel
|
||||
for (let i = 0; i < result.documentIndex.docsSchemaDocument.nodeNameTypePath.length; i++) {
|
||||
let pathStep = result.documentIndex.docsSchemaDocument.nodeNameTypePath[i]
|
||||
let nodeName = pathStep[0]
|
||||
let nodeType = pathStep[1]
|
||||
let nodeProject = pathStep[2]
|
||||
let nodeId = pathStep[3]
|
||||
let link = ' > <a onClick="UI.projects.education.spaces.docsSpace.navigateTo(\'' + nodeProject + '\', \'' + result.documentIndex.category + '\', \'' + nodeType.replace(/'/g, 'AMPERSAND') + '\', ' + undefined + ' ,\'' + nodeId + '\')" class="docs-search-result-content-record-project-category-link">'
|
||||
if (nodeName === 'New ' + nodeType || nodeName === 'My ' + nodeType || nodeName === undefined) {
|
||||
nodeName = ''
|
||||
}
|
||||
if (nodeName === '') {
|
||||
linkLabel = nodeType
|
||||
} else {
|
||||
linkLabel = nodeType + ' (' + nodeName + ')'
|
||||
}
|
||||
path = path + link + linkLabel + '</a>'
|
||||
}
|
||||
}
|
||||
|
||||
HTML = HTML + '<div class="docs-search-result-content-record-container">'
|
||||
HTML = HTML + '<p class="docs-search-result-content-record-project-category">' + result.documentIndex.project + ' > ' + result.documentIndex.category + path + '</p>'
|
||||
|
||||
let mainLink = ''
|
||||
|
||||
switch (result.documentIndex.category) {
|
||||
case 'Topic': {
|
||||
HTML = HTML + '<p class="docs-search-result-content-record-topic">' + result.documentIndex.docsSchemaDocument.topic + ' - Page ' + result.documentIndex.docsSchemaDocument.pageNumber + '</p>'
|
||||
mainLink = result.documentIndex.docsSchemaDocument.type
|
||||
break
|
||||
}
|
||||
case 'Tutorial': {
|
||||
HTML = HTML + '<p class="docs-search-result-content-record-tutorial">' + result.documentIndex.docsSchemaDocument.tutorial + ' - Page ' + result.documentIndex.docsSchemaDocument.pageNumber + '</p>'
|
||||
mainLink = result.documentIndex.docsSchemaDocument.type
|
||||
break
|
||||
}
|
||||
case 'Review': {
|
||||
HTML = HTML + '<p class="docs-search-result-content-record-review">' + result.documentIndex.docsSchemaDocument.review + ' - Page ' + result.documentIndex.docsSchemaDocument.pageNumber + '</p>'
|
||||
mainLink = result.documentIndex.docsSchemaDocument.type
|
||||
break
|
||||
}
|
||||
default: {
|
||||
mainLink = result.documentIndex.docsSchemaDocument.type
|
||||
}
|
||||
}
|
||||
HTML = HTML + '<p><a onClick="UI.projects.education.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>'
|
||||
|
||||
if (result.documentIndex.docsSchemaDocument.definition !== undefined) {
|
||||
HTML = HTML + '<p class="docs-search-result-content-record-extract">' + UI.projects.education.utilities.docs.getTextBasedOnLanguage(result.documentIndex.docsSchemaDocument.definition) + '</p>'
|
||||
} else {
|
||||
HTML = HTML + '<p class="docs-search-result-content-record-extract">' + 'No definition available.' + '</p>'
|
||||
}
|
||||
HTML = HTML + '</div>'
|
||||
}
|
||||
HTML = HTML + '</div>'
|
||||
totalResults.set(tab, resultCounter)
|
||||
}
|
||||
|
||||
// End Content
|
||||
HTML = HTML + '</div>'
|
||||
HTML = HTML + '</div>'
|
||||
|
||||
// End Section
|
||||
HTML = HTML + '</section>'
|
||||
|
||||
// Total Seconds Calculation
|
||||
let finalTime = new Date()
|
||||
let totalSeconds = ((finalTime.valueOf() - initialTime.valueOf()) / 1000).toFixed(3)
|
||||
for (let i = 0; i < tabs.length; i++) {
|
||||
let tab = tabs[i]
|
||||
HTML = HTML.replace(tab.toUpperCase() + '_TOTAL_SECONDS', totalSeconds)
|
||||
resultCounter = totalResults.get(tab)
|
||||
HTML = HTML.replace(tab.toUpperCase() + '_TOTAL_RESULTS', resultCounter)
|
||||
}
|
||||
|
||||
let docsContentDiv = document.getElementById('docs-content-div')
|
||||
docsContentDiv.innerHTML = HTML + UI.projects.education.spaces.docsSpace.footer.addFooter()
|
||||
|
||||
UI.projects.education.spaces.docsSpace.mainSearchPage.detectEnterOnSearchBox()
|
||||
UI.projects.education.spaces.docsSpace.mainSearchPage.setFocusOnSearchBox()
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,711 @@
|
||||
function newEducationUtilitiesDocs() {
|
||||
let thisObject = {
|
||||
buildOrderedPageIndex: buildOrderedPageIndex,
|
||||
addWarningIfTranslationIsOutdated: addWarningIfTranslationIsOutdated,
|
||||
getTextBasedOnLanguage: getTextBasedOnLanguage,
|
||||
setTextBasedOnLanguage: setTextBasedOnLanguage,
|
||||
parseGIF: parseGIF,
|
||||
reverseParseGIF: reverseParseGIF,
|
||||
parsePNG: parsePNG,
|
||||
reverseParsePNG: reverseParsePNG,
|
||||
parseTable: parseTable,
|
||||
parseLink: parseLink,
|
||||
parseYoutube: parseYoutube,
|
||||
reverseParseLink: reverseParseLink,
|
||||
reverseParseYoutube: reverseParseYoutube,
|
||||
reverseParseHierarchy: reverseParseHierarchy,
|
||||
reverseParseTable: reverseParseTable,
|
||||
addBold: addBold,
|
||||
addKeyboard: addKeyboard,
|
||||
addCodeToCamelCase: addCodeToCamelCase,
|
||||
addCodeToWhiteList: addCodeToWhiteList,
|
||||
addItalics: addItalics,
|
||||
addToolTips: addToolTips
|
||||
}
|
||||
|
||||
const TAGGING_STRING_SEPARATOR = '~>'
|
||||
|
||||
return thisObject
|
||||
|
||||
function buildOrderedPageIndex(project, category, query) {
|
||||
let array = []
|
||||
let schemaArray
|
||||
|
||||
switch (category) {
|
||||
case 'Topic': {
|
||||
schemaArray = SCHEMAS_BY_PROJECT.get(project).array.docsTopicSchema
|
||||
break
|
||||
}
|
||||
case 'Tutorial': {
|
||||
schemaArray = SCHEMAS_BY_PROJECT.get(project).array.docsTutorialSchema
|
||||
break
|
||||
}
|
||||
case 'Review': {
|
||||
schemaArray = SCHEMAS_BY_PROJECT.get(project).array.docsReviewSchema
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < schemaArray.length; i++) {
|
||||
let arrayItem = schemaArray[i]
|
||||
|
||||
switch (category) {
|
||||
case 'Topic': {
|
||||
if (arrayItem.topic !== query) { continue }
|
||||
break
|
||||
}
|
||||
case 'Tutorial': {
|
||||
if (arrayItem.tutorial !== query) { continue }
|
||||
break
|
||||
}
|
||||
case 'Review': {
|
||||
if (arrayItem.review !== query) { continue }
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
let itemAdded = false
|
||||
if (array.length === 0) {
|
||||
array.push(arrayItem)
|
||||
itemAdded = true
|
||||
} else {
|
||||
for (let j = 0; j < array.length; j++) {
|
||||
let orderedArrayItem = array[j]
|
||||
if (Number(arrayItem.pageNumber) < Number(orderedArrayItem.pageNumber)) {
|
||||
array.splice(j, 0, arrayItem)
|
||||
itemAdded = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if (itemAdded === false) {
|
||||
array.push(arrayItem)
|
||||
}
|
||||
|
||||
}
|
||||
return array
|
||||
}
|
||||
|
||||
function addWarningIfTranslationIsOutdated(paragraph) {
|
||||
if (paragraph === undefined) { return '' }
|
||||
if (paragraph.updated === undefined) { return '' }
|
||||
if (paragraph.translations === undefined) { return '' }
|
||||
if (paragraph.translations.length === 0) { return '' }
|
||||
for (let i = 0; i < paragraph.translations.length; i++) {
|
||||
let translation = paragraph.translations[i]
|
||||
if (translation.updated === undefined) { continue }
|
||||
if (translation.language === UI.projects.education.spaces.docsSpace.language) {
|
||||
if (paragraph.updated < translation.updated) {
|
||||
return ''
|
||||
} else {
|
||||
return ' <b>Warning!!!</b> This translation is outdated. English version is... <i>' + paragraph.text + '</i> Please update this translation.'
|
||||
}
|
||||
}
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
function getTextBasedOnLanguage(paragraph) {
|
||||
if (paragraph === undefined) { return }
|
||||
if (paragraph.translations === undefined) { return paragraph.text }
|
||||
if (paragraph.translations.length === 0) { return paragraph.text }
|
||||
for (let i = 0; i < paragraph.translations.length; i++) {
|
||||
let translation = paragraph.translations[i]
|
||||
if (translation.language === UI.projects.education.spaces.docsSpace.language) { return translation.text }
|
||||
}
|
||||
return paragraph.text
|
||||
}
|
||||
|
||||
function setTextBasedOnLanguage(paragraph, text) {
|
||||
if (UI.projects.education.spaces.docsSpace.language === UI.projects.education.globals.docs.DEFAULT_LANGUAGE) {
|
||||
if (paragraph.text !== text) {
|
||||
|
||||
/* This will make the Client to save this in a file overwritting the previous version*/
|
||||
UI.projects.education.spaces.docsSpace.documentPage.docsSchemaDocument.updated = true
|
||||
|
||||
paragraph.text = text
|
||||
paragraph.updated = (new Date()).valueOf()
|
||||
|
||||
}
|
||||
return
|
||||
} else {
|
||||
/*
|
||||
We will avoid setting up a new language if the text is
|
||||
the same as the text at the default language.
|
||||
*/
|
||||
if (paragraph.text === text) {
|
||||
return
|
||||
}
|
||||
}
|
||||
if (paragraph.translations === undefined) {
|
||||
paragraph.translations = []
|
||||
}
|
||||
for (let i = 0; i < paragraph.translations.length; i++) {
|
||||
let translation = paragraph.translations[i]
|
||||
if (translation.language === UI.projects.education.spaces.docsSpace.language) {
|
||||
if (translation.text !== text) {
|
||||
|
||||
/* This will make the Client to save this in a file overwritting the previous version*/
|
||||
UI.projects.education.spaces.docsSpace.documentPage.docsSchemaDocument.updated = true
|
||||
|
||||
translation.text = text
|
||||
translation.updated = (new Date()).valueOf()
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
let translation = {
|
||||
language: UI.projects.education.spaces.docsSpace.language,
|
||||
text: text,
|
||||
updated: (new Date()).valueOf()
|
||||
}
|
||||
paragraph.translations.push(translation)
|
||||
|
||||
/* This will make the Client to save this in a file overwritting the previous version*/
|
||||
UI.projects.education.spaces.docsSpace.documentPage.docsSchemaDocument.updated = true
|
||||
return
|
||||
}
|
||||
|
||||
function parseGIF(text) {
|
||||
return '<img class="docs-gif" src="' + text + '">'
|
||||
}
|
||||
|
||||
function reverseParseGIF(HTML) {
|
||||
let result = HTML
|
||||
result = result.replace(' <img class="docs-gif" src="', '')
|
||||
result = result.replace('">', '')
|
||||
return result.trim()
|
||||
}
|
||||
|
||||
function parsePNG(text) {
|
||||
return '<img class="docs-png" src="' + text + '">'
|
||||
}
|
||||
|
||||
function reverseParsePNG(HTML) {
|
||||
let result = HTML
|
||||
result = result.replace(' <img class="docs-png" src="', '')
|
||||
result = result.replace('">', '')
|
||||
return result.trim()
|
||||
}
|
||||
|
||||
function parseTable(text) {
|
||||
let HTML = ''
|
||||
let odd = false
|
||||
/* When the text is not formatted as a table, we auto format it as a single cell table */
|
||||
if (text.indexOf('|') < 0) {
|
||||
text = "|" + text + "|"
|
||||
}
|
||||
|
||||
/* We process the text based table*/
|
||||
let rows = text.split(String.fromCharCode(10))
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
let row = rows[i]
|
||||
if (row === '') {
|
||||
if (i === rows.length - 1) {
|
||||
HTML = HTML + '</tbody>'
|
||||
}
|
||||
continue
|
||||
}
|
||||
let colums = row.split('|')
|
||||
if (i === 0) {
|
||||
HTML = HTML + '<thead>'
|
||||
}
|
||||
if (i === 1) {
|
||||
HTML = HTML + '<tbody>'
|
||||
}
|
||||
if (odd === true) {
|
||||
HTML = HTML + '<tr class="docs-info-table-alt-bg">'
|
||||
odd = false
|
||||
} else {
|
||||
HTML = HTML + '<tr>'
|
||||
odd = true
|
||||
}
|
||||
if (colums.length < 2) {
|
||||
continue
|
||||
} else {
|
||||
/* We discard anything before the first | and after the last | */
|
||||
for (let j = 1; j < colums.length - 1; j++) {
|
||||
let column = colums[j]
|
||||
column = addRGB(column)
|
||||
|
||||
if (i === 0) {
|
||||
HTML = HTML + '<th>' + column + '</th>'
|
||||
} else {
|
||||
HTML = HTML + '<td>' + column + '</td>'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HTML = HTML + '</tr>'
|
||||
if (i === 0) {
|
||||
HTML = HTML + '</thead>'
|
||||
}
|
||||
if (i === rows.length - 1) {
|
||||
HTML = HTML + '</tbody>'
|
||||
}
|
||||
}
|
||||
return HTML
|
||||
|
||||
function addRGB(text) {
|
||||
const RGB_HTML = '<div style=\"display: block; background: RGB; border: 1px solid black;\"> </div>'
|
||||
let splittedText = text.split('RGB(')
|
||||
if (splittedText.length === 1) { return text }
|
||||
let remainderSplit = splittedText[1].split(')')
|
||||
if (remainderSplit.length === 1) { return text }
|
||||
let RGBFound = 'RGB(' + remainderSplit[0] + ')'
|
||||
let span = RGB_HTML.replace('RGB', RGBFound)
|
||||
let result = text.replace(RGBFound, span)
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
function parseLink(text) {
|
||||
let HTML = ''
|
||||
let splittedText = text.split('->')
|
||||
if (splittedText.length < 1) { return }
|
||||
HTML = '<a params="' + text + '" href="http://' + splittedText[1] + '" target="_" class="docs-external-link">' + splittedText[0] + '</a>'
|
||||
return HTML
|
||||
}
|
||||
|
||||
function parseYoutube(text) {
|
||||
let HTML = ''
|
||||
|
||||
HTML = HTML + '<div params="' + text + '" class="docs-youtube-video-container">'
|
||||
HTML = HTML + '<iframe width="830" height="465" src="https://www.youtube.com/embed/' + text + '" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>'
|
||||
HTML = HTML + '</div>'
|
||||
|
||||
return HTML
|
||||
}
|
||||
|
||||
function reverseParseLink(HTML) {
|
||||
let splittedHTML = HTML.split('"')
|
||||
return splittedHTML[1]
|
||||
}
|
||||
|
||||
function reverseParseYoutube(HTML) {
|
||||
let splittedHTML = HTML.split('"')
|
||||
return splittedHTML[1]
|
||||
}
|
||||
|
||||
function reverseParseHierarchy(HTML) {
|
||||
let splittedHTML = HTML.split('"')
|
||||
return splittedHTML[3]
|
||||
}
|
||||
|
||||
function reverseParseTable(paragraphNode) {
|
||||
|
||||
let tableNode = paragraphNode.childNodes[0]
|
||||
let thead
|
||||
let tbody
|
||||
let result = ''
|
||||
|
||||
for (let i = 0; i < tableNode.childNodes.length; i++) {
|
||||
let childNode = tableNode.childNodes[i]
|
||||
if (childNode.nodeName === "THEAD") {
|
||||
thead = childNode
|
||||
}
|
||||
if (childNode.nodeName === "TBODY") {
|
||||
tbody = childNode
|
||||
}
|
||||
}
|
||||
if (thead !== undefined) { processTRs(thead) }
|
||||
if (tbody !== undefined) { processTRs(tbody) }
|
||||
|
||||
function processTRs(TRs) {
|
||||
for (let i = 0; i < TRs.childNodes.length; i++) {
|
||||
let TR = TRs.childNodes[i]
|
||||
for (let j = 0; j < TR.childNodes.length; j++) {
|
||||
let TD = TR.childNodes[j]
|
||||
if (TD.innerText.trim() === "") {
|
||||
let RGB = removeRGB(TD.innerHTML)
|
||||
result = result + '|' + RGB
|
||||
} else {
|
||||
result = result + '|' + TD.innerText
|
||||
}
|
||||
}
|
||||
result = result + '|'
|
||||
}
|
||||
}
|
||||
|
||||
/* We break lines where needed */
|
||||
result = result.replaceAll('||', '|' + String.fromCharCode(10) + '|')
|
||||
return result.trim()
|
||||
|
||||
function removeRGB(HTML) {
|
||||
let text = HTML
|
||||
text = text.replaceAll('<div style="display: block; background: ', '')
|
||||
text = text.replaceAll('; border: 1px solid black;"> </div>', '')
|
||||
text = text.replaceAll(' ', '')
|
||||
return text.trim()
|
||||
}
|
||||
}
|
||||
|
||||
function addBold(text) {
|
||||
let splittedText = text.split(':')
|
||||
if (text.indexOf(':') >= 0) {
|
||||
return '<b>' + text.substring(0, text.indexOf(':') + 1) + '</b>' + text.substring(text.indexOf(':') + 1, text.length)
|
||||
} else {
|
||||
return text
|
||||
}
|
||||
}
|
||||
|
||||
function addKeyboard(text) {
|
||||
let expandedText = text
|
||||
.replaceAll('{', ' { ')
|
||||
.replaceAll('}', ' } ')
|
||||
.replaceAll('(', ' ( ')
|
||||
.replaceAll(')', ' ) ')
|
||||
.replaceAll('[', ' [ ')
|
||||
.replaceAll(']', ' ] ')
|
||||
.replaceAll(',', ' , ')
|
||||
.replaceAll('.', ' . ')
|
||||
let splittedText = expandedText.split(' ')
|
||||
let result = ''
|
||||
for (let i = 0; i < splittedText.length; i++) {
|
||||
let word = splittedText[i]
|
||||
if (
|
||||
word === 'Ctrl' ||
|
||||
word === 'Alt' ||
|
||||
word === 'Shift' ||
|
||||
word === 'Cmd' ||
|
||||
word === 'F1' ||
|
||||
word === 'F2' ||
|
||||
word === 'F3' ||
|
||||
word === 'F4' ||
|
||||
word === 'F5' ||
|
||||
word === 'F6' ||
|
||||
word === 'F7' ||
|
||||
word === 'F8' ||
|
||||
word === 'F9' ||
|
||||
word === 'F10' ||
|
||||
word === 'F11' ||
|
||||
word === 'F12' ||
|
||||
word === 'Del' ||
|
||||
word === '←' ||
|
||||
word === '→' ||
|
||||
word === '↑' ||
|
||||
word === '↓' ||
|
||||
word === 'Key-A' ||
|
||||
word === 'Key-B' ||
|
||||
word === 'Key-C' ||
|
||||
word === 'Key-D' ||
|
||||
word === 'Key-E' ||
|
||||
word === 'Key-F' ||
|
||||
word === 'Key-G' ||
|
||||
word === 'Key-H' ||
|
||||
word === 'Key-I' ||
|
||||
word === 'Key-J' ||
|
||||
word === 'Key-K' ||
|
||||
word === 'Key-L' ||
|
||||
word === 'Key-M' ||
|
||||
word === 'Key-N' ||
|
||||
word === 'Key-O' ||
|
||||
word === 'Key-P' ||
|
||||
word === 'Key-Q' ||
|
||||
word === 'Key-R' ||
|
||||
word === 'Key-S' || // S
|
||||
word === 'Key-T' ||
|
||||
word === 'Key-U' ||
|
||||
word === 'Key-V' ||
|
||||
word === 'Key-W' ||
|
||||
word === 'Key-X' ||
|
||||
word === 'Key-Y' ||
|
||||
word === 'Key-Z'
|
||||
) {
|
||||
word = '<kbd>' + word + '</kbd>'
|
||||
}
|
||||
if (i === 0) {
|
||||
result = word
|
||||
} else {
|
||||
result = result + ' ' + word
|
||||
}
|
||||
}
|
||||
result = result
|
||||
.replaceAll(' { ', '{')
|
||||
.replaceAll(' } ', '}')
|
||||
.replaceAll(' ( ', '(')
|
||||
.replaceAll(' ) ', ')')
|
||||
.replaceAll(' [ ', '[')
|
||||
.replaceAll(' ] ', ']')
|
||||
.replaceAll(' , ', ',')
|
||||
.replaceAll(' . ', '.')
|
||||
return result.trim()
|
||||
}
|
||||
|
||||
function addCodeToCamelCase(text) {
|
||||
let expandedText = text
|
||||
.replaceAll('{', ' { ')
|
||||
.replaceAll('}', ' } ')
|
||||
.replaceAll('(', ' ( ')
|
||||
.replaceAll(')', ' ) ')
|
||||
.replaceAll('[', ' [ ')
|
||||
.replaceAll(']', ' ] ')
|
||||
.replaceAll(',', ' , ')
|
||||
let splittedText = expandedText.split(' ')
|
||||
let result = ''
|
||||
for (let i = 0; i < splittedText.length; i++) {
|
||||
let word = splittedText[i]
|
||||
if (UI.projects.foundations.utilities.strings.isCamelCase(word) === true) {
|
||||
word = '<code class="docs-code">' + word + '</code>'
|
||||
}
|
||||
if (i === 0) {
|
||||
result = word
|
||||
} else {
|
||||
result = result + ' ' + word
|
||||
}
|
||||
}
|
||||
result = result
|
||||
.replaceAll(' { ', '{')
|
||||
.replaceAll(' } ', '}')
|
||||
.replaceAll(' ( ', '(')
|
||||
.replaceAll(' ) ', ')')
|
||||
.replaceAll(' [ ', '[')
|
||||
.replaceAll(' ] ', ']')
|
||||
.replaceAll(' , ', ',')
|
||||
return result
|
||||
}
|
||||
|
||||
function addCodeToWhiteList(text) {
|
||||
let result = text
|
||||
.replaceAll('true', '<code class="docs-code">true</code>')
|
||||
.replaceAll('false', '<code class="docs-code">false</code>')
|
||||
return result
|
||||
}
|
||||
|
||||
function addItalics(text) {
|
||||
let cleanText = text.replace(/'/g, ' AMPERSAND ') // scaping ampersands, separating them from other words
|
||||
let words = cleanText.split(' ')
|
||||
let changedText = ''
|
||||
for (let i = 0; i < words.length; i++) {
|
||||
let phrase1 = words[i]
|
||||
let phrase2 = words[i] + ' ' + words[i + 1]
|
||||
let phrase3 = words[i] + ' ' + words[i + 1] + ' ' + words[i + 2]
|
||||
let phrase4 = words[i] + ' ' + words[i + 1] + ' ' + words[i + 2] + ' ' + words[i + 3]
|
||||
|
||||
let cleanPhrase1 = cleanPhrase(phrase1)
|
||||
let cleanPhrase2 = cleanPhrase(phrase2)
|
||||
let cleanPhrase3 = cleanPhrase(phrase3)
|
||||
let cleanPhrase4 = cleanPhrase(phrase4)
|
||||
|
||||
let found = false
|
||||
|
||||
if (found === false && UI.projects.education.spaces.docsSpace.menuLabelsMap.get(cleanPhrase4) === true) {
|
||||
changedText = changedText + phrase4.replace(cleanPhrase4, '<i>' + cleanPhrase4 + '</i>') + ' '
|
||||
i = i + 3
|
||||
found = true
|
||||
}
|
||||
|
||||
if (found === false && UI.projects.education.spaces.docsSpace.menuLabelsMap.get(cleanPhrase3) === true) {
|
||||
changedText = changedText + phrase3.replace(cleanPhrase3, '<i>' + cleanPhrase3 + '</i>') + ' '
|
||||
i = i + 2
|
||||
found = true
|
||||
}
|
||||
|
||||
if (found === false && UI.projects.education.spaces.docsSpace.menuLabelsMap.get(cleanPhrase2) === true) {
|
||||
changedText = changedText + phrase2.replace(cleanPhrase2, '<i>' + cleanPhrase2 + '</i>') + ' '
|
||||
i = i + 1
|
||||
found = true
|
||||
}
|
||||
|
||||
if (found === false && UI.projects.education.spaces.docsSpace.menuLabelsMap.get(cleanPhrase1) === true) {
|
||||
changedText = changedText + phrase1.replace(cleanPhrase1, '<i>' + cleanPhrase1 + '</i>') + ' '
|
||||
i = i + 0
|
||||
found = true
|
||||
}
|
||||
|
||||
if (found === false) {
|
||||
changedText = changedText + phrase1 + ' '
|
||||
}
|
||||
}
|
||||
changedText = changedText.replaceAll(' AMPERSAND ', '\'')
|
||||
return changedText
|
||||
}
|
||||
|
||||
function addToolTips(text, excludedType) {
|
||||
|
||||
const TOOL_TIP_HTML = '<div onClick="UI.projects.education.spaces.docsSpace.navigateTo(\'PROJECT\', \'CATEGORY\', \'TYPE\')" class="docs-tooltip">TYPE_LABEL<span class="docs-tooltiptext">DEFINITION</span></div>'
|
||||
const LINK_ONLY_HTML = '<div onClick="UI.projects.education.spaces.docsSpace.navigateTo(\'PROJECT\', \'CATEGORY\', \'TYPE\')" class="docs-link">TYPE_LABEL<span class="docs-tooltiptext"></span></div>'
|
||||
|
||||
let resultingText = ''
|
||||
text = tagDefinedTypes(text, excludedType)
|
||||
let splittedText = text.split(TAGGING_STRING_SEPARATOR)
|
||||
|
||||
for (let i = 0; i < splittedText.length; i = i + 2) {
|
||||
let firstPart = splittedText[i]
|
||||
let taggedText = splittedText[i + 1]
|
||||
|
||||
if (taggedText === undefined) {
|
||||
return resultingText + firstPart
|
||||
}
|
||||
|
||||
let splittedTaggedText = taggedText.split('|')
|
||||
let category = splittedTaggedText[0]
|
||||
let type = splittedTaggedText[1]
|
||||
let project = splittedTaggedText[2]
|
||||
|
||||
/*
|
||||
We will search across all DOC SCHEMAS
|
||||
*/
|
||||
let found = false
|
||||
let docsSchemaDocument
|
||||
|
||||
for (let j = 0; j < PROJECTS_SCHEMA.length; j++) {
|
||||
let project = PROJECTS_SCHEMA[j].name
|
||||
docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsNodeSchema.get(type)
|
||||
if (docsSchemaDocument !== undefined) {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsConceptSchema.get(type)
|
||||
if (docsSchemaDocument !== undefined) {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsTopicSchema.get(type)
|
||||
if (docsSchemaDocument !== undefined) {
|
||||
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.docsReviewSchema.get(type)
|
||||
if (docsSchemaDocument !== undefined) {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
docsSchemaDocument = SCHEMAS_BY_PROJECT.get(project).map.docsBookSchema.get(type)
|
||||
if (docsSchemaDocument !== undefined) {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if (found === false) {
|
||||
return text
|
||||
}
|
||||
|
||||
let definition = UI.projects.education.utilities.docs.getTextBasedOnLanguage(docsSchemaDocument.definition)
|
||||
if (definition === undefined || definition === "") {
|
||||
let tooltip = LINK_ONLY_HTML
|
||||
.replace('CATEGORY', category)
|
||||
.replace('TYPE', type.replace(/'/g, 'AMPERSAND'))
|
||||
.replace('PROJECT', project)
|
||||
.replace('TYPE_LABEL', type)
|
||||
|
||||
resultingText = resultingText + firstPart + tooltip
|
||||
} else {
|
||||
let tooltip = TOOL_TIP_HTML
|
||||
.replace('CATEGORY', category)
|
||||
.replace('TYPE', type.replace(/'/g, 'AMPERSAND'))
|
||||
.replace('PROJECT', project)
|
||||
.replace('TYPE_LABEL', type)
|
||||
.replace('DEFINITION', definition)
|
||||
|
||||
resultingText = resultingText + firstPart + tooltip
|
||||
}
|
||||
}
|
||||
return resultingText
|
||||
}
|
||||
|
||||
/* Private Functions follow */
|
||||
function tagDefinedTypes(text, excludedType) {
|
||||
const MAX_NUMBER_OF_WORDS = 10
|
||||
text = text.trim()
|
||||
let cleanText = text.replace(/'/g, ' AMPERSAND ') // scaping ampersands, separating them from other words
|
||||
.replaceAll(':', ' :')
|
||||
.replaceAll(',', ' ,')
|
||||
.replaceAll('.', ' .')
|
||||
.replaceAll('!', ' !')
|
||||
let allWords = cleanText.split(' ')
|
||||
let words = []
|
||||
for (let i = 0; i < allWords.length; i++) {
|
||||
let word = allWords[i]
|
||||
if (word !== "") {
|
||||
words.push(word)
|
||||
}
|
||||
}
|
||||
let taggedText = ''
|
||||
for (let i = 0; i < words.length; i++) {
|
||||
|
||||
let phrases = []
|
||||
let cleanPhrases = []
|
||||
let phrase = ''
|
||||
|
||||
for (let j = 0; j < MAX_NUMBER_OF_WORDS; j++) {
|
||||
let word = words[i + j]
|
||||
if (word === "") { word = " " }
|
||||
if (word !== undefined) {
|
||||
if (phrase === '') {
|
||||
phrase = word
|
||||
} else {
|
||||
phrase = phrase + ' ' + word
|
||||
}
|
||||
if (phrase === undefined) { continue }
|
||||
phrases.push(phrase)
|
||||
cleanPhrases.push(cleanPhrase(phrase))
|
||||
}
|
||||
}
|
||||
|
||||
let found = false
|
||||
|
||||
for (let j = MAX_NUMBER_OF_WORDS - 1; j >= 0; j--) {
|
||||
for (let p = 0; p < PROJECTS_SCHEMA.length; p++) {
|
||||
let project = PROJECTS_SCHEMA[p].name
|
||||
|
||||
searchInSchema(SCHEMAS_BY_PROJECT.get(project).map.docsNodeSchema, 'Node')
|
||||
searchInSchema(SCHEMAS_BY_PROJECT.get(project).map.docsConceptSchema, 'Concept')
|
||||
searchInSchema(SCHEMAS_BY_PROJECT.get(project).map.docsTopicSchema, 'Topic')
|
||||
searchInSchema(SCHEMAS_BY_PROJECT.get(project).map.docsTutorialSchema, 'Tutorial')
|
||||
searchInSchema(SCHEMAS_BY_PROJECT.get(project).map.docsReviewSchema, 'Review')
|
||||
searchInSchema(SCHEMAS_BY_PROJECT.get(project).map.docsBookSchema, 'Book')
|
||||
|
||||
function searchInSchema(docSchema, category) {
|
||||
if (found === true) { return }
|
||||
|
||||
if (docSchema.get(cleanPhrases[j]) !== undefined) {
|
||||
if (cleanPhrases[j] !== excludedType) {
|
||||
taggedText = taggedText + phrases[j].replace(
|
||||
cleanPhrases[j],
|
||||
TAGGING_STRING_SEPARATOR + category + '|' + cleanPhrases[j] + '|' + project + TAGGING_STRING_SEPARATOR) + ' '
|
||||
} else {
|
||||
taggedText = taggedText + phrases[j] + ' '
|
||||
}
|
||||
i = i + j
|
||||
found = true
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (found === false) {
|
||||
taggedText = taggedText + phrases[0] + ' '
|
||||
}
|
||||
}
|
||||
taggedText = taggedText.replaceAll(' AMPERSAND ', '\'')
|
||||
.replaceAll(' :', ':')
|
||||
.replaceAll(' .', '.')
|
||||
.replaceAll(' ,', ',')
|
||||
.replaceAll(' !', '!')
|
||||
.replaceAll(' ', ' ')
|
||||
return taggedText
|
||||
}
|
||||
|
||||
function cleanPhrase(phrase) {
|
||||
return phrase.replace(',', '')
|
||||
.replace(';', '')
|
||||
.replace('(', '')
|
||||
.replace(')', '')
|
||||
.replace('_', '')
|
||||
.replace('.', '')
|
||||
.replace('[', '')
|
||||
.replace(']', '')
|
||||
.replace('{', '')
|
||||
.replace('}', '')
|
||||
.replace('/', '')
|
||||
.replace('>', '')
|
||||
.replace('<', '')
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
function newEducationUtilitiesLanguages() {
|
||||
let thisObject = {
|
||||
getLaguageLabel: getLaguageLabel
|
||||
}
|
||||
|
||||
return thisObject
|
||||
|
||||
function getLaguageLabel(language) {
|
||||
let languageLabel
|
||||
switch (language) {
|
||||
case 'EN': {
|
||||
languageLabel = 'English'
|
||||
break
|
||||
}
|
||||
case 'ES': {
|
||||
languageLabel = 'Spanish'
|
||||
break
|
||||
}
|
||||
case 'RU': {
|
||||
languageLabel = 'Russian'
|
||||
break
|
||||
}
|
||||
case 'IT': {
|
||||
languageLabel = 'Italian'
|
||||
break
|
||||
}
|
||||
case 'DE': {
|
||||
languageLabel = 'German'
|
||||
break
|
||||
}
|
||||
case 'FR': {
|
||||
languageLabel = 'French'
|
||||
break
|
||||
}
|
||||
case 'CN': {
|
||||
languageLabel = 'Simplified Chinese-Mandarin'
|
||||
break
|
||||
}
|
||||
case 'ID': {
|
||||
languageLabel = 'Bahasa'
|
||||
break
|
||||
}
|
||||
case 'TR': {
|
||||
languageLabel = 'Turkish'
|
||||
break
|
||||
}
|
||||
}
|
||||
return languageLabel
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user