2023-09-07 08:38:41 -06:00
|
|
|
(function(global) {
|
2023-08-16 10:55:24 -06:00
|
|
|
"use strict";
|
2023-09-07 16:41:55 -04:00
|
|
|
|
|
|
|
|
const sessionTimer = document.getElementById("sessionTimer");
|
2023-08-16 10:55:24 -06:00
|
|
|
|
2023-09-07 08:38:41 -06:00
|
|
|
setTimeout(function() {
|
2023-09-08 13:51:12 -06:00
|
|
|
var timeTillSessionEnd = new Date().getTime() + (5 * 60 * 1000);
|
2023-09-07 08:38:41 -06:00
|
|
|
var x = setInterval(function() {
|
|
|
|
|
var now = new Date().getTime();
|
|
|
|
|
var difference = timeTillSessionEnd - now;
|
|
|
|
|
var minutes = Math.floor((difference % (1000 * 60 * 60)) / (1000 * 60));
|
|
|
|
|
var seconds = Math.floor((difference % (1000 * 60)) / 1000);
|
2023-09-12 15:17:06 -04:00
|
|
|
document.getElementById("timeLeft").innerHTML = + minutes + "m " + seconds + "s";
|
2023-09-12 11:30:27 -06:00
|
|
|
showTimer();
|
2023-09-07 08:38:41 -06:00
|
|
|
document.getElementById("logOutTimer").addEventListener("click", logoutByUser);
|
|
|
|
|
document.getElementById("extendSessionTimer").addEventListener("click", extendSession);
|
2023-09-12 11:30:27 -06:00
|
|
|
if (difference < 0) {
|
2023-09-07 08:38:41 -06:00
|
|
|
clearInterval(x);
|
2023-09-12 11:30:27 -06:00
|
|
|
closeTimer();
|
2023-09-07 08:38:41 -06:00
|
|
|
redirectToSignin();
|
|
|
|
|
}
|
|
|
|
|
}, 1000);
|
2023-09-12 11:30:27 -06:00
|
|
|
}, 60 * 1000);
|
2023-09-07 08:38:41 -06:00
|
|
|
|
|
|
|
|
function redirectToSignin() {
|
|
|
|
|
window.location.href = '/sign-in';
|
2023-08-16 10:55:24 -06:00
|
|
|
}
|
|
|
|
|
|
2023-09-07 08:38:41 -06:00
|
|
|
function logoutByUser() {
|
|
|
|
|
window.location.href = '/sign-out';
|
|
|
|
|
}
|
2023-08-16 10:55:24 -06:00
|
|
|
|
2023-09-07 08:38:41 -06:00
|
|
|
function extendSession() {
|
|
|
|
|
window.location.reload();
|
|
|
|
|
}
|
2023-08-16 10:55:24 -06:00
|
|
|
|
2023-09-12 11:30:27 -06:00
|
|
|
function showTimer() {
|
|
|
|
|
sessionTimer.showModal();
|
2023-09-07 08:38:41 -06:00
|
|
|
}
|
|
|
|
|
|
2023-09-12 11:30:27 -06:00
|
|
|
function closeTimer() {
|
|
|
|
|
sessionTimer.close();
|
2023-09-07 08:38:41 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
})(window);
|