diff options
| author | Jules Laplace <jules@okfoc.us> | 2013-03-05 03:47:49 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2013-03-05 03:47:49 -0500 |
| commit | c9b139fbbf6ff83f1a5956b54cf88572e9aba7d9 (patch) | |
| tree | 920de0ea763f7c2535b73d463c617fb1cdb89243 /public/js | |
| parent | 04c5f336da58aad01e81d48c8c220758863c453d (diff) | |
fix win state
Diffstat (limited to 'public/js')
| -rw-r--r-- | public/js/game.js | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/public/js/game.js b/public/js/game.js index cd88014..1c27081 100644 --- a/public/js/game.js +++ b/public/js/game.js @@ -108,6 +108,7 @@ UI[ State.WAITING ] = new function() { this.load = function(data){ $("#current-state").html("Waiting"); $("#drawing").show(); + $(window).trigger("drawing:start") } this.unload = function(){ $("#drawing").hide(); @@ -162,15 +163,18 @@ UI[ State.WINNING ] = new function(){ for (var i in data.scores) { scores.push( [data.scores[i], i] ); } - console.log(scores); - var topthree = scores.sort(function(a,b){ a[0] - b[0] }).splice(0, 3); console.log(data); + console.log(scores); + var topthree = _.chain(data.scores).keys().sortBy(function(x){ data.scores[x] }); + console.log(topthree); + topthree = topthree.value().splice(0, 3); + console.log(topthree); for (var i in topthree) { - var score = topthree[i][0] - var nick = topthree[i][1] + var nick = topthree[i]; var image = data.images[ nick ]; var $li = $("<li>"); - $li.html("<img src='" + image.url + "'> " + image.nick ); + $li.html("<img src='" + image.url + "'> " + image.nick + " " + data.scores[nick] ); + $("#winning").append($li); } } this.load = function(data){ |
