Comments (7)
Ah, yes, in the checkIdleTimeout
function, you could reset the idleTimerLastActivity
storage variable to the current time if there are active connections. Does that work as desired?
//----------- IDLE TIMER FUNCTIONS --------------//
checkIdleTimeout = function () {
if ($.active > 0) { // start of $.active check
console.log('ACTIVE connection! NO TIMEOUT YET!');
// reset 'idleTimerLastActivity' storage variable to current time
store.set('idleTimerLastActivity', $.now());
} else {
console.log('NO active connections. Proceed to check other timeout conditions.');
var timeIdleTimeout = (store.get('idleTimerLastActivity') + (currentConfig.idleTimeLimit * 1000));
if ($.now() > timeIdleTimeout) {
console.log('inactivity has exceeded the idleTimeLimit');
if (!currentConfig.enableDialog) { // warning dialog is disabled
console.log('warning dialog disabled - log out user without warning');
logoutUser(); // immediately log out user when user is idle for idleTimeLimit
} else if (currentConfig.enableDialog && isDialogOpen() !== true) {
console.log('warning dialog is not open & will be opened');
openWarningDialog();
startDialogTimer(); // start timing the warning dialog
}
} else if (store.get('idleTimerLoggedOut') === true) { //a 'manual' user logout?
console.log('user has manually logged out? Log out all windows & tabs now.');
logoutUser();
} else {
console.log('inactivity has not yet exceeded the idleTimeLimit');
if (currentConfig.enableDialog && isDialogOpen() === true) {
console.log('warning dialog is open & will be closed');
destroyWarningDialog();
stopDialogTimer();
}
}
} // end of $.active check
};
from jquery-idletimeout.
from jquery-idletimeout.
Thanks for the feedback, feldenla. Glad it's working. And thanks for the suggestions & great code, rhetherington. For some time (years now), I wished I had the focus to fix up my plugin. I too want to combine the debugging & iframe scripts into one main, unminimized scripts. There are also a couple of bug fixes that need to be included. I am not able to do this work now, but perhaps in the future.
from jquery-idletimeout.
You will need to modify the code to check if there is an active AJAX request. Load the jquery-idleTimeout-for-testing.js script, https://github.com/JillElaine/jquery-idleTimeout/blob/master/jquery-idleTimeout-for-testing.js, on your page and watch the console (eg: use Firefox Developer Tools https://developer.mozilla.org/en-US/docs/Tools/Web_Console/Opening_the_Web_Console ) to see the output. This is very useful for debugging & understanding how the script works.
Next, modify the checkIdleTimeout
function to include a test for active AJAX connections. The checkIdleTimeout
function polls every idleCheckHeartbeat
seconds. It opens the warning dialog when certain conditions are met. Set a 'condition' that there must be no active connections before the dialog opens. See untested, modified code below.
You'll probably want to 'comment out' many of the extra 'console.log' outputs to focus only on the outputs you care about.
//----------- IDLE TIMER FUNCTIONS --------------//
checkIdleTimeout = function () {
if ($.active > 0) { // start of $.active check
console.log('ACTIVE connection! NO TIMEOUT YET!');
} else {
console.log('NO active connections. Proceed to check other timeout conditions.');
var timeIdleTimeout = (store.get('idleTimerLastActivity') + (currentConfig.idleTimeLimit * 1000));
if ($.now() > timeIdleTimeout) {
console.log('inactivity has exceeded the idleTimeLimit');
if (!currentConfig.enableDialog) { // warning dialog is disabled
console.log('warning dialog disabled - log out user without warning');
logoutUser(); // immediately log out user when user is idle for idleTimeLimit
} else if (currentConfig.enableDialog && isDialogOpen() !== true) {
console.log('warning dialog is not open & will be opened');
openWarningDialog();
startDialogTimer(); // start timing the warning dialog
}
} else if (store.get('idleTimerLoggedOut') === true) { //a 'manual' user logout?
console.log('user has manually logged out? Log out all windows & tabs now.');
logoutUser();
} else {
console.log('inactivity has not yet exceeded the idleTimeLimit');
if (currentConfig.enableDialog && isDialogOpen() === true) {
console.log('warning dialog is open & will be closed');
destroyWarningDialog();
stopDialogTimer();
}
}
} // end of $.active check
};
Please report back. Thank you.
from jquery-idletimeout.
Great work and thanks a lot for your timely reply.
It is working somehow as expected, that is, it keeps on waiting while there is an active AJAX connection.
So the user is active until the AJAX request is complete, however the user is logged out immediately the AJAX connection is closed and logs the message 'inactivity has exceeded the idleTimeLimit'.
It is obvious here that;
if ($.now() > timeIdleTimeout) { // would always be true }
Can we therefore reset store.get('idleTimerLastActivity')
to the current time if $.active > 0
and also stop pinging the server again to keep the session alive since there is an already active connection.
Your help would be greatly appreciated.
Thank you.
from jquery-idletimeout.
Thanks very much for your assistance.
It is now working to expectation.
from jquery-idletimeout.
from jquery-idletimeout.
Related Issues (20)
- Is there a way to change the timeout duration at runtime? HOT 5
- Dependency on jQuery UI for pop up. HOT 1
- Session time out counter show NAN HOT 15
- iframe inactivity detection bug HOT 2
- Accessing the $.fn.idleTimeout() after it was initialized HOT 1
- customCallback repeating call if redirectUrl: false HOT 2
- IE recursive loop crash. HOT 7
- Does not function if the page is having frameset HOT 2
- Cannot find any error handling callback HOT 2
- Unable to change dialogue on buttons, HOT 19
- Configuration issue - activityEvents override without mousemove HOT 7
- Error message only on IE 11 on Windows 2012 R2 - Solved HOT 12
- Releasing jquery-idleTimeout under MIT license HOT 7
- Logged out of iframes, not main page HOT 4
- IE 11 Tabs or windows not communicating when over 2 tabs. HOT 2
- IE-11 windows 10 multiple logout calls HOT 1
- How much of jquery-ui do you need to bundle? HOT 3
- Uncaught TypeError: $(...).idleTimeout is not a function HOT 1
- store.js HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery-idletimeout.