Skip to content

Instantly share code, notes, and snippets.

@cchang62
Created April 21, 2017 03:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cchang62/8c41f18677ba0e82d69dd855d63eed09 to your computer and use it in GitHub Desktop.
Save cchang62/8c41f18677ba0e82d69dd855d63eed09 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/wuhafaf
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div id="MinToExpire"></div>
<script id="jsbin-javascript">
var IDLE_TIMEOUT = 60 * 60; //seconds
var _idleSecondsCounter = 0;
document.onclick = function() {
_idleSecondsCounter = 0;
};
document.onmousemove = function() {
_idleSecondsCounter = 0;
};
document.onkeypress = function() {
_idleSecondsCounter = 0;
};
var userIdleInterval = window.setInterval(CheckIdleTime, 1000 * 60);
function CheckIdleTime() {
_idleSecondsCounter+=60;
var oPanel = document.getElementById("MinToExpire");
if (oPanel)
oPanel.innerHTML = (IDLE_TIMEOUT - _idleSecondsCounter) + "";
if (_idleSecondsCounter >= IDLE_TIMEOUT) {
alert("Time expired!");
window.clearInterval(userIdleInterval);
oPanel.innerHTML = ("Log Out!!!");
}
}
</script>
<script id="jsbin-source-javascript" type="text/javascript">var IDLE_TIMEOUT = 60 * 60; //seconds
var _idleSecondsCounter = 0;
document.onclick = function() {
_idleSecondsCounter = 0;
};
document.onmousemove = function() {
_idleSecondsCounter = 0;
};
document.onkeypress = function() {
_idleSecondsCounter = 0;
};
var userIdleInterval = window.setInterval(CheckIdleTime, 1000 * 60);
function CheckIdleTime() {
_idleSecondsCounter+=60;
var oPanel = document.getElementById("MinToExpire");
if (oPanel)
oPanel.innerHTML = (IDLE_TIMEOUT - _idleSecondsCounter) + "";
if (_idleSecondsCounter >= IDLE_TIMEOUT) {
alert("Time expired!");
window.clearInterval(userIdleInterval);
oPanel.innerHTML = ("Log Out!!!");
}
}</script></body>
</html>
var IDLE_TIMEOUT = 60 * 60; //seconds
var _idleSecondsCounter = 0;
document.onclick = function() {
_idleSecondsCounter = 0;
};
document.onmousemove = function() {
_idleSecondsCounter = 0;
};
document.onkeypress = function() {
_idleSecondsCounter = 0;
};
var userIdleInterval = window.setInterval(CheckIdleTime, 1000 * 60);
function CheckIdleTime() {
_idleSecondsCounter+=60;
var oPanel = document.getElementById("MinToExpire");
if (oPanel)
oPanel.innerHTML = (IDLE_TIMEOUT - _idleSecondsCounter) + "";
if (_idleSecondsCounter >= IDLE_TIMEOUT) {
alert("Time expired!");
window.clearInterval(userIdleInterval);
oPanel.innerHTML = ("Log Out!!!");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment