Permalink
Browse files

timer and score workin

  • Loading branch information...
1 parent ec8aa62 commit 4d3a1e4668607395ef2339329afa224e252654de @deepak1556 deepak1556 committed Dec 1, 2012
Showing with 26 additions and 5 deletions.
  1. +11 −5 static/script.js
  2. +13 −0 static/style.css
  3. +2 −0 views/index.ejs
View
@@ -68,7 +68,12 @@ var Queue = {
var countdown = function(value){
this.minute = value[0];
- this.second = value[1];
+ this.second = value[1]+1;
+};
+
+countdown.prototype.init = function(){
+ var self = this;
+ var set = setInterval(function(){self.tick();},1000);
};
countdown.prototype.tick = function(){
@@ -87,7 +92,7 @@ countdown.prototype.tick = function(){
countdown.prototype.update = function(){
var seconds = this.second;
if(seconds<10) seconds = "0" + seconds;
- $("#answer").val(this.minute + ":" + seconds);
+ $("#timer").val(this.minute + ":" + seconds);
};
$( function() {
@@ -102,10 +107,10 @@ $( function() {
}
}
});
- //timerbug to fix
+ //timer
socket.on('timer',function(data) {
- countdown(data.start);
- var set = setInterval(countdown.tick(),1000);
+ var time = new countdown(data.start);
+ time.init();
});
socket.on('result', function(data) {
if(data.correct) {
@@ -115,6 +120,7 @@ $( function() {
backgroundColor: "#000"
},750);
Board.unselectall();
+ $("#score").val(data.score);
}
else $("#answer").css("background","#500").stop().animate({
backgroundColor: "#000"
View
@@ -68,3 +68,16 @@ body {
color: white;
border: 0;
}
+
+#timer,#score {
+ width: 100px;
+ margin: 0;
+ margin-top: 40px;
+ letter-spacing: 4px;
+ padding: 15px;
+ font-size: 20px;
+ outline: none;
+ background: black;
+ color: white;
+ border: 0;
+}
View
@@ -14,6 +14,8 @@
</div>
<div class="right circularbg">
<div id="queueContainer">
+ <input type="text" id="timer" />
+ <input type="text" id="score" />
<h3>Found: </h3>
<ul id="queue">
</ul>

0 comments on commit 4d3a1e4

Please sign in to comment.