Last active
September 15, 2021 15:45
Revisions
-
maccman revised this gist
Jul 7, 2013 . 1 changed file with 2 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,12 +4,11 @@ var TIMEOUT = 20000; var lastTime = (new Date()).getTime(); setInterval(function() { var currentTime = (new Date()).getTime(); if (currentTime > (lastTime + TIMEOUT + 2000)) { $(document).wake(); } lastTime = currentTime; }, TIMEOUT); $.fn.wake = function(callback) { -
maccman created this gist
Jul 7, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ $ = jQuery TIMEOUT = 20000 lastTime = (new Date()).getTime() setInterval -> currentTime = (new Date()).getTime() # If timeout was paused (ignoring small # variations) then trigger the 'wake' event if currentTime > (lastTime + TIMEOUT + 2000) $(document).wake() lastTime = currentTime , TIMEOUT $.fn.wake = (callback) -> if typeof callback is 'function' $(this).on('wake', callback) else $(this).trigger('wake', arguments...) This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ (function($){ var TIMEOUT = 20000; var lastTime = (new Date()).getTime(); setInterval(function() { var currentTime; currentTime = (new Date()).getTime(); if (currentTime > (lastTime + TIMEOUT + 2000)) { $(document).wake(); } return lastTime = currentTime; }, TIMEOUT); $.fn.wake = function(callback) { if (typeof callback === 'function') { return $(this).on('wake', callback); } else { return $(this).trigger('wake'); } }; })(jQuery);