diff options
| author | Jules Laplace <jules@okfoc.us> | 2013-01-24 15:50:46 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2013-01-24 15:50:46 -0500 |
| commit | 17da997822d1a1d84cb996cc60b84a14aec62a1f (patch) | |
| tree | e830952d44ffdfde4f52665b3b4a785156fb1bed /public/javascripts/game.js | |
| parent | 704c2d7bf8dad10997ae143a575d9432519ff771 (diff) | |
| parent | 107daeccf148f2c7b56bd77815b62030803aa813 (diff) | |
logo hoveR
Diffstat (limited to 'public/javascripts/game.js')
| -rw-r--r-- | public/javascripts/game.js | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/public/javascripts/game.js b/public/javascripts/game.js index 184d3a9..2ddc432 100644 --- a/public/javascripts/game.js +++ b/public/javascripts/game.js @@ -53,32 +53,43 @@ var game = { }, bindEvents: function(){ - window.onblur = function () { - $("#really_waiting").html("BLUR"); - socket.emit('blur', { id: _id }); - blurTime = Date.now(); - afk = true; - own_cursor.el.addClass('idle'); - } - window.onfocus = function () { - $("#really_waiting").html("FOCUS"); - socket.emit('focus', { id: _id }); - afk = false; - own_cursor.el.removeClass('idle'); - if (blurTime) { - delay += (Date.now() - blurTime); - $("#reset").html( "You left the page for " + timeInWords(delay) + ", counting it against your score.." ); - } - } var emit_mouse_movement = $.throttle(50, function (e) { var y = Math.floor( e.pageY - window.innerHeight / 2 ); var x = Math.floor( e.pageX - window.innerWidth / 2 ); socket.emit('mouse', { x: x, y: y, id: _id }); }); - window.onmousemove = function(e){ - emit_mouse_movement(e); - own_cursor.el.css({ 'left': e.pageX, 'top': e.pageY }); - } + $(window).bind({ + blur: function () { + $("#really_waiting").html("BLUR"); + socket.emit('blur', { id: _id }); + blurTime = Date.now(); + afk = true; + own_cursor.el.addClass('idle'); + }, + focus: function () { + $("#really_waiting").html("FOCUS"); + socket.emit('focus', { id: _id }); + afk = false; + own_cursor.el.removeClass('idle').show(); + if (blurTime) { + delay += (Date.now() - blurTime); + $("#reset").html( "You left the page for " + timeInWords(delay) + ", counting it against your score.." ); + } + }, + mousemove: function(e){ + emit_mouse_movement(e); + own_cursor.el.css({ 'left': e.pageX, 'top': e.pageY }); + } + }); + + $(".okfocus").bind({ + mouseover: function(){ + own_cursor.el.hide(); + }, + mouseout: function(){ + own_cursor.el.show(); + } + }); } }; |
