Run button now recreates web-dev DOM; no submit button
This commit is contained in:
parent
33ba3f6033
commit
220db3106c
5 changed files with 17 additions and 7 deletions
app
assets/javascripts
schemas/subscriptions
views/play/level
|
@ -13,6 +13,8 @@ function receiveMessage(event) {
|
||||||
//console.log(event);
|
//console.log(event);
|
||||||
switch (event.data.type) {
|
switch (event.data.type) {
|
||||||
case 'create':
|
case 'create':
|
||||||
|
create(event.data.dom);
|
||||||
|
break;
|
||||||
case 'update':
|
case 'update':
|
||||||
if (virtualDOM)
|
if (virtualDOM)
|
||||||
update(event.data.dom);
|
update(event.data.dom);
|
||||||
|
|
|
@ -147,5 +147,6 @@ module.exports =
|
||||||
'tome:hide-problem-alert': c.object {title: 'Hide Problem Alert'}
|
'tome:hide-problem-alert': c.object {title: 'Hide Problem Alert'}
|
||||||
'tome:jiggle-problem-alert': c.object {title: 'Jiggle Problem Alert'}
|
'tome:jiggle-problem-alert': c.object {title: 'Jiggle Problem Alert'}
|
||||||
|
|
||||||
'tome:html-updated': c.object {title: 'HTML Updated', required: ['html']},
|
'tome:html-updated': c.object {title: 'HTML Updated', required: ['html', 'create']},
|
||||||
html: {type: 'string'}
|
html: {type: 'string', description: 'The full HTML to display'}
|
||||||
|
create: {type: 'boolean', description: 'Whether we should (re)create the DOM (as opposed to updating it)'}
|
||||||
|
|
|
@ -22,6 +22,8 @@ module.exports = class WebSurfaceView extends CocoView
|
||||||
@iframeLoaded = true
|
@iframeLoaded = true
|
||||||
@onIframeLoaded?()
|
@onIframeLoaded?()
|
||||||
@onIframeLoaded = null
|
@onIframeLoaded = null
|
||||||
|
|
||||||
|
# TODO: make clicking Run actually trigger a 'create' update here (for resetting scripts)
|
||||||
|
|
||||||
onHTMLUpdated: (e) ->
|
onHTMLUpdated: (e) ->
|
||||||
unless @iframeLoaded
|
unless @iframeLoaded
|
||||||
|
@ -31,8 +33,12 @@ module.exports = class WebSurfaceView extends CocoView
|
||||||
html = _.find(dom, name: 'html') ? {name: 'html', attribs: null, children: [body]}
|
html = _.find(dom, name: 'html') ? {name: 'html', attribs: null, children: [body]}
|
||||||
# TODO: pull out the actual scripts, styles, and body/elements they are doing so we can merge them with our initial structure on the other side
|
# TODO: pull out the actual scripts, styles, and body/elements they are doing so we can merge them with our initial structure on the other side
|
||||||
virtualDOM = @dekuify html
|
virtualDOM = @dekuify html
|
||||||
messageType = if @virtualDOM then 'update' else 'create'
|
messageType = if e.create or not @virtualDOM then 'create' else 'update'
|
||||||
@iframe.contentWindow.postMessage {type: messageType, dom: virtualDOM}, '*'
|
@iframe.contentWindow.postMessage {type: messageType, dom: virtualDOM}, '*'
|
||||||
|
@virtualDOM = virtualDOM
|
||||||
|
|
||||||
|
checkGoals: (dom) ->
|
||||||
|
# TODO: uhh, figure these out
|
||||||
|
|
||||||
dekuify: (elem) ->
|
dekuify: (elem) ->
|
||||||
return elem.data if elem.type is 'text'
|
return elem.data if elem.type is 'text'
|
||||||
|
|
|
@ -40,7 +40,7 @@ module.exports = class CastButtonView extends CocoView
|
||||||
super()
|
super()
|
||||||
@castButton = $('.cast-button', @$el)
|
@castButton = $('.cast-button', @$el)
|
||||||
spell.view?.createOnCodeChangeHandlers() for spellKey, spell of @spells
|
spell.view?.createOnCodeChangeHandlers() for spellKey, spell of @spells
|
||||||
if @options.level.get('hidesSubmitUntilRun') or @options.level.get 'hidesRealTimePlayback'
|
if @options.level.get('hidesSubmitUntilRun') or @options.level.get('hidesRealTimePlayback') or @options.level.isType('web-dev')
|
||||||
@$el.find('.submit-button').hide() # Hide Submit for the first few until they run it once.
|
@$el.find('.submit-button').hide() # Hide Submit for the first few until they run it once.
|
||||||
if @options.session.get('state')?.complete and @options.level.get 'hidesRealTimePlayback'
|
if @options.session.get('state')?.complete and @options.level.get 'hidesRealTimePlayback'
|
||||||
@$el.find('.done-button').show()
|
@$el.find('.done-button').show()
|
||||||
|
|
|
@ -539,7 +539,7 @@ module.exports = class SpellView extends CocoView
|
||||||
Backbone.Mediator.publish 'tome:spell-loaded', spell: @spell
|
Backbone.Mediator.publish 'tome:spell-loaded', spell: @spell
|
||||||
@eventsSuppressed = false # Now that the initial change is in, we can start running any changed code
|
@eventsSuppressed = false # Now that the initial change is in, we can start running any changed code
|
||||||
@createToolbarView()
|
@createToolbarView()
|
||||||
@updateHTML() if @options.level.isType('web-dev')
|
@updateHTML create: true if @options.level.isType('web-dev')
|
||||||
|
|
||||||
createDebugView: ->
|
createDebugView: ->
|
||||||
return if @options.level.isType('hero', 'hero-ladder', 'hero-coop', 'course', 'course-ladder', 'game-dev', 'web-dev') # We'll turn this on later, maybe, but not yet.
|
return if @options.level.isType('hero', 'hero-ladder', 'hero-coop', 'course', 'course-ladder', 'game-dev', 'web-dev') # We'll turn this on later, maybe, but not yet.
|
||||||
|
@ -663,6 +663,7 @@ module.exports = class SpellView extends CocoView
|
||||||
cast = @$el.parent().length
|
cast = @$el.parent().length
|
||||||
@recompile cast, e.realTime
|
@recompile cast, e.realTime
|
||||||
@focus() if cast
|
@focus() if cast
|
||||||
|
@updateHTML create: true if @options.level.isType('web-dev')
|
||||||
|
|
||||||
onCodeReload: (e) ->
|
onCodeReload: (e) ->
|
||||||
return unless e.spell is @spell or not e.spell
|
return unless e.spell is @spell or not e.spell
|
||||||
|
@ -727,8 +728,8 @@ module.exports = class SpellView extends CocoView
|
||||||
|
|
||||||
onCursorActivity: => # Used to refresh autocast delay; doesn't do anything at the moment.
|
onCursorActivity: => # Used to refresh autocast delay; doesn't do anything at the moment.
|
||||||
|
|
||||||
updateHTML: =>
|
updateHTML: (options={}) =>
|
||||||
Backbone.Mediator.publish 'tome:html-updated', html: @spell.constructHTML @getSource()
|
Backbone.Mediator.publish 'tome:html-updated', html: @spell.constructHTML(@getSource()), create: Boolean(options.create)
|
||||||
|
|
||||||
# Design for a simpler system?
|
# Design for a simpler system?
|
||||||
# * Keep Aether linting, debounced, on any significant change
|
# * Keep Aether linting, debounced, on any significant change
|
||||||
|
|
Reference in a new issue