/**
* This file is a component of FREE SOFTWARE / LIBRARY.
*
* Any entity with self-awareness, or organization are allowed to use, modify or
* redistribute this according to "GNU Lesser General Public License" v2.1.
*
* The goal of this distribution is that this software being useful and useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
/**
* A pack of tool functions for miscellaneous operations.
*
* @author Typhoon.Free.Wolf
* @version 2015-08-15_00-50.victory_day
*/
var COLOR_BLACK = '#000000';
var COLOR_DARK_GRAY = '#3F3F3F';
var COLOR_GRAY = '#7F7F7F';
var COLOR_LIGHT_GRAY = '#BFBFBF';
var COLOR_WHITE = '#FFFFFF';
var COLOR_DARK_RED = '#7F0000';
var COLOR_RED = '#FF0000';
var COLOR_LIGHT_RED = '#FF7F7F';
var COLOR_DARK_GREEN = '#007F00';
var COLOR_GREEN = '#00FF00';
var COLOR_LIGHT_GREEN = '#7FFF7F';
var COLOR_DARK_BLUE = '#00007F';
var COLOR_BLUE = '#0000FF';
var COLOR_LIGHT_BLUE = '#7F7FFF';
var COLOR_DARK_YELLOW = '#7F7F00';
var COLOR_YELLOW = '#FFFF00';
var COLOR_LIGHT_YELLOW = '#FFFF7F';
var COLOR_NORMAL_BACKGROUND = COLOR_WHITE;
var COLOR_NORMAL_BACKGROUND_DISABLED = COLOR_LIGHT_GRAY;
var COLOR_NORMAL = COLOR_BLACK;
var COLOR_NORMAL_DISABLED = COLOR_DARK_GRAY;
var COLOR_OK_BACKGROUND = COLOR_LIGHT_GREEN;
var COLOR_OK_BACKGROUND_DISABLED = COLOR_LIGHT_GRAY;
var COLOR_OK = COLOR_DARK_GREEN;
var COLOR_OK_DISABLED = COLOR_DARK_GREEN;
var COLOR_PARTLY_BACKGROUND = COLOR_LIGHT_YELLOW;
var COLOR_PARTLY_BACKGROUND_DISABLED = COLOR_LIGHT_GRAY;
var COLOR_PARTLY = COLOR_DARK_YELLOW;
var COLOR_PARTLY_DISABLED = COLOR_DARK_YELLOW;
var COLOR_FAILED_BACKGROUND = COLOR_LIGHT_RED;
var COLOR_FAILED_BACKGROUND_DISABLED = COLOR_LIGHT_GRAY;
var COLOR_FAILED = COLOR_DARK_RED;
var COLOR_FAILED_DISABLED = COLOR_DARK_RED;
var COLOR_ERROR_BACKGROUND = COLOR_RED;
var COLOR_ERROR_BACKGROUND_DISABLED = COLOR_RED;
var COLOR_ERROR = COLOR_WHITE;
var COLOR_ERROR_DISABLED = COLOR_LIGHT_RED;
// Self-exam:
// ----------------------------------------
/**
* A test function, just test wheather this script been loaded.
*
* @author Typhoon.Free.Wolf
* @version 2012-09-12_10-32
*/
function javascript_function()
{
alert('function javascript_function()\n{\n\t...\n}\n');
}
// Type judgment:
// ----------------------------------------
/**
* Judges whether the incoming thing is an array.
*
* @author Typhoon.Free.Wolf
* @version 2015-03-20_17-34
* @param objIn
* - The incoming variable.
* @return A boolean flag: true (is array) or false (not array).
*/
function isArray(objIn)
{
if (null == objIn) { return false; }
// alert(typeof objIn);
return ('object' == typeof objIn) && Array == objIn.constructor;
}
/**
* Judges whether the incoming thing is a date.
*
* @author Typhoon.Free.Wolf
* @version 2015-03-20_17-58
* @param objIn
* - The incoming variable.
* @return A boolean flag: true (is date) or false (not date).
*/
function isDate(objIn)
{
if (null == objIn) { return false; }
// alert(typeof objIn);
return ('object' == typeof objIn) && Date == objIn.constructor;
}
/**
* Judges whether the incoming thing is a DOM.
*
* @author Typhoon.Free.Wolf
* @version 2015-04-03_11-42
* @param objIn
* - The incoming variable.
* @return A boolean flag: true (is DOM) or false (not DOM).
*/
function isDom(objIn)
{
if (null == objIn) { return false; }
try
{
objIn.cloneNode(true);
if (1 == objIn.nodeType || 9 == objIn.nodeType)
{
return true;
}
else
{
return false;
}
}
catch(e)
{
return false;
}
}
/**
* Judges whether the incoming thing is a function.
*
* @author Typhoon.Free.Wolf
* @version 2015-03-20_18-02
* @param objIn
* - The incoming variable.
* @return A boolean flag: true (is function) or false (not function).
*/
function isFunction(objIn)
{
// Seems not necessary?
// if (null == objIn) { return false; }
// alert(typeof objIn);
return ('function' == typeof objIn) && Function == objIn.constructor;
}
/**
* Judges whether the incoming thing is a number.
*
* @author Typhoon.Free.Wolf
* @version 2015-03-20_21-08
* @param objIn
* - The incoming variable.
* @return A boolean flag: true (is number) or false (not number).
*/
function isNumber(objIn)
{
// Seems not necessary?
// if (null == objIn) { return false; }
// alert(typeof objIn);
if (isNaN(objIn)) { return false; }
return ('number' == typeof objIn) && Number == objIn.constructor;
}
/**
* Judges whether the incoming thing is a text string.
*
* @author Typhoon.Free.Wolf
* @version 2015-03-20_17-32
* @param objIn
* - The incoming variable.
* @return A boolean flag: true (is text) or false (not text).
*/
function isText(objIn)
{
// Seems not necessary?
// if (null == objIn) { return false; }
// alert(typeof objIn);
return ('string' == typeof objIn) && String == objIn.constructor;
}
/**
* Judges whether the incoming thing is constructed as an object.
*
* @author Typhoon.Free.Wolf
* @version 2015-03-20_18-10
* @param objIn
* - The incoming variable.
* @return A boolean flag: true (is constructed as object)
* or false (not constructed as object).
*/
function isConstructedAsObject(objIn)
{
if (null == objIn) { return false; }
// alert(typeof objIn);
return ('object' == typeof objIn) && Object == objIn.constructor;
}
// Type convertion:
// ----------------------------------------
/**
* Parses an object into a text string.
*
* @author Typhoon.Free.Wolf
* @version 2015-03-20_20-42
* @param objIn
* - The incoming variable.
* @param strNullReplacement
* - Replacement, while the incoming thing is null.
* @return A string representation of the object.
*/
function o2s(objIn, strNullReplacement)
{
if (null == objIn)
{
if (null == strNullReplacement) { return null; }
else
{
// Needs to fix the type of replacement in JAVASCRIPT.
return o2s(strNullReplacement, null);
}
}
if (isText(objIn)) { return objIn; }
else { return objIn + ''; }
}
/**
* Generates an integer number from an object.
*
* @author Typhoon.Free.Wolf
* @version 2015-03-20_21-12
* @param objIn
* - The incoming variable.
* @param intReplacement
* - Replacement, while the incoming thing is null, or unable to
* parse.
* @return Generated number.
*/
function o2i(objIn, intReplacement)
{
var strValue = o2s(objIn, null);
if (null == strValue)
{
if (null == intReplacement) { return null; }
else
{
// Needs to fix the type of replacement in JAVASCRIPT.
return o2i(intReplacement, null);
}
}
var intValue = parseInt(strValue);
if (isNumber(intValue)) { return intValue; }
{
if (null == intReplacement) { return null; }
else
{
// Needs to fix the type of replacement in JAVASCRIPT.
return o2i(intReplacement, null);
}
}
}
/**
* Generates an float number from an object.
*
* @author Typhoon.Free.Wolf
* @version 2015-03-20_21-42
* @param objIn
* - The incoming variable.
* @param fltReplacement
* - Replacement, while the incoming thing is null, or unable to
* parse.
* @return Generated number.
*/
function o2f(objIn, fltReplacement)
{
var strValue = o2s(objIn, null);
if (null == strValue)
{
if (null == fltReplacement) { return null; }
else
{
// Needs to fix the type of replacement in JAVASCRIPT.
return o2f(fltReplacement, null);
}
}
var fltValue = parseFloat(strValue);
if (isNumber(fltValue)) { return fltValue; }
{
if (null == fltReplacement) { return null; }
else
{
// Needs to fix the type of replacement in JAVASCRIPT.
return o2f(fltReplacement, null);
}
}
}
/**
* Returns the given DOM element, or gets one according to the text according
* to the given object.
*
* @author Typhoon.Free.Wolf
* @version 2015-03-30_20-17
* @param objIn
* - The incoming DOM element, or a random-typed object.
* @return The given DOM element, or gets one according to the text according
* to the given object; could be null.
*/
function o2dom(objIn)
{
if (null == objIn)
{
return null;
}
if (isDom(objIn))
{
return objIn;
}
var strElementId = o2s(objIn);
var domElement = document.getElementById(strElementId);
return domElement;
}
/**
* Returns the meta information of the given DOM element; or gets one DOM
* element according to the text according, and then gets its meta
* information.
*
* @author Typhoon.Free.Wolf
* @version 2015-03-30_20-44
* @param objIn
* - The incoming DOM element, or a random-typed object.
* @return An array of meta information as [ element, tag_name, type];
* could be null.
*/
function o2domMeta(objIn)
{
var obj1dMeta = [ null, null, null ];
var domElement = o2dom(objIn);
if (null == domElement)
{
return obj1dMeta;
}
obj1dMeta[0] = domElement;
var strTagName = domElement.tagName;
if (null != strTagName)
{
strTagName = strTagName.toLowerCase();
}
obj1dMeta[1] = strTagName;
var strType = domElement.type;
if (null != strType)
{
strType = strType.toLowerCase();
}
obj1dMeta[2] = strType;
return obj1dMeta;
}
// DOM value(s) and contents assignment:
// --------------------------------
/**
* Fills the given DOM element with the given contents.
*
* @author Typhoon.Free.Wolf
* @version 2014-03-31_21-42
* @param domElement
* - The target DOM element.
* @param objContents
* - The contents to be filled into the target.
* @return A boolean flag: true = done; false = failed.
*/
function fillElement(domElement, objContents)
{
// [S] Fast fail.
var blStat = false;
var obj1dMeta = o2domMeta(domElement);
domElement = obj1dMeta[0];
if (null == domElement)
{
return blStat;
}
var strTagName = obj1dMeta[1];
var strType = obj1dMeta[2];
// [E] Fast fail.
// [S] Setting value(s).
if (('input' == strTagName && 'button' == strType)
|| ('input' == strTagName && 'checkbox' == strType)
|| ('input' == strTagName && 'reset' == strType)
|| ('input' == strTagName && 'radio' == strType)
|| ('input' == strTagName && 'submit' == strType)
|| ('input' == strTagName && 'text' == strType)
|| ('select' == strTagName && 'select-one' == strType)
|| ('select' == strTagName && 'select-multiple' == strType)
|| ('textarea' == strTagName && 'textarea' == strType))
{
blStat = setValue(domElement, objContents);
}
// [E] Setting value(s).
// [S] Filling inner HTML.
else
{
blStat = setInnerHTML(domElement, objContents);
}
// [E] Filling inner HTML.
return blStat;
}
/**
* Sets the given value(s) to the given DOM element.
*
* @author Typhoon.Free.Wolf
* @version 2014-03-30_22-24
* @param domElement
* - The target DOM element.
* @param objValue
* - The value(s) to be set to the target.
* @return A boolean flag: true = done; false = failed.
*/
function setValue(domElement, objValue)
{
// [S] Fast fail.
var blStat = false;
var obj1dMeta = o2domMeta(domElement);
domElement = obj1dMeta[0];
if (null == domElement)
{
return blStat;
}
var strTagName = obj1dMeta[1];
var strType = obj1dMeta[2];
// [E] Fast fail.
// [S] Setting single value.
if (('input' == strTagName && 'button' == strType)
|| ('input' == strTagName && 'checkbox' == strType)
|| ('input' == strTagName && 'reset' == strType)
|| ('input' == strTagName && 'radio' == strType)
|| ('input' == strTagName && 'submit' == strType)
|| ('input' == strTagName && 'text' == strType)
|| ('select' == strTagName && 'select-one' == strType)
|| ('textarea' == strTagName && 'textarea' == strType))
{
blStat = setSingleValue(domElement, objValue);
}
// [E] Setting single value.
// [S] Setting multiple values.
else if ('select' == strTagName && 'select-multiple' == strType)
{
blStat = setMultipleValues(domElement, objValue);
}
// [E] Setting multiple values.
return blStat;
}
/**
* Sets a single value to the given DOM element.
*
* @author Typhoon.Free.Wolf
* @version 2014-03-30_21-54
* @param domElement
* - The target DOM element.
* @param strValue
* - The value be set to the target.
* @return A boolean flag: true = done; false = failed.
*/
function setSingleValue(domElement, strValue)
{
// [S] Fast fail.
var blStat = false;
var obj1dMeta = o2domMeta(domElement);
var domElement = obj1dMeta[0];
if (null == domElement)
{
return blStat;
}
var strTagName = obj1dMeta[1];
var strType = obj1dMeta[2];
// [E] Fast fail.
// Confirming value type.
strValue = o2s(strValue);
// [S] General setting.
if (('input' == strTagName && 'button' == strType)
|| ('input' == strTagName && 'checkbox' == strType)
|| ('input' == strTagName && 'reset' == strType)
|| ('input' == strTagName && 'radio' == strType)
|| ('input' == strTagName && 'submit' == strType)
|| ('input' == strTagName && 'text' == strType)
|| ('textarea' == strTagName && 'textarea' == strType))
{
domElement.value = strValue;
}
// [E] General setting.
// [S] Select setting.
else if ('select' == strTagName && 'select-one' == strType)
{
// Firefox accepts this:
// ----------------------------------------
// domElement.value = strValue;
// But IE6 prefers this:
// ----------------------------------------
var option1d = domElement.getElementsByTagName('option');
if (null != option1d && 0 < option1d.length)
{
var intOptionLength = option1d.length;
for (var intOptionIdx = 0; intOptionIdx < intOptionLength; intOptionIdx++)
{
if (strValue == option1d[intOptionIdx].value)
{
option1d[intOptionIdx].selected = 'selected';
}
else
{
option1d[intOptionIdx].selected = null;
}
}
}
}
// [S] Select setting.
return blStat;
}
/**
* Sets multiple values to the given DOM element.
*
* @author Typhoon.Free.Wolf
* @version 2014-03-30_22-44
* @param domElement
* - The target DOM element.
* @param obj1dValues
* - The values be set to the target.
* @return A boolean flag: true = done; false = failed.
*/
function setMultipleValues(domElement, obj1dValues)
{
// [S] Fast fail.
var blStat = false;
var obj1dMeta = o2domMeta(domElement);
domElement = obj1dMeta[0];
if (null == domElement)
{
return blStat;
}
var strTagName = obj1dMeta[1];
var strType = obj1dMeta[2];
// [E] Fast fail.
// [S] Confirming value type.
obj1dValues = isArray(obj1dValues) ? obj1dValues : [ obj1dValues ];
var str1dValues = new Array();
var intValueIdx;
for (intValueIdx = 0; intValueIdx < obj1dValues.length; intValueIdx++)
{
str1dValues.push(o2s(obj1dValues[intValueIdx]));
}
// [E] Confirming value type.
// [S] Select setting.
if ('select' == strTagName && 'select-multiple' == strType)
{
var option1d = domElement.getElementsByTagName('option');
if (null != option1d && 0 < option1d.length)
{
var intOptionLength = option1d.length;
var intValueLength = str1dValues.length;
for (var intOptionIdx = 0; intOptionIdx < intOptionLength; intOptionIdx++)
{
option1d[intOptionIdx].selected = null;
for (intValueIdx = 0; intValueIdx < intValueLength; intValueIdx++)
{
var strValue = str1dValues[intValueIdx];
if (strValue == option1d[intOptionIdx].value)
{
option1d[intOptionIdx].selected = 'selected';
continue;
}
}
}
}
}
// [S] Select setting.
return blStat;
}
/**
* Sets the inner HTML to the given DOM element.
*
* @author Typhoon.Free.Wolf
* @version 2014-03-31_21-42
* @param domElement
* - The target DOM element.
* @param strInnerHTML
* - The contents be set to the target.
* @return A boolean flag: true = done; false = failed.
*/
function setInnerHTML(domElement, strInnerHTML)
{
// [S] Fast fail.
domElement = o2dom(domElement);
if (null == domElement)
{
return false;
}
// [E] Fast fail.
domElement.innerHTML = o2s(strInnerHTML)
return true;
}
/**
* Gets a single value from a DOM element.
*
* @author Typhoon.Free.Wolf
* @version 2014-03-30_20-18
* @param domElement
* - Target DOM element.
* @return The single value of target DOM element.
*/
function getSingleValue(domElement)
{
domElement = o2dom(domElement);
return (null == domElement) ? null : domElement.value;
}
// Text manipulation:
// ----------------------------------------
/**
* Calculates the length of a text string by byte.
*
* @author Typhoon.Free.Wolf
* @version 2015-04-03_11-42
* @param strIn
* - Incoming text string.
* @return The length by byte.
*/
function calculateByteLength(strIn)
{
var blDebugFlag = false;
var strFuncName = 'calculateByteLength(\'' + strIn + '\')';
if (blDebugFlag) { alert('[S] ' + strFuncName); }
// [S] Fast checking.
strIn = o2s(strIn, null);
if (null == strIn || 1 > strIn.length)
{
if (blDebugFlag) { alert('TFW: Fast checking failed.'); }
if (blDebugFlag) { alert('[E] ' + strFuncName); }
return 0;
}
// [E] Fast checking.
// [S] Calculating byte length.
var intByteLength = 0;
var intStrLength = strIn.length;
if (blDebugFlag) { alert('TFW: intStrLength=[' + intStrLength + ']'); }
for (var intIdx = 0; intStrLength > intIdx; intIdx++)
{
var strChar = strIn.charAt(intIdx);
if (blDebugFlag)
{ alert('TFW: strIn.charAt(' + intIdx + ')=[' + strChar + ']'); }
var strEscaped = escape(strChar);
if (blDebugFlag)
{ alert('TFW: escape(strIn.charAt(' + intIdx + '))=[' + strEscaped
+ ']'); }
if ('%u' == strEscaped.substr(0, 2))
{
intByteLength = intByteLength + 2;
}
else
{
intByteLength++;
}
}
if (blDebugFlag) { alert('TFW: intByteLength=' + intByteLength); }
// [E] Calculating byte length.
if (blDebugFlag) { alert('[E] ' + strFuncName); }
return intByteLength;
}
/**
* Escapes a string by javascript function "encodeURI(...)", and then escapes
* "+" to "%2B".
*
* @author Typhoon.Free.Wolf
* @version 2015-04-03_11-42
* @param strIn
* - Incoming string.
* @return The escaped string.
*/
function encodeURI_(strIn)
{
strIn = o2s(strIn, null);
if (null != strIn)
{
strIn = encodeURI(strIn);
strIn = strIn.replace(/\+/g, '%2B');
}
return strIn;
}
/**
* Escapes a string by javascript function "encodeURIComponent_(...)", and then
* escapes "+" to "%2B".
*
* @author Typhoon.Free.Wolf
* @version 2015-04-03_11-42
* @param strIn
* - Incoming string.
* @return The escapes string.
*/
function encodeURIComponent_(strIn)
{
strIn = o2s(strIn, null);
if (null != strIn)
{
strIn = encodeURIComponent(strIn);
strIn = strIn.replace(/\+/g, '%2B');
}
return strIn;
}
/**
* Escapes a string by javascript function "escape(...)", and then escapes "+"
* to "%2B".
*
* @author Typhoon.Free.Wolf
* @version 2015-04-03_11-42
* @param strIn
* - Incoming string.
* @return The escapes string.
*/
function escape_(strIn)
{
strIn = o2s(strIn, null);
if (null != strIn)
{
strIn = escape(strIn);
strIn = strIn.replace(/\+/g, '%2B');
}
return strIn;
}
/**
* Trims the "white spaces" from both sides of the giving string.
*
* @author Typhoon.Free.Wolf
* @version 2012-09-08_22-38
* @param strIn
* - Incoming string.
* @return Trimmed string.
*/
function trim(strIn)
{
return trimRight(trimLeft(strIn));
}
/**
* Trims the "white spaces" from the left side of the giving string.
*
* @author Typhoon.Free.Wolf
* @version 2015-04-03_11-42
* @param strIn
* - Incoming string.
* @return Trimmed string.
*/
function trimLeft(strIn)
{
var blDebugFlag = false;
var strFuncName = 'trimLeft(\'' + strIn + '\')';
if (blDebugFlag) { alert('[S] ' + strFuncName); }
// [S] Fast checking.
strIn = o2s(strIn, null);
var intStrLength = (null == strIn) ? 0 : strIn.length;
if (1 > intStrLength)
{
if (blDebugFlag) { alert('TFW: Fast checking failed.'); }
if (blDebugFlag) { alert('[E] ' + strFuncName); }
return strIn;
}
// [E] Fast checking.
// [S] Calculating "white space" from left.
var intLengthToTrim = 0;
var strWhiteSpaces
= ' \b\n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000';
for (var intIdx = 0; intStrLength > intIdx; intIdx++)
{
var strChar = strIn.charAt(intIdx);
if (blDebugFlag)
{ alert('TFW: strIn.charAt(' + intIdx + ')=[' + strChar + ']'); }
if (0 <= strWhiteSpaces.indexOf(strChar))
{
// Found this character in "white spaces".
intLengthToTrim++;
}
else
{
if (blDebugFlag)
{ alert('TFW: intLengthToTrim=' + intLengthToTrim + ''); }
break;
}
}
// [E] Calculating "white space" from left.
// [S] Trimming.
var strOut = (1 > intLengthToTrim) ? strIn
: strIn.substring(intLengthToTrim, intStrLength);
if (blDebugFlag) { alert('TFW: strOut=[' + strOut + ']'); }
// [E] Trimming.
if (blDebugFlag) { alert('[E] ' + strFuncName); }
return strOut;
}
/**
* Trims the "white spaces" from the left side of the giving string.
*
* @author Typhoon.Free.Wolf
* @version 2015-04-03_11-42
* @param strIn
* - Incoming string.
* @return Trimmed string.
*/
function trimRight(strIn)
{
var blDebugFlag = false;
var strFuncName = 'trimRight(\'' + strIn + '\')';
if (blDebugFlag) { alert('[S] ' + strFuncName); }
// [S] Fast checking.
strIn = o2s(strIn, null);
var intStrLength = (null == strIn) ? 0 : strIn.length;
if (1 > intStrLength)
{
if (blDebugFlag) { alert('TFW: Fast checking failed.'); }
if (blDebugFlag) { alert('[E] ' + strFuncName); }
return strIn;
}
// [E] Fast checking.
// [S] Calculating "white space" from right.
var intLengthToTrim = 0;
var strWhiteSpaces
= ' \b\n\r\t\f\x0b\xa0\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u200b\u2028\u2029\u3000';
for (var intIdx = (intStrLength - 1); 0 <= intIdx; intIdx--)
{
var strChar = strIn.charAt(intIdx);
if (blDebugFlag)
{ alert('TFW: strIn.charAt(' + intIdx + ')=[' + strChar + ']'); }
if (0 <= strWhiteSpaces.indexOf(strChar))
{
// Found this character in "white spaces".
intLengthToTrim++;
}
else
{
if (blDebugFlag)
{ alert('TFW: intLengthToTrim=' + intLengthToTrim + ''); }
break;
}
}
// [E] Calculating "white space" from right.
// [S] Trimming.
var strOut = (1 > intLengthToTrim) ? strIn
: strIn.substring(0, (intStrLength - intLengthToTrim));
if (blDebugFlag) { alert('TFW: strOut=[' + strOut + ']'); }
// [E] Trimming.
if (blDebugFlag) { alert('[E] ' + strFuncName); }
return strOut;
}
// Miscellaneous:
// ----------------------------------------
/**
* Replaces some sensitive character for the display on the page.
*
* @author Typhoon.Free.Wolf
* @version 2015-04-03_15-23
* @param sbIn
* - Incoming text to be processed.
*/
function pageSafe(strIn)
{
strIn = o2s(strIn, null);
if (null != strIn && 0 < strIn.length)
{
strIn = strIn.replace(/&/g, '&');
strIn = strIn.replace(//g, '>');
strIn = strIn.replace(/\"/g, '"');
// IE6 may not support this!
// strIn = strIn.replace(/\'/g, ''');
}
return strIn;
}