-------------------------------------------------------------------------------- Documentation home page COAL.packages.library.cflib Component strlib library.cflib.strlib -------------------------------------------------------------------------------- Method Summary public any chrex(string value, [string charset=""], [numeric radix="16"]) public numeric httpDate([date theDate="#Now()#"]) Format a date as required by HTTP specifications public string naughtyFilter(string body, [any replaceType="all"], [any repeatValue="*"], [any naughtyList="mother fucker,cocksucker,shit,piss,fuck,cunt,tits"], [any replaceString="!@##$%^&*()!@##$%^&*()!@##$%^&*"]) Replaces unmentionables with gobbledegook public struct reFindAll(string regex, string text) public struct reFindNoCaseAll(string regex, string text) Method Detail chrex public any chrex(string value, [string charset=""], [numeric radix="16"]) Parameters: string value [string charset=""] [numeric radix="16"] Code: -------------------------------------------------------------------------------- httpDate public numeric httpDate([date theDate="#Now()#"]) Format a date as required by HTTP specifications Parameters: [date theDate="#Now()#"] - Date to format, default to Now() Code: -------------------------------------------------------------------------------- naughtyFilter public string naughtyFilter(string body, [any replaceType="all"], [any repeatValue="*"], [any naughtyList="mother fucker,cocksucker,shit,piss,fuck,cunt,tits"], [any replaceString="!@##$%^&*()!@##$%^&*()!@##$%^&*"]) Replaces unmentionables with gobbledegook Parameters: string body - Contains text to filter [any replaceType="all"] - ALL - all characters, FL - only the middle bits are replaced [any repeatValue="*"] - Character to repeat for replaced dirty characters [any naughtyList="mother fucker,cocksucker,shit,piss,fuck,cunt,tits"] - George Carlin's original 7 dirty words, not in his original order, but the longest listed first [any replaceString="!@##$%^&*()!@##$%^&*()!@##$%^&*"] - A replace string for ALL method, length must be at least as long as the longest dirty word Code: -------------------------------------------------------------------------------- reFindAll public struct reFindAll(string regex, string text) Parameters: string regex string text Code: -------------------------------------------------------------------------------- reFindNoCaseAll public struct reFindNoCaseAll(string regex, string text) Parameters: string regex string text Code: -------------------------------------------------------------------------------- Full Component Code: /** * Abbreviates a given string to roughly the given length, stripping any tags, making sure the ending doesn't chop a word in two, and adding an ellipsis character at the end. * * @param string String to use. (Required) * @param len Length to use. (Required) * @return Returns a string. * @author Gyrus (gyrus@norlonto.net) * @version 1, August 25, 2004 */ function abbreviate(string,len) { var newString = REReplace(string, "]*>", "", "ALL"); var lastSpace = 0; if (Len(string) GT len) { newString = Left(newString, len); lastSpace = Find(" ", Reverse(newString)); lastSpace = Len(newString) - lastSpace; newString = Left(newString, lastSpace) & " &##8230;"; } return newString; } /** * This turns a Microsoft Access hyperlink field into a standard URL. * * @param strval Variable containing the MS Access link you want to 'clean'. * @return Returns a string. * @author Mark Andrachek (hallow@webmages.com) * @version 1, January 3, 2002 */ function AccessLinkClean(strval) { return Mid(strval,2,Len(strval)-2); } /** * Strip pattern-matching wildcards from a string appearing in an Access query. * Modded list order (rkc 8/14/02) * * @param string The string to format. (Required) * @return Returns a string. * @author Matthew Walker (matthew@cabbagetree.co.nz) * @version 2, August 14, 2002 */ function AccessPatternMatchingFormat(string) { return ReplaceList(string, "[,%,_,##", "[[],[%],[_],[##]"); } /** * This function takes URLs in a text string and turns them into links. * Version 2 by Lucas Sherwood, lucas@thebitbucket.net. * Version 3 Updated to allow for ; * * @param string Text to parse. (Required) * @param target Optional target for links. Defaults to "". (Optional) * @param paragraph Optionally add paragraphFormat to returned string. (Optional) * @return Returns a string. * @author Joel Mueller (jmueller@swiftk.com) * @version 3, August 11, 2004 */ function ActivateURL(string) { var nextMatch = 1; var objMatch = ""; var outstring = ""; var thisURL = ""; var thisLink = ""; var target = IIf(arrayLen(arguments) gte 2, "arguments[2]", DE("")); var paragraph = IIf(arrayLen(arguments) gte 3, "arguments[3]", DE("false")); do { objMatch = REFindNoCase("(((https?:|ftp:|gopher:)\/\/)|(www\.|ftp\.))[-[:alnum:]\?%,\.\/&##!;@:=\+~_]+[A-Za-z0-9\/]", string, nextMatch, true); if (objMatch.pos[1] GT nextMatch OR objMatch.pos[1] EQ nextMatch) { outString = outString & Mid(String, nextMatch, objMatch.pos[1] - nextMatch); } else { outString = outString & Mid(String, nextMatch, Len(string)); } nextMatch = objMatch.pos[1] + objMatch.len[1]; if (ArrayLen(objMatch.pos) GT 1) { // If the preceding character is an @, assume this is an e-mail address // (for addresses like admin@ftp.cdrom.com) if (Compare(Mid(String, Max(objMatch.pos[1] - 1, 1), 1), "@") NEQ 0) { thisURL = Mid(String, objMatch.pos[1], objMatch.len[1]); thisLink = "" & thisURL & ""; outString = outString & thisLink; // String = Replace(String, thisURL, thisLink); // nextMatch = nextMatch + Len(thisURL); } else { outString = outString & Mid(String, objMatch.pos[1], objMatch.len[1]); } } } while (nextMatch GT 0); // Now turn e-mail addresses into mailto: links. outString = REReplace(outString, "([[:alnum:]_\.\-]+@([[:alnum:]_\.\-]+\.)+[[:alpha:]]{2,4})", "\1", "ALL"); if (paragraph) { outString = ParagraphFormat(outString); } return outString; } /** * Convert ASCII characters into a decimal number. * Removed evaluate * * @param string String to format. (Required) * @param order Byte order (i for Intel or m for Motorola) (Optional) * @param signed Process signed integers normally or in two's complement notation. Values are false (process normally), true (signed), and tcn (2's complement notation) (Optional) * @return Returns a string. * @author Evan Keller (coldfusion@evankeller.com) * @version 2, January 2, 2003 */ function AsciiToDec(string) { var order="i"; //Optional arrtibute: Byte Order //"i"= Intel (default) //"m"= Motorola var signed=false; //Optional attribute: Signed //false= unsigned (default) //true= signed //"tcn"= 2's Complement Notation var result=0; var i=0; if (ArrayLen(arguments) gt 1) { order = arguments[2]; } if (ArrayLen(arguments) gt 2) { signed = arguments[3]; } for (i=1; i LTE len(string)+1; i=i+1) { if (order is "i") { result = result + (asc(mid(string, i, 1)) * 256^(i-1)); } if (order is "m") { result = result + (asc(mid(string, i, 1)) * 256^(len(string)-i)); } } switch (signed) { case true: if (len(string) is 0) { //If the string is "0" the length is calculated as zero, //which throws things off, we set the string to " " so //it has a length of one. string = " "; } result = result - 256^len(string)/2; case "tcn": if (result GTE 256^len(string)/2) { result = result - 256^len(string); } default: result = result; } return result; } /** * Returns a negative number in brackets. * * @param myNum Number to format. (Required) * @return Returns a string. * @author Andrew Peterson (webmaster@mail.ioc.state.il.us) * @version 1, August 26, 2002 */ function BracketNumberFormat(myNum) { if(myNum eq "") { return 0; } else { if(myNum lt 0) { return '(' & numberformat(right(myNum, len(myNum)-1)) & ')'; } else { return numberFormat(myNum); } } } /** * Works like the built-in function lsCurrencyFormat, but do it right for Brazilian Currency (R$ - Real). * * @param valor Number to be formatted. (Required) * @return Returns a string. * @author Fernando Segalla (segalla@intralab.com.br) * @version 1, November 1, 2002 */ function BRCurrencyFormat(valor) { valor = DecimalFormat(valor); valor = Replace(valor,',','.','ALL'); valor = Reverse(Replace(Reverse(valor),'.',',','ONE')); if(valor LT 0) return "(R$" & Right(valor,Len(valor)-1) & ")"; else return "R$" & valor; } /** * Creates a bread crumb trail based on your sites sirectory structure. * * @return Returns a string. * @author Jon Lesser (jdl1101@rit.edu) * @version 1, February 14, 2005 */ function breadCrumb() { var baseLink = "/"; var delimiter = " > "; var crumbs = "Home" & delimiter; var breadCrumbArray = listToArray(replace(cgi.script_name, "_", " ", "all") , "/"); var i = 1; for(i=1; i lt arrayLen(breadCrumbArray); i=i+1) { baseLink = baseLink & replace(breadCrumbArray[i], " ", "_", "all") & "/"; if(i lt ArrayLen(breadCrumbArray)-1) crumbs = crumbs & "" & capFirstTitle(breadCrumbArray[i]) & "" & delimiter; else crumbs = crumbs & capFirstTitle(breadCrumbArray[i]); } return crumbs; } /** * Generates a byline from a list of names. * * @param names List of Names. (Required) * @param editors Boolean signifying that the list is a list of editors. Defaults to false. (Optional) * @param extrasMode String signifying extrasMode to use. Currently "IMDB" is support. Defaults to "none". (Optional) * @return Returns a string. * @author Gyrus (gyrus@norlonto.net) * @version 1, October 10, 2002 */ function Byline(names) { // Initialise var i = 0; var name = ""; var bylineString = ""; var edited = FALSE; var extrasMode = "none"; if (ArrayLen(Arguments) GT 1) { edited = Arguments[2]; } if (ArrayLen(Arguments) GT 2) { extrasMode = Arguments[3]; } // Loop through names if (ListLen(names)) { for (i=1; i LTE ListLen(names); i=i+1) { name = ListGetAt(names, i); // Edited? if (edited) { name = "#name# (ed.)"; } // Perform extras switch (extrasMode) { case "imdb": { name = "#name#"; break; } } if (i EQ 1) { bylineString = "by #name#"; } else if (i EQ ListLen(names)) { bylineString = "#bylineString# & #name#"; } else { bylineString = "#bylineString#, #name#"; } } } return bylineString; } /** * Capitalizes the first letter in each word. * Made udf use strlen, rkc 3/12/02 * * @param string String to be modified. * @return Returns a string. * @author Raymond Camden (ray@camdenfamily.com) * @version 1.1, March 12, 2002 */ function CapFirst(str) { var newstr = ""; var word = ""; var i = 1; var strlen = listlen(str," "); for(i=1;i lte strlen;i=i+1) { word = ListGetAt(str,i," "); newstr = newstr & UCase(Left(word,1)); if(len(word) gt 1) newstr = newstr & Right(word,Len(word)-1); if(i lt strlen) newstr = newstr & " "; } return newstr; } /** * Returns a string with words capitalized for a title. * Modified by Ray Camden to include var statements. * * @param initText String to be modified. * @return Returns a string. * @author Ed Hodder (ed.hodder@bowne.com) * @version 2, July 27, 2001 */ function capFirstTitle(initText){ var Words = ""; var j = 1; var m = 1; var doCap = ""; var thisWord = ""; var excludeWords = ArrayNew(1); var outputString = ""; initText = LCASE(initText); //Words to never capitalize excludeWords[1] = "an"; excludeWords[2] = "the"; excludeWords[3] = "at"; excludeWords[4] = "by"; excludeWords[5] = "for"; excludeWords[6] = "of"; excludeWords[7] = "in"; excludeWords[8] = "up"; excludeWords[9] = "on"; excludeWords[10] = "to"; excludeWords[11] = "and"; excludeWords[12] = "as"; excludeWords[13] = "but"; excludeWords[14] = "if"; excludeWords[15] = "or"; excludeWords[16] = "nor"; excludeWords[17] = "a"; //Make each word in text an array variable Words = ListToArray(initText, " "); //Check words against exclude list for(j=1; j LTE (ArrayLen(Words)); j = j+1){ doCap = true; //Word must be less that four characters to be in the list of excluded words if(LEN(Words[j]) LT 4 ){ if(ListFind(ArrayToList(excludeWords,","),Words[j])){ doCap = false; } } //Capitalize hyphenated words if(ListLen(Words[j],"-") GT 1){ for(m=2; m LTE ListLen(Words[j], "-"); m=m+1){ thisWord = ListGetAt(Words[j], m, "-"); thisWord = UCase(Mid(thisWord,1, 1)) & Mid(thisWord,2, LEN(thisWord)-1); Words[j] = ListSetAt(Words[j], m, thisWord, "-"); } } //Automatically capitalize first and last words if(j eq 1 or j eq ArrayLen(Words)){ doCap = true; } //Capitalize qualifying words if(doCap){ Words[j] = UCase(Mid(Words[j],1, 1)) & Mid(Words[j],2, LEN(Words[j])-1); } } outputString = ArrayToList(Words, " "); return outputString; } /** * Convert cardinal number strings to ordinal number strings. * * @param cardinalString Cardinal string to format. (Required) * @return Returns a string. * @author Howard Fore (me@hofo.com) * @version 1, May 26, 2003 */ function CardinalToOrdinal(cardinalString) { var resultString = ""; // Generated result to return var lastCardinal = ""; // Last word in cardinal number string var TempNum = 0; // temp integer cardinalSpecialStrings = "One,one,Two,two,Three,three,Four,four,Five,five,Six,six,Eight,eight,Nine,nine,Twelve,twelve"; ordinalSpecialStrings = "First,first,Second,second,Third,third,Fourth,fourth,Fifth,fifth,Sixth,sixth,Eighth,eighth,Ninth,ninth,Twelfth,twelfth"; cardinalString = trim(cardinalString); lastCardinal = listLast(cardinalString," "); resultString = ListDeleteAt(cardinalString,ListLen(cardinalString," ")," "); // Is lastCardinal a special case? TempNum = listFindNoCase(cardinalSpecialStrings,lastCardinal); if (TempNum GT 0) { resultString = ListAppend(resultString,ListGetAt(ordinalSpecialStrings,TempNum)," "); } else { if (ListFindNoCase(Right(lastCardinal,2),"en")) { // Last word ends with "en", add "th" resultString = ListAppend(resultString,lastCardinal & "th"," "); } if (ListFindNoCase(Right(lastCardinal,1),"d")) { // Last word ends with "d", add "th" resultString = ListAppend(resultString,lastCardinal & "th"," "); } if (ListFindNoCase(Right(lastCardinal,1),"y")) { // Last word ends with "y", delete "y", add "ieth" resultString = ListAppend(resultString, Left(lastCardinal,Len(lastCardinal) - 1) & "ieth"," "); } if (ListFindNoCase(Right(lastCardinal,3),"ion")) { // Last word ends with "ion", add "th" resultString = ListAppend(resultString,lastCardinal & "th"," "); } } return resultString; } /** * Escapes a credit card number, showing only the last 4 digits. The other digits are replaced with the * character. * * @param ccnum Credit card number you want to escape. (Required) * @return Returns a string. * @author Joshua Miller (josh@joshuasmiller.com) * @version 1, September 20, 2004 */ function ccEscape(ccnum){ return "#RepeatString("*",val(Len(ccnum)-4))##Right(ccnum,4)#"; } /** * Proper capitalization for us Mc's and Mac's! * * @param lastName String to modify. (Required) * @return Returns a string. * @author Kyle McNamara (kyle@themacs.info) * @version 1, May 20, 2003 */ function celticMcCaps(lastName) { var capLastName = lCase(lastName); if (left(lastName,2) eq "Mc") { capLastName = uCase(left(lastName,1)) & lCase(mid(lastName,2,1)) & uCase(mid(lastName,3,1)) & lCase(right(lastName,len(lastName)-3)); return capLastName; } else if (left(lastName,3) eq "Mac") { capLastName = uCase(left(lastName,1)) & lCase(mid(lastName,2,1)) & lCase(mid(lastName,3,1)) & uCase(mid(lastName,4,1)) & lCase(right(lastName,len(lastName)-4)); return capLastName; } else return lastName; } /** * companion to jsstringformat - formats a string for use as a coldfusion literal value * * @param mystring String to format. (Required) * @return Returns a string. * @author Isaac Dealey (info@turnkey.to) * @version 1, May 9, 2003 */ function cfStringFormat(mystring) { var x = 0; var npc = ""; var npcc = ""; mystring = rereplacenocase(mystring,"(""|##)","\1\1","ALL"); for (x = 1; x lte 31; x = x + 1) { npc = listappend(npc,chr(x)); npcc = listappend(npcc,"##chr(#x#)##"); } return replacelist(mystring,npc,npcc); } /** * Returns the character at a certain position in a string. * * @param str String to be checked. * @param pos Position to get character from. * @return Returns a character. * @author Raymond Camden (ray@camdenfamily.com) * @version 1, December 3, 2001 */ function CharAt(str,pos) { return Mid(str,pos,1); } /** * Only allow ASCII text string. * * @param str String to check. (Required) * @param denylist Additional list of codes to deny. (Optional) * @return Returns a boolean. * @author Tjarko Rikkerink (tjarko@ditadres.com) * @version 1, September 23, 2004 */ function checkAsc(str){ var i = 1; var nr = ""; var denylist = ""; if(arrayLen(arguments) gte 2) denylist = arguments[2]; while (i LTE len(str)) { nr = asc(mid(str,i,1)); if (nr LT 33 OR nr GT 126 OR listFind(denylist,nr)){ return false; } i = i + 1; } return true; } /** * This UDF is an extensible, easy to use pattern validator using regular expressions. * Rewrites by rcamden. * * @param checkWhat Name of the pattern to use. (Required) * @param str String to check. (Required) * @return Returns a boolean. * @author Chris Chay (itadept@earthlink.net) * @version 2, January 15, 2003 */ function CheckPattern(checkWhat, str) { var rePattern=""; // Assign RE pattern to this variable switch (checkWhat){ case "isEmail": rePattern="^([\w\d\-\.]+)@{1}(([\w\d\-]{1,67})|([\w\d\-]+\.[\w\d\-]{1,67}))\.(([a-zA-Z\d]{2,4})(\.[a-zA-Z\d]{2})?)$"; break; case "isIP": rePattern="^(((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|0?[0-9]?[0-9])\.){3,3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|0?[0-9]?[0-9]))$"; break; case "isFloat": rePattern="^[-+]?\d*\.?\d*$"; break; case "isInteger": rePattern="^[+-]?\d+$"; break; case "isUSPhone": rePattern="^((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}$"; break; case "isUSCurrency": rePattern="^\$(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?$"; break; case "isDate": rePattern="^(?:(?:(?:0?[13578]|1[02])(\/|-|\.)31)\1|(?:(?:0?[1,3-9]|1[0-2])(\/|-|\.)(?:29|30)\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:0?2(\/|-|\.)29\3(?:(?:(?:1[6-9]|[2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00))))$|^(?:(?:0?[1-9])|(?:1[0-2]))(\/|-|\.)(?:0?[1-9]|1\d|2[0-8])\4(?:(?:1[6-9]|[2-9]\d)?\d{2})$"; break; case "isCreditCard": rePattern="^((4\d{3})|(5[1-5]\d{2})|(6011))-?\d{4}-?\d{4}-?\d{4}|3[4,7]\d{13}$"; break; case "isSSN": rePattern="^\d{3}-\d{2}-\d{4}$"; break; case "isZipCode": rePattern="^\d{5}-\d{4}|\d{5}|[A-Z]\d[A-Z] \d[A-Z]\d$"; break; default: return("That pattern check is not available"); break; } return reFindNoCase(rePattern,str); } /** * Takes a two letter Country Code (i.e. US) and returns the full Country Name (i.e. UNITED STATES). * * @param code Two letter country code you want converted to the country name. * @return Returns a string. * @author Scott Delatush (delatush@yahoo.com) * @version 1, February 25, 2002 */ function CodeToCountry(Code) { var countries = "AFGHANISTAN,ALBANIA,ALGERIA,AMERICAN SAMOA,ANDORRA,ANGOLA,ANGUILLA,ANTARCTICA,ANTIGUA AND BARBUDA,ARGENTINA, ARMENIA,ARUBA,AUSTRALIA,AUSTRIA,AZERBAIJAN,BAHAMAS,BAHRAIN,BANGLADESH,BARBADOS,BELARUS,BELGIUM,BELIZE,BENIN, BERMUDA,BHUTAN,BOLIVIA,BOSNIA AND HERZEGOVINA,BOTSWANA,BOUVET ISLAND,BRAZIL,BRITISH INDIAN OCEAN TERRITORY, BRUNEI DARUSSALAM,BULGARIA,BURKINA FASO,BURUNDI,CAMBODIA,CAMEROON,CANADA,CAPE VERDE,CAYMAN ISLANDS,CENTRAL AFRICAN REPUBLIC, CHAD,CHILE,CHINA,CHRISTMAS ISLAND,COCOS (KEELING) ISLANDS,COLOMBIA,COMOROS,CONGO,THE DEMOCRATIC REPUBLIC OF THE CONGO, COOK ISLANDS,COSTA RICA,CÔTE D'IVOIRE,CROATIA,CUBA,CYPRUS,CZECH REPUBLIC,DENMARK,DJIBOUTI,DOMINICA,DOMINICAN REPUBLIC, EAST TIMOR,ECUADOR,EGYPT,EL SALVADOR,EQUATORIAL GUINEA,ERITREA,ESTONIA,ETHIOPIA,FALKLAND ISLANDS (MALVINAS),FAROE ISLANDS, FIJI,FINLAND,FRANCE,FRENCH GUIANA,FRENCH POLYNESIA,FRENCH SOUTHERN TERRITORIES,GABON,GAMBIA,GEORGIA,GERMANY,GHANA, GIBRALTAR,GREECE,GREENLAND,GRENADA,GUADELOUPE,GUAM,GUATEMALA,GUINEA,GUINEA-BISSAU,GUYANA,HAITI, HEARD ISLAND AND MCDONALD ISLANDS,HOLY SEE (VATICAN CITY STATE),HONDURAS,HONG KONG,HUNGARY,ICELAND,INDIA,INDONESIA, ISLAMIC REPUBLIC OF IRAN,IRAQ,IRELAND,ISRAEL,ITALY,JAMAICA,JAPAN,JORDAN,KAZAKSTAN,KENYA,KIRIBATI, DEMOCRATIC PEOPLE'S REPUBLIC OF KOREA,REPUBLIC OF KOREA,KUWAIT,KYRGYZSTAN,LAO PEOPLE'S DEMOCRATIC REPUBLIC,LATVIA, LEBANON,LESOTHO,LIBERIA,LIBYAN ARAB JAMAHIRIYA,LIECHTENSTEIN,LITHUANIA,LUXEMBOURG,MACAU,THE FORMER YUGOSLAV REPUBLIC OF MACEDONIA, MADAGASCAR,MALAWI,MALAYSIA,MALDIVES,MALI,MALTA,MARSHALL ISLANDS,MARTINIQUE,MAURITANIA,MAURITIUS,MAYOTTE,MEXICO, FEDERATED STATES OF MICRONESIA,REPUBLIC OF MOLDOVA,MONACO,MONGOLIA,MONTSERRAT,MOROCCO,MOZAMBIQUE,MYANMAR,NAMIBIA,NAURU, NEPAL,NETHERLANDS,NETHERLANDS ANTILLES,NEW CALEDONIA,NEW ZEALAND,NICARAGUA,NIGER,NIGERIA,NIUE,NORFOLK ISLAND, NORTHERN MARIANA ISLANDS,NORWAY,OMAN,PAKISTAN,PALAU,OCCUPIED PALESTINIAN TERRITORY,PANAMA,PAPUA NEW GUINEA,PARAGUAY, PERU,PHILIPPINES,PITCAIRN,POLAND,PORTUGAL,PUERTO RICO,QATAR,RÉUNION,ROMANIA,RUSSIAN FEDERATION,RWANDA,SAINT HELENA, SAINT KITTS AND NEIS,SAINT LUCIA,SAINT PIERRE AND MIQUELON,SAINT VINCENT AND THE GRENADINES,SAMOA,SAN MARINO, SAO TOME AND PRINCIPE,SAUDI ARABIA,SENEGAL,SEYCHELLES,SIERRA LEONE,SINGAPORE,SLOVAKIA,SLOVENIA,SOLOMON ISLANDS,SOMALIA, SOUTH AFRICA,SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS,SPAIN,SRI LANKA,SUDAN,SURINAME,SVALBARD AND JAN MAYEN,SWAZILAND, SWEDEN,SWITZERLAND,SYRIAN ARAB REPUBLIC,TAIWAN PROVINCE OF CHINA,TAJIKISTAN,UNITED REPUBLIC OF TANZANIA,THAILAND,TOGO, TOKELAU,TONGA,TRINIDAD AND TOBAGO,TUNISIA,TURKEY,TURKMENISTAN,TURKS AND CAICOS ISLANDS,TUVALU,UGANDA,UKRAINE, UNITED ARAB EMIRATES,UNITED KINGDOM,UNITED STATES,UNITED STATES MINOR OUTLYING ISLANDS,URUGUAY,UZBEKISTAN,VANUATU, VENEZUELA,VIET NAM,BRITISH VIRGIN ISLANDS,U.S. VIRGIN ISLANDS,WALLIS AND FUTUNA,WESTERN SAHARA,YEMEN,YUGOSLAVIA,ZAMBIA,ZIMBABWE"; var cCode ="AF,AL,DZ,AS,AD,AO,AI,AQ,AG,AR,AM,AW,AU,AT,AZ,BS,BH,BD,BB,BY,BE,BZ,BJ,BM,BT,BO,BA,BW,BV,BR,IO,BN,BG,BF,BI,KH,CM,CA,CV,KY,CF,TD,CL,CN,CX,CC,CO,KM,CG,CD,CK,CR,CI,HR,CU,CY,CZ,DK,DJ,DM,DO,TP,EC,EG,SV,GQ,ER,EE,ET,FK,FO,FJ,FI,FR,GF,PF,TF,GA,GM,GE,DE,GH,GI,GR,GL,GD,GP,GU,GT,GN,GW,GY,HT,HM,VA,HN,HK,HU,IS,IN,ID,IR,IQ,IE,IL,IT,JM,JP,JO,KZ,KE,KI,KP,KR,KW,KG,LA,LV,LB,LS,LR,LY,LI,LT,LU,MO,MK,MG,MW,MY,MV,ML,MT,MH,MQ,MR,MU,YT,MX,FM,MD,MC,MN,MS,MA,MZ,MM,NA,NR,NP,NL,AN,NC,NZ,NI,NE,NG,NU,NF,MP,NO,OM,PK,PW,PS,PA,PG,PY,PE,PH,PN,PL,PT,PR,QA,RE,RO,RU,RW,SH,KN,LC,PM,VC,WS,SM,ST,SA,SN,SC,SL,SG,SK,SI,SB,SO,ZA,GS,ES,LK,SD,SR,SJ,SZ,SE,CH,SY,TW,TJ,TZ,TH,TG,TK,TO,TT,TN,TR,TM,TC,TV,UG,UA,AE,GB,US,UM,UY,UZ,VU,VE,VN,VG,VI,WF,EH,YE,YU,ZM,ZW"; if(listFindNoCase(cCode,Code)) Code=listGetAt(countries,listFindNoCase(cCode,Code)); return Code; } /** * Adds commas after every third non-ending digit to the left of the decimal point. * * @param inNum Number to format. (Required) * @param default If number isn't numeric, display default instead. (Optional) * @return Returns a string. * @author Shawn Seley (shawnse@aol.com) * @version 1, August 26, 2002 */ function CommaFormat(inNum) { var outStr = ""; var decStr = ""; var default_value = inNum; if(ArrayLen(Arguments) GTE 2) default_value = Arguments[2]; if (not IsNumeric(inNum)) { return (default_value); } else { if(ListLen(inNum, ".") GT 1) { outStr = ListFirst(inNum, "."); decStr = "." & ListLast(inNum, "."); } else if (Find(".", Trim(inNum)) EQ 1) { decStr = inNum; } else { outStr = inNum; } if (Trim(outStr) NEQ "") { outStr = Reverse(outStr); outStr = REReplace(outStr, "([0-9][0-9][0-9])", "\1,", "ALL"); outStr = REReplace(outStr, ",$", ""); // delete potential leading comma outStr = REReplace(outStr, ",([^0-9]+)", "\1"); // delete leading comma w/ spaces in front of outStr = Reverse(outStr); } return (outStr & decStr); } } /** * Will convert Extended Characters to HTML Entities or HTML Entities to Extended Characters. * * @param string The string to format. (Required) * @param mode Determines if we change to HTML entities or from HTML entities to extended characters. "Safe" means to go from extended characters to HTML entities. Any other value will go the other way. (Required) * @param convertCRLF Converts CR/LF characters to

and
tags. Default is false. (Optional) * @param stripHTML Converts < and > to < and >. Default is true. (Optional) * @param trim Trim the string. Default is false. (Optional) * @return Returns a string. * @author Mike Gillespie (mike@striking.com) * @version 1, August 5, 2002 */ function ConvertEntity(string,mode) { /* declare working strings */ var clean_work = ""; var bad_chars = "&,"",Ã??,Ã?ÂÌ,Ã??,Ã??,Ã??,Ã??,Ã??,Ã??,Ã?ÂÌ,Ã??,Ã??,Ã??,Ã??,Ã?ÂÌ,Ã??,Ã??,Ã?ÂÌ,Ã??,Ã??,Ã??,Ã??,Ã??,Ã??,Ã??,Ã??,Ã??,Ã??,Ã??,Ã??,Ã?ÂÌ,Ã?¡,Ã?¢,Ã?¦,Ã? ,Ã?Â¥,Ã?£,Ã?¤,Ã?§,Ã?©,Ã?ª,Ã?¨,Ã?°,Ã?Â<,Ã?­,Ã?®,Ã?¬,Ã?¯,Ã?±,Ã?³,Ã?´,Ã?²,Ã?¸,Ã?µ,Ã?¶,Ã??,Ã?¾,Ã?º,Ã?Â>,Ã?¹,Ã?¼,Ã?½,Ã?¿,Ã?¡,Ã?£,Ã?¤,Ã?Â¥,Ã?¦,Ã?§,Ã?¨,Ã?©,Ã?ª,Ã?Â<,Ã?¬,Ã?­,Ã?®,Ã?¯,Ã?°,Ã?±,Ã?²,Ã?³,Ã?´,Ã?µ,Ã?¶,Ã?·,Ã?¸,Ã?¹,Ã?º,Ã?Â>,Ã?¼,Ã?½,Ã?¾,Ã?¿,Ã??,Ã?·,Ã?¢"; var good_chars = "&,",Æ,Á,Â,À,Å,Ã,Ä,Ç,Ð,É,Ê,È,Ë,Í,Î,Ì,Ï,Ñ,Ó,Ô,Ò,Ø,Õ,Ö,Þ,Ú,Û,Ù,Ü,Ý,á,â,æ,à,å,ã,ä,ç,é,ê,è,ð,ë,í,î,ì,ï,ñ,ó,ô,ò,ø,õ,ö,ß,þ,ú,û,ù,ü,ý,ÿ,¡,£,¤,¥,¦,§,¨,©,ª,«,¬,­,®,¯,°,±,²,³,´,µ,¶,·,¸,¹,º,»,¼,½,¾,¿,×,÷,¢"; if(string eq "") return ""; /* strip htm! for the control freak in all of us! */ if (arraylen(arguments) lte 4 or arguments[4] eq "Y") { bad_chars = bad_chars & "<,>"; good_chars= good_chars & "<,>"; } /* convert extended to entity */ if (mode eq "safe") { clean_work=ReplaceList(string, bad_chars, good_chars); /* CRLF option - UNIX and LINUX users will need to adjust to thier OS specific CRLF */ if (arraylen(arguments) gte 3 and arguments[3] eq "y") { clean_work=replace(clean_work,"#chr(13)##chr(10)#","
","all"); clean_work=replace(clean_work,"

","

","all"); } } /* convert entity to extended */ else { clean_work=ReplaceList(string, good_chars, bad_chars); /* CRLF option - UNIX and LINUX users will need to adjust to thier OS specific CRLF */ if (arraylen(arguments) gte 3 and arguments[3] eq "y") { clean_work=replace(clean_work,"

","

","all"); clean_work=replace(clean_work,"
","#chr(13)##chr(10)#","all"); } } /* trim it? */ if (arraylen(arguments) gte 5 and arguments[5] eq "y") { clean_work=trim(clean_work); } return clean_work; } /** * Reformats special chars typically found when copying and pasting from Word. * * @param str The string to modify. * @return Returns a string. * @author Glen Salisbury (gsalisbury@collegepublisher.com) * @version 1, October 29, 2001 */ function ConvertSpecialChars(textin) { return ReplaceList(textin, "#chr(145)#,#chr(146)#,#chr(147)#,#chr(148)#", "',',"","""); } /** * Get a count on searching string in the searched string. * Updated by Raymond Camden * * @param str The string to search. (Required) * @param c The string to look for. (Required) * @return Returns a numeric value. * @author Peini Wu (pwu@hunter.com) * @version 1, October 17, 2003 */ function CountIt(str, c) { var pos = findnocase(c, str, 1); var count = 0; if(c eq "") return 0; while(pos neq 0){ count = count + 1; pos = findnocase(c, str, pos+len(c)); } return count; } /** * This function returns the number of lines in a text file. * * @param text String to parse. (Required) * @return Returns a number. * @author Matheus Antonelli (matheus_antonelli@ig.com.br) * @version 1, June 3, 2003 */ function CountLines(text) { var CRLF = Chr(13) & Chr(10); return ListLen(text,CRLF); } /** * Takes a Country (i.e. United Kingdom) and returns the 3 letter ISO Country Name (i.e. GBR). * * @param country The name of the country. (Required) * @return Returns a string. * @author Will Swain (will@hothorse.com) * @version 1, September 21, 2004 */ function CountryTo3ACode(country) { var countries = "AFGHANISTAN,ALBANIA,ALGERIA,AMERICAN SAMOA,ANDORRA,ANGOLA,ANGUILLA,ANTARCTICA,ANTIGUA AND BARBUDA,ARGENTINA,ARMENIA,ARUBA,AUSTRALIA,AUSTRIA,AZERBAIJAN,BAHAMAS,BAHRAIN,BANGLADESH,BARBADOS,BELARUS,BELGIUM,BELIZE,BENIN,BERMUDA,BHUTAN,BOLIVIA,BOSNIA AND HERZEGOVINA,BOTSWANA,BOUVET ISLAND,BRAZIL,BRITISH INDIAN OCEAN TERRITORY,BRUNEI DARUSSALAM,BULGARIA,BURKINA FASO,BURUNDI,CAMBODIA,CAMEROON,CANADA,CAPE VERDE,CAYMAN ISLANDS,CENTRAL AFRICAN REPUBLIC,CHAD,CHILE,CHINA,CHRISTMAS ISLAND,COCOS (KEELING) ISLANDS,COLOMBIA,COMOROS,CONGO,THE DEMOCRATIC REPUBLIC OF THE CONGO,COOK ISLANDS,COSTA RICA,CÔTE D'IVOIRE,CROATIA,CUBA,CYPRUS,CZECH REPUBLIC,DENMARK,DJIBOUTI,DOMINICA,DOMINICAN REPUBLIC,EAST TIMOR,ECUADOR,EGYPT,EL SALVADOR,EQUATORIAL GUINEA,ERITREA,ESTONIA,ETHIOPIA,FALKLAND ISLANDS (MALVINAS),FAROE ISLANDS,FIJI,FINLAND,FRANCE,FRENCH GUIANA,FRENCH POLYNESIA,FRENCH SOUTHERN TERRITORIES,GABON,GAMBIA,GEORGIA,GERMANY,GHANA,GIBRALTAR,GREECE,GREENLAND,GRENADA,GUADELOUPE,GUAM,GUATEMALA,GUINEA,GUINEA-BISSAU,GUYANA,HAITI,HEARD ISLAND AND MCDONALD ISLANDS,HOLY SEE (VATICAN CITY STATE),HONDURAS,HONG KONG,HUNGARY,ICELAND,INDIA,INDONESIA,ISLAMIC REPUBLIC OF IRAN,IRAQ,IRELAND,ISRAEL,ITALY,JAMAICA,JAPAN,JORDAN,KAZAKSTAN,KENYA,KIRIBATI,DEMOCRATIC PEOPLE'S REPUBLIC OF KOREA,REPUBLIC OF KOREA,KUWAIT,KYRGYZSTAN,LAO PEOPLE'S DEMOCRATIC REPUBLIC,LATVIA,LEBANON,LESOTHO,LIBERIA,LIBYAN ARAB JAMAHIRIYA,LIECHTENSTEIN,LITHUANIA,LUXEMBOURG,MACAU,THE FORMER YUGOSLAV REPUBLIC OF MACEDONIA,MADAGASCAR,MALAWI,MALAYSIA,MALDIVES,MALI,MALTA,MARSHALL ISLANDS,MARTINIQUE,MAURITANIA,MAURITIUS,MAYOTTE,MEXICO,FEDERATED STATES OF MICRONESIA,REPUBLIC OF MOLDOVA,MONACO,MONGOLIA,MONTSERRAT,MOROCCO,MOZAMBIQUE,MYANMAR,NAMIBIA,NAURU,NEPAL,NETHERLANDS,NETHERLANDS ANTILLES,NEW CALEDONIA,NEW ZEALAND,NICARAGUA,NIGER,NIGERIA,NIUE,NORFOLK ISLAND,NORTHERN MARIANA ISLANDS,NORWAY,OMAN,PAKISTAN,PALAU,OCCUPIED PALESTINIAN TERRITORY,PANAMA,PAPUA NEW GUINEA,PARAGUAY,PERU,PHILIPPINES,PITCAIRN,POLAND,PORTUGAL,PUERTO RICO,QATAR,RÉUNION,ROMANIA,RUSSIAN FEDERATION,RWANDA,SAINT HELENA,SAINT KITTS AND NEVIS,SAINT LUCIA,SAINT PIERRE AND MIQUELON,SAINT VINCENT AND THE GRENADINES,SAMOA,SAN MARINO,SAO TOME AND PRINCIPE,SAUDI ARABIA,SENEGAL,SEYCHELLES,SIERRA LEONE,SINGAPORE,SLOVAKIA,SLOVENIA,SOLOMON ISLANDS,SOMALIA,SOUTH AFRICA,SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS,SPAIN,SRI LANKA,SUDAN,SURINAME,SVALBARD AND JAN MAYEN,SWAZILAND,SWEDEN,SWITZERLAND,SYRIAN ARAB REPUBLIC,TAIWAN PROVINCE OF CHINA,TAJIKISTAN,UNITED REPUBLIC OF TANZANIA,THAILAND,TOGO,TOKELAU,TONGA,TRINIDAD AND TOBAGO,TUNISIA,TURKEY,TURKMENISTAN,TURKS AND CAICOS ISLANDS,TUVALU,UGANDA,UKRAINE,UNITED ARAB EMIRATES,UNITED KINGDOM,UNITED STATES,UNITED STATES MINOR OUTLYING ISLANDS,URUGUAY,UZBEKISTAN,VANUATU,VENEZUELA,VIET NAM,BRITISH VIRGIN ISLANDS,U.S. VIRGIN ISLANDS,WALLIS AND FUTUNA,WESTERN SAHARA,YEMEN,YUGOSLAVIA,ZAIRE,ZAMBIA,ZIMBABWE"; var cCode ="AFG,ALB,DZA,ASM,AND,AGO,AIA,ATA,ATG,ARG,ARM,ABW,AUS,AUT,AZE,BHS,BHR,BGD,BRB,BLR,BEL,BLZ,BEN,BMU,BTN,BOL,BIH,BWA,BVT,BRA,IOT,BRN,BGR,BFA, BDI,KHM,CMR,CAN,CPV,CYM,CAF,TCD,CHL,CHN,CXR,CCK,COL,COM,COG,COD,COK,CRI,CIV,HRV,CUB,CYP,CZE,DNK,DJI,DMA,DOM,TMP,ECU,EGY,SLV,GNQ,ERI,EST,ETH,FLK,FRO,FJI,FIN,FRA,GUF,PYF,ATF,GAB,GMB,GEO,DEU,GHA,GIB,GRC,GRL,GRD,GLP,GUM,GTM,GIN,GNB,GUY,HTI,HMD,VAT,HND,HKG,HUN,ISL,IND,IDN,IRN,IRQ,IRL,ISR,ITA,JAM,JPN,JOR,KAZ,KEN,KIR,PRK,KOR,KWT,KGZ,LAO,LVA,LBN,LSO,LBR,LBY,LIE,LTU,LUX,MAC,MKD,MDG,MWI,MYS,MDV,MLI,MLT,MHL,MTQ,MRT,MUS,MYT,MEX,FSM,MDA,MCO,MNG,MSR,MAR,MOZ,MMR,NAM,NRU,NPL,NLD,ANT,NCL,NZL,NIC,NER,NGA,NIU,NFK,MNP,NOR,OMN,PAK,PLW,PSE,PAN,PNG,PRY,PER,PHL,PCN,POL,PRT,PRI,QAT,REU,ROM,RUS,RWA,SHN,KNA,LCA,SPM,VCT,WSM,SMR,STP,SAU,SEN,SYC,SLE,SGP,SVK,SVN,SLB,SOM,ZAF,SGS,ESP,LKA,SDN,SUR,SJM,SWZ,SWE,CHE,SYR,TWN,TJK,TZA,THA,TGO,TKL,TON,TTO,TUN,TUR,TKM,TCA,TUV,UGA,UKR,ARE,GBR,USA,UMI,URY,UZB,VUT,VEN,VNM,VGB,VIR,WLF,ESH,YEM,YUG,ZAR,ZMB,ZWE"; if(listFindNoCase(countries,country)) country=listGetAt(cCode,listFindNoCase(countries,country)); return country; } /** * Takes a Country (i.e. United United Kingdom) and returns theISO Country Name (i.e. GB). * * @param country Name of the country. (Required) * @return Returns a string. * @author Neil Robertson-Ravo (neil.robertson-ravo@csd.reedexpo.com) * @version 1, August 6, 2004 */ function countryToCode(country) { var countries = "AFGHANISTAN,ALBANIA,ALGERIA,AMERICAN SAMOA,ANDORRA,ANGOLA,ANGUILLA,ANTARCTICA,ANTIGUA AND BARBUDA,ARGENTINA, ARMENIA,ARUBA,AUSTRALIA,AUSTRIA,AZERBAIJAN,BAHAMAS,BAHRAIN,BANGLADESH,BARBADOS,BELARUS,BELGIUM,BELIZE,BENIN, BERMUDA,BHUTAN,BOLIVIA,BOSNIA AND HERZEGOVINA,BOTSWANA,BOUVET ISLAND,BRAZIL,BRITISH INDIAN OCEAN TERRITORY, BRUNEI DARUSSALAM,BULGARIA,BURKINA FASO,BURUNDI,CAMBODIA,CAMEROON,CANADA,CAPE VERDE,CAYMAN ISLANDS,CENTRAL AFRICAN REPUBLIC, CHAD,CHILE,CHINA,CHRISTMAS ISLAND,COCOS (KEELING) ISLANDS,COLOMBIA,COMOROS,CONGO,THE DEMOCRATIC REPUBLIC OF THE CONGO, COOK ISLANDS,COSTA RICA,CÔTE D'IVOIRE,CROATIA,CUBA,CYPRUS,CZECH REPUBLIC,DENMARK,DJIBOUTI,DOMINICA,DOMINICAN REPUBLIC, EAST TIMOR,ECUADOR,EGYPT,EL SALVADOR,EQUATORIAL GUINEA,ERITREA,ESTONIA,ETHIOPIA,FALKLAND ISLANDS (MALVINAS),FAROE ISLANDS, FIJI,FINLAND,FRANCE,FRENCH GUIANA,FRENCH POLYNESIA,FRENCH SOUTHERN TERRITORIES,GABON,GAMBIA,GEORGIA,GERMANY,GHANA, GIBRALTAR,GREECE,GREENLAND,GRENADA,GUADELOUPE,GUAM,GUATEMALA,GUINEA,GUINEA-BISSAU,GUYANA,HAITI, HEARD ISLAND AND MCDONALD ISLANDS,HOLY SEE (VATICAN CITY STATE),HONDURAS,HONG KONG,HUNGARY,ICELAND,INDIA,INDONESIA, ISLAMIC REPUBLIC OF IRAN,IRAQ,IRELAND,ISRAEL,ITALY,JAMAICA,JAPAN,JORDAN,KAZAKSTAN,KENYA,KIRIBATI, DEMOCRATIC PEOPLE'S REPUBLIC OF KOREA,REPUBLIC OF KOREA,KUWAIT,KYRGYZSTAN,LAO PEOPLE'S DEMOCRATIC REPUBLIC,LATVIA, LEBANON,LESOTHO,LIBERIA,LIBYAN ARAB JAMAHIRIYA,LIECHTENSTEIN,LITHUANIA,LUXEMBOURG,MACAU,THE FORMER YUGOSLAV REPUBLIC OF MACEDONIA, MADAGASCAR,MALAWI,MALAYSIA,MALDIVES,MALI,MALTA,MARSHALL ISLANDS,MARTINIQUE,MAURITANIA,MAURITIUS,MAYOTTE,MEXICO, FEDERATED STATES OF MICRONESIA,REPUBLIC OF MOLDOVA,MONACO,MONGOLIA,MONTSERRAT,MOROCCO,MOZAMBIQUE,MYANMAR,NAMIBIA,NAURU, NEPAL,NETHERLANDS,NETHERLANDS ANTILLES,NEW CALEDONIA,NEW ZEALAND,NICARAGUA,NIGER,NIGERIA,NIUE,NORFOLK ISLAND, NORTHERN MARIANA ISLANDS,NORWAY,OMAN,PAKISTAN,PALAU,OCCUPIED PALESTINIAN TERRITORY,PANAMA,PAPUA NEW GUINEA,PARAGUAY, PERU,PHILIPPINES,PITCAIRN,POLAND,PORTUGAL,PUERTO RICO,QATAR,RÉUNION,ROMANIA,RUSSIAN FEDERATION,RWANDA,SAINT HELENA, SAINT KITTS AND NEIS,SAINT LUCIA,SAINT PIERRE AND MIQUELON,SAINT VINCENT AND THE GRENADINES,SAMOA,SAN MARINO, SAO TOME AND PRINCIPE,SAUDI ARABIA,SENEGAL,SEYCHELLES,SIERRA LEONE,SINGAPORE,SLOVAKIA,SLOVENIA,SOLOMON ISLANDS,SOMALIA, SOUTH AFRICA,SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS,SPAIN,SRI LANKA,SUDAN,SURINAME,SVALBARD AND JAN MAYEN,SWAZILAND, SWEDEN,SWITZERLAND,SYRIAN ARAB REPUBLIC,TAIWAN PROVINCE OF CHINA,TAJIKISTAN,UNITED REPUBLIC OF TANZANIA,THAILAND,TOGO, TOKELAU,TONGA,TRINIDAD AND TOBAGO,TUNISIA,TURKEY,TURKMENISTAN,TURKS AND CAICOS ISLANDS,TUVALU,UGANDA,UKRAINE, UNITED ARAB EMIRATES,UNITED KINGDOM,UNITED STATES,UNITED STATES MINOR OUTLYING ISLANDS,URUGUAY,UZBEKISTAN,VANUATU, VENEZUELA,VIET NAM,BRITISH VIRGIN ISLANDS,U.S. VIRGIN ISLANDS,WALLIS AND FUTUNA,WESTERN SAHARA,YEMEN,YUGOSLAVIA,ZAMBIA,ZIMBABWE"; var cCode ="AF,AL,DZ,AS,AD,AO,AI,AQ,AG,AR,AM,AW,AU,AT,AZ,BS,BH,BD,BB,BY,BE,BZ,BJ,BM,BT,BO,BA,BW,BV,BR,IO,BN,BG,BF,BI,KH,CM,CA,CV,KY,CF,TD,CL,CN,CX,CC,CO,KM,CG,CD,CK,CR,CI,HR,CU,CY,CZ,DK,DJ,DM,DO,TP,EC,EG,SV,GQ,ER,EE,ET,FK,FO,FJ,FI,FR,GF,PF,TF,GA,GM,GE,DE,GH,GI,GR,GL,GD,GP,GU,GT,GN,GW,GY,HT,HM,VA,HN,HK,HU,IS,IN,ID,IR,IQ,IE,IL,IT,JM,JP,JO,KZ,KE,KI,KP,KR,KW,KG,LA,LV,LB,LS,LR,LY,LI,LT,LU,MO,MK,MG,MW,MY,MV,ML,MT,MH,MQ,MR,MU,YT,MX,FM,MD,MC,MN,MS,MA,MZ,MM,NA,NR,NP,NL,AN,NC,NZ,NI,NE,NG,NU,NF,MP,NO,OM,PK,PW,PS,PA,PG,PY,PE,PH,PN,PL,PT,PR,QA,RE,RO,RU,RW,SH,KN,LC,PM,VC,WS,SM,ST,SA,SN,SC,SL,SG,SK,SI,SB,SO,ZA,GS,ES,LK,SD,SR,SJ,SZ,SE,CH,SY,TW,TJ,TZ,TH,TG,TK,TO,TT,TN,TR,TM,TC,TV,UG,UA,AE,GB,US,UM,UY,UZ,VU,VE,VN,VG,VI,WF,EH,YE,YU,ZM,ZW"; if(listFindNoCase(countries,Country)) return listGetAt(cCode,listFindNoCase(countries,Country)); } /** * Returns a UUID in the Microsoft form. * * @return Returns a string. * @author Nathan Dintenfass (nathan@changemedia.com) * @version 1, July 17, 2001 */ function CreateGUID() { return insert("-", CreateUUID(), 23); } /** * Flexible PIN generator, supporting alphabetical, numeric, and alphanumeric types, upper, lower, and mixed cases, and validating prescence of letters and numbers in alphanumeric PINs at least 2 characters long. * * @param chars Number of characters to return. (Required) * @param type Type of PIN to create. Types are: n (numeric), a (alphabetical), m (mixed, or alphanumeric). Default is m. (Optional) * @param format Case of PIN. Options are: u (uppercase), l (lowercase), m (mixed). Default is m. (Optional) * @return Returns a string. * @author Sierra Bufe (sierra@brighterfusion.com) * @version 1, May 14, 2002 */ function createPIN(chars){ var type = "m"; var format = "m"; var PIN = ""; var isValid = false; var i = 0; var j = 0; var r = 0; // Check to see if type was provided. If not, default to "m" (mixed, or alphanumeric). if (ArrayLen(Arguments) GT 1) { type = Arguments[2]; if (type is "alphanumeric") type = "m"; type = left(type,1); if ("a,n,m" does not contain type) return "Invalid type argument. Valid types are: alpha, numeric, alphanumeric, mixed, a, n, m. This argument is optional, and defaults to alphanumeric"; } // Check to see if format was provided. If not, default to "m" (mixed upper and lower). if (ArrayLen(Arguments) GT 2) { format = Arguments[3]; format = left(format,1); if ("u,l,m" does not contain format) return "Invalid format argument. Valid formats are: upper, lower, mixed, u, l, m."; } // if type is alphanumeric, set j to 10 to allow for numbers in the RandRange if (type is "m") j = 10; while (not isValid) { PIN = ""; // loop through each character of the PIN for (i = 1; i LTE chars; i = i+1) { // numeric type if (type is "n") { r = RandRange(0,9) + 48; // lowercase format } else if (format is "l") { r = RandRange(97,122 + j); if (r GTE 123) r = r - 123 + 48; // uppercase format } else if (format is "u") { r = RandRange(65,90 + j); if (r GTE 91) r = r - 91 + 48; // upper and lower cases mixed } else if (format is "m") { r = RandRange(65,116 + j); if (r GTE 117) r = r - 117 + 48; else if (r GTE 91) r = r + 6; } PIN = PIN & Chr(r); } // verfify that alphanumeric strings contain both letters and numbers if (type is "m" AND chars GTE 2) { if (REFind("[A-Z,a-z]+",PIN) AND REFind("[0-9]+",PIN)) isValid = true; } else { isValid = true; } } return PIN; } /** * Replaces all unnecessary characters from a section of CSS code. * * @param sInput CSS you want to compress. (Required) * @return Returns a string. * @author Jordan Clark (JordanClark@Telus.net) * @version 1, November 19, 2002 */ function CssCompactFormat(sInput) { sInput = reReplace( sInput, "[[:space:]]{2,}", " ", "all" ); sInput = reReplace( sInput, "/\*[^\*]+\*/", " ", "all" ); sInput = reReplace( sInput, "[ ]*([:{};,])[ ]*", "\1", "all" ); return sInput; } /** * Corrects rounding bug in DecimalFormat. * Minor update. * * @param number The number to format. (Required) * @return Returns a number. * @author duncan cumming (duncan.cumming@alienationdesign.co.uk) * @version 2, October 12, 2004 */ function DecimalFormatCorrectly(number) { var lhs=0; var rhs=0; var decLen = 0; var i = 0; if(ListLen(number, ".") EQ 2) { //xxx.xxx lhs = ListFirst(number, "."); rhs = ListLast(number, "."); } else if (Find(".", Trim(number)) EQ 1) { // .xx rhs = number; } else if (Find(".", Trim(number)) EQ 0) { // xx lhs = number; } else { return number; } if (NOT IsNumeric(lhs) OR NOT IsNumeric(rhs)) return number; for (i = 0; i LT 2; i=i+1) { if (Len(rhs) LT 2) rhs = rhs & "0"; } // count how many digits > 2dp there are decLen = Len(rhs) - 2; // divide by this number of zeroes for (i = 0; i LT decLen; i=i+1) { rhs = rhs / 10; } // round it rhs = Round(rhs); if (rhs GTE 100) { rhs = 0; lhs = lhs + 1; } // pad with zeros if necessary if (rhs LT 10) { rhs = "0" & rhs; } lhs = NumberFormat(lhs); return (lhs & "." & rhs); } /** * Fixes text using Microsoft Latin-1 "Extentions", namely ASCII characters 128-160. * * @param text Text to be modified. (Required) * @return Returns a string. * @author Shawn Porter (sporter@rit.net) * @version 1, June 16, 2004 */ function DeMoronize (text) { var i = 0; // map incompatible non-ISO characters into plausible // substitutes text = Replace(text, Chr(128), "€", "All"); text = Replace(text, Chr(130), ",", "All"); text = Replace(text, Chr(131), "f", "All"); text = Replace(text, Chr(132), ",,", "All"); text = Replace(text, Chr(133), "...", "All"); text = Replace(text, Chr(136), "^", "All"); text = Replace(text, Chr(139), ")", "All"); text = Replace(text, Chr(140), "Oe", "All"); text = Replace(text, Chr(145), "`", "All"); text = Replace(text, Chr(146), "'", "All"); text = Replace(text, Chr(147), """", "All"); text = Replace(text, Chr(148), """", "All"); text = Replace(text, Chr(149), "*", "All"); text = Replace(text, Chr(150), "-", "All"); text = Replace(text, Chr(151), "--", "All"); text = Replace(text, Chr(152), "~", "All"); text = Replace(text, Chr(153), "™", "All"); text = Replace(text, Chr(155), ")", "All"); text = Replace(text, Chr(156), "oe", "All"); // remove any remaining ASCII 128-159 characters for (i = 128; i LTE 159; i = i + 1) text = Replace(text, Chr(i), "", "All"); // map Latin-1 supplemental characters into // their &name; encoded substitutes text = Replace(text, Chr(160), " ", "All"); text = Replace(text, Chr(163), "£", "All"); text = Replace(text, Chr(169), "©", "All"); text = Replace(text, Chr(176), "°", "All"); // encode ASCII 160-255 using ? format for (i = 160; i LTE 255; i = i + 1) text = REReplace(text, "(#Chr(i)#)", "&###i#;", "All"); // supply missing semicolon at end of numeric entities text = ReReplace(text, "&##([0-2][[:digit:]]{2})([^;])", "&##\1;\2", "All"); // fix obscure numeric rendering of < > & text = ReReplace(text, "&##038;", "&", "All"); text = ReReplace(text, "&##060;", "<", "All"); text = ReReplace(text, "&##062;", ">", "All"); // supply missing semicolon at the end of & " text = ReReplace(text, "&(^;)", "&\1", "All"); text = ReReplace(text, ""(^;)", ""\1", "All"); return text; } /** * Counts how many different chars are in a string. * removed use of arguments. to make it cf5 compat * * @param string String to check. (Required) * @param caseSensitive Determines if case sensitivity is used. Defaults to false. (Optional) * @return Returns a number. * @author Bjorn Jensen (public.cflib@saghian.com) * @version 1, February 6, 2004 */ function differentChars(string){ var iCount = 0; var i = 0; var sChars = ""; var sChar = ""; var caseSensitive = false; if (arrayLen(arguments) eq 2 and isBoolean(arguments[2]) and arguments[2]) { caseSensitive = true; } for(i=1;i lte len(string);i=i+1){ sChar = mid(string, i, 1); if (caseSensitive and not find(sChar, sChars)){ sChars = sChars & sChar; iCount = iCount+1; } else if (not caseSensitive and not findNoCase(sChar, sChars)){ sChars = sChars & sChar; iCount = iCount+1; } } return iCount; } /** * Returns a number converted into a string (i.e. 1 becomes "One Dollar"). * * @param dollaramount The number representing the dollar amount. * @param centsasdigits Boolean value (defaults to no) that specifies if cents should be displayed as digits. * @return Returns a string. * @author Ben Forta (ben@forta.com) * @version 1, July 18, 2001 */ function DollarAsString(number) { VAR Result=""; // Generated result VAR Strs=StructNew(); // Strings structure VAR Str=""; // Temp string VAR n=0; // Temp number VAR Dollars=0; // Dollar amount VAR Cents=0; // Cents amount VAR CentsAsDigits=0; // Cents as digits flag // Initialize strings if (NOT IsDefined("REQUEST.DStrs")) { REQUEST.DStrs=StructNew(); REQUEST.DStrs.space=" "; REQUEST.DStrs.and="and"; REQUEST.DStrs.dollar="Dollar"; REQUEST.DStrs.dollars="Dollars"; REQUEST.DStrs.cent="Cent"; REQUEST.DStrs.cents="Cents"; } // Check for optional parameter if (ArrayLen(Arguments) GTE 2 AND IsBoolean(Arguments[2])) CentsAsDigits=Arguments[2]; // Extract dollar and cent portions Dollars=Int(number); n=Find(".", number); if (n) { // There is a cents value Str=Trim(Mid(number, n+1, Len(number)-n)); if (Len(Str) IS 1) Cents=Str&"0"; else if (Len(Str) IS 2) Cents=Val(Str); else if (Len(Str) GTE 3) { Str=Left(Str, 2)&"."&Right(Str, Len(Str)-2); Cents=Round(Str); } } // Build result if (Dollars) Result=Result&NumberAsString(Dollars)&REQUEST.DStrs.space&IIf(Dollars IS 1, DE(REQUEST.DStrs.dollar), DE(REQUEST.DStrs.dollars)); if (Cents) { if (Dollars) Result=Result&REQUEST.DStrs.space&REQUEST.DStrs.and&REQUEST.DStrs.space; if (CentsAsDigits) Str=Cents; else Str=NumberAsString(Cents); Result=Result&Str&REQUEST.DStrs.space&IIf(Cents IS 1, DE(REQUEST.DStrs.cent), DE(REQUEST.DStrs.cents)); } return Result; } /** * Works like the built-in function DollarFormat, but does no rounding. * * @param inNum Number to format. (Required) * @param default_var Value to use if number isn't a proper number. (Optional) * @return Returns a string. * @author Shawn Seley (shawnse@aol.com) * @version 1, September 16, 2002 */ function DollarFormat2(inNum) { var out_str = ""; var decimal_str = ""; var default_value = inNum; if(ArrayLen(Arguments) GTE 2) default_value = Arguments[2]; if (not IsNumeric(inNum)) { return (default_value); } else { inNum = Trim(inNum); if(ListLen(inNum, ".") GT 1) { out_str = Abs(ListFirst(inNum, ".")); decimal_str = "." & ListLast(inNum, "."); } else if (Find(".", inNum) EQ 1) { decimal_str = inNum; } else { out_str = Abs(inNum); } if (out_str NEQ "") { // add commas out_str = Reverse(out_str); out_str = REReplace(out_str, "([0-9][0-9][0-9])", "\1,", "ALL"); out_str = REReplace(out_str, ",$", ""); // delete potential leading comma out_str = Reverse(out_str); } // add dollar sign (and parenthesis if negative) if(inNum LT 0) { return ("($" & out_str & decimal_str & ")"); } else { return ("$" & out_str & decimal_str); } } } /** * When given an email address this function will return the address in a format safe from email harvesters. * Minor edit by Rob Brooks-Bilson (rbils@amkor.com) * Update now converts all characters in the email address to unicode, not just the @ symbol. (by author) * * @param EmailAddress Email address you want to make safe. (Required) * @param Mailto Boolean (Yes/No). Indicates whether to return formatted email address as a mailto link. Default is No. (Optional) * @return Returns a string * @author Seth Duffey (sduffey@ci.davis.ca.us) * @version 2, May 2, 2002 */ function EmailAntiSpam(EmailAddress) { var i = 1; var antiSpam = ""; for (i=1; i LTE len(EmailAddress); i=i+1) { antiSpam = antiSpam & "&##" & asc(mid(EmailAddress,i,1)) & ";"; } if ((ArrayLen(Arguments) eq 2) AND (Arguments[2] is "Yes")) return "" & antiSpam & ""; else return antiSpam; } /** * Formats an e-mail address so that its domain is a link to its web site. * * @param theEmailAddress Email address. (Required) * @param theTarget Optional target for new window. (Optional) * @return Returns a string. * @author Shawn Seley (shawnse@aol.com) * @version 1, September 29, 2003 */ function emailDomainLink(theEmailAddress) { var this_username = listFirst(theEmailAddress, "@"); var this_domain = listLast(theEmailAddress, "@"); var theTarget = ""; if(arrayLen(arguments) gte 2) theTarget = arguments[2]; if(Len(theTarget) GT 0) return "#this_username#@#this_domain#"; else return "#this_username#@#this_domain#"; } /** * Applies a filter mask to a string. * * @param string String to be modified. (Required) * @param mask See Mask description above. (Required) * @param filter Option filter to apply before applying the mask. May be 'alpha', 'numeric', or 'alphanumeric'. Any characters not within the set specified are removed from the input before the mask is applied. (Optional) * @return Returns a string. * @author Joshua Olson (joshua@waetech.com) * @version 2, October 15, 2004 */ function FilterMask(value, mask) { var filter = ","; var t_value = ""; var pos = 1; var t_value_len = 0; var character = ""; var literal = 0; var char_at_pos = ""; var argc = ArrayLen(arguments); if (argc EQ 2) ArrayAppend(arguments,filter); filter = arguments[3]; t_value = value; value = ""; if (LCase(filter) IS "alphanumeric") t_value = REReplace(t_value, "[^[:alnum:]]", "", "ALL"); else if (LCase(filter) IS "numeric") t_value = REReplace(t_value, "[^[:digit:]]", "", "ALL"); else if (LCase(filter) IS "alpha") t_value = REReplace(t_value, "[^[:alpha:]]", "", "ALL"); t_value_len = Len(t_value); for (i=1; i LTE Len(mask); i = i + 1) { character = Mid(mask, i, 1); if (literal) { value = value & character; literal = "0"; } else { if (t_value_len GTE pos) char_at_pos = Mid(t_value, pos, 1); else char_at_pos = ""; pos = pos + 1; if (character IS "9") { if (IsNumeric(char_at_pos)) value = value & Val(char_at_pos); } else if (character IS "0") { value = value & Val(char_at_pos); } else if (character IS "_") { value = value & char_at_pos; } else if (character IS "A") { value = value & UCase(char_at_pos); } else if (character IS "a") { value = value & LCase(char_at_pos); } else if (character IS "B") { if (NOT IsNumeric(char_at_pos)) value = value & UCase(char_at_pos); } else if (character IS "b") { if (NOT IsNumeric(char_at_pos)) value = value & LCase(char_at_pos); } else if (character IS "\") { literal = 1; pos = pos - 1; } else { value = value & character; pos = pos - 1; } } } return value; } /** * Returns the number of times a pattern exists within a string. * Modified by Raymond Camden * Rewritten based on original UDF by Cory Aiken (corya@fusedsolutions.com) * * @param tString The string to check. * @param tsubString The string to look for. * @return Returns the number of occurrences. * @author Shawn Seley (shawnse@aol.com) * @version 3, March 20, 2002 */ function FindOccurrences(tString,tsubString){ if(not len(tString) OR not len(tsubString)) return 0; else { // delete all occurences of tString // and then calculate the number of occurences by comparing string sizes return ((len(tString) - len(replaceNoCase(tString, tsubString, "", "ALL"))) / len(tsubString)); } } /** * Remove extra characters from a form post added by Mac IE. * Changed attributes check to form[ check. * * @return Returns True. * @author Anthony Cooper (ant@bluevan.co.uk) * @version 2, February 7, 2003 */ function FixMacPost() { var thisField = ""; if (findNoCase("mac", cgi.HTTP_USER_AGENT) AND findNoCase("msie", cgi.HTTP_USER_AGENT)) { for (thisField in form) { if ((len(form[thisField]) GTE 2) AND NOT findNoCase(getTempDirectory(), form[thisField])) { form[thisField] = trim(form[thisField]); } } } return true; } /** * This is a workaround for the URLDecode bug that exists in CF5 and CFMX. * * @param string String to url decode. (Required) * @return Returns a string. * @author Anthony Petruzzi (tonyp@rolist.com) * @version 1, September 23, 2004 */ function fixURLDecode(string){ return URLDecode(ReReplaceNoCase(string, "%([^A-F0-9{2}])", "%25\1", "ALL")); } /** * Converts a string into "Flash" safe HTML. * * @param text Text to be converted. (Required) * @return Returns a string. * @author William Steiner (williams@hkusa.com) * @version 1, September 15, 2003 */ function FlashHTMLFormat(someText) { var returnText = someText; var listCount = 0; returnText = ReplaceNoCase(returnText, "#Chr(10)#", "", "ALL"); returnText = ReplaceNoCase(returnText, "

    ", "", "ALL"); returnText = StripCR(returnText); while (FindNoCase('
      ', returnText) neq 0) { while ((FindNoCase('
    ', returnText) gt FindNoCase('
  1. ', returnText)) AND (FindNoCase('
  2. ', returnText) neq 0)) { startSearchAt = FindNoCase('
      ', returnText); listCount = listCount + 1; // replaces the next
    1. with the correct number. if (listCount gt 9) returnText = ReplaceNoCase(returnText, "
    2. ", "
      #listCount#. "); else returnText = ReplaceNoCase(returnText, "
    3. ", "
      #listCount#. "); } // we are done with that list, get rid of the
        tag so we can find the next listCount = 0; returnText = ReplaceNoCase(returnText, "
          ", "
          ", "one"); returnText = ReplaceNoCase(returnText, "
        ", "

        ", "one"); } returnText = ReplaceNoCase(returnText, "
      1. ", "
        ", "ALL"); // Step xx, get rid of ALL
      2. ,
      , and tags returnText = ReplaceNoCase(ReplaceNoCase(ReplaceNoCase(returnText, "
    4. ", "", "ALL"), "
    ", "

    ", "ALL"), "", "

    ", "ALL"); // Step xx, REReplace statement changes the color attribute of the font tag to have // quotes around it...ActiveEdit strips them out :( returnText = REReplaceNoCase(returnText, "", "", "ALL"); returnText = REReplaceNoCase(returnText, "target=([A-Za-z0-9_]*)", "target=#Chr(34)#\1#Chr(34)#", "ALL"); returnText = REReplaceNoCase(returnText, "face=([A-Za-z0-9_ ]*)", "face=#Chr(34)#\1#Chr(34)#", "ALL"); returnText = REReplaceNoCase(returnText, "color=(#Chr(35)#[A-Za-z0-9]*)", "color=#Chr(34)#\1#Chr(34)#", "ALL"); returnText = REReplaceNoCase(returnText, "size=([A-Za-z0-9]*)", "size=#Chr(34)#\1#Chr(34)#", "ALL"); returnText = ReplaceNoCase(returnText, " ", " ", "ALL"); returnText = ReplaceNoCase(returnText, "&##39;", "'", "ALL"); returnText = ReplaceNoCase(returnText, "'", "'", "ALL"); returnText = ReplaceNoCase(returnText, "'", "'", "ALL"); returnText = ReplaceNoCase(returnText, """", "#Chr(34)#", "ALL"); returnText = ReplaceNoCase(returnText, """", "#Chr(34)#", "ALL"); returnText = ReplaceNoCase(returnText, "", "", "ALL"); returnText = ReplaceNoCase(returnText, "", "", "ALL"); returnText = ReplaceNoCase(returnText, "", "", "ALL"); returnText = ReplaceNoCase(returnText, "", "", "ALL"); return returnText; } /** * Function that formats a numeric list so that successive numbers are shown as a series. * * @param theList The list to parse. (Required) * @return Returns a string. * @author Mosh Teitelbaum (mosh.teitelbaum@evoch.com) * @version 1, June 4, 2004 */ function formatListAsSeries(theList) { var lastEle = ""; var isSet = false; var fList = ""; var currEle = ""; var idx = 0; for ( idx = 1; idx LTE ListLen(theList); idx = idx + 1 ) { currEle = ListGetAt(theList, idx); if ( Len(lastEle) EQ 0 ) { fList = fList & currEle; lastEle = currEle; isSet = false; } else if ( lastEle EQ currEle ) { //do nothing } else if ( lastEle + 1 NEQ currEle ) { if ( isSet ) { fList = fList & lastEle; } fList = fList & ", " & currEle; lastEle = currEle; isSet = false; } else { if ( NOT isSet ) { fList = fList & "-"; } lastEle = currEle; isSet = true; } } if ( isSet ) { fList = fList & lastEle; } return fList; } /** * Translates a 9 digit string into a social security number. * * @param string String to be modified. * @return Returns a string. * @author Rob Brooks-Bilson (rbils@amkor.com) * @version 1, July 16, 2001 */ function FormatSSN(str) { var SSN = ""; if (Not IsNumeric(str)) return "Error, str must be numeric"; if (Len(Str) NEQ 9) return "Error, str must be 9 digits long"; SSN = ReReplace(str,'([0-9]{3})([0-9]{2})([0-9]{4})','\1-\2-\3'); return SSN; } /** * Displays n number of characters from a string without cutting off in the middle of a word * Code used from FullLeft * * @param string String to be modified. (Required) * @param number Number of characters to include in teaser. (Required) * @param urlArgument URL to use for 'more' link. (Optional) * @return Returns a string. * @author Bryan LaPlante (blaplante@netwebapps.com) * @version 3, July 31, 2003 */ function FormatTeaser(string,number){ var urlArgument = ""; var shortString = ""; //return quickly if string is short or no spaces at all if(len(string) lte number or not refind("[[:space:]]",string)) return string; if(arrayLen(arguments) gt 2) urlArgument = "... [more]"; //Full Left code (http://www.cflib.org/udf.cfm?ID=329) if(reFind("[[:space:]]",mid(string,number+1,1))) { shortString = left(string,number); } else { if(number-refind("[[:space:]]", reverse(mid(string,1,number)))) shortString = Left(string, (number-refind("[[:space:]]", reverse(mid(string,1,number))))); else shortString = left(str,1); } return shortString & urlArgument; } /** * Returns either a formatted value or the passed default string. * * @param begin_str String to prepend to output. (Required) * @param str Variable to check. (Required) * @param end_str String to append to output. (Required) * @param default_str String to return if str is empty. (Required) * @return Returns a string. * @author Shawn Seley (shawnse@aol.com) * @version 1, June 26, 2002 */ function FormattedValueOrString(begin_str, str, end_str, default_str) { if (str IS "") return default_str; return begin_str & str & end_str; } /** * Strips HTML from all form fields. * Version 1.1 by Raymond Camden * * @param nostrip List of form fields that should not be modified. * @return Returns true. * @author Douglas Williams (klenzade@avondale.com) * @version 1.1, December 19, 2001 */ function FormStripHTML() { var nostrip = ""; if(arraylen(Arguments)) nostrip = Arguments[1]; if(structIsEmpty(form)) return; for (field in form) { if(NOT listfindnocase(nostrip, field)) form[field] = ReReplaceNoCase(form[field], "<[^>]*>", "", "ALL"); } return true; } /** * An enhanced version of left() that doesn't cut words off in the middle. * Minor edits by Rob Brooks-Bilson (rbils@amkor.com) and Raymond Camden (ray@camdenfamily.com) * * Updates for version 2 include fixes where count was very short, and when count+1 was a space. Done by RCamden. * * @param str String to be checked. * @param count Number of characters from the left to return. * @return Returns a string. * @author Marc Esher (jonnycattt@aol.com) * @version 2, April 16, 2002 */ function fullLeft(str, count) { if (not refind("[[:space:]]", str) or (count gte len(str))) return Left(str, count); else if(reFind("[[:space:]]",mid(str,count+1,1))) { return left(str,count); } else { if(count-refind("[[:space:]]", reverse(mid(str,1,count)))) return Left(str, (count-refind("[[:space:]]", reverse(mid(str,1,count))))); else return(left(str,1)); } } /** * Returns the page anchor from a specified URL. * * @param this_url URL to parse. * @return Returns a string. * @author Shawn Seley (shawnse@aol.com) * @version 1, February 21, 2002 */ function GetAnchorFromURL(this_url) { var re_found_struct = ""; this_url = trim(this_url); re_found_struct = REFind("##[^\?]*", this_url, 1, "True"); if (re_found_struct.pos[1] GT 0) { return Mid(this_url, re_found_struct.pos[1]+1, re_found_struct.len[1]-1); } else return ""; } /** * Gets the next text container (placeholder, tag, etc.) from a string as designated by starting and ending identifiers. * * @return Returns a structure. * @author Shawn Seley (shawnse@aol.com) * @version 0, October 2, 2002 */ function GetContainer(theString, startIdentifier, endIdentifier){ // some code based on Joshua Miller's RePlaceHolders() var startIdentifier_len = Len(startIdentifier); var endIdentifier_len = Len(endIdentifier); var container = StructNew(); var startIndex = 1; if(ArrayLen(Arguments) GTE 4) startIndex = Arguments[4]; container.start = 0; container.end = 0; container.len = 0; container.str = 0; container.contents = StructNew(); container.contents.start = 0; container.contents.end = 0; container.contents.len = 0; container.contents.str = 0; container.start = FindNoCase(startIdentifier, theString, startIndex); if (container.start GT 0) { container.end = FindNoCase(endIdentifier, theString, container.start+startIdentifier_len) + endIdentifier_len -1; container.len = container.end - container.start +1; container.str = Mid(theString, container.start, container.len); container.contents.start = container.start + startIdentifier_len; container.contents.end = container.end - endIdentifier_len; container.contents.len = container.contents.end - container.contents.start +1; container.contents.str = Mid(theString, container.contents.start, container.contents.len); } return container; } /** * Searches a string for email addresses. * Based on the idea by Gerardo Rojas and the isEmail UDF by Jeff Guillaume. * * @param str String to search. (Required) * @return Returns a list. * @author Raymond Camden (ray@camdenfamily.com) * @version 1, May 13, 2003 */ function getEmails(str) { var email = "(['_a-z0-9-]+(\.['_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.(([a-z]{2,3})|(aero|coop|info|museum|name)))"; var res = ""; var marker = 1; var matches = ""; matches = reFindNoCase(email,str,marker,marker); while(matches.len[1] gt 0) { res = listAppend(res,mid(str,matches.pos[1],matches.len[1])); marker = matches.pos[1] + matches.len[1]; matches = reFindNoCase(email,str,marker,marker); } return res; } /** * Returns the file name from a specified URL. * * @param this_url URL to parse. * @return Returns a string. * @author Shawn Seley (shawnse@aol.com) * @version 1, March 4, 2002 */ function GetFileFromURL(this_url) { var i = 0; var cnt = 0; var re_found_struct = ""; var this_file_name = ""; var num_dots = ""; this_url = trim(this_url); // find the last "/" character, after the scheme if(not Find("/", this_url)) { i=1; } else { if(Find("://", this_url)){ i = Find("://", this_url); cnt = Len(this_url) -i -2; if(cnt LT 1) cnt=1; this_url = Right(this_url, cnt); // now the scheme is chopped off } i = Len(this_url) - Find("/", Reverse(this_url)) +2; } re_found_struct = REFind("([^##\?]+\.[^##\?]+)", this_url, i, "True"); if (re_found_struct.pos[1] GT 0) { this_file_name = Mid(this_url, re_found_struct.pos[2], re_found_struct.len[2]); num_dots = (Len(this_file_name) - Len(Replace(this_file_name, ".", "", "ALL"))); if ( ((not Find("/", this_url)) and (num_dots GT 1)) or (FindOneOf("@:", this_file_name)) ){ // since this URL doesn't contain any "/" and since the "file" has two or more dots (".") // or if the filename contains a "@" or a ":" // then this filename is probably actually a host name return ""; } return this_file_name; } else { return ""; } } /** * Pass it a http_referer value and this fuction will parse out the keywords used to find it if referred from Google. * * @param referer The referer string to check. (Required) * @return Returns a string. * @author Matthew Fusfield (matt@fus.net) * @version 1, June 28, 2002 */ function getGoogleKeywords(referer) { var Keywords=''; var StartPos=0; var EndString=''; if (referer contains 'google.com') { StartPos=ReFindNoCase('q=.',referer); if (StartPos GT 0) { EndString=mid(referer,StartPos+2,Len(referer)); Keywords=ReReplaceNoCase(EndString,'&.*','','ALL'); Keywords=URLDecode(Keywords); } return Keywords; } else { return ''; } } /** * Returns the host from a specified URL. * RE fix for MX, thanks to Tom Lane * * @param this_url URL to parse. (Required) * @return Returns a string. * @author Shawn Seley (shawnse@aol.com) * @version 2, August 23, 2002 */ function GetHostFromURL(this_url) { var first_char = ""; var re_found_struct = ""; var num_expressions = 0; var num_dots = 0; var this_host = ""; this_url = trim(this_url); first_char = Left(this_url, 1); if (Find(first_char, "./")) { return ""; // relative URL = no host (ex: "../dir1/filename.html" or "/dir1/filename.html") } else if(Find("://", this_url)){ // absolute URL (ex: "pass@ftp.host.com">ftp://user:pass@ftp.host.com") re_found_struct = REFind("[^@]*@([^/:\?##]+)|([^/:\?##]+)", this_url, Find("://", this_url)+3, "True"); } else { // abbreviated URL (ex: "user:pass@ftp.host.com") re_found_struct = REFind("[^@]*@([^/:\?##]+)|([^/:\?##]+)", this_url, 1, "True"); } if (re_found_struct.pos[1] GT 0) { num_expressions = ArrayLen(re_found_struct.pos); if(re_found_struct.pos[num_expressions] is 0) num_expressions = num_expressions - 1; this_host = Mid(this_url, re_found_struct.pos[num_expressions], re_found_struct.len[num_expressions]); num_dots = (Len(this_host) - Len(Replace(this_host, ".", "", "ALL")));; if ((not FindOneOf("/@:", this_url)) and (num_dots LT 2)){ // since this URL doesn't contain any "/" or "@" or ":" characters and since the "host" has fewer than two dots (".") // then it is probably actually a file name return ""; } return this_host; } else { return ""; } } /** * Parses an HTML page and returns the title. * * @param str The HTML string to check. * @return Returns a string. * @author Raymond Camden (ray@camdenfamily.com) * @version 1, December 3, 2001 */ function GetHTMLTitle(str) { var matchStruct = reFindNoCase("<[[:space:]]*title[[:space:]]*>([^<]*)<[[:space:]]*/title[[:space:]]*>",str,1,1); if(arrayLen(matchStruct.len) lt 2) { writeoutput("error
    ");return ""; } return Mid(str,matchStruct.pos[2],matchStruct.len[2]); } /** * Converts Barcode to valid ISBN number (without "-"). * * @param BarCodeNum Bar code number. (Required) * @return Returns a string. * @author Amar Trivedi (atrivedi@ekomcorp.com) * @version 1, January 28, 2004 */ function getISBN(BarCodeNum) { var x =''; var sum = 0; var i = 0; var digitsum = 0; var ModSum=0; // Barcode Must be 13 digits AND numeric if(len(BarCodeNum) NEQ 13) return 0; if(not IsNumeric(BarCodeNum)) return 0; /** get rid of first 3 characters since they are NOT used for conversion **/ x = right(BarCodeNum,10); x = left(x,9); // loop through middle 9 digits for(i = 1; i LTE 9; i = i + 1) { digitsum = Mid( x, i, 1 ) * i; sum = sum + digitsum; } // check for the last letter/digit ModSum = sum MOD 11; if(ModSum EQ 10) ModSum = "x"; return x & ModSum; } /** * Parses an HTML string and returns META tag information. * Regex fix for names with spaces by Johan Steenkamp (johan@orbital.co.nz). * * @param str The string to check. (Required) * @return Returns an array. * @author Raymond Camden (ray@camdenfamily.com) * @version 3, October 24, 2003 */ function GetMetaHeaders(str) { var matchStruct = structNew(); var name = ""; var content = ""; var results = arrayNew(1); var pos = 1; var regex = ""; matchStruct = REFindNoCase(regex,str,pos,1); while(matchStruct.pos[1]) { results[arrayLen(results)+1] = structNew(); results[arrayLen(results)][ Mid(str,matchStruct.pos[2],matchStruct.len[2])] = Mid(str,matchStruct.pos[4],matchStruct.len[4]); results[arrayLen(results)].content = Mid(str,matchStruct.pos[7],matchStruct.len[7]); pos = matchStruct.pos[6] + matchStruct.len[6] + 1; matchStruct = REFindNoCase(regex,str,pos,1); } return results; } /** * Extracts the initials of a name from long string. * * @param str String to parse. (Required) * @return Returns a string. * @author Dimo Michailov (dmichailov@nospam.hotmail.com) * @version 1, May 9, 2003 */ function getNameInitials(str) { var newstr = ""; var word = ""; var i = 1; var strlen = listlen(str," "); for(i=1;i lte strlen;i=i+1) { word = ListGetAt(str,i," "); newstr = newstr & UCase(Left(word,1)); } return newstr; } /** * Returns the passed string with all non-numbers removed (letters, punctuation, whitespace, etc.). * * @param textStr String containing numbers you want returned. * @param allowDec Boolean (yes/no) indicating whether to preserve decimal points. Default is No. * @return Returns a number. * @author Mark Andrachek (hallow@webmages.com) * @version 1, December 18, 2001 */ function GetNumbers(textstr) { if (arraylen(arguments) GTE 2) { return REReplace(textstr,"[^0-9\.]",'','ALL'); } else { return REReplace(textstr,"[^0-9]",'','ALL'); } } /** * Returns the 2 character english text ordinal for numbers. * * @param num Number you wish to return the ordinal for. (Required) * @return Returns a string. * @author Mark Andrachek (hallow@webmages.com) * @version 1, November 5, 2003 */ function GetOrdinal(num) { // if the right 2 digits are 11, 12, or 13, set num to them. // Otherwise we just want the digit in the one's place. var two=Right(num,2); var ordinal=""; switch(two) { case "11": case "12": case "13": { num = two; break; } default: { num = Right(num,1); break; } } // 1st, 2nd, 3rd, everything else is "th" switch(num) { case "1": { ordinal = "st"; break; } case "2": { ordinal = "nd"; break; } case "3": { ordinal = "rd"; break; } default: { ordinal = "th"; break; } } // return the text. return ordinal; } /** * Returns the password from a specified URL. * * @param this_url URL to parse. * @return Returns a string. * @author Shawn Seley (shawnse@aol.com) * @version 1, February 21, 2002 */ function GetPasswordFromURL(this_url) { var first_char = ""; var re_found_struct = ""; this_url = trim(this_url); first_char = Left(this_url, 1); if (Find(first_char, "./")) { return ""; // relative URL = no password (ex: "../dir1/filename.html" or "/dir1/filename.html") } else if(Find("://", this_url)){ // absolute URL (ex: "pass@ftp.host.com">ftp://user:pass@ftp.host.com") re_found_struct = REFind("[^:]*:([^@]*@)", this_url, Find("://", this_url)+3, "True"); } else { // abbreviated URL (ex: "user:pass@ftp.host.com") re_found_struct = REFind("[^:]*:([^@]*@)", this_url, 1, "True"); } if (re_found_struct.pos[1] GT 0) { return Mid(this_url, re_found_struct.pos[2], re_found_struct.len[2]-1); } else { return ""; } } /** * Returns the path from a specified URL. * * @param this_url URL to parse. * @return Returns a string. * @author Shawn Seley (shawnse@aol.com) * @version 1, February 21, 2002 */ function GetPathFromURL(this_url) { var first_char = ""; var re_found_struct = ""; var path = ""; var i = 0; var cnt = 0; this_url = trim(this_url); first_char = Left(this_url, 1); if (Find(first_char, "./")) { // relative URL (ex: "../dir1/filename.html" or "/dir1/filename.html") re_found_struct = REFind("[^##\?]+", this_url, 1, "True"); } else if(Find("://", this_url)){ // absolute URL (ex: "pass@ftp.host.com">ftp://user:pass@ftp.host.com") re_found_struct = REFind("/[^##\?]*", this_url, Find("://", this_url)+3, "True"); } else { // abbreviated URL (ex: "user:pass@ftp.host.com") re_found_struct = REFind("/[^##\?]*", this_url, 1, "True"); } if (re_found_struct.pos[1] GT 0) { // get path with filename (if exists) path = Mid(this_url, re_found_struct.pos[1], re_found_struct.len[1]); // chop off the filename if(find("/", path)) { i = len(path) - find("/" ,reverse(path)) +1; cnt = len(path) -i; if (cnt LT 1) cnt =1; if (REFind("[^##\?]+\.[^##\?]+", Right(path, cnt))){ // if the part after the last slash is a file name then chop it off path = Left(path, i); } } return path; } else { return ""; } } /** * Returns the port number from a specified URL. * * @param this_url URL to parse. * @return Returns a string. * @author Shawn Seley (shawnse@aol.com) * @version 1, February 21, 2002 */ function GetPortFromURL(this_url) { var re_found_struct = ""; this_url = trim(this_url); re_found_struct = REFind("[^./].[^./:]+(:[[:digit:]]+)", this_url, 1, "True"); if (re_found_struct.pos[1] GT 0) { return Mid(this_url, re_found_struct.pos[2]+1, re_found_struct.len[2]-1); } else { return ""; } } /** * Returns a random alphanumeric string of a user-specified length. * * @param stringLenth Length of random string to generate. (Required) * @return Returns a string. * @author Kenneth Rainey (kip.rainey@incapital.com) * @version 1, February 3, 2004 */ function getRandString(stringLength) { var tempAlphaList = "a|b|c|d|e|g|h|i|k|L|m|n|o|p|q|r|s|t|u|v|w|x|y|z"; var tempNumList = "1|2|3|4|5|6|7|8|9|0"; var tempCompositeList = tempAlphaList&"|"&tempNumList; var tempCharsInList = listLen(tempCompositeList,"|"); var tempCounter = 1; var tempWorkingString = ""; //loop from 1 to stringLength to generate string while (tempCounter LTE stringLength) { tempWorkingString = tempWorkingString&listGetAt(tempCompositeList,randRange(1,tempCharsInList),"|"); tempCounter = tempCounter + 1; } return tempWorkingString; } /** * Returns the scheme from a specified URL. * * @param this_url URL to parse. * @return Returns a string. * @author Shawn Seley (shawnse@aol.com) * @version 1, February 21, 2002 */ function GetSchemeFromURL(this_url) { var i = 0; this_url = trim(this_url); i = Find("://", this_url, 1); if (i LT 1) { return ""; // relative url = no scheme (ex: "../dir1/filename.html" or "/dir1/filename.html") } else { return Left(this_url, i+2); // return the "://" and everything to the left of it } } /** * Returns the search part from a specified URL. * * @param this_url URL to parse. * @return Returns a string. * @author Shawn Seley (shawnse@aol.com) * @version 1, February 21, 2002 */ function GetSearchFromURL(this_url) { var re_found_struct = ""; this_url = trim(this_url); // the search part is simply everything after a "?" character re_found_struct = REFind("\?.*", this_url, 1, "True"); if (re_found_struct.pos[1] GT 0) { return Mid(this_url, re_found_struct.pos[1]+1, re_found_struct.len[1]); } else return ""; } /** * This UDF will take a Tab delimited text file and parse it into a mutlidimensional array * * @param x Tab text to parse. (Required) * @return Retuns an array. * @author Ray Bayly (rbayly@mediageneral.com) * @version 1, May 9, 2003 */ function GetTabTextFeed(X){ //Declare all variables used within this UDF var Xy = "";//This is an array that holds the lines var Xc = "";//this is the count for the number of lines var Yl = "";//This is a temp holder for the line var Yc = "";//This holds the length of the line bieng called var Yt = "";//this is an array that holds the line var i = 1; Xy = ArrayNew(1); Xc = ListLen(X, chr(10)); for(i=1;i LTE Xc;i=i+1){ Yl = ListGetAt(X, i, chr(10)); //Now I check for missing data Yl = replaceNoCase(Yl, " ", " NA ", "ALL"); Yl = replaceNoCase(Yl, " ", " NA ", "ALL"); Yl = replaceNoCase(Yl, " ", " NA NA ", "ALL"); //I know redundant code but for some reason it does not //catch all the tabs the first time through Yl = replaceNoCase(Yl, " ", " NA ", "ALL"); Yl = replaceNoCase(Yl, " ", " NA ", "ALL"); Yl = replaceNoCase(Yl, " ", " NA NA ", "ALL"); //Now we grab the size of the Line/List Yc = ListLen(Yl, chr(9)); //Set Yt as the array for the line Yt = ArrayNew(1); for(ix=1;ix LTE Yc;ix=ix+1){ //load each piece of text into an Array Dimension Yt[ix] = ListGetAt(Yl, ix, chr(9)); } //Add the New "Array Line" to the Master Array Xy[i] = Yt; } return Xy; } /** * Returns the content enclosed in a tag pair. * * @param tag The tag to look for. Should be passed without < or > and without attributes. (Required) * @param string The string to search. (Required) * @return Returns a string. * @author Johan Steenkamp (johan@orbital.co.nz) * @version 1, September 16, 2002 */ function getTagContent(tag,str) { var matchStruct = structNew(); var startTag = "<#tag#[^>]*>"; var endTag = ""; var endTagStart = 0; matchStruct = REFindNoCase(startTag,str,1,"true"); if(matchStruct.len[1] eq 0 ) return ""; endTagStart = REFindNoCase(endTag,str,matchStruct.pos[1],"false"); return Mid(str,matchStruct.pos[1]+matchStruct.len[1],endTagStart-matchStruct.pos[1]-matchStruct.len[1]); } /** * Returns the username from a specified URL. * Modified to handle differences in regex in cf5/mx. Thanks to Tom Lane for pointing out the issue. * * @param this_url URL to parse. (Required) * @return Returns a string. * @author Shawn Seley (shawnse@aol.com) * @version 2, August 23, 2002 */ function GetUsernameFromURL(this_url) { var first_char = ""; var re_found_struct = ""; var num_expressions = 0; this_url = trim(this_url); first_char = Left(this_url, 1); if (Find(first_char, "./")) { return ""; // relative URL = no username (ex: "../dir1/filename.html" or "/dir1/filename.html") } else if(Find("://", this_url)){ // absolute URL (ex: "pass@ftp.host.com">ftp://user:pass@ftp.host.com") re_found_struct = REFind("(([^:@]*:)[^:@]*@)|([^:@]*@)", this_url, Find("://", this_url)+3, "True"); } else { // abbreviated URL (ex: "user:pass@ftp.host.com") re_found_struct = REFind("(([^:@]*:)[^:@]*@)|([^:@]*@)", this_url, 1, "True"); } if (re_found_struct.pos[1] GT 0) { num_expressions = ArrayLen(re_found_struct.pos); if(re_found_struct.pos[num_expressions] is 0) num_expressions = num_expressions - 1; return Mid(this_url, re_found_struct.pos[num_expressions], re_found_struct.len[num_expressions]-1); } else { return ""; } } /** * Shortens a string without cutting words in half. * Modified by Raymond Camden on July 30, 2001 * * @param str The string to modify. * @param words The number of words to display. * @author David Grant (david@insite.net) * @version 2, July 30, 2001 */ function getWords(str,words) { var numWords = 0; var oldPos = 1; var i = 1; var strPos = 0; str = trim(str); str = REReplace(str,"[[:space:]]{2,}"," ","ALL"); numWords = listLen(str," "); if (words gte numWords) return str; for (i = 1; i lte words; i=i+1) { strPos = find(" ",str,oldPos); oldPos = strPos + 1; } if (len(str) lte strPos) return left(str,strPos-1); return left(str,strPos-1) & "..."; } /** * Converts a hex value to a string. * * @param hex Hex string. (Required) * @return Returns a string. * @author Michael Krock (michael.krock@avv.com) * @version 1, January 28, 2004 */ function hexToString(hex) { var str = ""; var i = 0; for (i=1; i LTE len(hex); i=i+2) { str = str & chr(inputBaseN(mid(hex,i,2),16)); } return str; } /** * Disguise a link using JavaScript's window.status attribute. * * @param href URL for the link. (Required) * @param display Text to disply in window.status. (Required) * @param caption Text for the link. (Required) * @return Returns a string. * @author Jeff Guillaume (jeff@kazoomis.com) * @version 1, September 20, 2002 */ function HideLink(href, display, caption) { var str = ""; str = ""; str = str & "#caption#"; return str; } /** * Applies a simple highlight to a word in a string. * Original version by Raymond Camden. * * @param string The string to format. (Required) * @param word The word to highlight. (Required) * @param front This is the HTML that will be placed in front of the highlighted match. It defaults to (Optional) * @param matchCase If true, the highlight will only match when the case is the same. Defaults to false. (Optional) * @return Returns a string. * @author Dave Forrest (dmf67@yahoo.com) * @version 2, June 12, 2003 */ function highLight(source,lookfor) { var tmpOn = "[;;^"; var tmpOff = "^;;]"; var hilightitem = ""; var endhilight = ""; var matchCase = false; var obracket = ""; var tmps = ""; var stripperRE = ""; var badTag = ""; var nextStart = ""; if(ArrayLen(arguments) GTE 3) hilightitem = arguments[3]; if(ArrayLen(arguments) GTE 4) endhilight = arguments[4]; if(ArrayLen(arguments) GTE 5) matchCase = arguments[5]; if(NOT matchCase) source = REReplaceNoCase(source,"(#lookfor#)","#tmpOn#\1#tmpOff#","ALL"); else source = REReplace(source,"(#lookfor#)","#tmpOn#\1#tmpOff#","ALL"); obracket = find("<",source); stripperRE = "<.[^>]*>"; while(obracket){ badTag = REFindNoCase(stripperRE,source,obracket,1); if(badTag.pos[1]){ tmps = Replace(Mid(source,badtag.pos[1],badtag.len[1]),"#tmpOn#","","ALL"); source = Replace(source,Mid(source,badtag.pos[1],badtag.len[1]),tmps,"ALL"); tmps = Replace(Mid(source,badtag.pos[1],badtag.len[1]),"#tmpOff#","","ALL"); source = Replace(source,Mid(source,badtag.pos[1],badtag.len[1]),tmps,"ALL"); nextStart = badTag.pos[1] + badTag.len[1]; } else nextStart = obracket + 1; obracket = find("<",source,nextStart); } source = Replace(source,tmpOn,hilightitem,"ALL"); source = Replace(source,tmpOff,endhilight,"ALL"); return source; } /** * Applies a simple highlight from and to a given position in a string. * version 2 by rcmamden * * @param str String to modify. (Required) * @param start Position to insert highlight. (Required) * @param end Position to end highlight. (Required) * @param startHi String to use for the beginning of the highlight. Defaults to (Optional) * @param endHi String to use for the end of the highlight. Defaults to (Optional) * @return Returns a string. * @author Scott Delatush (delatush@yahoo.com) * @version 2, September 24, 2002 */ function HighLightFromTo(str,start, end) { var startHi = ""; var endHi = ""; if(arrayLen(arguments) gte 4) startHi = arguments[4]; if(arrayLen(arguments) gte 5) endHi = arguments[5]; if(start gte (len(str) - 1)) return str; if(end gte len(str)) end = len(str); str = insert(startHi,str,start-1); str = insert(endHi,str,end+len(startHi)); return str; } /** * Formats a time difference in hours, minutes and seconds. * * @param time An integer representing a time duration. (Required) * @param type The type of the time duration. Defaults to milliseconds. (Optional) * @param mask Mask for HSMFormat. Defaults to "HH:MM:SS" (Optional) * @param displayMS Boolean to display milliseconds. Defaults to false. (Optional) * @return Returns a string. * @author Pascal Peters (ppeters@lrt.be) * @version 1, May 14, 2002 */ function HMSFormat(time) { var str = ""; var tmptime = 0; var h = 0; var m = 0; var s = 0; var sign = ""; // default values for optional parameters var type = "ms"; var mask = "HH:MM:SS"; var displayMs = false; if(ArrayLen(Arguments) gte 2) type = Arguments[2]; if(ArrayLen(Arguments) gte 3) mask = Arguments[3]; if(ArrayLen(Arguments) gte 4) displayMs = Arguments[4]; if(not IsNumeric(time)) return time; if(time lt 0){ time = Abs(time); sign = "-"; } switch(type){ case "h": h = int(time); tmptime = (time - h)*60; m = int(tmptime); s = (tmptime - m)*60; break; case "m": h = int(time/60); tmptime = time - h*60; m = int(tmptime); s = (tmptime - m)*60; break; case "s": h = int(time/3600); tmptime = time - h*3600; m = int(tmptime/60); s = tmptime - m*60; break; default: h = int(time/3600000); tmptime = time - h*3600000; m = int(tmptime/60000); tmptime = tmptime - m*60000; s = tmptime/1000; break; } m = NumberFormat(m,"00"); if(displayMs) s = NumberFormat(s,"00.000"); else s = NumberFormat(Round(s),"00"); str = Replace(mask,"HH",sign & h,"ALL"); str = Replace(str,"MM",m,"ALL"); str = Replace(str,"SS",s,"ALL"); return str; } /** * Replaces a huge amount of unnecessary whitespace from your HTML code. * * @param sInput HTML you wish to compress. (Required) * @return Returns a string. * @author Jordan Clark (JordanClark@Telus.net) * @version 1, November 19, 2002 */ function HtmlCompressFormat(sInput) { var level = 2; if( arrayLen( arguments ) GTE 2 AND isNumeric(arguments[2])) { level = arguments[2]; } // just take off the useless stuff sInput = trim(sInput); switch(level) { case "3": { // extra compression can screw up a few little pieces of HTML, doh sInput = reReplace( sInput, "[[:space:]]{2,}", " ", "all" ); sInput = replace( sInput, "> <", "><", "all" ); sInput = reReplace( sInput, " --------------------------------------------------------------------------------