Created
November 12, 2013 15:02
-
-
Save framon/7432287 to your computer and use it in GitHub Desktop.
Basic jQuery to detect idle time. TODO: Improve
This file contains 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 characters
idleTime = 0; | |
$(document).ready(function () { | |
//Increment the idle time counter every minute. | |
var idleInterval = setInterval(timerIncrement, 60000); // 1 minute | |
//Zero the idle timer on mouse movement. | |
$(this).mousemove(function (e) { | |
idleTime = 0; | |
}); | |
$(this).keypress(function (e) { | |
idleTime = 0; | |
}); | |
}); | |
function timerIncrement() { | |
idleTime = idleTime + 1; | |
if (idleTime > 19) { // 20 minutes | |
window.location.reload(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how do i implement it?