//If there are more than v this v number of demo-test-value
//functions, print a drop-down box instead of individual
//buttons.
var iBUTTON_THRESHOLD = 10;
var sDDB_DIVIDER = "[__DDB_DIVIDER__]";
var bDBG_TEST_FUNC_CALLS = false;
var bTST_FUNCS_ELIM_TYPE_POSTS = false;
var bTST_FUNCS_pppp_TO_POINT = false;
var bTST_FUNCS_dddd_TO_DASH = false;
var bTST_FUNCS___TO_SPACE = false;
var bCRSH_ALRT = true;
var bCRSH_DGNSTCS = true;
var bCRSH_THROW = true;
//If this is a 'concept' page, then set this to true.
//
//In the demo testing value buttons/ddb values, the
//'_txt'/'_pwd'/... will be suppressed from displaying. It
//is *assumed* that there is a type prefix, and the last four
//characters are blindly eliminated.
//
//This also changes...
// 'neg' to '-'
// 'neg' is expected to be lowercase, and the first
// three characters. Any other instances are not
// replaced.
// 'p' to '.'
// 'p' is only expected to exist once. Only the first
// 'p' is replaced.
var bCONCEPT_DOC_PAGE = false;
//Truly global among all forms.
var sJSDIR;
var sSifCfgUrl;
var bDbgJSLoads;
var bLDD_VFPD = false;
var bLDD_CIBC = false;
var bLDD_DBG = false;
var bLDD_OD = false;
var bLDD_STASIF = false;
var bLDD_SIF_CFG = false;
var bLDD_CI = false;
var bVFPDInUrl = false;
var aVfbc = [];
var sSifCfgUrl;
var bDbgJSLoads;
var sDMOV_FUNC_PRE = "vfpdtf__";
var sURLP_VFPD = "vfpd";
var sURLP_CIBC = "load_cibc";
var sFRM_NM_VFPD = "form_vfpd__";
var bLVFCalled = false; //XCMAX
function loadVF(s_jsDirUrl, s_sifCfgUrl, b_dbgJSLoads) {
if(bLVFCalled) { //XCMAX
crsh("vf.lvf1", loadVF, "loadVF (XCMAX): This function was already called.");
} //XCMAX
bLVFCalled = true; //XCMAX
ciMissing(loadVF, "loadVF (XCMAX)", "s_jsDirUrl", s_jsDirUrl);
if(s_jsDirUrl.substring((s_jsDirUrl.length - 1), s_jsDirUrl.length) != "/") { //XCMAX
crsh("vf.lvf1", loadVF, "loadVF (XCMAX): s_jsDirUrl must end with a url slash ('/'). Currently '" + s_jsDirUrl + "'.");
} //XCMAX
sJSDIR = s_jsDirUrl;
sSifCfgUrl = s_sifCfgUrl;
bDbgJSLoads = (df(b_dbgJSLoads) && b_dbgJSLoads);
if(df(sSifCfgUrl)) {
loadJS(bLDD_STASIF, true, sJSDIR, "vf_stASIF.js");
//false: It always needs to be loaded. It's only loaded
//once per loadVF() call.
loadJS(false, true, "", sSifCfgUrl);
}
}
var bCVFLCalled = false; //XCMAX
function completeVFLoad() {
var f = completeVFLoad;
var sF_XCMAX = "completeVFLoad (XCMAX): ";
ciNotLoaded(sF_XCMAX, undefined);
if(bCVFLCalled) { //XCMAX
crsh("vf.cvfl1", f, sF_XCMAX + "This function was already called.");
bCVFLCalled = true; //XCMAX
} //XCMAX
if(aVfbc.length == 0) {//XCMAX
crsh("vf.cvfl2", f, sF_XCMAX + "Must call configVF().");
} //XCMAX
//Length is at least one
if(!df(aVfbc[0].sFrmNm) && aVfbc.length > 1) { //XCMAX
crsh("vf.cvf3", f, sF_XCMAX + "aVfbc.length is greater than one (" + aVfbc.length + "), but aVfbc[0].sFrmNm is.[undefined].");
} //XCMAX
for(var i = 0; i < aVfbc.length; i++) {
var sFnm = aVfbc[i].sFrmNm;
for(var j = (i + 1); j < aVfbc.length; j++) { //XCMAX
if(sFnm == aVfbc[j].sFrmNm) { //XCMAX
crsh("vf.cvfl4", f, sF_XCMAX + ": configVF was called twice for the form named '" + sFnm + "'. [i=" + i + ", j=" + j + "]");
} //XCMAX
} //XCMAX
if(aVfbc.length > 1 || df(aVfbc[0].sFnm)) { //XCMAX
//[undefined] is a legal form name when the length equals zero.
if(!df(sFnm)) { //XCMAX
crsh("vf.cvfl5", f, sF_XCMAX + "configVF was called multiple times, but call number " + (i + 1) + ", has a form name of [undefined]. [undefined] is a legal form name only when configVF is called a single time.");
} //XCMAX
//These tests will fail (actually or conceptually) when
//the name is undefined.
if(eval("!df(document." + sFnm + ")")) { //XCMAX
crsh("vf.cvfl6", f, sF_XCMAX + ": configVF was called for a form named '" + sFnm + "', but no form having that name exists.");
} //XCMAX
if(sFnm.substring(0, sFRM_NM_VFPD.length) == sFRM_NM_VFPD) {//XCMAX
crsh("vf.cvfl7", f, sF_XCMAX + "configVF was called for a form named '" + sFnm + "'. No form name may start '" + sFRM_NM_VFPD + "'.");
} //XCMAX
} //XCMAX
}
commitVFPDValues();
}
function configVF(sb_cibcOnOff, i_dfltDbgPerScr, s_formName) {
if(!bLVFCalled) { //XCMAX
crsh("vf.cvf1", configVF, "configVF (XCMAX): Must call loadVF() first.");
} //XCMAX
//Add a new element to the end of aVfbc.
var vfbc = new VFBCfg(sb_cibcOnOff, i_dfltDbgPerScr, s_formName);
aVfbc[aVfbc.length] = vfbc;
bVFPDInUrl = (window.location.search.indexOf(sURLP_VFPD) != -1);
if(i_dfltDbgPerScr != -1) {
//Debugging is definitely needed when debugging is not -1.
loadDBG();
}
loadCIBC(vfbc.isCIBCOn());
}
function loadObjDgnstcs() {
loadJS(bLDD_OD, true, sJSDIR, "vf_obj_dgnstcs.js");
}
function loadCrashIf() {
loadJS(bLDD_CI, true, sJSDIR, "crash_if.js");
}
function loadCIBC(b_doLoad) {
//cibc is loaded only once per *page*, not per form.
if(b_doLoad || window.location.search.indexOf(sURLP_CIBC) != -1) {
loadJS(bLDD_CIBC, true, sJSDIR, "vf_cibVFCfg.js");
loadObjDgnstcs();
loadCrashIf();
}
}
function configVFPD(sb_on, sb_cibcOnOff, sb_onLink, sb_offLink, sb_resetLink, sb_successDDB, sb_cibcSection, sb_cibcCrshDdb, ai_dbgPerScrDDB, as_tstVFuncPosts, s_formName) {
var vfbc = gtVfbc(configVFPD, "configVFPD", s_formName);
vfbc.stVfpdc(sb_on, sb_cibcOnOff, sb_onLink, sb_offLink, sb_resetLink, sb_successDDB, sb_cibcSection, sb_cibcCrshDdb, ai_dbgPerScrDDB, as_tstVFuncPosts, s_formName);
loadVFPD(vfbc.isVfpdOn());
if(vfbc.isVfpdOn() && vfbc.bDCIBCOnOff) {
loadCIBC(true);
}
}
function gtSB(s_callingFunc, s_sbName, string_boolean, s_true, s_false) {
ciMissing(gtSB, s_callingFunc, s_sbName, string_boolean); //XCMAX
if(string_boolean == s_true) {
return true;
} else if(string_boolean == s_false) {
return false;
}
crsh("vf.gsb1", gtSB, s_callingFunc + " (XCMAX): The string_boolean parameter " + s_sbName + " must equal either s_true ([" + s_true + "]), or s_false ([" + s_false + "]).");
}
function getFormErrorMsgs(f_orm, s_userErrPre, b_crshAlert, b_crshDgnstcs, b_crshThrow) {
var sF_XCMAX = "getFormErrorMsgs (XCMAX)";
var f = getFormErrorMsgs;
//If vfpd is active, and CRSH is selected, then
//that needs to be refreshed. It's successfully
//updated on page load, but not otherwise.
commitVFPDValues();
if(getFormErrorMsgs.arguments.length > 2) { //XCMAX
crsh("vf.gfem1", f, sF_XCMAX + ": " + getFormErrorMsgs.arguments.length + " parameters have been provided to this function, but only two are expected.");
} //XCMAX
ciMissing(getFormErrorMsgs, sF_XCMAX, "f_orm", f_orm);
ciMissing(getFormErrorMsgs, sF_XCMAX, "s_userErrPre", s_userErrPre);
if(!df(f_orm.name) || f_orm.name == "") {
crsh("vf.gfem1", f, sF_XCMAX + ": f_orm.name is undefined or zero characters in length.");
}
if(aVfbc.length == 0) {
crsh("vf.gfem2", f, sF_XCMAX + ": Must call configVF() first.");
}
var vfbc = gtVfbc(getFormErrorMsgs, "getFormErrorMsgs", f_orm.name);
//Set utility.crsh() behavior
bCRSH_ALRT = df(b_crshAlert)? b_crshAlert : vfbc.bCrshAlrt;
bCRSH_DGNSTCS = df(b_crshDgnstcs)? b_crshDgnstcs : vfbc.bCrshDgnstcs;
bCRSH_THROW = df(b_crshThrow)? b_crshThrow : vfbc.bCrshThrow;
ciNotLoaded(sF_XCMAX, vfbc);
//Get the array of FLStats for this form.
var aFLS4Frm = gtAFLSvf(vfbc.sFrmNm);
//Should configuration be analyzed, and then should we crash
//if there's a problem with it?
var bCIBC = false;
if(!df(aFLS4Frm)) {
//The form has not yet been analyzed.
//We need to re-analyze the form.
bCIBC = true;
//fl_stats.gtAFLS()
var aFLS = gtAFLS(f_orm);
//We've made it this far, so the form's vf configuration
//is good. If it's not good, we would have not made it
//past the previous line.
aFLS4Frm = aFLS;
//Now the form's statistics exist in the global aFLStats.
}
if(bLDD_DBG) {
//vf_cib_cfg.js has been imported, so this function has
//been defined. The only way this is defined is when
//i_dps has been set, at some point to something other
//than -1. Even if it is -1 now, it's so fast it's not
//worth *not* calling this.
dbgVF(aFLS4Frm, vfbc.iDDPS, false);
}
//We need to under normal circumstances &&
//The code is available &&
//They want to
if(bLDD_CIBC && bCIBC && vfbc.isCIBCOn()) {
cibVFCfg(aFLS4Frm);
}
//fl_stats.gtAFLSUsrErrs()
return (gtUsrErrCnt(aFLS4Frm) > 0)
? gtAFLSUsrErrs(aFLS4Frm, "", s_userErrPre, "")
: "";
}
function loadVFPD(b_on) {
loadJS(bLDD_VFPD, b_on, sJSDIR, "vf_perm_diagnostics.js");
}
function loadDBG() {
loadJS(bLDD_DBG, true, sJSDIR, "vf_dbgVF.js");
loadObjDgnstcs();
loadCrashIf();
}
function loadJS(b_alreadyLoaded, b_doLoad, s_dir, s_jsFile) {
if(b_alreadyLoaded || !b_doLoad) {
//It was already loaded, or we don't want to load it.
return;
}
//We want to load it, and it's not yet been loaded.
var sLoad = '[vfpd on]
');
}
}
}
function commitVFPDValues() {
if(bLDD_VFPD) {
updateVFPDCRaw();
}
}
function stAFLSvf(a_flStats, s_formName) {
var vfbc = gtVfbc(stAFLSvf, "stAFLSvf", s_formName);
vfbc.aFLStats = a_flStats;
}
function gtAFLSvf(s_formName) {
return gtVfbc(gtAFLSvf, "gtAFLSvf", s_formName).aFLStats;
}
function gtDUrl(b_vfpdP, b_cibcP, b_resetLink) {
var url = window.location;
var sq = url.search;
sq = addDelUrlP(sq, b_vfpdP, sURLP_VFPD);
sq = addDelUrlP(sq, b_cibcP, sURLP_CIBC);
if(b_resetLink) {
//Forces a reload. When the link url is exactly the same as
//the current url, the link does nothing.
//What's the previous random link?
var sRND_PRE = "vfrndp_";
var iPOST_LEN = 4;
var iIdxPrevRnd = sq.indexOf(sRND_PRE);
if(iIdxPrevRnd != -1) {
sq = addDelUrlP(sq, false, sq.substring(iIdxPrevRnd, iIdxPrevRnd + sRND_PRE.length + iPOST_LEN));
}
//And now add a new random link.
var sRnd = ((new Date()).getTime() + "");
sRnd = sRnd.substring((sRnd.length - iPOST_LEN), sRnd.length);
sq = addDelUrlP(sq, true, sRND_PRE + sRnd);
}
//MUST SPLIT "//" IN THE URL, OR IT AND THE REST OF THE LINE
//WILL BE OBLITERATED AS A COMMENT.
return url.protocol + "/" + "/" + url.host + url.pathname + sq;
}
function doSubmitOnSuccess(f_orm) {
ciMissing(doSubmitOnSuccess, "doSubmitOnSuccess (XCMAX)", "f_orm", f_orm);
return gtVfbc(doSubmitOnSuccess, "doSubmitOnSuccess", f_orm.name).bSbmtOnSuccess;
}
function VFBCfg(sb_cibcOnOff, i_dfltDbgPerScr, s_formName) {
var sF = "VFBCfg";
var sF_XCMAX = sF + " (XCMAX)";
ciMissing(VFBCfg, sF_XCMAX, "sb_cibcOnOff", sb_cibcOnOff);
ciMissing(VFBCfg, sF_XCMAX, "i_dfltDbgPerScr", i_dfltDbgPerScr);
this.bCIBCOnOff = gtSB(sF, "sb_cibcOnOff", sb_cibcOnOff, "CIBC_ON", "CIBC_OFF");;
this.iDfltDPS = i_dfltDbgPerScr;
//May be undefined, meaning 'form_vfpd__undefined'!!!
//
this.sFrmNm = s_formName;
//VFPD
this.stVfpdc = pb_stVfpdc;
//Config
this.bDOnDflt;
this.bDCIBCOnOff = false;
this.bOnLnk = false;
this.bOffLnk = false;
this.bResetLnk = false;
this.bSuccessDDB = false;
this.bCIBCSctn = false;
this.bCIBCCrshDdb = false;
this.asTstngVFuncPost;
this.aiDPSddb;
//State
this.bDOn;
this.bCIBCDoCrsh;
this.bSbmtOnSuccess;
this.iDDPS;
this.bCrshAlrt;
this.bCrshDgnstcs;
this.bCrshThrow;
this.bOrigCrshAlrt = bCRSH_ALRT;
this.bOrigCrshDgnstcs = bCRSH_DGNSTCS;
this.bOrigCrshThrow = bCRSH_THROW;
this.turnDOnOff = pb_turnDOnOff;
this.isCIBCOn = pb_isCIBCOn;
this.isVfpdOn = pb_isVfpdOn;
this.turnDOnOff(false);
}
function pb_turnDOnOff(b_onOff) {
this.bCIBCDoCrsh = false;
//If on: Don't submit (by default)
//If off: Do submit.
this.bSbmtOnSuccess = !b_onOff;
this.iDDPS = this.iDfltDPS;
this.bDOn = b_onOff;
if(b_onOff && this.bCIBCCrshDdb) {
this.bCrshAlrt = true;
this.bCrshDgnstcs = false;
this.bCrshThrow = false;
} else {
this.bCrshAlrt = this.bOrigCrshAlrt;
this.bCrshDgnstcs = this.bOrigCrshDgnstcs;
this.bCrshThrow = this.bOrigCrshThrow;
}
}
function pb_isCIBCOn() {
var b = ((!this.bDOn && this.bCIBCOnOff) ||
(this.bDOn && this.bCIBCSctn && this.bCIBCDoCrsh));
if(!df(b)) {
crsh("vf.vfbc.icibco1", this.isCIBCOn, "isCIBCOn (XCMAX sanity check): b is undefined?! [this.bDOn=" + this.bDOn + ", this.bCIBCOnOff=" + this.bCIBCOnOff + ", this.bCIBCDoCrsh=" + this.bCIBCDoCrsh + "]");
}
return b;
}
function pb_isVfpdOn() {
return (df(this.bDOnDflt) && this.bDOnDflt != bVFPDInUrl);
}
function pb_stVfpdc(sb_on, sb_cibcOnOff, sb_onLink, sb_offLink, sb_resetLink, sb_successDDB, sb_cibcSection, sb_cibcCrshDdb, ai_dbgPerScrDDB, as_tstVFuncPosts, s_formName) {
var sF = "configVFPD";
if(df(this.bDOnDflt)) { //XCMAX
crsh("vfbc.svfpdc1", this.stVfpdc, sF + " (XCMAX): Already called " + sF + "() for s_formName ('" + s_formName + "').");
} //XCMAX
this.aFLStats;
this.bDOnDflt = gtSB(sF, "sb_on", sb_on, "ON", "OFF");
this.bDCIBCOnOff = gtSB(sF, "sb_cibcOnOff", sb_cibcOnOff, "CIBC_ON", "CIBC_OFF");
this.bOnLnk = gtSB(sF, "sb_onLink", sb_onLink, "ON_LNK", "NO_ON_LNK");
this.bOffLnk = gtSB(sF, "sb_offLink", sb_offLink, "OFF_LNK", "NO_OFF_LNK");
this.bResetLnk = gtSB(sF, "sb_resetLink", sb_resetLink, "RESET_LNK", "NO_RESET_LNK");
this.bSuccessDDB = gtSB(sF, "sb_successDDB", sb_successDDB, "SUCCESS_DDB", "NO_SUCCESS_DDB");
this.bCIBCSctn = gtSB(sF, "sb_cibcSection", sb_cibcSection, "CIBC_SCTN", "NO_CIBC_SCTN");
this.bCIBCCrshDdb = gtSB(sF, "sb_cibcCrshDdb", sb_cibcCrshDdb, "CIBC_CRSH_DDB", "NO_CIBC_CRSH_DDB");
if(df(as_tstVFuncPosts)) { //XCMAX
cibRA(sF + " (XCMAX)", "as_tstVFuncPosts", as_tstVFuncPosts);
for(var i = 0; i < as_tstVFuncPosts.length; i++) { //XCMAX
for(var j = (i + 1); j < as_tstVFuncPosts.length; j++) { //XCMAX
if(as_tstVFuncPosts[i] == as_tstVFuncPosts[j] && //XCMAX
as_tstVFuncPosts[i] != sDDB_DIVIDER && //XCMAX
as_tstVFuncPosts[j] != sDDB_DIVIDER) { //XCMAX
crsh("vfbc.svfpdc2", this.stVfpdc, sF + " (XCMAX): as_tstVFuncPosts[" + i + "] and as_tstVFuncPosts[" + j + "] are the same: '" + as_tstVFuncPosts[i] + "'. Form name='" + this.sFrmNm + "'");
} //XCMAX
} //XCMAX
} //XCMAX
} //XCMAX
if(df(ai_dbgPerScrDDB)) { //XCMAX
cibRA(sF, "ai_dbgPerScrDDB", ai_dbgPerScrDDB); //XCMAX
for(var i = 0; i < ai_dbgPerScrDDB.length; i++) { //XCMAX
if(!df(ai_dbgPerScrDDB) || !isNum(ai_dbgPerScrDDB[i], "false")) { //XCMAX
crsh("vfbc.svfpdc2", this.stVfpdc, sF_XCMAX + ": ai_dbgPerScrDDB[" + i + "] (" + ai_dbgPerScrDDB[i] + ") must be defined, and an integer.");
} //XCMAX
} //XCMAX
} //XCMAX
this.asTstngVFuncPost = as_tstVFuncPosts;
this.aiDPSddb = ai_dbgPerScrDDB;
//May be undefined, meaning 'form_vfpd__undefined'!!!
//
//Must have this same variable in VFBCfg
this.sFrmNm = s_formName;
this.turnDOnOff(this.bDOnDflt);
}
function gtVfbc(f_calling, s_callingFunc, s_formName) {
if(!df(aVfbc[0].sFrmNm)) {
//A form "named" undefined may only be when there's a
//single call to configVF per page. This is verified in
//completeVFLoad()
return aVfbc[0];
}
//There's at least one other element.
var sFrmNmLst = " Form names: ['";
for(var i = 0; i < aVfbc.length; i++) {
if(i > 0) {
sFrmNmLst += "', '";
}
sFrmNmLst += aVfbc[i].sFrmNm;
if(s_formName == aVfbc[i].sFrmNm) {
return aVfbc[i];
}
}
sFrmNmLst += "']";
crsh("vf.gc1", f_calling, s_callingFunc + " (XCMAX): No VFBCfg exists for a form named s_formName ('" + s_formName + "'). Must call loadVF(), configVF() and/or configVFPD() before calling this function. [aVfbc.length=" + aVfbc.length + "]" + sFrmNmLst);
}
function pb_setAFLS(a_flStats) {
}
function wrt(s_tring) {
document.writeln(s_tring);
return s_tring + '\n';
}
function wrtnl(s_tring) {
document.write(s_tring);
return s_tring;
}
function df(v_ariable) {
return (v_ariable != undefined);
}
function addDelUrlP(s_urlq, b_pNeeded, s_urlp) {
if(b_pNeeded == (s_urlq.indexOf(s_urlp) != -1)) {
//Needed and already there...OR...
//Not needed and already not there.
//Done!
return s_urlq;
}
//They're opposite values.
if(b_pNeeded) {
//Needed, but not in url.
if(s_urlq.length > 0) {
//Preserve existing url params
return s_urlq + "&" + s_urlp;
} else {
return "?" + s_urlp;
}
} else {
//Not needed, but in url.
var iIdx = s_urlq.indexOf(s_urlp);
var iLen = s_urlp.length;
//-1 is okay, because if length > 0, then it's at least ?vfpd
if(s_urlq.substring((iIdx - 1), iIdx) == "&") {
iIdx--;
iLen++;
}
var s = s_urlq.substring(0, iIdx) + s_urlq.substring((iIdx + iLen), s_urlq.length);
if(s.substring(0, 2) == "?&") {
s = "?" + s.substring(2, s.length);
}
return (s == "?")
? ""
: s;
}
}
var sCNSTR_XCMAX = "SIFmt.constructor (XCMAX)";
function SIFmt(s_msgTxtPostfix, si_rqdMin, si_rqdMax, si_altMin, si_altMax) {
ciMissing(SIFmt, sCNSTR_XCMAX, "s_msgTxtPostfix", s_msgTxtPostfix);
ciMissing(SIFmt, sCNSTR_XCMAX, "si_rqdMin", si_rqdMin);
ciMissing(SIFmt, sCNSTR_XCMAX, "si_rqdMax", si_rqdMax);
if(s_msgTxtPostfix == 'Dec' || //XCMAX
s_msgTxtPostfix == 'Email' || //XCMAX
s_msgTxtPostfix == 'Int') { //XCMAX
crsh("snf.cnstr1", SIFmt, sCNSTR_XCMAX + ": s_msgTxtPostfix (currently '" + s_msgTxtPostfix + "') must not equal 'Dec', 'Email', or 'Int'.");
} //XCMAX
//Ascending order: Numbers, then _, then letters
var acLtrsDgtsUndrscr = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '_', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0']; //XCMAX
for(var i = 0; i < (s_msgTxtPostfix.length - 1); i++) { //XCMAX
var c = s_msgTxtPostfix.substring(i, (i + 1)).toLowerCase(); //XCMAX
if(isInAscRA(c, acLtrsDgtsUndrscr)) { //XCMAX
continue; //XCMAX
} else { //XCMAX
crsh("snf.cnstr2", SIFmt, sCNSTR_XCMAX + ": s_msgTxtPostfix (currently '" + s_msgTxtPostfix + "') may not contain anything but letters, digits, and underscores. Character at index " + i + " ('" + c + "') is illegal.");
} //XCMAX
} //XCMAX
if(df(si_altMin) ^ df(si_altMax)) { //XCMAX
//Exactly one is defined, but not both.
crsh("snf.cnstr2", SIFmt, sCNSTR_XCMAX + ": si_altMin ('" + si_altMin + "') and si_altMax ('" + si_altMax + "') must both be either undefined or defined.");
} //XCMAX
//The alternate bounds are either both provided, or not.
cibLnRng(si_rqdMin, si_rqdMax, "si_rqdMin", "si_rqdMax", ""); //XCMAX
cibLnRng(si_altMin, si_altMax, "si_altMin", "si_altMax", "When provided, ");//XCMAX
//Internal variables
this.sMTPost = s_msgTxtPostfix;
this.siRqMn = si_rqdMin;
this.siRqMx = si_rqdMax;
this.siLtMn = si_altMin;
this.siLtMx = si_altMax;
this.gtFmtV = pb_gtFmtV;
this.isFmtEq = pb_isFmtEq;
this.type = "SIFmt";
}
function pb_isFmtEq(si_fmt) {
ciMissing(this.isFmtEq, "isFmtEq (XCMAX)", "si_fmt", si_fmt);
return (si_fmt.siRqMn == this.siRqMn &&
si_fmt.siRqMx == this.siRqMx &&
si_fmt.siLtMn == this.siLtMn &&
si_fmt.siLtMx == this.siLtMx);
}
function gtDgts(s_tring) {
ciMissing(gtDgts, "gtDgts (XCMAX)", "s_tring", s_tring);
if(/^\D$/.test(s_tring)) {
//There are no numbers at all.
return "";
}
//There is at least one number.
var asNumberParts = s_tring.split(/\D/);
var sNumber = asNumberParts[0];
for(var i = 1; i < asNumberParts.length; i++) {
sNumber += asNumberParts[i];
}
return sNumber;
}
function pb_gtFmtV(s_value) {
ciMissing(this.gtFmtV, "gtSIFromFormat (XCMAX)", "s_value", s_value);
//util_string.gtDgts()
var sDigits = gtDgts(s_value);
var siRqdPart;
var siAltPart;
var iStrippedLen = sDigits.length;
//We're only comparing against the "minimum" bound, because
//we know that the minimum and maximum formats are the same
//length.
if(iStrippedLen < this.siRqMn.length) {
//The value is shorter than it is required to be.
return undefined;
} //ELSE: The value is at least as long as required..
if(iStrippedLen > this.siRqMn.length) {
//The length of the value is greater than required, but
//that's okay if there's an alternate format.
if(!df(this.siLtMn)) {
//No alternate format. The length is illegal.
return undefined;
} //ELSE: There is an alternate format...
if(iStrippedLen !=
(this.siRqMn.length + this.siLtMn.length)) {
//...but the length of the value is not equal to either
//the required or required-plus-alternate formats length.
return undefined;
} //ELSE: ...and it is equal to the required-plus-
// alternate length.
siRqdPart = sDigits.substring(0, this.siRqMn.length);
siAltPart = sDigits.substring(this.siRqMn.length, iStrippedLen);
} else { //The value's length is exactly the required
//length.
siRqdPart = sDigits;
siAltPart = undefined;
}
if(!isInFrmtRng(siRqdPart, this.siRqMn, this.siRqMx)) {
//The required part of the value is out of range.
return undefined;
}
if(df(siAltPart) &&
!isInFrmtRng(siAltPart, this.siLtMn, this.siLtMx)) {
//The alternate part has been provided, and that part of
//the value is out of range.
return undefined;
}
//The format is totaly valid for this SIFmt.
return sDigits;
}
function isInFrmtRng(si_valuePart, si_frmtPartMin, si_frmtPartMax) {
var iValuePart = parseInt(si_valuePart, 10);
var iFPartMin = parseInt(si_frmtPartMin, 10);
var iFPartMax = parseInt(si_frmtPartMax, 10);
return (iValuePart >= iFPartMin &&
iValuePart <= iFPartMax);
}
function FLStats(frm_frmLmnt, fls_frm, a_prevFLS) {
var ffl = frm_frmLmnt;
var f = FLStats;
var sFLSC_XCMAX = "FLStats.constructor (XCMAX): ";
//Parameter checking...START
//Note that "sXCMAX" is part of these variables' names.
ciMissing(FLStats, sFLSC_XCMAX, "frm_frmLmnt", ffl);
//Get the type of frm_frmLmnt...START
//(This section is not a sanity check, but must be right here.)
var iFflTypeIdx = gtVRAIdx("fls.c0", ffl.type, asOBJ_TYPES);
if(iFflTypeIdx == -1 &&
df(ffl.elements) &&
df(ffl.elements.length) &&
df(ffl.reset)) {
//Forms have no "type" attribute, but they all have an
//elements array, and a reset function. Hey, it's the
//least I could do. :' )
//asOBJ_TYPES[0]="form"
iFflTypeIdx = 0;
}
//iFflTypeIdx now equals...
//...-1 when it is a form element, but one we don't
// care about.
//...0 when it's the form (fls_frm must be undefined)
//...[Some other asOBJ_TYPES array index] when it is a
// form element and we do care about it.
//Get the type of frm_frmLmnt...END
if(df(fls_frm)) { //XCMAX
if(iFflTypeIdx == 0) { //XCMAX
crsh("fls.c1", f, sFLSC_XCMAX + "fls_frm is provided, but frm_frmLmnt is also a 'form' object.");
} //XCMAX
ciNotFLStats(sFLSC_XCMAX, "fls_frm", fls_frm);
if(fls_frm.sType != "form") {//XCMAX
crsh("fls.c2", f, sFLSC_XCMAX + "fls_frm, when provided, must have an 'sType' equal to 'form'. Currently, fls_frm.sType='" + fls_frm.sType + "'.");
} //XCMAX
//ELSE: fls_frm is undefined
} else { //XCMAX
if(df(a_prevFLS)) { //XCMAX
crsh("fls.c3", f, sFLSC_XCMAX + "When fls_frm is not provided, a_prevFLS must also be undefined. Currently, a_prevFLS=['" + a_prevFLS.join("', '") + "'].");
} //XCMAX
if(iFflTypeIdx != 0) { //XCMAX
crsh("fls.c4", f, sFLSC_XCMAX + "When fls_frm is not provided, frm_frmLmnt must be a form object. Currently, frm_frmLmnt.type=" + ffl.type + ", frm_frmLmnt.toString()=[" + ffl.toString() + "].");
} //XCMAX
} //XCMAX
if(df(a_prevFLS)) { //XCMAX
cibRA(sFLSC_XCMAX, "a_prevFLS", a_prevFLS);
} //XCMAX
//Parameter checking...END
//Everything seems good now...
//Variables and functions...START
//Basic info
this.sNm;
this.sType;
this.obj;
this.sAftrFrmNm;
this.sAftrAttrNm;
this.iTotOpts;
this.flsFrm; //A pointer to the form's FLStats
this.sUsrErr;
this.bUseThisFLS = false;
this.type = "FLStats";
this.useThisFLS = pb_useThisFLS;
this.gtCd4Attr = pb_gtCd4Attr;
this.gtCdAttrNm = pb_gtCdAttrNm;
this.gtCdFLSNm = pb_gtCdFLSNm;
this.gtAttrVRaw = pb_gtAttrVRaw;
this.gtEvlCdLmntAttrNm = pb_gtEvlCdLmntAttrNm;
this.gtEvlCdObjNm = pb_gtEvlCdObjNm;
this.gtEvalCode = pv_gtEvalCode;
this.isAttrAssc2Lmnt = pb_isAttrAssc2Lmnt;
this.gtAttrV = pb_gtAttrV;
this.isLmntVal1OrMore = pb_isLmntVal1OrMore;
this.gtLmntValSnglr = pb_gtLmntValSnglr;
this.gtLmntOptsTotal = pb_gtLmntOptsTotal;
this.gtLmntOptsChosen = pb_gtLmntOptsChosen;
this.ciFrm1OrMore = pv_ciFrm1OrMore; //XCMAX
this.gtFLS4Frm = pv_gtFLS4Frm;
this.gtLmntStats = pv_gtLmntStats;
this.unassociateFalseBS = pv_unassociateFalseBS;
//Variables and functions...END
if(df(fls_frm)) {
//This is a form element, not the form itself. All form
//elements have a pointer to the FLStats for the form.
this.flsFrm = fls_frm;
}
//validate_form.gtStrIdx() and .asOBJ_TYPES
if(iFflTypeIdx == -1) {
//This is a form element (as best we can determine above),
//but it's a type we don't care about. Perhaps it's a
//submit or reset or button or hidden...
this.bUseThisFLS = false;
//ELSE: We care about this type of element.
} else if(!df(fls_frm)) {
//This is the form itself.
this.gtFLS4Frm(ffl);
this.bUseThisFLS = true;
} else {
//This is an element in the form
this.bUseThisFLS = this.gtLmntStats(ffl, a_prevFLS);
}
if(!this.bUseThisFLS) {
//If you don't return now, the below sanity checks and
//unassociateFalseBS() calls will crash.
return;
}
//Must be after this.bUseThisFLS is known to be true.
if(!df(ffl.name) || //XCMAX
ffl.name == "") { //XCMAX
crsh("fls.c5", f, sFLSC_XCMAX + "frm_frmLmnt.name ([" + ffl.name + "]) must be defined, at least one character in length, and unique among all forms in this web page.");
} //XCMAX
this.sNm = ffl.name;
if(gtVRAIdx("fls.c6", this.sType, asOBJ_TYPES) == -1) {//XCMAX
crsh("fls.c7", f, sFLSC_XCMAX + "this.sType ('" + this.sType + "') is not one of these valid types: '" + asOBJ_TYPES.join("', '") + "'.");
}//XCMAX
if(df(this.iTotOpts) && //XCMAX
this.iTotOpts < 2) { //XCMAX
crsh("fls.c1", f, sFLSC_XCMAX + " (this.sNm='" + this.sNm + "'): This element is a multiple-value element, but there are less than two options?! One checkbox checkbox sets should be considered singular.\n\n" + sXCMAX);
} //XCMAX
//Regarding all boolean string attributes that happen to
//both undefined and equal to "false": Undefine them
//entirely. A boolean sting attribute equal to "false" is
//one that might as well not be associated at all. This
//makes the actual value consistent with the
//documentation, that boolean strings are only recognized
//when equal to "true" (assuming a legal boolean string
//value).
//validate_form.asVF_ATTRS
//asVF_ATTRS[7]="bsNoBadSubStrs"
this.unassociateFalseBS(7);
//asVF_ATTRS[10]="bsGlobalTrimSpaces"
this.unassociateFalseBS(10);
//asVF_ATTRS[11]="bsTrimSpaces"
this.unassociateFalseBS(11);
//asVF_ATTRS[12]="bsDontTrimSpaces"
this.unassociateFalseBS(12);
}
function gtAFLSUsrErrs(a_flStats, s_header, s_linePre, s_footer) {
var sF_XCMAX = "gtAFLSUsrErrs (XCMAX)";
cibAFLS(sF_XCMAX, "a_flStats", a_flStats);
ciMissing(gtAFLSUsrErrs, sF_XCMAX, "s_header", s_header);
ciMissing(gtAFLSUsrErrs, sF_XCMAX, "s_linePre", s_linePre);
ciMissing(gtAFLSUsrErrs, sF_XCMAX, "s_footer", s_footer);
var sErrors = "";
for(var i = 0; i < a_flStats.length; i++) {
if(df(a_flStats[i].sUsrErr)) {
sErrors += s_linePre + a_flStats[i].sUsrErr;
if(i < (a_flStats.length - 1)) {
sErrors += "\n";
}
}
}
if(sErrors == "") { //XCMAX
crsh("os.guefaos1", gtAFLSUsrErrs, sF_XCMAX + "No element in a_flStats has a defined value for sUsrErr.");
} //XCMAX
return s_header + sErrors + s_footer;
}
function gtAFLS(f_orm) {
ciMissing(gtAFLS, "gtAFLS (XCMAX)", "f_orm", f_orm);
var aFLStats = new Array(1);
aFLStats[0] = new FLStats(f_orm);
//...and then each element within.
for(var i = 0; i < f_orm.elements.length; i++) {
//Passing in aFLStats is how we keep track of array
//elements (chk/rdo/slm) as a whole, rather than each
//array element in it.
var fls = new FLStats(f_orm[i], aFLStats[0], aFLStats);
if(fls.useThisFLS()) {
aFLStats[aFLStats.length] = fls;
}
}
return aFLStats;
}
function pb_useThisFLS() {
ciMissing(this.useThisFLS, "useThisFLS (XCMAX) [This function may only be called once per object, after which time this.bUseThisFLS is undefined.]", "this.bUseThisFLS", this.bUseThisFLS);
var b = this.bUseThisFLS;
this.bUseThisFLS = undefined;
return b;
}
function pb_gtCd4Attr(s_attrNm) {
//util_string.gtCd4V()
return this.gtCdAttrNm(s_attrNm) + " = " + gtCd4V(this.gtAttrV(s_attrNm)) + ";\n";
}
function pb_gtCdAttrNm(s_attrNm) {
ciMissing(this.gtCdAttrNm, "gtCdAttrNm (XCMAX)", "s_attrNm", s_attrNm);
if(this.sType == "form") {
return this.sNm + "." + s_attrNm;
} else {
return this.flsFrm.sNm + this.sAftrFrmNm + this.sNm + "." + s_attrNm + this.sAftrAttrNm;
}
}
function pb_gtCdFLSNm() {
if(this.sType == "form") {
return this.sNm;
} else {
return this.flsFrm.sNm + this.sAftrFrmNm + this.sNm + this.sAftrAttrNm;
}
}
function pb_gtAttrVRaw(s_attrNm) {
return eval(this.gtEvlCdLmntAttrNm(s_attrNm));
}
function pb_isAttrAssc2Lmnt(s_attrNm) {
return df(this.gtAttrVRaw(s_attrNm));
}
var asSUB_RNG_ATTRS = ['dDecMin', 'dDecMax', 'iIntMin', 'iIntMax', 'iMinLength', 'iMaxLength', 'maxLength', 'iMCMin', 'iMCMax']; //XCMAX
function pb_gtAttrV(s_attrNm) {
//validate_form.asVF_ATTRS and gtVRAIdx()
if(gtVRAIdx("gtAttrV", s_attrNm, asVF_ATTRS) == -1 &&//XCMAX
gtVRAIdx("gtAttrV", s_attrNm, asSUB_RNG_ATTRS) == -1) {//XCMAX
crsh("fls.gav1", this.gtAttrV, "gtAttrV (XCMAX): s_attrNm ('" + s_attrNm + "') is not a legal attribute. Must exist in either validate_form.asVF_ATTRS or fl_stats.asSUB_RNG_ATTRS.\n\n asVF_ATTRS=\n['" + asVF_ATTRS.join("', '") + "'])\n\nasSUB_RNG_ATTRS=\n(['" + asSUB_RNG_ATTRS.join("', '") + "'])");
} //XCMAX
if(!this.isAttrAssc2Lmnt(s_attrNm)) { //XCMAX
crsh("fls.gav2", this.gtAttrV, "gtAttrV (XCMAX): isAttrAssc2Lmnt(s_attrNm) equals false. s_attrNm='" + s_attrNm + "', this.sNm='" + this.sNm + "', this.sType='" + this.sType + "'.");
} //XCMAX
return this.gtAttrVRaw(s_attrNm);
}
function pb_isLmntVal1OrMore() {
return (!df(this.iTotOpts));
}
function pb_gtLmntValSnglr() {
this.ciFrm1OrMore("gtLmntValSnglr", false);//XCMAX
//This element can have only one value, and is one of the
//following types:
// - text
// - textarea
// - radio
// - select-one
// - checkbox (with one element only)
var vValSnglr;
if(this.sType == "select-one" &&
this.obj.selectedIndex != -1) {
vValSnglr = this.obj.options[this.obj.selectedIndex].value;
} else if(this.sType == "radio") {
var rdo = eval(this.gtEvlCdObjNm());
for(var i = 0; i < rdo.length; i++) {
if(rdo[i].checked) {
vValSnglr = rdo[i].value;
break;
}
}
} else if(this.sType == "checkbox") {
//This is the only element in this checkbox set.
if(this.checked) {
vValSnglr = this.obj.value;
}
} else {
vValSnglr = this.obj.value;
}
return (vValSnglr == "")
? undefined
: vValSnglr;
}
function pb_gtLmntOptsTotal() {
this.ciFrm1OrMore("gtLmntOptsTotal", true);//XCMAX
return this.iTotOpts;
}
function pb_gtLmntOptsChosen() {
this.ciFrm1OrMore("gtLmntOptsChosen", true);//XCMAX
var iOptsChosen = 0;
if(this.sType == "checkbox" &&
this.flsFrm.obj.elements[this.sNm].length > 1) {
//Definitely more than one checkbox element in this
//checkbox set. Checkbox sets with only one element in it
//are single-valued.
for(var i = 0; i < this.iTotOpts; i++) {
if(this.flsFrm.obj.elements[this.sNm][i].checked) {
iOptsChosen++;
}
}
} else if(this.sType == "select-multiple") {
for(var i = 0; i < this.iTotOpts; i++) {
if(this.obj.options[i].selected) {
iOptsChosen++;
}
}
}
return iOptsChosen;
}
function pv_ciFrm1OrMore(s_callingFunc, b_1OrMore) {//XCMAX
if(this.sType == "form" || //XCMAX
this.isLmntVal1OrMore() == b_1OrMore) { //XCMAX
crsh("fls.cif1om", ciFrm1OrMore, s_callingFunc + " (XCMAX) ('" + this.sNm + "'): sType may not equal 'form', and/or b_1OrMore=" + b_1OrMore + " must equal isLmntVal1OrMore() (" + isLmntVal1OrMore() + ").");
} //XCMAX
} //XCMAX
function pv_gtFLS4Frm(f_orm) {
this.obj = f_orm;
this.sType = "form";
this.sAftrFrmNm = undefined;
this.sAftrAttrNm = undefined;
this.iTotOpts = undefined;
//This enforces the uniqueness restriction noted in the
//frm_frmLmnt parameter documentation of the FLStats
//constructor.
var bNameFound = false;
for(var i = 0; i < document.forms.length; i++) {
if(!bNameFound) {
if(document.forms[i].name == f_orm.name) {
//Found the first form having this form's name.
bNameFound = true;
}
//Still have yet to find a form having this form's
//name.
} else if(document.forms[i].name == f_orm.name) {//XCMAX
//A form with this name was already found. It is, but
//shouldn't be found again.
crsh("fls.gosff", this.gtFLS4Frm, "FLStats.constructor (XCMAX): The name of this form is '" + f_orm.name + "', but at least one other form on this page has that same name.");
}
}
}
function pv_gtLmntStats(frm_lmnt, a_prevFLS) {
this.sType = frm_lmnt.type;
//All the element types: text, textarea, radio,
//select-one, checkbox, select-multiple
this.iTotOpts = undefined;
if(this.sType == "checkbox" &&
this.flsFrm.obj.elements[frm_lmnt.name].length > 1) {
this.iTotOpts = this.flsFrm.obj.elements[frm_lmnt.name].length;
} else if(this.sType == "select-multiple") {
this.iTotOpts = frm_lmnt.options.length;
}
//If only one possible choice, then this.iTotOpts remain
//undefined.
if(this.sType == "radio" ||
(df(this.iTotOpts) && this.sType == "checkbox")) {
for(var i = 0; i < a_prevFLS.length; i++) {
if(a_prevFLS[i].sNm == frm_lmnt.name) {
//Already analyzed.
return false;
}
}
}
if(this.sType == "radio" ||
this.sType == "checkbox") {
this.obj = this.flsFrm.obj[frm_lmnt.name];
this.sAftrFrmNm = "['";
this.sAftrAttrNm = "']";
} else {
this.obj = frm_lmnt;
this.sAftrFrmNm = ".";
this.sAftrAttrNm = "";
}
//If this.iTotOpts is undefined, then this is a singular
//value element. Otherwise, it is a multiple-value object.
return true;
}
function pv_unassociateFalseBS(i_attrIdx) {
var sAttrNm = asVF_ATTRS[i_attrIdx];
if(this.isAttrAssc2Lmnt(sAttrNm) &&
this.gtAttrV(sAttrNm) == "false") {
eval(this.gtEvlCdLmntAttrNm(sAttrNm) + " = undefined;\n");
}
}
function pb_gtEvlCdLmntAttrNm(s_attrNm) {
ciMissing(this.gtEvlCdLmntAttrNm, "gtEvlCdLmntAttrNm (XCMAX)", "s_attrNm", s_attrNm);
return this.gtEvalCode(s_attrNm);
}
function pb_gtEvlCdObjNm() {
return this.gtEvalCode(undefined);
}
function pv_gtEvalCode(s_attrNm) {
var sAttrCd;
if(!df(s_attrNm)) {
sAttrCd = "";
} else {
sAttrCd = "." + s_attrNm;
}
if(this.sType == "form") {
//this.flsFrm may not exist if this is the
//cnstr!
return "document." + this.sNm + sAttrCd;
} else {
//this.flsFrm should exist, since the form should be
//created before any elements.
return "document." + this.flsFrm.sNm + this.sAftrFrmNm + this.sNm + sAttrCd + this.sAftrAttrNm;
}
}
//Private variables...START
var cSS_DELIM = "\~";
var sSS_CURRLEN = 'CURRLEN';
var sSS_BOUND_MIN = 'RANGE_MIN';
var sSS_BOUND_MAX = 'RANGE_MAX';
var sSS_BSS_LIST = 'BSS_LIST';
var sSS_BSS_FOUND = 'BSS_FOUND';
var sSS_OPTS_TOT = 'OPTS_TOTAL';
var sSS_OPTS_CHSN = 'OPTS_CHOSEN';
var aFLStats = undefined;
//Private variables...END
//As defined in validate_form.js. This notifies all other
//code that this JavaScript file has indeed been loaded.
bLDD_GUEC = true;
function gtUsrErrCnt(a_flStats) {
//Start off with no errors.
var iTotalErrors = 0;
//"i = 1" because a_flStats[0] is the form, and therefore has no value.
for(var i = 1; i < a_flStats.length; i++) {
var fls = a_flStats[i];
//Assume no error. Eliminate previous ones.
fls.sUsrErr = undefined;
var bTxtPwd = (fls.sType == "text" ||
fls.sType == "password");
var bString = (bTxtPwd || fls.sType == "textarea");
if(bString) {
//Trimming has highest precedence.
trimStringLmnt(fls);
}
//Get the current value for this form elements.
var iOptsChosen;
var vValSnglr;
if(fls.isLmntVal1OrMore()) {
vValSnglr = fls.gtLmntValSnglr();
} else {
iOptsChosen = fls.gtLmntOptsChosen();
}
//If iOptsChosen is undefined, then this element is a
//singular-value element, even if vValSnglr is
//undefined. No value (or "") in a text box, for
//instance, is fine.
//Required has second-highest precedence.
if(hasRequiredError(fls, iOptsChosen, vValSnglr)) {
//The error message has been set into fls.sUsrErr.
iTotalErrors++;
continue;
}
//If we've reached here, then...
//...the value is not required and is...
// ...not missing
// ...missing
//...the value is required and is not missing
if((!df(vValSnglr) && !df(iOptsChosen)) ||
(df(iOptsChosen) && iOptsChosen == 0)) {
//(DON'T TOUCH OR RE-FORMAT THIS COMMENT)
//Nothing further to check, because there's no
//value. Go onto the next element.
//This is *not* an error, which is why
//"iTotalErrors++" is not here!
continue;
}
//This is not applicable with sif text/password
//elements, so it can be done before sif attributes are
//analyzed.
if(bString && hasStrLnError(fls, vValSnglr)) {
iTotalErrors++;
continue;
}
if(bTxtPwd) {
if(hasTxtPwdError(fls, vValSnglr)) {
iTotalErrors++;
continue;
}
//Nothing txa-specific to check.
//Nothing rdo/sl1-specific to check.
} else if(fls.sType == "checkbox" || fls.sType == "select-multiple") {
//A checkbox set with one element is singular.
//A checkbox set with more than one element is multiple
//A radio set is always singular.
if(hasChkSlmError(fls, iOptsChosen, vValSnglr)) {
iTotalErrors++;
continue;
}
}
//Bad sub-strings has the lowest priority of all.
if(bString) {
if(hasBSSError(fls, vValSnglr)) {
iTotalErrors++;
continue;
}
}
}
return iTotalErrors;
}
function initVF() {
for(var i = 0; i < aVfbc.length; i++) {
stAFLSvf(undefined, aVfbc[i].sFrmNm)
}
//utility.js
bCrshd = false;
sCrshCd = undefined;
sCrshMsg = undefined;
fCrsh = undefined;
}
//Compatibility configuration...START
//documentation/unit_test/unit_tests.html#attribute_compatibility
//Every object-type recognized be validate_form.js
var cotFrm = new CmptblOTA(true, "form");
var cotTxt = new CmptblOTA(true, "text");
var cotPwd = new CmptblOTA(true, "password");
var cotTxa = new CmptblOTA(true, "textarea");
var cotRdo = new CmptblOTA(true, "radio");
var cotSl1 = new CmptblOTA(true, "select-one");
var cotChk = new CmptblOTA(true, "checkbox");
var cotSlm = new CmptblOTA(true, "select-multiple");
var asOBJ_TYPES = ["form", "text", "password", "textarea", "radio", "select-one", "checkbox", "select-multiple"];
var aCMPTBL_OBJ_TYPES = [cotFrm, cotTxt, cotPwd, cotTxa, cotRdo, cotSl1, cotChk, cotSlm];
//Every attribute type (except "sMsgTxt[SIFmt]" ones)
//recognized by validate_form.js
var ca_sMr = new CmptblOTA(false, "sMsgRequired");
var ca_sMtd = new CmptblOTA(false, "sMsgTxtDec");
var ca_sMte = new CmptblOTA(false, "sMsgTxtEmail");
var ca_sMti = new CmptblOTA(false, "sMsgTxtInt");
var ca_sMbl = new CmptblOTA(false, "sMsgBadLength");
var ca_sMmcr = new CmptblOTA(false, "sMsgMCRange");
var ca_asGbss = new CmptblOTA(false, "asGlobalBadSubStrs");
var ca_bsNbss = new CmptblOTA(false, "bsNoBadSubStrs");
var ca_asBss = new CmptblOTA(false, "asBadSubStrs");
var ca_sMbss = new CmptblOTA(false, "sMsgBadSubStr");
var ca_bsGts = new CmptblOTA(false, "bsGlobalTrimSpaces");
var ca_bsDts = new CmptblOTA(false, "bsDontTrimSpaces");
var ca_bsTs = new CmptblOTA(false, "bsTrimSpaces");
var aCMPTBL_ATTRS = [ca_sMr, ca_sMtd, ca_sMte, ca_sMti, ca_sMbl, ca_sMmcr, ca_asGbss, ca_bsNbss, ca_asBss, ca_sMbss, ca_bsGts, ca_bsDts, ca_bsTs];
var asVF_ATTRS = //idx
[ca_sMr.sNm, //0,
ca_sMtd.sNm, //1,
ca_sMte.sNm, //2,
ca_sMti.sNm, //3,
ca_sMbl.sNm, //4,
ca_sMmcr.sNm, //5,
ca_asGbss.sNm, //6,
ca_bsNbss.sNm, //7,
ca_asBss.sNm, //8,
ca_sMbss.sNm, //9,
ca_bsGts.sNm, //10,
ca_bsDts.sNm, //11,
ca_bsTs.sNm]; //12,
//
//(sMsgTxt[SIFmt], too: "sif")
//
//Define which attributes are compatible with a given
//object-type
//The length of ca4TxtPwd is used by stASIF()
var ca4TxtPwd = [ca_sMr, ca_sMtd, ca_sMte, ca_sMti, ca_sMbl, ca_bsNbss, ca_asBss, ca_sMbss, ca_bsDts, ca_bsTs];
var ca4ChkSlm = [ca_sMr, ca_sMmcr];
cotFrm.addGdAtts4OT([ca_bsGts, ca_asGbss]);
cotTxt.addGdAtts4OT(ca4TxtPwd); //sif
cotPwd.addGdAtts4OT(ca4TxtPwd); //sif
cotTxa.addGdAtts4OT([ca_sMr, ca_sMbl, ca_bsNbss, ca_asBss, ca_sMbss, ca_bsDts, ca_bsTs]);
cotRdo.addGdAtts4OT([ca_sMr]);
cotSl1.addGdAtts4OT([ca_sMr]);
cotChk.addGdAtts4OT(ca4ChkSlm);
cotSlm.addGdAtts4OT(ca4ChkSlm);
//Define which object-types are compatible with a given
//attribute.
var acotTxtPwd = [cotTxt, cotPwd];
var acotStrings = [cotTxt, cotPwd, cotTxa];
ca_sMr.stGoodOTs4Attr([cotTxt, cotPwd, cotTxa, cotRdo, cotSl1, cotChk, cotSlm]);
ca_sMtd.stGoodOTs4Attr(acotTxtPwd);
ca_sMte.stGoodOTs4Attr(acotTxtPwd);
ca_sMti.stGoodOTs4Attr(acotTxtPwd);
ca_sMbl.stGoodOTs4Attr(acotStrings);
ca_asBss.stGoodOTs4Attr(acotStrings);
ca_sMbss.stGoodOTs4Attr(acotStrings);
ca_bsDts.stGoodOTs4Attr(acotStrings);
ca_bsTs.stGoodOTs4Attr(acotStrings);
ca_bsNbss.stGoodOTs4Attr(acotStrings);
ca_sMmcr.stGoodOTs4Attr([cotChk, cotSlm]);
ca_asGbss.stGoodOTs4Attr([cotFrm]);
ca_bsGts.stGoodOTs4Attr([cotFrm]);
//Define which (other) attributes are *in*compatible with
//a given attribute.
//Adding [] is not possible, so commented out. Still
//listed though, for completeness.
//ca_sMr.addBdAtts4Att([]);
ca_sMtd.addBdAtts4Att([ca_sMte, ca_sMti]); //sif
ca_sMte.addBdAtts4Att([ca_sMtd, ca_sMti]); //sif
ca_sMti.addBdAtts4Att([ca_sMtd, ca_sMte, ca_sMbl]); //sif
ca_sMbl.addBdAtts4Att([ca_sMti]); //sif
//ca_sMmcr.addBdAtts4Att([]);
//ca_asGbss.addBdAtts4Att([]);
ca_bsNbss.addBdAtts4Att([ca_asBss, ca_sMbss]);
ca_asBss.addBdAtts4Att([ca_bsNbss]);
ca_sMbss.addBdAtts4Att([ca_bsNbss]);
//ca_bsGts.addBdAtts4Att([]);
ca_bsTs.addBdAtts4Att([ca_bsDts]); //sif
ca_bsDts.addBdAtts4Att([ca_bsTs]); //sif
//Compatibility configuration...START
function gtCOTA(a_cota, s_name) {
for(var i = 0; i < a_cota.length; i++) {
if(s_name == a_cota[i].sNm) {
return a_cota[i];
}
}
}
//Get form-value error messages...START
function gtMsgSSBounds(s_message, i_min, i_max) {
if(df(i_min)) {
s_message = gtMsgRplcSpclStr(s_message, cSS_DELIM, sSS_BOUND_MIN, i_min);
}
if(df(i_max) && i_max != -1) {
//For a text element, "MAXLENGTH" equals -1 when not defined (or bogus).
s_message = gtMsgRplcSpclStr(s_message, cSS_DELIM, sSS_BOUND_MAX, i_max);
}
return s_message;
}
function gtMsgRplcSpclStr(s_message, c_delimiter, s_toReplace, s_replaceWith) {
var sss = c_delimiter + s_toReplace + c_delimiter;
if(!df(s_message)) {
//Special case, when an error occured previously in the
//code, but throw didn't occur. If we don't do this,
//we'll get another throw, because the below will
//cause an "s_message has no properties"
//
s_message = "";
}
var iSSIdx = s_message.indexOf(sss);
if(iSSIdx != -1) {
return s_message.substring(0, iSSIdx) + s_replaceWith + s_message.substring((iSSIdx + sss.length), (s_message.length + 1));
} else {
return s_message;
}
}
function trimStringLmnt(fls_tpta) {
//This is a string element.
var v = fls_tpta.obj.value;
if(!df(v)) {
//No value to trim
return;
}
if(fls_tpta.isAttrAssc2Lmnt(ca_bsDts.sNm)) {
//Explicitely should not trim.
return;
}
if(fls_tpta.flsFrm.isAttrAssc2Lmnt(ca_bsGts.sNm) ||
fls_tpta.isAttrAssc2Lmnt(ca_bsTs.sNm)) {
//Trim it!
v = trmChr(' ', v);
fls_tpta.obj.value = trmChr('\t', v);
}
}
function hasRequiredError(fls_lmnt, i_optsChosen, v_valSnglr) {
if(!fls_lmnt.isAttrAssc2Lmnt(ca_sMr.sNm)) {
//Missing is a non-issue. Good (false, no error)
return false;
}
//If missing, bad.
if((fls_lmnt.isLmntVal1OrMore() &&
!df(v_valSnglr)) ||
i_optsChosen == 0) {
fls_lmnt.sUsrErr = fls_lmnt.gtAttrV(ca_sMr.sNm);
return true;
}
//Not missing. Good (false, no error).
return false;
}
function hasTxtPwdError(fls_txtpwd, v_valSnglr) {
//It is assumed/expected that there is only one "sMsgTxt"
//variables associated to this text/password element.
if(fls_txtpwd.isAttrAssc2Lmnt(ca_sMte.sNm)) {
//util_string.isEml()
if(!isEml(fls_txtpwd.gtLmntValSnglr())) {
fls_txtpwd.sUsrErr = fls_txtpwd.gtAttrV(ca_sMte.sNm);
return true;
}
}
if(fls_txtpwd.isAttrAssc2Lmnt(ca_sMti.sNm)) {
return hasDecIntErr("false", fls_txtpwd, ca_sMti.sNm, "iIntMin", "iIntMax");
}
if(fls_txtpwd.isAttrAssc2Lmnt(ca_sMtd.sNm)) {
return hasDecIntErr("true", fls_txtpwd, ca_sMtd.sNm, "dDecMin", "dDecMax");
}
//sMsgTxt* (sif, not dec/email/int) attributes exist/were
//added at indexes 13 and up.
for(var i = 13; i < aCMPTBL_ATTRS.length; i++) {
if(fls_txtpwd.isAttrAssc2Lmnt(aCMPTBL_ATTRS[i].sNm)) {
//".sif" is set in stASIF()
var sStrpdAndValid = aCMPTBL_ATTRS[i].sif.gtFmtV(fls_txtpwd.obj.value);
if(df(sStrpdAndValid)) {
fls_txtpwd.obj.value = sStrpdAndValid;
return false;
} else {
fls_txtpwd.sUsrErr = fls_txtpwd.gtAttrV(aCMPTBL_ATTRS[i].sNm);
return true;
}
}
}
//None of these attributes were associated to this
//text/password element, so no error.
return false;
}
function hasDecIntErr(bs_decInt, fls_txtpwd, s_msgAttrNm, v_minBound, v_maxBound) {
var vMin = fls_txtpwd.gtAttrVRaw(v_minBound);
var vMax = fls_txtpwd.gtAttrVRaw(v_maxBound);
var vValue = fls_txtpwd.obj.value;
//util_string.isNum()
if(!isNum(fls_txtpwd.obj.value, bs_decInt) ||
(df(vMin) && vMin > vValue) ||
(df(vMax) && vMax < vValue)) {
fls_txtpwd.sUsrErr = gtMsgSSBounds(
fls_txtpwd.gtAttrV(s_msgAttrNm), vMin, vMax);
return true;
}
return false;
}
function hasStrLnError(fls_tpta, v_valSnglr) {
if(fls_tpta.sType != "text" && fls_tpta.sType != "password" &&
fls_tpta.sType != "textarea") {
//Only string elements have length.
return false;
}
//This is a string element
if(!fls_tpta.isAttrAssc2Lmnt(ca_sMbl.sNm)) {
//No value, so no bad length.
return false;
}
//Value, so possibly bad length.
var iCurrLen = fls_tpta.gtLmntValSnglr().length;
if(fls_tpta.isAttrAssc2Lmnt("iMinLength") &&
(iCurrLen < fls_tpta.gtAttrV("iMinLength"))) {
stBadLnMsg(fls_tpta, iCurrLen);
return true;
}
var iMx = fls_tpta.gtAttrVRaw("iMaxLength");
if(df(iMx) && iMx != -1 &&
(iCurrLen > iMx)) {
stBadLnMsg(fls_tpta, iCurrLen);
return true;
}
return false;
}
function stBadLnMsg(fls_tpta, i_currLen) {
var sErr = gtMsgRplcSpclStr(
fls_tpta.gtAttrV(ca_sMbl.sNm),
cSS_DELIM, sSS_CURRLEN,
i_currLen);
fls_tpta.sUsrErr = gtMsgSSBounds(sErr,
fls_tpta.gtAttrVRaw("iMinLength"),
fls_tpta.gtAttrVRaw("iMaxLength"));
}
function hasChkSlmError(fls_chkslm, i_optsChosen, v_valSnglr) {
if(!fls_chkslm.isAttrAssc2Lmnt(ca_sMmcr.sNm)) {
//The number of selected options doesn't matter.
return false;
}
//...oh yes it does...
var iMn = fls_chkslm.gtAttrVRaw("iMCMin");
var iMx = fls_chkslm.gtAttrVRaw("iMCMax");
if((df(iMn) &&
i_optsChosen < iMn) ||
(df(iMx) &&
iMx < i_optsChosen)) {
var sErr = gtMsgSSBounds(
fls_chkslm.gtAttrVRaw(ca_sMmcr.sNm), iMn, iMx);
sErr = gtMsgRplcSpclStr(sErr,
cSS_DELIM, sSS_OPTS_TOT, fls_chkslm.iTotOpts);
fls_chkslm.sUsrErr = gtMsgRplcSpclStr(sErr,
cSS_DELIM, sSS_OPTS_CHSN, fls_chkslm.gtLmntOptsChosen());
return true;
}
return false;
}
function hasBSSError(fls_tpta, v_valSnglr) {
if(fls_tpta.flsFrm.isAttrAssc2Lmnt(ca_asBss.sNm)) {
//This element is exempt.
return false;
}
var asBSS;
if(fls_tpta.isAttrAssc2Lmnt(ca_asBss.sNm)) {
//The element's list has higher priority than the
//form's list, which is why this block comes before...
asBSS = fls_tpta.gtAttrV(ca_asBss.sNm)
} else if(fls_tpta.flsFrm.isAttrAssc2Lmnt(ca_asGbss.sNm)) {
//...this one.
asBSS = fls_tpta.flsFrm.gtAttrV(ca_asGbss.sNm)
} else {
//No bad sub strings are defined.
return false;
}
//There are illegal sub-strings.
for(var i = 0; i < asBSS.length; i++) {
if(v_valSnglr.indexOf(asBSS[i]) != -1) {
var sErr = gtMsgRplcSpclStr(
fls_tpta.gtAttrV(ca_sMbss.sNm),
cSS_DELIM, sSS_BSS_LIST,
"['" + asBSS.join("', '") + "']");
fls_tpta.sUsrErr = gtMsgRplcSpclStr(sErr,
cSS_DELIM, sSS_BSS_FOUND,
asBSS[i]);
return true;
}
}
//No bad sub-strings found in the value.
return false;
}
//Get user error messages...END
function pb_addGdAtts4OT(a_cvfAttribute) {
this.addCVFAttrs("addGdAtts4OT", true, a_cvfAttribute);
}
function pb_addBdAtts4Att(a_cvfAttribute) {
this.addCVFAttrs("addBdAtts4Att", false, a_cvfAttribute);
}
function pv_addCVFAttrs(s_callingFunc, b_objTypeOrAttr, a_cvfAttribute) {
this.add2RA(s_callingFunc, b_objTypeOrAttr, this.aACAttrs_G4OT_B4A, a_cvfAttribute);
}
function pb_stGoodOTs4Attr(a_cvfAttribute) {
if(this.aCObjTypes_G4A.length > 1) { //XCMAX
crsh("cota.sgot4a1", this.stGoodOTs4Attr, "stGoodOTs4Attr (XCMAX): this.aCObjTypes_G4A.length=" + this.aCObjTypes_G4A.length + ". Can only call this function once. Note the name of this function starts 'st' (meaning 'set'), not 'add'.");
} //XCMAX
this.add2RA("stGoodOTs4Attr", false, this.aCObjTypes_G4A, a_cvfAttribute);
}
function pb_add2RA(s_callingFunc, b_objTypeOrAttr, a_dest, a_cvfAttribute) {
cibRA(s_callingFunc + " (XCMAX)", "a_cvfAttribute", a_cvfAttribute);
if(b_objTypeOrAttr != this.bOTorA) { //XCMAX
crsh("cota.cincvfa", this.add2RA, s_callingFunc + " (XCMAX): This function is only applicable for " + (b_objTypeOrAttr?"object-types":"vf-attributes") + ". This object represents " + (this.bOTorA?"object-types":"vf-attributes") + ".");
} //XCMAX
for(var i = 0; i < a_cvfAttribute.length; i++) {
a_dest[a_dest.length] = a_cvfAttribute[i];
}
}
function pb_hasAttr(s_attribute) {
ciMissing(this.hasAttr, "hasAttr (XCMAX)", "s_attribute", s_attribute);
for(var i = 0; i < this.aACAttrs_G4OT_B4A.length; i++) {
if(s_attribute == this.aACAttrs_G4OT_B4A.sNm) {
return true;
}
}
return false;
}
function pb_hasOT(s_objType) {
ciMissing(this.hasOT, "hasOT (XCMAX)", "s_objType", s_objType);
for(var i = 0; i < this.aCObjTypes_G4A.length; i++) {
if(s_objType == this.aCObjTypes_G4A[i].sNm) {
return true;
}
}
return false;
}
function CmptblOTA(b_objTypeOrAttr, s_name) {
ciMissing(CmptblOTA, "CmptblOTA (XCMAX)", "b_objTypeOrAttr", b_objTypeOrAttr);
ciMissing(CmptblOTA, "CmptblOTA (XCMAX)", "s_name", s_name);
if(s_name.length < 1) { //XCMAX
crsh("coa.cnstr1", CmptblOTA, "CmptblOTA.constructor (XCMAX): s_name is zero characters in length.");
} //XCMAX
this.sNm = s_name;
this.bOTorA = b_objTypeOrAttr;
this.aCObjTypes_G4A = [];
this.stGoodOTs4Attr = pb_stGoodOTs4Attr;
//Both object-types and attributes keep track of attributes,
//for one reason or another.
this.aACAttrs_G4OT_B4A = [];
this.addBdAtts4Att = pb_addBdAtts4Att;
this.addGdAtts4OT = pb_addGdAtts4OT;
this.addCVFAttrs = pv_addCVFAttrs;
this.add2RA = pb_add2RA;
this.hasAttr = pb_hasAttr;
this.hasOT = pb_hasOT;
//For ca-s that are representing SIFmt attributes.
//Used in hasTxtPwdError()
//".sif" is set in stASIF()
this.sif = undefined;
}
function gtVRAIdx(s_callingFunc, v_alue, a_value) {
cibRA(s_callingFunc + " (XCMAX) [NOTE THAT THERE ARE THREE PARAMETERS, THE FIRST BEING THE 'CALLING FUNCTION']", "a_value", a_value);
for(var i = 0; i < a_value.length; i++) {
if(v_alue == a_value[i]) {
return i;
}
}
return -1;
}
function isInAscRA(v_alue, a_value) {
cibRA("isInAscRA (XCMAX)", "a_value", a_value);
for(var i = 0; i < a_value.length; i++) {
if(v_alue < a_value[i]) {
return false;
}
if(v_alue == a_value[i]) {
return true;
}
}
return false;
}
function isRA(o_potentialArray) {
ciMissing(isRA, 'util_array.isRA (XCMAX)', 'o_potentialArray', o_potentialArray);
if(typeof o_potentialArray != 'object') {
return false;
}
//It is definitely an object.
return (o_potentialArray.constructor.toString().match(/array/i) != null);
}
function isNum(s_potential, bs_decimalAllowed) {
ciMissing(isNum, 'util_string.isNum [XCMAX]', 's_potential', s_potential);
cibBoolStr('util_string.isNum [XCMAX]', 'bs_decimalAllowed', bs_decimalAllowed);
if(s_potential.length < 1) {
return false;
}
if(s_potential == '-') {
//A negative sign only makes no sense.
return false;
}
if(/^-[0]+$/.test(s_potential)) {
//Negative zero makes no sense.
return false;
}
if(/^[0]+$/.test(s_potential)) {
//Zero is a legal number:
//0 == 0000000000000 == 000
return true;
}
//It is definitely not zero.
//^ The start of the line.
//[-]{0,1} Zero or one dashes.
//[0-9]+ One or more of any digit.
//$ The end of the line.
if(/^[-]{0,1}[0-9]+$/.test(s_potential)) {
//No matter what, this is valid. This is a leagal integer
//and decimal.
return true;
}
//It's not an integer...
if(bs_decimalAllowed == 'false') {
//...but it must be.
return false;
}
//...and that's okay. It might be a decimal
//Due to precision:
//10.0000000000001 is legal (12 zeros)
//10.00000000000001 is not (13 zeros)
//^ The start of the line.
//[-]{0,1} Zero or one dashes.
//[0-9]* Zero or more digits.
//[.] A decimal point.
//[0-9]+ One or more digits.
//$ The end of the line.
if(/^[-]{0,1}[0-9]*[.][0-9]+$/.test(s_potential)) {
//It is a "raw" decimal. The only thing that would make
//this illegal is if it were -0.0 or -.0, or -0.0000 or
//-.0000 or ...
return !(/^-0*[.]0+$/.test(s_potential));
}
//It is not a legal decimal number.
return false;
}
function isEml(s_potentialEmail) {
if(!df(s_potentialEmail) || //XCMAX
s_potentialEmail.length < 1) {//XCMAX
crsh("us.ie1", isEml, "isEml (XCMAX): s_potentialEmail must be defined, and at least one character in length.");
} //XCMAX
if(s_potentialEmail.indexOf(" ") != -1 ||
s_potentialEmail.indexOf("/") != -1 ||
s_potentialEmail.indexOf("\\\\") != -1 ||
s_potentialEmail.indexOf(",") != -1) {
//A space, slash or comma was found.
return false;
}
if(/[@.][@.]/.test(s_potentialEmail)) {
//An @ or dot is followed by an @ or dot.
return false;
}
if(/^[@.]/.test(s_potentialEmail)) {
//The first character is an @ or dot.
return false;
}
if(/[@.]$/.test(s_potentialEmail)) {
//The last character may not be an @ or dot.
return false;
}
if(!/^[^@]+@[^@]+$/.test(s_potentialEmail)) {
//Only one @ allowed
// (Negative of:
// Must have one or more non-@ starting the line,
// exactly one @, and then
// one or more non-@ ending the line.)
return false;
}
//There is exactly one @.
if(!/@.*[.]/.test(s_potentialEmail)) {
//At least one dot must follow the (single) @.
return false;
}
//At least one dot follows the @. We already determined
//above that it does not immediately follow it,
//No negative conditions were met. This is a legal email address.
//Cool, eh? : )
return true;
}
function trmChr(c_harToTrim, s_tring) {
if(!c_harToTrim || c_harToTrim.length != 1) {//XCMAX
crsh("us.tc1", trmChr, "us.trmChr (XCMAX): c_harToTrim must be provided, and must be exactly one character in length. Currently '" + c_harToTrim + "'.");
} //XCMAX
ciMissing(trmChr, 'us.trmChr [XCMAX]', 's_tring', s_tring);
var i = 0;
var iStartingSpaces = 0;
while(s_tring.substring(i, (i + 1)) == c_harToTrim) {
iStartingSpaces++;
i++;
}
if(iStartingSpaces == s_tring.length) {
return "";
}
i = 0;
var iEndingSpaces = 0;
while(s_tring.substring((s_tring.length - i), (s_tring.length - (i + 1))) == c_harToTrim) {
iEndingSpaces++;
i++;
}
if(iStartingSpaces == 0 && iEndingSpaces == 0) {
return s_tring;
}
return s_tring.substring(iStartingSpaces, (s_tring.length - iEndingSpaces));
}
function gtCd4V(s_value) {
if(!df(s_value)) {
return "undefined";
//util_string.isNum()
} else if(isNum(s_value, "true")) {
return s_value;
//util_array.isRA()
} else if(isRA(s_value)) {
return "['" + s_value.join("', '") + "']";
} else {
//This is a boolean string or plain string.
return "'" + s_value + "'";
}
}
//[crsh() ids used in this js file: 1..4]
//Global variables...START
//As defined in validate_form.js. This notifies all other
//code that this JavaScript file has indeed been loaded.
bLDD_CI = true;
//Initialized in validate_form.js
//A secret public global variable. For testing purposes, you
//may want to avoid re-displaying the error after the alert
//box (within H1 tags). This gives you access to the error id
//
//bCRSH_ALRT: If 'true', then an alert box is displayed
//when the crash function is called. If 'false', no alert box
//is displayed. Should default to 'true'.
bCRSH_ALRT = true;
//bCRSH_DGNSTCS: If 'true', then the error message is
//displayed on a new web page, to make it truly clear that an
//error occured. If 'false', the error message is not
//displayed on a new page. Should default to 'true'.
bCRSH_DGNSTCS = true;
//bCRSH_THROW
bCRSH_THROW = true;
//This is automatically manipulated by this js file. It is private
//and should never be altered.
var bCrshd = false;
//The id of the error.
var sCrshCd = undefined;
var fCrsh = undefined;
//The full text of the error.
var sCrshMsg = undefined;
//Global variables...END
function crsh(s_code, f_unc, s_error) {
if(!df(f_unc)) {
return alert("ERROR in utility.crsh: f_unc is undefined. [crsh.caller=" + crsh.caller.name + ", s_code='" + s_code + "', s_error='" + s_error + "']");
}
if(!df(f_unc.arguments)) {
return alert("ERROR in utility.crsh: f_unc.arguments is undefined. Make sure f_unc is a function reference. [crsh.caller=" + crsh.caller.name + ", s_code='" + s_code + "', s_error='" + s_error + "']");
}
if(!s_code) {
return alert("ERROR in utility.crsh: s_code is required and must not equal zero or empty string. [crsh.caller=" + crsh.caller.name + ", f_unc='" + f_unc + "', s_error='" + s_error + "']");
}
var sHdr = "u.crsh() ERROR. ";
var sFncNm = "Function: " + f_unc.name + "()";
var sCode = "Code: " + s_code;
var sClrNm = "Caller: ";
if(df(f_unc.caller)) {
//This block cannot be a ()?: line, because you'll get
//a "f_unc.caller has no properties" exception when this
//error is from a top-level function call.
sClrNm += f_unc.caller.name + "()"
} else {
sClrNm += "[TOP LEVEL CALL. Called by the document itself]";
}
var sCrshClr = "crsh() caller: " + crsh.caller.name;
var sArgs = "";
var aFrgs = f_unc.arguments;
if(!isRA(aFrgs)) {
sArgs = "COULD NOT DETERMINE ARGUMENTS. f_unc.arguments is not of type 'array'. WHY?!";
} else {
for(var i = 0; i < aFrgs.length; i++) {
sArgs += i + " [" + aFrgs[i] + "]\n";
}
}
sArgs = "Argument(s):\n" + sArgs;
//This must precede the "wrt" line. Otherwise you'll get
//a "not defined" exception for either getEMsg() or
//bCRSH_ALRT...START
var sLrt = sHdr + sCode + "\nbCRSH_DGNSTCS=" + bCRSH_DGNSTCS + " bCRSH_ALRT=" + bCRSH_ALRT + " bCRSH_THROW=" + bCRSH_THROW + "\n";
if(bCRSH_DGNSTCS) {
sLrt += "\n(About to write this error and code to the document)";
} else if(bCRSH_ALRT && window.location.hash.length > 0) {
if(bCRSH_THROW) {
sLrt += "\n[[[ NOTE: The page may reload to '" + window.location.hash + "', and form values may revert to their defaults. ANYONE KNOW WHY THIS RELOADS IN UNPREDICTABLE LOCATIONS???? ]]]";
} else {
sLrt += "\n[[[ NOTE: bCRSH_THROW equals false. Unpredictable behavior may follow this dialog... ]]]";
}
}
sLrt += "\n------------------------" +
"\n" + s_error +
"\n---------------------\n" + sFncNm +
"\n" + sClrNm +
"\n" + sCrshClr;
//For debugging purposes.
sCrshCd = s_code;
sCrshMsg = sLrt;
fCrsh = f_unc;
if(bCRSH_ALRT) {
alert(sLrt);
}
//This must precede the "wrt" line. Otherwise you'll get
//a "not defined" exception for either getEMsg() or
//bCRSH_ALRT...END
var sDgnstcs;
if(bCRSH_DGNSTCS) {
var sb = "\n
";
var sTop = "
" + sHdr + sCode + "..."; var sBtm = " |
" + s_error + "
" + sCode + sb + sFncNm + sb + sClrNm + sb + sCrshClr + "
\n" + sArgs + "\n" + "
" + f_unc + "\n
" + f_unc.caller + "\n" + sTop + "END\n" + sBtm; } //Divided into two functions, which for some reason seems to //prevent errors. if(bCRSH_THROW) { crshAndThrow(sDgnstcs, sLrt); } else { crshNoThrow(sDgnstcs); } } function crshAndThrow(s_dgnstcs, s_throwMsg) { if(bCRSH_DGNSTCS) { wrt(s_dgnstcs); } throw s_throwMsg; } function crshNoThrow(s_dgnstcs) { if(bCRSH_DGNSTCS) { wrt(s_dgnstcs); } } function ciMissing(f_calling, s_callingFileFunc, s_varName, v_required) { if(!df(v_required)) { crsh("u.cim1", f_calling, s_callingFileFunc + ': Required parameter ' + s_varName + ' is undefined.'); } } function cibBoolStr(s_callingFunc, s_bsName, bs_shouldBe) { ciMissing(cibBoolStr, "u.cibBoolStr (s_callingFunc='" + s_callingFunc + "', s_bsName='" + s_bsName + "')", "bs_shouldBe", bs_shouldBe); if(bs_shouldBe == 'true' || bs_shouldBe == 'false') { //It's all good. return; } crsh("u.cibbs1", cibBoolStr, s_callingFunc + ": " + s_bsName + " must be a *string* equal to either 'true' or 'false'. EXTRA INFO: bs_shouldBe.toString()='" + bs_shouldBe.toString() + "', bs_shouldBe.type='" + bs_shouldBe.type + "' , value='" + bs_shouldBe + "'."); } function cibAFLS(s_callingFunc, s_aosName, a_flStats) { cibRA(s_callingFunc, s_aosName, a_flStats); for(var i = 0; i < a_flStats.length; i++) { ciNotFLStats(s_callingFunc, s_aosName + "[" + i + "]", a_flStats[i]); } } function ciNotFLStats(s_callingFunc, s_flsName, v_shouldBeFLS) { ciMissing(ciNotFLStats, s_callingFunc, s_flsName, v_shouldBeFLS); if(!df(v_shouldBeFLS.type) || v_shouldBeFLS.type != "FLStats") { crsh("os.cinos1", ciNotFLStats, s_callingFunc + ": " + s_flsName + " is not of type 'FLStats'. Currently, [" + v_shouldBeFLS + "]."); } } //Intended for validate_form.js function ciNotLoaded(s_callingFunc, vfb_cfg) { var f = ciNotLoaded; var sF = s_callingFunc; var sDgnstcsStart = ".\n----------\nDiagnostics:\ns_jsDirUrl='" + sJSDIR + "' (as you provided to loadVF())\n"; if(df(vfb_cfg)) { if(vfb_cfg.isVfpdOn() && !bLDD_VFPD) { crsh("vf.gfem8", f, sF + "Permanent VF-Diagnostics are currently active, but '" + sJSDIR + "vf_perm_diagnostics.js'could not be loaded" + sDgnstcsStart + "bLDD_VFPD=" + bLDD_VFPD + "\nvfb_cfg.isVfpdOn()=" + vfb_cfg.isVfpdOn() + ", vfb_cfg.bDOnDflt=" + vfb_cfg.bDOnDflt + ", bVFPDInUrl=" + bVFPDInUrl + ", vfb_cfg.sFrmNm='" + vfb_cfg.sFrmNm + "'\nwindow.location.search='" + window.location.search + "'\nvfb_cfg.isVfpdOn()=" + vfb_cfg.isVfpdOn() + "'\nbLDD_VFPD=" + bLDD_VFPD); } else if(vfb_cfg.isCIBCOn() && !bLDD_CIBC) { crsh("vf.gfem9", f, sF + "vfb_cfg.isCIBCOn() equals true, but '" + sJSDIR + "vf_cib_config.js' or '" + sJSDIR + " could not be loaded" + sDgnstcsStart + "vfb_cfg.sFrmNm='" + vfb_cfg.sFrmNm + "'\nbLDD_CIBC=" + bLDD_CIBC); } else if(vfb_cfg.iDDPS != -1 && !bLDD_DBG) { crsh("vf.gfem10", f, sF + "vfb_cfg.iDDPS equals something other than -1 (" + vfb_cfg.iDDPS + "), but '" + sJSDIR + "vf_dbgVF.js' could not be loaded" + sDgnstcsStart + "vfb_cfg.sFrmNm='" + vfb_cfg.sFrmNm + "'"); } } if((bLDD_CIBC || bLDD_DBG) && !bLDD_OD) { crsh("vf.gfem11", f, sF + "Either " + sJSDIR + "vf_cib_config.js (" + bLDD_CIBC + ") or " + sJSDIR + "vf_dbgVF.js (" + bLDD_DBG + ") were loaded, but the required sub-file '" + sJSDIR + "vf_obj_dgnstcs.js' could not be loaded" + sDgnstcsStart); } else if(df(sSifCfgUrl) && (!bLDD_STASIF || !bLDD_SIF_CFG || (aCMPTBL_ATTRS.length == 13))) { crsh("vf.gfem12", f, sF + "s_relUrl2ASIFmt ('" + sSifCfgUrl + "') has at least one of the following problems:\n - It could not be loaded. Verify the path.\n - It does not call stASIF().\n - It does not contain the required variable and value 'bLDD_SIF_CFG=true;'" + sDgnstcsStart + "bLDD_STASIF=" + bLDD_STASIF + "\naCPMTBL_ATTRS.length=" + aCMPTBL_ATTRS.length + "\nbLDD_SIF_CFG=" + bLDD_SIF_CFG); } } function cibRA(s_callingFunc, s_arrayNm, a_rray) { ciMissing(cibRA, s_callingFunc, s_arrayNm, a_rray); if(!isRA(a_rray)) { crsh("ua.ciba1", cibRA, s_callingFunc + ": " + s_arrayNm + " is not an array according to util_array.isRA(). " + s_arrayNm + "=[" + a_rray.toString() + "]."); } if(a_rray.length < 1) { crsh("ua.ciba2", cibRA, s_callingFunc + ": " + s_arrayNm + " is zero elements in length."); } for(var i = 0; i < a_rray.length; i++) { if(!df(a_rray[i])) { crsh("ua.ciba3", cibRA, s_callingFunc + ": " + s_arrayNm + "[" + i + "] is undefined. " + s_arrayNm + "=['" + a_rray.join("', '") + "']"); } } } //Intended for si_fmt.js function cibLnRng(si_min, si_max, s_minName, s_maxName, s_whenProvided) { cibInt(s_minName, si_min); cibInt(s_maxName, si_max); if(!df(si_min)) { //This is the alternate minimum bound. We also know the //max alt bound is undefined. return; } //Both rqd/alt bounds have been provided. if(si_min.length != si_max.length) { crsh("snf.cnstr1", cibLnRng, "cibLnRng: " + s_whenProvided + s_minName + " ('" + si_min + "') and " + s_maxName + " ('" + si_max + "') must be the same length."); } if(parseInt(si_min, 10) > parseInt(si_max, 10)) { crsh("snf.cnstr1", cibLnRng, "cibLnRng: " + s_whenProvided + s_minName + " ('" + si_min + "') must be (numerically) less than or equal to " + s_maxName + " ('" + si_max + "')."); } } //Intended for si_fmt.js function cibInt(s_boundName, si_frmtBound) { if(df(si_frmtBound) && !isNum(si_frmtBound, "false") || si_frmtBound < 0) { crsh("snf.cnstr4", cibInt, "cibLnRng: The value of " + s_boundName + " ('" + si_frmtBound + "') must be an *integer* greater than -1."); } }