diff --git a/dist/js/jquery-idleTimeout-plus-iframe.js b/dist/js/jquery-idleTimeout-plus-iframe.js
index 29f19e4..a635791 100644
--- a/dist/js/jquery-idleTimeout-plus-iframe.js
+++ b/dist/js/jquery-idleTimeout-plus-iframe.js
@@ -1,11 +1,7 @@
/**
- * This work is licensed under the Creative Commons Attribution-Share Alike 3.0
- * United States License. To view a copy of this license,
- * visit http://creativecommons.org/licenses/by-sa/3.0/us/ or send a letter
- * to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
- *
- * Modified by: Jason Abraham (CrashSensei)
+ * Written by: Jason Abraham (CrashSensei)
* Email: jason@linearsoft.com
+ * License: GPLv3 (https://www.gnu.org/licenses/gpl-3.0-standalone.html)
*
* Configurable idle (no activity) timer and logout redirect for jQuery.
* Supports both jQueryUI dialogs or Bootstrap modals
@@ -19,7 +15,7 @@
* Multi-window support requires JQuery Storage API
* Dialogs require either jQueryUI or Bootstrap
*
- * version 0.5.0
+ * version 0.9.5
**/
(function(root, factory) {
@@ -57,7 +53,7 @@
// Auto-Url settings (NOTE: if a callback is defined auto url redirection will only occur if the callback returns true)
redirectUrl: '/timed-out', // URL if no action is taken after the warning/lock screen timeout
logoutUrl: '/logout', // URL if the user clicks "Logout" on the warning/lock screen
- logoutAutoUrl: 'null', // URL for secondary tabs that received an automatic logout trigger (to help avoid race conditions)
+ logoutAutoUrl: null, // URL for secondary tabs that received an automatic logout trigger (to help avoid race conditions)
redirectCallback: false,
logoutCallback: false,
logoutAutoCallback: false,
@@ -67,7 +63,9 @@
keepAliveUrl: window.location.href, // set URL to ping - does not apply if keepAliveInterval: false
keepAliveAjaxType: 'GET',
keepAliveAjaxData: '',
-
+ keepAliveResponse: false, // add ability to check keep alive's response. if user was logged out by other means, or something went wrong, redirect to keepAliveBadUrl - Set to false to disable KeepAliveBadUrl redirection
+ keepAliveBadUrl: window.location.href, // set URL to redirect to if keepAliveResponse wasn't what was expected and if keepAliveResponse isn't set to false
+
// Lock Screen settings
lockEnabled: false, // Set to true to enable lock screen before redirecting
lockTimeLimit: 7200, // 2 hrs
@@ -88,7 +86,7 @@
iframesSupport: false, // Enable iframe support (also requires multiWindow support to work)
multiWindowSupport: false // Requires jquery-storage-api
};
- var bodyElm = $('body'); // Store for jQuery optimization
+ var bodyElm = null;
var dataStore = null;
//#########################################################################
// ### Public API Functions
@@ -101,9 +99,10 @@
* @return {boolean} - Returns true if successfully initialized
*/
api.start = function(userConfig) {
+ bodyElm = $('body');
//--Merge default and user configs
config = $.extend(config, userConfig);
- if (config.logoutAutoUrl === null) config.logoutAutoUrl = config.logoutUrl;
+ if (config.logoutAutoUrl == null) config.logoutAutoUrl = config.logoutUrl;
//--Convert secs to millisecs
config.idleTimeLimit *= 1000;
config.idleCheckHeartbeat *= 1000;
@@ -349,7 +348,12 @@
$.ajax({
type: config.keepAliveAjaxType,
url: config.keepAliveUrl,
- data: config.keepAliveAjaxData
+ data: config.keepAliveAjaxData,
+ success: function(response){
+ if(config.keepAliveResponse !== false && $.trim(response) !== config.keepAliveResponse){
+ window.location.replace(config.keepAliveBadUrl);
+ }
+ }
});
}, config.keepAliveInterval);
}
diff --git a/dist/js/jquery-idleTimeout-plus-iframe.min.js b/dist/js/jquery-idleTimeout-plus-iframe.min.js
index e3437c1..85438de 100644
--- a/dist/js/jquery-idleTimeout-plus-iframe.min.js
+++ b/dist/js/jquery-idleTimeout-plus-iframe.min.js
@@ -1 +1 @@
-!function(t,o){"function"==typeof define&&define.amd?define(["jquery"],o):"object"==typeof exports?module.exports=o(require("jquery")):t.IdleTimeoutPlus=o(t.jQuery)}(this,function(t){function o(){null===tt&&(tt=t.localStorage?t.initNamespaceStorage("jqueryIdleTimeoutPlus").localStorage:{})}function n(t,o){$.multiWindowSupport?tt.set(t,o):tt[t]=o}function e(t,o){if(o="undefined"==typeof o?null:o,$.multiWindowSupport){if(tt.isSet(t))return tt.get(t)}else if(t in tt)return tt[t];return o}function l(){n("warningStartTime",-1),n("lockStartTime",-1),i(),$.idleCallback!==!1&&$.idleCallback($)}function i(){a(),n("lastActivity",t.now()),nt=setInterval(r,$.idleCheckHeartbeat)}function a(){clearInterval(nt)}function r(){var o=e("lastActivity",t.now())+$.idleTimeLimit;return e("logoutTriggered")===!0?N():e("lockStartTime",-1)!==-1?(a(),A()):t.now()>=o?(a(),$.warnEnabled?d():$.lockEnabled?L():O()):void 0}function c(){t(document).on($.activityEvents,function(t){if("mousemove"===t.type){if(t.clientX===at[0]&&t.clientY===at[1])return;at[0]=t.clientX,at[1]=t.clientY}e("warningStartTime",-1)===-1&&e("lockStartTime",-1)===-1&&i()})}function u(){s(),et=setInterval(function(){t.ajax({type:$.keepAliveAjaxType,url:$.keepAliveUrl,data:$.keepAliveAjaxData})},$.keepAliveInterval)}function s(){clearInterval(et)}function d(){k(),$.warnCallback!==!1&&(rt=$.warnCallback($)),v()}function p(){f(),w(),n("warningStartTime",-1),l()}function k(){n("warningStartTime",t.now()),lt=setInterval(m,500)}function f(){clearInterval(lt)}function m(){if(e("logoutTriggered")===!0)return f(),N();if(e("warningStartTime",-1)===-1)return p();var o=e("warningStartTime")+$.warnTimeLimit-1;return t.now()>=o?(f(),$.lockEnabled?(w(),L()):O()):void b()}function v(){rt&&(g(),b(),$.bootstrap?(ut.modal("show"),ut.focus()):ut.dialog("open"),ct=!0)}function w(){ct=!1,null!==ut&&($.bootstrap?(ut.modal("hide"),_.removeClass("modal-open"),t("div.modal-backdrop").remove()):ut.dialog("close"))}function b(){if(null!==ut&&(null!==st||null!==dt)){var o=t.now(),n=Math.floor((e("warningStartTime",o)+$.warnTimeLimit-o)/1e3);if(null!==st&&st.html(V(n)),null!==dt){var l=Math.floor(n/($.warnTimeLimit/1e3)*100);$.bootstrap?dt.css("width",l+"%"):dt.progressbar("value",l)}}}function g(){if(null===ut){var t="";t=$.warnContentCallback===!1?$.bootstrap?j():C():$.warnContentCallback($),$.bootstrap?h(t):y(t)}}function h(o){_.append(o),null!==$.warnLogoutButton&&t("#jitp-warn-logout").on("click",function(){T()}),t("#jitp-warn-alive").on("click",function(){S()}),ut=t("#jitp-warn-display"),(null!==$.warnCountdownMessage||$.warnCountdownBar)&&(st=ut.find(".jitp-countdown-holder")),$.warnCountdownBar&&(dt=t("#jitp-warn-bar"))}function y(o){var n=[];null!==$.warnLogoutButton&&n.push({text:$.warnLogoutButton,click:function(){T()}}),n.push({text:$.warnStayAliveButton,click:function(){S()}}),t(o).dialog({buttons:n,closeOnEscape:!1,modal:!0,title:$.warnTitle,minWidth:320,autoOpen:!1,open:function(){null===$.warnTitle?t(this).closest(".ui-dialog").find(".ui-dialog-titlebar").hide():t(this).closest(".ui-dialog").find(".ui-dialog-titlebar-close").hide(),t(this).parent().find("button:nth-child(2)").focus()}}),ut=t("#jitp-warn-display"),null!==$.warnCountdownMessage&&(st=ut.find(".jitp-countdown-holder")),$.warnCountdownBar&&(dt=t("#jitp-warn-bar"),dt.progressbar({value:0,max:100}))}function j(){var t=null===$.warnTitle?"":'
"}function R(){M(),Y()}function K(){$.lockPassCallback(t("#jitp-lock-pass").val())}function Q(){s(),a(),f(),M()}function Y(){Q(),n("logoutTriggered",!0),("function"!=typeof $.logoutCallback||$.logoutCallback($))&&window.location.replace($.logoutUrl)}function D(){Q(),("function"!=typeof $.logoutAutoCallback||$.logoutAutoCallback($))&&window.location.replace($.logoutAutoUrl)}function N(){return Q(),$.multiWindowSupport?void setTimeout(O,Z(100,500)):O()}function O(){return e("logoutTriggered",!1)?D():(n("logoutTriggered",!0),void(("function"!=typeof $.redirectCallback||$.redirectCallback($))&&window.location.replace($.redirectUrl)))}function X(){n("activityEvents",$.activityEvents)}function F(){t(document).on("dialogopen shown.bs.modal",function(){ct||kt||G()})}function G(){var t,o=function(){"complete"===document.readyState&&(clearInterval(t),J())};t=setInterval(o,1e3)}function J(o){o||(o=t(document));var n=0;o.find("iframe,frame").each(function(){if(t(this).hasClass("jitp-inspected")===!1)try{J(t(this).contents()),t(this).on("load",z(t(this)));var o=t(this)[n];o.attachEvent&&o.attachEvent("onload",z(t(this))),n++}catch(e){t(this).addClass("jitp-inspected cross-site")}})}function z(o){var n=o.contents(),l=e("activityEvents","");try{n.on(l,function(o){t("body").trigger(o)}),o.addClass("jitp-inspected")}catch(i){}}function V(t){var o=Math.floor(t/60);if(o<=15){var n=t%60,e=o>0?o+"m ":"";return e+=n+"s"}if(o<=75)return o<=22?"about 15 mins":o<=37?"about 30 mins":o<=52?"about 25 mins":"about 1 hour";var l=Math.floor(o/60);return o%=60,o<=15?"about "+l+" hours":o>52?"about "+(l+1)+" hours":"about "+l+"½ hours"}function Z(t,o){return Math.floor(Math.random()*(o-t))+t}var $={idleTimeLimit:1200,idleCallback:!1,idleCheckHeartbeat:2,bootstrap:!1,activityEvents:"click keypress scroll wheel mousewheel mousemove touchmove",warnEnabled:!0,warnTimeLimit:180,warnCallback:!1,warnContentCallback:!1,warnTitle:"Session Timeout",warnMessage:"Your session is about to expire!",warnStayAliveButton:"Stay Connected",warnLogoutButton:"Logout",warnCountdownMessage:"Time remaining: {timer}",warnCountdownBar:!1,redirectUrl:"/timed-out",logoutUrl:"/logout",logoutAutoUrl:null,redirectCallback:!1,logoutCallback:!1,logoutAutoCallback:!1,keepAliveInterval:600,keepAliveUrl:window.location.href,keepAliveAjaxType:"GET",keepAliveAjaxData:"",keepAliveResponse:!1,keepAliveBadUrl:window.location.href,lockEnabled:!1,lockTimeLimit:7200,lockHaltKeepAlive:!0,lockCallback:!1,lockContentCallback:!1,lockPassCallback:!1,lockTitle:null,lockUsername:"System User",lockMessage:"Enter your password to unlock the screen",lockUnlockButton:"UnLock",lockLogoutButton:"Not {username} ?",lockCountdownMessage:"Auto-logout in: {timer}",lockBlockUiConfig:{},lockLoadActive:!1,iframesSupport:!1,multiWindowSupport:!1},_=null,tt=null,ot={};ot.start=function(l){if(_=t("body"),$=t.extend($,l),null==$.logoutAutoUrl&&($.logoutAutoUrl=$.logoutUrl),$.idleTimeLimit*=1e3,$.idleCheckHeartbeat*=1e3,$.warnTimeLimit*=1e3,$.lockTimeLimit*=1e3,$.keepAliveInterval*=1e3,$.multiWindowSupport&&!t.localStorage)return console.error("jitp: Multi-Window support requested but JQuery Storage API is unavailable."),!1;if($.warnEnabled&&$.warnCallback===!1||$.lockEnabled&&$.lockCallback===!1)if($.bootstrap){if("undefined"==typeof t.fn.modal)return console.error("jitp: Bootstrap library is unavailable"),!1}else if("undefined"==typeof t.ui)return console.error("jitp: jQueryUI library is unavailable"),!1;if($.lockEnabled&&!$.multiWindowSupport)return console.error("jitp: Lock screen requested but multi-window support is not enabled."),!1;if($.lockEnabled&&$.lockCallback===!1){if("undefined"==typeof t.blockUI)return console.error("jitp: Lock screen requested but blockUI library is unavailable."),!1;if($.lockPassCallback===!1)return console.error("jitp: Lock screen requested but lockPassCallback function is not set."),!1}return $.iframesSupport&&!$.multiWindowSupport?(console.error("jitp: IFrame support requested but Multi-Window support disabled."),!1):(o(),$.lockEnabled&&($.lockLoadActive||e("lockStartTime",-1)>0)?L():(n("logoutTriggered",!1),n("warningStartTime",-1),n("lockStartTime",-1),n("lastActivity",t.now()),i(),$.keepAliveInterval&&u()),$.keepAliveInterval&&u(),X(),F(),c(),G(),!0)},ot.cleanUpLockScreen=function(){o(),t.localStorage&&tt.set("lockStartTime",-99)},ot.logout=function(){Y()},ot.displayWarning=function(){m()},ot.displayLockScreen=function(){E()},ot.initLockScreen=function(){a(),f(),A()},ot.setIdleTimeLimit=function(t){"number"==typeof t&&($.idleTimeLimit=1e3*t,ot.rollback())},ot.setWarnTimeLimit=function(t){"number"==typeof t&&($.warnTimeLimit=1e3*t,ot.rollback())},ot.setLockTimeLimit=function(t){"number"==typeof t&&($.lockTimeLimit=1e3*t,ot.rollback())},ot.rollback=function(){U(),p()},ot.iframeRecheck=function(){G()};var nt,et,lt,it,at=[-1,-1],rt=!0,ct=!1,ut=null,st=null,dt=null,pt=!0,kt=!1,ft=null,vt=null;return ot});
\ No newline at end of file
diff --git a/dist/js/jquery-idleTimeout-plus.js b/dist/js/jquery-idleTimeout-plus.js
index d8da996..c4064c9 100644
--- a/dist/js/jquery-idleTimeout-plus.js
+++ b/dist/js/jquery-idleTimeout-plus.js
@@ -1,11 +1,7 @@
/**
- * This work is licensed under the Creative Commons Attribution-Share Alike 3.0
- * United States License. To view a copy of this license,
- * visit http://creativecommons.org/licenses/by-sa/3.0/us/ or send a letter
- * to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
- *
- * Modified by: Jason Abraham (CrashSensei)
+ * Written by: Jason Abraham (CrashSensei)
* Email: jason@linearsoft.com
+ * License: GPLv3 (https://www.gnu.org/licenses/gpl-3.0-standalone.html)
*
* Configurable idle (no activity) timer and logout redirect for jQuery.
* Supports both jQueryUI dialogs or Bootstrap modals
@@ -19,7 +15,7 @@
* Multi-window support requires JQuery Storage API
* Dialogs require either jQueryUI or Bootstrap
*
- * version 0.5.0
+ * version 0.9.5
**/
(function(root, factory) {
@@ -57,7 +53,7 @@
// Auto-Url settings (NOTE: if a callback is defined auto url redirection will only occur if the callback returns true)
redirectUrl: '/timed-out', // URL if no action is taken after the warning/lock screen timeout
logoutUrl: '/logout', // URL if the user clicks "Logout" on the warning/lock screen
- logoutAutoUrl: 'null', // URL for secondary tabs that received an automatic logout trigger (to help avoid race conditions)
+ logoutAutoUrl: null, // URL for secondary tabs that received an automatic logout trigger (to help avoid race conditions)
redirectCallback: false,
logoutCallback: false,
logoutAutoCallback: false,
@@ -67,7 +63,9 @@
keepAliveUrl: window.location.href, // set URL to ping - does not apply if keepAliveInterval: false
keepAliveAjaxType: 'GET',
keepAliveAjaxData: '',
-
+ keepAliveResponse: false, // add ability to check keep alive's response. if user was logged out by other means, or something went wrong, redirect to keepAliveBadUrl - Set to false to disable KeepAliveBadUrl redirection
+ keepAliveBadUrl: window.location.href, // set URL to redirect to if keepAliveResponse wasn't what was expected and if keepAliveResponse isn't set to false
+
// Lock Screen settings
lockEnabled: false, // Set to true to enable lock screen before redirecting
lockTimeLimit: 7200, // 2 hrs
@@ -88,7 +86,7 @@
multiWindowSupport: false // Requires jquery-storage-api
};
- var bodyElm = $('body'); // Store for jQuery optimization
+ var bodyElm = null;
var dataStore = null;
//#########################################################################
// ### Public API Functions
@@ -101,9 +99,10 @@
* @return {boolean} - Returns true if successfully initialized
*/
api.start = function(userConfig) {
+ bodyElm = $('body');
//--Merge default and user configs
config = $.extend(config, userConfig);
- if (config.logoutAutoUrl === null) config.logoutAutoUrl = config.logoutUrl;
+ if (config.logoutAutoUrl == null) config.logoutAutoUrl = config.logoutUrl;
//--Convert secs to millisecs
config.idleTimeLimit *= 1000;
config.idleCheckHeartbeat *= 1000;
@@ -335,7 +334,12 @@
$.ajax({
type: config.keepAliveAjaxType,
url: config.keepAliveUrl,
- data: config.keepAliveAjaxData
+ data: config.keepAliveAjaxData,
+ success: function(response){
+ if(config.keepAliveResponse !== false && $.trim(response) !== config.keepAliveResponse){
+ window.location.replace(config.keepAliveBadUrl);
+ }
+ }
});
}, config.keepAliveInterval);
}
diff --git a/dist/js/jquery-idleTimeout-plus.min.js b/dist/js/jquery-idleTimeout-plus.min.js
index b7cf1e1..f7252fe 100644
--- a/dist/js/jquery-idleTimeout-plus.min.js
+++ b/dist/js/jquery-idleTimeout-plus.min.js
@@ -1 +1 @@
-!function(t,o){"function"==typeof define&&define.amd?define(["jquery"],o):"object"==typeof exports?module.exports=o(require("jquery")):t.IdleTimeoutPlus=o(t.jQuery)}(this,function(t){function o(){null===R&&(R=t.localStorage?t.initNamespaceStorage("jqueryIdleTimeoutPlus").localStorage:{})}function n(t,o){z.multiWindowSupport?R.set(t,o):R[t]=o}function e(t,o){if(o="undefined"==typeof o?null:o,z.multiWindowSupport){if(R.isSet(t))return R.get(t)}else if(t in R)return R[t];return o}function l(){n("warningStartTime",-1),n("lockStartTime",-1),i(),z.idleCallback!==!1&&z.idleCallback(z)}function i(){a(),n("lastActivity",t.now()),Z=setInterval(r,z.idleCheckHeartbeat)}function a(){clearInterval(Z)}function r(){var o=e("lastActivity",t.now())+z.idleTimeLimit;return e("logoutTriggered")===!0?N():e("lockStartTime",-1)!==-1?(a(),A()):t.now()>=o?(a(),z.warnEnabled?d():z.lockEnabled?L():O()):void 0}function c(){t(document).on(z.activityEvents,function(t){if("mousemove"===t.type){if(t.clientX===ot[0]&&t.clientY===ot[1])return;ot[0]=t.clientX,ot[1]=t.clientY}e("warningStartTime",-1)===-1&&e("lockStartTime",-1)===-1&&i()})}function u(){s(),$=setInterval(function(){t.ajax({type:z.keepAliveAjaxType,url:z.keepAliveUrl,data:z.keepAliveAjaxData})},z.keepAliveInterval)}function s(){clearInterval($)}function d(){k(),z.warnCallback!==!1&&(nt=z.warnCallback(z)),w()}function p(){f(),b(),n("warningStartTime",-1),l()}function k(){n("warningStartTime",t.now()),_=setInterval(m,500)}function f(){clearInterval(_)}function m(){if(e("logoutTriggered")===!0)return f(),N();if(e("warningStartTime",-1)===-1)return p();var o=e("warningStartTime")+z.warnTimeLimit-1;return t.now()>=o?(f(),z.lockEnabled?(b(),L()):O()):void v()}function w(){nt&&(g(),v(),z.bootstrap?(lt.modal("show"),lt.focus()):lt.dialog("open"),et=!0)}function b(){et=!1,null!==lt&&(z.bootstrap?(lt.modal("hide"),F.removeClass("modal-open"),t("div.modal-backdrop").remove()):lt.dialog("close"))}function v(){if(null!==lt&&(null!==it||null!==at)){var o=t.now(),n=Math.floor((e("warningStartTime",o)+z.warnTimeLimit-o)/1e3);if(null!==it&&it.html(G(n)),null!==at){var l=Math.floor(n/(z.warnTimeLimit/1e3)*100);z.bootstrap?at.css("width",l+"%"):at.progressbar("value",l)}}}function g(){if(null===lt){var t="";t=z.warnContentCallback===!1?z.bootstrap?j():C():z.warnContentCallback(z),z.bootstrap?y(t):T(t)}}function y(o){F.append(o),null!==z.warnLogoutButton&&t("#jitp-warn-logout").on("click",function(){h()}),t("#jitp-warn-alive").on("click",function(){S()}),lt=t("#jitp-warn-display"),(null!==z.warnCountdownMessage||z.warnCountdownBar)&&(it=lt.find(".jitp-countdown-holder")),z.warnCountdownBar&&(at=t("#jitp-warn-bar"))}function T(o){var n=[];null!==z.warnLogoutButton&&n.push({text:z.warnLogoutButton,click:function(){h()}}),n.push({text:z.warnStayAliveButton,click:function(){S()}}),t(o).dialog({buttons:n,closeOnEscape:!1,modal:!0,title:z.warnTitle,minWidth:320,autoOpen:!1,open:function(){null===z.warnTitle?t(this).closest(".ui-dialog").find(".ui-dialog-titlebar").hide():t(this).closest(".ui-dialog").find(".ui-dialog-titlebar-close").hide(),t(this).parent().find("button:nth-child(2)").focus()}}),lt=t("#jitp-warn-display"),null!==z.warnCountdownMessage&&(it=lt.find(".jitp-countdown-holder")),z.warnCountdownBar&&(at=t("#jitp-warn-bar"),at.progressbar({value:0,max:100}))}function j(){var t=null===z.warnTitle?"":'