Jonathan Ouellette 580e90f6a2 initial add
2022-09-27 14:10:30 -07:00

64 lines
1.4 KiB
JavaScript

var timoutWarning = 1740000; // Display warning in 29 Mins.
var timoutNow = 1800000; // Timeout in 30 mins.
//var timoutWarning = 10000; // Display warning in 10 secs.
//var timoutNow = 20000; // Timeout in 20 secs
var logoutUrl = '/Home/MyTasks'; // URL to logout page.
var warningTimer;
var timeoutTimer;
// Start timers.
function StartTimers() {
warningTimer = setTimeout("IdleWarning()", timoutWarning);
timeoutTimer = setTimeout("IdleTimeout()", timoutNow);
}
// Reset timers.
function ResetTimers() {
clearTimeout(warningTimer);
clearTimeout(timeoutTimer);
StartTimers();
}
function IdleTimeout() {
//window.location = logoutUrl;
//var url = '/MyTasks/Home';
window.location.href = logoutUrl;
}
// Show idle timeout warning dialog.
function IdleWarning() {
$("#timeout").modal('show');
}
function DisplayAPIError(description, xhr) {
if (xhr.status === 401) {
return;
}
var msg = "Error occurred during " + description + "\r\n";
try {
var resp = JSON.parse(xhr.responseText);
if (resp.result === "Error") {
msg = msg + resp.detail;
} else if (resp.result === "Invalid") {
msg = resp.detail;
} else {
msg = msg + xhr.responseText;
}
}
catch (e) {
msg = msg + xhr.responseText;
}
alert(msg);
}