From 7b96fa671729e14a261817dd062e396fc36be39e Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Sat, 5 Sep 2020 18:38:04 +0200 Subject: [PATCH] Update TutorialSpace.js --- Spaces/TutorialSpace.js | 140 +++++++++++++++++++++++++++++++--------- 1 file changed, 109 insertions(+), 31 deletions(-) diff --git a/Spaces/TutorialSpace.js b/Spaces/TutorialSpace.js index 143888223..547419a96 100644 --- a/Spaces/TutorialSpace.js +++ b/Spaces/TutorialSpace.js @@ -1,18 +1,15 @@ function newTutorialSpace() { const MODULE_NAME = 'Tutorial Space' let thisObject = { + stop: stop, + skip: skip, + done: done, playTutorial: playTutorial, resumeTutorial: resumeTutorial, - stopTutorial: stopTutorial, playTutorialTopic: playTutorialTopic, resumeTutorialTopic: resumeTutorialTopic, - stopTutorialTopic: stopTutorialTopic, playTutorialStep: playTutorialStep, resumeTutorialStep: resumeTutorialStep, - stopTutorialStep: stopTutorialStep, - skipTutorialTopic: skipTutorialTopic, - skipTutorialStep: skipTutorialStep, - tutorialDone: tutorialDone, tutorialTopicDone: tutorialTopicDone, tutorialStepDone: tutorialStepDone, resetTutorialProgress: resetTutorialProgress, @@ -41,9 +38,11 @@ function newTutorialSpace() { let currentTutorialNode let currentTutorialTopicNode let currentTutorialStepNode + let currentNode let currentStatus = 'Stopped' - let docAppDiv = document.getElementById('tutorialStepDiv') + let tutorialDiv = document.getElementById('tutorialDiv') + let tutorialFormDiv = document.getElementById('tutorialFormDiv') return thisObject @@ -58,8 +57,9 @@ function newTutorialSpace() { currentTutorialNode = undefined currentTutorialTopicNode = undefined currentTutorialStepNode = undefined + currentNode = undefined - docAppDiv = undefined + tutorialDiv = undefined } function resize() { @@ -93,41 +93,60 @@ function newTutorialSpace() { function makeInvisible() { const HEIGHT = 0 const WIDTH = 0 + const FORM_HEIGHT = 0 tutorialPosition = { x: 100000, y: 100000 } - docAppDiv.style = ' ' + + tutorialDiv.style = ' ' + 'position:fixed; top:' + tutorialPosition.y + 'px; ' + 'left:' + tutorialPosition.x + 'px; ' + 'width: ' + WIDTH + 'px;' + 'height: ' + HEIGHT + 'px;' + 'z-index:1;' + + tutorialFormDiv.style = ' ' + + 'position:fixed; top:' + (tutorialPosition.y) + 'px; ' + + 'left:' + tutorialPosition.x + 'px; ' + + 'width: ' + WIDTH + 'px;' + + 'height: ' + FORM_HEIGHT + 'px;' + + 'z-index:1;' } function makeVsible() { const HEIGHT = 800 const WIDTH = 500 const MARGIN = 300 + const FORM_HEIGHT = 80 tutorialPosition = { x: MARGIN, y: (browserCanvas.height - HEIGHT) / 2 } - docAppDiv.style = ' ' + + tutorialDiv.style = ' ' + 'position:fixed; top:' + tutorialPosition.y + 'px; ' + 'left:' + tutorialPosition.x + 'px; ' + 'width: ' + WIDTH + 'px;' + 'height: ' + HEIGHT + 'px;' + 'z-index:1;' + + buildHTML() + + tutorialFormDiv.style = ' ' + + 'position:fixed; top:' + (tutorialPosition.y + HEIGHT - FORM_HEIGHT) + 'px; ' + + 'left:' + tutorialPosition.x + 'px; ' + + 'width: ' + WIDTH + 'px;' + + 'height: ' + FORM_HEIGHT + 'px;' + + 'z-index:1;' } } function playTutorial(node) { currentTutorialNode = node + currentNode = node currentStatus = 'Playing Tutorial' } @@ -135,13 +154,22 @@ function newTutorialSpace() { } - function stopTutorial() { + function stop() { currentTutorialNode = undefined currentTutorialTopicNode = undefined currentTutorialStepNode = undefined currentStatus = 'Stopped' } + + function skip() { + + } + + function done() { + + } + function playTutorialTopic(node) { } @@ -150,10 +178,6 @@ function newTutorialSpace() { } - function stopTutorialTopic() { - - } - function playTutorialStep(node) { } @@ -162,22 +186,6 @@ function newTutorialSpace() { } - function stopTutorialStep() { - - } - - function skipTutorialTopic() { - - } - - function skipTutorialStep() { - - } - - function tutorialDone() { - - } - function tutorialTopicDone() { } @@ -190,6 +198,76 @@ function newTutorialSpace() { } + function buildHTML() { + + let nodeConfig = JSON.parse(currentNode.config) + let html = '' + if (nodeConfig.title !== undefined && nodeConfig.title !== '') { + html = html + '

' + nodeConfig.title + '

' + } + html = html + '
' + if (nodeConfig.summary !== undefined && nodeConfig.summary !== '') { + html = html + '
' + nodeConfig.summary + '
' + } + if (nodeConfig.subTitle !== undefined && nodeConfig.subTitle !== '') { + html = html + '

' + nodeConfig.subTitle + '

' + } + if (nodeConfig.definition !== undefined && nodeConfig.definition !== '') { + html = html + '' + html = html + '' + html = html + '' + html = html + '' + html = html + '' + html = html + '
' + if (nodeConfig.image !== undefined && nodeConfig.image !== '') { + html = html + '' + } + html = html + '' + html = html + '' + nodeConfig.definition + '' + html = html + '
' + } + if (nodeConfig.bulletListIntro !== undefined && nodeConfig.bulletListIntro !== '') { + html = html + '

' + nodeConfig.bulletListIntro + '

' + } + if (nodeConfig.bulletArray !== undefined) { + html = html + '' + } + if (nodeConfig.paragraph1 !== undefined && nodeConfig.paragraph1 !== '') { + html = html + '

' + nodeConfig.paragraph1 + '

' + } + if (nodeConfig.callOut !== undefined && nodeConfig.callOut !== '') { + html = html + '
' + nodeConfig.callOut + '
' + } + if (nodeConfig.paragraph2 !== undefined && nodeConfig.paragraph2 !== '') { + html = html + '

' + nodeConfig.paragraph2 + '

' + } + if (nodeConfig.paragraph2 !== undefined && nodeConfig.paragraph2 !== '') { + html = html + '

' + nodeConfig.paragraph2 + '

' + } + if (nodeConfig.note !== undefined && nodeConfig.note !== '') { + html = html + '' + } + if (nodeConfig.tip !== undefined && nodeConfig.tip !== '') { + html = html + '' + } + if (nodeConfig.important !== undefined && nodeConfig.important !== '') { + html = html + '' + } + if (nodeConfig.warning !== undefined && nodeConfig.warning !== '') { + html = html + '' + } + html = html + '
' + + tutorialDiv.innerHTML = html + } + function draw() { if (isInitialized === false) { return } }