Something like this
if(
this.contextObj!=null
){
var ms=this.contextObj.get('sessionTimeout');
if(ms!=null&&ms>0){
(function(){
var t;
window.onload = resetTimer;
window.onmousemove = resetTimer;
window.onmousedown = resetTimer;
window.ontouchstart = resetTimer;
window.onclick = resetTimer;
window.onkeypress = resetTimer;
window.addEventListener('scroll',resetTimer,true);
function logout(){
console.log('Logging Out');
mx.logout();
}
function resetTimer() {
console.log('Timer Reset');
clearTimeout(t);
t = setTimeout(logout,ms);
}
})();
}
}
The contextObj is some table associated with the role with a field for the timeout in milliseconds