Created
April 21, 2017 03:18
-
-
Save cchang62/8c41f18677ba0e82d69dd855d63eed09 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/wuhafaf
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
<!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> |
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
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