var defaultScreenMode = "default" // will replace with parm var defaultPasswordChangePage = "password_change.jsp" // will replace with parm var defaultMessagePage = "/jsps/error.jsp"; var defaultLogonPage = "/"; var defaultPath = "/jsps/"; var defaultServletPath = "/EFClientMainServlet"; var defaultAdminServletPath = "/EFAdminServlet"; var activeServlet = "/EFClientMainServlet"; var defaultSystemID = "BFIA"; var pageDumpTimer = 30000; var sessionCheckTimer = 5000; //var sessionCheckTimer = 45; var suspendTimeout = 9000; var pageKeyName = "_includes_js_rsscript.jsp"; var DEBUG = false; var checkTimeOutSw = true; var formsDumpSw = false; var defaultErrorFieldStyle = "color"; var defaultErrorFieldColor = "yellow"; var securedSw = true; var undefined; // do not give this a value var errorMessageType = "span"; var processing_dialog; var processCntr = 0; var processingWindowStatus; var processingMessage = ""; var lastEventTime = new Date(); var isSuspendMode = false; var isSuspendDialog = false; var pingSw = true; var now = false; var dialogSw = false; var alertUp = false; var coverUp = false; var bypassSuspend = false; var rsParent; var closePopupsSw = false; var containerHash = {}; var p_uid =""; var p_pwd =""; var m_page_timer_sw = false; var loggingOut = false; var bypassUnload = false; var to_upper_sw = false; var scrnWidth = 0; var scrnHeight = 0; var processId; var pingInterval = 7000; var rs_userid = "null"; //some useful constants var CONFIRM_YES = 1; var CONFIRM_NO = 2; var CONFIRM_CANCEL = 3; /* errorNotify - used to report any exceptions encountered */ /* Debugging methods to print out the present stack trace */ function stackTrace(startingPoint) { var stackTraceMessage = "Stack trace:
\n"; if (document) { stackTraceMessage += "Current document: " + document.location + "
\n"; } var nextCaller = startingPoint; while (nextCaller) { stackTraceMessage += getSignature(nextCaller) + "\n"; nextCaller = nextCaller.caller; } stackTraceMessage += "\n\n"; return stackTraceMessage; } function getSignature(theFunction) { var signature = getFunctionName(theFunction); signature += "("; for (var x=0; x 30) nextArgument = nextArgument.substring(0, 30) + "..."; // apend the next argument to the signature signature += nextArgument!=null ? "'" + nextArgument + "'" : 'null'; // comma seperator if(x < theFunction.arguments.length - 1) signature += ", "; } signature += ")"; return signature; } function getFunctionName(theFunction) { // mozilla makes it easy. I love mozilla. if(theFunction.name) { return theFunction.name; } // try to parse the function name from the definition var definition = theFunction.toString(); var name = definition.substring(definition.indexOf('function') + 8,definition.indexOf('(')); if(name) return name; // sometimes there won't be a function name // like for dynamic functions return "anonymous"; } function errorNotify(errobj) { //we don't want to show the same error multiple times if (DEBUG && !errobj.alerted) { alert("!error! " + errobj.message); alert(window.stackTrace(arguments.callee)); errobj.alerted = true; throw errobj; } else if (DEBUG) { //allow browser to receive the exception, helps for debugging throw errobj; } } function isReadOnly(show_warning) { return false; } function startsWith(str, val) { if (str == null || val == null) return false; if (val.length > str.length) return false; return (str.indexOf(val,0) != -1); } function setMother(m){ } function setPing(sw) { pingSw = sw; } function setDebug(sw) { DEBUG = sw; } function getSelectedValue(el) { if (el == null) return null; var inx = el.selectedIndex; if (inx != -1) { return (el.options[inx].value); } return null; } // Basic event handler routines function setParent(w) { rsParent = w; } function setEventTime() { try { if (!m_page_timer_sw)return; lastEventTime = new Date(); if (rsParent != undefined) rsParent.setEventTime(); } catch (e) { errorNotify(e); } } function setDialogSwitch(sw) { dialogSw = sw; } function isDialog(){return dialogSw;} function setSessionPing() { setInterval("pingServer(true)", pingInterval); } /** initializes the page */ /*************************/ function initPage(sw) { try { loggingOut = false; // set the timer as necessary /******** --- THIS SECTION HAS BEEN DISABLED -- USE setSessionPing in top window of appliccation. if ((false == true || dialogSw == true) || (sw != undefined && sw == true)) { m_page_timer_sw = true; setInterval("checkSessionTimeOut()", sessionCheckTimer); pingServer(false); setInterval("pingServer(false)", pingInterval); } else { m_page_timer_sw = false; } *********/ clearAllMessageFields(); } catch (e) {errorNotify(e);} } function getScreenMode() { try { // call method in footer return getScreenModeF(); } catch (e) { errorNotify(e); } } function isResolutionChanged() { try { var w = screen.availWidth; var h = screen.availHeight; return (w != scrnWidth || h != scrnHeight); } catch (e) {} } function pingServer(bypass) { try { if (!pingSw) return; var c = createNewContainer("PING"); var tw = getTopWindow(); if (tw != null) { if (tw.isResolutionChanged()) { tw.scrnWidth = screen.availWidth; tw.scrnHeight = screen.availHeight; c.putRequestParameter("screen_width", tw.scrnWidth); c.putRequestParameter("screen_height", tw.scrnHeight); } } if (bypass) c.setBypassSessionCheckSw(true); else c.setBypassSessionCheckSw(false); callEngageRS(c, "ping", "pingHandler", false); } catch (e) {} } function pingHandler(c) { try { do { if (!c.isAck()) { closePopupsSw = true; if (false == true || dialogSw) { var doneSw = "logout"; var obj = new Object; obj.response = doneSw; window.returnValue = obj; window.close(); } else goToLogon(); break; } if (c.wasError()) { if (false == true || dialogSw) { if (isSuspendDialog) { closePopupsSw = true; var doneSw = "logout"; var obj = new Object; obj.response = doneSw; window.returnValue = obj; window.close(); break; } } handleBasicErrors(c); break; } var message = c.getResponseParameter("usermessage"); if (message != undefined && message.length > 0) { var fname = c.getResponseParameter("firstname"); var lname = c.getResponseParameter("lastname"); fname = htmlDecode(fname); lname = htmlDecode(lname); message = htmlDecode(message); alert("Message from " + fname + " " + lname + "

