mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-04-07 18:44:29 -04:00
Implement saving lastLevel in database re #627
This commit is contained in:
parent
f0640dd2e8
commit
a35d0cb651
4 changed files with 13 additions and 13 deletions
|
@ -31,14 +31,11 @@ module.exports = class HomeView extends View
|
|||
$('input:visible:first', @).focus()
|
||||
|
||||
# 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[0]?
|
||||
href = playLink.attr("href").split("/")
|
||||
href[href.length-1] = lastLevel if href.length isnt 0
|
||||
href = href.join("/")
|
||||
playLink.attr("href", href)
|
||||
else
|
||||
console.log("TODO: Insert here code to get latest level played from the database. If this can't be found, we just let the user play the first level.")
|
||||
lastLevel = me.get("lastLevel")
|
||||
if lastLevel? and lastLevel isnt ""
|
||||
playLink = @$el.find("#beginner-campaign")
|
||||
if playLink[0]?
|
||||
href = playLink.attr("href").split("/")
|
||||
href[href.length-1] = lastLevel if href.length isnt 0
|
||||
href = href.join("/")
|
||||
playLink.attr("href", href)
|
|
@ -154,7 +154,9 @@ module.exports = class PlayLevelView extends View
|
|||
return Backbone.Mediator.subscribeOnce 'modal-closed', @onLevelLoaderLoaded, @
|
||||
|
||||
# Save latest level played in local storage
|
||||
localStorage["lastLevel"] = @levelID if localStorage? and not (@levelLoader.level.get('type') in ['ladder', 'ladder-tutorial'])
|
||||
if not (@levelLoader.level.get('type') in ['ladder', 'ladder-tutorial'])
|
||||
me.set('lastLevel', @levelID)
|
||||
me.save()
|
||||
@grabLevelLoaderData()
|
||||
team = @getQueryVariable("team") ? @world.teamForPlayer(0)
|
||||
@loadOpponentTeam(team)
|
||||
|
|
|
@ -18,7 +18,7 @@ UserHandler = class UserHandler extends Handler
|
|||
'name', 'photoURL', 'password', 'anonymous', 'wizardColor1', 'volume',
|
||||
'firstName', 'lastName', 'gender', 'facebookID', 'emailSubscriptions',
|
||||
'testGroupNumber', 'music', 'hourOfCode', 'hourOfCodeComplete', 'preferredLanguage',
|
||||
'wizard', 'aceConfig', 'simulatedBy', 'simulatedFor', 'autocastDelay'
|
||||
'wizard', 'aceConfig', 'simulatedBy', 'simulatedFor', 'autocastDelay', 'lastLevel'
|
||||
]
|
||||
|
||||
jsonSchema: schema
|
||||
|
|
|
@ -18,6 +18,7 @@ UserSchema = c.object {},
|
|||
volume: c.pct({title: 'Volume'})
|
||||
music: {type: 'boolean', default: true}
|
||||
autocastDelay: {type: 'integer', 'default': 5000 }
|
||||
lastLevel: { type: 'string' }
|
||||
|
||||
emailSubscriptions: c.array {uniqueItems: true, 'default': ['announcement', 'notification']}, {'enum': emailSubscriptions}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue