Here is the JavaScript, I just call it onReady of the web block. The only issue I've noticed is that if the user does not have the tab active, the interval is still running in the browser but all of the events are essentially queued and executed when the tab/window regains focus. So that's a little weird, if you find a better solution please let me know.
function idleTimeout (uTimeout, uWarning,uTimeoutAction,uWarningAction) {
var interval = 60000;
var IDLE_TIMEOUT = uTimeout;
var IDLE_WARNING = uTimeout - uWarning;
var idleCounter = 0;
var warningAction = uWarningAction;
var timeoutAction = uTimeoutAction;
var timeoutInterval;
document.onmousemove = document.onkeypress = function () {
idleCounter = 0;
};
timeoutInterval= window.setInterval(CheckIdleTime, interval);
console.log("Created Interval:");
function CheckIdleTime(){
if (++idleCounter >= IDLE_TIMEOUT) {
console.log('Triggering session timeout ');
timeoutAction();
clearInterval(timeoutInterval);
} else if (idleCounter == IDLE_WARNING) {
console.log('Triggering session warning ');
warningAction();
}
}
return timeoutInterval;
}