Created
February 23, 2017 00:33
-
-
Save nickcoyne/16450cd364e40c0b984122ae233c4ffb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var timoutWarning = 60000; // Display warning in 1 min. | |
var timoutNow = 60000; // Warning has been shown, give the user 1 minute to interact | |
var logoutUrl = '/timeout'; // URL to logout page. | |
var warningTimer; | |
var timeoutTimer; | |
// Start warning timer. | |
function StartWarningTimer() { | |
warningTimer = setTimeout("IdleWarning()", timoutWarning); | |
} | |
// Reset timers. | |
function ResetTimeOutTimer() { | |
clearTimeout(timeoutTimer); | |
StartWarningTimer(); | |
BetterModals.closeModal($("#modalLogoutWarning")); | |
} | |
// Show idle timeout warning dialog. | |
function IdleWarning() { | |
clearTimeout(warningTimer); | |
timeoutTimer = setTimeout("IdleTimeout()", timoutNow); | |
BetterModals.showModal($("#modalLogoutWarning")); | |
} | |
// Logout the user. | |
function IdleTimeout() { | |
window.location = logoutUrl; | |
} | |
StartWarningTimer(); | |
// Button click handlers | |
// close page | |
$(document).on("click", ".js-temp-user-logout", function() { | |
IdleTimeout(); | |
}); | |
// continue | |
$(document).on("click", ".js-temp-user-continue", function() { | |
ResetTimeOutTimer(); | |
}); | |
// we should reset the timer when | |
// submitting responses | |
// switching tabs | |
// we should suspend the timer | |
// while watching video | |
// we should restart the timer | |
// when stopping video play |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment