diff --git a/src/adonisjs/public/author/js/author.js b/src/adonisjs/public/author/js/author.js index 46555a672..0738865e7 100644 --- a/src/adonisjs/public/author/js/author.js +++ b/src/adonisjs/public/author/js/author.js @@ -289,7 +289,7 @@ class AuthorManager { async _caseLoad (caseId) { Basic.service.currentCaseId = caseId - const caseObj = await MessageBus.i.request('data/case/' + caseId + '/get', null, null, true) + const caseObj = await MessageBus.i.request('case/get/' + caseId, null, null, true) this._currentCaseTitle = caseObj.message.title await this._compile(caseObj.message.source) @@ -542,7 +542,7 @@ class AuthorManager { Comments.prepare(this._compiledCase, knotid) if (Panels.s.commentsVisible) MessageBus.i.publish('control/comments/editor') - MessageBus.i.publish('control/case/ready', null, true) + MessageBus.i.publish('case/ready/' + Basic.service.currentCaseId, null, true) } } diff --git a/src/adonisjs/public/author/js/draft.js b/src/adonisjs/public/author/js/draft.js index 720dbf061..7f1eb43b1 100644 --- a/src/adonisjs/public/author/js/draft.js +++ b/src/adonisjs/public/author/js/draft.js @@ -231,7 +231,7 @@ class DraftManager { } async downloadCase (topic, message) { - const caseObj = await MessageBus.i.request('data/case/' + message + '/get', null, null, true) + const caseObj = await MessageBus.i.request('case/get/' + message, null, null, true) Basic.service.downloadFile( caseObj.message.source, caseObj.message.title + '.md') } diff --git a/src/adonisjs/public/context/playground/js/versum-context.js b/src/adonisjs/public/context/playground/js/versum-context.js index b15356469..110052fb4 100644 --- a/src/adonisjs/public/context/playground/js/versum-context.js +++ b/src/adonisjs/public/context/playground/js/versum-context.js @@ -16,7 +16,7 @@ class VersumContextManager { this.updateVisibility = this.updateVisibility.bind(this) MessageBus.i.subscribe('control/translate/example', this.translate) - MessageBus.i.subscribe('var/output/changed', this.updateVisibility) + MessageBus.i.subscribe('input/changed/output', this.updateVisibility) } async translate (topic, message) { diff --git a/src/adonisjs/public/dccs/components/control/dcc-compute.js b/src/adonisjs/public/dccs/components/control/dcc-compute.js index 78bcdeee6..62a15f803 100644 --- a/src/adonisjs/public/dccs/components/control/dcc-compute.js +++ b/src/adonisjs/public/dccs/components/control/dcc-compute.js @@ -19,7 +19,7 @@ class DCCCompute extends DCCBase { if (this.active) { const variables = DCCCompute.filterVariables(this._compiled, false) for (let v of variables) - this._subscribe('var/' + v + '/set', this.update) + this._subscribe('var/set/' + v.replace(/\./g, '/'), this.update) } } } @@ -70,7 +70,7 @@ class DCCCompute extends DCCBase { this.update() } - async update() { + async update () { const result = await DCCCompute.computeExpression(this._compiled, this._bus) if (result) await this.multiRequest('true', null) @@ -101,9 +101,9 @@ class DCCCompute extends DCCBase { case 'divert-script': let message if (expression.target.startsWith('Case.')) - { message = 'case/' + expression.target.substring(5) + '/navigate' } + { message = 'case/navigate/' + expression.target.substring(5) } else - { message = 'knot/' + expression.target + '/navigate' } + { message = 'knot/navigate/' + expression.target.replace(/\./g, '/') } let cBus = (bus != null) ? bus : MessageBus.i if (expression.parameter) { bus.publish(message, expression.parameter, true) @@ -227,7 +227,8 @@ class DCCCompute extends DCCBase { if (s[0] != null) { result = DCCCompute.computeCompiled(s[1]) let cBus = (bus != null) ? bus : MessageBus.i - await cBus.request('var/' + s[0] + '/set', result, null, true) + await cBus.request('var/set/' + s[0].replace(/\./g, '/'), + result, null, true) } else if (compiledSet.length == 1) { result = DCCCompute.computeCompiled(s[1]) // looks for a variable inside the expression @@ -235,7 +236,7 @@ class DCCCompute extends DCCBase { if (autoAssign) { let variable = s[1].find(el => el[0] == 3) if (variable) - await this._request('var/' + variable[1] + '/set', result, null, true) + await this._request('var/set/' + variable[1].replace(/\./g, '/'), result, null, true) } */ } @@ -269,8 +270,9 @@ class DCCCompute extends DCCBase { for (let c of compiled) if (c[0] == DCCCompute.role.variable) { let cBus = (bus != null) ? bus : MessageBus.i - if (cBus.hasSubscriber('var/' + c[1] + '/get')) { - const mess = await cBus.request('var/' + c[1] + '/get', null, null, true) + if (cBus.hasSubscriber('var/get/' + c[1].replace(/\./g, '/'), true)) { + const mess = await cBus.request('var/get/' + c[1].replace(/\./g, '/'), + null, null, true) if (mess.message != null) { const value = (mess.message.body != null) ? mess.message.body : mess.message diff --git a/src/adonisjs/public/dccs/components/data/dcc-submit.js b/src/adonisjs/public/dccs/components/data/dcc-submit.js index 108c6fb69..bc3d8e2e9 100644 --- a/src/adonisjs/public/dccs/components/data/dcc-submit.js +++ b/src/adonisjs/public/dccs/components/data/dcc-submit.js @@ -41,7 +41,7 @@ class DCCSubmit extends DCCButton { const topic = (this.hasAttribute('topic')) ? this.topic : (this.hasAttribute('variable')) - ? 'var/' + this.variable + '/changed' + ? 'input/changed/' + this.variable.replace(/\./g, '/') : 'button/' + this.label + '/clicked' if (this.hasAttribute('message')) { message.value = this.message } let form = null diff --git a/src/adonisjs/public/dccs/components/visual/dcc-button.js b/src/adonisjs/public/dccs/components/visual/dcc-button.js index 053be7b1f..0bcbe4c17 100644 --- a/src/adonisjs/public/dccs/components/visual/dcc-button.js +++ b/src/adonisjs/public/dccs/components/visual/dcc-button.js @@ -16,9 +16,11 @@ class DCCButton extends DCCBlock { connectedCallback () { super.connectedCallback() - if (this.hasAttribute('topic') && this.topic.endsWith('/navigate')) { + if (this.hasAttribute('topic') && + MessageBus.extractLevel(this.topic, 2) == 'navigate') { this.navigationBlocked = this.navigationBlocked.bind(this) - this._subscribe('+/+/navigate/blocked', this.navigationBlocked) + this._subscribe(MessageBus.extractLevelsSegment(this.topic, 1, 2) + '/!', + this.navigationBlocked) } this._publish('control/button/' + @@ -153,10 +155,12 @@ class DCCButton extends DCCBlock { const v = (this.variable.includes(':')) ? this.variable.substring(0, this.variable.indexOf(':')) : this.variable message.value = (this.variable.endsWith(':label')) ? this.label : this.message - this._publish('var/' + v + '/changed', message, true) + this._publish('input/changed/' + v.replace(/\./g, '/'), message, true) } if (this.hasAttribute('label') || this.hasAttribute('topic')) { - if (this.hasAttribute('topic') && this.topic.endsWith('/navigate')) { this._active = false } + if (this.hasAttribute('topic') && + MessageBus.extractLevel(this.topic, 2) == 'navigate') + this._active = false const topic = (this.hasAttribute('topic')) ? this.topic : 'button/' + this.label + '/clicked' if (this.hasAttribute('message')) { message.value = this.message } diff --git a/src/adonisjs/public/dccs/components/visual/dcc-expression.js b/src/adonisjs/public/dccs/components/visual/dcc-expression.js index a201e98c8..a55e3ab05 100644 --- a/src/adonisjs/public/dccs/components/visual/dcc-expression.js +++ b/src/adonisjs/public/dccs/components/visual/dcc-expression.js @@ -34,7 +34,7 @@ class DCCExpression extends DCCVisual { // also monitors all messages if (this.active) { this.stateChanged = this.stateChanged.bind(this) - this._subscribe('var/+/state_changed', this.stateChanged) + this._subscribe('input/state/#', this.stateChanged) this._stateValues = {} } @@ -47,10 +47,10 @@ class DCCExpression extends DCCVisual { if (this.active) { this.variableUpdated = this.variableUpdated.bind(this) const variables = DCCCompute.filterVariables(this._compiled, false) - // this._subscribe(// 'var/' + this._variable + '/set', this.variableUpdated) - this._subscribe('var/*/set', this.variableUpdated) + this._subscribe('var/set/*', this.variableUpdated) for (let v of variables) - this._subscribe('var/' + v + '/set', this.variableUpdated) + this._subscribe('var/set/' + v.replace(/\./g, '/'), + this.variableUpdated) } } } @@ -66,7 +66,6 @@ class DCCExpression extends DCCVisual { async _showResult () { let result = await DCCCompute.computeExpression(this._compiled) - // let result = await this._request('var/' + this._variable + '/get', null, null, true) if (result == null) { result = '' } else { @@ -139,7 +138,7 @@ class DCCExpression extends DCCVisual { } stateChanged (topic, message) { - const id = MessageBus.extractLevel(topic, 2) + const id = MessageBus.extractLevelsSegment(topic, 3).replace(/\//g, '.') if (id.startsWith(this._variable)) { const subid = id.substring(this._variable.length + 1) diff --git a/src/adonisjs/public/dccs/components/visual/dcc-image-marker.js b/src/adonisjs/public/dccs/components/visual/dcc-image-marker.js index 275d5b6e0..f9dd7a245 100644 --- a/src/adonisjs/public/dccs/components/visual/dcc-image-marker.js +++ b/src/adonisjs/public/dccs/components/visual/dcc-image-marker.js @@ -123,7 +123,7 @@ class DCCGroupMarker extends DCCBase { this._subscribe('dcc/marker-spot/set', this.setMarkerSpot) this._subscribe('dcc/marker-spot/selected', this.spotSelected) - this._publish('var/' + this.context + '/group_input/ready', + this._publish('input/ready/ + xlink:href="[image]"/> ` diff --git a/src/adonisjs/public/dccs/components/visual/dcc-input-choice.js b/src/adonisjs/public/dccs/components/visual/dcc-input-choice.js index f38a7b96b..fb98ec306 100644 --- a/src/adonisjs/public/dccs/components/visual/dcc-input-choice.js +++ b/src/adonisjs/public/dccs/components/visual/dcc-input-choice.js @@ -27,7 +27,7 @@ class DCCInputOption extends DCCInput { // align with dcc-state-select if (this._parent == null) { - this._publish('var/' + this._variable + '/input/ready', + this._publish('input/ready/' + this._variable.replace(/\./g, '/'), { sourceType: DCCInputOption.elementTag, content: this.value @@ -100,7 +100,7 @@ class DCCInputOption extends DCCInput { inputChanged () { this.changed = true - this._publish('var/' + this._variable + '/changed', + this._publish('input/changed/' + this._variable.replace(/\./g, '/'), { sourceType: DCCInputOption.elementTag, value: this.value @@ -233,7 +233,7 @@ class DCCInputChoice extends DCCInput { } this.changed = true - this._publish('var/' + this._variable + '/changed', + this._publish('input/changed/' + this._variable.replace(/\./g, '/'), { sourceType: DCCInputChoice.elementTag, value: this._value @@ -400,7 +400,7 @@ class DCCInputChoice extends DCCInput { this._presentationIsReady() // align with dcc-state-select - this._publish('var/' + this._variable + '/group_input/ready', + this._publish('input/ready//' + this.player.replace(/\./g, '/'), + this.innerHTML, null, true) console.log('=== return value') console.log(value) const input = value.message diff --git a/src/adonisjs/public/dccs/components/visual/dcc-input-typed.js b/src/adonisjs/public/dccs/components/visual/dcc-input-typed.js index 5127cf70e..d8a4965c7 100644 --- a/src/adonisjs/public/dccs/components/visual/dcc-input-typed.js +++ b/src/adonisjs/public/dccs/components/visual/dcc-input-typed.js @@ -13,7 +13,7 @@ class DCCInputTyped extends DCCInput { super.connectedCallback() this.innerHTML = '' - this._publish('var/' + this._variable + '/input/ready', + this._publish('input/ready/' + this._variable.replace(/\./g, '/'), DCCInputTyped.elementTag) } @@ -55,7 +55,7 @@ class DCCInputTyped extends DCCInput { inputTyped () { this.changed = true this.value = this._inputVariable.value - this._publish('var/' + this._variable + '/typed', + this._publish('input/typed/' + this._variable.replace(/\./g, '/'), { sourceType: DCCInputTyped.elementTag, value: this.value @@ -65,7 +65,7 @@ class DCCInputTyped extends DCCInput { inputChanged () { this.changed = true this.value = this._inputVariable.value - this._publish('var/' + this._variable + '/changed', + this._publish('input/changed/' + this._variable.replace(/\./g, '/'), { sourceType: DCCInputTyped.elementTag, value: this.value diff --git a/src/adonisjs/public/dccs/components/visual/dcc-input.js b/src/adonisjs/public/dccs/components/visual/dcc-input.js index daf52220d..d3e9e8c12 100644 --- a/src/adonisjs/public/dccs/components/visual/dcc-input.js +++ b/src/adonisjs/public/dccs/components/visual/dcc-input.js @@ -23,8 +23,8 @@ class DCCInput extends DCCBlock { ? this._statement : this._variable.substring(this._variable.lastIndexOf('.') + 1) - this._publish('var/' + this._variable + '/input/mandatory', - inputIndication) + this._publish('input/mandatory/' + this._variable.replace(/\./g, '/'), + inputIndication) } } diff --git a/src/adonisjs/public/dccs/components/visual/dcc-slider.js b/src/adonisjs/public/dccs/components/visual/dcc-slider.js index 01babda61..dcf4e56c7 100644 --- a/src/adonisjs/public/dccs/components/visual/dcc-slider.js +++ b/src/adonisjs/public/dccs/components/visual/dcc-slider.js @@ -24,7 +24,7 @@ class DCCSlider extends DCCInput { super.connectedCallback() this.innerHTML = '' - this._publish('var/' + this._variable + '/input/ready', + this._publish('input/ready/' + this._variable.replace(/\./g, '/'), DCCSlider.elementTag) } @@ -69,7 +69,7 @@ class DCCSlider extends DCCInput { this.changed = true this._value = this._inputVariable.value if (this._inputIndex) { this._inputIndex.innerHTML = this._value } - this._publish('var/' + this._variable + '/changed', + this._publish('input/changed/' + this._variable.replace(/\./g, '/'), { sourceType: DCCSlider.elementTag, value: this._value diff --git a/src/adonisjs/public/dccs/components/visual/dcc-state-select.js b/src/adonisjs/public/dccs/components/visual/dcc-state-select.js index d986a2b32..d885ec117 100644 --- a/src/adonisjs/public/dccs/components/visual/dcc-state-select.js +++ b/src/adonisjs/public/dccs/components/visual/dcc-state-select.js @@ -57,7 +57,7 @@ class DCCStateSelect extends DCCVisual { this._render() - this._publish('var/' + this.completeId + '/subinput/ready', + this._publish('input/ready/>/' + this.completeId.replace(/\./g, '/'), { sourceType: DCCStateSelect.elementTag, content: this.innerHTML @@ -134,7 +134,8 @@ class DCCStateSelect extends DCCVisual { } set selection (newValue) { - if (this._statesArr && this._statesArr.includes(newValue)) { this._selectionIndex = this._statesArr.indexOf(newValue) } + if (this._statesArr && this._statesArr.includes(newValue)) + this._selectionIndex = this._statesArr.indexOf(newValue) this.setAttribute('selection', newValue) } @@ -143,16 +144,22 @@ class DCCStateSelect extends DCCVisual { } set selectionIndex (newValue) { - if (this._statesArr && this._statesArr[newValue]) { this.selection = this._statesArr[newValue] } else { this._selectionIndex = newValue } + if (this._statesArr && this._statesArr[newValue]) + this.selection = this._statesArr[newValue] + else + this._selectionIndex = newValue } /* Rendering */ async _render () { if (this.states != null) { - if (this.hasAttribute('answer') || this.author) { this.selection = this.answer } else if (this.hasAttribute('player')) { + if (this.hasAttribute('answer') || this.author) + this.selection = this.answer + else if (this.hasAttribute('player')) { const value = await this._request( - 'var/' + this.player + '/get/sub', this.innerHTML, null, true) + 'var/get/>/' + this.player.replace(/\./g, '/'), + this.innerHTML, null, true) this.selection = value.message } else { this._presentation.addEventListener('mouseover', this._showState) @@ -196,7 +203,7 @@ class DCCStateSelect extends DCCVisual { _changeState () { if (this.states != null) { this.selectionIndex = (this.selectionIndex + 1) % this._statesArr.length - this._publish('var/' + this.completeId + '/state_changed', + this._publish('input/state/' + this.completeId.replace(/\./g, '/'), { sourceType: DCCStateSelect.elementTag, state: this.selection, @@ -240,8 +247,8 @@ class DCCGroupSelect extends DCCBlock { this._groupReady = true this._answerRequests() - this._publish('var/' + this.variable + '/group_input/ready', - DCCGroupSelect.elementTag) + this._publish('input/ready/ '' } ] diff --git a/src/adonisjs/public/dccs/playground/gallery/cell/ecology-editor.js b/src/adonisjs/public/dccs/playground/gallery/cell/ecology-editor.js index ec0479746..639b350be 100644 --- a/src/adonisjs/public/dccs/playground/gallery/cell/ecology-editor.js +++ b/src/adonisjs/public/dccs/playground/gallery/cell/ecology-editor.js @@ -178,16 +178,16 @@ Selecione abaixo a chance de cada um dos eventos: - + - - + + - + - + - + diff --git a/src/adonisjs/public/dccs/playground/gallery/cell/microworld3.js b/src/adonisjs/public/dccs/playground/gallery/cell/microworld3.js index 81d1e76ce..dee047892 100644 --- a/src/adonisjs/public/dccs/playground/gallery/cell/microworld3.js +++ b/src/adonisjs/public/dccs/playground/gallery/cell/microworld3.js @@ -164,16 +164,16 @@ Selecione abaixo a chance de cada um dos eventos: - + - - + + - + - + - + diff --git a/src/adonisjs/public/dccs/playground/gallery/cell/movement-sand-clock-editor.js b/src/adonisjs/public/dccs/playground/gallery/cell/movement-sand-clock-editor.js index 2c006384f..fb0a09120 100644 --- a/src/adonisjs/public/dccs/playground/gallery/cell/movement-sand-clock-editor.js +++ b/src/adonisjs/public/dccs/playground/gallery/cell/movement-sand-clock-editor.js @@ -141,9 +141,9 @@ Selecione abaixo a chance de cada um dos eventos: - - - + + + ` diff --git a/src/adonisjs/public/infra/bus.js b/src/adonisjs/public/infra/bus.js index 419ae1563..35fc43ffe 100644 --- a/src/adonisjs/public/infra/bus.js +++ b/src/adonisjs/public/infra/bus.js @@ -57,6 +57,16 @@ class MessageBus { } async publish (topic, message, track) { + /* + console.log('----- message: ' + topic) + console.log(message) + if (this._runningCase && this._runningCase.track) + console.log(this._runningCase.track.userid) + else { + console.log('[no running case]') + } + */ + if (track != null && this.debugger != null) this.debugger(topic, message) @@ -136,7 +146,7 @@ class MessageBus { if (responseTopic) { rt = responseTopic } else { if (rm == null) { rm = {} } else if (typeof rm !== 'object') { rm = { body: rm } } rm.responseStamp = MessageBus._stamp - rt = requestTopic + '/response/' + MessageBus._stamp + rt = 'response/' + MessageBus._stamp + '/' + requestTopic MessageBus._stamp++ } @@ -157,6 +167,16 @@ class MessageBus { } } + /* + Publishes the response only if a request exists + */ + publishHasResponse (topic, requestMessage, responseMessage, track) { + if (requestMessage.responseStamp) + this.publish( + MessageBus.buildResponseTopic(topic, requestMessage), + responseMessage, track) + } + async waitMessage (topic) { const promise = new Promise((resolve, reject) => { const callback = function (topic, message) { @@ -256,18 +276,44 @@ class MessageBus { * Returns the label at a specific level of the message. */ static extractLevel (topic, level) { - let label = null + const levelSet = MessageBus._splitLevels(topic, level) + return (levelSet == null) ? null : levelSet[level - 1] + } + + /* + * Returns the hierarchy from a level to a level of the message. + */ + static extractLevelsSegment (topic, levelFrom, levelTo) { + let hierarchy = null + const levelSet = MessageBus._splitLevels(topic) + if (levelSet != null) { + if (levelTo == null) + levelTo = levelSet.length + if (levelTo >= levelFrom) { + if (levelSet != null) { + hierarchy = '' + for (let l = levelFrom-1; l < levelTo; l++) + hierarchy += levelSet[l] + ((l < levelTo-1) ? '/' : '') + } + } + } + return hierarchy + } + + static _splitLevels (topic, level) { + let split = null if (topic != null) { const levelSet = topic.split('/') - if (level <= levelSet.length) { label = levelSet[level - 1] } + if (level == null || level <= levelSet.length) + split = levelSet } - return label + return split } /* Message building services *************************/ static buildResponseTopic (topic, message) { - return topic + '/response/' + message.responseStamp + return 'response/' + message.responseStamp + '/' + topic } } diff --git a/src/adonisjs/public/infra/conditional-layout.js b/src/adonisjs/public/infra/conditional-layout.js index 2bf93a35c..6b1d16adf 100644 --- a/src/adonisjs/public/infra/conditional-layout.js +++ b/src/adonisjs/public/infra/conditional-layout.js @@ -56,7 +56,7 @@ class LayoutController { async busMessages(){ // console.log('======= starting conditional-layout') - LayoutController.user = await MessageBus.i.waitMessage('data/user/info') + LayoutController.user = await MessageBus.i.waitMessage('user/login/+') if(new URL(document.location).pathname == '/author/'){ LayoutController.case = await MessageBus.i.waitMessage('service/response/get/harena-case') } diff --git a/src/adonisjs/public/infra/dcc-common-server-proxy.js b/src/adonisjs/public/infra/dcc-common-server-proxy.js index c0f961bae..fc9cb766f 100644 --- a/src/adonisjs/public/infra/dcc-common-server-proxy.js +++ b/src/adonisjs/public/infra/dcc-common-server-proxy.js @@ -7,7 +7,7 @@ class DCCCommonServer { this.casesList = this.casesList.bind(this) MessageBus.i.subscribe('data/case/*/list', this.casesList) this.loadCase = this.loadCase.bind(this) - MessageBus.i.subscribe('data/case/+/get', this.loadCase) + MessageBus.i.subscribe('case/get/+', this.loadCase) this.loadTheme = this.loadTheme.bind(this) this.themeFamilySettings = this.themeFamilySettings.bind(this) MessageBus.i.subscribe('data/theme_family/+/settings', diff --git a/src/adonisjs/public/infra/dcc-logger.js b/src/adonisjs/public/infra/dcc-logger.js index d8b22321f..0aa643490 100644 --- a/src/adonisjs/public/infra/dcc-logger.js +++ b/src/adonisjs/public/infra/dcc-logger.js @@ -6,13 +6,25 @@ class DCCLogger extends DCCLight { super() this._notifyLogger = this._notifyLogger.bind(this) - this._subscribe('case/summary', this._notifyLogger) + this._subscribe('#', this._notifyLogger) } _notifyLogger (topic, message, track) { if (track) { - console.log('=== logger DCC: ' + topic) - console.log(message) + // console.log('=== logger DCC: ' + topic) + // console.log(message) + + if (MessageBus.matchFilter(topic, 'user/login/+')) { + console.log('=== user logged') + console.log(MessageBus.extractLevel(topic, 3)) + } + + if (MessageBus.matchFilter(topic, 'case/start/+')) { + console.log('=== case started') + console.log('user id: ' + message.userId) + console.log('case id: ' + message.caseId) + console.log('instance id: ' + MessageBus.extractLevel(topic, 3)) + } } } } diff --git a/src/adonisjs/public/infra/simple-page-tasks.js b/src/adonisjs/public/infra/simple-page-tasks.js index 661f10200..e360c75fb 100644 --- a/src/adonisjs/public/infra/simple-page-tasks.js +++ b/src/adonisjs/public/infra/simple-page-tasks.js @@ -18,7 +18,7 @@ class PageController { // console.log(PageController.scriptsComplete) }) MessageBus.i.subscribe('control/dhtml/ready', this.removeLoadingIcon) - MessageBus.i.subscribe('control/case/ready', this.removeLoadingIcon) + MessageBus.i.subscribe('case/ready/+', this.removeLoadingIcon) MessageBus.i.subscribe('control/validate/ready', this.removeLoadingIcon) MessageBus.i.subscribe('control/html/ready', this.pageReady) } diff --git a/src/adonisjs/public/infra/token-validator.js b/src/adonisjs/public/infra/token-validator.js index 5d835dee0..3f81769df 100644 --- a/src/adonisjs/public/infra/token-validator.js +++ b/src/adonisjs/public/infra/token-validator.js @@ -35,7 +35,8 @@ class TokenController { // localStorage.setItem('harena-user-grade', endpointResponse.data.grade) // localStorage.setItem('harena-user-institution', endpointResponse.data.institution) // localStorage.setItem('harena-user-institution-id', endpointResponse.data.institutionId) - MessageBus.i.publish('data/user/info', endpointResponse.data) + MessageBus.i.publish('user/login/' + endpointResponse.data.userId, + endpointResponse.data, true) TokenController.instance.changeHeaderButtons(endpointResponse.data) }) .catch(function (error) { @@ -111,7 +112,8 @@ class TokenController { // localStorage.setItem('harena-user-grade', endpointResponse.data.grade) // localStorage.setItem('harena-user-institution', endpointResponse.data.institution) // localStorage.setItem('harena-user-institution-id', endpointResponse.data.institutionId) - MessageBus.i.publish('data/user/info', endpointResponse.data) + MessageBus.i.publish('user/login/' + endpointResponse.data.userId, + endpointResponse.data, true) TokenController.instance.changeHeaderButtons(endpointResponse.data) } else{ diff --git a/src/adonisjs/public/player/js/caselist.js b/src/adonisjs/public/player/js/caselist.js index 8bd8428d9..05e9a6791 100644 --- a/src/adonisjs/public/player/js/caselist.js +++ b/src/adonisjs/public/player/js/caselist.js @@ -4,7 +4,7 @@ class CaseQueueManager { this._nextCase = this._nextCase.bind(this) - MessageBus.i.subscribe('case/+/navigate', this._nextCase) + MessageBus.i.subscribe('case/navigate/+', this._nextCase) this.start() } diff --git a/src/adonisjs/public/player/js/htracker.js b/src/adonisjs/public/player/js/htracker.js index c70c81ec4..b53844528 100644 --- a/src/adonisjs/public/player/js/htracker.js +++ b/src/adonisjs/public/player/js/htracker.js @@ -10,77 +10,83 @@ class Tracker { this._caseCompleted = false this.inputReady = this.inputReady.bind(this) - MessageBus.i.subscribe('var/+/input/ready', this.inputReady) + MessageBus.i.subscribe('input/ready/#', this.inputReady) this.inputMandatory = this.inputMandatory.bind(this) - MessageBus.i.subscribe('var/+/input/mandatory', this.inputMandatory) - this.groupinputReady = this.groupinputReady.bind(this) - MessageBus.i.subscribe('var/+/group_input/ready', this.groupinputReady) - this.subinputReady = this.subinputReady.bind(this) - MessageBus.i.subscribe('var/+/subinput/ready', this.subinputReady) + MessageBus.i.subscribe('input/mandatory/#', this.inputMandatory) this.inputTyped = this.inputTyped.bind(this) - MessageBus.i.subscribe('var/+/typed', this.inputTyped) + MessageBus.i.subscribe('input/typed/#', this.inputTyped) this.inputChanged = this.inputChanged.bind(this) - MessageBus.i.subscribe('var/+/changed', this.inputChanged) + MessageBus.i.subscribe('input/changed/#', this.inputChanged) this.stateChanged = this.stateChanged.bind(this) - MessageBus.i.subscribe('var/+/state_changed', this.stateChanged) - this.allMandatoryFilled = this.allMandatoryFilled.bind(this) - MessageBus.i.subscribe('var/*/input/mandatory/get', this.allMandatoryFilled) + MessageBus.i.subscribe('input/state/#', this.stateChanged) this.knotStart = this.knotStart.bind(this) - MessageBus.i.subscribe('knot/+/start', this.knotStart) + MessageBus.i.subscribe('knot/start/#', this.knotStart) this.caseCompleted = this.caseCompleted.bind(this) - MessageBus.i.subscribe('case/completed', this.caseCompleted) + MessageBus.i.subscribe('case/completed/+', this.caseCompleted) MessageBus.i.subscribe('session/close', this.caseCompleted) this.submitVariables = this.submitVariables.bind(this) - MessageBus.i.subscribe('control/input/submit', this.submitVariables) + MessageBus.i.subscribe('input/submit/*', this.submitVariables) } - inputMandatory (topic, message) { - const v = MessageBus.extractLevel(topic, 2) - if (v != null) { - this._mandatoryFilled[v] = { message: message, filled: false } - } + _extractEntityId (topic, position) { + return MessageBus.extractLevelsSegment(topic, position).replace(/\//g, '.') } - inputReady (topic, message) { - this._initializeVariable(topic, '') + _exportEntityId (entity) { + return entity.replace(/\./g, '/') } - groupinputReady (topic, message) { - this._initializeVariable(topic, {}) - this._groupInput = MessageBus.extractLevel(topic, 2) + inputMandatory (topic, message, track) { + if (MessageBus.extractLevel(topic, 3) == '*') + MessageBus.i.publishHasResponse( + topic, message, this._mandatoryFilled, track) + else { + const v = this._extractEntityId(topic, 3) + if (v != null) + this._mandatoryFilled[v] = { message: message, filled: false } + } } - subinputReady (topic, message) { - if (this._groupInput != null) { - const id = MessageBus.extractLevel(topic, 2) - this._variables[this._groupInput][id] = - { content: message.content, state: ' ' } - } + inputReady (topic, message) { + const type = MessageBus.extractLevel(topic, 3) + const position = (type == '<' || type == '>') ? 4 : 3 + const v = this._extractEntityId(topic, position) + if (v != null && this._variables[v] == null) + switch (type) { + case '<' : this._updateVariable(v, {}) + this._groupInput = v + break + case '>' : if (this._groupInput != null) + this._variables[this._groupInput][v] = + { content: message.content, state: ' ' } + break + default: this._updateVariable(v, '') + } } inputTyped (topic, message) { - this._updateVariable(topic, message.value) + this._updateVariable(this._extractEntityId(topic, 3), message.value) // this._changedVariable(topic, message.value) } inputChanged (topic, message) { - this._updateVariable(topic, message.value) + this._updateVariable(this._extractEntityId(topic, 3), message.value) // this._changedVariable(topic, message.value) } stateChanged (topic, message) { - if (this._groupInput != null) { - const id = MessageBus.extractLevel(topic, 2) - this._variables[this._groupInput][id].state = message.state - } + if (this._groupInput != null) + this._variables[this._groupInput][this._extractEntityId(topic, 3)].state = + message.state } submitVariables (topic, message) { for (const v in this._variables) { if (this._varUpdated[v] == null || this._varUpdated[v]) { - MessageBus.i.publish('var/' + v + '/set', this._variables[v], true) + MessageBus.i.publish('var/set/' + this._exportEntityId(v), + this._variables[v], true) this._varUpdated[v] = false } } @@ -100,32 +106,19 @@ class Tracker { } */ - _updateVariable (topic, value) { - const v = MessageBus.extractLevel(topic, 2) - if (v != null) { - this._variables[v] = value - this._varUpdated[v] = true - if (this._mandatoryFilled[v] !== undefined) { - this._mandatoryFilled[v].filled = (value.length > 0) } + _updateVariable (variable, value) { + if (variable != null) { + this._variables[variable] = value + this._varUpdated[variable] = true + if (this._mandatoryFilled[variable] !== undefined) { + this._mandatoryFilled[variable].filled = (value.length > 0) } } } - _initializeVariable (topic, value) { - const v = MessageBus.extractLevel(topic, 2) - if (v != null && this._variables[v] == null) - this._updateVariable(topic, value) - } - - allMandatoryFilled (topic, message, track) { - MessageBus.i.publish(MessageBus.buildResponseTopic(topic, message), - this._mandatoryFilled, track) - } - knotStart (topic, message) { - const k = MessageBus.extractLevel(topic, 2) const currentDateTime = new Date() this._knotTrack.push( - {knotid: k, + {knotid: this._extractEntityId(topic, 3), timeStart: currentDateTime.toJSON()}) } @@ -139,8 +132,10 @@ class Tracker { if (message && message.knotid) kt.knotid = message.knotid this._knotTrack.push(kt) - MessageBus.i.publish('case/summary', - {knotTrack: this._knotTrack, + MessageBus.i.publish('case/summary/' + MessageBus.extractLevel(topic, 3), + {userId: message.userId, + caseId: message.caseId, + knotTrack: this._knotTrack, variables: this._variables}, true) } } diff --git a/src/adonisjs/public/player/js/player.js b/src/adonisjs/public/player/js/player.js index d35d05cc2..ee509333b 100644 --- a/src/adonisjs/public/player/js/player.js +++ b/src/adonisjs/public/player/js/player.js @@ -11,10 +11,9 @@ class PlayerManager { this.controlEvent = this.controlEvent.bind(this) MessageBus.i.subscribe('control/#', this.controlEvent) this.navigateEvent = this.navigateEvent.bind(this) - MessageBus.i.subscribe('knot/+/navigate', this.navigateEvent) - MessageBus.i.subscribe('flow/+/navigate', this.navigateEvent) - MessageBus.i.subscribe('case/+/navigate', this.navigateEvent) - MessageBus.i.subscribe('variable/+/navigate', this.navigateEvent) + MessageBus.i.subscribe('knot/navigate/#', this.navigateEvent) + MessageBus.i.subscribe('flow/navigate/+', this.navigateEvent) + MessageBus.i.subscribe('case/navigate/+', this.navigateEvent) MessageBus.i.subscribe('session/close', this.navigateEvent) this._notesStack = [] @@ -24,7 +23,7 @@ class PlayerManager { MessageBus.i.subscribe('/report/get', this.produceReport) this.caseCompleted = this.caseCompleted.bind(this) - MessageBus.i.subscribe('case/completed', this.caseCompleted) + MessageBus.i.subscribe('case/completed/+', this.caseCompleted) // tracking this.trackTyping = this.trackTyping.bind(this) @@ -47,124 +46,120 @@ class PlayerManager { } async navigateEvent (topic, message) { - let target = MessageBus.extractLevel(topic, 2) - this.trackTrigger(target) - - let mandatoryEmpty = null - const mandatoryM = await MessageBus.i.request('var/*/input/mandatory/get') - for (const m in mandatoryM.message) { - if (mandatoryM.message[m].filled == false && mandatoryEmpty == null) { - mandatoryEmpty = mandatoryM.message[m].message } - } - - if (mandatoryEmpty != null) { - MessageBus.i.publish(topic + '/blocked', 'Input missing: ' + mandatoryEmpty, true) - await DCCNoticeInput.displayNotice( - 'You must answer the question: ' + mandatoryEmpty, - 'message', 'Ok') - } else { - if (this._currentKnot != null) { - MessageBus.i.publish('control/input/submit', null, true) // provisory - MessageBus.i.publish('knot/' + this._currentKnot + '/end', null, true) + if (MessageBus.extractLevel(topic, 3) != '!') { // navigation blocked + let target = + MessageBus.extractLevelsSegment(topic, + (MessageBus.extractLevel(topic, 3) == '=') ? 4 : 3).replace(/\//g, '.') + this.trackTrigger(target) + + let mandatoryEmpty = null + const mandatoryM = await MessageBus.i.request('input/mandatory/*') + for (const m in mandatoryM.message) { + if (mandatoryM.message[m].filled == false && mandatoryEmpty == null) { + mandatoryEmpty = mandatoryM.message[m].message } } - switch (topic) { - case 'knot/ 0) { - const panel = this._notesStack.pop() - this._mainPanel.removeChild(panel) - } - if (this._state.historyHasPrevious()) { - // removes the panel to rebuild it + if (mandatoryEmpty != null) { + MessageBus.i.publish(MessageBus.extractLevelsSegment(topic, 1, 2) + '/!', + 'Input missing: ' + mandatoryEmpty, true) + await DCCNoticeInput.displayNotice( + 'You must answer the question: ' + mandatoryEmpty, + 'message', 'Ok') + } else { + if (this._currentKnot != null) { + MessageBus.i.publish('input/submit/*', null, true) // provisory + MessageBus.i.publish('knot/end/' + this._currentKnot.replace(/\./g, '/'), + null, true) + } + + switch (topic) { + case 'knot/navigate/<': if (this._notesStack.length > 0) { const panel = this._notesStack.pop() this._mainPanel.removeChild(panel) } - this.knotLoad(this._state.historyPrevious()) - } - break - case 'knot/</navigate': const nextKnot = this._state.nextKnot() - this._state.historyRecord(nextKnot) - this.knotLoad(nextKnot) - break - case 'flow/>/navigate': const flowNext = this._nextFlowKnot() - if (flowNext != null) { - // console.log('=== flow next') - // console.log(flowNext) - this._state.historyRecord(flowNext.target) - this.knotLoad(flowNext.target) - } - break - case 'case/>/navigate': - // jumping other instructions - improve it - // console.log('=== next case') - let instruction - do { - instruction = this._state.metascriptNextInstruction() - } while (instruction != null && instruction.type != 'divert-script' && - instruction.target.substring(0, 5).toLowerCase() != 'case.') - - // console.log(instruction) - if (instruction != null) { - if (instruction.parameter) { - // console.log("=== metaparameter"); - // console.log(instruction.parameter.parameter); - this._state.metaexecParameterSet(instruction.parameter.parameter) + if (this._state.historyHasPrevious()) { + // removes the panel to rebuild it + if (this._notesStack.length > 0) { + const panel = this._notesStack.pop() + this._mainPanel.removeChild(panel) + } + this.knotLoad(this._state.historyPrevious()) + } + break + case 'knot/navigate/<<': this.startCase() + const flowStart = this._nextFlowKnot() + const startKnot = (flowStart != null) + ? flowStart.target + : (DCCPlayerServer.localEnv) + ? DCCPlayerServer.playerObj.start + : this._compiledCase.start + // console.log("=== start"); + // console.log(startKnot); + this._state.historyRecord(startKnot) + this.knotLoad(startKnot) + break + case 'knot/navigate/>': const nextKnot = this._state.nextKnot() + this._state.historyRecord(nextKnot) + this.knotLoad(nextKnot) + break + case 'flow/navigate/>': const flowNext = this._nextFlowKnot() + if (flowNext != null) { + // console.log('=== flow next') + // console.log(flowNext) + this._state.historyRecord(flowNext.target) + this.knotLoad(flowNext.target) + } + break + case 'case/navigate/>': + // jumping other instructions - improve it + // console.log('=== next case') + let instruction + do { + instruction = this._state.metascriptNextInstruction() + } while (instruction != null && instruction.type != 'divert-script' && + instruction.target.substring(0, 5).toLowerCase() != 'case.') + + // console.log(instruction) + if (instruction != null) { + if (instruction.parameter) { + // console.log("=== metaparameter"); + // console.log(instruction.parameter.parameter); + this._state.metaexecParameterSet(instruction.parameter.parameter) + } + window.open('index.html?case=' + + instruction.target.substring(5) + + (this._previewCase ? '&preview' : ''), '_self') + } + break + case 'session/close': + this.sessionClose() + break + default: if (MessageBus.matchFilter(topic, 'knot/navigate/#')) { + if (MessageBus.matchFilter(topic, 'knot/navigate/=/#')) { + const result = await MessageBus.i.request( + 'var/get/' + target.replace(/\./g, '/'), null, null, true) + target = Translator.instance.findContext( + this._compiledCase.knots, this._currentKnot, + result.message) + } + this._state.historyRecord(target) + if (message.value) { + this._state.parameter = message.value + this.knotLoad(target, message.value) + } else { + this._state.parameter = null + this.knotLoad(target) + } + } else if (MessageBus.matchFilter(topic, 'case/navigate/+')) { + if (message) { + this._state.metaexecParameterSet(message.parameter) } - window.open('index.html?case=' + - instruction.target.substring(5) + - (this._previewCase ? '&preview' : ''), '_self') + window.open('index.html?case=' + target + + (this._previewCase ? '&preview' : ''), '_self') } break - case 'session/close': - this.sessionClose() - break - default: if (MessageBus.matchFilter(topic, 'knot/+/navigate') || - MessageBus.matchFilter(topic, 'variable/+/navigate')) { - /* - console.log("=== variable navigate"); - console.log(target); - */ - if (MessageBus.matchFilter(topic, 'variable/+/navigate')) { - const result = await MessageBus.i.request('var/' + target + '/get', null, null, true) - target = Translator.instance.findContext( - this._compiledCase.knots, this._currentKnot, - result.message) - /* - console.log("=== variable resolved"); - console.log(target); - */ - } - this._state.historyRecord(target) - if (message.value) { - this._state.parameter = message.value - this.knotLoad(target, message.value) - } else { - this._state.parameter = null - this.knotLoad(target) - } - } else if (MessageBus.matchFilter(topic, 'case/+/navigate')) { - if (message) { - // console.log("=== metaparameter"); - // console.log(message.parameter); - this._state.metaexecParameterSet(message.parameter) - } - window.open('index.html?case=' + target + - (this._previewCase ? '&preview' : ''), '_self') } - break } } } @@ -226,7 +221,7 @@ class PlayerManager { await this._caseLoad(this._state.currentCase) this._caseFlow() - MessageBus.i.publish('knot/< this._runningCase is provisory - MessageBus.i.publish('case/' + this._state.currentCase + '/resume', this._state.runningCase, true) + MessageBus.i.publish('case/resume/' + this._state.runningCase, + {userId: this._state.userid, + caseId: this._state.currentCase}, true) MessageBus.i.defineRunningCase(this._state.runningCase) } diff --git a/src/adonisjs/public/player/js/state.js b/src/adonisjs/public/player/js/state.js index 5535280eb..49a8848ea 100644 --- a/src/adonisjs/public/player/js/state.js +++ b/src/adonisjs/public/player/js/state.js @@ -28,12 +28,13 @@ class PlayState { this._metastate = {} + this.sessionRecord = this.sessionRecord.bind(this) + MessageBus.i.subscribe('user/login/+', this.sessionRecord) + this.variableGet = this.variableGet.bind(this) - MessageBus.i.subscribe('var/+/get', this.variableGet) + MessageBus.i.subscribe('var/get/#', this.variableGet) this.variableSet = this.variableSet.bind(this) - MessageBus.i.subscribe('var/+/set', this.variableSet) - this.variableSubGet = this.variableSubGet.bind(this) - MessageBus.i.subscribe('var/+/get/sub', this.variableSubGet) + MessageBus.i.subscribe('var/set/#', this.variableSet) } /* @@ -50,9 +51,8 @@ class PlayState { return (state == null || state.completed) ? null : state } - sessionRecord (userid, token) { - this._state.userid = userid - this._state.token = token + sessionRecord (topic) { + this._state.userid = MessageBus.extractLevel(topic, 3) this._stateStore() } @@ -121,53 +121,55 @@ class PlayState { * Scenario Variables */ + _extractEntityId (topic) { + return MessageBus.extractLevelsSegment(topic, 3).replace(/\//g, '.') + } + variableGet (topic, message, track) { - let id = MessageBus.extractLevel(topic, 2) + const type = MessageBus.extractLevel(topic, 3) + let id = this._extractEntityId(topic, (type == '>') ? 4 : 3) - if (id != null) + if (id != null) { id = id.toLowerCase() - if (id != null && id.startsWith('previous.')) { - const previousKnot = this.historyPreviousId().toLowerCase() - if (previousKnot != null) { id = previousKnot + '.' + id.substring(9) } - } - - if (id == '*') - MessageBus.i.publish(MessageBus.buildResponseTopic(topic, message), - this._state.variables, track) - else { - // tries to give a scope to the variable - if (id != null && this._state.variables[id] == null) { - const currentKnot = this.historyCurrent() - if (currentKnot != null && - this._state.variables[currentKnot + '.' + id] != null) { id = currentKnot + '.' + id } + if (id.startsWith('previous.')) { + const previousKnot = this.historyPreviousId().toLowerCase() + if (previousKnot != null) { id = previousKnot + '.' + id.substring(9) } } - if (id != null) { - MessageBus.i.publish(MessageBus.buildResponseTopic(topic, message), - this._state.variables[id], track) + switch (type) { + case '*': + MessageBus.i.publishHasResponse ( + topic, message, this._state.variables, track) + break + case '>': + let result = null + while (this._state.variables[id] === undefined && id.indexOf('.') > -1) + id = id.substring(id.indexOf('.') + 1) + if (this._state.variables[id]) { + for (const v in this._state.variables[id]) { + if (this._state.variables[id][v].content == message.body) + result = this._state.variables[id][v].state + } + } + MessageBus.i.publishHasResponse (topic, message, result, track) + break + default: + // tries to give a scope to the variable + if (this._state.variables[id] == null) { + const currentKnot = this.historyCurrent() + if (currentKnot != null && + this._state.variables[currentKnot + '.' + id] != null) + id = currentKnot + '.' + id + } + MessageBus.i.publishHasResponse ( + topic, message, this._state.variables[id], track) } } } - variableSubGet (topic, message, track) { - const completeId = MessageBus.extractLevel(topic, 2) - if (completeId != null) { - let result = null - let id = completeId - while (this._state.variables[id] === undefined && id.indexOf('.') > -1) { id = id.substring(id.indexOf('.') + 1) } - if (this._state.variables[id]) { - for (const v in this._state.variables[id]) { - if (this._state.variables[id][v].content == message.body) { result = this._state.variables[id][v].state } - } - } - MessageBus.i.publish(MessageBus.buildResponseTopic(topic, message), - result, track) - } - } - variableSet (topic, message, track) { - const id = MessageBus.extractLevel(topic, 2) + const id = this._extractEntityId(topic, 3) let status = false const content = (message.responseStamp != null && message.body != null) ? @@ -183,8 +185,8 @@ class PlayState { status = true } this._stateStore() - MessageBus.i.publish(MessageBus.buildResponseTopic(topic, message), - status, track) + + MessageBus.i.publishHasResponse(topic, message, status, track) } /* diff --git a/src/adonisjs/public/scripts/playground/gallery/cell/aquarium-scripts-plus.js b/src/adonisjs/public/scripts/playground/gallery/cell/aquarium-scripts-plus.js index 220d6878d..0aa311a69 100644 --- a/src/adonisjs/public/scripts/playground/gallery/cell/aquarium-scripts-plus.js +++ b/src/adonisjs/public/scripts/playground/gallery/cell/aquarium-scripts-plus.js @@ -51,7 +51,7 @@ -`, +`, `Selecione um dos ícones abaixo para editar o ambiente:
diff --git a/src/adonisjs/public/scripts/playground/gallery/cell/aquarium-scripts.js b/src/adonisjs/public/scripts/playground/gallery/cell/aquarium-scripts.js index d64321b52..47da8f662 100644 --- a/src/adonisjs/public/scripts/playground/gallery/cell/aquarium-scripts.js +++ b/src/adonisjs/public/scripts/playground/gallery/cell/aquarium-scripts.js @@ -55,7 +55,7 @@ -`, +`, `Selecione um dos ícones abaixo para editar o ambiente:
diff --git a/src/adonisjs/public/scripts/playground/gallery/cell/aquarium-sliders.js b/src/adonisjs/public/scripts/playground/gallery/cell/aquarium-sliders.js index 4fcb7c507..427f16773 100644 --- a/src/adonisjs/public/scripts/playground/gallery/cell/aquarium-sliders.js +++ b/src/adonisjs/public/scripts/playground/gallery/cell/aquarium-sliders.js @@ -80,7 +80,7 @@ -`, +`, `Selecione um dos ícones abaixo para editar o ambiente:
@@ -159,16 +159,16 @@ Selecione abaixo a chance de cada um dos eventos:
- + - - + + - + - + - + ` ) })() diff --git a/src/adonisjs/public/scripts/playground/gallery/cell/boids.js b/src/adonisjs/public/scripts/playground/gallery/cell/boids.js index 0c6018ada..ab30c76d0 100644 --- a/src/adonisjs/public/scripts/playground/gallery/cell/boids.js +++ b/src/adonisjs/public/scripts/playground/gallery/cell/boids.js @@ -35,7 +35,7 @@ _________________ - + @@ -44,7 +44,7 @@ _________________ - +
diff --git a/src/adonisjs/public/scripts/playground/gallery/cell/cerrado-sliders.js b/src/adonisjs/public/scripts/playground/gallery/cell/cerrado-sliders.js index 5305bff1e..47bd78a52 100644 --- a/src/adonisjs/public/scripts/playground/gallery/cell/cerrado-sliders.js +++ b/src/adonisjs/public/scripts/playground/gallery/cell/cerrado-sliders.js @@ -80,7 +80,7 @@ -`, +`, `Selecione um dos ícones abaixo para editar o ambiente:
@@ -159,16 +159,16 @@ Selecione abaixo a chance de cada um dos eventos:
- + - - + + - + - + - + ` ) })() diff --git a/src/adonisjs/public/scripts/playground/gallery/cell/expression-rocket-wide-timer-scale-ruler.js b/src/adonisjs/public/scripts/playground/gallery/cell/expression-rocket-wide-timer-scale-ruler.js index 4cf0f867f..9f0e3d7f9 100644 --- a/src/adonisjs/public/scripts/playground/gallery/cell/expression-rocket-wide-timer-scale-ruler.js +++ b/src/adonisjs/public/scripts/playground/gallery/cell/expression-rocket-wide-timer-scale-ruler.js @@ -37,7 +37,7 @@ - + @@ -46,7 +46,7 @@ - +
diff --git a/src/adonisjs/public/scripts/playground/gallery/cell/expression-rocket-wide-timer-scale.js b/src/adonisjs/public/scripts/playground/gallery/cell/expression-rocket-wide-timer-scale.js index c478f0c20..f2b929fee 100644 --- a/src/adonisjs/public/scripts/playground/gallery/cell/expression-rocket-wide-timer-scale.js +++ b/src/adonisjs/public/scripts/playground/gallery/cell/expression-rocket-wide-timer-scale.js @@ -33,14 +33,14 @@ - + - +
- + - +
-`, +`, `Selecione um dos ícones abaixo para editar o ambiente:
diff --git a/src/adonisjs/public/scripts/playground/gallery/cell/microworld-sliders.js b/src/adonisjs/public/scripts/playground/gallery/cell/microworld-sliders.js index b5c88dd03..c644c6c41 100644 --- a/src/adonisjs/public/scripts/playground/gallery/cell/microworld-sliders.js +++ b/src/adonisjs/public/scripts/playground/gallery/cell/microworld-sliders.js @@ -79,7 +79,7 @@ -`, +`, `Selecione um dos ícones abaixo para editar o ambiente:
@@ -153,16 +153,16 @@ Selecione abaixo a chance de cada um dos eventos:
- + - - + + - + - + - + ` ) })() diff --git a/src/adonisjs/public/scripts/playground/gallery/cell/zombie-wall-challenge1.js b/src/adonisjs/public/scripts/playground/gallery/cell/zombie-wall-challenge1.js index 486a2c691..d188b84ab 100644 --- a/src/adonisjs/public/scripts/playground/gallery/cell/zombie-wall-challenge1.js +++ b/src/adonisjs/public/scripts/playground/gallery/cell/zombie-wall-challenge1.js @@ -104,7 +104,7 @@ Configure a transparência do teto:
- + ` ) })() diff --git a/src/adonisjs/public/scripts/playground/gallery/cell/zombie-wall-challenge2.js b/src/adonisjs/public/scripts/playground/gallery/cell/zombie-wall-challenge2.js index 989f3a8a6..d9f457ff3 100644 --- a/src/adonisjs/public/scripts/playground/gallery/cell/zombie-wall-challenge2.js +++ b/src/adonisjs/public/scripts/playground/gallery/cell/zombie-wall-challenge2.js @@ -104,7 +104,7 @@ Configure a transparência do teto:
- + ` ) })() diff --git a/src/adonisjs/public/scripts/playground/gallery/cell/zombie-wall-challenge3.js b/src/adonisjs/public/scripts/playground/gallery/cell/zombie-wall-challenge3.js index cd9be45d8..7229fd189 100644 --- a/src/adonisjs/public/scripts/playground/gallery/cell/zombie-wall-challenge3.js +++ b/src/adonisjs/public/scripts/playground/gallery/cell/zombie-wall-challenge3.js @@ -104,7 +104,7 @@ Configure a transparência do teto:
- + ` ) })() diff --git a/src/adonisjs/public/scripts/playground/gallery/cell/zombie-wall-challenge4.js b/src/adonisjs/public/scripts/playground/gallery/cell/zombie-wall-challenge4.js index 4dbba8fc2..580980d65 100644 --- a/src/adonisjs/public/scripts/playground/gallery/cell/zombie-wall-challenge4.js +++ b/src/adonisjs/public/scripts/playground/gallery/cell/zombie-wall-challenge4.js @@ -104,7 +104,7 @@ Configure a transparência do teto:
- + ` ) })() diff --git a/src/adonisjs/public/scripts/playground/gallery/cell/zombie-wall-challenge5.js b/src/adonisjs/public/scripts/playground/gallery/cell/zombie-wall-challenge5.js index 98a1fc5c9..848e5d433 100644 --- a/src/adonisjs/public/scripts/playground/gallery/cell/zombie-wall-challenge5.js +++ b/src/adonisjs/public/scripts/playground/gallery/cell/zombie-wall-challenge5.js @@ -104,7 +104,7 @@ Configure a transparência do teto:
- + ` ) })() diff --git a/src/adonisjs/public/scripts/playground/gallery/cell/zombie-wall-challenge6.js b/src/adonisjs/public/scripts/playground/gallery/cell/zombie-wall-challenge6.js index 4a3ef396c..73ed3b841 100644 --- a/src/adonisjs/public/scripts/playground/gallery/cell/zombie-wall-challenge6.js +++ b/src/adonisjs/public/scripts/playground/gallery/cell/zombie-wall-challenge6.js @@ -104,7 +104,7 @@ Configure a transparência do teto:
- + ` ) })() diff --git a/src/adonisjs/public/scripts/playground/gallery/cell/zombie-wall-train1.js b/src/adonisjs/public/scripts/playground/gallery/cell/zombie-wall-train1.js index 09bd6f4e1..04b3fd2ed 100644 --- a/src/adonisjs/public/scripts/playground/gallery/cell/zombie-wall-train1.js +++ b/src/adonisjs/public/scripts/playground/gallery/cell/zombie-wall-train1.js @@ -104,7 +104,7 @@ Configure a transparência do teto:
- + ` ) })() diff --git a/src/adonisjs/public/themes/jacinto/detailed.html b/src/adonisjs/public/themes/jacinto/detailed.html index d8fc4a358..43f3121f0 100644 --- a/src/adonisjs/public/themes/jacinto/detailed.html +++ b/src/adonisjs/public/themes/jacinto/detailed.html @@ -641,7 +641,7 @@ cy="186.4236" r="25.741863" /> - + diff --git a/src/adonisjs/public/themes/jacinto/detailed_role.html b/src/adonisjs/public/themes/jacinto/detailed_role.html index 8fd1d0f8d..db32e043c 100644 --- a/src/adonisjs/public/themes/jacinto/detailed_role.html +++ b/src/adonisjs/public/themes/jacinto/detailed_role.html @@ -569,6 +569,6 @@ cy="186.4236" r="25.741863" /> - + diff --git a/src/adonisjs/public/themes/jacinto/exam.html b/src/adonisjs/public/themes/jacinto/exam.html index 6bca152c2..8945d8edd 100644 --- a/src/adonisjs/public/themes/jacinto/exam.html +++ b/src/adonisjs/public/themes/jacinto/exam.html @@ -664,6 +664,6 @@ cy="186.4236" r="25.741863" /> - + diff --git a/src/adonisjs/public/themes/jacinto/exam_wide.html b/src/adonisjs/public/themes/jacinto/exam_wide.html index c201f465d..3a9b3cf43 100644 --- a/src/adonisjs/public/themes/jacinto/exam_wide.html +++ b/src/adonisjs/public/themes/jacinto/exam_wide.html @@ -90,6 +90,6 @@ r="25.265163" inkscape:label="#path38" /> - + diff --git a/src/adonisjs/public/themes/jacinto/information.html b/src/adonisjs/public/themes/jacinto/information.html index d1cf5b17b..635f43d70 100644 --- a/src/adonisjs/public/themes/jacinto/information.html +++ b/src/adonisjs/public/themes/jacinto/information.html @@ -676,6 +676,6 @@ cy="186.4236" r="25.741863" /> - + diff --git a/src/adonisjs/public/themes/jacinto/information_exam.html b/src/adonisjs/public/themes/jacinto/information_exam.html index 6f4475e33..ec53942e6 100644 --- a/src/adonisjs/public/themes/jacinto/information_exam.html +++ b/src/adonisjs/public/themes/jacinto/information_exam.html @@ -683,6 +683,6 @@ cy="186.4236" r="25.741863" /> - + diff --git a/src/adonisjs/public/themes/jacinto/input.html b/src/adonisjs/public/themes/jacinto/input.html index dbde2e756..bfd216bd2 100644 --- a/src/adonisjs/public/themes/jacinto/input.html +++ b/src/adonisjs/public/themes/jacinto/input.html @@ -583,6 +583,6 @@ cy="186.4236" r="25.741863" /> - + diff --git a/src/adonisjs/public/themes/jacinto/notice.html b/src/adonisjs/public/themes/jacinto/notice.html index bc0dcf710..96374078a 100644 --- a/src/adonisjs/public/themes/jacinto/notice.html +++ b/src/adonisjs/public/themes/jacinto/notice.html @@ -91,12 +91,12 @@ r="25.265163" inkscape:label="#path38" /> - + - + - + diff --git a/src/adonisjs/public/themes/jacinto/notice_exam_zoom.html b/src/adonisjs/public/themes/jacinto/notice_exam_zoom.html index 141ad6ddc..a9b45f659 100644 --- a/src/adonisjs/public/themes/jacinto/notice_exam_zoom.html +++ b/src/adonisjs/public/themes/jacinto/notice_exam_zoom.html @@ -98,12 +98,12 @@ r="25.265163" inkscape:label="#path38" /> - + - + - + diff --git a/src/adonisjs/public/themes/jacinto/notice_wide.html b/src/adonisjs/public/themes/jacinto/notice_wide.html index 6f00d9ef2..3f49a84b6 100644 --- a/src/adonisjs/public/themes/jacinto/notice_wide.html +++ b/src/adonisjs/public/themes/jacinto/notice_wide.html @@ -90,12 +90,12 @@ r="25.265163" inkscape:label="#path38" /> - + - + - + diff --git a/src/adonisjs/public/themes/jacinto/old/detailed.html b/src/adonisjs/public/themes/jacinto/old/detailed.html index 1637d1511..6bd6ee236 100644 --- a/src/adonisjs/public/themes/jacinto/old/detailed.html +++ b/src/adonisjs/public/themes/jacinto/old/detailed.html @@ -214,7 +214,7 @@ id="Path_320" /> - + - + - + - + \ No newline at end of file diff --git a/src/adonisjs/public/themes/jacinto/presentation_3.html b/src/adonisjs/public/themes/jacinto/presentation_3.html index 0a4603119..3fcb4711a 100644 --- a/src/adonisjs/public/themes/jacinto/presentation_3.html +++ b/src/adonisjs/public/themes/jacinto/presentation_3.html @@ -861,6 +861,6 @@ cy="186.4236" r="25.741863" /> - + diff --git a/src/adonisjs/public/themes/jacinto/presentation_4.html b/src/adonisjs/public/themes/jacinto/presentation_4.html index 0f182aba0..b17116e0f 100644 --- a/src/adonisjs/public/themes/jacinto/presentation_4.html +++ b/src/adonisjs/public/themes/jacinto/presentation_4.html @@ -958,6 +958,6 @@ cy="186.4236" r="25.741863" /> - + diff --git a/src/adonisjs/public/themes/minimal/note.html b/src/adonisjs/public/themes/minimal/note.html index 521031651..4838af380 100644 --- a/src/adonisjs/public/themes/minimal/note.html +++ b/src/adonisjs/public/themes/minimal/note.html @@ -1,6 +1,6 @@
- +
{knot}
diff --git a/src/adonisjs/public/themes/plain/local/note.js b/src/adonisjs/public/themes/plain/local/note.js index 33ea1be1c..f1ce15eb0 100644 --- a/src/adonisjs/public/themes/plain/local/note.js +++ b/src/adonisjs/public/themes/plain/local/note.js @@ -2,7 +2,7 @@ const localTheme = `
- +
{knot}
diff --git a/src/adonisjs/public/themes/simple-svg/detailed.html b/src/adonisjs/public/themes/simple-svg/detailed.html index f3b7b84b2..a545c474e 100644 --- a/src/adonisjs/public/themes/simple-svg/detailed.html +++ b/src/adonisjs/public/themes/simple-svg/detailed.html @@ -539,6 +539,6 @@ r="25.741863" visibility="hidden" /> - + diff --git a/src/adonisjs/public/themes/simple-svg/exam.html b/src/adonisjs/public/themes/simple-svg/exam.html index a1670b89d..8c8f26961 100644 --- a/src/adonisjs/public/themes/simple-svg/exam.html +++ b/src/adonisjs/public/themes/simple-svg/exam.html @@ -666,6 +666,6 @@ r="25.741863" visibility="hidden" /> - + diff --git a/src/adonisjs/public/themes/simple-svg/input.html b/src/adonisjs/public/themes/simple-svg/input.html index 147d28a0b..a73648701 100644 --- a/src/adonisjs/public/themes/simple-svg/input.html +++ b/src/adonisjs/public/themes/simple-svg/input.html @@ -586,6 +586,6 @@ r="25.741863" visibility="hidden" /> - + diff --git a/src/adonisjs/public/themes/simple/local/note.js b/src/adonisjs/public/themes/simple/local/note.js index 33ea1be1c..f1ce15eb0 100644 --- a/src/adonisjs/public/themes/simple/local/note.js +++ b/src/adonisjs/public/themes/simple/local/note.js @@ -2,7 +2,7 @@ const localTheme = `
- +
{knot}
diff --git a/src/adonisjs/public/themes/simple/note.html b/src/adonisjs/public/themes/simple/note.html index 725d15ebb..e3366fdee 100644 --- a/src/adonisjs/public/themes/simple/note.html +++ b/src/adonisjs/public/themes/simple/note.html @@ -10,7 +10,7 @@
- +
diff --git a/src/adonisjs/public/themes/simple/note_references.html b/src/adonisjs/public/themes/simple/note_references.html index afad77caa..cb25a0ea5 100644 --- a/src/adonisjs/public/themes/simple/note_references.html +++ b/src/adonisjs/public/themes/simple/note_references.html @@ -10,7 +10,7 @@
- +
diff --git a/src/adonisjs/public/themes/zombie/local/note.js b/src/adonisjs/public/themes/zombie/local/note.js index 33ea1be1c..f1ce15eb0 100644 --- a/src/adonisjs/public/themes/zombie/local/note.js +++ b/src/adonisjs/public/themes/zombie/local/note.js @@ -2,7 +2,7 @@ const localTheme = `
- +
{knot}
diff --git a/src/adonisjs/public/themes/zombie/note.html b/src/adonisjs/public/themes/zombie/note.html index 1eaf50904..7b7a77ad2 100644 --- a/src/adonisjs/public/themes/zombie/note.html +++ b/src/adonisjs/public/themes/zombie/note.html @@ -1,6 +1,6 @@
- +
{knot}
diff --git a/src/adonisjs/public/translator/playground/js/author-versum.js b/src/adonisjs/public/translator/playground/js/author-versum.js index e0388d62c..7f24c0962 100644 --- a/src/adonisjs/public/translator/playground/js/author-versum.js +++ b/src/adonisjs/public/translator/playground/js/author-versum.js @@ -16,7 +16,7 @@ class AuthorVersumManager { this.updateVisibility = this.updateVisibility.bind(this) MessageBus.i.subscribe('control/translate/example', this.translate) - MessageBus.i.subscribe('var/output/changed', this.updateVisibility) + MessageBus.i.subscribe('input/changed/output', this.updateVisibility) } async translate (topic, message) { diff --git a/src/adonisjs/public/translator/translator.js b/src/adonisjs/public/translator/translator.js index b7d38e878..4f799ee09 100644 --- a/src/adonisjs/public/translator/translator.js +++ b/src/adonisjs/public/translator/translator.js @@ -425,7 +425,7 @@ class Translator { // can be interesting this link in the future // compiled[c].input = this.findContext(knotSet, knotId, compiled[c].input); else if (compiled[c].type == 'option' || - compiled[c].type == 'divert') { + compiled[c].type == 'divert') { compiled[c].contextTarget = this._findTarget(knotSet, knotId, compiled[c].target) } else if (compiled[c].type == 'text-block') @@ -654,41 +654,7 @@ class Translator { } } - // seventh cycle - aggregates options - let optionGroup = null - let subtype = null - for (let c = 1; c < compiled.length; c++) { - const pr = (c > 1 && compiled[c - 1].type == 'linefeed') ? c - 2 : c - 1 - if (compiled[c].type == 'option') { - let stype = compiled[c].subtype - if (compiled[pr].type == 'option' && compiled[c].subtype == subtype) { - optionGroup = this._initializeObject( - { - type: 'input', - subtype: 'choice', - exclusive: true, - shuffle: (subtype == '+'), - options: {} - }, compiled[pr]._source) - this._transferOption(optionGroup.options, compiled[pr]) - compiled[pr] = optionGroup - } - if (optionGroup != null && compiled[c].subtype == subtype) { - this._transferOption(optionGroup.options, compiled[c]) - optionGroup._source += '\n' + compiled[c]._source - const shift = c - pr - compiled.splice(c - shift + 1, shift) - c -= shift - } else - optionGroup = null - subtype = stype - } else if (compiled[c].type != 'linefeed') { - optionGroup = null - } - compiled[c].seq = c + 1 - } - - // eighth cycle - computes subordinate elements + // seventh cycle - computes subordinate elements for (let c = 0; c < compiled.length; c++) { const pr = (c > 1 && compiled[c - 1].type == 'linefeed') ? c - 2 : c - 1 // later blockquotes and subordinates (excluding knot subordinates) @@ -727,14 +693,6 @@ class Translator { (compiled[c].subordinate || compiled[c].blockquote)) { compiled[pr][Translator.element[compiled[pr].type].subtext] = compiled[c].content - /* - if (compiled[pr][Translator.element[compiled[pr].type].subtext] == null) - compiled[pr][Translator.element[compiled[pr].type].subtext] = - compiled[c].content; - else - compiled[pr][Translator.element[compiled[pr].type].subtext] += "\n" + - compiled[c].content; - */ merge = true } if (merge) { @@ -743,19 +701,71 @@ class Translator { compiled[pr].mergeLine = Translator.element[compiled[c].type] && Translator.isLine.includes(compiled[c].type) - /* - compiled[pr].mergeLine = - (Translator.element[compiled[c].type] && - Translator.element[compiled[c].type].line !== undefined) - ? Translator.element[compiled[c].type].line : false; - */ const shift = c - pr compiled.splice(c - shift + 1, shift) c -= shift } } - // previous blockquotes for inputs - else if (compiled[c].type == 'input' && compiled[pr].blockquote) { + // manages elements subordinated to the knot + else if ((c == 0 || (c == 1 && compiled[c - 1].type == 'linefeed')) && + compiled[c].subordinate && compiled[c].type == 'image') { + // console.log('=== image back') + unity.background = { + alternative: compiled[c].alternative, + path: compiled[c].path + } + if (compiled[c].title) { unity.background.title = compiled[c].title } + compiled[c].render = false + } + if (c >= 0) { compiled[c].seq = c + 1 } + } + + // eighth cycle - aggregates options + let optionGroup = null + let subtype = null + for (let c = 1; c < compiled.length; c++) { + const pr = (c > 1 && compiled[c - 1].type == 'linefeed') ? c - 2 : c - 1 + if (compiled[c].type == 'option') { + console.log('=== previous') + console.log(compiled[pr]) + let stype = compiled[c].subtype + if (compiled[pr].type == 'input' && compiled[pr].subtype && + compiled[pr].subtype == 'choice' && compiled[pr].options == null) { + subtype = stype + optionGroup = compiled[pr] + optionGroup.options = {} + } else if (compiled[pr].type == 'option' && + compiled[c].subtype == subtype) { + optionGroup = this._initializeObject( + { + type: 'input', + subtype: 'choice', + exclusive: true, + shuffle: (subtype == '+'), + options: {} + }, compiled[pr]._source) + this._transferOption(optionGroup.options, compiled[pr]) + compiled[pr] = optionGroup + } + if (optionGroup != null && compiled[c].subtype == subtype) { + this._transferOption(optionGroup.options, compiled[c]) + optionGroup._source += '\n' + compiled[c]._source + const shift = c - pr + compiled.splice(c - shift + 1, shift) + c -= shift + } else + optionGroup = null + subtype = stype + } else if (compiled[c].type != 'linefeed' || + compiled[c].content.length > 1) + optionGroup = null + compiled[c].seq = c + 1 + } + + // ninth cycle - previous blockquotes for inputs + for (let c = 0; c < compiled.length; c++) { + const pr = (c > 1 && compiled[c - 1].type == 'linefeed') ? c - 2 : c - 1 + if (compiled[c].type == 'input' && compiled[pr].blockquote) { let content = compiled[pr].content let source = compiled[pr]._source @@ -773,21 +783,10 @@ class Translator { compiled.splice(pr, shift) c -= shift } - // manages elements subordinated to the knot - else if ((c == 0 || (c == 1 && compiled[c - 1].type == 'linefeed')) && - compiled[c].subordinate && compiled[c].type == 'image') { - // console.log('=== image back') - unity.background = { - alternative: compiled[c].alternative, - path: compiled[c].path - } - if (compiled[c].title) { unity.background.title = compiled[c].title } - compiled[c].render = false - } if (c >= 0) { compiled[c].seq = c + 1 } } - // ninth cycle - joins script sentences + // tenth cycle - joins script sentences // quite similar to text-block (join?) let script let scriptSeq @@ -828,7 +827,7 @@ class Translator { this._compileMergeLinefeeds(compiled) - // tenth cycle - process and hide formal comments + // eleventh cycle - process and hide formal comments let inFormal = false let lastContext = null let lastId = null @@ -1864,7 +1863,12 @@ class Translator { _transformNavigationMessage (target) { let message const lower = target.toLowerCase() - if (Translator.reservedNavigation.includes(lower)) { message = Translator.navigationMap[lower] } else if (lower.startsWith('variable.')) { message = 'variable/' + target.substring(9) + '/navigate' } else { message = 'knot/' + target + '/navigate' } + if (Translator.reservedNavigation.includes(lower)) { + message = Translator.navigationMap[lower] } + else if (lower.startsWith('variable.')) + message = 'knot/navigate/=/' + target.substring(9).replace(/\./g, '/') + else + message = 'knot/navigate/' + target.replace(/\./g, '/') return message } @@ -2232,7 +2236,10 @@ class Translator { // provisory - weak strategy (only one per case) let answer = '' if (this._playerInputShow || this.authoringRender) { - if (this._playerInputShow == '#answer' || this.authoringRender) { answer = " answer='" + obj.value + "'" } else { answer = " player='" + this._playerInputShow + "'" } + if (this._playerInputShow == '#answer' || this.authoringRender) + { answer = " answer='" + obj.value + "'" } + else + { answer = " player='" + this._playerInputShow + "'" } } let extraAttr = '' @@ -2266,7 +2273,10 @@ class Translator { // indicates how related selects will behave this._playerInputShow = null if (obj.show) { - if (obj.show == 'answer') { this._playerInputShow = '#answer' } else { this._playerInputShow = obj.variable } + if (obj.show == 'answer') + this._playerInputShow = '#answer' + else + this._playerInputShow = obj.variable } } @@ -2681,11 +2691,11 @@ class Translator { 'knot.previous', 'knot.next', 'flow.next', 'session.close'] Translator.navigationMap = { - 'case.next': 'case/>/navigate', - 'knot.start': 'knot/</navigate', - 'flow.next': 'flow/>/navigate', + 'case.next': 'case/navigate/>', + 'knot.start': 'knot/navigate/<<', + 'knot.previous': 'knot/navigate/<', + 'knot.next': 'knot/navigate/>', + 'flow.next': 'flow/navigate/>', 'session.close': 'session/close' }