return ret;
}
+
+
+function isValidKey(elt, size) {
+
+ if ( elt.value.length == size )
+ {
+ if ( size == 5 || size == 13 ) // ASCII key
+ return true;
+ // Kludge to fix Safari regex bug with Unicode escape sequences
+ var re = new RegExp("[^\\x30-\\x39\\x41-\\x46\\x61-\\x66]", "g");
+
+ var arMatch = elt.value.match(re);
+ // Most browsers return null; Safari returns an empty match object
+ if ((arMatch == null) || (arMatch.length == 0))
+ return true;
+ }
+ return false;
+}
-function isValidKey(val, size) {
- var ret = false;
- var len = val.length;
- var dbSize = size * 2;
- if ( len == size )
- ret = true;
- else if ( len == dbSize ) {
- for ( i = 0; i < dbSize; i++ )
- if ( isHexaDigit(val.charAt(i)) == false )
+function isValidHexKey(val, size) {
+ var ret = false;
+ if (val.length == size) {
+ for ( i = 0; i < val.length; i++ ) {
+ if ( isHexaDigit(val.charAt(i)) == false ) {
break;
- if ( i == dbSize )
+ }
+ }
+ if ( i == val.length ) {
ret = true;
- } else
- ret = false;
+ }
+ }
return ret;
}
return true;
}
+// same as is isNameUnsafe but allow spaces
+function isCharUnsafe(compareChar) {
+ var unsafeString = "\"<>%\\^[]`\+\$\,='#&@.:\t";
+
+ if ( unsafeString.indexOf(compareChar) == -1 && compareChar.charCodeAt(0) >= 32
+ && compareChar.charCodeAt(0) < 123 )
+ return false; // found no unsafe chars, return false
+ else
+ return true;
+}
+
+function isValidNameWSpace(name) {
+ var i = 0;
+
+ for ( i = 0; i < name.length; i++ ) {
+ if ( isCharUnsafe(name.charAt(i)) == true )
+ return false;
+ }
+
+ return true;
+}
+
function isSameSubNet(lan1Ip, lan1Mask, lan2Ip, lan2Mask) {
var count = 0;
return false;
}
+
function isValidIpAddress(address) {
var i = 0;
addrParts = address.split('.');
if ( addrParts.length != 4 ) return false;
-
for (i = 0; i < 4; i++) {
- num = parseInt(addrParts[i])
- if ( isNaN(num) )
+ if (isNaN(addrParts[i]) || addrParts[i] =="")
return false;
+ num = parseInt(addrParts[i]);
if ( num < 0 || num > 255 )
return false;
}
-
return true;
}
var zeroBitPos = 0, oneBitPos = 0;
var zeroBitExisted = false;
- if ( mask == '0.0.0.0' )
+ if ( mask == '0.0.0.0' || mask == "" )
return false;
maskParts = mask.split('.');
}
function isValidPort(port) {
+ if (port == "")
+ return false;
+
var fromport = 0;
var toport = 100;
if ( addrParts.length != 6 ) return false;
for (i = 0; i < 6; i++) {
+ if ( addrParts[i] == '' )
+ return false;
for ( j = 0; j < addrParts[i].length; j++ ) {
c = addrParts[i].toLowerCase().charAt(j);
if ( (c >= '0' && c <= '9') ||
return true;
}
-var hexVals = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
- "A", "B", "C", "D", "E", "F");
-var unsafeString = "\"<>%\\^[]`\+\$\,'#&";
+var hexVals = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F");
+var unsafeString = "\"<>%\\^[]`+$,'#&;/?:@=";
// deleted these chars from the include list ";", "/", "?", ":", "@", "=", "&" and #
// so that we could analyze actual URLs
+// Put all of the characters back in the string so encoding will work again. -skst (1 Feb 2006)
function isUnsafe(compareChar)
// this function checks to see if a char is URL unsafe.
else
newStr = newStr + convert(val.substring(i,i+1));
} else {
- // woopsie! restore.
- alert ("Found a non-ISO-8859-1 character at position: " + (i+1) + ",\nPlease eliminate before continuing.");
- newStr = original;
- // short-circuit the loop and exit
- i = len;
+ alert ("Found a non-ISO-8859-1 character at position " + (i+1) + ". Please delete this character.");
+//TODO: Nothing tests the return value. -skst (6 Feb 2006)
+ return original;
}
}
return retStr;
}
+
+// Web page manipulation functions
+
+function showhide(element, sh)
+{
+ var status;
+ if (sh == 1) {
+ status = "block";
+ }
+ else {
+ status = "none"
+ }
+
+ if (document.getElementById)
+ {
+ // standard
+ document.getElementById(element).style.display = status;
+ }
+ else if (document.all)
+ {
+ // old IE
+ document.all[element].style.display = status;
+ }
+ else if (document.layers)
+ {
+ // Netscape 4
+ document.layers[element].display = status;
+ }
+}
+
+// Load / submit functions
+
+function getSelect(item)
+{
+ var idx;
+ if (item.options.length > 0) {
+ idx = item.selectedIndex;
+ return item.options[idx].value;
+ }
+ else {
+ return '';
+ }
+}
+
+function setSelect(item, value)
+{
+ for (i=0; i<item.options.length; i++) {
+ if (item.options[i].value == value) {
+ item.selectedIndex = i;
+ break;
+ }
+ }
+}
+
+function setCheck(item, value)
+{
+ if ( value == '1' ) {
+ item.checked = true;
+ } else {
+ item.checked = false;
+ }
+}
+
+function setDisable(item, value)
+{
+ if ( value == 1 || value == '1' ) {
+ item.disabled = true;
+ } else {
+ item.disabled = false;
+ }
+}
+
+function submitText(item)
+{
+ return '&' + item.name + '=' + item.value;
+}
+
+function submitSelect(item)
+{
+ return '&' + item.name + '=' + getSelect(item);
+}
+
+
+function submitCheck(item)
+{
+ var val;
+ if (item.checked == true) {
+ val = 1;
+ }
+ else {
+ val = 0;
+ }
+ return '&' + item.name + '=' + val;
+}
+