forked from nko3/website
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gerad Suyderhoud
committed
Nov 5, 2013
1 parent
4390b83
commit 52758e0
Showing
3 changed files
with
45 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
load = -> | ||
ws = io.connect(window.location.origin) | ||
|
||
# reload the page after ~10 seconds (if you're on the index page) | ||
ws.on 'reload', -> | ||
setTimeout -> | ||
if window.location.pathname is '/' | ||
window.location.reload() | ||
, (Math.random() * 10000) | ||
|
||
ws.on 'updateStats', (stats) -> | ||
updateStats $("#overall-stats"), stats | ||
|
||
# update the stats billboard on the team page | ||
ws.on 'updateTeamStats', (json) -> | ||
{ teamId, stats } = json | ||
updateStats $(".team-stats[data-team-id=#{teamId}]"), stats | ||
|
||
# update the deployed stuff | ||
ws.on 'deploy', (team) -> | ||
updateEntryInfo($('#recent-deploys'), team) | ||
|
||
# update the interesting entrys on judge visit | ||
ws.on 'judgeVisit', (team) -> | ||
updateEntryInfo($('#interesting-teams'), team) | ||
|
||
updateStats = ($el, stats) -> | ||
for k, v of stats | ||
$el.find(".#{k} .number").text(v) | ||
|
||
updateEntryInfo = ($el, team) -> | ||
$toAdd = template 'entry-info', team: team | ||
|
||
$toRemove = $el.find(".entry-info[data-team-id=#{team.id}]:first") | ||
if $toRemove.length is 0 | ||
$toRemove = $el.find('.entry-info:last') | ||
|
||
$toRemove.remove() | ||
$toAdd.hide().prependTo($el).animate width: 'show' | ||
|
||
$(load) | ||
# note no pjax load here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters