var sessionLengthSec = 64;
var sessionLengthMs = sessionLengthSec * 1000;
var modalPopupDisplayed = false;
timeoutCheckInterval = setInterval(function(){
$("#display-cookie").click();
var sessionCookie = getCookie(cookieName);
var sessionDate = new Date(sessionCookie);
var sessionTimeoutMs = sessionDate.getTime() + sessionLengthMs;
var SessionTimeoutDate = new Date(sessionTimeoutMs);
var remainingMs = sessionTimeoutMs - Date.now()
var remainingSec = remainingMs / (1000)
if (remainingSec < 60) {
// if we're within 60 seconds
if (!modalPopupDisplayed) {
modalPopupDisplayed = true;
showModalPopUp();
}
else {
// check if we're happy as clams
if (remainingSec < 0) {
// if we're still here - redirect
// popup will need to have self destructing count down timer
//window.location
}
}
} else {
// we have more than 1 minute remaining, clear popup flag - we must have done something
modalPopupDisplayed = false;
}
$("#time-remaining").text(remainingSec.toFixed(2) + " seconds")
}, 1000);
var popUpObj;
function showModalPopUp() {
popUpObj=window.open("PopUp.htm",
"ModalPopUp",
"toolbar=no," +
"scrollbars=no," +
"location=no," +
"statusbar=no," +
"menubar=no," +
"resizable=0," +
"width=400," +
"height=250," +
"left = 490," +
"top=300"
);
popUpObj.focus();
}
// Code goes here
var cookieName = 'LastSessionActiveTime';
$("#set-cookie").click(function(e) {
setCookie(cookieName, new Date().toLocaleString(),0);
}).click(); // set on load
$("#display-cookie").click(function(e) {
var cookieValue = getCookie(cookieName);
var text = "{"+cookieName +": "+cookieValue+"}";
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.