Browse Source

fix clear interval on checkmate or draw

romanmatiasko 10 years ago
parent
commit
fe5ff9d9f6
2 changed files with 8 additions and 0 deletions
  1. 4 0
      public/javascripts/play.js
  2. 4 0
      server.js

+ 4 - 0
public/javascripts/play.js

@@ -153,6 +153,10 @@ function movePiece(from, to, promotion, rcvd) {
     }
 
     if ($chess.game_over()) {
+      $socket.emit('timer-clear-interval', {
+        'token': $token
+      });
+
       $('.resign').hide();
       alert(result);
     } else {

+ 4 - 0
server.js

@@ -125,6 +125,10 @@ io.sockets.on('connection', function (socket) {
     runTimer('black', data.token, socket);
   });
 
+  socket.on('timer-clear-interval', function (data) {
+    clearInterval(games[data.token].interval);
+  });
+
   socket.on('new-move', function (data) {
     var receiver, game;