Primer Commit

This commit is contained in:
LuisAngelSalinasl
2025-08-04 18:51:41 -06:00
commit 8fcbb98114
8990 changed files with 1407288 additions and 0 deletions
@@ -0,0 +1,189 @@
/*
* jQuery Idle Timeout 1.2
* Copyright (c) 2011 Eric Hynds
*
* http://www.erichynds.com/jquery/a-new-and-improved-jquery-idle-timeout-plugin/
*
* Depends:
* - jQuery 1.4.2+
* - jQuery Idle Timer (by Paul Irish, http://paulirish.com/2009/jquery-idletimer-plugin/)
*
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/
(function($, win){
var idleTimeout = {
init: function( element, resume, options ){
var self = this, elem;
this.warning = elem = $(element);
this.resume = $(resume);
this.options = options;
this.countdownOpen = false;
this.failedRequests = options.failedRequests;
this._startTimer();
this.title = document.title;
// expose obj to data cache so peeps can call internal methods
$.data( elem[0], 'idletimeout', this );
// start the idle timer
$.idleTimer(options.idleAfter * 1000);
// once the user becomes idle
$(document).bind("idle.idleTimer", function(){
// if the user is idle and a countdown isn't already running
if( $.data(document, 'idleTimer') === 'idle' && !self.countdownOpen ){
self._stopTimer();
self.countdownOpen = true;
self._idle();
}
});
// bind continue link
this.resume.bind("click", function(e){
e.preventDefault();
win.clearInterval(self.countdown); // stop the countdown
self.countdownOpen = false; // stop countdown
self._startTimer(); // start up the timer again
self._keepAlive( false ); // ping server
options.onResume.call( self.warning ); // call the resume callback
});
},
_idle: function(){
var self = this,
options = this.options,
warning = this.warning[0],
counter = options.warningLength;
// fire the onIdle function
options.onIdle.call(warning);
// set inital value in the countdown placeholder
options.onCountdown.call(warning, counter);
// create a timer that runs every second
this.countdown = win.setInterval(function(){
if(--counter === 0){
window.clearInterval(self.countdown);
options.onTimeout.call(warning);
} else {
options.onCountdown.call(warning, counter);
document.title = options.titleMessage.replace('%s', counter) + self.title;
}
}, 1000);
},
_startTimer: function(){
var self = this;
this.timer = win.setTimeout(function(){
self._keepAlive();
}, this.options.pollingInterval * 1000);
},
_stopTimer: function(){
// reset the failed requests counter
this.failedRequests = this.options.failedRequests;
win.clearTimeout(this.timer);
},
_keepAlive: function( recurse ){
var self = this,
options = this.options;
//Reset the title to what it was.
document.title = self.title;
// assume a startTimer/keepAlive loop unless told otherwise
if( typeof recurse === "undefined" ){
recurse = true;
}
// if too many requests failed, abort
if( !this.failedRequests ){
this._stopTimer();
options.onAbort.call( this.warning[0] );
return;
}
$.ajax({
timeout: options.AJAXTimeout,
url: options.keepAliveURL,
error: function(){
self.failedRequests--;
},
success: function(response){
if($.trim(response) !== options.serverResponseEquals){
self.failedRequests--;
}
},
complete: function(){
if( recurse ){
self._startTimer();
}
}
});
}
};
// expose
$.idleTimeout = function(element, resume, options){
idleTimeout.init( element, resume, $.extend($.idleTimeout.options, options) );
return this;
};
// options
$.idleTimeout.options = {
// number of seconds after user is idle to show the warning
warningLength: 30,
// url to call to keep the session alive while the user is active
keepAliveURL: "",
// the response from keepAliveURL must equal this text:
serverResponseEquals: "OK",
// user is considered idle after this many seconds. 10 minutes default
idleAfter: 600,
// a polling request will be sent to the server every X seconds
pollingInterval: 60,
// number of failed polling requests until we abort this script
failedRequests: 5,
// the $.ajax timeout in MILLISECONDS!
AJAXTimeout: 250,
// %s will be replaced by the counter value
titleMessage: 'Warning: %s seconds until log out | ',
/*
Callbacks
"this" refers to the element found by the first selector passed to $.idleTimeout.
*/
// callback to fire when the session times out
onTimeout: $.noop,
// fires when the user becomes idle
onIdle: $.noop,
// fires during each second of warningLength
onCountdown: $.noop,
// fires when the user resumes the session
onResume: $.noop,
// callback to fire when the script is aborted due to too many failed requests
onAbort: $.noop
};
})(jQuery, window);
@@ -0,0 +1,148 @@
/*
* jQuery idleTimer plugin
* version 0.8.092209
* by Paul Irish.
* http://github.com/paulirish/yui-misc/tree/
* MIT license
* adapted from YUI idle timer by nzakas:
* http://github.com/nzakas/yui-misc/
* Copyright (c) 2009 Nicholas C. Zakas
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
(function($){
$.idleTimer = function f(newTimeout){
//$.idleTimer.tId = -1 //timeout ID
var idle = false, //indicates if the user is idle
enabled = true, //indicates if the idle timer is enabled
timeout = 30000, //the amount of time (ms) before the user is considered idle
events = 'mousemove keydown DOMMouseScroll mousewheel mousedown', // activity is one of these events
//f.olddate = undefined, // olddate used for getElapsedTime. stored on the function
/* (intentionally not documented)
* Toggles the idle state and fires an appropriate event.
* @return {void}
*/
toggleIdleState = function(){
//toggle the state
idle = !idle;
// reset timeout counter
f.olddate = +new Date;
//fire appropriate event
$(document).trigger( $.data(document,'idleTimer', idle ? "idle" : "active" ) + '.idleTimer');
},
/**
* Stops the idle timer. This removes appropriate event handlers
* and cancels any pending timeouts.
* @return {void}
* @method stop
* @static
*/
stop = function(){
//set to disabled
enabled = false;
//clear any pending timeouts
clearTimeout($.idleTimer.tId);
//detach the event handlers
$(document).unbind('.idleTimer');
},
/* (intentionally not documented)
* Handles a user event indicating that the user isn't idle.
* @param {Event} event A DOM2-normalized event object.
* @return {void}
*/
handleUserEvent = function(){
//clear any existing timeout
clearTimeout($.idleTimer.tId);
//if the idle timer is enabled
if (enabled){
//if it's idle, that means the user is no longer idle
if (idle){
toggleIdleState();
}
//set a new timeout
$.idleTimer.tId = setTimeout(toggleIdleState, timeout);
}
};
/**
* Starts the idle timer. This adds appropriate event handlers
* and starts the first timeout.
* @param {int} newTimeout (Optional) A new value for the timeout period in ms.
* @return {void}
* @method $.idleTimer
* @static
*/
f.olddate = f.olddate || +new Date;
//assign a new timeout if necessary
if (typeof newTimeout == "number"){
timeout = newTimeout;
} else if (newTimeout === 'destroy') {
stop();
return this;
} else if (newTimeout === 'getElapsedTime'){
return (+new Date) - f.olddate;
}
//assign appropriate event handlers
$(document).bind($.trim((events+' ').split(' ').join('.idleTimer ')),handleUserEvent);
//set a timeout to toggle state
$.idleTimer.tId = setTimeout(toggleIdleState, timeout);
// assume the user is active for the first x seconds.
$.data(document,'idleTimer',"active");
}; // end of $.idleTimer()
})(jQuery);
@@ -0,0 +1,48 @@
var UIIdleTimeout = function() {
return {
init: function() {
var o;
$("body").append(""), $.idleTimeout("#idle-timeout-dialog", ".modal-content button:last", {
idleAfter: 5,
timeout: 3e4,
pollingInterval: 5,
keepAliveURL: "/keep-alive",
serverResponseEquals: "OK",
onTimeout: function() {
window.location = "authentication-lockscreen.html"
},
onIdle: function() {
$("#idle-timeout-dialog").modal("show"), o = $("#idle-timeout-counter"), $("#idle-timeout-dialog-keepalive").on("click", function() {
$("#idle-timeout-dialog").modal("hide")
})
},
onCountdown: function(e) {
o.html(e)
}
})
}
}
}();
jQuery(function() {
UIIdleTimeout.init()
});
/*$.idleTimeout('#idletimeout', '#idletimeout a', {
idleAfter: 5,
pollingInterval: 2,
keepAliveURL: 'keep.php',
serverResponseEquals: 'OK',
onTimeout: function(){
$(this).slideUp();
window.location = "lock-screen.html";
},
onIdle: function(){
$(this).slideDown(); // show the warning bar
},
onCountdown: function( counter ){
$(this).find("span").html( counter ); // update the counter
},
onResume: function(){
$(this).slideUp(); // hide the warning bar
}
});*/
@@ -0,0 +1,44 @@
! function(e) {
"use strict";
e.sessionTimeout = function(t) {
function o() { f || (e.ajax({ type: d.ajaxType, url: d.keepAliveUrl, data: d.ajaxData }), f = !0, setTimeout(function() { f = !1 }, d.keepAliveInterval)) }
function i() { clearTimeout(a), (d.countdownMessage || d.countdownBar) && s("session", !0), "function" == typeof d.onStart && d.onStart(d), d.keepAlive && o(), a = setTimeout(function() { "function" != typeof d.onWarn ? e("#session-timeout-dialog").modal("show") : d.onWarn(d), n() }, d.warnAfter) }
function n() { clearTimeout(a), e("#session-timeout-dialog").hasClass("in") || !d.countdownMessage && !d.countdownBar || s("dialog", !0), a = setTimeout(function() { "function" != typeof d.onRedir ? window.location = d.redirUrl : d.onRedir(d) }, d.redirAfter - d.warnAfter) }
function s(t, o) {
clearTimeout(l.timer), "dialog" === t && o ? l.timeLeft = Math.floor((d.redirAfter - d.warnAfter) / 1e3) : "session" === t && o && (l.timeLeft = Math.floor(d.redirAfter / 1e3)), d.countdownBar && "dialog" === t ? l.percentLeft = Math.floor(l.timeLeft / ((d.redirAfter - d.warnAfter) / 1e3) * 100) : d.countdownBar && "session" === t && (l.percentLeft = Math.floor(l.timeLeft / (d.redirAfter / 1e3) * 100));
var i = e(".countdown-holder"),
n = l.timeLeft >= 0 ? l.timeLeft : 0;
if (d.countdownSmart) {
var a = Math.floor(n / 60),
r = n % 60,
u = a > 0 ? a + "m" : "";
u.length > 0 && (u += " "), u += r + "s", i.text(u)
} else i.text(n + "s");
d.countdownBar && e(".countdown-bar").css("width", l.percentLeft + "%"), l.timeLeft = l.timeLeft - 1, l.timer = setTimeout(function() { s(t) }, 1e3)
}
var a, r = { title: "Your Session is About to Expire!", message: "Your session is about to expire.", logoutButton: "Logout", keepAliveButton: "Stay Connected", keepAliveUrl: "/keep-alive", ajaxType: "POST", ajaxData: "", redirUrl: "/timed-out", logoutUrl: "/log-out", warnAfter: 9e5, redirAfter: 12e5, keepAliveInterval: 5e3, keepAlive: !0, ignoreUserActivity: !1, onStart: !1, onWarn: !1, onRedir: !1, countdownMessage: !1, countdownBar: !1, countdownSmart: !1 },
d = r,
l = {};
if (t && (d = e.extend(r, t)), d.warnAfter >= d.redirAfter) return console.error('Bootstrap-session-timeout plugin is miss-configured. Option "redirAfter" must be equal or greater than "warnAfter".'), !1;
if ("function" != typeof d.onWarn) {
var u = d.countdownMessage ? "<p>" + d.countdownMessage.replace(/{timer}/g, '<span class="countdown-holder"></span>') + "</p>" : "",
c = d.countdownBar ? '<div class="progress" style="height: 15px;"> <div class="progress-bar bg-info countdown-bar active" role="progressbar" style="min-width: 15px; width: 100%;"> <span class="countdown-holder"></span> </div> </div>' : "";
e("body").append('<div class="modal fade" id="session-timeout-dialog"> <div class="modal-dialog"> <div class="modal-content"> <div class="modal-header"> <h4 class="modal-title">' + d.title + '</h4> <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> </div> <div class="modal-body"> <p>' + d.message + "</p> " + u + " " + c + ' </div> <div class="modal-footer"> <button id="session-timeout-dialog-logout" type="button" class="btn btn-danger">' + d.logoutButton + '</button> <button id="session-timeout-dialog-keepalive" type="button" class="btn btn-success" data-dismiss="modal">' + d.keepAliveButton + "</button> </div> </div> </div> </div>"), e("#session-timeout-dialog-logout").on("click", function() { window.location = d.logoutUrl }), e("#session-timeout-dialog").on("hide.bs.modal", function() { i() })
}
if (!d.ignoreUserActivity) {
var m = [-1, -1];
e(document).on("keyup mouseup mousemove touchend touchmove", function(t) {
if ("mousemove" === t.type) {
if (t.clientX === m[0] && t.clientY === m[1]) return;
m[0] = t.clientX, m[1] = t.clientY
}
i(), e("#session-timeout-dialog").length > 0 && e("#session-timeout-dialog").data("bs.modal") && e("#session-timeout-dialog").data("bs.modal").isShown && (e("#session-timeout-dialog").modal("hide"), e("body").removeClass("modal-open"), e("div.modal-backdrop").remove())
})
}
var f = !1;
i()
}
}(jQuery);
@@ -0,0 +1,66 @@
(function(e) {
jQuery.sessionTimeout = function(t) {
function u(t) {
switch (t) {
case "start":
s = setTimeout(function() {
e.each(i.closeModals, function(t, n) {
e("#" + n).modal("hide")
});
document.title = i.titleMessage;
e("#sessionTimeout-dialog").modal("show");
a("start")
}, i.warnAfter);
break;
case "stop":
clearTimeout(s);
break
}
}
function a(e) {
switch (e) {
case "start":
o = setTimeout(function() {
window.location = i.redirUrl
}, i.redirAfter - i.warnAfter);
break;
case "stop":
clearTimeout(o);
break
}
}
var n = [];
var r = {
title: "Your session is about to expire!",
message: "Your session is about to expire.",
titleMessage: "Warning: Time Out",
stayConnectedBtn: "Stay connected",
logoutBtn: "Logout",
closeModals: n,
keepAliveUrl: "/keep-alive",
redirUrl: "/timed-out",
logoutUrl: "/log-out",
warnAfter: 9e5,
redirAfter: 12e5
};
var i = r,
s, o;
if (t) {
i = e.extend(r, t)
}
e("body").append('<div class="modal fade" id="sessionTimeout-dialog">' + '<div class="modal-dialog">' + '<div class="modal-content">' + '<div class="modal-header">' + '<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>' + '<h4 class="modal-title">' + i.title + "</h4>" + "</div>" + '<div class="modal-body">' + i.message + "</div>" + '<div class="modal-footer">' + '<div class="btn-group">' + '<button id="sessionTimeout-dialog-logout" type="button" class="btn btn-danger">' + i.logoutBtn + "</button>" + '<button id="sessionTimeout-dialog-keepalive" type="button" class="btn btn-success" data-dismiss="modal">' + i.stayConnectedBtn + "</button>" + "</div>" + "</div>" + "</div>" + "</div>" + "</div>");
e("#sessionTimeout-dialog-logout").on("click", function() {
window.location = i.logoutUrl
});
e("#sessionTimeout-dialog").on("hide.bs.modal", function() {
e.ajax({
type: "POST",
url: i.keepAliveUrl
});
a("stop");
u("start")
});
u("start")
}
})(jQuery)
@@ -0,0 +1,2 @@
var SessionTimeout = function() { var i = function() { $.sessionTimeout({ title: "Session Timeout Notification", message: "Your session is expiring soon.", redirUrl: "authentication-lockscreen.html", logoutUrl: "authentication-login1.html", warnAfter: 5e3, redirAfter: 2e4, ignoreUserActivity: !0, countdownMessage: "Redirecting in {timer} seconds.", countdownBar: !0 }) }; return { init: function() { i() } } }();
jQuery(function() { SessionTimeout.init() });