mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-28 01:55:38 -05:00
Live leaderboard updating
This commit is contained in:
parent
1efb96f24a
commit
a5864c4f0c
2 changed files with 16 additions and 1 deletions
|
@ -14,6 +14,9 @@ module.exports = class MyMatchesTabView extends CocoView
|
|||
|
||||
constructor: (options, @level, @sessions) ->
|
||||
super(options)
|
||||
@refreshMatches()
|
||||
|
||||
refreshMatches: ->
|
||||
@teams = teamDataFromLevel @level
|
||||
@nameMap = {}
|
||||
@loadNames()
|
||||
|
@ -82,6 +85,7 @@ module.exports = class MyMatchesTabView extends CocoView
|
|||
c1 and not _.isEqual(c1, c2)
|
||||
|
||||
rankSession: (e) ->
|
||||
console.log "Clicked"
|
||||
button = $(e.target).closest('.rank-button')
|
||||
sessionID = button.data('session-id')
|
||||
session = _.find @sessions.models, { id: sessionID }
|
||||
|
|
|
@ -64,7 +64,18 @@ module.exports = class LadderView extends RootView
|
|||
return if @startsLoading
|
||||
@insertSubView(@ladderTab = new LadderTabView({}, @level, @sessions))
|
||||
@insertSubView(@myMatchesTab = new MyMatchesTabView({}, @level, @sessions))
|
||||
|
||||
setInterval(@fetchSessionsAndRefreshViews.bind(@), 10000)
|
||||
|
||||
fetchSessionsAndRefreshViews: ->
|
||||
@sessions.fetch({"success": @refreshViews})
|
||||
|
||||
refreshViews: =>
|
||||
@ladderTab.constructor({}, @level, @sessions)
|
||||
@myMatchesTab.refreshMatches()
|
||||
console.log "refreshed views!"
|
||||
|
||||
|
||||
|
||||
# Simulations
|
||||
|
||||
onSimulateAllButtonClick: (e) ->
|
||||
|
|
Loading…
Reference in a new issue