Merge branch 'feature/play-button' of https://github.com/dristic/codecombat into test

This commit is contained in:
GlenDC 2014-01-19 14:04:26 +01:00
commit 1f486c3cb6
2 changed files with 15 additions and 0 deletions

View file

@ -34,6 +34,17 @@ module.exports = class HomeView extends View
@wizardType.fetch()
@wizardType.once 'sync', @initCanvas
# Try to find latest level and set "Play" link to go to that level
if localStorage?
lastLevel = localStorage["lastLevel"]
if lastLevel? and lastLevel isnt ""
playLink = @$el.find("#beginner-campaign")
if playLink?
href = playLink.attr("href").split("/")
href[href.length-1] = lastLevel if href.length isnt 0
href = href.join("/")
playLink.attr("href", href)
initCanvas: =>
@stage = new createjs.Stage($('#beginner-campaign canvas', @$el)[0])
@createWizard()

View file

@ -81,6 +81,10 @@ module.exports = class PlayLevelView extends View
@load() unless @isEditorPreview
# Save latest level played in local storage
if localStorage?
localStorage["lastLevel"] = @levelID
setLevel: (@level, @supermodel) ->
@god?.level = @level.serialize @supermodel
@load()