1 /* -------------------------------------------------------------------------- */
3 (c) 2005-2006 U.S. Robotics Corporation
5 /* -------------------------------------------------------------------------- */
7 /* --------------------------------------------------------------------------
9 Wireless info functions
14 This is called to set the visibility of fields on
15 the Status and Tutorial pages.
17 // initializeSecurity("<%ejGetWl(wlAuthMode)%>", "<%ejGetWl(wlWep)%>")
18 function initializeSecurity(strAuthMode, strWEPmode)
20 var method = getSecurityMethod(strAuthMode, strWEPmode);
21 if (method.indexOf("RADIUS") != -1)
23 // only show Encryption if also WPA
24 if (method.indexOf("WPA") != -1)
25 setVisibility("idEncrypt", true);
27 setVisibility("idRADIUSkey", true);
30 setVisibility("idKey8021x1", true);
31 setVisibility("idKey8021x2", true);
32 setVisibility("idKey8021x3", true);
34 else if (method.indexOf("WPA") != -1)
36 setVisibility("idEncrypt", true);
37 setVisibility("idKeyWPA", true);
39 else if (method.indexOf("WEP") != -1)
41 setVisibility("idKeyWEP", true);
45 // getSecurityMethod("<%ejGetWl(wlAuthMode)%>", "<%ejGetWl(wlWep)%>")
46 function getSecurityMethod(strAuthMode, strWEPmode)
51 if (strWEPmode == "enabled")
55 case "shared": return "WEP shared";
57 case "psk": return "WPA";
58 case "psk2": return "WPA2";
59 case "psk2mix": return "WPA2 and WPA";
61 case "wpa": return "WPA with 802.1x (RADIUS)";
62 case "wpa2": return "WPA2 with 802.1x (RADIUS)";
63 case "wpa2mix": return "WPA2 and WPA with 802.1x (RADIUS)";
64 case "radius": return "802.1x (RADIUS)";
66 default: return "None";
74 Return encryption method used for WPA or WEP
76 function getEncryption(strEncrypt)
80 case "aes": return "AES";
81 case "tkip": return "TKIP";
82 case "tkip+aes": return "AES and TKIP";
89 Return the WEP key specified by the current index.
91 function getWEPkey(strWEPkeyIx, strKey1, strKey2, strKey3, strKey4)
93 if (strWEPkeyIx == "")
96 var ixKey = parseInt(strWEPkeyIx);
97 if ((ixKey >= 1) && (ixKey <= 4))
99 var keys = new Array(strKey1, strKey2, strKey3, strKey4);
100 return keys[ixKey - 1];
106 function getWEPkeyType(strKey)
108 return getKeySize(strKey) + "-" + (isKeyASCII(strKey) ? "ASCII" : "hex");
116 This is called when the user changes a sub-type of
117 encryption (WEP ASCII 128-bit, WEP hex 64-bit, ...).
125 function setMaxLength(bClearValues, strType, eltKeys)
127 var bHex = ((strType == "type128hex") || (strType == "type64hex"));
130 if ((strType == "type64ASCII") || (strType == "type64hex"))
133 var iMaxLength = getKeyLength(iBits, bHex);
135 document.getElementById("idKeyNumChars").innerHTML = iMaxLength;
138 some page(s) might have only one key field,
139 instead of an array of them, so check for that
141 if (eltKeys.length == null)
143 eltKeys.maxLength = iMaxLength;
149 for (var i = 0; i < eltKeys.length; ++i)
151 eltKeys[i].maxLength = iMaxLength;
153 eltKeys[i].value = "";
160 /* --------------------------------------------------------------------------
162 General helper functions
167 This function tests the passed element's value for being inside
168 the passed range--inclusive. If it's not, it displays an error
169 and sets focus to the field...and returns false.
171 function inRange(strName, elt, min, max)
173 if ((elt.value == "") || (elt.value < min) || (elt.value > max))
175 alert("The " + strName + " setting must be between " + min + " and " + max + ", inclusive.");
183 This function tests the passed element's length for being at least the
184 passed number of characters. If it's not, it displays an error and sets
185 focus to the field...and returns false.
187 function minLength(strName, elt, min)
189 if (elt.value.length < min)
191 alert("The " + strName + " field must have at least " + min + " characters.");