From mboxrd@z Thu Jan 1 00:00:00 1970 From: Michael Tremer To: development@lists.ipfire.org Subject: Re: [PATCH] Remove unused snortupdateutility.js Date: Mon, 29 Mar 2021 11:35:21 +0100 Message-ID: In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============3629521832033469971==" List-Id: --===============3629521832033469971== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hello, > On 28 Mar 2021, at 13:23, Leo Hofmann wrote: >=20 > Hello Peter, >=20 > thank you for reviewing my work! >=20 > Unfortunately I don't know how to remove files during an update. Can you ta= ke over for me? Done. You normally do not have to worry about these things. A note in the com= mit message will help me to remember. Best, -Michael > Best regards > Leo >=20 > Am 27.03.2021 um 21:27 schrieb Peter M=C3=BCller: >> Hello Leo, >>=20 >> indeed, this is orphaned. Thank you for catching it. :-) >>=20 >> We probably need to remove it during the upgrading procedure of the Core U= pdate this patch will >> be included in, for good measures. >>=20 >> Acked-by: Peter M=C3=BCller >>=20 >> Thanks, and best regards, >> Peter M=C3=BCller >>=20 >>> This script doesn't seem to be maintained or used anywhere anymore. >>> The last reference to it was removed in commit 1772664. >>>=20 >>> Signed-off-by: Leo-Andres Hofmann >>> --- >>> config/rootfiles/common/web-user-interface | 1 - >>> html/html/include/snortupdateutility.js | 744 --------------------- >>> 2 files changed, 745 deletions(-) >>> delete mode 100644 html/html/include/snortupdateutility.js >>>=20 >>> diff --git a/config/rootfiles/common/web-user-interface b/config/rootfile= s/common/web-user-interface >>> index 9b2667676..540bf1e4b 100644 >>> --- a/config/rootfiles/common/web-user-interface >>> +++ b/config/rootfiles/common/web-user-interface >>> @@ -300,7 +300,6 @@ srv/web/ipfire/html/images/view-refresh.png >>> srv/web/ipfire/html/images/wakeup.gif >>> srv/web/ipfire/html/images/window-new.png >>> srv/web/ipfire/html/include >>> -srv/web/ipfire/html/include/snortupdateutility.js >>> srv/web/ipfire/html/include/zoneconf.js >>> srv/web/ipfire/html/index.cgi >>> srv/web/ipfire/html/redirect-templates >>> diff --git a/html/html/include/snortupdateutility.js b/html/html/include/= snortupdateutility.js >>> deleted file mode 100644 >>> index 10750519c..000000000 >>> --- a/html/html/include/snortupdateutility.js >>> +++ /dev/null >>> @@ -1,744 +0,0 @@ >>> -/* >>> -File Info: utility.js - JavaScript library >>> - >>> -Author: Drew S. Dupont >>> - >>> -Date: 2/26/2003 - 8/12/2004 (or present day) >>> - >>> -Description: Utility functions in JavaScript >>> - Drew S. Dupont >>> -*/ >>> -// Show/Hide HTML Span >>> -function showHideHTML(id, content) { >>> - // Browser variables >>> - var ie45, ns6, ns4, dom =3D false; >>> - >>> - // Basic browser parse >>> - if (navigator.appName =3D=3D "Microsoft Internet Explorer") { >>> - ie45 =3D parseInt(navigator.appVersion) >=3D 4; >>> - } else if (navigator.appName =3D=3D "Netscape") { >>> - ns6 =3D parseInt(navigator.appVersion) >=3D 5; >>> - ns4 =3D parseInt(navigator.appVersion) < 5; >>> - } >>> - dom =3D ie45 || ns6; >>> - >>> - // Return if using an old Netscape browser >>> - if(ns4) return; >>> - >>> - // Check for type of call supported >>> - el =3D document.all ? document.all[id] : dom ? document.getElementById(= id) : document.layers[id]; >>> - >>> - // Check if content to be "switched" is "" >>> - if (content =3D=3D "") { >>> - // Return old content and replace with "" >>> - content =3D el.innerHTML; >>> - el.innerHTML =3D ""; >>> - } else { >>> - // Replace current content with new content and return "" >>> - el.innerHTML =3D content; >>> - content =3D ""; >>> - } >>> - >>> - // Return content (either old or "") >>> - return content; >>> -} >>> - >>> -// Check for special chars >>> -function checkForSpecialChars(field, alphaStart, specialCheckChars) { >>> - // Local vars >>> - var alphaStartChars =3D /^[a-zA-Z]/; >>> - var noSpecialChars =3D /([^a-zA-Z0-9 _,?!':;\r\t\n\/\\\-\.#@]+)/; >>> - >>> - // Check if should start with an alpha char >>> - if (alphaStart) { >>> - // Make sure starts with a alpha char >>> - if (alphaStartChars.test(field.value)) { >>> - // Check for special chars >>> - if (noSpecialChars.test(field.value)) { >>> - // Return true >>> - return true; >>> - } else { >>> - // Check for specialCheckChars >>> - if (specialCheckChars && (specialCheckChars.test(field.value))) { >>> - // Return true >>> - return true; >>> - } else { >>> - // Return false >>> - return false; >>> - } >>> - } >>> - } else { >>> - // Return true >>> - return true; >>> - } >>> - } else { >>> - // Check if contains any special chars >>> - if (noSpecialChars.test(field.value)) { >>> - // Return true >>> - return true; >>> - } else { >>> - // Check for specialCheckChars >>> - if (specialCheckChars && (specialCheckChars.test(field.value))) { >>> - // Return true >>> - return true; >>> - } else { >>> - // Return false >>> - return false; >>> - } >>> - } >>> - } >>> -} // End checkForSpecialChars >>> - >>> -// Launch help >>> -function launchHelp(helpSrc) { >>> - helpWindow =3D window.open(helpSrc, "helpWindow", "resizable=3Dyes,menu= bar=3Dno,statusbar=3Dno,titlebar=3Dno,scrollbars=3Dyes,width=3D400,height=3D4= 00") >>> - helpWindow.moveTo(25, 25); >>> - helpWindow.focus(); >>> -} >>> - >>> -// Image On >>> -function imageOn(imageName) { >>> - document[imageName].src =3D eval(imageName + "_over.src"); >>> -} >>> - >>> -// Image Off >>> -function imageOff(imageName) { >>> - document[imageName].src =3D eval(imageName + ".src"); >>> -} >>> - >>> -// Image Down >>> -function imageDown(imageName) { >>> - document[imageName].src =3D eval(imageName + "_down.src"); >>> -} >>> - >>> -// Image button On >>> -function imageButtonOn(item, imageName) { >>> - item.src =3D eval(imageName + "_over.src"); >>> -} >>> - >>> -// Image button Off >>> -function imageButtonOff(item, imageName) { >>> - item.src =3D eval(imageName + ".src"); >>> -} >>> - >>> -// Image button Down >>> -function imageButtonDown(item, imageName) { >>> - item.src =3D eval(imageName + "_down.src"); >>> -} >>> - >>> -// changeStatus >>> -function changeStatus(message) { >>> - // Set window status >>> - window.status =3D message; >>> - >>> - // Return true >>> - return true; >>> -} // End changeStatus >>> - >>> -// isNumeric function >>> -function isNumeric(num) { >>> - // Boolean var >>> - var bolValidNum =3D true; >>> - var digits =3D "1234567890"; >>> - var len =3D num.length; >>> - >>> - // Loop over num >>> - for (i =3D 0; i < len; ++i) { >>> - numSub =3D num.substring(i, i + 1); >>> - >>> - // Test for numeric match >>> - if (digits.indexOf(numSub) =3D=3D -1) { >>> - bolValidNum =3D false; >>> - } >>> - } >>> - >>> - // Return boolean var >>> - return bolValidNum; >>> -} // End isNumeric >>> - >>> -// Check for numeric and display nice error >>> -function checkNumeric(field, message) { >>> - // Is it valid >>> - if (!isNumeric(field.value)) { >>> - alert(message); >>> - field.focus(); >>> - } >>> -} // End checkNumeric >>> - >>> -// Function getInt which return numeric value of passed in string >>> -function getInt(str, i, minlength, maxlength) { >>> - for (x =3D maxlength; x >=3D minlength; --x) { >>> - var token =3D str.substring(i, i + x); >>> - >>> - // Check for numeric >>> - if (isNumeric(token)) { >>> - return token; >>> - } >>> - } >>> - >>> - // Return null >>> - return null; >>> -} >>> - >>> -// Function dateCheck, requires global err variable for passing error me= ssages >>> -// and requires the isNumeric function >>> -function dateCheck(date, humanname, dateFormat) { >>> - // Date validation >>> - var date_s =3D date; >>> - >>> - // If no dateFormat, then set one >>> - if (dateFormat =3D=3D null) { >>> - format =3D "mm/dd/yyyy"; >>> - } else { >>> - format =3D dateFormat; >>> - } >>> - >>> - var date_err =3D 0; // Possible values are 0, 1 >>> - var date_year_err =3D 0; // Possible values are 0, 1 >>> - var date_month_err =3D 0; // Possible values are 1-12 >>> - var date_day_err =3D 0; // Possible values are 0, 1, 2, 3, 4 >>> - var i_date_s =3D 0; >>> - var i_format =3D 0; >>> - var err =3D ""; >>> - var c =3D ""; >>> - var token =3D ""; >>> - var token2 =3D ""; >>> - var x, y; >>> - var year =3D 0; >>> - var month =3D 0; >>> - var date =3D 0; >>> - var bYearProvided =3D false; >>> - var MONTH_NAMES =3D new Array('January','February','March','April','May= ','June','July','August','September','October','November','December','Jan','F= eb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); >>> - >>> - // Trim the leading spaces from the string >>> - while (date_s.charAt(0) =3D=3D ' ') { >>> - date_s =3D date_s.slice(1); >>> - } >>> - >>> - while (i_format < format.length) { >>> - // Get next token from format string >>> - c =3D format.charAt(i_format); >>> - token =3D ""; >>> - >>> - while ((format.charAt(i_format) =3D=3D c) && (i_format < format.length= )) { >>> - token +=3D format.charAt(i_format); >>> - ++i_format; >>> - } >>> - >>> - // Extract contents of value based on format token >>> - if ((token =3D=3D "yyyy") || (token =3D=3D "yy") || (token =3D=3D "y")= ) { >>> - if (token =3D=3D "yyyy") { x =3D 4; y =3D 4; } // 4-digit year >>> - if (token =3D=3D "yy") { x =3D 2; y =3D 2; } // 2-digit year >>> - if (token =3D=3D "y") { x =3D 2; y =3D 4; } // 2-or-4-digit year >>> - >>> - year =3D getInt(date_s, i_date_s, x, y); >>> - bYearProvided =3D true; >>> - >>> - if ((year =3D=3D null) || (year.length !=3D token.length)) { >>> - date_year_err =3D 1; >>> - } >>> - >>> - i_date_s +=3D year.length; >>> - } else { >>> - if (token =3D=3D "mmm") { // Month name >>> - month =3D 0; >>> - >>> - for (var i =3D 0; i < MONTH_NAMES.length; ++i) { >>> - var month_name =3D MONTH_NAMES[i]; >>> - >>> - if (date_s.substring(i_date_s, (i_date_s + month_name.length)).toLo= werCase() =3D=3D month_name.toLowerCase()) { >>> - month =3D i + 1; >>> - >>> - if (month > 12) { >>> - month -=3D 12; >>> - } >>> - >>> - i_date_s +=3D month_name.length; >>> - break; >>> - } >>> - } >>> - >>> - if ((month =3D=3D 0) || (month < 1) || (month > 12)) { >>> - date_month_err =3D 1; >>> - } >>> - } else { >>> - if ((token =3D=3D "mm") || (token =3D=3D "m")) { >>> - x =3D token.length; y =3D 2; >>> - month =3D getInt(date_s, i_date_s, x, y); >>> - >>> - if ((month =3D=3D null) || (month < 1) || (month > 12)) { >>> - date_month_err =3D 1; >>> - } >>> - >>> - i_date_s +=3D month.length; >>> - } else { >>> - if (token=3D=3D"dd" || token=3D=3D"d") { >>> - x =3D token.length; y =3D 2; >>> - date =3D getInt(date_s, i_date_s, x, y); >>> - >>> - if ((date =3D=3D null) || (date < 1) || (date > 31)) { >>> - date_day_err =3D 1; >>> - } >>> - >>> - i_date_s +=3D date.length; >>> - } else { >>> - if (date_s.substring(i_date_s, (i_date_s + token.length)) !=3D tok= en) { >>> - date_err =3D 1; >>> - } else { >>> - i_date_s +=3D token.length; >>> - } >>> - } >>> - } >>> - } >>> - } >>> - } >>> - >>> - // If there are any trailing characters left in the date_s, it doesn't = match >>> - if (i_date_s !=3D date_s.length) { >>> - date_err =3D 1; >>> - } >>> - >>> - // Is date valid for month? >>> - if ((month =3D=3D 4) || (month =3D=3D 6) || (month =3D=3D 9) || (month = =3D=3D 11)) { >>> - if (date > 30) { >>> - date_day_err =3D 2; >>> - } >>> - } else { >>> - if (month =3D=3D 2) { >>> - // Check for leap year >>> - if ((((year % 4) =3D=3D 0) && ((year % 100) !=3D 0)) || ((year % 400)= =3D=3D 0)) { >>> - // Leap year >>> - if (date > 29) { >>> - date_day_err =3D 3 >>> - } >>> - } else { >>> - if (date > 28) { >>> - date_day_err =3D 4; >>> - } >>> - } >>> - } else { >>> - if (date > 31) { >>> - date_day_err =3D 1; >>> - } >>> - } >>> - } >>> - >>> - // Add to the error message, if needed >>> - if (date_err !=3D 0) { >>> - err +=3D "\n - The " + humanname + " must be a valid date in the forma= t " + format + "."; >>> - } >>> - >>> - // Add to the error message, if needed >>> - if (date_month_err !=3D 0) { >>> - err +=3D "\n - The month must be between 1-12."; >>> - } >>> - >>> - // Add to the error message, if needed >>> - if (date_year_err !=3D 0) { >>> - err +=3D "\n - The " + humanname + " must have a valid year."; >>> - } >>> - >>> - // Add to the error message, if needed >>> - if (date_day_err !=3D 0) { >>> - switch (date_day_err) { >>> - case 1: >>> - err +=3D "\n - The month you entered in the " + humanname + " can on= ly have between 1 and 31 days."; >>> - break; >>> - case 2: >>> - err +=3D "\n - The month you entered in the " + humanname + " can on= ly have between 1 and 30 days."; >>> - break; >>> - case 3: >>> - err +=3D "\n - The month you entered in the " + humanname + " can on= ly have between 1 and 29 days in a Leap Year."; >>> - break; >>> - default: >>> - err +=3D "\n - The month you entered in the " + humanname + " can on= ly have between 1 and 28 days in a non-Leap Year."; >>> - break; >>> - } >>> - } >>> - >>> - return err; >>> -} // End dateCheck >>> - >>> -// Compares two MM/DD/YYY dates for less than (-1), equal to (0), or >>> -// greater than (1) >>> -function dateCompare(date1, date2) { >>> - var localDate1 =3D new Date(date1.substring(6,10), date1.substring(0,2)= , date1.substring(3,5)); >>> - var localDate2 =3D new Date(date2.substring(6,10), date2.substring(0,2)= , date2.substring(3,5)); >>> - >>> - // Greater than >>> - if (localDate1.getTime() > localDate2.getTime()) { >>> - return 1; >>> - } else { >>> - // Less than >>> - if (localDate1.getTime() < localDate2.getTime()) { >>> - return -1; >>> - } else { >>> - // Equal >>> - return 0; >>> - } >>> - } >>> -} // End dateCompare >>> - >>> -// All-purpose form validation script >>> -function checkForm(dataForm) { >>> - var msg =3D ""; >>> - var stripBlanksStart =3D /^\s+/g; >>> - var stripBlanksEnd =3D /\s+$/g; >>> - var squeezeBlanks =3D /\s+/g; >>> - var stripNonNumbers =3D /\D+/g; >>> - var stripNotDollars =3D /[^0-9\.]/g; >>> - var noSpaces =3D /\s+/g; >>> - var allNumbers =3D /^\d+$/; >>> - var zipCodeCheck =3D /^(\d{5})$|^(\d{5}-\d{4})$/; >>> - var passwordNumbers =3D /\d{1,}/; >>> - var passwordLetters =3D /\D{1,}/; >>> - var emailPattern =3D /^[a-zA-Z0-9]([a-zA-Z0-9_\-\.]*)@([a-zA-Z0-9_\-\.]= *)(\.[a-zA-Z]{2,3}(\.[a-zA-Z]{2}){0,2})$/i; >>> - var replaceSeps =3D /[-,\.\/]/g; >>> - var time24Format =3D /^(([0-1]?\d)|(2[0-3])):[0-5]\d(:([0-5]\d))?/; >>> - var time12Format =3D /^(\d|0\d|1[0-2]):[0-5]\d(:[0-5]\d)?( (A|P)\.?M\.?= )?/; >>> - var ipNetworkAddress =3D /^((\d{1,2}|[1]\d{2}|2[0-4]\d|25[0-5])(\.(\d{1= ,2}|[1]\d{2}|2[0-4]\d|25[0-5])){3}){1}((\/(0\.0\.0\.0|128\.0\.0\.0|192\.0\.0\= .0|224\.0\.0\.0|240\.0\.0\.0|248\.0\.0\.0|252\.0\.0\.0|254\.0\.0\.0|(255\.(0\= .0\.0|128\.0\.0|192\.0\.0|224\.0\.0|240\.0\.0|248\.0\.0|252\.0\.0|254\.0\.0|(= 255\.(0\.0|128\.0|192\.0|224\.0|240\.0|248\.0|252\.0|254\.0|(255\.(0|128|192|= 224|240|248|252|254|255))))))))|(\/(\d|[1-2]\d|3[0-2]))){0,1}$/; >>> - var ipNetworkPort =3D /^(\d{1,4}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|65= 5[0-2]\d|6553[0-5]){1}((\:|\-)(\d{1,4}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|65= 5[0-2]\d|6553[0-5])){0,1}$/; >>> - var passwordLength =3D 6; >>> - var error_fields =3D ""; >>> - var errors =3D ""; >>> - >>> - // Loop over form elements >>> - for (var i =3D 0; i < dataForm.length; ++i) { >>> - var element =3D dataForm.elements[i]; >>> - >>> - // Check for select box >>> - if (element.selectbox) { >>> - // Check for required >>> - if (element.required) { >>> - // Check for value >>> - if (element.options[element.selectedIndex].value =3D=3D "") { >>> - error_fields +=3D "\n - " + element.humanname + " requires a select= ion."; >>> - } >>> - } >>> - continue; >>> - } >>> - >>> - // Strip the leading and trailing blanks >>> - element.value =3D element.value.replace(stripBlanksStart, ''); >>> - element.value =3D element.value.replace(stripBlanksEnd, ''); >>> - >>> - // If it is required and is empty, alert >>> - if (element.required && (!element.value.length)) { >>> - error_fields +=3D "\n - " + element.humanname + " is required."; >>> - continue; >>> - } else { >>> - // If it isn't required and doesn't have any length, skip it >>> - if ((! element.required) && (! element.value.length)) { >>> - continue; >>> - } >>> - } >>> - >>> - // Check for special characters >>> - if (element.checkspecialchars) { >>> - if (checkForSpecialChars(element, element.alphaStart, element.special= Chars)) { >>> - error_fields +=3D "\n - " + element.humanname + " contains invalid c= haracters."; >>> - continue; >>> - } >>> - } >>> - =09 >>> - // Convert to uppercase if necessary >>> - if (element.uppercase) { >>> - element.value =3D element.value.toUpperCase(); >>> - } >>> - >>> - // Convert to uppercase if necessary >>> - if (element.lowercase) { >>> - element.value =3D element.value.toLowerCase(); >>> - } >>> - >>> - // UCFirst if necessary >>> - if (element.ucfirst) { >>> - // Squeeze the blanks >>> - rs =3D element.value.replace(squeezeBlanks, ' '); >>> - dsegs =3D rs.split(' '); >>> - element.value =3D ""; >>> - >>> - // Loop over chars >>> - for (j =3D 0; j < dsegs.length; ++j) { >>> - if (dsegs[j].length > 1) { >>> - fl =3D dsegs[j].substr(0, 1); >>> - fl =3D fl.toUpperCase(); >>> - rn =3D dsegs[j].substr(1); >>> - rn =3D rn.toLowerCase(); >>> - dsegs[j] =3D fl + rn; >>> - } >>> - >>> - // Check for first value >>> - element.value =3D j ? element.value + ' ' + dsegs[j] : dsegs[j]; >>> - } >>> - } >>> - >>> - // Check for equality test >>> - if (element.equalto) { >>> - // Check for truevalue and use if found, otherwise use value >>> - var elementValue1 =3D element.truevalue ? element.truevalue : element= .value; >>> - var elementValue2 =3D element.equaltovalue.truevalue ? element.equalt= ovalue.truevalue : element.equaltovalue.value; >>> - >>> - // Check for value equality >>> - if (elementValue1 !=3D elementValue2) { >>> - error_fields +=3D"\n - " + element.humanname + " is not the same as = " + element.equaltovalue.humanname; >>> - continue; >>> - } >>> - } >>> - >>> - // Check for less than >>> - if (element.lessthan) { >>> - // Check for truevalue and use if found, otherwise use value >>> - var elementValue1 =3D element.truevalue ? element.truevalue : element= .value; >>> - var elementValue2 =3D element.lessthanvalue.truevalue ? element.lesst= hanvalue.truevalue : element.lessthanvalue.value; >>> - >>> - // Check for values >>> - if ((elementValue1 !=3D '') && (elementValue2 !=3D '')) { >>> - // Check for value less than >>> - if (elementValue1 >=3D elementValue2) { >>> - error_fields +=3D"\n - " + element.humanname + " must be less than = " + element.lessthanvalue.humanname; >>> - continue; >>> - } >>> - } >>> - } >>> - >>> - // Check for less than equalto >>> - if (element.lessthanequalto) { >>> - // Check for truevalue and use if found, otherwise use value >>> - var elementValue1 =3D element.truevalue ? element.truevalue : element= .value; >>> - var elementValue2 =3D element.lessthanequaltovalue.truevalue ? elemen= t.lessthanequaltovalue.truevalue : element.lessthanequaltovalue.value; >>> - >>> - // Check for values >>> - if ((elementValue1 !=3D '') && (elementValue2 !=3D '')) { >>> - // Check for value less than equalto >>> - if (elementValue1 > elementValue2) { >>> - error_fields +=3D"\n - " + element.humanname + " must be less than = or equal to " + element.lessthanequaltovalue.humanname; >>> - continue; >>> - } >>> - } >>> - } >>> - >>> - // Check for greater than >>> - if (element.greaterthan) { >>> - // Check for truevalue and use if found, otherwise use value >>> - var elementValue1 =3D element.truevalue ? element.truevalue : element= .value; >>> - var elementValue2 =3D element.greaterthanvalue.truevalue ? element.gr= eaterthanvalue.truevalue : element.greaterthanvalue.value; >>> - >>> - // Check for values >>> - if ((elementValue1 !=3D '') && (elementValue2 !=3D '')) { >>> - // Check for value greater than >>> - if (elementValue1 <=3D elementValue2) { >>> - error_fields +=3D"\n - " + element.humanname + " must be greater th= an " + element.greaterthanvalue.humanname; >>> - continue; >>> - } >>> - } >>> - } >>> - >>> - // Check for greater than equalto >>> - if (element.greaterthanequalto) { >>> - // Check for truevalue and use if found, otherwise use value >>> - var elementValue1 =3D element.truevalue ? element.truevalue : element= .value; >>> - var elementValue2 =3D element.greaterthanequaltovalue.truevalue ? ele= ment.greaterthanequaltovalue.truevalue : element.greaterthanequaltovalue.valu= e; >>> - >>> - // Check for values >>> - if ((elementValue1 !=3D '') && (elementValue2 !=3D '')) { >>> - // Check for value greater than equalto >>> - if (elementValue1 < elementValue2) { >>> - error_fields +=3D"\n - " + element.humanname + " must be greater th= an or equal to " + element.greaterthanequaltovalue.humanname; >>> - continue; >>> - } >>> - } >>> - } >>> - >>> - // Check a price (sort of) >>> - if (element.price) { >>> - // Strip out currency stuff >>> - element.value =3D element.value.replace(stripNotDollars, ''); >>> - continue; >>> - } >>> - >>> - // Check a telephone number >>> - if (element.telephone) { >>> - // Strip out parens and spaces >>> - rs =3D element.value.replace(stripNonNumbers, ''); >>> - >>> - if (rs.length =3D=3D 7) { >>> - element.value =3D rs.substr(0, 3) + "-" + rs.substr(3, 4); >>> - } else { >>> - if (rs.length =3D=3D 10) { >>> - element.value =3D rs.substr(0, 3) + "-" + rs.substr(3, 3) + "-" + r= s.substr(6, 4); >>> - } else { >>> - error_fields +=3D "\n - " + element.humanname + " is an invalid tel= ephone number."; >>> - } >>> - } >>> - continue; >>> - } >>> - >>> - // Check a zip code >>> - if (element.zipcode) { >>> - if (!zipCodeCheck.test(element.value)) { >>> - error_fields +=3D"\n - " + element.humanname + " is an invalid zipco= de."; >>> - } >>> - continue; >>> - } >>> - >>> - // Check a password (sort of) >>> - if (element.password) { >>> - if (element.value.length < passwordLength) { >>> - error_fields +=3D "\n - " + element.humanname + " is too short"; >>> - error_fields +=3D "\n Minimum length is " + passwordLength + " = characters."; >>> - continue; >>> - } >>> - >>> - if (!passwordNumbers.test(element.value)) { >>> - error_fields +=3D "\n - " + element.humanname + " must contain at le= ast one number."; >>> - continue; >>> - } >>> - >>> - if (!passwordLetters.test(element.value)) { >>> - error_fields +=3D "\n - " + element.humanname + " must contain at le= ast one letter."; >>> - continue; >>> - } >>> - } >>> - >>> - // Check for all numbers >>> - if (element.numeric) { >>> - if (!allNumbers.test(element.value)) { >>> - error_fields +=3D "\n - " + element.humanname + " is not numeric."; >>> - } >>> - continue; >>> - } >>> - >>> - // Check an email address for validity >>> - if (element.email) { >>> - element.value =3D element.value.replace(noSpaces, ''); >>> - >>> - if (!emailPattern.test(element.value)) { >>> - error_fields +=3D "\n - " + element.humanname + " is not a valid ema= il address."; >>> - } >>> - continue; >>> - } >>> - >>> - // Check a date >>> - if (element.date) { >>> - error_fields +=3D dateCheck(element.value, element.humanname, element= .format); >>> - continue; >>> - } >>> - >>> - // Check a time >>> - if (element.time) { >>> - // Check for 24 hour time >>> - if (element.time24) { >>> - // Check for valid >>> - if (!time24Format.test(element.value)) { >>> - error_fields +=3D "\n - " + element.humanname + " is not a valid 24= hour time."; >>> - } >>> - } else { >>> - // Check for valid >>> - if (!time12Format.test(element.value)) { >>> - error_fields +=3D "\n - " + element.humanname + " is not a valid 12= hour time."; >>> - } >>> - } >>> - continue; >>> - } >>> - >>> - // Check the lengths >>> - if (element.minlen && (element.value.length < element.minlen)) { >>> - error_fields +=3D "\n - " + element.humanname + " is too short"; >>> - error_fields +=3D "\n Minimum length is " + element.minlen + " c= haracters."; >>> - continue; >>> - } >>> - >>> - if (element.maxlen && (element.value.length > element.maxlen)) { >>> - error_fields +=3D"\n - " + element.humanname + " is too long"; >>> - error_fields +=3D"\n Maximum length is " + element.maxlen + " ch= aracters."; >>> - continue; >>> - } >>> - >>> - // Check for ip/network address >>> - if (element.ipnetworkaddress) { >>> - if (!ipNetworkAddress.test(element.value)) { >>> - error_fields +=3D"\n - " + element.humanname + " is not a valid ip/n= etwork address"; >>> - } >>> - continue; >>> - } >>> - >>> - // Check for ip/network port >>> - if (element.ipnetworkport) { >>> - if (!ipNetworkPort.test(element.value)) { >>> - error_fields +=3D"\n - " + element.humanname + " is not a valid ip/n= etwork port"; >>> - } else { >>> - var searchChar =3D ""; >>> - var portArray =3D ""; >>> - >>> - if (element.value.indexOf(":") > -1) { >>> - searchChar =3D ":"; >>> - } else if (element.value.indexOf("-") > -1) { >>> - searchChar =3D "-"; >>> - } >>> - =09 >>> - if (searchChar !=3D '') { >>> - portArray =3D element.value.split(searchChar); >>> - >>> - if (portArray.length =3D=3D 2) { >>> - if (parseInt(portArray[0]) > parseInt(portArray[1])) { >>> - error_fields +=3D"\n - " + element.humanname + " can not have a s= tart port greater than an end port"; >>> - } >>> - } >>> - } >>> - } >>> - continue; >>> - } >>> - } >>> - >>> - // Check for any errors >>> - if (error_fields =3D=3D "") { >>> - return true; >>> - } else { >>> - msg =3D "The following fields have errors:\n"; >>> - msg +=3D error_fields; >>> - alert(msg); >>> - return false; >>> - } >>> -} >>> - >>> -// Clear data >>> -function clearData(field, data) { >>> - // Check if they equal >>> - if (field.value =3D=3D data) { >>> - // Clear data >>> - field.value =3D ''; >>> - } >>> -} >>> - >>> -// Set empty data >>> -function setEmptyData(field, data) { >>> - // Check if they equal >>> - if (! field.value.length) { >>> - // Clear data >>> - field.value =3D data; >>> - } >>> -} >>> - >>> -// Trim whitespace from beginning and end >>> -function trim(data) { >>> - var objRegExp =3D /^(\s*)$/; >>> - >>> - // Check for all spaces >>> - if (objRegExp.test(data)) { >>> - data =3D data.replace(objRegExp, ''); >>> - >>> - if (data.length =3D=3D 0) >>> - return data; >>> - } >>> - >>> - // Check for leading & trailing spaces >>> - objRegExp =3D /^(\s*)([\W\w]*)(\b\s*$)/; >>> - >>> - if (objRegExp.test(data)) { >>> - // Remove leading and trailing whitespace characters >>> - data =3D data.replace(objRegExp, '$2'); >>> - } >>> - >>> - return data; >>> -} >>>=20 --===============3629521832033469971==--