- if (timeLeft < 0) {
- timeLeft = 'Expired';
- document.getElementById("time").style.background = "red";
- clearInterval(timerRef);
- } else {
- timeLeft += 1;
- timeLeft = '< ' + timeLeft + ' min';
- }
-
- document.getElementById("timer").innerHTML = timeLeft;
+ if (timeLeft < 0) {
+ clearInterval(timerRef);
+ console.log('Session expired, reload page');
+ last = -1;
+ location.reload();
+ } else if (timeLeft == 1) {
+ if (timeLeft < last || last == -1) {
+ last = timeLeft;
+ timeLeft = '< ' + timeLeft + ' min';
+ console.log('Session soon to expire');
+ document.getElementById("time").style.background = "red";
+ document.getElementById("timer").innerHTML = timeLeft;
+ }
+ } else {
+ if ((timeLeft < last && timeLeft > 0) || last == -1) {
+ last = timeLeft;
+ console.log('Session valid < ' + timeLeft);
+ timeLeft = '< ' + timeLeft + ' min';
+ document.getElementById("timer").innerHTML = timeLeft;
+ }
+ }