/**
JS FILE OVERVIEW DOCUMENTATION
Debug a form's vf-related information in a series of configurable alert()
boxes.
See the tutorial for implementation details.
This is a holder for the dbgVF()
function. Debugging may not be used, so its code is held in a separate file so it's not imported when unneeded.
**/
//As defined in validate_form.js. This notifies all other
//code that this JavaScript file has indeed been loaded.
bLDD_DBG = true;
/**
PUBLIC FUNCTION
Friendly-looking alert-box output for your form: Its elements, validate_form.js
configuration, and actual values.
Debugging is output on an element-by-element basis, in alert boxes. The functions from fl_stats.js
and vf_obj_dgnstcs.js
do most of the work here, and you could use them directly. The benefits of this function are pretty much the 'x-per-screen' stuff.
PARAMETERS
a_flStats
: The array of FLStats representing the form you wish to debug. REQUIRED if i_dbgPerScreen
is provided
i_dbgPerScreen
: The number of elements to display per screen. If undefined or equal to -1, then no debugging takes place. If defined, must be an integer equal -1 or be greater than zero.
SIGNATURE
dfgVF(a_flStats, i_dbgPerScreen)
**/
function dbgVF(a_flStats, i_dbgPerScreen, b_cibRA) {
if(!df(b_cibRA) || b_cibRA) {
//Crash if the array is bad.
cibAFLS("dbgVF", "a_flStats", a_flStats);
}
if(!df(i_dbgPerScreen)) {
//Debugging is not desired.
return;
} else if(!isNum(i_dbgPerScreen, 'false')) {
crsh("dvf1", dbgVF, "dbgVF: The only legal values for i_dbgPerScreen (currently [" + i_dbgPerScreen + "]) are [undefined], [-1], or [greater than zero].");
} else if(i_dbgPerScreen == -1) {
//Debugging is not desired.
return;
} else if(i_dbgPerScreen < 1) {
crsh("dvf2", dbgVF, "dbgVF: The only legal values for i_dbgPerScreen (currently [" + i_dbgPerScreen + "]) are [undefined], [-1], or [greater than zero].");
}
var sDbg = "";
var iLeftScr = i_dbgPerScreen;
for(var iLmntIdx = 0; iLmntIdx < a_flStats.length; iLmntIdx++) {
//Update the total number of objects left.
iLeftTot = a_flStats.length - iLmntIdx;
sDbg += gtDbg4FLS(a_flStats[iLmntIdx], (sDbg.length<1), (iLmntIdx + 1));
//Decrement the number left to display in this screen.
iLeftScr--;
if(iLeftScr < 1 || iLmntIdx == (a_flStats.length - 1)) {
var iLastLmnt = iLmntIdx + 1;
//When iLeftScr >= 1, then this is the straggling
//elements on the very last screen.
var iFirstLmnt = iLastLmnt - i_dbgPerScreen + 1 + iLeftScr;
alert("validate_form.js DEBUGGING [" + iFirstLmnt + " to " + iLastLmnt + " of " + a_flStats.length + "/" + i_dbgPerScreen + " per screen]\n--------------------------------\n" + sDbg);
sDbg = "";
iLeftScr = i_dbgPerScreen;
}
}
}
function gtDbg4FLS(fl_stats, b_topOfScreen, i_idxP1) {
var sDbg = "";
if(!b_topOfScreen) {
sDbg = "\n\n";
}
sDbg += "--- [[" + i_idxP1 + "]] --- " + fl_stats.sNm + " [type='" + fl_stats.sType + "'] ---\n";
if(fl_stats.sType != "form") {
//This is a form element, and therefore has a potential value.
if(!fl_stats.isLmntVal1OrMore()) {
sDbg += "[[ " + fl_stats.gtLmntOptsChosen() + " of " + fl_stats.iTotOpts + " options selected ]]\n";
} else if(df(fl_stats.gtLmntValSnglr())) {
var sValue = fl_stats.gtLmntValSnglr();
var sLength = "";
if(fl_stats.sType == "text" ||
fl_stats.sType == "password" ||
fl_stats.sType == "textarea") {
sLength = " (length=" + sValue.length + ")";
}
sDbg += "[[ VALUE" + sLength + "]] [" + sValue + "]\n";
}
}
return sDbg + gtCd4Lmnt(fl_stats);
}