Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(AddKeyDownHandler);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(HideLoadingMessage);
Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(HideLoadingMessage);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(aspNetAjaxErrorHandling);
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(RenewRoundtripToken);
if (typeof (Sys.Browser.WebKit) === "undefined") { //ignore jslint
Sys.Browser.WebKit = {};
}
if (navigator.userAgent.indexOf("WebKit/") > -1) {
Sys.Browser.agent = Sys.Browser.WebKit;
Sys.Browser.version = parseFloat(navigator.userAgent.match(/WebKit\/(\d+(\.\d+)?)/)[1]);
Sys.Browser.name = "WebKit";
}
Type.registerNamespace("Acbs");
Type.registerNamespace("Acbs.WebClient");
Acbs.WebClient.SessionAlert = function (objectId) {
Acbs.WebClient.SessionAlert.initializeBase(this, [objectId]);
this.ID = objectId;
this._timeBeginMs = +(new Date());
this._timeEnd = null;
this._timeLeft = 0;
this._logOutTimeMs = 0;
this._sessionTimeout = 60;
this._warnSeconds = 120; // 2 minutes
this._logOutUrl = '/LogOn.aspx?SessionTimeOut=1';
this.CountDownTimer = null;
this.WarnCountDownIntervalTimer = null;
this._redirectFlag = false;
this._maximumTimeEnd = null;
this._maximumTimeLeft = 0;
this._maximumLogOutTimeMs = 0;
this.maximumTimeCountDownTimer = null;
this.maximumTimeWarnCountDownIntervalTimer = null;
this._maximumTimeWarnSeconds = 300; // 5 minutes
};
Acbs.WebClient.SessionAlert.prototype = {
Initialize: function () {
doAjaxPost('/Services/SessionAlertService.asmx/GetSessionTimeoutTime', null, 'POST', 'json', true, false,
Function.createDelegate(this, this.GetSessionTimeoutTimeCallback),
Function.createDelegate(this, this.OnWebServiceErrorCallback));
},
InitializeTimer: function () {
if (this._timeBeginMs + (60 * 1000) < +(new Date())) {
this._timeBeginMs = +(new Date());
}
if (this._timeEnd && +(new Date(this._timeEnd)) > (this._timeBeginMs + (this._sessionTimeout * 60 * 1000) - (60 * 1000))) {
this._logOutTimeMs = +(new Date(this._timeEnd));
} else {
this._logOutTimeMs = this._timeBeginMs + (this._sessionTimeout * 60 * 1000);
}
this._timeLeft = (this._logOutTimeMs - (this._warnSeconds * 1000) - (+new Date()));
if (this.CountDownTimer) {
window.clearTimeout(this.CountDownTimer);
}
this.CountDownTimer = window.setTimeout(Function.createDelegate(this, this.OnCountDown), this._timeLeft / 2);
if (this.WarnCountDownIntervalTimer) {
window.clearInterval(this.WarnCountDownIntervalTimer);
}
this._redirectFlag = false;
if (this._maximumTimeEnd && (+(new Date(this._maximumTimeEnd))) > ((+new Date(this._timeEnd)) - (this._sessionTimeout * 60 * 1000))) {
this._maximumLogOutTimeMs = +(new Date(this._maximumTimeEnd));
}
else {
this._maximumLogOutTimeMs = ((+new Date(this._timeEnd)) - (this._sessionTimeout * 60 * 1000)) + this._maximumTimeWarnSeconds * 1000;
}
this._maximumTimeLeft = (this._maximumLogOutTimeMs - ((+new Date(this._timeEnd)) - (this._sessionTimeout * 60 * 1000)));
if (this.maximumCountDownTimer) {
window.clearTimeout(this.maximumCountDownTimer);
}
this.maximumCountDownTimer = window.setTimeout(Function.createDelegate(this, this.OnMaximumTimeCountDown), this._maximumTimeLeft);
if (this.maximumWarnCountDownIntervalTimer) {
window.clearInterval(this.maximumWarnCountDownIntervalTimer);
}
//this.WriteStatistics();
},
OnOK: function () {
var img = new Image(1, 1);
img.src = '/Reconnect.aspx?dt=' + (+(new Date()));
if (isIE6()) { RestoreDropdowns(); }
$get('sessionAlert-window').style.display = "none";
$get('sessionAlert-shadow').style.display = "none";
$get('sessionAlert-background').style.display = "none";
if (this.WarnCountDownIntervalTimer) {
window.clearInterval(this.WarnCountDownIntervalTimer);
}
this.Initialize();
if (window.location.pathname.toLowerCase().indexOf('/calendarpage.aspx') >= 0 && 'undefined' !== typeof (calendarId)) {
doPostBack(calendarId, null);
}
},
OnCancel: function () {
$get('sessionAlert-window').style.display = "none";
$get('sessionAlert-shadow').style.display = "none";
$get('sessionAlert-background').style.display = "none";
if (this.WarnCountDownIntervalTimer) {
window.clearInterval(this.WarnCountDownIntervalTimer);
}
if (this.CountDownTimer) {
window.clearTimeout(this.CountDownTimer);
}
if (!this._redirectFlag) {
this._redirectFlag = true;
window.location.href = this._logOutUrl;
}
},
OnWarn: function () {
$('#sessionAlert-background').height($(document).height());
$get('sessionAlert-window').style.display = "block";
$get('sessionAlert-shadow').style.display = "block";
$get('sessionAlert-background').style.display = "block";
if (isIE6()) { HideAllDropDownLists(); }
this._timeLeft = this._warnSeconds;
this.UpdateWarnTimeLeft();
this.WarnCountDownIntervalTimer = window.setInterval(Function.createDelegate(this, this.WarnCountDown), 1000);
window.focus();
if ($get('btnOK')) {
$get('btnOK').focus();
}
},
OnCountDown: function () {
this._timeLeft = (this._logOutTimeMs - (this._warnSeconds * 1000) - (+(new Date())));
if (this._timeLeft <= 60 * 1000) {
// if less than 1 minutes left, go to warn
this.CountDownTimer = window.setTimeout(Function.createDelegate(this, this.OnWarn), this._timeLeft);
} else {
// else set timer for half of the remaining session time
this.CountDownTimer = window.setTimeout(Function.createDelegate(this, this.OnCountDown), ((this._timeLeft - 5000) / 2));
}
//this.WriteStatistics();
},
WarnCountDown: function () {
this._timeLeft--;
if (this._timeLeft >= 0) {
this.UpdateWarnTimeLeft();
} else {
if (this.WarnCountDownIntervalTimer) {
window.clearInterval(this.WarnCountDownIntervalTimer);
}
if (this.CountDownTimer) {
window.clearTimeout(this.CountDownTimer);
}
if (!this._redirectFlag) {
this._redirectFlag = true;
window.location.href = this._logOutUrl;
}
}
},
UpdateWarnTimeLeft: function () {
$get('sessionAlert-msg').innerHTML = 'Your session will end in ' + this._timeLeft + ' seconds.
Please click OK to renew your session.';
},
GetSessionTimeoutTimeCallback: function (timeoutTime) {
this._timeEnd = timeoutTime.d;
this.InitializeTimer();
},
OnWebServiceErrorCallback: function (error) {
//alert(error.get_message());
this._timeEnd = null;
this.InitializeTimer();
},
OnMaximumTimeCountDown: function () {
this._maximumTimeLeft = (this._maximumLogOutTimeMs - (+(new Date())));
if (this._maximumTimeLeft <= 60 * 1000) {
// if less than 1 minutes left, go to warn
this.maximumTimeCountDownTimer = window.setTimeout(Function.createDelegate(this, this.OnMaximumTimeWarn), this._maximumTimeLeft);
} else {
// else set timer for half of the remaining session time
this.maximumTimeCountDownTimer = window.setTimeout(Function.createDelegate(this, this.OnMaximumTimeCountDown), ((this._maximumTimeLeft - 5000) / 2));
}
},
OnMaximumTimeWarn: function () {
$('#maximum-session-alert-background').height($(document).height());
$get('maximum-session-alert-window').style.display = "block";
$get('maximum-session-alert-shadow').style.display = "block";
$get('maximum-session-alert-background').style.display = "block";
if (isIE6()) { HideAllDropDownLists(); }
this._maximumTimeLeft = this._maximumTimeWarnSeconds;
this.MaximumTimeUpdateWarnTimeLeft();
this.maximumTimeWarnCountDownIntervalTimer = window.setInterval(Function.createDelegate(this, this.MaximumTimeWarnCountDown), 1000);
window.focus();
if ($get('btnSessionAlertOK')) {
$get('btnSessionAlertOK').focus();
}
},
MaximumTimeWarnCountDown: function () {
this._maximumTimeLeft--;
if (this._maximumTimeLeft >= 0) {
this.MaximumTimeUpdateWarnTimeLeft();
} else {
if (this.maximumTimeWarnCountDownIntervalTimer) {
window.clearInterval(this.maximumTimeWarnCountDownIntervalTimer);
}
if (this._maximumTimeCountDownTimer) {
window.clearTimeout(this.maximumTimeCountDownTimer);
}
window.location.href = this._logOutUrl;
}
},
MaximumTimeUpdateWarnTimeLeft: function () {
$get('maximum-session-alert-msg').innerHTML = 'Your session will end in ' + this._maximumTimeLeft + ' seconds.
Please save all your changes and re-login to SyndTrak.';
},
OnMaximumTimeOK: function () {
$get('maximum-session-alert-window').style.display = "none";
$get('maximum-session-alert-shadow').style.display = "none";
$get('maximum-session-alert-background').style.display = "none";
if (this.maximumTimeWarnCountDownIntervalTimer) {
window.clearInterval(this.maximumTimeWarnCountDownIntervalTimer);
}
if (this.maximumTimeCountDownTimer) {
window.clearTimeout(this.maximumTimeCountDownTimer);
}
},
WriteStatistics: function () {
// For debugging purpose, make sure there is a div with id="sessionStats"
var beginHours = new Date(this._timeBeginMs).getHours();
var beginMinutes = new Date(this._timeBeginMs).getMinutes();
var beginSeconds = new Date(this._timeBeginMs).getSeconds();
if (beginMinutes < 10) {
beginMinutes = '0' + beginMinutes;
}
if (beginSeconds < 10) {
beginSeconds = '0' + beginSeconds;
}
var endHours = new Date(this._timeEnd).getHours();
var endMinutes = new Date(this._timeEnd).getMinutes();
var endSeconds = new Date(this._timeEnd).getSeconds();
if (endMinutes < 10) {
endMinutes = '0' + endMinutes;
}
if (endSeconds < 10) {
endSeconds = '0' + endSeconds;
}
if ($('#sessionStats')) {
$('#sessionStats').text('Session timeout: ' + (this._sessionTimeout + (this._warnSeconds / 60))
+ ' | Begin time: ' + beginHours + ':' + beginMinutes + ':' + beginSeconds
+ ' | End time: ' + endHours + ':' + endMinutes + ':' + endSeconds
+ ' | Warning in: ' + (this._timeLeft / 60000).toFixed(2));
}
}
};
Acbs.WebClient.SessionAlert.registerClass('Acbs.WebClient.SessionAlert', Sys.UI.Control);
if (typeof (Sys) !== 'undefined') { //ignore jslint
Sys.Application.notifyScriptLoaded();
}