home *** CD-ROM | disk | FTP | other *** search
- function _NextToken(sz, ichStart, chDelim)
- {
- var ich = ichStart;
- var cch = sz.length;
- while (ich < cch && sz.charAt(ich) == chDelim)
- {
- ich++;
- }
- if (ich == cch)
- ich = -1;
- return ich;
- }
- function BoilerPlate()
- {
- this._rgszFields = new Array();
- this._cfield = 0;
- }
- function BoilerPlate_Parse(szArgs)
- {
- szArgs += " ";
- var ichTag = 0;
- while (true)
- {
- ichTag = szArgs.indexOf("<", ichTag);
- if (-1 == ichTag)
- break;
- else
- {
- ichTag++;
- var ichNameEnd = szArgs.indexOf(" ", ichTag);
- var ichValueBegin = _NextToken(szArgs, ichNameEnd, " ");
- var ichValueEnd;
- if (szArgs.charAt(ichValueBegin) == '"')
- {
- ichValueBegin++;
-
- ichValueEnd = szArgs.indexOf('"', ichValueBegin);
- }
- else
- ichValueEnd = szArgs.indexOf(">", ichValueBegin);
- var szField = szArgs.substring(ichTag, ichNameEnd);
- var szValue = szArgs.substring(ichValueBegin, ichValueEnd);
- this._rgszFields[szField.toLowerCase()] = szValue;
- this._cfield++;
- ichTag = ichValueEnd;
- }
- }
- }
- function BoilerPlate_Get(szFieldName)
- {
- var szValue = this._rgszFields[szFieldName.toLowerCase()];
- if ("" == szValue || "undefined" == typeof szValue)
- return null;
- return szValue;
- }
- function BoilerPlate_Length()
- {
- return this._cfield;
- }
- function _FindParentRow(elem)
- {
- var trLast = null;
- while (elem)
- {
- if ("TR" == elem.tagName.toUpperCase())
- return elem;
- elem = elem.parentElement;
- }
- return null;
- }
- function BoilerPlate_Apply()
- {
- var i;
- for (i = document.all.length - 1; i >= 0; i--)
- {
- var elem = document.all.item(i);
- var szField;
- var bDeleteRow = false;
- var bIsElemMarked = false;
- var bHideElem = false;
- if (null != elem._bpInnerText)
- {
- szField = this.Get(elem._bpInnerText);
- if (null == szField)
- {
- bDeleteRow = true;
- bHideElem = true;
- szField = "n/a";
- }
- elem.innerText = szField;
- bIsElemMarked = true;
- }
- if (null != elem._bpHref && "A" == elem.tagName)
- {
- szField = this.Get(elem._bpHref);
- bHideElem = false;
- if (null != szField &&
- ("http:" == szField.substring(0, 5) ||
- "https:" == szField.substring(0, 6) ||
- "file:" == szField.substring(0, 5) ||
- "ftp:" == szField.substring(0, 4)))
- {
- elem.href = szField;
- if ("n/a" == elem.innerText)
- {
- elem.innerText = elem.href;
- }
- if (elem.href != elem.innerText)
- {
- elem.title = elem.href;
- }
- bDeleteRow = false;
- }
- else
- {
- elem.style.color = document.fgColor;
- }
- bIsElemMarked = true;
- if ("n/a" == szField)
- bHideElem = true;
- }
- if (null != elem._bpValue)
- {
- elem._bpVar = this.Get(elem._bpValue);
- bIsElemMarked = true;
- }
- if (null != elem._bpNop && null == this.Get(elem._bpNop))
- {
- bHideElem = true;
- }
- if (bHideElem)
- {
- elem.style.display = 'none';
- }
- if (bIsElemMarked)
- {
- var trElem = _FindParentRow(elem);
- if (trElem && false != trElem._bpDelete)
- {
- trElem._bpDelete = bDeleteRow;
- }
- }
- }
- var rgrows = document.all.tags("TR");
- for (i = rgrows.length - 1; i >= 0; i--)
- {
- var trElem = rgrows[i];
- if (trElem && trElem._bpDelete)
- {
- var tbl = trElem.parentElement;
- tbl.deleteRow(trElem.rowIndex);
- }
- }
- }
- function InitBoilerPlateClass()
- {
- new BoilerPlate(null);
- BoilerPlate.prototype.Parse = BoilerPlate_Parse;
- BoilerPlate.prototype.Get = BoilerPlate_Get;
- BoilerPlate.prototype.Length = BoilerPlate_Length;
- BoilerPlate.prototype.Apply = BoilerPlate_Apply;
- }
-