From faba0ff6a6c4cc43ffa9b1ba7be5b2bc8d5c47d2 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 24 Jan 2013 17:13:44 -0500 Subject: blur issue --- app.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'app.js') diff --git a/app.js b/app.js index 2b1bfce..4656530 100644 --- a/app.js +++ b/app.js @@ -159,7 +159,8 @@ io.sockets.on('connection', function (socket) { } socket.emit('scores', { 'scores': scores.reverse(), - 'users': users + 'users': users, + 'now': Date.now() }) }); @@ -185,6 +186,7 @@ io.sockets.on('connection', function (socket) { image: user.image, count: user.count, connected: now, + current: 0, active: true }; @@ -202,11 +204,12 @@ io.sockets.on('connection', function (socket) { socket.on('blur', function(data){ if (! socket.user) return; var now = Date.now(); - updateTime(socket.user, now, socket.connected); - socket.connected = now; if (socket.user.id in users) { users[socket.user.id].active = false; + users[socket.user.id].current += now - socket.connected; } + updateTime(socket.user, now, socket.connected); + socket.connected = now; io.sockets.emit('blur', data); }); @@ -214,7 +217,9 @@ io.sockets.on('connection', function (socket) { if (!socket.user) return; var now = Date.now(); socket.connected = now; - users[socket.user.id].active = true; + if (socket.user.id in users) { + users[socket.user.id].active = true; + } io.sockets.emit('focus', data); }); @@ -230,7 +235,6 @@ io.sockets.on('connection', function (socket) { users: users, now: now }); - }); }); -- cgit v1.2.3-70-g09d2