mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-02-17 08:50:58 -05:00
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
|
@ -13,6 +13,8 @@ function receiveMessage(event) {
|
|||
//console.log(event);
|
||||
switch (event.data.type) {
|
||||
case 'create':
|
||||
create(event.data.dom);
|
||||
break;
|
||||
case 'update':
|
||||
if (virtualDOM)
|
||||
update(event.data.dom);
|
||||
|
|
|
@ -147,5 +147,6 @@ module.exports =
|
|||
'tome:hide-problem-alert': c.object {title: 'Hide Problem Alert'}
|
||||
'tome:jiggle-problem-alert': c.object {title: 'Jiggle Problem Alert'}
|
||||
|
||||
'tome:html-updated': c.object {title: 'HTML Updated', required: ['html']},
|
||||
html: {type: 'string'}
|
||||
'tome:html-updated': c.object {title: 'HTML Updated', required: ['html', 'create']},
|
||||
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
|
||||
@onIframeLoaded?()
|
||||
@onIframeLoaded = null
|
||||
|
||||
# TODO: make clicking Run actually trigger a 'create' update here (for resetting scripts)
|
||||
|
||||
onHTMLUpdated: (e) ->
|
||||
unless @iframeLoaded
|
||||
|
@ -31,8 +33,12 @@ module.exports = class WebSurfaceView extends CocoView
|
|||
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
|
||||
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}, '*'
|
||||
@virtualDOM = virtualDOM
|
||||
|
||||
checkGoals: (dom) ->
|
||||
# TODO: uhh, figure these out
|
||||
|
||||
dekuify: (elem) ->
|
||||
return elem.data if elem.type is 'text'
|
||||
|
|
|
@ -40,7 +40,7 @@ module.exports = class CastButtonView extends CocoView
|
|||
super()
|
||||
@castButton = $('.cast-button', @$el)
|
||||
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.
|
||||
if @options.session.get('state')?.complete and @options.level.get 'hidesRealTimePlayback'
|
||||
@$el.find('.done-button').show()
|
||||
|
|
|
@ -539,7 +539,7 @@ module.exports = class SpellView extends CocoView
|
|||
Backbone.Mediator.publish 'tome:spell-loaded', spell: @spell
|
||||
@eventsSuppressed = false # Now that the initial change is in, we can start running any changed code
|
||||
@createToolbarView()
|
||||
@updateHTML() if @options.level.isType('web-dev')
|
||||
@updateHTML create: true if @options.level.isType('web-dev')
|
||||
|
||||
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.
|
||||
|
@ -663,6 +663,7 @@ module.exports = class SpellView extends CocoView
|
|||
cast = @$el.parent().length
|
||||
@recompile cast, e.realTime
|
||||
@focus() if cast
|
||||
@updateHTML create: true if @options.level.isType('web-dev')
|
||||
|
||||
onCodeReload: (e) ->
|
||||
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.
|
||||
|
||||
updateHTML: =>
|
||||
Backbone.Mediator.publish 'tome:html-updated', html: @spell.constructHTML @getSource()
|
||||
updateHTML: (options={}) =>
|
||||
Backbone.Mediator.publish 'tome:html-updated', html: @spell.constructHTML(@getSource()), create: Boolean(options.create)
|
||||
|
||||
# Design for a simpler system?
|
||||
# * Keep Aether linting, debounced, on any significant change
|
||||
|
|
Loading…
Reference in a new issue