BattleSim/client/app/js/concerns/router.coffee

22 lines
594 B
CoffeeScript
Raw Normal View History

2016-02-01 22:19:30 +00:00
class PokeBattleRouter extends Backbone.Router
routes:
"" : "main"
"battles/:id" : "spectateBattle"
main: =>
$navigation = $('#navigation')
$navigation.find('.nav_item').first().click()
spectateBattle: (id) =>
if PokeBattle.battles.get(id)
PokeBattle.navigation.changeWindowToBattle(id)
else
PokeBattle.primus.send('spectateBattle', id)
PokeBattle.router = new PokeBattleRouter()
PokeBattle.primus.once "loginSuccess", ->
return if Backbone.History.started
PokeBattle.events.trigger("ready")
routed = Backbone.history.start(pushState: true)