From c9b139fbbf6ff83f1a5956b54cf88572e9aba7d9 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 5 Mar 2013 03:47:49 -0500 Subject: fix win state --- public/js/game.js | 14 +++++++++----- 1 file 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.html(" " + image.nick ); + $li.html(" " + image.nick + " " + data.scores[nick] ); + $("#winning").append($li); } } this.load = function(data){ -- cgit v1.2.3-70-g09d2