Skip to content

Instantly share code, notes, and snippets.

@var23rav
Created October 28, 2015 09:56
Show Gist options
  • Save var23rav/9d2df418e3ad9c625e24 to your computer and use it in GitHub Desktop.
Save var23rav/9d2df418e3ad9c625e24 to your computer and use it in GitHub Desktop.
Session time out popup js file
<script>
var sec=60,min=14,runTimer,idleTimeCounter;
$(document).ready(function(){
idleTimeCheck();
value = 'com.odr.core.domain.LoggedInUsers@1aea2956';
console.log("Session1 ="+value);
});
function idleTimeCheck()
{
var IDLE_TIMEOUT = 6300; //seconds
var _idleSecondsCounter = 0;
document.onclick = function() {
_idleSecondsCounter = 0;
};
document.onmousemove = function() {
_idleSecondsCounter = 0;
};
document.onkeypress = function() {
_idleSecondsCounter = 0;
};
idleTimeCounter = window.setInterval(CheckIdleTime, 1000);
function CheckIdleTime() {
_idleSecondsCounter++;
if (_idleSecondsCounter >= IDLE_TIMEOUT) {
clearInterval(idleTimeCounter);
$('#timeoutModal').reveal($(this).data());
startTimer();
}
}
}
function startTimer()
{
if(min == 0 && sec == 0)
{
min=14;
sec=60;
clearTimeout(runTimer);
return;
}
else if(sec == 0)
{
sec=60;
min=min-1;
}
sec=sec-1;
document.getElementById('timer').innerHTML = min +":"+ sec;
runTimer = setTimeout('startTimer()',1000);
}
function stopTimer()
{
min=14;
sec=60;
clearTimeout(runTimer);
$('#timeoutModal').trigger('reveal:close');
idleTimeCheck();
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment