summaryrefslogtreecommitdiff
path: root/public/js/game.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/js/game.js')
-rw-r--r--public/js/game.js22
1 files changed, 20 insertions, 2 deletions
diff --git a/public/js/game.js b/public/js/game.js
index a4cf74b..0b90328 100644
--- a/public/js/game.js
+++ b/public/js/game.js
@@ -71,7 +71,7 @@ var Events = {
img.src = data.url;
},
- // Another player votes on an image
+ // Another player votes on an image..
vote: function(data){
}
@@ -116,8 +116,9 @@ UI[ State.WAITING ] = new function() {
UI[ State.DRAWING ] = new function(){
this.load = function(data){
- $("#current-state").html("Draw!");
+ $("#current-state").html("Draw! The word is " + data.word);
$("#drawing").show();
+ $(window).trigger("drawing:start")
},
this.unload = function(){
$("#drawing").hide();
@@ -149,13 +150,30 @@ UI[ State.VOTING ] = new function(){
this.click = function(){
voted = true;
var nick = $(this).data("nick");
+ console.log("VOTE >> ", nick);
Events.send.vote({ nick: nick });
}
}
UI[ State.WINNING ] = new function(){
+ this.build = function(data){
+ $("#winning").empty();
+ var scores = [];
+ for (var i in data.scores) {
+ scores.push( [data.scores[i], i] );
+ }
+ var topthree = scores.sort(function(){ a[0] - b[0] }).splice(0, 3);
+ for (var i in topthree) {
+ var score = topthree[i][0]
+ var nick = topthree[i][1]
+ var image = data.images[ nick ];
+ var $li = $("<li>");
+ $li.html("<img src='" + image.url + "'> " + image.nick );
+ }
+ }
this.load = function(data){
$("#current-state").html("Win!");
+ this.build(data);
$("#winning").show();
}
this.unload = function(){