" + message, 675, 300); } }while(false); } catch (e) {} } function htmlDecode(input){ var decoded = $('
').html(input).text(); return decoded; } function showMDialog(_url, obj, str, callBackParam) { obj = obj || {}; var heightParam = 500; var widthParam = 500; str = modifyDialogHeightWidth(str); if (str.indexOf("dialogHeight") != -1) { var heightString = str.substring(str.indexOf("dialogHeight") + "dialogHeight".length); heightString = heightString.substring(heightString.indexOf(":") + 1, heightString.indexOf("px")); heightParam = parseInt(heightString); } if (str.indexOf("dialogWidth") != -1) { var widthString = str.substring(str.indexOf("dialogWidth") + "dialogWidth".length); widthString = widthString.substring(widthString.indexOf(":") + 1, widthString.indexOf("px")); widthParam = parseInt(widthString); } return getIFrameDialogBox(_url, widthParam, heightParam, obj.title || '', '', callBackParam, obj); } //converting parameters to firefox style (http://www.bigresource.com/JAVASCRIPTS-replacement-for-window-showmodelessdialog-in-mozilla-1sSpNgGX.html) function convertIEWindowParamsToFirefox(sFeatures) { /* Notes: 1. edge & help attributes do not work. 2. "height" & "width" must be entered before "center" 3. if you should choose to set "center=yes" do not put in "left" and "top" 4. Minimize button not hidden, but when clicked the window will not disappear 5. Aside from the aforementioned, all features should react the same *fingers crossed* 6. Still in the works, so don't expect miracles. Any problems/queries/complaints please don't hesitate. Email: x_goose_x@hotmail.com */ sFeatures = sFeatures.replace(/ /gi,''); arrFeatures = sFeatures.split(";"); sWinFeat = "directories=0,menubar=0,titlebar=0,toolbar=0,"; for ( x in arrFeatures ) { aTmp = arrFeatures[x].split(":"); sKey = aTmp[0].toLowerCase(); sVal = aTmp[1]; switch (sKey) { case "dialogheight" : sWinFeat += "height=" + sVal + ","; pHeight = sVal; break; case "dialogwidth": sWinFeat += "width=" + sVal + ","; pWidth = sVal; break; case "dialogtop": sWinFeat += "screenY=" + sVal + ","; break; case "dialogleft": sWinFeat += "screenX=" + sVal + ","; break; case "resizable": sWinFeat += "resizable=" + sVal + ","; break; case "status": sWinFeat += "status=" + sVal + ","; break; case "center": if ( sVal.toLowerCase() == "yes" ) { sWinFeat += "screenY=" + ((screen.availHeight-pHeight)/2) + ","; sWinFeat += "screenX=" + ((screen.availWidth-pWidth)/2) + ","; } break; } } return sWinFeat; } function showMlessDialog(_url, obj, str) { try { str = modifyDialogHeightWidth(str); if (window.showModelessDialog) { return showModelessDialog(_url, obj, str); } else { str = convertIEWindowParamsToFirefox(str); var wnd = window.open(_url, _url, str); wnd.dialogArguments = obj; } } catch (e) { errorNotify(e); } } function modifyDialogHeightWidth(str) { var _multiplier = 1.1; var ixH = 0; var ixHP = 0; var sstr = ""; var sstr2 = ""; var pH = 0; var pW = 0; var s = ""; var s_w = screen.availWidth; var s_h = screen.availHeight; ixH = str.indexOf("dialogHeight:", 0); ixHP = str.indexOf("px", ixH); sstr = str.substring(ixH, ixHP + 2); s = str.substring(ixH + "dialogHeight:".length, ixHP); pH = parseInt(s); if ((pH * _multiplier) <= s_h) { sstr2 = sstr.replace(s, " "+ (pH * _multiplier)); str = str.replace(sstr, sstr2); } ixH = str.indexOf("dialogWidth:", 0); ixHP = str.indexOf("px", ixH); sstr = str.substring(ixH, ixHP + 2); s = str.substring(ixH + "dialogWidth:".length, ixHP); pW = parseInt(s); if ((pW * _multiplier) <= s_w) { sstr2 = sstr.replace(s, " "+ (pW * _multiplier)); str = str.replace(sstr, sstr2); } return str; } function error(pMessage, w, h) { if (pMessage == null) return; pMessage = "" + pMessage + ""; if (w == null || h == null) { if (pMessage.length > 150) { w = 533; h = 333; } } alert(pMessage, w, h); } function isNativeModalDialogBoxSupported() { return false; } function removeHTMLTags(str) { if (str == null || str.length == 0) return ""; str = str.replace(/
/g, "\n"); str = str.replace(//g, "\n"); str = str.replace(/<\/br>/g, ""); for (var i = 0; i < 20; i++) { var index1 = str.indexOf("<") if (index1 < 0) break; var index2 = str.indexOf(">", index1); if (index2 < 0) break; var a = str.substring(0, index1); if (index2 < str.length -1) { str = a + str.substring(index2 + 1); } else { str = a; } } return str; } var origAlert = window.alert; window.alert = function(pMessage, w, h) { if (isNativeModalDialogBoxSupported()) { return alertBox(pMessage, w, h); } return origAlert(removeHTMLTags(pMessage)); } function alertBox(pMessage, w, h) { var pg = "alert.jsp"; if (!securedSw) pg = "alert_NS.jsp"; if (w == undefined) { w = 375; } if (h == undefined){ h = 225; } var msg = ("" + pMessage).replace(/^\n/, '
'); var obj = {}; obj.pMessage = msg; obj.securedSw = securedSw; closePopupsSw = false; try { window.sessionStorage.setItem("dialogArguments", JSON.stringify(obj)); } catch (ignored) {} // mother and pParent won't be passed because of the serialization process obj.mother = getTopWindow(); obj.pParent = window; var ret = window.showMDialog("/skeva/engage/engage_common/view/web/" + pg, obj, "center: yes; dialogHeight: " + h + "px; dialogWidth: " + w + "px; edge: Raised; scroll: No; resizable: No; status: No;"); return ret || false; } function confirmJQuery(message, callbackOk, callbackCancel) { $('
').dialog({ modal: true, resizable: false, width:400, title: "Confirmation", open: function() { $(this).html(message); $('.ui-button').addClass('smallUIButton'); }, buttons: { Cancel: function() { callbackCancel && callbackCancel(); $( this ).dialog( "close" ); }, OK: function(){ callbackOk(); $( this ).dialog( "close" ); } } }); } function passwordPromptJQuery(msg, callback){ var tmp = msg + "

"; $('
').dialog({ modal: true, resizable: false, open: function() { $(this).html(tmp); var buttons = $('.ui-button'); buttons.addClass('smallUIButton'); }, buttons: { OK: function(){ callback($('#passwordPrompt2Field').val()); $( this ).dialog( "close" ); } } }); } var origConfirm = window.confirm; window.confirm = function(pMessage, w, h, set_upper_left, path_to_page) { if (isNativeModalDialogBoxSupported()) { return confirmBox(pMessage, w, h, set_upper_left, path_to_page); } return origConfirm(removeHTMLTags(pMessage)); } function confirmBox(pMessage, w, h, set_upper_left, path_to_page) { var ret; try { var pg = "confirm.jsp"; if (path_to_page == null || path_to_page == undefined) { path_to_page = "/skeva/engage/engage_common/view/web/" + pg; } var ustr = (set_upper_left != null && set_upper_left == true) ? " dialogLeft:25; dialogTop:25; " : ""; if (!securedSw) pg = "confirm_NS.jsp"; var msg = pMessage.replace(/^\n/, '
'); var obj = new Object(); obj.pMessage = msg; obj.pParent = window; obj.securedSw = securedSw; obj.mother = getTopWindow(); closePopupsSw = false; if (w != undefined && h != undefined) ret = window.showMDialog(path_to_page,obj, ustr + "center: yes; dialogHeight: " + h + "px; dialogWidth: " + w + "px; edge: Raised; scroll: No; resizable: No; status: No;"); else ret = window.showMDialog(path_to_page,obj, ustr + "center: yes; dialogHeight: 225px; dialogWidth: 350px; edge: Raised; scroll: No; resizable: No; status: No;"); if (ret == undefined) return false; else return ret; } catch (e) {} } function confirm3Buttons(pMessage, w, h) { var pg = "/skeva/engage/engage_common/view/web/confirm3Buttons.jsp"; var msg = pMessage.replace(/^\n/, '
'); var obj = new Object(); obj.pMessage = msg; obj.pParent = window; obj.securedSw = securedSw; obj.mother = getTopWindow(); w = w || 350; h = h || 225; var ret = window.showMDialog(pg, obj, "center: yes; dialogHeight: " + h + "px; dialogWidth: " + w + "px; edge: Raised; scroll: No; resizable: No; status: No;"); return ret || CONFIRM_CANCEL; } function confirmDialog(pMessage,pType,height,width) { try { var msg = pMessage.replace(/^\n/, '
'); var obj = new Object(); obj.pMessage = msg; obj.pParent = window; obj.securedSw = securedSw; obj.mother = getTopWindow(); obj.type = pType; var ret = window.showMDialog("/skeva/engage/engage_common/view/web/confirm.jsp",obj,"center: yes; dialogHeight: "+height+"px; dialogWidth: "+width+"px; edge: Raised; scroll: No; resizable: No; status: No;"); if (ret == undefined) return false; else return ret; } catch (e) { errorNotify(e); } } function passwordPrompt(pMessage) { return prompt(pMessage, null, null, null, true, true); } var origPrompt = window.prompt; window.prompt = function(pMessage, pDefault, w, h, password_sw, useNativePrompt) { if (!useNativePrompt && isNativeModalDialogBoxSupported()) { return promptBox(pMessage, pDefault, w, h, password_sw); } return origPrompt(removeHTMLTags(pMessage), removeHTMLTags(pDefault)); } function promptBox(pMessage, pDefault, w, h, password_sw) { try { var pg = "/jsps/prompt.jsp?message=" + pMessage if (password_sw != null) pg += "&password=Y"; if (pDefault != null) pg += "&default_value=" + pDefault; var obj = new Object(); if (w == null) w = 675; if (h == null) h = 135; return window.showMDialog(pg, obj,"center: yes; dialogHeight: " + h + "px; dialogWidth: " + w + "px; edge: Raised; scroll: No; resizable: No; status: No;"); } catch (e) {} } function openProcessingWindow(pMessage, max_in_milliseconds) { var m = pMessage || ""; max_in_milliseconds = max_in_milliseconds || 60000; var mother = getTopWindow(); if (!mother.Ext) { mother = this; } if (processing_dialog) { mother.closeExtJSWindow(processing_dialog); } try{ processing_dialog = mother.Ext.MessageBox.show({ msg: m, closable: true, progressText: 'Processing...', width: 400, wait: { interval: 200 } }); } catch (e) { console.error('Unable to show processing_dialog:', e); } setTimeout(function() { if (processing_dialog && processing_dialog.isVisible()) { processing_dialog.close(); } }, max_in_milliseconds); return processing_dialog; } function checkProcessingStatus() { if (getProcessingWindowStatus() == "close") { setProcessingWindowStatus(""); closeProcessingWindow(); } } function closeProcessingWindowNow() { try { if (processing_dialog) { //closeExtJSWindow(processing_dialog); processing_dialog.close(); } } catch(e) { console.log(e.message); } processingWindowStatus = null; processing_dialog = null; } function closeProcessingWindow() { try { if(processing_dialog){ processing_dialog.close(); } } catch (e) { console.log(e.message); } processing_dialog = null; } function closeProcessingImage() { try { setProccessImage(false); } catch(e) {} } function setProccessImage(sw) { if (window.top.processImage) { if (sw) { window.top.$("#processImage").css("display", "inline"); } else { window.top.$("#processImage").css("display", "none"); } } } function openProcessingWindowBACK(pMessage, max_in_milliseconds) { try { if (getProcessingWindowStatus() == "open") { processingMessage = pMessage; return; } setProcessingWindowStatus("open"); var obj = new Object(); obj.pMessage = pMessage; obj.pParent = window; var _url = "/skeva/engage/engage_common/view/web/processing2.jsp"; if (max_in_milliseconds) _url += "?max_time=" + max_in_milliseconds; return window.showMDialog(_url, obj,"center: yes; dialogHeight: 235px; dialogWidth: 400px; scroll: no; raised; resizable: no; status: no;"); } catch (e) { errorNotify(e); } } function closeProcessingWindowBACK() { setProcessingWindowStatus("close"); } function getProcessingMessage() { try { if (processingMessage != undefined && trim(processingMessage).length > 0) { var m = processingMessage; processingMessage = ""; return m; } return ""; } catch (e) { errorNotify(e); } } function getProcessingWindowStatus() { return processingWindowStatus; } function setProcessingWindowStatus(status) { processingWindowStatus = status; } function logoutSession() { try { doLogout(); } catch (e) { errorNotify(e); } } function doLogout() { try { callEngageRS(createNewContainer("logoutSession"), "handleLogout", "NONE", false); bypassUnload = true; goToLogon(); } catch (e) { errorNotify(e); } } /** * this is slightly different than doLogout in that it also sets an exception * so that the logon page can display the invalid session message */ function invalidateSession(uid, pwd) { try { var c =createNewContainer("invalidateSession"); p_uid = ""; p_pwd = ""; if (uid != undefined && pwd != undefined) { p_uid = uid; p_pwd = pwd; c.putRequestParameter("p_userid", p_uid); c.putRequestParameter("p_password", p_pwd); bypassUnload = true; } callEngageRS(c, "handleInvalidateSession", "NONE", false); goToLogon(); } catch (e) {errorNotify(e);} } function logoutHandler(c) { try {goToLogon();} catch (e) {errorNotify(e);} } function getScreenMode() { try { var pos; var start; var end; var ck = document.cookie; var v; var value; var pos = ck.indexOf("defaultScreenMode"); if (pos != -1) { v = "defaultScreenMode"; start = pos + v.length+1; end = ck.indexOf("&", start); value = ck.substring(start, end); if (value != undefined) { return value; } } } catch (e) {errorNotify(e);} return "default"; } function goToLogon() { try { loggingOut = true; var loc = ""; loc = "/"; if (getScreenMode() == "full" ) { //getTopWindow().close(); //parent.location.reload() getTopWindow().location = loc; } else getTopWindow().location = loc; } catch (e) {alert(e);errorNotify(e);} } function clearPageSnapShot() { try { var c = createNewContainer("SNAPSHOT"); c.putRequestParameter("pageKey", pageKeyName); callEngageRS(c, "clearPageSnapShot", "NONE", false); } catch (e) {errorNotify(e);} } function loadPageSnapShot() { try { var c = createNewContainer("SNAPSHOT"); c.putRequestParameter("pageKey", pageKeyName); callEngageRS(c, "getPageSnapShot", "loadPageSnapShotHandler", false); } catch (e) {errorNotify(e);} } function loadPageSnapShotHandler(c) { try { // error message will already by set if ERR_MESSAGE TAG EXISTS do { if (!c.wasError()) { var v = c.getResponse(); if (v == undefined || v.length == 0) break; var item = c.getResponseParameter("PAGEVALUE"); var xmlDoc = rsxml.XMLDocument; xmlDoc.loadXML(item); } else {alert("error");errorHandler(c);} }while(false); } catch (e) {errorNotify(e);} } /** helper method to reset all forms in a frameset */ /***************************************************/ function resetPageForms() { try { for(i=0; i < document.forms.length; i++) { document.forms[i].reset(); } } catch (e) {errorNotify(e);} } function setPageDumpTimer(val) { try { pageDumpTimer = val; //'setInterval("formElementsDump()", pageDumpTimer); } catch (e) {errorNotify(e);} } function setServletPath(val) {activeServlet = val;} function setClientServlet() {activeServlet = defaultServletPath;} function setAdminServlet() {activeServlet = defaultAdminServletPath;} function getClientServlet(){return defaultServletPath;} function getAdminServlet(){return defaultAdminServletPath;} function handleFormsSubmit(frms, c, mth, callback) { try { if (frms == undefined || frms.length == 0) return; var len = frms.length; for (var i = 0; i < len; i++) { handleFormSubmit(frms[i]); } } catch (e) {errorNotify(e);} } function handleFormSubmit(frm, c, mth, callback) { try { clearAllMessageFields(); doFormSubmitSetup(frm, c); return callEngageRS(c, mth, callback, false); } catch (e) {errorNotify(e);} } function handleFormSubmit2(frm, c, mth, o, asyn) { try { clearAllMessageFields(); doFormSubmitSetup(frm, c); return callEngageRS2(c, mth, o, null, asyn); } catch (e) {errorNotify(e);} } function handleFormDump(frm) { try { var c = createNewContainer("NONE") c.putRequestParameter("page_key", pageKeyName); doFormSubmitSetup(frm, c); callEngageRS(c, "setFormElementsDump", "NONE", false); } catch (e) {} } function handleSubmit(c, mth, callback) { try { clearAllMessageFields(); for(var i=0; i < document.forms.length; i++) { doFormSubmitSetup(document.forms[i], c); } return callEngageRS(c, mth, callback, false); } catch (e) {errorNotify(e);} } function handleSubmit2(c, mth, w) { try { clearAllMessageFields(); for(var i=0; i < w.document.forms.length; i++) { doFormSubmitSetup(w.document.forms[i], c); } return callEngageRS2(c, mth, w); } catch (e) {errorNotify(e);} } /* * note: this processes using normal form submit rules: * 1) if a
has no "name", it will not be forwarded * 2) for