jTimeout
jTimeout copied to clipboard
Default event callbacks set to false from documentation throw an error
Hello, this is my config :
<link rel="stylesheet" src="/assets/jalert/jAlert.css"/>
<script src="/assets/jalert/jAlert.min.js"></script>
<script src="/assets/jalert/jAlert-functions.min.js"></script>
<script src="/assets/jalert/jTimeout.min.js"></script>
<script>
$(function () {
$.jTimeout({
flashTitle: true, //whether or not to flash the tab/title bar when about to timeout, or after timing out
flashTitleSpeed: 500, //how quickly to switch between the original title, and the warning text
flashingTitleText: '**WARNING**', //what to show in the tab/title bar when about to timeout, or after timing out
originalTitle: document.title, //store the original title of this page
timeoutAfter: 60, //pass this from server side to be fully-dynamic. For PHP: ini_get('session.gc_maxlifetime'); - 1440 is generally the default timeout
heartbeat: 1, //how many seconds in between checking the expiration - warning: changing this can effect your prior countdown warning and timeout - for best results, stick with 1
extendOnMouseMove: true, //Whether or not to extend the session when the mouse is moved
mouseDebounce: 30, //How many seconds between extending the session when the mouse is moved (instead of extending a billion times within 5 seconds)
onMouseMove: false, //Override the standard $.get() request that uses the extendUrl with your own function.
extendUrl: '/index.xhtml', //URL to request in order to extend the session.
logoutUrl: '/auto-logout.xhtml', //URL to request in order to force a logout after the timeout. This way you can end a session early based on a shorter timeout OR if the front-end timeout doesn't sync with the backend one perfectly, you don't look like an idiot.
loginUrl: '/login.xhtml', //URL to send a customer when they want to log back in
secondsPrior: 30, //how many seconds before timing out to run the next callback (onPriorCallback)
onPriorCallback: false, //override the popup that shows when getting within x seconds of timing out
onClickExtend: false, //override the click to extend button callback
onTimeout: false, //override the timeout function if you'd like
onSessionExtended: false //override the session extension method (triggered only after a timeout)
}
);
$.jTimeout().getExpiration(); //gets the expiration date string
$.jTimeout().getSecondsTillExpiration(); //gets the number of seconds until the session expires
});
</script>
jQuery 3.4.1 / Chrome v 75.0
i get this error :
jTimeout.min.js:10 Uncaught TypeError: c.options.onPriorCallback is not a function
at countdown (jTimeout.min.js:10)
and then a series of :
jTimeout.min.js:10 Uncaught TypeError: c.options.onMouseMove is not a function
at HTMLBodyElement.
the flashingTitleText: 'WARNING' is showed on the page title
removed all the options above and leave the default options .. the error has disappeared ..
just a question JAlert need Bootstrap?
It doesn’t need bootstrap. You probably have a bad value or typo in your options. I’ll look when I get on my computer in a couple hours.
Sent from my iPhone
On Jul 18, 2019, at 7:15 AM, afterbit01 [email protected] wrote:
just a question JAlert need Bootstrap?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.
I asked for Bootstrap .. because the jAlert texts (ex .. Your session will timeout in ..) appear at the bottom of the html page .. I see the countdown, etc. but not the popup that covers the entire html page
It works!... it was a problem of CSS.. now i review my jTimeout options as suggested before.. thank you!!!.. btw.. great plugin!!! ;-)
Can you fix your original comment above? The code formatting is only working for half of it. And thanks lol.
yes.. done!
Looks like it doesn't like you passing false for those options: "onPriorCallback" and "onMouseMove". Just pass an empty function to see if that fixes it. Sorry I took so long to respond and didn't bother looking at my own code/documentation lol. I'm really tied up with stuff.
onMouseMove: function(){ }
or don't pass anything at all and you'll get the default functionality which might be what you're looking for...
Looks like it doesn't like you passing false for those options: "on Prior Callback" and "onMouseMove".
Yes it seems so.. I don't pass anything using the default and it works..
Ok, so the check before running those methods needs to be fixed. Thanks for reporting it. If you have time and want to contribute, please change it and submit a pull request :) Otherwise, I'll update it as soon as I am able.