var countdownRemaining=0;
var countdownExecuter;
var mainExecuter;
function keepAlive() {
// Ping a site other than the activeSessionTest.jsp to keep the remaining time updated
new PeriodicalExecuter(function(pe) {new Ajax.Request('../web/about.jsp');},30);
}
function afterModalBox() {
countdownExecuter.stop();
}
function warnUserTimeout() {
var tm = $('timeoutMessage');
if (!tm) {
countdownExecuter = new PeriodicalExecuter(function(pe) {
countdownRemaining--;
if (countdownRemaining < 0 && countdownExecuter!=null) {
countdownExecuter.stop();
new Ajax.Request('../web/activeSessionTest.jsp', {
method: 'post',
onSuccess: function(transport) {
var timeRemaining=new Number(transport.responseText);
if (timeRemaining < 0) {
// Session expired, send user to the logout page
window.location.href='../web/logout.jsp?expired=true';
} else {
Modalbox.hide();
}
}
});
} else {
var p = $('timeoutMessage');
if (p) {
var message='Your session is about to expire.
You will be logged out in ' + countdownRemaining + ' second' + (countdownRemaining==1 ? '' : 's') + '.';
p.update(message);
Modalbox.resizeToContent();
}
}
}, 1);
Modalbox.show('
Your session is about to expire.
', { title: '', width: 300, transitions: false, afterHide: afterModalBox } ); } } mainExecuter=new PeriodicalExecuter(function(pe) { new Ajax.Request('../web/activeSessionTest.jsp', { method: 'post', onSuccess: function(transport) { var timeRemaining=new Number(transport.responseText); if (timeRemaining < 0) { // Session expired, send user to the logout page window.location.href='../web/logout.jsp?expired=true'; } else if (timeRemaining < 60000) { var tr = $('timeRemaining'); if (tr && tr.style.display != 'none') { tr.blindUp(); } countdownRemaining = (timeRemaining/1000).toFixed(0); warnUserTimeout(); } else { var message=""; var time=timeRemaining / 1000; var timeMessage="second"; if (time > 60) { time=time/60; timeMessage="minute"; } time=time.toFixed(0); if (time > 1) { timeMessage=timeMessage + "s"; } if (time <= 5 || timeMessage == "second") { message = "Your session will expire in " + time + " " + timeMessage; var p = $('timeRemaining'); if (p) { p.update(message); if (p.style.display=='none') { p.blindDown(); } p.resizeToContent(); } } else { var p = $('timeRemaining'); if (p && p.style.display != 'none') { p.blindUp(); } } } } }); },15);